I've seen some tutorials use this code to convert Keypoints (from a list of matches) to an argument for findHomography().
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)
I would prefer to use an existing function if it exists( ie. Keypoint_convert() ) for better readability. However when I try this:
kp_template_match = [kp_template[m.queryIdx].pt for m in matches]
kp_scene_match = [kp_scene[m.trainIdx].pt for m in matches]
src_pts = cv2.KeyPoint_convert(kp_template_match)
dst_pts = cv2.KeyPoint_convert(kp_scene_match)
homography, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC)
, I get this error:
> TypeError: srcPoints is not a numpy array, neither a scalar
Can anyone explain why?