2

I'm implementing, for the first time, a sw for objects detection for static images. My first goal is to detect simple circles, then I'll move to more complex object. Unfortunately it seems I have problem when validating my classifier.

My choice was to use a HOG descriptor (using OpenCv) and a svm as classifier (using svmlight). The code compiles and works but there is something that sounds odd to me, probably concerning the svm.

I have:

  • a training set composed by 5 images 48x48px of different circles and 5 images 48x48px of non-circles (I know there are too few of them in order to have a solid classifier but, up to know, it's to test that everything works)
  • a test set composed by 4 images 48x48px (with circles as big as the ones used for the training) and 1 image much bigger (765x600px) with multiple size circles and other geometric forms.

What happens is that:

  • the circles in the test set are not detected when the images are 48x48, even if in the test set there are some images used in the training phase.
  • in the image 765x800 (which contains circles of any size) the circles which are of the same size of the training set, or bigger, are correctly identified.

I'm using the following parameters:

  • hog: winSize=48x48px, winStride=4x4px, cellSize=4px, blockSize=8px, blockStride=4x4px
  • classifier: svm regression with a linear classifier with C=0.01. (RBF results are worse than linear)

This is the api which performs the detections with the parameters I'm using.

vector<Rect> found;
double hitThreshold = 0.; // tolerance
Size padding(Size(32, 32));
double scale = 1.05;
int groupThreshold = 2;
hog.detectMultiScale(testImg, found, hitThreshold, win_stride, padding, scale, groupThreshold);

Is there any reason why the circles in the images 48x48px are not detected and the circles in the bigger image are detected? I expect 48x48px images to be correctly classified in order to validate the classifier. I have added the bigger image when nothing where detected in 48x48px images.

Besides, what sounds stranger is the fact that in the 48x48ps test set there are some images used in the training set and I think they must be identified, instead they are not! (I know that the training set and the test set must be different but I did that when nothing were detected.)

This is my first experience with hog descriptors and svm so it might not work because of a configuration error or the choice of the images..

Any help is welcome!

Thanks in advance :)

Vince
  • 21
  • 2
  • You said you use SVM in regression mode, have you tried by using it to simply classify each class as positive or negative? I often found useful when my SVM didn't work to take a quick look at the HOG feature vector values, it can give a rough idea of problems in the features.. – powder Jun 26 '14 at 13:15
  • imho, the testimages must be larger than the size the hog descriptor was trained on. (else the detectMultiScale approach fails) – berak Jun 26 '14 at 13:38
  • What is the size of the output hog descriptor? – GilLevi Jun 26 '14 at 14:20
  • Thank you all for your comments. @GilLevi do you refer to the size of the trained hog descriptors? that is: 4357 (4356+b value). – Vince Jun 26 '14 at 15:42
  • @powder I had tried to simply classify but it gives the same results. Now I'll try displaying the trained hog feature vectors. However the classifier works correclty, only with bigger images. I hope it's as berak says. – Vince Jun 26 '14 at 15:43
  • I mean, what is the dimension of the descriptor? – GilLevi Jun 26 '14 at 15:49
  • I'm not sure about the requirement of a bigger dimension in testing..I use SVM a lot (libSVM) and I always scale images to have the exact same dimension (100x100 pixels) in order to compensate for scale changes (mine is not a detector but a classifier though, so I do not require to search multiscale but the detection is provided by something else..) – powder Jun 27 '14 at 07:51
  • I think I may not have understood your question correctly..i'm sorry.. however, I'll try to answer: each train image returns a vector with hog descriptor of size 4356. For each cell 9 bins are computed. After the training a vector of size 4356 + the b value is generated – Vince Jun 27 '14 at 10:39
  • You could also try to apply some power normalization to your feature vectors, using linear svm it can help a lot (just do a sqrt() of your feature vector). I don't recall the exact paper but it's often used (http://www.cv-foundation.org/openaccess/content_cvpr_workshops_2014/W16/html/Alletto_From_Ego_to_2014_CVPR_paper.html just to link the first I found). Not sure if it's going to make the miracle but trying it doesn't hurt.. – powder Jun 27 '14 at 12:58

0 Answers0