What are Stages in traincascade.exe?
We are using 125 positive test images and 250 negative images. How many stages we should put to train the classifier? What if we give 1 stage only?
We are using 125 positive test images and 250 negative images. How many stages we should put to train the classifier? What if we give 1 stage only?
To completely understand stages you should first read the Viola and Jones paper which discusses the principle of cascade classifiers which is a combination of weak classifiers to obtain a strong classifier. However compared to the official implementation, OpenCV has a slight addition, which are stages.
Basically
Now how to define how much stages you need? Start by adding for example 25 stages, and see how the returned acceptanceRatio
is small enough. I usually suggest until it goes below 10^-5. After that you are overfitting the actual model from my experience. I implemented an overload function that allows adding a acceptanceRatioBreakValue
. Take a look here.
Addition: if you want a complete wrapup of the traincascade parameters and useful settings, you can get the just released book OpenCV 3 Blueprints which has a complete chapter discussing the interface.
Matlab Cascade Classifier is a wrapper over OpenCV one. There is a good tutorial for Matlab classifier.
Total hit and false alarm rates calculated using hit (stageHR) and false alarm (stageFAR) rates for each stage:
totalHR = stageHR^NumStages;
totalFAR = stageFAR^NumStages.
Thus values of hit and false alarm rates for each stage depend on number of stages.
Number of stages influences the amount of training data: number of positive samples to use at each stage can be estimated using the following formula (see link):
number of positive samples = floor(totalPositiveSamples / (1 + (NumStages- 1) * (1 - stageHR)))
Following information is useful for choosing a number of stages:
-1 Sorry but please explain to me how posting a link of a wrapper, which is not officially supported would help to solve this problem ...
@StevenPuttemans in fact the link has a pretty good high-level and easy-to-understand description of Cascade Classifiers. Though I agree it should be pointed more clearly that it's just a link to get a grasp of the theory
@LorenaGdL I agree, but just copy pasting links without a deeper explanation is not what we want to aim for here :D So I rather have him updating the answer with specific guidelines from that cite and refer to it, rather then just posting a link. Also, it still contains HOG features, which are removed in OpenCV.
Yes. I agree. Link only answer is not a good answer. I made my answer a bit larger :)
Asked: 2015-11-24 07:05:32 -0600
Seen: 3,061 times
Last updated: Nov 25 '15