# 代码5-14 检测车牌的SIFT特征并匹配import cv2img1 = cv2.imread('../data/plate.jpg')img2 = cv2.imread('../data/car.jpg')sift = cv2.SIFT_create()# 利用sift.detectAndCompute()函数找到特征点,计算描述符;kp1, des1 = sift.detectAndCompute(img1, None)kp2, des2 = sift.detectAndCompute(img2, None)# 创建匹配对象bf = cv2.BFMatcher()# 暴力匹配matches = bf.match(des1, des2)# 排序matches = sorted(matches, key=lambda x: x.distance)# 绘制匹配图像img3 = cv2.drawMatches(img1, kp1, img2, kp2, matches[: 50], None, flags=2)cv2.imwrite('../tmp/BF.jpg', img3)cv2.imshow("aa",img3)cv2.waitKey()