What's inside a haar cascade classifier in Open CV computer vision?

classification, opencv, xml

Solution

I'll try explain the cascade xml meaning.

<_>
<!-- root node -->
    <feature>
      <rects>
        <_>3 7 14 4 -1.</_>
        <_>3 9 14 2 2.</_></rects>
      <tilted>0</tilted></feature>
    <threshold>4.0141958743333817e-003</threshold>
    <left_val>0.0337941907346249</left_val>
    <right_val>0.8378106951713562</right_val></_></_>
<_>

In

<_>3 7 14 4 -1.</_>

3,7 are the cordinate of the rectangle you'd like to sum using the square sum matrix (the integral image) 14 4 are the length and hieght of the rectangle -1 is the wieght of the rectangle (this is NOT the weight according to viola-johnes original article)

please denote that the rects are should be normalize to your detector size

if the rects sum passes the threashold value , then the right_val is sumed for the future, otherwise the left_sum is sumed

Good luck

S

Problem

I need to translate an .xml OpenCV haar cascade to a txt file. (Open CV has a Haar Feature-based Cascade Classifier for Object Detection.) So I need to understand the xml. I'm wondering what are the "stages" and the "trees". Does a tree stand for a weak classifier? Are the trees in the same stage combined to be a strong classifier?? Are the stages cascaded??? In a tree from haarcascade_frontalface_alt.xml, it says: ``` <!-- tree 0 --> <_> <!-- root node --> <feature> <rects> <_>3 7 14 4 -1.</_> <_>3 9 14 2 2.</_></rects> <tilted>0</tilted></feature> <threshold>4.0141958743333817e-003</threshold> <left_val>0.0337941907346249</left_val> <right_val>0.8378106951713562</right_val></_></_> <_> ``` I want to know what the numbers stand for.

Original source