Ask Your Question

Revision history [back]

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

  • From the complete pool of possible features the most discriminative feature between pos and neg training set is determined.
  • That feature is used to train (in the default setting) a binary decision tree.
  • However a single tree might not do good enough to reach a weak classifier (from the paper, a weak classifier is a classifier that does a bit better then random guessing, so higher accuracy then 50%).
  • Therefore OpenCV combines stumps until the stumps combined reach the stage of a weak classifier existing out of multiple stump decision trees. Then it continues to the next stage.

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.

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

  • From the complete pool of possible features the most discriminative feature between pos and neg training set is determined.
  • That feature is used to train (in the default setting) a binary decision tree.
  • However a single tree might not do good enough to reach a weak classifier (from the paper, a weak classifier is a classifier that does a bit better then random guessing, so higher accuracy then 50%).
  • Therefore OpenCV combines stumps until the stumps combined reach the stage of a weak classifier existing out of multiple stump decision trees. Then it continues to the next stage.

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.