Matching with ORB features using brute-force matching with python-opencv

In this section, we will demonstrate how two image descriptors can be matched using the brute-force matcher of opencv. In this, a descriptor of a feature from one image is matched with all the features in another image (using some distance metric), and the closest one is returned. We will use the BFMatcher() function with ORB descriptors to match two images of books:

img1 = cv2.imread('../images/books.png',0) # queryImageimg2 = cv2.imread('../images/book.png',0) # trainImage# Create a ORB detector objectorb = cv2.ORB_create()# find the keypoints and descriptorskp1, des1 = orb.detectAndCompute(img1,None)kp2, des2 = orb.detectAndCompute(img2,None)# create a BFMatcher object ...

Get Hands-On Image Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.