在底层,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)