#include<opencv2/opencv.hpp>
using namespace cv;//下面的所有cv相关类型不用加上前缀了
int main(){
Mat img =imread("/home/douxiao/Desktop/opencvtest/demo1/001.jpg");//声明Mat变量,并读取图片,imread中需要传入图片的绝对路径
imshow("image",img);//在窗口中显示载入的图片
waitKey();//等待按键
return 0;
}
直接复制后发现不能运行:
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /build/opencv-ys8xiq/opencv-2.4.9.1+dfsg/modules/highgui/src/window.cpp, line 269
terminate called after throwing an instance of 'cv::Exception'
what(): /build/opencv-ys8xiq/opencv-2.4.9.1+dfsg/modules/highgui/src/window.cpp:269: error: (-215) size.width>0 && size.height>0 in function imshow
已放弃 (核心已转储)