Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
raed bou aram
raed bou aram le 26 Juil 2015
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 commentaire
Stephen23
Stephen23 le 26 Juil 2015
Modifié(e) : Stephen23 le 26 Juil 2015
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.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 26 Juil 2015

Community Treasure Hunt

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

Start Hunting!

Translated by