【问题标题】:YOLO compilation with OPENCV=1 failsOPENCV=1 的 YOLO 编译失败
【发布时间】:2018-02-04 17:52:29
【问题描述】:

我正在按照 YOLO 说明使用 make 文件进行编译,使用 OPENCV=1

GPU=1
CUDNN=0
OPENCV=1
OPENMP=0
DEBUG=0

尝试在带有 CUDA8.0 和 CUDNN6 的 Ubuntu 16.04 PC 上使用 OPENCV=1 制作时出现以下错误

`MYPC:~/darknet$ make
 gcc -Iinclude/ -Isrc/ -DOPENCV `pkg-config --cflags opencv`  -DGPU -I/usr/local/cuda/include/ -Wall -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -DOPENCV -DGPU -c ./src/gemm.c -o obj/gemm.o
In file included from /usr/local/include/opencv2/core/core_c.h:48:0,
                 from /usr/local/include/opencv2/highgui/highgui_c.h:45,
                 from include/darknet.h:25,
                 from ./src/utils.h:5,
                 from ./src/gemm.c:2:
/usr/local/include/opencv2/highgui/highgui_c.h:139:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
 CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);
 ^
compilation terminated due to -Wfatal-errors.
Makefile:85: recipe for target 'obj/gemm.o' failed
make: *** [obj/gemm.o] Error 1`

附加信息:我的 opencv 安装在主目录中,文件夹名称为“opencv”

`$ python
 Python 3.5.4 |Anaconda 4.2.0 (64-bit)| (default, Nov 20 2017, 18:44:38) 
 [GCC 7.2.0] on linux
 Type "help", "copyright", "credits" or "license" for more information.
 >>> 
 >>> import cv2
 >>> cv2.__version__
 '3.4.0'`

` 有什么解决这个问题的建议吗?

【问题讨论】:

    标签: opencv opencv3.0 darknet


    【解决方案1】:

    打开“/usr/local/include/opencv2/highgui/highgui_c.h”文件并注释掉第139行:

    //CVAPI(cv::Rect)cvGetWindowImageRect(const char* name);
    

    【讨论】:

    • 为什么?这条线是做什么的?
    • 原因是这段代码将使用 C 编译器(不是 C++)编译,其中不存在命名空间概念。声明中的“cv::Rect”在 C 中无效并导致问题。当我检查该功能未在 Yolo 中使用时,因此推测删除它是安全的。我让我的 yolo 工作,到目前为止还没有遇到任何问题。
    猜你喜欢
    • 1970-01-01
    • 2014-06-01
    • 2014-06-03
    • 2018-02-20
    • 1970-01-01
    • 2011-12-21
    • 2021-05-12
    • 2015-06-11
    • 2021-06-14
    相关资源
    最近更新 更多