opencv - opencv 中对 `cv::imread(std::string const&, int)' 的 undefined reference

标签 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

最佳答案

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

关于opencv - opencv 中对 `cv::imread(std::string const&, int)' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42921025/

相关文章:

c++ - 使用鼠标手动提取对象

android - ndk-build.cmd 编译失败(opencv 人脸检测)

r - 量化灰度图像

c# - 两幅图像之间的差异

python - 从 JPG 到 b64encode 再到 cv2.imread()

c++ - "opencv2 computer vision application programming cookbook"书中代码的QT配置

c++ - 将 OpenGL 纹理转换为 OpenCV 矩阵

algorithm - 地平线检测算法

java - 如何将图像标准化为一系列值

android - 在 Android 中将卷积矩阵算法从 Java 转换为 JNI 时未获得预期结果