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

1

5

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?

Laubin answered 20/1, 2016 at 8:41 Comment(0)
E
9

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.

Ellata answered 20/1, 2016 at 10:27 Comment(3)
Is there any compresensive tutorial or book explaning all of these computations and algorithm?Laubin
@Laubin Not sure if one exists. I just explore this code to understand it.Ellata
Still leaves a lot of open questions, but, believe it or not, yours is so far the best description I could find online. Thanks for explaining!Mop

© 2022 - 2024 — McMap. All rights reserved.