I have two images which I want to compare using python and opencv.
I understood how to extract surf features from a single images from this book: Programming Computer Vision with Python.
I extract the features as follows:
import cv2
from numpy import *
# read image
im = cv2.imread('empire.jpg')
# downsample
im_lowres = cv2.pyrDown(im)
# convert to grayscale
gray = cv2.cvtColor(im_lowres,cv2.COLOR_RGB2GRAY)
# detect feature points
s = cv2.SURF()
mask = uint8(ones(gray.shape))
keypoints = s.detect(gray,mask)
# show image and points
vis = cv2.cvtColor(gray,cv2.COLOR_GRAY2BGR)
for k in keypoints[::10]:
cv2.circle(vis,(int(k.pt[0]),int(k.pt[1])),2,(0,255,0),-1)
cv2.circle(vis,(int(k.pt[0]),int(k.pt[1])),int(k.size),(0,255,0),2)
cv2.imshow('local descriptors',vis)
cv2.waitKey()
Now how I can I compare keypoints with another sets of keypoints which comes from a reference image using?