[討論] 視頻中,找圓和正方形會有誤判?已回收
這個程式裡用在視頻中,圓和正方形老是會誤判,當然也有正確的時候,想請教
要如何把誤判率降到最低
vid = videoinput('winvideo', 1,'RGB24_640x480');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval = 5;
start(vid)
while (vid.FramesAcquired > -0.1)
z = zeros(480,640);
c = getsnapshot(vid);
gray = rgb2gray(c);
bw = im2bw(c,0.6);
bw = bwareaopen(bw,50);
[B,L] = bwboundaries(bw,'noholes'); % 二值圖像跟蹤區域邊界使用
STATS = regionprops(L,'BoundingBox','centroid','Extent'); % 計算圖像區域的重心
座標
flushdata(vid);
imshow(bw)
hold on
for i = 1 : length(STATS)
W(i) = uint8(abs(STATS(i).BoundingBox(3)-STATS(i).BoundingBox(4)) < 0.1);
W(i) = W(i) + 2 * uint8((STATS(i).Extent - 1) == 0 );
c = STATS(i).Centroid;
switch W(i)
case 1
plot(centroid(1),centroid(2),'wO'); 圓
case 2
plot(centroid(1),centroid(2),'wX');
case 3
plot(centroid(1),centroid(2),'wS'); 正方形
end
end
hold off
end
感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 120.96.35.54
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章