0

我正在尝试通过检测和跟踪来自网络摄像头的视频中的红色对象并在空白背景上增加相应的强度值来制作虚拟绘图板。我正在使用此代码来跟踪红色对象

data = getsnapshot(vid);
diff_im = imsubtract(data(:,:,1), rgb2gray(data));  %find red regions in image

diff_im = medfilt2(diff_im, [3 3]);               %Use a median filter to filter out noise

diff_im = im2bw(diff_im,0.18);      % Convert the resulting grayscale image into a binary image.


diff_im = bwareaopen(diff_im,300);    % Remove all those pixels less than 300px,

[bw, count]  = bwlabel(diff_im, 8);

if(count > 0)
%% then draw rectangle around centroid of detected object

我正在检查每个像素,这会在图像尺寸增加时增加处理时间(即使是 640*480)。由于此输出对于许多帧都是空白的。我怎样才能改善它..??

4

0 回答 0