#include<opencv2/opencv.hpp>
#include<highgui.h>
#include<iostream>
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
// read image
Mat picture = imread("./lena.jpg");
// create window
namedWindow("My Test", CV_WINDOW_AUTOSIZE);
// display
imshow("My Test", picture);
// 关闭
waitKey(0);
destroyWindow("My Test");
destroyWindow("My Gray Test");
return 0;
}
$ g++ hello2.cpp -o hello2 `pkg-config --cflags --libs opencv`
$ ./hello2
init done
opengl support available
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /mybk/opencv-3.2.0/modules/highgui/src/window.cpp, line 312
terminate called after throwing an instance of 'cv::Exception'
what(): /mybk/opencv-3.2.0/modules/highgui/src/window.cpp:312: error: (-215) size.width>0 && size.height>0 in function imshow
已放弃 (核心已转储)
同样的代码在opencv2.4.13下运行是没问题的。
#include<highgui.h>
#include<iostream>
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
// read image
Mat picture = imread("./lena.jpg");
// create window
namedWindow("My Test", CV_WINDOW_AUTOSIZE);
// display
imshow("My Test", picture);
// 关闭
waitKey(0);
destroyWindow("My Test");
destroyWindow("My Gray Test");
return 0;
}
$ g++ hello2.cpp -o hello2 `pkg-config --cflags --libs opencv`
$ ./hello2
init done
opengl support available
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /mybk/opencv-3.2.0/modules/highgui/src/window.cpp, line 312
terminate called after throwing an instance of 'cv::Exception'
what(): /mybk/opencv-3.2.0/modules/highgui/src/window.cpp:312: error: (-215) size.width>0 && size.height>0 in function imshow
已放弃 (核心已转储)
同样的代码在opencv2.4.13下运行是没问题的。