AKAZE local features matching

AKAZE local features matching

一.知识补充

1.KAZE是日语音译过来的 , KAZE与SIFT、SURF最大的区别在于构造尺度空间,KAZE是利用非线性方式构造,得到的关键点也就更准确(尺度不变性 );

​ AKAZE局特征点检测与匹配 A表示Accelerated(加速的) ,与SIFT、 SUFR比较,更加稳定;相比比非线性尺度空间KAZE,AKAZE速度更加快。

2.homography详解

What is Homography?
Two images of a scene are related by a homography under two conditions.

The two images are that of a plane (e.g. sheet of paper, credit card etc.).
The two images were acquired by rotating the camera about its optical axis. We take such images while generating panoramas.
As mentioned earlier, a homography is nothing but a 3×3 matrix as shown below.

Let be a point in the first image and be the coordinates of the same physical point in the second image. Then, the Homography relates them in the following way

If we knew the homography, we could apply it to all the pixels of one image to obtain a warped image that is aligned with the second image.

二.代码实现

示例代码:

#include <opencv2/features2d.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;
const float inlier_threshold = 2.5f; // Distance threshold to identify inliers with homography check
const float nn_match_ratio = 0.8f;   // Nearest neighbor matching ratio
int main(int argc, char* argv[])
{
   
    CommandLineParser parser(argc, argv,
                             "{@img1 | ../data/graf1.png | input image 1}"
                             "{@img2 | ../data/graf3.png | input image 2}"
                             "{@homography | ../data/H1to3p.xml | homography matrix}");
    Mat img1 = imread(parser.get<String>("@img1"), IMREAD_GRAYSCALE);
    Mat img2 = imread(parser.get<String>("@img2"), IMREAD_GRAYSCALE);
    Mat homography;
    FileStorage fs(parser.get<String>("@homography"), FileStorage::READ);
    fs.getFirstTopLevelNode() >> homography;
    vector<KeyPoint> kpts1, kpts2;
    Mat desc1, desc2;
    Ptr<AKAZE> akaze = AKAZE::create();
    akaze->detectAndCompute(img1, noArray(), kpts1, desc1);
    akaze->detectAndCompute(img2, noArray(), kpts2, desc2);
    BFMatcher matcher(NORM_HAMMING);
    vector< vector<DMatch> > nn_matches;
    matcher.knnMatch(desc1, desc2, nn_matches, 2);
    vector<KeyPoint> matched1, matched2;
    for(size_t i = 0; i < nn_matches.size(); i++) {
   
        DMatch first = nn_matches[i][0];
        float dist1 = nn_matches[i][<
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值