haar cascade XML for Viola-jones

988 views Asked by At
<!-- tree 0 -->
-<_>
**<!-- root node -->**
-<feature>
    -<rects>
        <_>2 7 16 4 -1.</_>
        <_>2 9 16 2 2.</_>
    </rects>
    <tilted>0</tilted>
</feature>
<threshold>4.3272329494357109e-003</threshold>
<left_val>0.0383819006383419</left_val>
<right_node>1</right_node>
</_>
-<_>
    **<!-- node 1 -->**
-<feature>
    -<rects>
        <_>8 4 3 14 -1.</_>
        <_>8 11 3 7 2.</_>
    </rects>
    <tilted>0</tilted>    
</feature>
<threshold>0.0130761601030827</threshold>
<left_val>0.8965256810188294</left_val>            
<right_val>0.2629314064979553</right_val>

What are <root node> and <node 1> respectively?

I thougth that each weak classifier matches with one haar-like feature

but when I see this XML code, there are two nodes and I am confused.

end I don't get what right/left_node or right/left_val means also.

2

There are 2 answers

0
user3072099 On

There are different ways you train the samples. One way is to have "nsplits" option to be less than 2, where only root nodes are generated, with ,each root node corresponding to a haar feature, but if "nsplits" is greater than 1 you have root node split into leaf nodes such that the root node + leaf nodes = nsplits value and having 1 haar feature associated with each "node" arranged in a regression decision tree form (CART).

To answer your question short, even here each classifier is a haar feature but are arranged in a desision tree form having more than 1 leaf. For this particular example the training was done with nsplits = 2.

0
Mahmoud Fayez On

OpenCV code is generic not for Viola-Jones particular algorithm, so the XML file has a tree like structure while the Viola-Jones has linear structure of multiple stages. In short you will find that each root node is a stage, and of course inner nodes are the features while each feature has 2 or 3 rectangles.