OpenCV - Image Stitching

99封情书 提交于 2019-11-29 02:17:14

This is what I would suggest you to try, in this order:

1) Use CV_RANSAC option for homography. Refer http://opencv.willowgarage.com/documentation/cpp/calib3d_camera_calibration_and_3d_reconstruction.html

2) Try other descriptors, particularly SIFT or SURF which ship with OpenCV. For some images FAST or BRIEF descriptors are not discriminating enough. EDIT (Aug '12): The ORB descriptors, which are based on BRIEF, are quite good and fast!

3) Try to look at the Homography matrix (step through in debug mode or print it) and see if it is consistent.

4) If above does not give you a clue, try to look at the matches that are formed. Is it matching one point in one image with a number of points in the other image? If so the problem again should be with the descriptors or the detector.

My hunch is that it is the descriptors (so 1) or 2) should fix it).

Also switch to Hamming distance instead of L1 distance in BruteForceMatcher. BRIEF descriptors are supposed to be compared using Hamming distance.

Your homography, might calculated based on wrong matches and thus represent bad allignment. I suggest to path the matrix through additional check of interdependancy between its rows.

You can use the following code:

bool cvExtCheckTransformValid(const Mat& T){

    // Check the shape of the matrix
    if (T.empty())
       return false;
    if (T.rows != 3)
       return false;
    if (T.cols != 3)
       return false;

    // Check for linear dependency.
    Mat tmp;
    T.row(0).copyTo(tmp);
    tmp /= T.row(1);
    Scalar mean;
    Scalar stddev;
    meanStdDev(tmp,mean,stddev);
    double X = abs(stddev[0]/mean[0]);
    printf("std of H:%g\n",X);
    if (X < 0.8)
       return false;

    return true;    
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!