Ask Your Question
0

error: ‘imread’ was not declared in this scope

asked 2020-02-15 00:07:53 -0600

I am using OpenCV 4.0 from https://github.com/opencv/opencv/arch... 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?

edit retag flag offensive close merge delete

Comments

This is not a filename "hallo"

supra56 gravatar imagesupra56 ( 2020-02-16 11:06:54 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2020-02-15 01:11:59 -0600

berak gravatar image

please

#include <opencv2/imgcodecs.hpp>

in your code.

also you should not include anything from the src folder,

a proper make install should have copied the headers to

-I/usr/local/include/opencv4

and the libs to

-L/usr/local/lib
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-02-15 00:07:53 -0600

Seen: 1,792 times

Last updated: Feb 15 '20