Comparing image to a database of images using SURF - python
Hey there I hope you guys can help me out. My goal is to write a program which will compare a photo of a car with a database of images (with a cars ofc) and tell me "That car is most likely a BMW" - I want only information about mark of a car.
I decided to use SURF. I'm getting keypoints and descriptors from database images and "my BMW". But how shall I match them ? Which matcher would be the best (BFMatcher, FlannMatcher, KNearest) and how shall I use them ?
For example that's what I got already.
import numpy as np
import cv2
# Load database
bmw1 = cv2.imread('database/bmw1.jpg')
audi1 = cv2.imread('database/audi1.jpg')
hundai1 = cv2.imread('database/hundai1.jpg')
# grayscale
gbmw1 = cv2.cvtColor(bmw1,cv2.COLOR_BGR2GRAY)
gaudi1 = cv2.cvtColor(audi1,cv2.COLOR_BGR2GRAY)
ghundai1 = cv2.cvtColor(hundai1,cv2.COLOR_BGR2GRAY)
# SURF
minHessian = 1000
surf = cv2.SURF(minHessian)
# kp and desc of database
kp_bmw1, des_bmw1 = surf.detectAndCompute(gbmw1,None)
kp_audi1, des_audi1 = surf.detectAndCompute(gaudi1,None)
kp_hundai1, des_hundai1 = surf.detectAndCompute(ghundai1,None)
#Load my test photo
test = cv2.imread('photo.jpg')
gtest = cv2.cvtColor(gtest,cv2.COLOR_BGR2GRAY)
kp_test, des_test = surf.detectAndCompute(gtest,None)