Complete the code to create a SIFT feature detector.
import cv2 sift = cv2.[1]()
The correct method to create a SIFT detector in OpenCV is SIFT_create().
Complete the code to detect keypoints and compute descriptors from an image using SIFT.
keypoints, descriptors = sift.[1](image, None)
The detectAndCompute method detects keypoints and computes descriptors in one step.
Fix the error in the code to create a BFMatcher with L2 norm for SIFT descriptors.
bf = cv2.BFMatcher([1], crossCheck=True)
SIFT descriptors are float vectors, so the correct norm type is cv2.NORM_L2.
Fill both blanks to filter matches using Lowe's ratio test.
good_matches = [] for m, n in matches: if m.[1] < [2] * n.distance: good_matches.append(m)
Lowe's ratio test compares the distance of the best match to the second best match using the distance attribute and a ratio threshold like 0.75.
Fill all three blanks to draw matches between two images.
img_matches = cv2.drawMatches(img1, kp1, img2, kp2, [1], None, flags=[2]) cv2.imshow('Matches', img_matches) cv2.waitKey([3])
To draw only good matches, pass good_matches. The flag cv2.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS hides unmatched keypoints. cv2.waitKey(0) waits indefinitely for a key press.