zoukankan      html  css  js  c++  java
  • OpenCV教程(47) sift特征和surf特征

         在前面三篇教程中的几种角检测方法,比如harris角检测,都是旋转无关的,即使我们转动图像,依然能检测出角的位置,但是图像缩放后,harris角检测可能会失效,比如下面的图像,图像放大之前可以检测出为harris角,但是图像放大后,则变成了边,不能检测出角了。所以,harris角是缩放相关的。

    image

         在paper Distinctive Image Features from Scale-Invariant Keypoints中D.Lowe提出了SIFT算法,该算法是缩

    放无关的。

    sift算法原理参考下面两篇链接。

    http://blog.csdn.net/cserchen/article/details/5606859

    http://wenku.baidu.com/view/2e1f33b665ce050876321362.html

    论文的原文可见:http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf

    OpenCV中使用sift特征的代码如下:

    // Read input image
    image= cv::imread("../church01.jpg",0);

    keypoints.clear();
    // Construct the sift feature detector object
    cv::SiftFeatureDetector sift(
        0.03,  // feature threshold
        10.);  // threshold to reduce
    // sensitivity to lines

    // Detect the SURF features
    sift.detect(image,keypoints);

    cv::drawKeypoints(image,keypoints,featureImage,cv::Scalar(255,255,255),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

    // Display the corners
    cv::namedWindow("SIFT Features");
    cv::imshow("SIFT Features",featureImage);

    image

    surf算法可以看作加速的sift算法。原理参考http://wenku.baidu.com/view/1f66acf3f61fb7360b4c65ad.html

    opencv中使用surf的代码为:

    // Read input image
    cv::Mat image= cv::imread("../church03.jpg",0);
    // vector of keypoints
    std::vector<cv::KeyPoint> keypoints;
    keypoints.clear();
    // Construct the SURF feature detector object
    cv::SurfFeatureDetector surf(2500);
    // Detect the SURF features
    surf.detect(image,keypoints);

    cv::Mat featureImage;
    cv::drawKeypoints(image,keypoints,featureImage,cv::Scalar(255,255,255),cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

    // Display the corners
    cv::namedWindow("SURF Features");
    cv::imshow("SURF Features",featureImage);

    image

    完整代码:工程FirstOpenCV50

  • 相关阅读:
    全程软件测试_项目启动
    全程软件测试_规范测试过程
    python_json常用的方法
    python_eval的用法
    python_判断字符串编码的方法
    python_Notepad++编码集的说明
    python_编码集的介绍
    初识HTML
    mysql学习目录
    python学习目录
  • 原文地址:https://www.cnblogs.com/mikewolf2002/p/3603375.html
Copyright © 2011-2022 走看看