Ask Your Question
1

Is there a way to compute a RANSAC based affine transformation?

asked 2013-01-31 09:56:23 -0500

Ben gravatar image

updated 2013-01-31 10:09:35 -0500

I know of findHomography(), but that computes all kinds of perspective transformations. I'd like to restrict the degrees of freedom to translation, rotation and scale.

There is a method estimateRigidTransform in the video module, but it's not RANSAC based.

Am I missing something?

Or do I have to implement it on my own?

edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted
2

answered 2013-05-16 07:08:01 -0500

Ben gravatar image

I solved this problem by first finding a homography and then estimating the rigid transform using only the homography's inlier matches.

edit flag offensive delete link more

Comments

That's dangerous... You might get wrong inliers e.g. if you have a degenerated perspective transformation that maps all points to infinity your inlier criterion is basically useless. You must check the homography for sanity (which is non-trivial in practice).

SR gravatar imageSR ( 2013-06-30 16:32:03 -0500 )edit

I know. These degenerated transformations are annoying. But they usually occur in image pairs that don't match anyway. Do you have a better solution?

Ben gravatar imageBen ( 2013-07-01 02:43:41 -0500 )edit
1

answered 2013-01-31 10:58:00 -0500

Guanta gravatar image

Afaik this doesn't exist, so you need to implement it on your own.

edit flag offensive delete link more
0

answered 2019-05-10 07:13:10 -0500

ZettaCircl gravatar image

updated 2019-05-10 07:14:19 -0500

Yes it does :

    # Compute a rigid transformation (without depth, only scale + rotation + translation)
    transformation_rigid_matrix, rigid_mask = cv2.estimateAffinePartial2D(src_pts, dst_pts)

It is RANSAC based, as you can see there : https://docs.opencv.org/4.0.0/d9/d0c/...

estimateAffinePartial2D (   
    InputArray  from,
    InputArray  to,
    OutputArray     inliers = noArray(),
    int     method = RANSAC,
    double  ransacReprojThreshold = 3,
    size_t  maxIters = 2000,
    double  confidence = 0.99,
    size_t  refineIters = 10 
)
edit flag offensive delete link more
0

answered 2019-11-06 02:57:04 -0500

patto gravatar image

How to get the scale factor from Mx,i = cv2.estimateAffinePartial2D(src_pts, dst_pts)? scale = np.sqrt((Mx[0,1] * Mx[0,1]) + (Mx[0,0] * Mx[0,0])) right?

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-01-31 09:56:23 -0500

Seen: 3,557 times

Last updated: May 10