Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::findHomography does not work

Hi,

I use the following code:

    //Points
    std::vector<cv::Point2f> detectedPoints;
    std::vector<cv::Point2f> localPoints;

    for (std::vector< cv::DMatch >::iterator i = matches.begin(); i != matches.end(); ++i)
    {
        detectedPoints.push_back(detectedKeyPoints.at(i->queryIdx).pt);
        localPoints.push_back(localKeyPoints.at(i->trainIdx).pt);
        std::cout << "Detected: " << detectedKeyPoints.at(i->queryIdx).pt << " Local: " << localKeyPoints.at(i->trainIdx).pt << std::endl;
    }

    cv::Mat H12;
    cv::Mat mask;

    H12 = cv::findHomography(detectedPoints, localPoints, mask, CV_RANSAC, 3);

    std::cout << mask << std::endl;

That is resulting in the following output:

Detected: [139.324, 160.001] Local: [139.323, 160]
Detected: [256.327, 212.994] Local: [256.323, 213]
Detected: [141.323, 140] Local: [141.323, 140]
Detected: [139.323, 141.001] Local: [187.323, 159]
Detected: [176.318, 61.9985] Local: [176.323, 62]
Detected: [255.328, 239.994] Local: [86.323, 218]
Detected: [133.318, 62.0009] Local: [126.323, 216]
[1; 1; 0; 0; 0; 1; 1]

Point 1 seems to be a good match so is point 2. But why is point 3 marked as outlier whereas points 6 and 7 are marked as inliers but they are definitely not.