Humam Helfawi Humam Helfawi - 3 months ago 31
C++ Question

estimate 2D transformation between two set of points using Ransac

As I know, OpenCV uses RANSAC in order to solve the problem of

findhomograph
and it return some useful parameters like the
homograph_mask
. However, if I want to estimate just 2D transformation which means an Affine Matrix, is there a way to use the same methodlogy of
findHomography
which uses RANSAC and return that mask ?

Answer

estimateRigidTransform does use RANSAC internally, though the parameters are fixed at the moment - see the code here - https://github.com/opencv/opencv/blob/master/modules/video/src/lkpyramid.cpp

cv::Mat cv::estimateRigidTransform( InputArray src1, InputArray src2, bool fullAffine )
{
    const int RANSAC_MAX_ITERS = 500;
    const int RANSAC_SIZE0 = 3;
    const double RANSAC_GOOD_RATIO = 0.5;

    // ...

    // RANSAC stuff:
    // 1. find the consensus
    for( k = 0; k < RANSAC_MAX_ITERS; k++ )
    {
        int idx[RANSAC_SIZE0];
        Point2f a[RANSAC_SIZE0];
        Point2f b[RANSAC_SIZE0];

        // choose random 3 non-complanar points from A & B
        for( i = 0; i < RANSAC_SIZE0; i++ )
        {
            for( k1 = 0; k1 < RANSAC_MAX_ITERS; k1++ )
            {
Comments