求大神帮我看一下代码问题出在哪里 结果显示出来了可是在按回车关闭的时候有错误

weixin_41961421 2018-05-19 09:49:39


#include "stdafx.h"
#include "highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/legacy/legacy.hpp"
#include <iostream>

using namespace cv;
using namespace std;


int main()
{

Mat image01 = imread("G:\\汉代纹饰图片\\2.png");
Mat image02 = imread("G:\\汉代纹饰图片\\3.png");
imshow("p2", image01);
imshow("p1", image02);

//灰度图转换
Mat image1_1, image2_2, image1, image2, image3, image4, image5, image6;
cvtColor(image01, image1_1, CV_RGB2GRAY);
cvtColor(image02, image2_2, CV_RGB2GRAY);

//直方图均衡化
equalizeHist(image1_1, image3);
equalizeHist(image2_2, image4);

bilateralFilter(image3, image5, 5, 10.0, 2.0);
bilateralFilter(image4, image6, 5, 10.0, 2.0);

Canny(image5, image1, 100, 300);
Canny(image6, image2, 100, 300);


//提取特征点
SurfFeatureDetector surfDetector(800); // 海塞矩阵阈值,在这里调整精度,值越大点越少,越精准
vector<KeyPoint> keyPoint1, keyPoint2;
surfDetector.detect(image1, keyPoint1);
surfDetector.detect(image2, keyPoint2);

//特征点描述,为下边的特征点匹配做准备
SurfDescriptorExtractor SurfDescriptor;
Mat imageDesc1, imageDesc2;
SurfDescriptor.compute(image1, keyPoint1, imageDesc1);
SurfDescriptor.compute(image2, keyPoint2, imageDesc2);

FlannBasedMatcher matcher;
vector<vector<DMatch> > matchePoints;
vector<DMatch> GoodMatchePoints;

vector<Mat> train_desc(1, imageDesc1);
matcher.add(train_desc);
matcher.train();

matcher.knnMatch(imageDesc2, matchePoints, 2);
cout << "total match points: " << matchePoints.size() << endl;

// Lowe's algorithm,获取优秀匹配点
for (int i = 0; i < matchePoints.size(); i++)
{
if (matchePoints[i][0].distance < 0.6 * matchePoints[i][1].distance)
{
GoodMatchePoints.push_back(matchePoints[i][0]);
}
}

Mat first_match;
drawMatches(image02, keyPoint2, image01, keyPoint1, GoodMatchePoints, first_match);
imshow("first_match ", first_match);
imwrite("first_match.jpg", first_match);
cout << "total good match points: " << GoodMatchePoints.size() << endl;
waitKey();
return 0;
}
...全文
872 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2018-05-21
  • 打赏
  • 举报
回复
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处,看不懂时双击下一行,直到能看懂为止

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧