When the darknet is integrated into the project, there are some problems, the following record the workaround:
Integration steps:
First, when the YOLO is compiled, you need to open three switches:
#define GPU
#define CUDNN
#define OPENCV
Put the compiled libdarknet.so and darknet.h into the corresponding project folder respectively;
Add the corresponding Lib path and include path in CMakeLists.txt;
Add the appropriate CPP and HPP as well as the main function test code, and modify the corresponding CMakeLists.txt;
Compile
The problems encountered and how to resolve them are as follows:
Problem: Functions such as load_network are not defined and cannot be found
Cause: YOLO is a pure C framework, the project is C + +, so the function to be called needs to add extern "C" {}
Workaround: Include all function definitions in darknet.h with extern "C" {}
Problem: List ambigous;
Reason: in C + + standard library has list this container, but in darknet.h also defined the same name structure body;
WORKAROUND: Apply the global using namespace Std to the project, remove it and use std:
Question: Caffe::caffe::set_mode (CAFFE::CAFFE::GPU), error here, specifically forget what is wrong, in short, is related to the # define GPU in Darknet.h
Workaround:
#undef GPU
Caffe::caffe::set_mode (CAFFE::CAFFE::GPU);
#define GPU
Problem: No. 0 Graphics card running the project when normal, instead of the 1th graphics card times wrong: CUDA error:an Illegal memory access was encountered./src/cuda.c:36:check_error:assertion ' 0 ' failed.
Reason: Search for the relevant solution on the net, generally is the computation ability that place changes after recompile YOLO, but with me is not the same situation, I was in call Setdeviceid when the mistake;
WORKAROUND: You should call Cuda_set_device (GPU_ID) before calling Load_network (_cfgfile, _weightfile, 0);
At present, the YOLO is the above problems;
There are some other soft links can not find the problem, and later found to be connected to the system path to go, rather than connect to the same folder under the library, do not know how to cause, only delete the re-link.
Darknet integration problems and how to solve them