Created
March 23, 2019 09:57
-
-
Save saurabhpal97/897cc9f3ed0e0e186b4ac26ce00ee4e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
#reading images in grayscale format | |
image1 = cv2.imread('messi.jpg',0) | |
image2 = cv2.imread('team.jpg',0) | |
#finding out the keypoints and their descriptors | |
keypoints1,descriptors1 = cv2.detectAndCompute(image1,None) | |
keypoints2,descriptors2 = cv2.detectAndCompute(image2,None) | |
#matching the descriptors from both the images | |
bf = cv2.BFMatcher() | |
matches = bf.knnMatch(ds1,ds2,k = 2) | |
#selecting only the good features | |
good_matches = [] | |
for m,n in matches: | |
if m.distance < 0.75*n.distance: | |
good.append([m]) | |
image3 = cv2.drawMatchesKnn(image1,kp1,image2,kp2,good,flags = 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment