先上两个code吧
#!/usr/bin/env python
import cv2
import numpy as np
img1 = cv2.imread('box.png', 0)
img2 = cv2.imread('box_in_scene.png', 0)
orb = cv2.ORB_create()
kp1, des1 = orb.detectAndCompute(img1, None)
kp2, des2 = orb.detectAndCompute(img2, None)
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1, des2)
matches = sorted(matches, key = lambda x:x.distance)
img3 = np.zeros((720, 1280, 3), np.uint8)
#img3 = cv2.drawMatches(img1, kp1, img2, kp2, matches[:10], img3, (255,0,0), (0,255,255), None, 2)
img3 = cv2.drawMatches(img1, kp1, img2, kp2, matches[:10], img3)
cv2.imshow('match', img3)
cv2.waitKey(0)
#!/usr/bin/env python
import cv