How to correctly read video frames from webcam in linux?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello guys, I am struggling with the getsnapshot function in Linux platforms. With the next code I am able to visualize the video from my webcam with the preview command, but the message "linuxvideo: A frame was dropped during acquisition." appears when I try to get an snapshot. Isn't it weird? What should I do to correctly acquire frames from the webcam?
clc, clear
vid = videoinput('linuxvideo',1);
set(vid,'FramesPerTrigger',1);
set(vid,'TriggerRepeat',Inf);
set(vid,'ReturnedColorSpace','rgb')
vidRes = get(vid, 'VideoResolution');
nBands = get(vid, 'NumberOfBands');
ax = preview(vid);
frame = getsnapshot(obj);
delete(vid);
0 Commenti
Risposta accettata
Image Analyst
il 20 Gen 2013
Modificato: Image Analyst
il 20 Gen 2013
You're getting one frame. But it's acquiring 30 frames a second or something like that. Who cares if one got dropped? You might try putting in a pause(0.1) after the preview() and before the getsnapshot() if you're trying to avoid warning messages - see if that gets rid of it. You need to wait about 4 frame times after you go live to get a good image. One frame needs to get thrown away because you have only a partial exposure. Then you get a good full exposure during the next frame time. The next frame, it gets transferred off the sensor to the image buffer to get ready for sending to the computer. The next frame time it gets digitized and sent over the signal cable to the computer's memory. So it may take a few frames for signal that you send to the camera to make it from the computer to the camera and then come back with an image.
And what is obj? Shouldn't it be vid:
frame = getsnapshot(vid);
0 Commenti
Più risposte (0)
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!