How to preview a webcam object in a figure (no preview window).

1 visualización (últimos 30 días)
PaoloB
PaoloB el 11 de Mzo. de 2015
Comentada: Peer Blumido el 7 de Jul. de 2017
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 comentario
Amith Mudugamuwa
Amith Mudugamuwa el 4 de Feb. de 2017
Hellow PaoloB,
I have the same problem. Could you find a way to get the video in GUI?
Thanks

Iniciar sesión para comentar.

Respuestas (1)

Peer Blumido
Peer Blumido el 7 de Jul. de 2017
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 comentario
Peer Blumido
Peer Blumido el 7 de Jul. de 2017
Instead of tab4 you have to write your figure. In my GUI i got an extra tab for the preview and capture the image.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by