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)