Matching with RanSAC (ORB or SURF) - Evaluate Performance in Python

248 Views Asked by At

Please, I have implemented ORB for feature detection/description on the image, and I have done the same with SURF. I applied a matching with FLANN, and then I tried to improve the results with RanSAC by computing the homography matrix :

MIN_MATCH_COUNT = 30
if len(good)>MIN_MATCH_COUNT:
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)
H, mask = cv.findHomography(src_pts, dst_pts, cv.RANSAC,ransacReprojThreshold=3.0)
matchesMask = mask.ravel().tolist()

h,w = img1.shape
pts = np.float32([ [0,0],[0,h-1],[w-1,h-1],[w-1,0] ]).reshape(-1,1,2)
dst = cv.perspectiveTransform(pts,H) 

img2 = cv.polylines(img2,[np.int32(dst)],True,255,3, cv.LINE_AA)

print (H)

My questions:

  • why FLANN is not stable ? the results are changed every time I run the algorithm ?
  • Do you have a solution/script to evaluate the errors (Inliers and Outliers) of RanSAC as a curve in Python?

NB: On the Internet I found only regression solutions which is out of my subject.

0

There are 0 best solutions below