필터 지우기
필터 지우기

can i use 2 push buttons to start and stop this code of mine?

조회 수: 1 (최근 30일)
Sanjeev
Sanjeev 2013년 1월 21일
i tried using 2 push buttons to start and stop my video processing. But the GUI disappears as soon as i click start. whats seems to be the problem? here is the executable part of my code
clc;
close all;
clear all;
source = videoinput('winvideo');
set(source, 'ReturnedColorSpace', 'RGB');
set(source, 'FramesPerTrigger', 1);
set(source, 'TriggerRepeat', 50);
triggerconfig(source, 'manual');
start(source);
thresh = 15/255;
pause(2);
trigger(source);
bg = getdata(source,1,'double');
bg_bw = rgb2gray(bg);
fr_size = size(bg);
width = fr_size(2);
height = fr_size(1);
f = zeros(height, width);
for i=1:50
trigger(source);
fr=getdata(source,1,'double');
fr1=fr(:,:,:,1);
fr_bw1=rgb2gray(fr1);
bg_fr_diff = abs((double(bg_bw)) - (double(fr_bw1)));
for j=1:width % if fr_diff > thresh pixel in foreground
for k=1:height
if (bg_fr_diff(k,j) > thresh)
f(k,j) =255;
else
f(k,j) = 0;
end
end
end
figure(1),subplot(2,1,1),imshow(fr1)
subplot(2,1,2),imshow(uint8(f))
bg_bw=fr_bw1

채택된 답변

Walter Roberson
Walter Roberson 2013년 1월 21일
Get rid of the "clear all" and "close all".
  댓글 수: 2
Jan
Jan 2013년 1월 21일
+1. Another example for the negative effects of the excessively used brute clearing header. Who does beginners tell to extinguish all existing values before running some code?
Jan
Jan 2013년 4월 5일
I've accepted this answer. It would be better, if the OP cares about selecting an accepted answer or at least reply, if this solves the problem already.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by