"错误:尝试使用 OpenCV 和 CUDA 构建暗网时,'IplImage' 未命名类型? [英] "Error: 'IplImage' does not name a type when trying to build darknet with OpenCV and CUDA?

查看:19
本文介绍了"错误:尝试使用 OpenCV 和 CUDA 构建暗网时,'IplImage' 未命名类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Darkent 与 OpenCV 和 CUDA 结合使用.我按照以下说明安装了暗网:

https://pjreddie.com/darknet/install/

我按照以下说明安装了 CUDA:

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

最后,我按照这些说明安装了 OpenCV:

http://www.linuxfromscratch.org/blfs/view/svn/general/opencv.html

然后我将以下几行添加到我的 bashrc 末尾:

export PATH=$PATH:/usr/local/cuda-11.1/bin导出 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.1/lib64:/usr/include/opencv4export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/include/opencv4

然后我在暗网找到 opencv 库时遇到了麻烦,所以我在/usr/local/lib/pkgconfig 添加了一个 opencv.pc 文件,内容如下:

<预><代码>前缀=/usrexec_prefix=${prefix}libdir=${prefix}/lib/x86_64-linux-gnuincludeir_new=${prefix}/include/opencv4名称:OpenCV描述:开源计算机视觉库版本:4.5.0库: -L${libdir} -lopencv_dnn -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videocvcode_opencvl_img_videoopen_videoopen_video_opennLibs.private: -ldl -lm -lpthread -lrtCflags: -I${includedir_new}

接下来,我修改了darknet目录下的Makefile,使得GPU=1,OPENCV=1.我运行了 make,但遇到错误:

./src/image_opencv.cpp:12:1: 错误:IplImage"没有命名类型12 |IplImage *image_to_ipl(image im)|^~~~~~~~编译因 -Wfatal 错误而终止.

任何帮助将不胜感激.我正在运行 ubuntu 20.04,内核 5.4.0-53-generic.

解决方案

/src/image_opencv.cpp 文件中似乎缺少一些标题行,在开头添加这些行而不是使它再次.

#include "opencv2/core/core_c.h";#include "opencv2/videoio/legacy/constants_c.h";#include "opencv2/highgui/highgui_c.h";

此外,您必须在同一文件中将 IplImage ipl = m 行更改为 IplImage ipl = cvIplImage(m);.

I am trying to use Darkent with OpenCV and CUDA. I installed darknet according to these instructions:

https://pjreddie.com/darknet/install/

I installed CUDA according to these instructions:

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

Finally, I installed OpenCV according to these instructions:

http://www.linuxfromscratch.org/blfs/view/svn/general/opencv.html

I then added the following lines to the end of my bashrc:

export PATH=$PATH:/usr/local/cuda-11.1/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.1/lib64:/usr/include/opencv4
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/include/opencv4

I was then having trouble with darknet finding the opencv library, so I added an opencv.pc file at /usr/local/lib/pkgconfig, with the following content:


prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/x86_64-linux-gnu
includedir_new=${prefix}/include/opencv4

Name: OpenCV
Description: Open Source Computer Vision Library
Version: 4.5.0
Libs: -L${libdir} -lopencv_dnn -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_core
Libs.private: -ldl -lm -lpthread -lrt
Cflags: -I${includedir_new}

Next, I modified the Makefile in the darknet directory such that GPU=1, and OPENCV=1. I ran make, but am encountering the error:

./src/image_opencv.cpp:12:1: error: ‘IplImage’ does not name a type
   12 | IplImage *image_to_ipl(image im)
      | ^~~~~~~~
compilation terminated due to -Wfatal-errors.

Any help would be greatly appreciated. I am running ubuntu 20.04, kernel 5.4.0-53-generic.

解决方案

It seems there are some missing header lines in file /src/image_opencv.cpp, add these lines at the beginning than make it again.

#include "opencv2/core/core_c.h"
#include "opencv2/videoio/legacy/constants_c.h"
#include "opencv2/highgui/highgui_c.h"

Additionally, you have to change the line IplImage ipl = m to IplImage ipl = cvIplImage(m); in the same file.

这篇关于&quot;错误:尝试使用 OpenCV 和 CUDA 构建暗网时,'IplImage' 未命名类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆