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

조회 수: 5 (최근 30일)
raed bou aram
raed bou aram 2015년 7월 26일
답변: Walter Roberson 2015년 7월 26일
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일

Community Treasure Hunt

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

Start Hunting!

Translated by