estimateAffinePartial2D and estimateAffine2D

Hi all,

Can anyone explain me what is the difference between these two: estimateAffinePartial2D and estimateAffine2D?

Are they better/different from estimateRigidTransform?

They are seems to be new kids in the block...

My findings: estimateAffinePartial2D and estimateAffine2D return the same results as estimateRigidTransform for float input values BUT if we use int points something weird is returned

std::vector<cv::Point> p1s,p2s;

p1s.push_back(cv::Point( 100, 0));
p1s.push_back(cv::Point( 0, 100));
p1s.push_back(cv::Point(-100, 0));
p1s.push_back(cv::Point( 0,-100));

p2s.push_back(cv::Point(71, -71));
p2s.push_back(cv::Point(71, 71));
p2s.push_back(cv::Point(-71, 71));
p2s.push_back(cv::Point(-71, -71));

// 1.
cv::Mat t_false = cv::estimateRigidTransform(p1s,p2s,false);
std::cout << "estimateRigidTransform false: " << t_false << "\n" << std::flush;

// 2.
cv::Mat t_true = cv::estimateRigidTransform(p1s,p2s,true);
std::cout << "estimateRigidTransform true:" << t_true << "\n" << std::flush;

// 3.
std::vector<uchar> inliers(p1s.size(), 0);
cv::Mat affine1 = cv::estimateAffine2D(p1s, p2s, inliers);
std::cout << "estimateAffine2D" << affine1 << "\n" << std::flush;

// 4.
cv::Mat affine2 = cv::estimateAffinePartial2D(p1s, p2s, inliers);
std::cout << "estimateAffinePartial2D" << affine2 << "\n" << std::flush;


and results:

estimateRigidTransform false: [0.7100000000000001, 0.7100000000000001, 0; -0.7100000000000001, 0.7100000000000001, 0]

estimateRigidTransform true:[0.7100000000000001, 0.7100000000000001, 0; -0.7100000000000001, 0.7100000000000001, 0]

estimateAffine2D[1, -0, -0; -0, 1, -0]

estimateAffinePartial2D[1, -0, 0; 0, 1, 0]

edit retag close merge delete

Sort by ยป oldest newest most voted

estimateAffinePartial2d is similar to estimateRigidTransform with the parameter fullAffine = false

estimateAffine2d is similar to estimateRigidTransform with the parameter fullAffine = true.

They don't use the same code. I think the only difference is that the estimateAffine functions use RANSAC to remove outliers and so are accurate even on noisy data.

more

@Tetragramm, Can you please provide any sample/test/example code to properly run estimateAffinePartial2d in python, Please, Any help is appreciated.

( 2018-11-19 01:31:58 -0600 )edit

I'm afraid there are no examples using it, and I'm not a python person. The conversion from C++ to Python for most things is straightforward, so take a look at how it's used.

( 2018-11-19 17:51:09 -0600 )edit

@Tetragramm Solved it ;)

( 2018-12-01 21:25:52 -0600 )edit

The original creator of the estimateAffine2D and estimateAffinePartial2D has acknowledge the bug where int inputs lead to the identity matrix output https://github.com/opencv/opencv/pull...

I am trying to use estimateAffinePartial2D in Python and I am erroneously getting the identity matrix output even with float inputs, but there may be more wrong and I'm not on the latest version with the fix for you problem above.

more