YOLOv3的Darknet在OpenCV3.4.1(bug)下编译出错填坑

刚配置完环境

https://www.cnblogs.com/clemente/p/11029117.html

能正常跑原版 darknet ,但是跑了一下别人修改的版本出现了错误

查Google之后才发现遇到这个问题的朋友不在少数,大概的原因是因为OpenCV 3.4.1在C的API里有bug,所以导致了这个编译问题。那么我将国外大神的办法转到这里,希望能够帮助大家解决这个问题,原帖地址在这,也衷心感谢这位国外大神。

步骤有两步,需要修改两个c文件。

 

第一步,找到:

/usr/local/include/opencv2/core/cvdef.h

修改485行左右的代码:

#else
#include <stdint.h>
namespace cv {
typedef ::int8_t int8_t;
typedef ::uint8_t uint8_t;
typedef ::int16_t int16_t;
typedef ::uint16_t uint16_t;
typedef ::int32_t int32_t;
typedef ::uint32_t uint32_t;
typedef ::int64_t int64_t;
typedef ::uint64_t uint64_t;
}
#endif

把这段代码注释掉,改为:

#else
#include <stdint.h>
//namespace cv {
//typedef ::int8_t int8_t;
//typedef ::uint8_t uint8_t;
//typedef ::int16_t int16_t;
//typedef ::uint16_t uint16_t;
//typedef ::int32_t int32_t;
//typedef ::uint32_t uint32_t;
//typedef ::int64_t int64_t;
//typedef ::uint64_t uint64_t;
//}
#endif
 

第二步,找到:

/usr/local/include/opencv2/highgui/highgui_c.h

修改139行左右的代码:

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

修改类型为:

CVAPI(CvRect)cvGetWindowImageRect(const char* name);

这两步做完以后,再在darknet文件夹下执行make命令,应该就能编译通过了。编译通过以后别忘了把修改过的代码改回来,因为不知道以后什么时候万一还会用到,到时候忘了自己改过这里的话会很麻烦。

 

 

 

参考

https://zhuanlan.zhihu.com/p/36933700

转载于:https://www.cnblogs.com/clemente/p/11031893.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值