I am trying to compute descriptors given a set of Keypoint
that i have computed with cv2.KeyPoint
!
But when i try to call sift.compute()
like this, just to see if it works:
sift= cv2.SIFT()
sift.compute(img, Keypoint)
I get the following error that i can't manage to understand: <method 'compute' of 'cv2.Feature2D' objects> returned NULL without setting an error
I am using Opencv 4.4
If you look at the documentation
You should declare SIFT
as:
sift = cv.SIFT_create()
Therefore the correct code will be:
sift = cv.SIFT_create()
kp, des = sift.detectAndCompute(gray,None)
Update
If you have already calculated the key-points (kp
) then draw it on the current image:
img=cv.drawKeypoints(gray,kp,img)
cv.imwrite('sift_keypoints.jpg',img)