机器学习备注:YOLOV3在visual studio2015(version: update3)上的编译调试
用linux没有windows那么多,用起来觉得vc的调试工具还是比linux里好用,于是把YOLOv3(Darknet)整到visual studio里去玩玩。记录下碰到的问题,
项目的下载地址在这里,
https://github.com/AlexeyAB/darknet
感谢作者,整个过程还算顺利,安装可以参考这里
https://github.com/AlexeyAB/darknet/issues/1455#issuecomment-416030423
这里整理一下原文安装过程(请使用OpenCV3.2.0替代文中的OpenCV3.3.0, 解释看后面)
- Windows 10 + Visual Studio 2015 Update 3
https://download.microsoft.com/download/4/8/f/48f0645f-51b6-4733-b808-63e640cddaec/vs2015.3.exe
推荐你下载光盘镜像,
http://download.microsoft.com/download/7/c/f/7cf151c3-b735-4e35-a1bb-9a48224f4a95/vs2015.3.ent_chs.iso
- download OpenCV 3.3.0
https://nchc.dl.sourceforge.net/project/opencvlibrary/opencv-win/3.3.0/opencv-3.3.0-vc14.exe
编译:俺没有GPU,所以直接打开
\darknet-master\build\darknet\darknet_no_gpu.sln选择了Release
然后添加依赖
(Right click darknet_no_gpu project) > (Click Properties) > C/C++ > Additional include Directories
add
- D:\opencv_3.3.0\build\include
- D:\opencv_3.3.0\build\include\opencv
- D:\opencv_3.3.0\build\include\opencv2
Configuration Properties > Linker > Input > Additional Dependencies
add
- D:\opencv_3.3.0\build\x64\vc14\lib\opencv_world330.lib
- D:\opencv_3.3.0\build\x64\vc14\lib\opencv_world330d.lib
重点是会碰到问题,记录一下
第一个问题
报错
1>e:\ayolo\darknet-master\src\darknet.c(355): warning C4013: “_CrtSetDbgFlag”未定义;假设外部返回 int
1>e:\ayolo\darknet-master\src\darknet.c(355): error C2065: “_CRTDBG_ALLOC_MEM_DF”: 未声明的标识符
1>e:\ayolo\darknet-master\src\darknet.c(355): error C2065: “_CRTDBG_LEAK_CHECK_DF”: 未声明的标识符
解决办法1-- 注释掉内存跟踪那行
int main(int argc, char **argv)
{
ifdef _DEBUG
// _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
解决办法2-- 添加内存跟踪头文件
在Darknet.c中添加
#if defined(WIN32)
#include <crtdbg.h>
#endif
第二个问题,cvdef.h(58): error C2061: 语法错误: 标识符“cv”
问题
1>d:\dependency\opencv3.3.0\include\opencv2\core\cvdef.h(58): error C2061: 语法错误: 标识符“cv”
1>d:\dependency\opencv3.3.0\include\opencv2\core\cvdef.h(434): fatal error C1070: 文件
“d:\dependency\opencv3.3.0\include\opencv2\core\cvdef.h”中的 #if/#endif 对不匹配
解决办法
使用Opencv3.2.0, 警报消失,编译成功
恰好github上有同样的人在问,在github上的回复了(https://github.com/AlexeyAB/darknet/issues/233)