Different SURF Features Extracted Between MATLAB and OpenCV?

↘锁芯ラ 提交于 2019-12-19 08:55:22

问题


I'm implementing an algorithm in OpenCV that I've designed in MATLAB. I'm writing a unit test for the SURF feature extractor in OpenCV, and I want to compare the output of MATLAB's extracted SURF features to OpenCV.

This issue is, using the same parameters for both MATLAB and OpenCV extractors I'm getting different numbers of features. How is this possible? Are there different ways to implement SURF?

For MATLAB (http://www.mathworks.com/help/vision/ref/detectsurffeatures.html) I'm using:

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

For OpenCV I'm using:

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

What's going on here? Is there a better way to test that openCV and MATLAB are producing the same extracted SURF features from the same image?

Thank you for your help!


回答1:


Under the hood, MATLAB uses OpenCV for some of its computer vision functions, including detecting SURF features. If you look inside the $matlabroot/bin/$arch folder, you'll find OpenCV shared libraries in addition to a gateway library ocv.dll).

In fact, the same reference paper is mentioned in the documentation of both, which suggests that the algorithm parameters have the same meaning in both frameworks.

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)



来源:https://stackoverflow.com/questions/17865546/different-surf-features-extracted-between-matlab-and-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!