How i can loop a video until a button is pushed or a condition is given?

2 次查看(过去 30 天)
I have my code already set down. but i am having problems with telling Matlab how I can continues executing the code until the user closes the video, or Give it a condition for stopping.
vid=videoinput('winvideo',1);
figure(3);preview(vid);
set(vid,'ReturnedColorspace','rgb')
img = getsnapshot(vid);
figure (2); imagesc(img);
red = img(:,:,1); % Canal Rojo
green = img(:,:,2); % Canal Verde
blue = img(:,:,3); % Canal Azul
a = zeros(size(img, 1), size(img, 2));
just_red = cat(3, red, a, a);
just_green = cat(3, a, green, a);
just_blue = cat(3, a, a, blue);
I= just_red - just_green;
I2=im2bw(I, graythresh(I));
I3= bwareaopen(I2, 100);
se=strel('disk',6);
I4=imclose(I3,se);
Ic=imfill(I4,'holes');
I tried with a toggle button, but i a newbie, and i know nothing about programming.
Thanks, Alex
  1 个评论
Stephen23
Stephen23 2015-7-26
编辑:Stephen23 2015-7-26
This time I formatted your code for you, but in future you can do this yourself by simply selecting the code and then pressing the {} Code button that you will find above the textbox. And please do not put empty lines between every line of your code: this is a waste of your time and ours.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2015-7-26

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by