CV4.1: Failed Assertion in function detectAndCompute level>=0

145 views Asked by At

I'm curently working on a little algorithm using ORB. It has to recalculate keypoints and descriptors at some point, since their location and size change. However, calling detectAndCompute with the "useExistingKepoints"-flag on, fails at the assertion "level >= 0". I am confused, since there is no attribute called "level" in a keypoint or descriptor. My question is what exactly causes the assertion to fail and how to avoid that?

Fyi: Since trackers work with rectangular bounding boxes instead of circular Keypoints, I have to translate one in another.

Keypoint2BoundingBox:

//Create Rect2d with data from the keypoint. 
//Orientation and octave don't need to be saved, since  the object gets reused
//kp: KeyPoint
Rect2d(round(kp.pt.x - kp.size / 2), round(kp.pt.y - kp.size / 2)
       round(kp.size), round(kp.size)));

BoundingBox2Keypoint (The result of this method gets passed to ORB causing the problem)

//obtain previous kp object and update it accordingly
//kp: KeyPoint;   rect: Rect2d
kp->size = int(round(max(rect->height,rect->width)));
kp->octave = int(round(size2Octave(kp->size, patchsize, scale)));
kp->pt = Point2f(int(round(rect->x-(rect->width/2))),
int(round(rect->y-(rect->height/2))));

Size2Octave

//Uses keypoint size and some ORB parameters to compute the octave 
//the keypoint would have
//size: Keypoint Size;   patchsize: size of keypoints at octave 0;
//scale: stepsize to next octave
//returns fraction if Keypoint size is not multiple of patchsize
log10(size/patchsize)/log(scale);
1

There are 1 answers

0
Miki On BEST ANSWER

As you can see in the source code:

 level = keypoints[i].octave;
 CV_Assert(level >= 0);

you need to fix the way you compute the octave