我在Eclipse Mars中配置了OpenCV 3.1.0.这些是我的配置,
G ++包括:D:/ opencv/build/install/include; GCC包括:D:/ opencv/build/install/include
链接库:libopencv_core310,libopencv_highgui310
链接器库路径:D:/ opencv/build/lib(此目录中的文件类似于libopencv_core310.dll.a)
我收到这样的错误,
imageRead.cpp:15: undefined reference to `cv::imread(cv::String const&, int)'
这是我的imageRead.cpp文件,
#include#include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" using namespace std; using namespace cv; int main(int argc, const char** argv) { Mat img = imread("D:/sample.jpg", CV_LOAD_IMAGE_UNCHANGED); if (img.empty()) { cout << "Error: Image cannot be loaded." << endl; system("pause"); return -1; } namedWindow("Image Window", CV_WINDOW_AUTOSIZE); imshow("Image Window", img); if (waitKey() == 27) { return -1; } destroyWindow("Image Window"); return 0; }
有人可以帮忙解决这个错误吗?
从OpenCV3开始,imread函数驻留在imgcodecs模块中.将opencv_imgcodecs
库添加到项目后,Imread应该可以工作(注意:imgcodecs,而不是imcodecs).
我建议链接以下库:
opencv_core opencv_highgui opencv_imgproc opencv_imgcodecs
在.cpp文件中,您可以包含这样的内容
#include#include #include #include using namespace std; using namespace cv;
要么
#include#include using namespace std; using namespace cv;