Displaying figures in a while Loop
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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........
0 commentaires
Réponses (1)
Walter Roberson
le 20 Oct 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()
0 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!