Home > Mobile >  getting an error with detectAndCompute with AKAZE_create
getting an error with detectAndCompute with AKAZE_create

Time:10-06

Here's my code:

import cv2

im = cv2.imread('a.png', cv2.IMREAD_COLOR)
imGray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
feat = cv2.AKAZE_create(500)
keypoints, descriptors = feat.detectAndCompute(imGray, None)

When I run it I get this error:

Traceback (most recent call last):
  File "akaze.py", line 6, in <module>
    keypoints, descriptors = feat.detectAndCompute(imGray, None)
cv2.error: OpenCV(4.6.0) /io/opencv/modules/features2d/src/kaze/AKAZEFeatures.cpp:1294: error: (-215:Assertion failed) x0 - 6 * scale >= 0 && x0   6 * scale < Lx.cols in function 'Sample_Derivative_Response_Radius6'

It works fine if I replace AKAZE_create with a different feature descriptor extractor, e.g. ORB_create.

Am I doing something wrong or does detectAndCompute just not work with AKAZE_create?

I'm running Python 3.8.10 and OpenCV 4.6.0.

CodePudding user response:

It seems that you are trying to limit the number of keypoints but for AKAZE_create there is no option to limit that number as Rotem pointed out in here

You can replace feat = cv2.AKAZE_create(500) with feat = cv2.AKAZE_create()

For documentation of AKAZE constructor here

  • Related