Ask Your Question
0

estimateAffinePartial2D and estimateAffine2D

asked 2017-01-21 17:07:19 -0600

phryniszak gravatar image

updated 2017-01-22 03:39:28 -0600

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 flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-01-21 18:14:24 -0600

Tetragramm gravatar image

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.

edit flag offensive delete link more

Comments

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

AbhiTronix gravatar imageAbhiTronix ( 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.

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

@Tetragramm Solved it ;)

AbhiTronix gravatar imageAbhiTronix ( 2018-12-01 21:25:52 -0600 )edit
0

answered 2017-07-24 15:54:47 -0600

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-01-21 17:07:19 -0600

Seen: 22,914 times

Last updated: Jan 22 '17