[英]OpenCV Dense feature detector
我正在使用openCV进行一些密集的特征提取。 例如,代码
DenseFeatureDetector detector(12.f, 1, 0.1f, 10);
我不太了解上述构造函数中的参数。 这是什么意思 ? 阅读有关它的opencv 文档也无济于事。 在文档中,参数为:
DenseFeatureDetector( float initFeatureScale=1.f, int featureScaleLevels=1,
float featureScaleMul=0.1f,
int initXyStep=6, int initImgBound=0,
bool varyXyStepWithScale=true,
bool varyImgBoundWithScale=false );
他们应该怎么办? 即scale,initFeatureScale,featureScaleLevels等的含义是什么? 您如何知道密集采样的网格或网格间距等。
我也使用带有密集检测器的opencv,我想我可以为您提供一些帮助。 我不确定我要说什么,但是经验告诉我。
当我使用密集检测器时,我会通过那里灰度图像。 检测器制作一些阈值滤波器,其中opencv使用灰度最小值与来转换图像。 灰阶比阈值高的像素将被视为黑点,而其他像素则为白点。 在阈值越来越大的循环中重复执行此操作。 因此,参数initFeatureScale确定执行此循环所需的第一个阈值,featureScaleLevels参数指示此阈值在一个循环迭代与下一个循环之间要大多少,featureScaleMul是计算下一个阈值的乘数。
无论如何,如果您正在寻找最佳参数来使用密集检测器来检测任何特定点,那么您将提供我为此而设计的程序。 它在github中被解放了。 这是一个程序,您可以在其中测试某些检测器(密集检测器就是其中之一),并通过一个用户界面(只要您在执行程序时就可以更改检测器参数)来检查其参数是否更改。 您将看到检测到的点将如何变化。 要尝试,只需单击链接 ,然后下载文件。 您可能需要几乎所有文件来执行程序。
事先道歉,我主要使用Python,所以我会避免使用C ++来掩饰自己。
DenseFeatureDetector填充带有KeyPoints的向量,以传递给计算特征描述符。 这些关键点具有一个点向量及其标度集。 在文档中,比例是关键点的像素半径。
关键点在传递给DenseFeatureVector的图像矩阵的宽度和高度上均匀分布。
现在来看参数:
initFeatureScale设置初始KeyPoint特征半径(以像素为单位)(据我所知这没有效果)
秤featureScaleLevels数overwhich我们希望使关键点
用于initFeatureScale超过featureScaleLevels featureScaleMuliplier比例调节,这种规模的调整也可以应用于边界(initImgBound)和步长大小(initxystep)。 因此,当我们设置featureScaleLevels> 1时,该乘数将应用于连续的比例,以调整特征比例,阶梯和图像周围的边界。
initXyStep移动列和行的步长(以像素为单位)。 我希望自我解释。
initImgBound行/列边界区域可以忽略图像(像素)周围的内容,因此,一个initImgBound为10的100x100图像将在图像的中央80x80部分中创建关键点。
VariantXyStepWithScale布尔值,如果我们有多个featureScaleLevels ,我们想使用featureScaleMultiplier来调整步长。
variableImgBoundWithScale布尔值,与variableXyStepWithScale一样,但应用于边框。
这是来自OpenCV 2.4.3源中detectors.cpp的DenseFeatureDetector源代码,它可能比我的话解释得更好:
DenseFeatureDetector::DenseFeatureDetector( float _initFeatureScale, int _featureScaleLevels,
float _featureScaleMul, int _initXyStep,
int _initImgBound, bool _varyXyStepWithScale,
bool _varyImgBoundWithScale ) :
initFeatureScale(_initFeatureScale), featureScaleLevels(_featureScaleLevels),
featureScaleMul(_featureScaleMul), initXyStep(_initXyStep), initImgBound(_initImgBound),
varyXyStepWithScale(_varyXyStepWithScale), varyImgBoundWithScale(_varyImgBoundWithScale)
{}
void DenseFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
{
float curScale = static_cast<float>(initFeatureScale);
int curStep = initXyStep;
int curBound = initImgBound;
for( int curLevel = 0; curLevel < featureScaleLevels; curLevel++ )
{
for( int x = curBound; x < image.cols - curBound; x += curStep )
{
for( int y = curBound; y < image.rows - curBound; y += curStep )
{
keypoints.push_back( KeyPoint(static_cast<float>(x), static_cast<float>(y), curScale) );
}
}
curScale = static_cast<float>(curScale * featureScaleMul);
if( varyXyStepWithScale ) curStep = static_cast<int>( curStep * featureScaleMul + 0.5f );
if( varyImgBoundWithScale ) curBound = static_cast<int>( curBound * featureScaleMul + 0.5f );
}
KeyPointsFilter::runByPixelsMask( keypoints, mask );
}
您可能希望计算调用将基于DenseFeatureDetector生成的关键点,使用相关的关键点检测算法(例如角度)来计算其他关键点特性。 不幸的是,Python下的SIFT并非如此-我没有研究其他功能检测器,也没有研究C ++中的行为。
另请注意,DenseFeatureDetector不在OpenCV 3.2中(不确定在哪个版本上将其删除)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.