Ask Your Question

Revision history [back]

Question about calculation of positive and negative examples for training a LBP classifier and not getting stuck because of a wrong number of nPOS and nNEG.

This question is adressed to @Maria Dimashova in the first place, author of the traincascade algorithm (or of the original haar training algorithm in openCV). However, all other inputs are certainly welcome!

I found your suggesting of using the following equation to determine the numPos and numNeg elements for cascade training:

vec-file has to contain >= (numPose + (numStages-1) * (1 - minHitRate) * numPose) + S, where S is a count of samples from vec-file that can be recognized as background right away.

Assuming I have the following setup

  • 214 Positive images of cars to train a aerial detector
  • 10.000 Negative images of possible surroundings (to model the background)

I first use the create_samples utility in openCV to form a vector file with the positive images. This results in a vector of 214 images (all having a 28*56 resolution). The resulting vector file is stored as ouput.vec

I have a negative bg.txt file for defining negative images in negative folder.

I now want to determine the correct number of positives to assing to this traincascade using your suggested formula. This results in:

214 >= (numPose + (10-1) * (1 - 0.995) * numPose) + S.

I notice that the parameter S is described fairly vague. I would assume it would be 10.000 since that is the amount of bg files, but thats not possible, because it would result in a large negative result.

So could you specify more specific what this parameter S is? From the description you say, vector elements that can be determined as negatives right away. Does this mean that you have to include all the negatives into the createsamples algorithm to create a vector of 10.214 elements?

Guidance greatly appreciated!