lilouch
lilouch

Reputation: 1056

OpenCV : Assertion failed using one of the two constructors of SIFT

I'm trying to use Sift but i have an error. I don't understand why.

I do something like that :

detector = new SiftFeatureDetector(0.03,//feature threshold
                                 10);//threshold to reduce sensitivity to lines,
SiftDescriptorExtractor extractor;

Then i get this error :

OpenCV Error: Assertion failed (firstOctave >= -1 && actualNLayers <= nOctaveLayers) in operator(), file terminate called after throwing an instance of 'cv::Exception'  
what():  /home/opencv-2.4.6.1/modules/nonfree/src/sift.cpp:755: error: (-215) firstOctave >= -1 && actualNLayers <= nOctaveLayers in function operator()  

Howewer when i used SIFT with this way for example :

detector = new SiftFeatureDetector(400)

it works ! But I don't know what is this parameter, because on the documentation this is something like that :

SiftFeatureDetector( double threshold, double edgeThreshold,...)

Can you explain me please and tell me what i did wrong? Thank

Upvotes: 1

Views: 429

Answers (1)

deltheil
deltheil

Reputation: 16121

According to the exception log you are working with OpenCV 2.4.6.1.

That said you are probably referring to the documentation of a former OpenCV release. As you can see below, the constructor has been modified between 2.3.0 and 2.4.0:

OpenCV 2.3.0

SiftFeatureDetector( double threshold, double edgeThreshold, ... );

OpenCV 2.4.0

explicit SIFT( int _nfeatures=0, int _nOctaveLayers=3,
          double _contrastThreshold=0.04, double _edgeThreshold=10,
          double _sigma=1.6);

// ...

typedef SIFT SiftFeatureDetector;
typedef SIFT SiftDescriptorExtractor;

So in your case you pass wrong parameters, which should explain the abnormal situation.

Upvotes: 4

Related Questions