I am trying to only draw the keypoints (without the image) using this example code:
import cv2
import numpy as np
img = cv2.imread('test.png')
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
sift = cv2.SIFT()
kp = sift.detect(gray,None)
img=cv2.drawKeypoints(gray,kp)
cv2.imwrite('sift_keypoints.jpg',img)
I tried cv2.drawKeypoints(None,kp)
and cv2.drawKeypoints(kp)
but to no avail.
Any ideas how this could be achieved ?
Thanks.
You can get ONLY the keypoints by drawing them on a solid black image having the SAME shape of your original image.
This is the image I used:
I then obtained the keypoints:
Then I created an image of solid color(black) having same size of the original image and draw these keypoints on them.
Voila ONLY keypoints
CODE:
#---Creating image of solid color with same size as image---
mask = np.zeros((img.shape[0], img.shape[1], 3), np.uint8)
mask[:] = (0, 0, 0)
#---Drawing keypoints on the mask image---
fmask = cv2.drawKeypoints(mask,kp,None,color=(0,255,0), flags=0)
cv2.imshow('fmask.jpg', fmask)