用于多人检测的HOG描述符

时间:2014-05-17 06:33:43

标签: matlab image-processing video-processing matlab-cvst

我正在使用HOG-LBP描述符进行实时人员检测,并使用滑动窗口方法检测器和LibSVM用于分类器。然而,在分类后,我从来没有得到多个检测到的人,有时只有1或可能没有。我想我的分类步骤有问题。这是我的分类代码:

     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

对于我的整个代码,我已在此处发布:[HOG with SVM](sliding window technique for multiple people detection

我真的需要帮助。 THX。

1 个答案:

答案 0 :(得分:2)

如果您在滑动窗口方面遇到问题,可以使用this代码:

topLeftRow = 1;
topLeftCol = 1;
[bottomRightCol bottomRightRow d] = size(im);

fcount = 1;

% this for loop scan the entire image and extract features for each sliding window
for y = topLeftCol:bottomRightCol-wSize(2)   
    for x = topLeftRow:bottomRightRow-wSize(1)
        p1 = [x,y];
        p2 = [x+(wSize(1)-1), y+(wSize(2)-1)];
        po = [p1; p2];
        img = imcut(po,im);     
        featureVector{fcount} = HOG(double(img));
        boxPoint{fcount} = [x,y];
        fcount = fcount+1;
        x = x+1;
    end
end

lebel = ones(length(featureVector),1);
P = cell2mat(featureVector);
% each row of P' correspond to a window
[~, predictions] = svmclassify(P',lebel,model); % classifying each window

[a, indx]= max(predictions);