I am using a simple code to extract keypoint outside a ROI. The code works with ORB but not with SIFT. Code:
vector<KeyPoint> kp;
Mat d;
string image = "image";
Mat M = imread(image,0);
//Ptr<FeatureDetector> det = new OrbFeatureDetector(); //> WORKS
Ptr<FeatureDetector> det = new SiftFeatureDetector(); //> CRASH at .detect
Rect roi(100,100,70,70);
Mat mask(M.size(), CV_8UC1, Scalar::all(255));
mask(roi).setTo(Scalar::all(0));
det->detect(M,kp,mask);
The detect method crashes with:
OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si
ze.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channel
s()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3
) - 1))*4) & 15) == elemSize1()) in unknown function, file C:\slave\builds\WinIn
stallerMegaPack\src\opencv\modules\core\include\opencv2/core/mat.hpp, line 545
If i simply use ORB
Ptr<FeatureDetector> det = new OrbFeatureDetector();
with the same code the detect works just fine.