java opencv surf_opencv surf特征编程出现错误

程序应该可以运行,网上很多,通过surf比较两幅图像,通过线段连接。试了好几个这样的程序,老师在matcher.match(descriptors_1,descriptors_2,matches);这一步错误希望高手解答#incl...

程序应该可以运行,网上很多,通过surf比较两幅图像,通过线段连接。试了好几个这样的程序,老师在matcher.match(descriptors_1,descriptors_2,matches);这一步错误希望高手解答

#include "stdafx.h"#include #include #include "opencv2/core/core.hpp"//因为在属性中已经配置了opencv等目录,所以把其当成了本地目录一样#include "opencv2/features2d/features2d.hpp"#include "opencv2/highgui/highgui.hpp"using namespace cv;using namespace std;void readme();int main(int argc,char* argv[]){ Mat img_1=imread("E:\\image\\church01.jpg",CV_LOAD_IMAGE_GRAYSCALE);//宏定义时CV_LOAD_IMAGE_GRAYSCALE=0,也就是读取灰度图像 Mat img_2=imread("E:\\image\\church02.jpg",CV_LOAD_IMAGE_GRAYSCALE);//一定要记得这里路径的斜线方向,这与Matlab里面是相反的 if(!img_1.data || !img_2.data)//如果数据为空 { cout< keypoints_1,keypoints_2;//构造2个专门由点组成的点向量用来存储特征点 detector.detect(img_1,keypoints_1);//将img_1图像中检测到的特征点存储起来放在keypoints_1中 detector.detect(img_2,keypoints_2);//同理 //在图像中画出特征点 Mat img_keypoints_1,img_keypoints_2; drawKeypoints(img_1,keypoints_1,img_keypoints_1,Scalar::all(-1),DrawMatchesFlags::DEFAULT); drawKeypoints(img_2,keypoints_2,img_keypoints_2,Scalar::all(-1),DrawMatchesFlags::DEFAULT); imshow("surf_keypoints_1",img_keypoints_1); imshow("surf_keypoints_2",img_keypoints_2); //计算特征向量 SurfDescriptorExtractor extractor;//定义描述子对象 Mat descriptors_1,descriptors_2;//存放特征向量的矩阵 extractor.compute(img_1,keypoints_1,descriptors_1); extractor.compute(img_2,keypoints_2,descriptors_2); //用burte force进行匹配特征向量 BruteForceMatcher>matcher;//定义一个burte force matcher对象 vectormatches; matcher.match(descriptors_1,descriptors_2,matches); //绘制匹配线段 Mat img_matches; drawMatches(img_1,keypoints_1,img_2,keypoints_2,matches,img_matches);//将匹配出来的结果放入内存img_matches中 //显示匹配线段 imshow("surf_Matches",img_matches);//显示的标题为Matches waitKey(0); return 0;}

matcher.match(descriptors_1,descriptors_2,matches);这一步错误

继续运行

展开

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值