我目前正在使用 MATLAB 在"人群计数估计"中做一个项目。对于该项目,我需要在拥挤的图像(使用航空相机拍摄)中找到头部数量。我目前正在使用圆形霍夫变换来检测图像中的头部。
头部大小因海拔高度而异。因此,我以接受(image,Min_head_size,Max_head_size)作为参数的方式进行编码。头部大小将被视为圆的半径(圆形霍夫变换),并将检测该半径的圆。我已将阈值设置为(pi*radius)。
使用上述方法,我无法检测到所有头部。也有很多误报。我可以这样继续吗?有没有其他解决方案可以精确计算人头?
function Crowd_counter(img,r1,r2)
img1 = imread(img); %read the image
img=im2bw(img1,graythresh(img1)); %convert into binary
imgBW = edge(img); %'canny' edge detection
count=0;
FDetect = vision.CascadeObjectDetector; %for face detection
BB = step(FDetect,img1); %bounding box for face detect
for i=r1:r2
[ydetect,xdetect,Accumulator] = houghcircle(imgBW,i,(i*pi)); %circular hough
y{count+1}=ydetect; %storing y co-ordinates
x{count+1}=xdetect; %storing x co-ordinates
count=count+1;
i=i+1;
end
disp(count);
figure;
imshow(img1); %for visualizing detected heads
hold on;
crowd=0;
for j=1:count
crowd=crowd+length(x{j}); %for counting detected heads
plot(x{j},y{j},'.','LineWidth',2,'Color','red');
j=j+1;
end
disp('Number of heads:');
disp(crowd);
disp('Number of faces:');
disp(size(BB,1));
disp('Total');
disp(crowd+size(BB,1));
输入图像
输出自 Crowd_counter('51.jpg',3,7)
这似乎是一个不错的方法。我还没有尝试过这个,但从你的输出图像来看,似乎很多边缘都被错误地归类为头部。我的第一个想法是使用一个Hessian矩阵,就像HARRIS角探测器后续步骤中使用的矩阵可以帮助消除其中一些。这应该需要一些误报。我想弄清楚如何找到假阴性需要付出更多的努力。我想再次强调,我自己没有尝试过,只有当你觉得逻辑对你有意义时,我才会走这条路。