Ask Your Question

Revision history [back]

When going trough the forum in search of some guidance on train_cascade parameters, I finally found this unanswered question, which deserves some help. Mainly since most of the questions here are identical to some recently posted.

I will try to structure my answer, hopefully making it all clear to you!

ANSWER 1 : maxFalseAlarmRate

In the code you are suggesting, if(tempLeafFARate <= requiredLeafFARate), the leafFARate is not equal to the parameter maxFalseAlarmRate you are passing as an argument. Actually the leafFARate = (minHitRate) ^ (current leaf level). So if you are at the 4th layer of the current weak classifier, this means that you have standard (0.5) ^4 which is actually 0.0625. So if the element that is projected in the box, is lower than this value, training will be stopped.

MaximumFalseAlarmRate gives you the rate that needs to be achieved on your negative count. You will always end up with NEG amount:number. That number parameter actually needs to get lower than maxFalseAlarmRate ^ (current stage depth) in order to reach again a break parameter to stop training.

Try not to mess both parameters up.

ANSWER 2 : Samples unique

You could actually use different views of a currect object to train this BUT than only that exact object will be detectable. If you want a detector for a general class, than you need to add as many examples, with as much variation, as you can get your hands on.

Once you got the samples, you can use the create_samples utility, to create a unique vector of positive elements for training.

ANSWER 3 : numPos parameter

Again one that actually creates a lot of mistakes. It is actually the amount of positive images that is fed to your training stage. However, since it can be that a positive image is excluded from training after a while, you need to use a lower number than the actual number of elements in the vector file.

If you want to read the complete solution and discussion, read this:

If you want to accept that it is like this, take 0.9 x numberOfElements in the vector as numPos parameter, which works in 98% of the cases, or 0.8 x numberOfElements in the vector if you don't want to risk failing.

Acceptanceratio was just explained in answer 1. The details of all the small questions around the formula can be found in the links provided.

ANSWER 4 : PRECALCULATION TIME

Is the time needed to take the samples that will be used for that stage training and calculate corresponding features from them. This is necessary in order to apply the boosting algorithm which decides what feature will be the next to use in your classifier.

Again, the parameters appearing in the table are explained in answer 1, besides from the hit rate which is the amount of positive samples that are actually classified as positives.

ANSWER 5 : THE REST

About the parameters, this is more details about the structure that boosting will use to create your weak classifiers. Read more about adaBoost algorithm and it will be clear to you. However, leave them standard values if you do not want it to get complicated.

Do not expect TBB to speed up the process alot. It only creates a better performance for the precalculation time. The rest of the algorithm isn't optimized to work on multiple cores. If you want that, you will have to optimize the source code yourself. So getting a 90% workload on your CPU won't happen with the standard implementation.

Also about the long training, it all depends on the quality and amount of your samples. HAAR wavelet features can take up to weeks to train a classifier, where LBP are a bit faster, but can also take a long time. There is no quick training, except with limited dataset!

Cheers :)

When going trough the forum in search of some guidance on train_cascade parameters, I finally found this unanswered question, which deserves some help. Mainly since most of the questions here are identical to some recently posted.

I will try to structure my answer, hopefully making it all clear to you!

ANSWER 1 : maxFalseAlarmRate

In the code you are suggesting, if(tempLeafFARate <= requiredLeafFARate), the leafFARate is not equal to the parameter maxFalseAlarmRate you are passing as an argument. Actually the leafFARate = (minHitRate) (maxFalseAlarmRate ) ^ (current leaf level). So if you are at the 4th layer of the current weak classifier, this means that you have standard (0.5) (0.995) ^4 which is actually 0.0625. So if the element that is projected in the box, is lower than this value, 0.9801. If the false alarm rate goes below that, training will be stopped.

MaximumFalseAlarmRate gives you the rate that needs to be achieved on your negative count. You will always end up with NEG amount:number. That number parameter actually needs to get lower than maxFalseAlarmRate ^ (current stage depth) in order to reach again a break parameter to stop training.

Try not to mess both parameters up.

ANSWER 2 : Samples unique

You could actually use different views of a currect object to train this BUT than only that exact object will be detectable. If you want a detector for a general class, than you need to add as many examples, with as much variation, as you can get your hands on.

Once you got the samples, you can use the create_samples utility, to create a unique vector of positive elements for training.

ANSWER 3 : numPos parameter

Again one that actually creates a lot of mistakes. It is actually the amount of positive images that is fed to your training stage. However, since it can be that a positive image is excluded from training after a while, you need to use a lower number than the actual number of elements in the vector file.

If you want to read the complete solution and discussion, read this:

If you want to accept that it is like this, take 0.9 x numberOfElements in the vector as numPos parameter, which works in 98% of the cases, or 0.8 x numberOfElements in the vector if you don't want to risk failing.

Acceptanceratio was just explained in answer 1. The details of all the small questions around the formula can be found in the links provided.

ANSWER 4 : PRECALCULATION TIME

Is the time needed to take the samples that will be used for that stage training and calculate corresponding features from them. This is necessary in order to apply the boosting algorithm which decides what feature will be the next to use in your classifier.

Again, the parameters appearing in the table are explained in answer 1, besides from the hit rate which is the amount of positive samples that are actually classified as positives.

ANSWER 5 : THE REST

About the parameters, this is more details about the structure that boosting will use to create your weak classifiers. Read more about adaBoost algorithm and it will be clear to you. However, leave them standard values if you do not want it to get complicated.

Do not expect TBB to speed up the process alot. It only creates a better performance for the precalculation time. The rest of the algorithm isn't optimized to work on multiple cores. If you want that, you will have to optimize the source code yourself. So getting a 90% workload on your CPU won't happen with the standard implementation.

Also about the long training, it all depends on the quality and amount of your samples. HAAR wavelet features can take up to weeks to train a classifier, where LBP are a bit faster, but can also take a long time. There is no quick training, except with limited dataset!

Cheers :)