11

I want to use estimateRigidTransform function of OpenCV but it throws up an error.

AttributeError Traceback (most recent call last) in 30 31 #Find transformation matrix ---> 32 m = cv2.estimateRigidTransform(prev_pts, curr_pts, fullAffine=False) #will only work with OpenCV-3 or less 33 34 # Extract traslation

AttributeError: module 'cv2.cv2' has no attribute 'estimateRigidTransform'

my openCV version is 4.0.0.

LocoGris
  • 4,432
  • 3
  • 15
  • 30
user9437069
  • 111
  • 1
  • 1
  • 3

1 Answers1

12

As indicated in the documentation of estimateRigidTransform, this function has been deprecated:

Deprecatd: Use cv::estimateAffine2D, cv::estimateAffinePartial2D instead. If you are using this fuction with images, extract points using cv::calcOpticalFlowPyrLK and then use the estimation fuctions.

cv::estimateAffine2D should be more robust to noise, but more computationally expensive than cv::estimateAffinePartial2D. They are similar to estimateRigidTransform with the fullAffine parameter set to true or false, respectively.

Paul92
  • 8,827
  • 1
  • 23
  • 37
  • 1
    new_t = cv2.estimateRigidTransform(img, anchor, fullAffine=False) where size of anchor = (1280, 1920) and size of img = (1280, 1920) doesn't work. I replace estimageRigidTransofrm with estimateAffice2d(img, anchor) and receives this error cv2.error: OpenCV(4.1.2) /io/opencv/modules/calib3d/src/ptsetreg.cpp:831: error: (-215:Assertion failed) count >= 0 && to.checkVector(2) == count in function 'estimateAffine2D' How to make corrections? – fisakhan Jan 27 '20 at 14:06
  • If I am reading your message correctly, you are feeing whole (1280 x 1920) images into both functions? -You are only meant to give them pairs of matching points from both the src and dst image. – Diarmaid O Cualain Nov 08 '22 at 15:16
  • @DiarmaidOCualain Can you please explain What 'pairs of Marching Points from both the src and dst image' mean? – Enos jeba Feb 02 '23 at 16:35
  • 1
    I mean pairs of matching points: An (x, y) point in the source (src) image, and an (x, y) point in the destination (dst) image make a pair. – Diarmaid O Cualain Feb 02 '23 at 16:43