Skip to content

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

@P66094125

Description

@P66094125

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions