SiftFeatureDetector no longer works in version 3.4

I’m currently updateing from OpenCV 24 to 3.4 and now stumble upon a problem with the (formelry working) SiftFeatureDetector. The function call to

siftDetector.detect(*fiducial,siftKeypoints);

causes an exception and does not work. The reason seems to be the code at Feature2D::detectAndCompute(), there nothing is implemented:

/* Detects keypoints and computes the descriptors */
void Feature2D::detectAndCompute( InputArray, InputArray,
std::vector&,
OutputArray,
bool )
{
CV_INSTRUMENT_REGION();

CV_Error(Error::StsNotImplemented, "");

}

My instatiation of the SiftFeatureDetector is quite simple and has not changed:

cv::SiftFeatureDetector siftDetector;

So…any idea what could be the problem here?

Thanks :slight_smile:

the api has indeed changed wrt. 2.4, now you have to use:

Ptr<SIFT> sift = SIFT::create(); // no more xfeatures2d !
sift->detectAndCompute(image, noArray(), kp, desc);

please have a look at the tutorials

Correct me when I’m wrong but this is what I’m doing: detectAndCompute() as per your code-snippet is the function which is called by detect() directly and detectAndCompute() it is the function which is not implemented! So that’s exactly the problem I have…

no, not exactly.

you need to use a pointer to SIFT or Feature2D to make polymorphism work
(so it calls the derived function, not the “not implemented” one)

1 Like