Sift特征

sift = scale invariant feature transform—— 尺度不变特征变换,具有尺度,旋转,仿射,视角,光照不变性。。

关于sift的特征介绍,已经有很多的blog对其进行简介了,见参考的blog。我也没有将2004年那篇原文精细看完,这里只是提供在opencv中如何实现 sift关键点的检测。

Code:

[cpp]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. #include <iostream>  
  2. #include <opencv2\core\core.hpp>  
  3. #include <opencv2\highgui\highgui.hpp>  
  4. #include <opencv2\highgui\highgui.hpp>  
  5. #include <opencv2\features2d\features2d.hpp>  
  6. #include <opencv2\nonfree\nonfree.hpp>             //  sift特征在这个头文件中  
  7.   
  8. using namespace std;  
  9. using namespace cv;  
  10.   
  11. int main()  
  12. {  
  13.     Mat image = imread("F:\\lena.png", 1);  
  14.     if(!image.data)  
  15.     {  
  16.         cout << "Fail to load image" << endl;  
  17.         return 0;  
  18.     }  
  19.     vector<KeyPoint> keypoints;          //  存放关键点  
  20.     SiftFeatureDetector sift(0.03, 10.0);   // 其中0.03代表特征的阀值:用于去除低对比度的关键点   10是用于降低直线敏感度的阀值:去除不稳点的边缘响应点  
  21.     sift.detect(image, keypoints);  
  22.     drawKeypoints(image, keypoints, image, Scalar(255,255,255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);  
  23.     namedWindow("sift");  
  24.     imshow("sift", image);  
  25.     waitKey(0);  
  26.     return 0;  
  27. }  

Explanation:

<1>sift函数阀值介绍见代码注释

<2>drawKeypoints函数:

(1)设置特征点的颜色时可以赋予一个负值,这将产生有趣的结果,即绘制的圆将拥有不同的随机颜色

(2)绘制标记参数:

 

[cpp]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. struct DrawMatchesFlags{    enum    {  
  2.         DEFAULT = 0, // 输出图像将被创建(Mat::create),  
  3.                      // 只画出特征点,而不画出周围的circle包含特征点的大小和方向.  
  4.         DRAW_OVER_OUTIMG = 1, // 输出图像将被创建(using Mat::create),匹配点将被画在输出图像的内容上.  
  5.         NOT_DRAW_SINGLE_POINTS = 2, // 单个的点不画出.  
  6.         DRAW_RICH_KEYPOINTS = 4 // 对每个特征点周围的circle,包含特征点的大小和方向将被画出.      
  7.     };  
  8. };  

Result:


参考blog:

http://www.cnblogs.com/cfantaisie/archive/2011/06/14/2080917.html

http://blog.youkuaiyun.com/abcjennifer/article/details/7639681

http://blog.youkuaiyun.com/xiaowei_cqu/article/details/8069548

http://www.cnblogs.com/tornadomeet/archive/2012/08/16/2643168.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值