Head detection using HOG and SVM I am currently trying to detect heads in a sequence of real-footage images and am using HOG feature descriptor and SVM as classifier.

Currently I am using Dalal's HOG implementation code in MATLAB found in this link:
http://www.mathworks.com/matlabcentral/fileexchange/46408-histogram-of-oriented-gradients--hog--code-using-matlab

Currently I am using libSVM MATLAB version found in this link:
http://www.csie.ntu.edu.tw/~cjlin/libsvm/

I prepared 350 positive training images and 1243 negative training images.

The hog feature vectors extracted from the training images are converted to libsvmFormat and inputted in the libsvm training method, to obtain a model. The hog vector length is that of 1764.

Regarding the libSVM I chose these as parameters:


-s 0  (i.e. C-SVC)
-c 1  (i.e. cost = 1)
-t 2  (i.e. kernel = RBF)
-g 3  (i.e. gamma = 3 (this is for kernel))


Regarding the HOG version, I left the cell, bin &amp; block parameters as they were in the implementation shown in the link above.

I am using a scanning window of size 128x128 and 256x256 to scan through the whole image to detect possible heads.  At each window, the hog feature vector is extracted for each image and is inputted in libsvm predict, to test whether it should be classified as a head or not.

However, after doing all the above, I have a numerous amount of false negatives and can't figure out what I am doing wrong. 

Can someone experience please offer some advice on what is possibly wrong?  I really need to figure this out please.  Much appreciated!
The thing to keep in mind here is that HOG is not invariant to in-plane rotation. A change in orientation of more than 10-15 degrees will probably throw it off.  So if your head can have different orientations in the image, you would either need to train multiple detectors or use something other than HOG.

By the way, there is a function extractHOGFeatures in the Computer Vision System Toolbox, and SVM is available in the Statistics Toolbox. See this example.

Edit: from your sample images it looks like in most cases you need to detect profile faces. vision.CascadeObjectDetector in the Computer Vision System Toolbox can do that for you. For greater robustness, I would run two detectors in succession: one for profile faces and one for frontal faces.  And also, HOG may not be your best choice here. For face detection Haar or LBP features generally work better.

No matter what you do, you will have some false negatives.  So, if you are using a video camera, I would also recommend tracking the faces.  See this example. This will give you an opportunity to correct mistakes made on individual frames.

Edit2: You can also train your own detector with trainCascadeObjectDetector, and you can use trainingImageLabeler app to label the positive samples.