How to replace "getsnapshot" with the button on my webcam?
이전 댓글 표시
I need to capture a picture from my webcam, but I want to do it with an external trigger. The preferred trigger is the webcam button, but I'm open for other suggestions.
I know how to open the preview window and use the getsnapshot to get a snapshot.
The code is as follows:
%%initially
clear
clc
close all
%%display image options
imaqhwinfo
%%define webcam and open camera window
vid = videoinput('winvideo', 1, 'RGB24_320x240');
preview(vid);
%%get snapshot
data = getsnapshot(vid);
What I want to do is substitute the getsnapshot(vid) with an endless loop that checks if I pressed the button. When that condition is satisfied, the loop breaks, and I continue with proccessing my image.
채택된 답변
추가 답변 (2개)
Siddharth Shankar
2011년 1월 30일
1 개 추천
What you are asking for is a "hardware trigger". You could check if your VIDEOINPUT object supports hardware triggers by using the TRIGGERINFO command. For ex:
triggerinfo(vid)
Most webcams I have worked with only have "immediate" as the trigger type.
One possibility is to connect a debouncer switch to your system via the serial port, or maybe a data acquisition card. You can then have a call to GETSNAPSHOT as soon as you detect a switch press. You can read more about trigger types for image acquisition devices here: Comparison of Trigger Types.
David Tarkowski
2011년 2월 18일
0 개 추천
Webcams don't expose access to their hardware buttons in a consistent manner, so there is no good way for us to expose those buttons as hardware trigger inputs.
I think that Jiro's suggestion of using a uicontrol is probably the best solution. In the callback for the uicontrol you would call getsnapshot and then call your processing routine.
카테고리
도움말 센터 및 File Exchange에서 Matrox Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!