matlab滑动窗口法,matlab – 用于多人检测的滑动窗口技术

我正在研究用于检测人的视频监控应用程序.目前我正在实现HOG描述符作为检测器.但是,我有关于滑动窗口技术的问题.我的代码只能检测单个人.我也使用MexOpen CV中的Group Rectangles来创建多个边界框.有谁知道如何编写滑动窗口技术来检测多个对象?谢谢.

% Reading the image

im = strcat ('C:\Users\Documents\MATLAB\HOG\HOG\images\16.bmp');

im = imread (im);

win_size= [64, 128];

[lastRightCol lastRightRow d] = size(im);

counter = 1;

%% Scan the window by using sliding window object detection

% this for loop scan the entire image and extract features for each sliding window

% Loop on scales (based on size of the window)

for s=1:0.5:3

disp(strcat('s is',num2str(s)));

X=win_size(1)*s;

Y=win_size(2)*s;

for y = 1:X/4:lastRightCol-Y

for x = 1:Y/4:lastRightRow-X

p1 = [x,y];

p2 = [x+(X-1), y+(Y-1)];

po = [p1; p2] ;

% Croped image and scan it.

crop_px = [po(1,1) po(2,1)];

crop_py = [po(1,2) po(2,2)];

topLeftRow = ceil(min(crop_px));

topLeftCol = ceil(min(crop_py));

bottomRightRow = ceil(max(crop_px));

bottomRightCol = ceil(max(crop_py));

cropedImage = img(topLeftCol:bottomRightCol,topLeftRow:bottomRightRow,:);

% Get the feature vector from croped image using HOG descriptor

featureVector{counter} = getHOGDescriptor(img);

boxPoint{counter} = [x,y,X,Y];

count = counter+1;

x = x+2;

end

end

end

label = ones(length(featureVector),1);

P = cell2mat(featureVector);

% each row of P' correspond to a window

% classifying each window

[~, predictions] = svmclassify(P', label,model);

% set the threshold for getting multiple detection

% the threshold value is 0.7

get_detect = predictions.*[predictions>0.6];

% the the value after sorted

[r,c,v]= find(get_detect);

%% Creating the bounding box for detection

for ix=1:length(r)

rects{ix}= boxPoint{r(ix)};

end

if (isempty(rects))

rects2=[];

else

rects2 = cv.groupRectangles(rects,3,'EPS',0.35);

end

for i = 1:numel(rects2)

rectangle('Position',[rects2{i}(1),rects2{i}(2),64,128], 'LineWidth',2,'EdgeColor','y');

end

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值