Pregunta

I was trying to implement the FREAK Descriptor in Python using Opencv. Here is the code i'm using:

def surf_freak_detect(image,hessianThreshold):
    surfDetector = cv2.SURF(hessianThreshold)
    surfDetector=cv2.GridAdaptedFeatureDetector(surfDetector,50)
    keypoints = surfDetector.detect(image,None) 
    freakExtractor = cv2.DescriptorExtractor_create('FREAK')
    keypoints,descriptors= freakExtractor.compute(image,keypoints)
    del freakExtractor
    return keypoints,descriptors

Is this the correct way to initialise the Freak Descriptor? By doing a little debugging I found out that the interpreter takes a very long time at Computing the Descriptors and then eventually crashes. The keypoints are detected properly. Weirdly, it works sometimes and sometimes just crashes!

¿Fue útil?

Solución

If the keypoints are detected properly but the program crashes when generating the descriptors it is because the descriptor region (which surrounds the keypoint) comes out of the image and there is a memory access to a position that does not exist.

You have to somehow limit the operating region for freak descriptors.

Otros consejos

There are now Python bindings for FREAK in OpenCV 3.0. Its configuration options are described here. It seems to be missing documentation of how to actually call it in Python, but you can use it in Python like this:

freakExtractor = cv2.xfeatures2d.FREAK_create()
keypoints,descriptors= freakExtractor.compute(image,keypoints)

(You have to get the keypoints from a separate feature detector, like you did in your code above.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top