【问题标题】:opencv_traincascade number of featuresopencv_traincascade 特征数
【发布时间】:2017-01-07 21:13:33
【问题描述】:

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

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

这个数字是怎么计算出来的?

【问题讨论】:

标签: opencv


【解决方案1】:

与 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();
}

【讨论】:

  • 查看你的 opencv 安装文件夹。我现在找不到确切的路径,但它会在那里;D
  • 你知道上面代码的解释吗?学习LBP已经有一段时间了,但是看不懂这几行代码背后的逻辑。比如,为什么宽高要除以3?
  • 我不知道。你可以看看其他人是否对此有明确的解释。 (您可能不想接受答案,因为已回答的问题不会吸引很多其他用户)
  • 也许3与LBP 3x3 grid size有关? LBP 大小会增加,但您始终拥有 3x3 的网格大小(单元格大小会增加)。在我看来,你应该用纸来运行算法,为每次迭代绘制模式和特定的 winSize 值,以完全理解代码。
猜你喜欢
  • 2011-10-24
  • 2018-12-11
  • 1970-01-01
  • 2015-08-07
  • 1970-01-01
  • 1970-01-01
  • 2013-01-11
  • 2019-01-28
  • 2014-12-20
相关资源
最近更新 更多