简体   繁体   English

Haar级联用于人脸检测xml文件代码说明OpenCV

[英]Haar cascade for face detection xml file code explanation OpenCV

I am performing face detection using opencv haar cascade. 我正在使用opencv haar cascade进行面部检测。

I wanted to know the explanation of the xml code of the haar cascade that I have included in my program. 我想知道我在程序中包含的haar级联的xml代码的解释。 Can someone help me to understand the values presented in the XML file, for instance: weakcount , maxcount , threshold , internal nodes , leaf values etc. 有人可以帮助我理解XML文件中显示的值,例如: weakcountmaxcountthresholdinternal nodesleaf values等。

I have made use of the haarcascade_frontalface_alt2.xml file. 我已经使用了haarcascade_frontalface_alt2.xml文件。 I have already performed face detection. 我已经进行过脸部检测。 Currently I am working on counting the number of faces detected. 目前我正在计算检测到的面部数量。

As I understand, in general you already know about haarcascade structure and OpenCV implementation of it. 据我了解,一般来说你已经了解了haarcascade结构和OpenCV的实现。 If no, please first look into OpenCV manual and read something about cascade of boosted trees, for example, Lienhart's paper . 如果不是,请首先查看OpenCV手册并阅读有关增强树级联的内容,例如Lienhart的论文

Now about xml structure itself. 现在关于xml结构本身。

<maxWeakCount>3</maxWeakCount>

This parameter describe amount of simple classifiers (trees) at the stage. 此参数描述阶段中简单分类器(树)的数量。

<stageThreshold>3.5069230198860168e-01</stageThreshold>

It is stage threshold, ie threshold score for exiting from cascade at the stage. 它是阶段阈值,即在阶段退出级联的阈值分数。 During all stages, we compute final score from trees, and when final score is less then threshold, we exit from entire cascade and consider result as non-object. 在所有阶段,我们计算树的最终得分,当最终得分低于阈值时,我们退出整个级联并将结果视为非对象。

<weakClassifiers>

Start of trees parameters in the stage. 在阶段中启动树参数。

<_>
  <internalNodes>
    0 1 0 4.3272329494357109e-03 -1 -2 1 1.3076160103082657e-02
  </internalNodes>
  <leafValues>
    3.8381900638341904e-02 8.9652568101882935e-01 2.6293140649795532e-01
  </leafValues>
</_>

This is tree description. 这是树的描述。 internalNodes parameter contains the following: internalNodes参数包含以下内容:

  • 0 1 or 1 0 defines leaf index in current node where we should go. 0 11 0定义当前节点中应该去的叶索引。 In a first case we go to the left if value is below threshold and to the right if above, and in a second case we go to the right leaf if value is above threshold. 在第一种情况下,如果值低于阈值则向左移动,如果在上面,则向右移动;在第二种情况下,如果值高于阈值,则向右移动。
  • feature index 特征索引
  • threshold for choosing leaf 选择叶子的门槛
  • there is one more -1 -2 1 ... parameters list - as I see from OpenCV sources, it is just another node with leaf indexes, but negative values are ignored according to evaluation code (also from OpenCV sources). 还有一个-1 -2 1 ...参数列表 - 正如我从OpenCV源中看到的,它只是具有叶索引的另一个节点,但根据评估代码(也来自OpenCV源)忽略负值。

Consider cascade evaluation code: 考虑级联评估代码:

do
{
    CascadeClassifierImpl::Data::DTreeNode& node = cascadeNodes[root + idx];
    double val = featureEvaluator(node.featureIdx);
    idx = val < node.threshold ? node.left : node.right;
}
while( idx > 0 );

leafValues contains left value (ie left leaf score), right value (right leaf score) and tree threshold. leafValues包含左值(即左叶分数),右值(右叶分数)和树阈值。

<_>
<rects>
  <_>
    6 3 1 9 -1.</_>
  <_>
    6 6 1 3 3.</_></rects></_>
<_>

It is feature description itself according to HAAR paradigm. 根据HAAR范例,它是功能描述本身​​。 Feature index from previous section describes index of rects pair. 上一节中的特征索引描述了rects对的索引。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM