使用RANSAC提纯ORB和BRISK特征点,达到鲁棒匹配的效果(OpenCV 2.4.13下,源码)

#include 
#include 
#include 
#include 
#include 

using namespace std;
using namespace cv;
int main() {

    //Read images
    Mat graf_1, graf_3;
    graf_1 = imread("../data/vggAffineDataset/graf/img1.ppm");
    graf_3 = imread("../data/vggAffineDataset/graf/img3.ppm");
    if (graf_1.empty() || graf_3.empty()){
        cerr<<"No images"< kp1, kp3;
    orb.detect(graf_1,kp1);
    orb.detect(graf_3,kp3);
    //brisk.detect(graf_1,kp1);
    //brisk.detect(graf_3,kp3);
    cout<<"The number of keypoints of graf_1 is "< matches;
    matcher.match(desc_1,desc_3,matches);
    double max_dist = 0;
    double min_dist = 10000;
    for (int i = 0; i < matches.size(); ++i) {
        if (matches[i].distance < min_dist)
            min_dist = matches[i].distance;
        if (matches[i].distance > max_dist)
            max_dist = matches[i].distance;
    }

    vector goodMatches;
    for (int j = 0; j < matches.size(); ++j) {
        if (matches[j].distance < 4*min_dist)
            goodMatches.push_back(matches[j]);
    }
    cout<<"Matches is "<(k,0) = pt1.x;
        p1.at(k,1) = pt1.y;

        pt3 = kp3[goodMatches[k].trainIdx].pt;
        p3.at(k,0) = pt3.x;
        p3.at(k,1) = pt3.y;
    }

    vector m_RANSACStatus;
    findHomography(p1,p3,CV_RANSAC,3,m_RANSACStatus);

    int inlinerCount = 0;
    for (int l = 0; l < ptCount; ++l) {
        if (m_RANSACStatus[l] != 0)
            inlinerCount++;
    }
    cout<<"inlinerCount is "< inlierMatches;
    for (int i=0; i


实验效果图:

使用RANSAC提纯ORB和BRISK特征点,达到鲁棒匹配的效果(OpenCV 2.4.13下,源码)_第1张图片

(kp_graf_1)

使用RANSAC提纯ORB和BRISK特征点,达到鲁棒匹配的效果(OpenCV 2.4.13下,源码)_第2张图片

(kp_graf_3)

使用RANSAC提纯ORB和BRISK特征点,达到鲁棒匹配的效果(OpenCV 2.4.13下,源码)_第3张图片

(不经过任何处理的图像匹配)

使用RANSAC提纯ORB和BRISK特征点,达到鲁棒匹配的效果(OpenCV 2.4.13下,源码)_第4张图片

(使用距离小于最小距离10倍时的匹配效果)

使用RANSAC提纯ORB和BRISK特征点,达到鲁棒匹配的效果(OpenCV 2.4.13下,源码)_第5张图片

(使用RANSAC算法提纯后的图像匹配效果)

你可能感兴趣的:(OpenCV,图像处理,计算机视觉,c++,计算机视觉,opencv,ORB,BRISK)