AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.62k stars 7.95k forks source link

advice for building as a ROS node #5457

Open LukeAI opened 4 years ago

LukeAI commented 4 years ago

Hi @AlexeyAB (or any c++ pros)

I would like to wrap this repo. as a c++ ROS node. Ideally I would like to use this repo. as a subtree that I can pull occasionally to get updates. The ROS programming part won't be a problem but I'm struggling to know how to begin with the build interface.

A ROS node must be built with catkin which requires a CMakeLists file. So the package structure is like this.

darknet_ros
├── CMakeLists.txt
├── darknet (AlexeyAB/darknet)
├── launch
├── package.xml
└── src (containing darknet_ros.cpp)

Is the best way to do this to use the ".so" ? If so, should I cause darknet to be built from my CMakeLists by just running an external shell script that just does "cd darknet && make"? and how can I include the .so in my CMakeLists so as to be able to give darknet_ros.cpp access to #include "yolo_v2_class.hpp" ?

There is a very similar project using an out of date version of this repo that directly includes the source files from AlexeyAB/darknet in the ROS CMakelists file and sets CUDA_NVCC_FLAGS etc. Would this be a better way to do it in any respect (performance or something?) I'm hesitant to do this because I would then have to maintain it any time upstream changes happen.

I realise this is rather subjective and a bit beyond the scope of this repo. but would really appreciate your opinion/advice on this.

stephanecharette commented 4 years ago

If you are looking for a C++ interface to use with ROS, you may also want to see the DarkHelp library instead of using the darknet one directly. I've used it in several ROS projects. See here: https://www.ccoderun.ca/darkhelp/api/API.html

(Disclaimer: I'm the author of DarkHelp and DarkMark.)

LukeAI commented 4 years ago

@stephanecharette thanks for the suggestion, I think I prefer to stay close to the source and not draw in additional 3rd party dependencies.

LukeAI commented 4 years ago

but if you know how to link to the .so using CMakeLists that'd be great?

I've built darknet with USE_CPP=1 and LIBSO=1

I'm attempting to link (for now, just to get something working) with:

add_executable(hello src/hello.cpp)
TARGET_LINK_LIBRARIES(hello /absolute/path/to/libdarknet.so)

and then trying to include like: #include <yolo_v2_class.hpp>

but I get: fatal error: yolo_v2_class.hpp: No such file or directory

Shame-fight commented 4 years ago

Looking forward to your work, I have the same needs. At the same time, can you now provide python based ros files (output boxes coordinates), thanks in advance! @LukeAI

Shame-fight commented 4 years ago

this may help you:https://github.com/tom13133/darknet_ros I have test it on pc,this repo has a problem:the exact same bounding boxes will be published twice,this problem occurs frequently. @LukeAI