2
votes

I am doing a project to detect people in crowd using HOG-LBP. I want to make it for real-time application. I've read in some references, integral image/histogram can increase the speed of the performance from sliding window detection. I want to ask, how to implement integral image on my sliding window detection:

here is the code for integral image from matlab:

A = (cumsum(cumsum(double(img)),2));

and here my sliding window detection code:

im = strcat ('C:\Documents\Crowd_PETS09\S1\L1\Time_13-57\View_001\frame_0150.jpg');
im = imread (im);


figure (1), imshow(im);

win_size= [32, 32];

[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
    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

            %get four points for boxes
            p1  = [x,y];
            p2  = [x+(X-1), y+(Y-1)];
            po  = [p1; p2] ;

            % cropped image based on the four points
            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    = im(topLeftCol:bottomRightCol,topLeftRow:bottomRightRow,:);

            %Get the feature vector from croped image
            HOGfeatureVector{counter}= getHOG(double(cropedImage));
            LBPfeatureVector{counter}= getLBP(cropedImage);
            LBPfeatureVector{counter}= LBPfeatureVector{counter}';
            boxPoint{counter} = [x,y,X,Y];
            counter = counter+1;
            x = x+2;

        end
    end
end

where should i put the integral image code?

i am really appreciate, if someone can help me to figure it out.

Thank you.

1
I wouldn't use matlab for real timezenpoy
1) A ) is missing. 2) The best way to find an implementation is to read more books and learn more about what you are working on.Yvon
why? but I think, it will still work with matlab, wont it? do you have any idea for it? @zenpoyIndrasyach
oo yeah it is just small mistake, forget while wrote it. I have read some references and understood. but it seems hard for me when i should apply on the code. that's why i asked to some experts, hopefully they can help me. @YvonIndrasyach
I didn't say it won't work. But you should expect a nice x5 to x100 performance boost when implementing the sane algorithm in c++. Espezenpoy

1 Answers

1
votes

The integral image is most suited for the Haar-like features. Using it for HOG or LBP would be tricky. I would suggest to first get your algorithm working, and then think about optimizing it.

By the way, the Computer Vision System Toolbox includes the extractHOGFeatures function, which would be helpful. Here's an example of training a HOG-SVM classifier to recognize hand-written digits. Also there is a vision.PeopleDetector object, which uses a HOG-SVM classifier to detect people. You could either use it directly for your project, or use it to evaluate performance of your own algorithm.