opencv_traincascade的功能数量

时间:2016-08-31 10:18:57

标签: opencv

当我使用opencv_traincascade使用本地二进制模式(LBP)训练我的分类器时,我在控制台上编写了这个:

Number of unique features given windowSize [50,28] : 51408

这个数字是如何计算的?

1 个答案:

答案 0 :(得分:2)

与OpenCV一样,您可以查看源代码。它基本上是根据窗口大小计算的。

该号码来自featureEvaluator->getNumFeatures()。见here

 cout << "Number of unique features given windowSize [" 
      << _cascadeParams.winSize.width << "," 
      << _cascadeParams.winSize.height << "] : " 
      << featureEvaluator->getNumFeatures() << "" << endl;

此函数只返回numFeatures。见here

 int getNumFeatures() const { return numFeatures; }

对于LPB功能,此数字在generateFeatures中计算:

void CvLBPEvaluator::generateFeatures()
{
    int offset = winSize.width + 1;
    for( int x = 0; x < winSize.width; x++ )
        for( int y = 0; y < winSize.height; y++ )
            for( int w = 1; w <= winSize.width / 3; w++ )
                for( int h = 1; h <= winSize.height / 3; h++ )
                    if ( (x+3*w <= winSize.width) && (y+3*h <= winSize.height) )
                         features.push_back( Feature(offset, x, y, w, h ) );
    numFeatures = (int)features.size();
}