【QT报错opencv的undefined reference to `cv::VideoCapture::VideoCapture()‘,fatal error: opencv2/dnn/dnn.】

guanlin@guanlin-virtual-machine:~/OpenNI2Samples/build$ make

[ 10%] Built target InfraredOniFileRecorder
[ 15%] Linking CXX executable ColorReaderUVC
CMakeFiles/ColorReaderUVC.dir/ColorReaderUVC.cpp.o: In function main': ColorReaderUVC.cpp:(.text.startup+0x215): undefined reference to cv::VideoCapture::VideoCapture()’
ColorReaderUVC.cpp:(.text.startup+0x21f): undefined reference to cv::VideoCapture::open(int)' ColorReaderUVC.cpp:(.text.startup+0x227): undefined reference to cv::VideoCapture::isOpened() const’
ColorReaderUVC.cpp:(.text.startup+0x244): undefined reference to cv::VideoCapture::~VideoCapture()' ColorReaderUVC.cpp:(.text.startup+0x273): undefined reference to cv::VideoCapture::~VideoCapture()’
ColorReaderUVC.cpp:(.text.startup+0x295): undefined reference to cv::VideoCapture::set(int, double)' ColorReaderUVC.cpp:(.text.startup+0x2aa): undefined reference to cv::VideoCapture::set(int, double)’
ColorReaderUVC.cpp:(.text.startup+0x2bf): undefined reference to cv::VideoCapture::set(int, double)' ColorReaderUVC.cpp:(.text.startup+0x311): undefined reference to cv::VideoCapture::operator>>(cv::Mat&)’
collect2: error: ld returned 1 exit status
CMakeFiles/ColorReaderUVC.dir/build.make:94: recipe for target ‘ColorReaderUVC’ failed
make[2]: *** [ColorReaderUVC] Error 1
CMakeFiles/Makefile2:104: recipe for target ‘CMakeFiles/ColorReaderUVC.dir/all’ failed
make[1]: *** [CMakeFiles/ColorReaderUVC.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2

ubuntu下找不到VideoCapture类,原因是没有将libopencv_videoio.so连接进来,对于 VideoCapture 类,至少需要链接到 opencv_core、opencv_imgproc 和 opencv_videoio 库。

也就是在ui界面的pro文件修改。

fatal error: opencv2/dnn/dnn.hpp: 没有那个文件或目录

opencv库里没有dnn.hpp

如果你的OpenCV版本为3.x或更低版本,则确实没有dnn.hpp文件。

dnn.hpp是OpenCV 4.x版本中的深度学习模块的头文件。

如果你想在OpenCV3.x或更低版本中使用深度学习模块,你需要使用cafe或tensoriow等框架来实现。如果你想使用OpenCV 4.x版本中的深度学习模块,你需要升级你的OpenCV版本,并且确保你的编译选项正确设置。

相关问题
fatal error: opencv2/dnn/dnn.hpp: 没有那个文件或目录这个错误是由于编译器无法找到dnn.hpp文件,通常是由于OpenCV的头文件路径设置不正确导致的。

解决这个问题的方法是在编译选项中添加OpenCV的头文件路径。如果你使用的是CMake进行编译,可以在cMakeLists.txt文件中添加以下代码:

```bash
find package(OpenCV REQUIRED)
include directories(${OpenCW INCLUDE DIRS})

如果你手动编译,可以在编译命令中添加以下选项:

-I/path/to/opencv/include

其中/path/to/opencv是你安装OpenCV的路径。请确保这个路径下包含了 dnn.hpp文件。

tensort加速yolov5

在make的时候报错opencv2/dnn/dnn.hpp:没有那个文件或目录
#include<opencv2/dnn/dnn.hpp>这个错误提示是因为找不到OpenCV的dnn模块,可以尝试安装OpenCV并重新编译代码。具体步骤如下:
1.安装OpenCV
可以使用以下命令安装OpenCv

sudo apt-get update
sudo apt-get install libopencw-dev

2.修改Makefile
在Makefile中添加OpenCV的链接选项,具体如下:

LIBS+=`pkg-config --libs opencv

3.重新编译代码
执行以下命令重新编译代码:

make clean
make

如果还是出现类似的错误提示,可以尝试添加OpenCV的头文件路径

CFLAGS+= -I/usr/include/opencv4/
  • 17
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值