4

我正在实现我在 MATLAB 中设计的 OpenCV 算法。我正在为 OpenCV 中的 SURF 特征提取器编写单元测试,我想将 MATLAB 提取的 SURF 特征的输出与 OpenCV 进行比较。

这个问题是,对 MATLAB 和 OpenCV 提取器使用相同的参数,我得到了不同数量的特征。这怎么可能?是否有不同的方式来实现 SURF?

对于 MATLAB ( http://www.mathworks.com/help/vision/ref/detectsurffeatures.html ) 我正在使用:

MetricThresh: 200
NumOctaves: 3
NumScaleLevels: 4
SURFSize: 64

对于我正在使用的 OpenCV:

HessianThreshold: 200
nOctaves: 3
nOctaveLayers: 4
extended: false upright
: true

这里发生了什么?有没有更好的方法来测试 openCV 和 MATLAB 是否从同一图像中生成相同的提取 SURF 特征?

感谢您的帮助!

4

1 回答 1

4

在底层,MATLAB 将 OpenCV 用于其一些计算机视觉功能,包括检测SURF特征。如果您查看$matlabroot/bin/$arch文件夹内部,您会发现 OpenCV 共享库以及网关库ocv.dll)。

实际上,两者的文档中都提到了相同的参考论文,这表明算法参数在两个框架中具有相同的含义。

MATLAB

Herbert Bay, Andreas Ess, Tinne Tuytelaars, Luc Van Gool "SURF: Speeded Up Robust Features", Computer Vision and Image Understanding (CVIU), Vol. 110, No. 3, pp. 346--359, 2008

OpenCV

Bay, H. and Tuytelaars, T. and Van Gool, L. "SURF: Speeded Up Robust Features", 9th > European Conference on Computer Vision, 2006


First thing, make sure you are using the same parameter values in both, taking into account the default values. Here are the doc pages for OpenCV and MATLAB for reference.

So try the following codes:

In MATLAB:

>> img = [];     % some 2d grayscale image
>> pts = detectSURFFeatures(img, 'MetricThreshold',200, ...
       'NumOctaves',3, 'NumScaleLevels',4);

In C++ OpenCV:

cv::Mat img;     // some grayscale image
cv::SURF surf(200.0, 3, 4-2, false, true);

cv::Mat mask;    // optional mask (unused here)
std::vector<cv::KeyPoint> pts;
surf(img, mask, pts);

Other than that, MATLAB usually include an older version of OpenCV (my MATLAB R2013a ships with v2.4.2 DLLs), which could result in different results from whatever OpenCV version you are using (latest as of now is v2.4.6)

于 2013-07-26T01:14:12.970 回答