Indrasyach
Indrasyach

Reputation: 147

HOG descriptor for multiple people detection

I am doing a real-time people detection using HOG-LBP descriptor and using a sliding window approach for the detector also LibSVM for the classifier. However, after classifier I never get multiple detected people, sometimes is only 1 or might be none. I guess I have a problem on my classification step. Here is my code on classification:

     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

For the whole my code, I have posted here : [HOG with SVM] (sliding window technique for multiple people detection)

I really need a help for it. Thx.

Upvotes: 0

Views: 1817

Answers (1)

phyrox
phyrox

Reputation: 2449

If you have problems wiith the sliding window, you can use this code:

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);

Upvotes: 2

Related Questions