amsw11 2015-09-27 06:24 采纳率: 0%
浏览 2433

opencv下surf代码出错显示未经处理的异常: 0xC0000005

#include "opencv2/core/core.hpp"

#include "opencv2/features2d/features2d.hpp"

#include "opencv2/highgui/highgui.hpp"

#include "opencv2/nonfree/nonfree.hpp"

#include

using namespace cv;

int main(int argc, char** argv)
{
//【0】改变console字体颜色

system("color 2F");

//【0】显示帮助文字    

//【1】载入源图片并显示  
Mat srcImage1 = imread("F:\\01.jpg", 1);
Mat srcImage2 = imread("F:\\02.jpg", 1);
if (!srcImage1.data || !srcImage2.data)//检测是否读取成功  
{
    printf("读取图片错误,请确定目录下是否有imread函数指定名称的图片存在~! \n"); return false;
}
imshow("原始图1", srcImage1);
imshow("原始图2", srcImage2);

//【2】定义需要用到的变量和类  
int minHessian = 400;//定义SURF中的hessian阈值特征点检测算子  
SurfFeatureDetector detector(minHessian);//定义一个SurfFeatureDetector(SURF) 特征检测类对象  
std::vector<KeyPoint> keypoints_1, keypoints_2;//vector模板类是能够存放任意类型的动态数组,能够增加和压缩数据  

//【3】调用detect函数检测出SURF特征关键点,保存在vector容器中  
detector.detect(srcImage1, keypoints_1);
detector.detect(srcImage2, keypoints_2);

//【4】绘制特征关键点  
Mat img_keypoints_1; Mat img_keypoints_2;
drawKeypoints(srcImage1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
drawKeypoints(srcImage2, keypoints_2, img_keypoints_2, Scalar::all(-1), DrawMatchesFlags::DEFAULT);

//【5】显示效果图  
imshow("特征点检测效果图1", img_keypoints_1);
imshow("特征点检测效果图2", img_keypoints_2);

waitKey(60000);
return 0;

}
网上说是有空指针或内存越界,哪儿出错了,有时还有桟损坏

  • 写回答

1条回答 默认 最新

  • devmiao 2015-09-27 15:54
    关注

    目测是指针的问题,单步执行,找到错误的行,看指针是否没有初始化

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab实现基于主成分变换的图像融合。
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊