'Can't get ORB algorithm to match my images
I've tried to use ORB algorithm on these images. The code works but i can't get enough keypoints to match the images. How can i make it work?
import cv2
import numpy as np
img1 = cv2.imread('cards4/eightofspades100.png', 0)
img2 = cv2.imread('cards4/deck 4.png', 0)
cv2.imshow('img1',img1)
orb = cv2.ORB_create()
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)
#des1 and des2 are arrays of 500 features and 32 values
imgKp1 = cv2.drawKeypoints(img1, kp1, None)
imgKp2 = cv2.drawKeypoints(img2, kp2, None)
bf = cv2.BFMatcher()
matches = bf.knnMatch(des1, des2, k=2)
good = []
# m and n because k = 2 and k is the number of features
for m,n in matches:
if m.distance <1*n.distance:
good.append([m])
img3 = cv2.drawMatchesKnn(img1, kp1, img2, kp2, good, None, flags = 2)
cv2.imshow('Kp1', imgKp1)
cv2.imshow('Kp2', imgKp2)
#cv2.imshow('img1', img1)
#cv2.imshow('img2', img2)
#cv2.imshow('img3', img3)
cv2.waitKey(0)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
