简体   繁体   English

克隆垫子时,OpenCV崩溃(是:这是OpenCV 3中的错误吗?)

[英]OpenCV crashes when cloning a mat (was: Is this a bug in OpenCV 3?)

I have this code in opencv 3 which crashes: 我在崩溃的opencv 3中有以下代码:

int main(int argc, char *argv[])
{
   cv::Mat image1(100, 100, CV_8UC1);
   cv::Mat image2 = image1.clone();
}

This code crashes on clone line with this error: 此代码在克隆行上崩溃,并显示以下错误:

 Unhandled exception at 0x00007FF62E41992B in test_aoolication.exe: 0xC0000005: Access violation reading location 0x000000000000000D.

Is it a bug in OpenCV 3 or I am doing something strange? 是OpenCV 3中的错误,还是我正在做一些奇怪的事情?

Based on some comments which reported they have no problem, I did more search and I found that the problem was I did not include opencv.hpp to my *.cpp file. 根据一些报告它们没有问题的评论,我进行了更多搜索,发现问题是我的* .cpp文件中没有包含opencv.hpp。

Interestingly, I did not get any compile time error and I was able to compile and run application. 有趣的是,我没有遇到任何编译时错误,并且能够编译和运行应用程序。

So if you have strange behavior in openCV, make sure that you included to your code! 因此,如果您在openCV中有奇怪的行为,请确保已将其包含在代码中!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM