[討論] (求救)Camera座標和影像座標的互動?已回收
camera視頻鏡頭看到紅色物體移動的座標 = bc
而我在視頻下放入一張白色影像 = bx
現在希望紅色物體移動時能和底下的白色影像互動
也就是說
bc座標移到(100,100),白色影像的(100,100)座標可以顯示黑點_
代表說互相有互動到
但是我在程式中 hold on 底下裡加入
if bc(100,100) = = bx(100,100)
bx(100,100) = 1
end
電腦卻告訴我
The expression to the left of the equals sign is not a valid target for an
assignment.
已經想很久了,不知道我哪裡搞錯??
原始碼:
clear all;
vid = videoinput('winvideo',1);
bx = ones(480,640);
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval = 5;
start(vid)
while(vid.FramesAcquired<=80)
data = getsnapshot(vid);
diff_im = imsubtract(data(:,:,1), rgb2gray(data));
diff_im = medfilt2(diff_im, [3 3]);
diff_im = im2bw(diff_im,0.29);
diff_im = bwareaopen(diff_im,680);
bw = bwlabel(diff_im,8);
bw = fliplr(bw);
stats = regionprops(bw, 'BoundingBox', 'Centroid');
imshow(bx)
hold on
for object = 1:length(stats)
bc = stats(object).Centroid;
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', 'black');
end
hold off
end
stop(vid);
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 120.96.47.236
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章