Displaying figures in a while Loop

7 visualizzazioni (ultimi 30 giorni)
Ryan
Ryan il 19 Ott 2015
Risposto: Walter Roberson il 20 Ott 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........

Risposte (1)

Walter Roberson
Walter Roberson il 20 Ott 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()

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by