How to when I getdata from Video processing gets increasingly slow in GUI
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
if true
Table = zeros(1,17);
test = readtable ('datatrain.csv');
xdata = test(1:end,[12 13]);
train = table2array(xdata);
group1 = test(1:end,17);
group = table2array(group1);
% svmStruct = svmtrain(train,group,'kernel_function','rbf','ShowPlot',true);
svmStruct = svmtrain(train,group,'ShowPlot',false);
vid = webcam;
% preview(vid);
set(vid,'TriggerRepeat',Inf);
set(vid,'ReturnedColorSpace','grayscale');
vid.FrameGrabInterval = 3;
% Set value of a video source object property.
vid_src = getselectedsource(vid);
set(vid_src,'Tag','motion detection setup');
disp(sprintf(' FRAMING START from VIDEO'));
start(vid);
data2 = getdata(vid,1);
count = 0;
while(vid.FramesAcquired<=300)% Stop after 100 frames
data = getdata(vid,2);
% diff_im = imsubtract(data(:,:,:,1),data(:,:,:,2));
% diff_im = imsubtract(data2,data(:,:,:,1));
diff_im = abs((data2) - (data(:,:,:,1)));
for i=1:720
for j=1:1280
if(diff_im(i,j) <25)
diff_im(i,j)=diff_im(i,j)+0;
else
diff_im(i,j)=diff_im(i,j) + 255;
end
end
end
diff_im = imbinarize(diff_im,0.09);
% if sum(diff_im(:)>0)
diff_open = imfill(diff_im,'holes');
diff_open = bwareaopen(diff_open,25000,8);
diff_open = bwareaopen(diff_open,25000,8);
if sum(diff_open(:)==1)>10000
% imshow(diff_open);
% drawnow ;
[BWAREA,PERI,cen,Dispersion,height,width,aspect,upperRatio,lowerRatio,Ratio,theta] = AREAPICTURE (diff_open) ;
diff_im2 = imsubtract (data2,data(:,:,:,2));
diff_im2 = imbinarize(diff_im2,0.09);
[BWAREA2,PERI2,cen2,Dispersion2,height2,width2,aspect2,upperRatio2,lowerRatio2,Ratio2,theta2] = AREAPICTURE (diff_im2) ;
if (count == 0)
Angle = theta ;
Velocity = 0;
end
if (count == 1) && (theta <=70)
Angle = theta ;
end
Velocity = abs (Angle - theta);
Table(1,1)= BWAREA;
Table(1,2) = PERI;
Table(1,3) = cen(1,1);
Table(1,4) = cen(1,2);
Table(1,5)= Dispersion;
Table(1,6) = height;
Table(1,7) = width;
Table(1,8)= aspect;
Table(1,9) = upperRatio;
Table(1,10) = lowerRatio;
Table(1,11) = Ratio;
Table(1,12)= theta;
Table(1,13)= Velocity;
fid = fopen('datarealtime.csv','wt'); dlmwrite('datarealtime.csv', Table,'delimiter',',','-append'); fclose(fid); normaldata ('datarealtime.csv'); svm ('normaltorealtime.csv',svmStruct);
Angle=theta;
count=count+1;
%
end
% end
end stop(vid); delete(vid); clear vid; end
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu MATLAB Support Package for IP Cameras finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!