Include darknet Yolov3 for object detection

我的梦境 提交于 2020-06-16 05:45:34

问题


Unfortunately I am not very experienced with C++ and the handling of Visual Studio. I have to implement a C++ application, in which I can integrate yolo or darknet as a library and use it flexibly. I'm using Windows and Visual Studio 2015.

I have looked at the following repo. What I have tried so far:

  • I have installed CUDA (although I want to run the model on the CPU for testing purposes), Cudnn and Opencv
  • I opened the vs solution from build\darknet\darknet_no_gpu.sln from the AlexeyAb repo with Visual Studio. Inside the repo there are a lot of header and C-files :

  • I also added my opencv\build\include path to the Additional Include Directories, the opencv\x64\vc14\lib to the Additonal Library Directories and the opencv_world320.dllfile to the linker Input field.

  • I also set x64 and Release

Now, I don't know how to proceed. Just creating a source.cpp and do a #include "darknet.h" seems not to work. I get a lot of errors like: darknet_no_gpu.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.. In the repo it is mentioned at several places that you have to build the solution but what exactly does this mean or what exactly do I get afterwards and do with it?

Does anyone know how I could solve my problem? I'm really glad for any advice!


回答1:


For using Yolo v3 in a C++ application you can use the Alexey AB darknet repo.
Just build the yolo_cpp_dll.sln or the yolo_cpp_dll_no_gpu.sln in the build/darknet folder depending on whether you need GPU support or not.
There's also an example console application provided in the repository, that already integrates the yolo dll and it's features (see build/darknet/yolo_console_dll.sln).
You can find more information on how to get those solutions to work and how to use darknet as a dll library here.
The C++ API of the yolo dll can be found here.

To add the Yolo DLL to a VS project, you have to ...

... set Build to Release x64
... configure following properties in "Configuration Properties" tab for Release x64:

  • add the path of the folder of the header file (yolo_v2_class.hpp) under Project->Configuration Properties->C/C++->General->Additional Include Directories

  • add the path of the folder of the lib file (yolo_cpp_dll.lib) under Project->Configuration Properties->Linker->General->Additional Library Directories

  • add yolo_cpp_dll.lib under Project->Configuration Properties->Linker->Input->Additional Dependencies

... put pthreadVC2.dll and yolo_cpp_dll.dll close to your .exe file (you can find those dlls in build/darknet/x64 if you already built the yolo_cpp_dll.sln or the yolo_cpp_dll_no_gpu.sln)

Thanks to @glm_java for fixing my runtime issue when using the yolo dll!

If you have further questions, on how to build or compile these solutions, feel free to ask me!




回答2:


@LRK I got the same bad_alloc exception and I've solved using changing visual studio from Debug to Release mode. I hope it will work.



来源:https://stackoverflow.com/questions/61286151/include-darknet-yolov3-for-object-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!