Skip to content

Instantly share code, notes, and snippets.

@ndahlquist
Created December 14, 2017 06:29
Show Gist options
  • Save ndahlquist/7aedef241be1708ed123086092feb3a7 to your computer and use it in GitHub Desktop.
Save ndahlquist/7aedef241be1708ed123086092feb3a7 to your computer and use it in GitHub Desktop.
orb = cv2.ORB_create()
kp1, des1 = orb.detectAndCompute(l, None)
kp2, des2 = orb.detectAndCompute(r, None)
# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
# Match descriptors.
matches = bf.match(des1, des2)
# Sort them in the order of their distance.
matches = sorted(matches, key=lambda x: x.distance)
# Graph the difference in x and y to see if we can identify a trend.
x_coords = []
y_coords = []
for match in matches[:50]:
x_coords.append(kp2[match.trainIdx].pt[0] - kp1[match.queryIdx].pt[0])
y_coords.append(kp2[match.trainIdx].pt[1] - kp1[match.queryIdx].pt[1])
plt.scatter(x_coords, y_coords)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment