I am trying to use a feature detector in OpenCV in MATLAB. For that, I am creating a MEX file that calls certain other functions in other CPP files. These functions implement the necessary routine to call the OpenCV feature detector. Everything is well till creating the MEX file. It can even run normal OpenCV routines from MATLAB. But, When I am simply using the feature detector, it is giving me an error - VECTOR ITERATORS INCOMPATIBLE. Please find the necessary information below -
File 1 - FeatureDetectorMEX.cpp -> This file contains the MEX function that calls the feature detector from FeatureDetetor.cpp File 2 - FeatureDetector.cpp -> This file contains the feature detector FAST. Then it calls the feature extractor BRIEF to get some feature descriptors for keypoints. Here is the code -
Keypoints sourceKp;
Descriptors sourceDesc;
cv::FastFeatureDetector *detector = new cv::FastFeatureDetector(50);
cv::BriefDescriptorExtractor *extractor = new cv::BriefDescriptorExtractor();
//The following line generates the error
detector->detect(img.clone(),sourceKp);
if(!sourceKp.empty())
{
extractor->compute(img.clone(),sourceKp,sourceDesc);
}
Here, img is the image data structure of type cv::Mat. Keypoints is a vector - std::vector Keypoints. Descriptors is also cv::Mat.
FastFeatureDetector is the class that implements the FAST feature detector. BriefDescriptorExtractor is the class implementing Brief.
Here is the details of the error -
Debug Assertion Failed!
Program: C:\Program Files\MATLAB\R2010b\bin\win64\MATLAB.exe
File: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\Vector
Line: 238
Expression: vector iterators incompatible
Here are a few more information: My system is 64 bit. I am running MATLAB R2010b, and VC 2010 ultimate edition. All codes and dlls are in 64 bit. The program does not throw any errors if run from VC console. But, throws error if run from MATLAB.
My question: Has anyone faced this kind of problem with any of the feature detector programs in OpenCV? If yes, kindly help me with this.