How to use SIFT detector and SURF descriptor in opencv?

Multi tool use
How to use SIFT detector and SURF descriptor in opencv?
I want to use a SIFT detector and SURF descriptor. However, I just know how to use a SIFT / SURF detector and descriptor to compute similarity of two images but not the combination of them.
Here is the code for SIFT detector and descriptor:
sift = cv2.xfeatures2d.SIFT_create()
img_a = cv2.imread('a.jpg')
img_b = cv2.imread('b.jpg')
kp_des_a = sift.detectAndCompute(img_a , None)[1]
kp_des_b = sift.detectAndCompute(img_b , None)[1]
bf = cv2.BFMatcher()
matches = bf.knnMatch(kp_des_a, kp_des_b, k=2)
good = [m for m, n in matches if m.distance < 0.7*n.distance]
score = len(good)
How to use SIFT detector and SURF descriptor?
sift.detect()
surf.compute()
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I haven't used python interface. So I could be wrong here. But you can try detecting keypoints using
sift.detect()
. Then try usingsurf.compute()
to get the descriptors.– dhanushka
Jul 3 at 9:45