未定义的引用`cv :: imread(std :: string const&,int)'在opencv中

时间:2017-03-21 07:45:12

标签: opencv image-processing

我正在使用opencv和cuda 6.5,当我尝试编译这段代码时:

#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <stdio.h>
using namespace cv;

int main() {
Mat src = imread("mini.jpg", 0);

if (!src.data) exit(1);
gpu::GpuMat d_src(src);
gpu::GpuMat d_dst;
gpu::bilateralFilter(d_src, d_dst, -1, 50, 7);
gpu::Canny(d_dst, d_dst, 35, 200, 3);
Mat dst(d_dst);
imwrite("out.png", dst);
return 0;
}

我收到了这些错误:

ubuntu32@Dell32:~/Templates/openCV$ nvcc gpu.cu `pkg-config --cflags
--libs opencv` /tmp/tmpxft_000016c6_00000000-16_gpu.o: In function `main': tmpxft_000016c6_00000000-3_gpu.cudafe1.cpp:(.text+0x63): undefined reference to `cv::imread(std::string const&, int)' tmpxft_000016c6_00000000-3_gpu.cudafe1.cpp:(.text+0x1bc): undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)' collect2: error: ld returned 1 exit status

1 个答案:

答案 0 :(得分:2)

对于openCV 3.X,您需要将库imgcodecs添加到项目中。