Ask Your Question

Revision history [back]

error: ‘imread’ was not declared in this scope

I am using OpenCV 4.0 from https://github.com/opencv/opencv/archive/4.0.0.zip Below is the code

#include "opencv2/core.hpp"
#include <opencv2/core/utility.hpp>
#include "opencv2/highgui.hpp"

using namespace std;
using namespace cv;



int main(int argc, const char* argv[]){
    Mat frame0 = imread("hallo");
    return 0;
}

I compile it with

g++ -std=c++11 test.cpp -o test -I/home/user/opencv/modules/core/include/ -I/home/user/opencv/modules/highgui/include/ -L/home/user/opencv/build/lib -lopencv_objdetect -lopencv_features2d -lopencv_imgproc -lopencv_highgui -lopencv_core -lopencv_imgcodecs

It throws me error

test.cpp: In function ‘int main(int, const char**)’:
test.cpp:11:32: error: ‘imread’ was not declared in this scope
     Mat frame0 = imread("hallo");

Any direction on how to resolve it?