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

那年仲夏 提交于 2019-12-09 01:29:52

问题


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?


回答1:


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).

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.



来源:https://stackoverflow.com/questions/34895186/what-is-the-meaning-of-values-in-stage-xml-and-cascade-xml-for-opencv-cascade-cl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!