Explanation of cascade.xml in a haar classifier
adaboost, classification, haar-wavelet, opencv
Solution
After digging into OpenCV's source code, I finally obtain answers to my own questions.
- Values enclosed withtin internalNodes tags
node.left node.right node.featureIdx node.threshold
I'm not sure what's node.left and node.right are for as I can't see them being called anywhere.
- The weights are used to calculate the feature as in below:
float ret = rect[0].weight * CALC_SUM(p[0], _offset) + rect[1].weight * CALC_SUM(p[1], _offset);
- As mentioned in the first bullet, the node.featureIdx are the index of the feature that's being evaluated at that particular node.
Problem
It would be best if someone could explain the numbers/values in the cascade.xml entirely. Example in: ``` <!-- stage 0 --> <_> <maxWeakCount>3</maxWeakCount> <stageThreshold>-8.8384145498275757e-001</stageThreshold> <weakClassifiers> <_> <internalNodes> 0 -1 66 5.1593100652098656e-003</internalNodes> <leafValues> -8.0555558204650879e-001 8.0694979429244995e-001</leafValues></_> <_> <internalNodes> 0 -1 108 1.5044789761304855e-002</internalNodes> <leafValues> -6.2940740585327148e-001 7.5122624635696411e-001</leafValues></_> <_> <internalNodes> 0 -1 99 -4.7172707127174363e-005</internalNodes> <leafValues> 5.5112153291702271e-001 -8.6111217737197876e-001</leafValues></_></weakClassifiers></_> ``` What are the meanings of these values ``` <internalNodes> 0 -1 99 -4.7172707127174363e-005</internalNodes> ``` Another question is, how does the program know which feature to use for a particular stage? As far as I know, features are in the form as below ``` <_> <rects> <_> 21 6 3 5 -1.</_> <_> 22 6 1 5 3.</_></rects> <tilted>0</tilted></_> ``` Whereby it's the coordinates of two rectangles, forming something like below: ``` =-= = Black colored rectangle =-= - White colored rectangle =-= =-= =-= ``` What are the values -1. and 3. mean? I know it's weights but how is it used to calculate the feature? Summary - What are the meaning of the values inside `<internalNodes>`? - How is the feature calculated? How are the weights in `<rects>` use? - Most importantly, which field denotes that which features are being used in a particular stage/node. Thanks!