Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the RANSAC to remove the mismatching? #26

Open
P66094125 opened this issue Mar 4, 2021 · 0 comments
Open

How to use the RANSAC to remove the mismatching? #26

P66094125 opened this issue Mar 4, 2021 · 0 comments

Comments

@P66094125
Copy link

P66094125 commented Mar 4, 2021

img_homo_gray1= cv2.cvtColor(IX, cv2.COLOR_BGR2GRAY)
img_homo_gray2= cv2.cvtColor(registered, cv2.COLOR_BGR2GRAY)

MIN_MATCH_COUNT =5
if matches>MIN_MATCH_COUNT:
M, mask = cv2.findHomography(X,Z, cv2.RANSAC,5.0)
matchesMask = mask.ravel().tolist()
print(matchesMask)
h,w =img_homo_gray1.shape
pts = np.float32([ [0,0],[0,h-1],[w-1,h-1],[w-1,0] ]).reshape(-1,1,2)
dst = cv2.perspectiveTransform(pts, M)
img_homo_gray2= cv2.polylines(img_homo_gray2, [np.int32(dst)], True, 255, 3, cv2.LINE_AA)
else:
matchesMask = None

#calaulate RANSAC matching point
sum = 0
for i in range(1,matches, 1):
if mask[i][0]==1:
sum += 1
print("RANSAC matching point: ",sum)
mismatching=matches-sum
print("mismatching:",mismatching)

#---------------------------------------------------------------------------------

Question: I don't know how to draw the matching line after doing RANSAC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant