Reputation: 125
I try to compare two points in two different images, so I want to convert the coordinates to Keypoints to compute with them the description and matching results later.
I found the method:
keypoint = cv2.KeyPoint(x, y, 0)
vec = [keypoint]
and it works but as result I get everytime:
>>>akaze.compute(image, vec)
([], None)
Even when I take detected keypoints, convert them to coordinates and back to keypoints (using the structure above) I get the same result.
So, how can I convert the given coordinates to keypoints (for example KAZE keypoints)? Thank you a lot!
Regards, Leo
Upvotes: 2
Views: 3285
Reputation: 4874
The main issue that you created keypoint with zero size. According to documentation, KeyPoint
constructor signature requires 3 parameters: x and y coordinates and size (which is keypoint diameter). You set this size to zero.
Thus the first change is setting keypoint diameter, i. e. I supposed that this should work:
keypoint = cv2.KeyPoint(x, y, 5)
but it does not. The reason is that OpenCV keypoint descriptor computer doesn't accept keypoints with default class_id (-1). Really I don't know what is actual class_id purpose (see discussion), but I changed it to zero just because akaze.detect(...)
method returns number of keypoint in this field (i. e. 0 for 1st keypoint, 1 for second one and so on). I also set size value to 5 because of the same reason - these values in detected points were from about 4.8 to 5.7.
After these modifications everything became OK, i. e. this code:
keypoints = [cv2.KeyPoint(x, y, 5, _class_id=0)]
akaze = cv2.AKAZE_create("AKAZE")
akaze.compute(image, keypoints)
gave proper result in my case (OpenCV 3.0.0). I suppose that for 2.4.x version it will be also OK.
Upvotes: 2