Humam Helfawi Humam Helfawi - 1 year ago 169
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

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

Answer Source

estimateRigidTransform does use RANSAC internally, though the parameters are fixed at the moment - see the code here -

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++ )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download