简体   繁体   English

错误:“imread”未在此范围内声明

[英]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我正在使用来自https://github.com/opencv/opencv/archive/4.0.0.zip 的OpenCV 4.0 下面是代码

#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?关于如何解决它的任何方向?

put #include <opencv2/imgcodecs.hpp> and use put #include <opencv2/imgcodecs.hpp>并使用

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

to compile will solve the problem编译将解决问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM