我最近安装了 OpenCV,但无法使用imread()
。
这是我的代码
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( )
{
Mat i=imread("home/ali/opencv/lena.png",1);
namedWindow("a",WINDOW_FULLSCREEN);
imshow("a",i);
waitKey(0);
return 0;
}
这是我.pro
在 Qt 中的文件
QT += core
QT -= gui
CONFIG += c++11
TARGET = opencv
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_imgcodecs
SOURCES += main.cpp
这是我收到的:
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/ali/Downloads/opencv/opencv-3.2.0.www.fileniko.com/opencv-3.2.0/modules/highgui/src/window.cpp, line 304
terminate called after throwing an instance of 'cv::Exception'
what(): /home/ali/Downloads/opencv/opencv-3.2.0.www.fileniko.com/opencv-3.2.0/modules/highgui/src/window.cpp:304: error: (-215) size.width>0 && size.height>0 in function imshow
Press <RETURN> to close this window...
^A
使用opencv3.2 ubuntu qt