Ask Your Question

Revision history [back]

estimateRigidTransform Error in OpenCV4

Hi, Following python code was working in older version of cv but due to deprecation of estimateRigidTransform function in cv4, it is not working. So, I replaced estimateRigidTransform with estimateAffine2D to make it functional in opencv4.

    target_pts = np.array([[tx1, ty1], [tx2, ty2], [tx3, ty3], [tx4, ty4]]).astype(np.float32) * scale
    org_pts = np.array([[x1, y1], [x2, y2], [x3, y3], [x4, y4]]).astype(np.float32)
    #mat_ = cv2.estimateRigidTransform(org_pts, target_pts, True)
    mat_ = cv2.estimateAffine2D(org_pts, target_pts)
    dsize = (int(120 * scale), int(48 * scale))
    warped = cv2.warpAffine(image, mat_, dsize)

The above code is now throwing error TypeError: Expected Ptr<cv::umat> for argument 'M' for last line warpAffine function params due to change in argument value (I think).

Please guide, How I can replace estimateRigidTransform with other to make it functional. What steps should I do