How to correctly read video frames from webcam in linux?
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2013-1-20
编辑:Image Analyst
2013-1-20
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!