3

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 :

enter image description here

  • 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!

desertnaut
  • 57,590
  • 26
  • 140
  • 166
f_3464gh
  • 162
  • 3
  • 11

2 Answers2

3

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!

LRK
  • 123
  • 1
  • 8
  • DO you know where to include the dll in visual Studio? – f_3464gh Apr 21 '20 at 09:48
  • Sorry, for that mess Please have a look at the edited solution – LRK Apr 21 '20 at 16:22
  • Do you have experiences running yolo on a raspberry Pi? If yes, I would appreciate it if you have a look at my question here: https://stackoverflow.com/questions/61360030/best-algorithm-and-platform-to-run-object-detection-on-embedded-systems – f_3464gh Apr 22 '20 at 08:04
  • Do I undestand correctly, that your main goal is it, to run a console application (either written in c++ or python) that performs object detection on a rasberry PI? If so, from what I've seen YOLOv3 is a good solution for fast object detection. The downside is, that it requires a lot of GPU to be that fast. So if you are on a rasberry PI, that isn't equipped with a high-end GPU, I would recommend you to to use YOLOv3-tiny, it's less accurate but way faster. Have a look [here](https://pjreddie.com/darknet/yolo/) for a comparison of network performances. – LRK Apr 22 '20 at 13:02
  • yes that is correct. Great tip! But even with tiny yolo i have really low fps. Do you know if another model or some model in tensorflow is faster on embedded systems? Thanks for your help! – f_3464gh Apr 22 '20 at 13:55
  • What hardware are you using for for object detection? – LRK Apr 22 '20 at 20:43
  • Raspberry PI 4 with 1 gb RAM and Camera Module v2.1 – f_3464gh Apr 23 '20 at 06:33
  • I think that you only have two options in that case: One is to add a GPU to your Rasberry PI, have a look [here](https://www.techrepublic.com/article/want-your-raspberry-pi-4-to-run-a-modern-graphics-card-this-engineers-working-on-it/). The other one is to set up a console application that uses remote Object Detection (The PI sends the image to a PC and the PC responds with the detection boxes). It depends whether you need a fast object detection (GPU attached to Pi) or whether performance doesn't matter (remote detection). However a remote detection doesn't have to be significantly slower. – LRK Apr 23 '20 at 22:44
  • @LRK I am trying to make single .exe and I am also trying to build yolo_cpp_dll.sln or yolo_console_dll.sln. HOwever, I failed to do so. I cannot find the yolo_cpp_dll.lib file. Is there any step by step tutorial for this? Please help me with this. I am using YOLOv4 Darknet. – Virtuall.Kingg May 26 '22 at 02:22
1

@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.

glm_java
  • 19
  • 2