How to preview a webcam object in a figure (no preview window).
3 次查看(过去 30 天)
显示 更早的评论
I am a little confused about the two different video objects that Matlab uses. On one hand one can create an image acquisition object and then preview it using
preview(obj)
which creates a preview window, or
preview(obj,himage)
which will display the preview in an image (for instance if you want to have the preview in your gui).
Then there are the "webcam" objects, which only allows to open the preview in a preview windows. I have tried to use the second format (obj, himage) with a webcam object and it works but the problem arises when you try to stop the stream (closePreview), as this will also destroy/close the container, and crash Matlab.
So my question: is there a way to have the webcam preview in a GUI?
Please also note that if I try to list the video objects in Matlab the webcam does not appear (it appears with webcamlist though).
Attached is a snippet of code that produces horrible consequences on Matlab (need to kill the process).
1 个评论
Amith Mudugamuwa
2017-2-4
Hellow PaoloB,
I have the same problem. Could you find a way to get the video in GUI?
Thanks
回答(1 个)
Peer Blumido
2017-7-7
Hi, if you mean to show your preview in a window inside your GUI figure. I used this. BildCamaxes is for you preview size in your figure.
BildCamaxes = axes(tab4,'Units','pixels','Position',[240,20,520,330]); vid = videoinput('winvideo',2); vidRes = vid.VideoResolution; nBands = vid.NumberOfBands; hImage = image(zeros(vidRes(2),vidRes(1), nBands),'Parent',BildCamaxes); preview(vid, hImage);
1 个评论
Peer Blumido
2017-7-7
Instead of tab4 you have to write your figure. In my GUI i got an extra tab for the preview and capture the image.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!