Matching Error In Orb With Opencv 3
currently i am working on opevcv with python but when i use kp1 = orb.detect(img1,None) kp2 = orb.detect(img2,None) kp1, des1 = orb.compute(img1, kp1) kp2, des2 =
Solution 1:
You need to create the matcher
object first. A complete example can be found on OpenCV tutorials:
import numpy as np
import cv2
from matplotlib import pyplot as plt
img1 = cv2.imread('box.png',0) # queryImage
img2 = cv2.imread('box_in_scene.png',0) # trainImage# Initiate ORB detector
orb = cv2.ORB()
# find the keypoints and descriptors with ORB
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)
# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
# Match descriptors.
matches = bf.match(des1,des2)
# Sort them in the order of their distance.
matches = sorted(matches, key = lambda x:x.distance)
# Draw first 10 matches.
img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:10], flags=2)
plt.imshow(img3),plt.show()
Post a Comment for "Matching Error In Orb With Opencv 3"