openCV SurfFeatureDetector 是否不必要地在内部提取描述符?
我只是想知道,是否使用 SurfFeatureDetector 来检测关键点并使用 SurfDescriptorExtractor 来提取 SURF 描述符(请参阅下面的代码,如下所述此处)不会提取描述符两次。
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints;
detector.detect( img, keypoints ); //detecting keypoints, extracting descriptors without returning them
SurfDescriptorExtractor extractor;
Mat descriptors;
extractor.compute( img, keypoints, descriptors ); // extracting descriptors a second time
openCV 文档说,这两个类是 SURF() 类的包装器。 SURF::operator() 被重载,一个版本仅采用关键点向量,另一个版本另外采用描述符向量。 令我感兴趣的是...然后两者都调用 cvExtractSURF()
函数,该函数似乎提取了描述符,无论如何...(我没有深入研究 C 代码,因为我发现它很难理解,所以也许我错了) 但这意味着 SurfFeatureDetector 会提取描述符而不返回它们。在下一步中使用 SurfDescriptorExtractor 只会执行第二次,这对我来说似乎非常低效。但我说得对吗?
I just wondered, if using a SurfFeatureDetector to detect keypoints and a SurfDescriptorExtractor to extract the SURF descriptors (see code below as described here) wouldn't extract the descriptors twice.
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints;
detector.detect( img, keypoints ); //detecting keypoints, extracting descriptors without returning them
SurfDescriptorExtractor extractor;
Mat descriptors;
extractor.compute( img, keypoints, descriptors ); // extracting descriptors a second time
The openCV documentation says, those 2 classes are wrappers for the SURF() class.
The SURF::operator()
is overloaded, one version taking just a keypoint vector, the other one additionally taking a vector for the descriptors.
What intrigues me... both then call the cvExtractSURF()
function, which seems to extract the descriptors, no matter what... (I did not dive too deep into the C code as I find it hard to understand, so maybe I'm wrong)
But this would mean that the SurfFeatureDetector
would extract descriptors without returning them. Using the SurfDescriptorExtractor
in the next step just does it a second time, which seems very inefficient to me. But am I right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以放心,检测器实际上并不计算描述符。要查看的关键语句是 surf.cpp 的第 687 行
if( !descriptors ) continue;
在检测期间不会按应有的方式计算特征。这种架构很可能是由于 surf 代码在设计/开发为可自行工作后被“添加”到 OpenCV 中。作为背景:请注意,检测器和特征提取器是不同的东西。您首先使用 SurfFeatureDetector 来“检测”点,其中提取本地特征(使用 SurfDescriptorExtractor)。您拥有的片段是一个很好的指南。
You can be assured that detector does not actually compute the descriptors. The key statement to look at is line 687 of surf.cpp
if( !descriptors ) continue;
Features are not computed during detection, the way it should be. This kind of architecture is most likely due to the fact that surf code was "added" to OpenCV after it was designed/developed to work by itself.As a background: note that detector and feature extractors are different things. You first "detect" points using SurfFeatureDetector where local features are extracted (using SurfDescriptorExtractor). The snippet you have is a good guide.