Sheet Computer Vision
Sheet Computer Vision
DETEKSI WARNA
close all;
clear all;
clc;
vid=videoinput('winvideo',1, 'YUY2_160x120');
set(vid,'TriggerRepeat',Inf);
vid.returnedcolorspace='rgb';
vid.FrameGrabInterval=2;
start(vid)
SHEET COMPUTER VISION SK2
while(vid.FramesAcquired<=200)
data = getsnapshot(vid);
diff_im = imsubtract(data(:,:,3), rgb2gray(data));
diff_im = medfilt2(diff_im, [3 3]);
diff_im = im2bw(diff_im,0.16);
diff_im = bwareaopen(diff_im,100);
bw = bwlabel(diff_im, 8);
stats = regionprops(bw, 'BoundingBox', 'Centroid');
imshow(data)
hold on
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','r','LineWidth',1)
plot(bc(1),bc(2), '-m+')
a=text(bc(1)+15,bc(2),strcat('X:',num2str(round(bc(1))),'Y:',num2str(round(bc(2)))));
set(a,'FontName','Arial','FontWeight','bold','FontSize',12,'Color','Blue');
end
hold off
end
stop(vid)
DETEKSI GERAK
opticFlow = opticalFlowHS;
imshow(frameRGB)
hold on
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',25)
hold off