OpenCV imread() problem
I have installed OpenCV lately and I cannot use imread().
This is my code
#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;
}and this is my .pro file in 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.cppthis is what I receive:
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/ali/Downloads/opencv/ line 304
terminate called after throwing an instance of 'cv::Exception' what(): /home/ali/Downloads/opencv/ error: (-215) size.width>0 && size.height>0 in function imshow
Press <RETURN> to close this window...
^AUsing opencv3.2 ubuntu qt
11 Answer
This comment provided the correct solution:
So - what happens, exactly? My guess is that your filepath is invalid (it needs to be "
/home/ali/opencv/lena.png" - note the leading /)
I changed the path and it worked.
0