Displaying figures in a while Loop

6 visualizaciones (últimos 30 días)
Ryan
Ryan el 19 de Oct. de 2015
Respondida: Walter Roberson el 20 de Oct. de 2015
Hi everybody,
I'm trying to run a while loop only when I'm receiving video from a webcam, and then stop the while loop when I manually 'x' out of the figure of the video feed. The way I'm currently doing it I always get an error when exit out of the video figure, and I've only figured out how to do it for a specified amount of time. Please help..
My current code is like this:
Video = videoinput('winvideo',2);
set(Video,'FramesPerTrigger',Inf);
set(Video,'ReturnedColorspace','grayscale');
start(Video)
while(Video.FramesAcquired <= Inf)
data = getsnapshot(Video)
imshow(data)
%AND SO ON........

Respuestas (1)

Walter Roberson
Walter Roberson el 20 de Oct. de 2015
Video = videoinput('winvideo',2);
set(Video,'FramesPerTrigger',Inf);
set(Video,'ReturnedColorspace','grayscale');
start(Video)
imhand = imshow(zeros(2,2)); %establish an image object
while(Video.FramesAcquired <= Inf)
data = getsnapshot(Video)
if ~isgraphics(imhand); break; end %image gone, user must have deleted it
set(imhand, 'CData', data);
end
stop(Video);
If you are using R2014a or earlier, replace isgraphics() with ishandle()

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by