ORB's detectAndCompute returns None for a slightly different image

Viewed 1130

I have some kind of alignment task to do. In the process, I need to extract descriptors and keypoints. I'm using the following simple code for 2 images that are almost identical, with the same shape:

orb = cv2.ORB_create(maxFeatures)
(kpsA, descsA) = orb.detectAndCompute(image, None)
(kpsB, descsB) = orb.detectAndCompute(template, None)

ORB fails with the image on the left, but fine with the right one

ORB fails with the image on the left, but fine with the right one.

The returned (kpsA, descsA) are fine, but len(kpsB)==0 and descsB==None and I can't find the reason for that.

2 Answers

As mentioned in the comments, ORB fails to detect any features on the left image and probably only finds few features on the right image.

Instead consider doing image alignment/ image registration using a method that is not feature based. Have a look at dense optical flow algorithms such as cv::optflow::DenseRLOFOpticalFlow.

With that being said, your task looks challenging. Even humans will have difficulties solving it well. Good luck.

It's been a year since you asked the question but I want to suggest you try this. A plausible reason you see None for some images is because the default value of the threshold in the function is too high. So just play with the fastThreshold and edgeThreshold params and see if it works for you.

A good sanity check will be to set

orb = cv2.ORB_create(fastThreshold=0, edgeThreshold=0)

and see what's happen.

Next, you can chose whether to ignore these images or to try a smaller threshold.

The full explanation of the function params is here in the opencv doc.

Related