Under the hood, MATLAB uses OpenCV for some computer vision , including SURF detection. If you look in the $matlabroot/bin/$arch folder, you will find the OpenCV shared libraries in addition to the ocv.dll gateway ocv.dll ).
In fact, the same reference document is mentioned in the documentation of both, which means that the parameters of the algorithm have the same value in both frames.
MATLAB
Herbert Bay, Andreas Ess, Tinn Tuytelaars, Luke Van Gul "SURF: Accelerated Reliable 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: Accelerated Reliable Functions", 9th> European Computer Vision Conference, 2006
First, make sure that you use the same parameter values ββin both, taking into account the default values. Below are the pages of the OpenCV and MATLAB document 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);
In addition, MATLAB usually includes an older version of OpenCV (my MATLAB R2013a comes with v2.4.2 files), which can lead to different results from any version of OpenCV that you are using (the latter is currently v2.4.6)