OpenCV Haar Classifier result table explanation
Asked Answered
H

1

14

I am trying to create a Haar classifier to recognise objects however I can't seem to figure out what the results table that is produced at each stage stands for.

E.g. 1

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   700 : 700
NEG count : acceptanceRatio    2500 : 0.452161
Precalculation time: 9
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|        1|
+----+---------+---------+
|   5|        1|   0.7432|
+----+---------+---------+
|   6|        1|   0.6312|
+----+---------+---------+
|   7|        1|   0.5112|
+----+---------+---------+
|   8|        1|   0.6104|
+----+---------+---------+
|   9|        1|   0.4488|
+----+---------+---------+
END>

E.g. 2

===== TRAINING 2-stage =====
<BEGIN
POS count : consumed   500 : 500
NEG count : acceptanceRatio    964 : 0.182992
Precalculation time: 49
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+

I'm not sure what the N, HR, and FA are referring to in each of these cases. Could someone explain what they stand for and what they mean?

Heigho answered 17/11, 2014 at 11:32 Comment(0)
P
24

Searching for "HR" in the OpenCV source leads us to this file. Lines 1703-1707 inside CvCascadeBoost::isErrDesired print the table:

cout << "|"; cout.width(4); cout << right << weak->total;
cout << "|"; cout.width(9); cout << right << hitRate;
cout << "|"; cout.width(9); cout << right << falseAlarm;
cout << "|" << endl;
cout << "+----+---------+---------+" << endl;

So HR and FA stand for hit rate and false alarm. Conceptually: hitRate = % of positive samples that are classified correctly as such. falseAlarm = % of negative samples incorrectly classified as positive.

Reading the code for CvCascadeBoost::train, we can see the following while loop

cout << "+----+---------+---------+" << endl;
cout << "| N  | HR      | FA      |" << endl;
cout << "+----+---------+---------+" << endl;

do
{
    [...]
}
while( !isErrDesired() && (weak->total < params.weak_count) );

Just looking at this, and not knowing much about the specifics of boosting, we can make the educated guess that training works until error is low enough, as measured by falseAlarm.

Prole answered 17/11, 2014 at 13:22 Comment(4)
Just one question about the %. When it prints 1 is that 1% or 100% with 0.7432 being 0.7% or 74% respectively?Heigho
Here 1 is 100% and 0.7432 is 74.32%Prole
what is the unit of precalculation time? minute or hour?Sharice
@monusuri the pre-calculation time is in seconds. If you give it more memory for faster processing it actually takes more pre-calculation time to load up that memory. In my case 60 seconds pre-calc and an hour or so to process.Tracheid

© 2022 - 2024 — McMap. All rights reserved.