Search code examples
matlabimage-processingsvmmatlab-cvstsliding-window

Matlab Image Processing Sliding Window SVM


I am trying to create a object detection SVM that can detect remote control calls rolling slowly on the floor. i am using HOG cpp script in matlab (via mex) and the SVM-Light library (http://svmlight.joachims.org/)

i was wondering how i could go about detecting the cars if they are closer to the camera (i know that i need to have different sized windows im just not sure how to implement it) and how to tell SVM not to detect anything if it cannot see a car.There will only be one car in the frame at all times. I am using a Matlab 2012a. I was also wondering on how to speed up the Sliding window algorithm and also was wondering if the size of the training images will affect the results dramatically.

here is my sliding window code

[bottomRightCol bottomRightRow d] = size(im);

fcount = 1;

for y = 1:bottomRightCol-wSize(2)    
    for x = 1:bottomRightRow-wSize(1)
        img = imcut([[x,y]; [x+(wSize(1)-1), y+(wSize(2)-1)]],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);
[~, predictions] = svmclassify(P',lebel,model);
[a, indx]= max(predictions);
bBox = cell2mat(boxPoint(indx));
rectangle('Position',[bBox(1),bBox(2),wSize(1),wSize(2)],'LineWidth',3, 'EdgeColor','r');

sorry about all the questions but any help or advice would be greatly appreciated

Cheers :D


Solution

  • The Computer Vision System Toolbox lets you train a cascade object detector The cascade object detector also uses the sliding window approach, but it uses a cascade of boosted classifiers, rather than an SVM. Also, you would need a more recent version of MATLAB, because this functionality is not available in R2012a.

    You can also try a different approach. If your camera is stationary, you can detect moving objects (your cars) using background subtraction. The Computer Vision System Toolbox includes the vision.ForegroundDetectorObject, which is available in R2012a.