AV(Access Violation)错误:非法访问。

image_match.exe 中的 0x0000002a 处有未经处理的异常: 0xC0000005: Access violation

程序完全完全拷贝,在别人电脑上可以运行,在自己电脑上则不行!考虑是环境配置问题。

cout无法显示Mat类,狂跳exceptional,大概是你想用VS2012的<<操作符,但是dll的ostream operator<<其实是用的vs2010的<<,结果两者冲突了。所以导致exceptional的出现。


原因:使用的opencv版本太乱了,之前的没卸载干净

处理办法:进系统变量和用户变量中删除其他版本的path值。

如果当初有用过vs2012,在里面设置过vc11下的lib,后来又把平台换成VS2010,设置了VC10的路径而忘记删除VC11,这次请把以前vc11的路径删掉,只保留VC10。【参考而已,适当删除!】

#include "opencv2/core/core.hpp"
#include "highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/legacy/legacy.hpp" using namespace cv;
using namespace std; int main(int argc, char** argv)
{
//待匹配的两幅图像,其中img1包括img2,也就是要从img1中识别出img2
Mat img1 = imread("book_in_scene.png");
Mat img2 = imread("book.png"); Mat image01;
Mat image02;
cvtColor(img1,image01,CV_RGB2GRAY);
cvtColor(img2,image02,CV_RGB2GRAY);
SIFT sift1, sift2; vector<KeyPoint> key_points1, key_points2; Mat descriptors1, descriptors2, mascara; sift1(img1,mascara,key_points1,descriptors1);
sift2(img2,mascara,key_points2,descriptors2); //实例化暴力匹配器——BruteForceMatcher
BruteForceMatcher<L2<float>> matcher;
//定义匹配器算子
vector<DMatch>matches;
//实现描述符之间的匹配,得到算子matches
matcher.match(descriptors1,descriptors2,matches); //提取出前3个最佳匹配结果
nth_element(matches.begin(), //匹配器算子的初始位置
matches.begin()+, // 排序的数量
matches.end()); // 结束位置
//剔除掉其余的匹配结果
matches.erase(matches.begin()+, matches.end()); namedWindow("SIFT_matches");
Mat img_matches;
//在输出图像中绘制匹配结果
drawMatches(img1,key_points1, //第一幅图像和它的特征点
img2,key_points2, //第二幅图像和它的特征点
matches, //匹配器算子
img_matches, //匹配输出图像
Scalar(,,)); //用白色直线连接两幅图像中的特征点
imshow("SIFT_matches",img_matches); vector<Point2f> imagePoints1,imagePoints2;
for(int i=;i<;i++)
{
imagePoints1.push_back(key_points1[matches[i].queryIdx].pt);
imagePoints2.push_back(key_points2[matches[i].trainIdx].pt);
} Mat homo=findHomography(imagePoints1,imagePoints2,CV_RANSAC);
////也可以使用getPerspectiveTransform方法获得透视变换矩阵,不过要求只能有4个点,效果稍差  
//Mat homo=getPerspectiveTransform(imagePoints1,imagePoints2);     
cout<<"变换矩阵为:\n"<<homo<<endl<<endl;//输出映射矩阵  
//图像配准  
Mat imageTransform1,imageTransform2;
warpPerspective(image01,imageTransform1,homo,Size(image02.cols,image02.rows));
imshow("经过透视矩阵变换后",imageTransform1);
waitKey(); return ;
}

以上是图像特征匹配代码。

科学网—【opencv】cout显示Mat类对象会跳出exceptional的解决方法 - 邓若曦的博文 http://blog.sciencenet.cn/blog-972981-712339.html

c++ - opencv: using cout with Mat object throwing exception - Stack Overflow

problem with reading image to Mat - OpenCV Q&A Forum

cout显示Mat类对象报错Access Violation的更多相关文章

  1. std::vector push_back报错Access violation

    C/C++ code   ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include < ...

  2. 网站报错Access denied for user 'root'@'localhost' -问题排查续

    网站报错Access denied for user 'root'@'localhost' (using password: YES) 每次的挽救办法就是: /etc/init.d/mysqld st ...

  3. MyEclipse上有main函数类运行报错:Editor does not contain a main type

    MyEclipse下有main函数类运行报错:Editor does not contain a main type 出现这种问题的原因是,该java文件所在的包没有被MyEclipse认定为源码包. ...

  4. 报错: Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library

    报错: Access restriction:The type JPEGCodec is not accessible due to restriction on required library C ...

  5. 008-MySQL报错-Access denied for user 'root'@'localhost' (using password: NO)

    1.新安装的mysql报错 MySQL报错-Access denied for user 'root'@'localhost' (using password: NO) 解决方案 1.先停掉原来的服务 ...

  6. MyEclipse上有main函数类运行报错:Editor does not contain a

    MyEclipse下有main函数类运行报错:Editor does not contain a main type?出现这种问题的原因是,该java文件   MyEclipse下有main函数类运行 ...

  7. PL/SQL插入数据报错:Access violation at address 00413A81 in module 'plsqldev.exe'. Read of address 00000000

    前言 今天同事在使用plsql给oracl数据库插入记录时报错:Access violation at address 00413A81 in module 'plsqldev.exe'. Read ...

  8. List转换成JSON对象报错(一)

    List转换成JSON对象 1.具体报错如下 Exception in thread "main" java.lang.NoClassDefFoundError: org/apac ...

  9. java使用类数组 报错Exception in thread "main" java.lang.NullPointerException

    源代码如下: Point[] points=new Point[n];//Point是一个类 for(int i=0;i<n;i++) { System.out.print("请输入x ...

随机推荐

  1. 企业建站系统MiinCMP1.0.5 标准版公布!

    2014-5-6日,Juuluu公布其企业建站系统MiinCMP1.0.5 标准版,1.0.5是一款相对成熟的企业站点解决方式.执行MiinCMP1.0.5,仅仅需2M的mysql,50m的java空 ...

  2. Shell 传递参数(转)

    我们可以在执行 Shell 脚本时,向脚本传递参数,脚本内获取参数的格式为:$n.n 代表一个数字,1 为执行脚本的第一个参数,2 为执行脚本的第二个参数,以此类推…… 实例 以下实例我们向脚本传递三 ...

  3. linux下的QQ执行玩法:pidgin-lwqq

    安装pidgin: sudo apt-get install pidgin 安装pidgin-lwqq: sudo add-apt-repository ppa:lainme/pidgin-lwqq ...

  4. 08-session详解

    如何获取session对象? 1,openSession 2,getCurrentSession 如果使用getCurrentSession需要在hibernate.cfg.xml文件中进行配置: 如 ...

  5. lspci查看硬件信息时提示找不到命令

    系统环境:centos 6.3 X64 错误信息:[root@localhost ~]# lspci-bash: lspci: command not found 问题原因:这是因为没有安装pciut ...

  6. Linux-查看C语言手册及man的特殊用法

    man命令可以查看c语言库函数的函数原型, 比如 $ man malloc 如果显示 "No manual entry for malloc", 则需要安装 "man-p ...

  7. myBatis的引出

    jdbc 优点:简单易学,上手快,非常灵活构建sql,效率高. l缺点:代码繁琐,难以写出高质量的代码(资源的释放,SQL注入安全性等),开发者关注多,又要写业务逻辑,又要关注对象的创建和销毁. Hi ...

  8. excel合并单元格

    最简单的: =A1&B1&C1 在C14单元格中输入公式:=CONCATENATE(A14,"@",B14,".com"),确认后,即可将A14 ...

  9. swift向方法传数组参数的语法

    总是记不住向方法中传数组参数的语法,所以记录一下. func calculateStatistics(scores:[Int]) -> (min:Int,max:Int,sum:Int) { v ...

  10. javascript和html中unicode编码和字符转义的详解

    1.html中的转义:在html中如果遇到转义字符(如“ ”),不管你的页面字符编码是utf-8亦或者是GB2312,都会直接打印成相应的字符:而当遇到(如:“\u8981”[此处的8981是16进制 ...