, SURF . SURF- . , " ". , , .
, , , ( , ).
, , HOG , - , - , . , , , , , - . , - , . , , .
- , ( , - ). , SIFT SURF - . - .
, , , .
: , , . findHomography , , mask. , .
Edit2: (, Java , Python)
import cv2
import numpy as np
a = cv2.imread(r'C:\Temp\leaf1.jpg')
b = cv2.imread(r'C:\Temp\leaf2.jpg')
agray = cv2.cvtColor(a, cv2.COLOR_BGR2GRAY)
bgray = cv2.cvtColor(b, cv2.COLOR_BGR2GRAY)
surf = cv2.SURF()
kp1, d1 = surf.detectAndCompute(agray,None)
kp2, d2 = surf.detectAndCompute(bgray,None)
print 'numFeatures1 =', len(kp1)
print 'numFeatures2 =', len(kp2)
bf = cv2.BFMatcher()
matches = bf.knnMatch(d1,d2, k=2)
good = []
for m,n in matches:
if m.distance < 0.75*n.distance:
good.append(m)
print 'numMatches =', len(matches)
print 'numGoodMatches =', len(good)
if len(good)>10:
src_pts = np.float32([ kp1[m.queryIdx].pt for m in good ]).reshape(-1,1,2)
dst_pts = np.float32([ kp2[m.trainIdx].pt for m in good ]).reshape(-1,1,2)
M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
print 'numMatches =', sum(mask.ravel().tolist())
else:
print "not enough good matches are found"
SURF
numFeatures1 = 685
numFeatures2 = 1566
numMatches = 685
numGoodMatches = 52
numMatches = 11
, "" . , , numMatches , . , , , , - . , .