使用OpenCV匹配多张ORB图片

本文介绍如何使用OpenCV库进行ORB特征检测和匹配,通过代码实现对多张图片的匹配过程,并展示了相应的匹配结果。
摘要由CSDN通过智能技术生成

代码

//
// Created by wcm on 2020/6/15.
//
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <chrono>
#include <nmmintrin.h>

using namespace std;
using namespace cv;


//寻找图片关键点
void find_feature_matches(
        //读取图片文件,保存为向量
        //图片关键点
        Mat &img_1, Mat &img_2,
        std::vector<KeyPoint> &keypoints_1,
        std::vector<KeyPoint> &keypoints_2,
        std::vector<DMatch> &matches
        );



int main()
{
   
    cv::String path = "/home/automobile/wcm/img_data" ;
    cv::String savedfilename;
    std::vector<cv::String> filenames;
   //cv::glob()读取文件夹中数据
   cv::glob(path, filenames);

   if(filenames.size() == 0){
   
       cout << "No image files[png]" <<endl;
   }



    chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
    Mat img_1, img_2;
    vector<KeyPoint> keypoints_1, keypoints_2;
    vector<DMatch> good_matches;
    find_feature_matches(img_1, img_2, keypoints_1, keypoints_2, good_matches);
    cout << "size = " << filenames.size() <<endl;

    //从尾部开始匹配图片
    for(int i = filenames.size(); i > 0; i--){
   
        img_1 = cv::imread(filenames[i]);
        cout << "read i = " << i << endl;
        img_2 = cv::imread(filenames[i-1]);
        cout << "read i+1 = " << i-1 <<endl;
        find_feature_matches(img_1, img_2, keypoints_1, keypoints_2, good_matches);
    }


    chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
    chrono::duration<double> time_used_match = chrono::duration_cast<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值