OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 06 Nov 2019 02:57:04 -0600Is there a way to compute a RANSAC based affine transformation?http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/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?Thu, 31 Jan 2013 09:56:23 -0600http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/Answer by patto for <p>I know of <code>findHomography()</code>, but that computes all kinds of perspective transformations.
I'd like to restrict the degrees of freedom to translation, rotation and scale.</p>
<p>There is a method <code>estimateRigidTransform</code> in the video module, but it's not RANSAC based.</p>
<p>Am I missing something?</p>
<p>Or do I have to implement it on my own?</p>
http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?answer=221157#post-id-221157How 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?Wed, 06 Nov 2019 02:57:04 -0600http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?answer=221157#post-id-221157Answer by ZettaCircl for <p>I know of <code>findHomography()</code>, but that computes all kinds of perspective transformations.
I'd like to restrict the degrees of freedom to translation, rotation and scale.</p>
<p>There is a method <code>estimateRigidTransform</code> in the video module, but it's not RANSAC based.</p>
<p>Am I missing something?</p>
<p>Or do I have to implement it on my own?</p>
http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?answer=212781#post-id-212781Yes 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/group__calib3d.html#gad767faff73e9cbd8b9d92b955b50062d
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
)Fri, 10 May 2019 07:13:10 -0500http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?answer=212781#post-id-212781Answer by Ben for <p>I know of <code>findHomography()</code>, but that computes all kinds of perspective transformations.
I'd like to restrict the degrees of freedom to translation, rotation and scale.</p>
<p>There is a method <code>estimateRigidTransform</code> in the video module, but it's not RANSAC based.</p>
<p>Am I missing something?</p>
<p>Or do I have to implement it on my own?</p>
http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?answer=13481#post-id-13481I solved this problem by first finding a homography and then estimating the rigid transform using only the homography's inlier matches.Thu, 16 May 2013 07:08:01 -0500http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?answer=13481#post-id-13481Comment by SR for <p>I solved this problem by first finding a homography and then estimating the rigid transform using only the homography's inlier matches.</p>
http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?comment=15945#post-id-15945That'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).Sun, 30 Jun 2013 16:32:03 -0500http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?comment=15945#post-id-15945Comment by Ben for <p>I solved this problem by first finding a homography and then estimating the rigid transform using only the homography's inlier matches.</p>
http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?comment=15960#post-id-15960I know. These degenerated transformations are annoying. But they usually occur in image pairs that don't match anyway. Do you have a better solution?Mon, 01 Jul 2013 02:43:41 -0500http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?comment=15960#post-id-15960Answer by Guanta for <p>I know of <code>findHomography()</code>, but that computes all kinds of perspective transformations.
I'd like to restrict the degrees of freedom to translation, rotation and scale.</p>
<p>There is a method <code>estimateRigidTransform</code> in the video module, but it's not RANSAC based.</p>
<p>Am I missing something?</p>
<p>Or do I have to implement it on my own?</p>
http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?answer=6751#post-id-6751Afaik this doesn't exist, so you need to implement it on your own.Thu, 31 Jan 2013 10:58:00 -0600http://answers.opencv.org/question/6747/is-there-a-way-to-compute-a-ransac-based-affine-transformation/?answer=6751#post-id-6751