0

I have moved from 3.4 to 4.0 and cv2 is missing the estimateRigidTransform function. The documentation shows it is still there in the C++ library but it is not in cv2. Has it been renamed or am I missing something stupid when im building it?

I checked 3.5 and it looks like it is the first version where it is missing.

Surenthar Pitchai
  • 1,231
  • 15
  • 18
jonathanbyrn
  • 719
  • 6
  • 13

2 Answers2

2

As you can see in the doc, estimateRigidTransform is now deprecated.

You should use estimateAffine2D or estimateAffinePartial2D

Also, I'm pretty sure that OpenCV 3.5 does not exists: you go from 3.4.4 to 4.0.0.

Miki
  • 40,887
  • 13
  • 123
  • 202
  • Apologies, I meant 4.0, I shouldn't be coding tired. Thanks for the help! – jonathanbyrn Nov 30 '18 at 09:50
  • shape of anchor = (1280, 1920), shape of img = (1280, 1920) and new_t = cv2.estimateRigidTransform(img, anchor, fullAffine=False) How should I replace estimateRigidTransofrm with estimateAffine2d? I used cv2.estimateAffine2d(img, anchor, fullAffine=False) and received 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' – fisakhan Jan 27 '20 at 13:58
0

You can use the estimateAffine3D as follows:

cv::Mat get_rigid_transform(std::vector<cv::points3d> poinst1 , std::vector<cv::points3d> points2)
{

   cv::Mat affine_transformation = cv::Mat::eye(3, 4, CV_64F);
   std::vector<uchar> inliers;
   cv::estimateAffine3D(points1, poinst2, affine_transformation, inliers);
   return affine_transformation;
}
cyborg
  • 554
  • 2
  • 7