zoukankan      html  css  js  c++  java
  • keypoint && DMatch

    下面单独介绍KEYPOINT 与DMatch的内在联系

     1     std::vector<cv::Point2f> points1, points2;
     2 
     3     for (std::vector<cv::DMatch>::const_iterator it= matches.begin();
     4              it!= matches.end(); ++it) {
     5 
     6              // Get the position of left keypoints
     7              float x= keypoints1[it->queryIdx].pt.x;
     8              float y= keypoints1[it->queryIdx].pt.y;
     9              points1.push_back(cv::Point2f(x,y));
    10              cv::circle(image1,cv::Point(x,y),3,cv::Scalar(255,255,255),3);
    11              // Get the position of right keypoints
    12              x= keypoints2[it->trainIdx].pt.x;
    13              y= keypoints2[it->trainIdx].pt.y;
    14              cv::circle(image2,cv::Point(x,y),3,cv::Scalar(255,255,255),3);
    15              points2.push_back(cv::Point2f(x,y));
    16     }

    class KeyPoint

    {          

                 Point2f  pt;  //坐标  常用的就是这个了

                 float  size; //特征点邻域直径

                 float  angle; //特征点的方向,值为[零,三百六十),负值表示不使用

                 float  response;

                 int  octave; //特征点所在的图像金字塔的组

                 int  class_id; //用于聚类的id

    }

    1. 存放匹配结果的结构:

      struct DMatch

      {              //三个构造函数

                DMatch():

      queryIdx(-1),trainIdx(-1),imgIdx(-1),distance(std::numeric_limits<float>::max()) {} //这块就相当于初始化

                DMatch(int  _queryIdx, int  _trainIdx, float  _distance ) :

      queryIdx( _queryIdx),trainIdx( _trainIdx), imgIdx(-1),distance( _distance) {}

                DMatch(int  _queryIdx, int  _trainIdx, int  _imgIdx, float  _distance ) :                   queryIdx(_queryIdx), trainIdx( _trainIdx), imgIdx( _imgIdx),distance( _distance) {}

                intqueryIdx;  //此匹配对应的查询图像的特征描述子索引

                inttrainIdx;   //此匹配对应的训练(模板)图像的特征描述子索引

                intimgIdx;    //训练图像的索引(若有多个)

      /*********************************         

      int queryIdx; // query descriptor index
      int trainIdx; // train descriptor index
      int imgIdx; // train image index

      ***********************************/

                float distance;  //两个特征向量之间的欧氏距离,越小表明匹配度越高。

                bool operator  < (const DMatch &m) const;

      };

    2. 3

      图片中特征点欧式距离的计算公式:

      0ρ = √( (x1-x2)2+(y1-y2)2 ) |x| = √( x2 + y2 )

  • 相关阅读:
    2018.7.9 模拟赛
    树状数组||归并排序求逆序对+离散化 nlogn
    LCS nlogn
    孤岛营救问题
    [POJ 3621] Sighting Cows
    树状数组求LIS
    nlogn求逆序对&&陌上花开
    最长可重区间集
    LCA模板
    [BZOJ] 4196 [Noi2015]软件包管理器
  • 原文地址:https://www.cnblogs.com/haoxing990/p/4593163.html
Copyright © 2011-2022 走看看