OpenCV特征匹配总结

1.概述

在深度学习出现之前,图像中的特征匹配方法主要有

2.理论对比

3.代码实现

#include <iostream>
#include <opencv2/opencv.hpp>

int main(int argc, char** argv) {
    if(argc != 3) {
        std::cerr << "Usage: " << argv[0] << " <image1_path> <image2_path>" << std::endl;
        return -1;
    }

    // Load the images
    cv::Mat img1 = cv::imread(argv[1], cv::IMREAD_GRAYSCALE);
    cv::Mat img2 = cv::imread(argv[2], cv::IMREAD_GRAYSCALE);
    if(img1.empty() || img2.empty()) {
        std::cerr << "Error: Couldn't read one or both images. Check the paths and try again." << std::endl;
        return -1;
    }

    // Detect ORB keypoints and descriptors
    cv::Ptr<cv::ORB> orb = cv::ORB::create();
    std::vector<cv::KeyPoint> keypoints1, keypoints2;
    cv::Mat descriptors1, descriptors2;
    orb->detectAndCompute(img1, cv::noArray(), keypoints1, descriptors1);
    orb->detectAndCompute(img2, cv::noArray(), keypoints2, descriptors2);

    // Use BFMatcher to match the ORB descriptors
    cv::BFMatcher matcher(cv::NORM_HAMMING);
    std::vector<cv::DMatch> matches;
    matcher.match(descriptors1, descriptors2, matches);

    // Draw the matches
    cv::Mat imgMatches;
    cv::drawMatches(img1, keypoints1, img2, keypoints2, matches, imgMatches);
    cv::imshow("ORB Feature Matches", imgMatches);

    // Wait for a key press and then close
    cv::waitKey(0);

    return 0;
}

相关推荐

  1. OpenCV特征匹配总结

    2024-05-13 21:54:04       39 阅读
  2. OpenCV学习记录——特征匹配

    2024-05-13 21:54:04       49 阅读
  3. LightGlue-OpenCV 实现实时相机图片特征匹配

    2024-05-13 21:54:04       62 阅读
  4. opencv模板匹配

    2024-05-13 21:54:04       45 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-13 21:54:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-13 21:54:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-05-13 21:54:04       82 阅读
  4. Python语言-面向对象

    2024-05-13 21:54:04       91 阅读

热门阅读

  1. 信息系统架构_3.信息系统架构的一般原理

    2024-05-13 21:54:04       31 阅读
  2. vue3速览

    2024-05-13 21:54:04       34 阅读
  3. 完美实现vue3异步加载组件

    2024-05-13 21:54:04       39 阅读
  4. ts 详细-学习

    2024-05-13 21:54:04       30 阅读
  5. notepad++

    notepad++

    2024-05-13 21:54:04      31 阅读
  6. 存储芯片了解

    2024-05-13 21:54:04       34 阅读
  7. 大模型管理工具:Ollama

    2024-05-13 21:54:04       36 阅读
  8. 软件测试至关重要

    2024-05-13 21:54:04       25 阅读
  9. 做跨境电商如何解决IP独立环境?

    2024-05-13 21:54:04       32 阅读
  10. [HDLBits] Three modules

    2024-05-13 21:54:04       34 阅读