【opencv练习38 - SURF描述子】

SURF特征(speed up robust feature) 加速鲁棒特征
一种尺度不变特征检测器,其是SIFT(scale invariant feature transform 尺度不变特征变换)的高效变种算法。
特点:
1)运算速度快,实时性
2)尺度不变,稳定性
3)方向无关,稳定性

具体实现:
1.对每个像素计算Hessian矩阵
2….
3….

/*******************************************************************
    测试程序 SURF描述子
    时间:2016年9月5日
*******************************************************************/

void readme();

int main( void )
{

    Mat img_1 = imread( "1.jpg" , CV_LOAD_IMAGE_GRAYSCALE );
    Mat img_2 = imread( "2.jpg" , CV_LOAD_IMAGE_GRAYSCALE );

  if( !img_1.data || !img_2.data )
  { 
      cout<<"Step 000 OK"<<endl;
      return -1;
  }

  //Step 1: 使用SURF【检测子】,检测关键点 **************************************
  int minHessian = 400;

  SurfFeatureDetector detector( minHessian );

  std::vector<KeyPoint> keypoints_1, keypoints_2;

  //检测(图像 --> 点向量)
  detector.detect( img_1, keypoints_1 );    
  detector.detect( img_2, keypoints_2 );
  cout<<"Step 1 detect OK!!!"<<endl;

  //-- Step 2: 计算【描述子】(特征向量)**************************************
  SurfDescriptorExtractor extractor;

  Mat descriptors_1, descriptors_2;

  //检测(图像 + 点向量 --> 描述子)
  extractor.compute( img_1, keypoints_1, descriptors_1 );
  extractor.compute( img_2, keypoints_2, descriptors_2 );
  cout<<"Step 2 compute OK!!!"<<endl;

  //-- Step 3: 匹配描述子向量 with a brute force matcher **************************************
  BFMatcher matcher(NORM_L2);
  std::vector< DMatch > matches;

  //检测(描述子1 + 描述子2 --> matches)
  matcher.match( descriptors_1, descriptors_2, matches );

  cout<<"Step 3 match OK!!!"<<endl;
  //绘制匹配 -- Draw matches
  Mat img_matches;
  drawMatches( img_1, keypoints_1, img_2, keypoints_2, matches, img_matches );
  //-- 图像1+关键点1 + 图像2+关键点2 + matches向量 ——> 合成输出图像 
  imshow("Matches", img_matches );


  waitKey(0);

  return 0;
}

void readme()
{ 
    std::cout << " Usage: ./SURF_descriptor <img1> <img2>" << std::endl; 
}

这里写图片描述

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值