Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of values in stage.xml and cascade.xml for opencv cascade classifier

I have tried to detect something from a tutorial. When training have finished, stage files and cascade file is created. I have knowledge about the algorithm but I don't know meaning of information inside these file.

<internalNodes>
        0 -1 13569 2.8149113059043884e-003</internalNodes>
      <leafValues>
        9.8837211728096008e-002 -8.5897433757781982e-001</leafValues></_>  

and

<rects>
        <_>
          0 0 3 1 -1.</_>
        <_>
          1 0 1 1 3.</_></rects>
      <tilted>0</tilted></_>

What are the meanings of these values?

like image 203
Gokhan Avatar asked Jan 20 '16 08:01

Gokhan


1 Answers

Let's start with first block:

<internalNodes>
        0 -1 13569 2.8149113059043884e-003</internalNodes>
<leafValues>
        9.8837211728096008e-002 -8.5897433757781982e-001</leafValues></_> 

It describes one of the weak classifier. In such case it's stump based, i.e. it's tree with max depth is equal to 1. 0 and -1 it's indexes of left and right child of root node. If indexes less or equal to zero it indicates that it's leaf nodes. Note that to calculate leaf index you need to negate it. Next number (13569) is index of feature in <features> section. And next number (2.8149113059043884e-003) is node threshold. In leafValues section presented weights of leafs in cascade tree.

For example, in this weak classifier we need to calculate value of 13569 feature. Next, compare this value with threshold (2.8149113059043884e-003) and if it less that threshold than you need to add the first leaf value (9.8837211728096008e-002) else you need to add the second leaf value (-8.5897433757781982e-001).

enter image description here

Next section describes one of the Haar feature:

<rects>
        <_>
          0 0 3 1 -1.</_>
        <_>
          1 0 1 1 3.</_></rects>
<tilted>0</tilted></_>

It obviously describes parameters of rectangle (x, y, width, height) and the weight of rectangle. It also may be tilted, that indicates by <tilted>0</tilted> flag.

I hope it will help.

like image 106
akarsakov Avatar answered Nov 08 '22 01:11

akarsakov