DarkHelp - C++ wrapper library for Darknet

Overview

What is the DarkHelp C++ API?

The DarkHelp C++ API is a wrapper to make it easier to use the Darknet neural network framework within a C++ application. DarkHelp performs the following:

  • load a Darknet-style neural network (.cfg, .names, .weights)
  • run inference on images -- either filenames or OpenCV cv::Mat images and video frames -- and return a vector of results
  • optionally annotate images/frames with the inference results

Example annotated image after calling DarkHelp::NN::predict() and DarkHelp::NN::annotate():

annotated image example

What is the DarkHelp CLI?

DarkHelp also has a very simple command-line tool that uses the DarkHelp C++ API so some of the functionality can be accessed directly from the command-line. This can be useful to run tests or for shell scripting.

What is the DarkHelp Server?

DarkHelp Server is a command-line tool that loads a neural network once, and then keeps running in the background. It repeatedly applies the network to images or video frames and saves the results.

Unlike Darknet and the DarkHelp CLI which have to re-load the neural network every time they're called, DarkHelp Server only does this once. DarkHelp Server can be configured to save the results in .txt format, .json format, annotate images, and can also crop the objects and create individual image files from each of the objects detected by the neural network.

License

DarkHelp is open source and published using the MIT license. Meaning you can use it in your commercial application. See license.txt for details.

How to Build DarkHelp (Linux)

Extremely simple easy-to-follow tutorial on how to build Darknet, DarkHelp, and DarkMark.

DarkHelp build tutorial

DarkHelp requires that Darknet has already been built and installed, since DarkHelp is a wrapper for the C functionality available in libdarknet.so.

Building Darknet (Linux)

You must build Darknet with the LIBSO=1 variable set to have it build libdarknet.so. On Ubuntu:

sudo apt-get install build-essential git libopencv-dev
cd ~/src
git clone https://github.com/AlexeyAB/darknet.git
cd darknet
# edit Makefile to set LIBSO=1, and possibly other flags
make
sudo cp libdarknet.so /usr/local/lib/
sudo cp include/darknet.h /usr/local/include/
sudo ldconfig

Building DarkHelp (Linux)

Now that Darknet is built and installed, you can go ahead and build DarkHelp. On Ubuntu:

sudo apt-get install cmake build-essential libtclap-dev libmagic-dev libopencv-dev
cd ~/src
git clone https://github.com/stephanecharette/DarkHelp.git
cd DarkHelp
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
make package
sudo dpkg -i darkhelp*.deb

Building Darknet (Windows)

The Windows build uses vcpkg to install the necessary 3rd-party libraries such as OpenCV. See the files readme_windows.txt and build_windows.cmd for details.

Start the "Developer Command Prompt for Visual Studio" (not Power Shell!) and run the following commands to build Darknet and OpenCV:

cd c:\src
git clone https://github.com/microsoft/vcpkg
cd vcpkg
bootstrap-vcpkg.bat
vcpkg.exe integrate install
vcpkg.exe integrate powershell
vcpkg.exe install opencv[contrib,core,dnn,ffmpeg,jpeg,png,quirc,tiff,webp]:x64-windows darknet[opencv-base]:x64-windows

Building DarkHelp (Windows)

Once you finish building Darknet and OpenCV, run the following commands in the "Developer Command Prompt for VS" to build DarkHelp:

cd c:\src\vcpkg
vcpkg.exe install tclap:x64-windows
cd c:\src
git clone https://github.com/stephanecharette/DarkHelp.git
cd darkhelp
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake ..
msbuild.exe /property:Platform=x64;Configuration=Release /target:Build -maxCpuCount -verbosity:normal -detailedSummary DarkHelp.sln

Make sure you update the path to the toolchain file if you used a different directory.

If you have NSIS installed, then you can create an installation package with this command:

msbuild.exe /property:Platform=x64;Configuration=Release PACKAGE.vcxproj

Example Code

DarkHelp has many optional settings that impact the output, especially DarkHelp::NN::annotate().

To keep it simple this example code doesn't change any settings. It uses the default values as it runs inference on several images and saves the output:

// include DarkHelp.hpp and link against libdarkhelp, libdarknet, and OpenCV
//
const auto samples_images = {"dog.jpg", "cat.jpg", "horse.jpg"};
//
// Only do this once.  You don't want to keep reloading the network inside
// the loop because loading the network is actually a long process that takes
// several seconds to run to finish.
DarkHelp::NN nn("animals.cfg", "animals_best.weights", "animals.names");
//
for (const auto & filename : samples_images)
{
    // get the predictions; on a decent GPU this should take milliseconds,
    // while on a CPU this might take a full second or more
    const auto results = nn.predict(filename);
    //
    // display the results on the console
    // (meaning coordinates and confidence levels, not displaying the image)
    std::cout << results << std::endl;
    //
    // annotate the image and save the results
    cv::Mat output = nn.annotate();
    cv::imwrite("output_" + filename, output, {CV_IMWRITE_PNG_COMPRESSION, 9});
}

C++ API Doxygen Output

The official DarkHelp documentation and web site is at https://www.ccoderun.ca/darkhelp/.

Some links to specific useful pages:

tiled image example

Issues
  • make error in Linux

    make error in Linux

    Building ver: 1.3.11-1
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /share_data/YuhaoSun/DarkHelp-master/build
    (yolox) [email protected]:/share_data/YuhaoSun/DarkHelp-master/build# make
    Scanning dependencies of target dh
    [ 16%] Building CXX object src-lib/CMakeFiles/dh.dir/DarkHelp.cpp.o
    [ 33%] Linking CXX static library libdarkhelp.a
    [ 33%] Built target dh
    Scanning dependencies of target cli
    [ 50%] Building CXX object src-tool/CMakeFiles/cli.dir/DarkHelpCli.cpp.o
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:131:35: error: use of deleted function ‘std::atomic<bool>::atomic(const std::atomic<bool>&)’
     std::atomic<bool> signal_raised = false;
                                       ^
    In file included from /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:10:0:
    /usr/include/c++/5/atomic:66:5: note: declared here
         atomic(const atomic&) = delete;
         ^
    /usr/include/c++/5/atomic:70:15: note:   after user-defined conversion: constexpr std::atomic<bool>::atomic(bool)
         constexpr atomic(bool __i) noexcept : _M_base(__i) { }
                   ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp: In function ‘void show_help_window()’:
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:20: error: expected unqualified-id before ‘[’ token
      for (const auto & [key, val] : help)
                        ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:20: error: expected ‘;’ before ‘[’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:21: error: ‘key’ was not declared in this scope
      for (const auto & [key, val] : help)
                         ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:26: error: ‘val’ was not declared in this scope
      for (const auto & [key, val] : help)
                              ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp: In lambda function:
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:31: error: expected ‘{’ before ‘:’ token
      for (const auto & [key, val] : help)
                                   ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp: In function ‘void show_help_window()’:
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:31: error: expected ‘;’ before ‘:’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:31: error: expected primary-expression before ‘:’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:31: error: expected ‘)’ before ‘:’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:220:31: error: expected primary-expression before ‘:’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:215:13: error: unused variable ‘font_face’ [-Werror=unused-variable]
      const auto font_face  = cv::HersheyFonts::FONT_HERSHEY_SIMPLEX;
                 ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:216:13: error: unused variable ‘font_scale’ [-Werror=unused-variable]
      const auto font_scale  = 0.5;
                 ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:217:13: error: unused variable ‘font_thickness’ [-Werror=unused-variable]
      const auto font_thickness = 1;
                 ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:219:6: error: unused variable ‘y’ [-Werror=unused-variable]
      int y = 25;
          ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp: In function ‘void init(Options&, int, char**)’:
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:21: error: expected unqualified-id before ‘[’ token
       for (const auto & [key, val] : debug_messages)
                         ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:21: error: expected ‘;’ before ‘[’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:22: error: ‘key’ was not declared in this scope
       for (const auto & [key, val] : debug_messages)
                          ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:27: error: ‘val’ was not declared in this scope
       for (const auto & [key, val] : debug_messages)
                               ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp: In lambda function:
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:32: error: expected ‘{’ before ‘:’ token
       for (const auto & [key, val] : debug_messages)
                                    ^
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp: In function ‘void init(Options&, int, char**)’:
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:32: error: expected ‘;’ before ‘:’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:32: error: expected primary-expression before ‘:’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:32: error: expected ‘)’ before ‘:’ token
    /share_data/YuhaoSun/DarkHelp-master/src-tool/DarkHelpCli.cpp:571:32: error: expected primary-expression before ‘:’ token
    cc1plus: all warnings being treated as errors
    src-tool/CMakeFiles/cli.dir/build.make:82: recipe for target 'src-tool/CMakeFiles/cli.dir/DarkHelpCli.cpp.o' failed
    make[2]: *** [src-tool/CMakeFiles/cli.dir/DarkHelpCli.cpp.o] Error 1
    CMakeFiles/Makefile2:184: recipe for target 'src-tool/CMakeFiles/cli.dir/all' failed
    make[1]: *** [src-tool/CMakeFiles/cli.dir/all] Error 2
    Makefile:171: recipe for target 'all' failed
    make: *** [all] Error 2
    
    opened by lantudou 8
  • Build error - Jetson AGX

    Build error - Jetson AGX

    Dear Stephan, Outstanding work on DarkHelp, and DarkMark! I've tried to install them on Jetson AGX and i reived the following problem. (Darknet have been installed with Libso and arch=compute_72

    I have NVIDIA JetPack installed as my Linux with all standard things coming with it.

    Thank you for your support and help!

    error on make: [email protected]:~/developer/darknet/DarkHelp/built$ make [ 16%] Building CXX object src-lib/CMakeFiles/dh.dir/DarkHelp.cpp.o /home/agx-dev-1/developer/darknet/DarkHelp/src-lib/DarkHelp.cpp: In member function ‘virtual DarkHelp& DarkHelp::init(const string&, const string&, const string&, bool, DarkHelp::EDriver)’: /home/agx-dev-1/developer/darknet/DarkHelp/src-lib/DarkHelp.cpp:169:44: error: ‘DNN_BACKEND_CUDA’ is not a member of ‘cv::dnn’ opencv_net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA); ^~~~~~~~~~~~~~~~ /home/agx-dev-1/developer/darknet/DarkHelp/src-lib/DarkHelp.cpp:170:43: error: ‘DNN_TARGET_CUDA’ is not a member of ‘cv::dnn’ opencv_net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA); ^~~~~~~~~~~~~~~ src-lib/CMakeFiles/dh.dir/build.make:62: recipe for target 'src-lib/CMakeFiles/dh.dir/DarkHelp.cpp.o' failed make[2]: *** [src-lib/CMakeFiles/dh.dir/DarkHelp.cpp.o] Error 1 CMakeFiles/Makefile2:85: recipe for target 'src-lib/CMakeFiles/dh.dir/all' failed make[1]: *** [src-lib/CMakeFiles/dh.dir/all] Error 2 Makefile:151: recipe for target 'all' failed make: *** [all] Error 2

    Before the error the cmake made this: [email protected]:~/developer/DarkHelp/build$ cmake -DCMAKE_BUILD_TYPE=Release .. -- The C compiler identification is GNU 7.5.0 -- The CXX compiler identification is GNU 7.5.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done Building ver: 1.3.6-1 -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE
    -- Found OpenCV: /usr (found version "4.1.1") -- Configuring done -- Generating done -- Build files have been written to: /home/agx-dev-1/developer/DarkHelp/build

    opened by mate-hegedus 6
  • std namespace errors while compiling using cmake

    std namespace errors while compiling using cmake

    I am building a cross-compilation platform using OpenCV 3.4.4, darknet (and its dependencies) and DarkHelp.

    DarkHelp dependencies such as magic, tclap etc have been cross-compiled successfully along with OpenCV and darknet. I have tested it on my RPi, the darknet libs and exe works.

    When I try to compile Darkhelp,

    cmake -DOpenCV_DIR="${RPI_SYSROOT}/usr/local/lib" -DCMAKE_PREFIX_PATH="${RPI_SYSROOT}/usr/local" ..

    
    -- The C compiler identification is GNU 7.5.0
    -- The CXX compiler identification is GNU 7.5.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    Building ver: 1.4.18-1
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE  
    -- Found OpenCV: /home/develop/RPi-sysroot/usr/local (found version "3.4.4") 
    -- Configuring done
    -- Generating done
    -- Build files have been written to: 
    

    make -j4

    
    [ 11%] Building CXX object src-lib/CMakeFiles/dh.dir/DarkHelpConfig.cpp.o
    In file included from /usr/include/c++/7/ext/string_conversions.h:41:0,
                     from /usr/include/c++/7/bits/basic_string.h:6361,
                     from /usr/include/c++/7/string:52,
                     from /usr/include/c++/7/stdexcept:39,
                     from /usr/include/c++/7/array:39,
                     from /usr/include/c++/7/tuple:39,
                     from /usr/include/c++/7/bits/stl_map.h:63,
                     from /usr/include/c++/7/map:61,
                     from /home/develop/test_darknet/DarkHelp/src-lib/DarkHelp.hpp:9,
                     from /home/develop/test_darknet/DarkHelp/src-lib/DarkHelpConfig.cpp:6:
    /usr/include/c++/7/cstdlib:144:11: error: '::calloc' has not been declared
       using ::calloc;
               ^~~~~~
    /usr/include/c++/7/cstdlib:147:11: error: '::free' has not been declared
       using ::free;
               ^~~~
    /usr/include/c++/7/cstdlib:151:11: error: '::malloc' has not been declared
       using ::malloc;
               ^~~~~~
    
    

    This is a short part of the error. All the calls to std:: are reported.

    While searching for a solution, I found this post

    It seems some include<> are done within the namespace{} as I came across multiple forum posts. Let me know if any more information is required to find a solution.

    opened by ashishmagar600 4
  • Compilation error on Raspberry Pi 4 / CM4 : cannot convert ‘const long long int*’ to ‘const time_t*’ {aka ‘const long int*’}

    Compilation error on Raspberry Pi 4 / CM4 : cannot convert ‘const long long int*’ to ‘const time_t*’ {aka ‘const long int*’}

    I stumbled on this compilation fatal error (output.txt) while trying to compile Darkhelp on Compute Module 4 (armv7l Raspbian). This error occurred in 2 files : first in DarkHelpServer.cpp and secondly in DarkHelpCli.cpp

    I bypassed this error by editing line 230 in DarkHelpServer.cpp and line 1046 in DarkHelpCli.cpp https://github.com/stephanecharette/DarkHelp/blob/318e33d4fe7b97ec02e1086bac7c3adfd73ec74d/src-tool/DarkHelpServer.cpp#L230 https://github.com/stephanecharette/DarkHelp/blob/318e33d4fe7b97ec02e1086bac7c3adfd73ec74d/src-tool/DarkHelpCli.cpp#L1046

    I wrote in both files:

    std::time_t t = seconds; const auto lt = std::localtime(&t);

    Can you check if my update is correct and update these two files if it complies with your code ?

    Thank you in advance.

    PS : Thank you for your job done on this project, it's incredible how it's easy to use darknet with your help.

    opened by QuietLullaby 4
  • Does DarkHelp Implement Image Tiling during Inference?

    Does DarkHelp Implement Image Tiling during Inference?

    @stephanecharette I'm exploring image tiling to improve small object detection. I see that DarkHelp and Darkmark has the ability implement image tiling on datasets; but it's not clear to me if Darkmark implements tiling during inference.

    Thanks in advance,

    opened by seabass1217 4
  • Compiling on Rocky Linux

    Compiling on Rocky Linux

    I'm having trouble installing on Rocky Linux (basically CentOS 8). I've installed darknet following your instructions and it's working.

    CUDA-version: 11060 (11060), cuDNN: 8.4.0, CUDNN_HALF=1, GPU count: 1  
     CUDNN_HALF=1 
     OpenCV version: 3.4.6
    

    When I try to make DarkMark I get the following issue.

    # cmake -DCMAKE_BUILD_TYPE=Release ..
    -- The C compiler identification is GNU 8.5.0
    -- The CXX compiler identification is GNU 8.5.0
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    Building ver: 1.4.16-1
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE  
    CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
      Could NOT find CUDA (missing: CUDA_INCLUDE_DIRS CUDA_CUDART_LIBRARY) (found
      suitable exact version "11.6")
    Call Stack (most recent call first):
      /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
      /usr/share/cmake/Modules/FindCUDA.cmake:1264 (find_package_handle_standard_args)
      /usr/local/lib64/cmake/opencv4/OpenCVConfig.cmake:86 (find_package)
      /usr/local/lib64/cmake/opencv4/OpenCVConfig.cmake:108 (find_host_package)
      CM_dependencies.cmake:7 (FIND_PACKAGE)
      CMakeLists.txt:18 (INCLUDE)
    
    
    -- Configuring incomplete, errors occurred!
    

    CMakeError.log CMakeOutput.log

    Seems to have something to with with pthreads. I have libpthread installed and create seems to be available.

    # nm /lib64/libpthread.so.0 | grep "pthread_create"
    00000000000093d4 t .annobin___pthread_create_2_1.end
    0000000000008458 t .annobin___pthread_create_2_1.start
    0000000000006ed0 t .annobin_pthread_create.c
    00000000000093d4 t .annobin_pthread_create.c_end
    000000000000683c t .annobin_pthread_create.c_end.exit
    000000000000683c t .annobin_pthread_create.c_end.hot
    000000000000683c t .annobin_pthread_create.c_end.startup
    000000000000683c t .annobin_pthread_create.c_end.unlikely
    000000000000683c t .annobin_pthread_create.c.exit
    000000000000683c t .annobin_pthread_create.c.hot
    000000000000683c t .annobin_pthread_create.c.startup
    0000000000006820 t .annobin_pthread_create.c.unlikely
    0000000000008460 t __pthread_create_2_1
    000000000000682e t __pthread_create_2_1.cold.12
    0000000000008460 T [email protected]@GLIBC_2.2.5
    

    Any help would be very appreciated. I'm trying to get DarkMark installed and from the video it looks amazing!

    Thanks!

    opened by agorman 3
  • Run on Python

    Run on Python

    Hi, this work is very great and I would just like to ask if there might be a possible where it can also be ran natively in Python in the future? Thank you so much.

    opened by arianyambao 2
  • Duplicate call to fuse_conv_batchnorm() in init()

    Duplicate call to fuse_conv_batchnorm() in init()

    https://github.com/stephanecharette/DarkHelp/blob/c6b05ba2a93c004bda40c6ae8a6377c3340722cd/src-lib/DarkHelp.cpp#L145-L147

    load_network_custom already does call fuse_conv_batchnorm() internally, this will call it twice.

    opened by philipp-schmidt 1
  • Update DarkHelp.hpp to fix std::chrono error

    Update DarkHelp.hpp to fix std::chrono error

    Hello, thanks for the DarkHelp!

    I was compiling the dark help following the instructions provided in the readme section. I am using Ubuntu 18.04, cmake version 3.15.2 I met the following error:

    [ 11%] Building CXX object src-lib/CMakeFiles/dh.dir/DarkHelpUtils.cpp.o
    [ 11%] Building CXX object src-lib/CMakeFiles/dh.dir/DarkHelpNN.cpp.o
    [ 11%] Building CXX object src-lib/CMakeFiles/dh.dir/DarkHelpConfig.cpp.o
    In file included from /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelp.hpp:122:0,
                     from /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpPredictionResult.cpp:6:
    /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpNN.hpp:263:9: error: ‘chrono’ in namespace ‘std’ does not name a type
        std::chrono::high_resolution_clock::duration duration;
             ^~~~~~
    In file included from /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelp.hpp:123:0,
                     from /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpPredictionResult.cpp:6:
    /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpUtils.hpp:27:41: error: ‘chrono’ in namespace ‘std’ does not name a type
      std::string duration_string(const std::chrono::high_resolution_clock::duration duration);
                                             ^~~~~~
    /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpUtils.hpp:27:70: error: expected unqualified-id before ‘::’ token
      std::string duration_string(const std::chrono::high_resolution_clock::duration duration);
                                                                          ^~
    /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpUtils.hpp:27:70: error: expected ‘)’ before ‘::’ token
    /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpUtils.hpp:27:70: error: expected initializer before ‘::’ token
    In file included from /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelp.hpp:122:0,
                     from /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpNN.cpp:6:
    /home/almon-18/almon_projects/darknet_redo/src/DarkHelp/src-lib/DarkHelpNN.hpp:263:9: error: ‘chrono’ in namespace ‘std’ does not name a type
        std::chrono::high_resolution_clock::duration duration;
             ^~~~~~
    

    I googled online and it seems that it is missing a #include <chrono>. I added it into DarkHelp/src-lib/DarkHelp.hpp and fixed this issue.

    opened by s95huang 0
  • Unused Function Error on ARM64 Ubuntu 18.04

    Unused Function Error on ARM64 Ubuntu 18.04

    Self solved, leaving this here to save time for any others who encounter this. I encountered this error while following the install:

    /src/DarkHelp/src-lib/DarkHelp.cpp:729:23: error: unused function 'convert_darknet_image_to_opencv_mat' [-Werror,-Wunused-function] static inline cv::Mat convert_darknet_image_to_opencv_mat(const image img) ^ 1 error generated. src-lib/CMakeFiles/dh.dir/build.make:75: recipe for target 'src-lib/CMakeFiles/dh.dir/DarkHelp.cpp.o' failed

    This error was solved by editing CM_definitions.cmake , changing the line in ELSE() to ADD_COMPILE_OPTIONS (-Wextra -Wno-unused-parameter )

    Additionally, I got an error for sudo dpkg -i darkmark*.deb [sudo] password for USER: dpkg: error: cannot access archive 'darkmark*.deb': No such file or directory

    which was solved by replacing the file darkmark*.deb with the full filename

    opened by ejaybennett 0
  • 'undefined reference to function' after -static compilation using make for DarkHelp project

    'undefined reference to function' after -static compilation using make for DarkHelp project

    OS: Ubuntu 18.04 LTS

    Built DarkNet succesfully and can be used with './darknet'

    Built DarkHelp using this and compiled 'example_project'.

    I am trying to build a standalone executable "exe_static" to be used on linux systems, where I might not have the privileges to install dependencies.

    Copied DarkHelp/build/src-lib/libdarkhelp.a and libdarknet.a to /usr/lib/

    exe_static.cpp

    #include <DarkHelp.hpp>
    #include <typeinfo>
    
    
    int main(int argc, char *argv[])
    {
    	DarkHelp::Config cfg("model.cfg", "model.weights", "names.list");
    	cfg.enable_tiles			= true;
    	cfg.combine_tile_predictions		= true;
    	cfg.annotation_auto_hide_labels		= false;
    	cfg.annotation_include_duration		= false;
    	cfg.annotation_include_timestamp	= false;
    
    	DarkHelp::NN nn(cfg);
    	const auto results = nn.predict(argv[1]);
    
    //        std::cout <<"Shape of result = : " << results.size() << "\n";
    
    	return 0;
    }
    
    

    CMakeLists.txt

    CMAKE_MINIMUM_REQUIRED (VERSION 3.0)
    
    PROJECT (ExampleProject C CXX)
    
    SET (CMAKE_BUILD_TYPE Release)
    SET (CMAKE_CXX_STANDARD 17)
    SET (CMAKE_CXX_STANDARD_REQUIRED ON)
    
    ADD_DEFINITIONS ("-Wall -Wextra -Werror -Wno-unused-parameter ")
    
    FIND_PACKAGE (Threads	REQUIRED)
    FIND_PACKAGE (OpenCV	REQUIRED)
    #FIND_LIBRARY (DARKHELP	libdarkhelp.a)
    #FIND_LIBRARY (DARKNET	libdarknet.a)
    
    INCLUDE_DIRECTORIES (${OpenCV_INCLUDE_DIRS})
    
    FILE (GLOB SOURCE *.cpp)
    LIST (SORT SOURCE)
    
    SET (BUILD_SHARED_LIBS=OFF)
    SET (OPENCV_GENERATE_PKGCONFIG=YES)
    
    
    ADD_EXECUTABLE (exe_static ${SOURCE})
    
    SET_TARGET_PROPERTIES(exe_static PROPERTIES 
       LINK_SEARCH_START_STATIC ON
       LINK_SEARCH_END_STATIC ON
    )
    
    set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
    
    set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
    
    #TARGET_LINK_LIBRARIES (exe_static Threads::Threads ${DARKHELP} ${DARKNET} ${OpenCV_LIBS})
    TARGET_LINK_LIBRARIES (exe_static Threads::Threads libdarknet.a libdarkhelp.a  ${OpenCV_LIBS} )
    
    

    Same file structure as DarkHelp/example_project

    $> cd build $> cmake ..

    -- The C compiler identification is GNU 7.5.0
    -- The CXX compiler identification is GNU 7.5.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Looking for pthread_create
    -- Looking for pthread_create - not found
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - found
    -- Found Threads: TRUE  
    -- Found OpenCV: /usr/local (found version "3.4.4") 
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /path/to/exe_static/build
    
    

    $> make

    Scanning dependencies of target exe_static
    [ 50%] Building CXX object CMakeFiles/exe_static.dir/exe_static.cpp.o
    [100%] Linking CXX executable exe_static
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libdarkhelp.a(DarkHelpNN.cpp.o): In function `DarkHelp::NN::reset()':
    DarkHelpNN.cpp:(.text+0x1ff8): undefined reference to `free_network'
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libdarkhelp.a(DarkHelpNN.cpp.o): In function `DarkHelp::NN::predict_internal_darknet()':
    DarkHelpNN.cpp:(.text+0x45ca): undefined reference to `make_image'
    DarkHelpNN.cpp:(.text+0x4715): undefined reference to `network_predict'
    DarkHelpNN.cpp:(.text+0x4761): undefined reference to `get_network_boxes'
    DarkHelpNN.cpp:(.text+0x4b7e): undefined reference to `free_detections'
    DarkHelpNN.cpp:(.text+0x4ba7): undefined reference to `free_image'
    DarkHelpNN.cpp:(.text+0x5190): undefined reference to `do_nms_sort'
    /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libdarkhelp.a(DarkHelpNN.cpp.o): In function `DarkHelp::NN::init()':
    DarkHelpNN.cpp:(.text+0xaa81): undefined reference to `load_network_custom'
    DarkHelpNN.cpp:(.text+0xaaa7): undefined reference to `calculate_binary_weights'
    collect2: error: ld returned 1 exit status
    CMakeFiles/exe_static.dir/build.make:139: recipe for target 'exe_static' failed
    make[2]: *** [exe_static] Error 1
    CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/exe_static.dir/all' failed
    make[1]: *** [CMakeFiles/exe_static.dir/all] Error 2
    Makefile:83: recipe for target 'all' failed
    make: *** [all] Error 2
    
    
    
    opened by ashishmagar600 2
  • an classification problem

    an classification problem

    in AlexeyAB darknet, softmax_layer.c has two layers, softmax_layer and contrastive _layer. my problem is "how to use contrastive layer in classification?" if you known. can offer an example cfg file? thanks

    opened by tuteming 1
  • Issue with Inference - Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

    Issue with Inference - Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

    I'm running DarkHelp in a C++ application (Through CLion). I am able to conduct detection through video capture but when I attempt to run inference as I get the following error message:

    Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

    Code:

    DarkHelp::Config cfg(config_file, weights_file, names_file ); cfg.enable_tiles = true; cfg.combine_tile_predictions = true; cfg.annotation_auto_hide_labels = false; cfg.annotation_include_duration = true; cfg.annotation_include_timestamp = false;

    DarkHelp::NN nn(cfg)

    const auto result = nn.predict(filename); cv::Mat output = nn.annotate()

    I'm using coco names and config file with pretrained YOLOv4 weights.

    Any idea what could be causing the issue?

    Thanks in advance.

    opened by Brandonio-c 5
  • json output with detection for video inference

    json output with detection for video inference

    Hi, first of all thanks for your great work!

    I realised that the output.json does not contain detection when running inference on a video. Is that correct? Is there another way to get the detections for each frame?

    opened by jokober 1
  • Can I use DarkHelp along with YOLOV4? Can DarkHelp sends the output of YOLOv4 Darknet via tcp/ip?

    Can I use DarkHelp along with YOLOV4? Can DarkHelp sends the output of YOLOv4 Darknet via tcp/ip?

    I have used YOLOv4 Darknet for object detection. I want to send the results of the Detection to C# gui via tcp/ip. Is it possible using DarkHelp? If yes, what procedures should I follow? Thank You in Advance.

    opened by PIjarihd 1
Owner
Stéphane Charette
C/C++ developer. Mostly linux-based. IoT, desktop, and embedded device. Computer vision, neural networks, Ubuntu geek.
Stéphane Charette
Support Yolov4/Yolov3/Centernet/Classify/Unet. use darknet/libtorch/pytorch to onnx to tensorrt

ONNX-TensorRT Yolov4/Yolov3/CenterNet/Classify/Unet Implementation Yolov4/Yolov3 centernet INTRODUCTION you have the trained model file from the darkn

null 156 Jun 10, 2022
License plate parsing using Darknet and YOLO

DarkPlate Note that DarkPlate by itself is not a complete software project. The intended purpose was to create a simple project showing how to use Dar

Stéphane Charette 27 Apr 11, 2022
C++11 wrapper for the LMDB embedded B+ tree database library.

lmdb++: a C++11 wrapper for LMDB This is a comprehensive C++ wrapper for the LMDB embedded database library, offering both an error-checked procedural

D.R.Y. C++ 257 Jun 16, 2022
Implement yolov5 with Tensorrt C++ api, and integrate batchedNMSPlugin. A Python wrapper is also provided.

yolov5 Original codes from tensorrtx. I modified the yololayer and integrated batchedNMSPlugin. A yolov5s.wts is provided for fast demo. How to genera

weiwei zhou 39 Jun 18, 2022
cudnn_frontend provides a c++ wrapper for the cudnn backend API and samples on how to use it

cuDNN Frontend API Introduction The cuDNN Frontend API is a C++ header-only library that demonstrates how to use the cuDNN C backend API. The cuDNN C

NVIDIA Corporation 103 May 23, 2022
Watertight Manifold Python Wrapper

Watertight Manifold Python Wrapper This repository is a simple PythonWrapper around the origin implementation of the paper: Huang, Jingwei, Hao Su, an

Photogrammetry & Robotics Bonn 13 Apr 16, 2022
A simple ros wrapper for apriltag-cpp

Ros wrapper for apriltags-cpp Ros wrapper of the APRIL tags library, using OpenCV (and optionally, CGAL). Requirements Currently, apriltags-cpp requir

Robot Perception & Navigation Group (RPNG) 6 Dec 30, 2021
ROS wrapper for real-time incremental event-based vision motion estimation by dispersion minimisation

event_emin_ros ROS wrapper for real-time incremental event-based vision motion estimation by dispersion minimisation (EventEMin). This code was used t

Imperial College London 2 Jan 10, 2022
Python wrapper for Environment Simulator Minimalistic (esmini)

python-esmini is a python wrapper for Environment Simulator Minimalistic (esmini). Install the package python-esmini is now only available for the Lin

Hamid Ebadi 4 May 21, 2022
The dgSPARSE Library (Deep Graph Sparse Library) is a high performance library for sparse kernel acceleration on GPUs based on CUDA.

dgSPARSE Library Introdution The dgSPARSE Library (Deep Graph Sparse Library) is a high performance library for sparse kernel acceleration on GPUs bas

dgSPARSE 49 Jun 17, 2022
C-based/Cached/Core Computer Vision Library, A Modern Computer Vision Library

Build Status Travis CI VM: Linux x64: Raspberry Pi 3: Jetson TX2: Backstory I set to build ccv with a minimalism inspiration. That was back in 2010, o

Liu Liu 6.9k Jun 23, 2022
Edge ML Library - High-performance Compute Library for On-device Machine Learning Inference

Edge ML Library (EMLL) offers optimized basic routines like general matrix multiplications (GEMM) and quantizations, to speed up machine learning (ML) inference on ARM-based devices. EMLL supports fp32, fp16 and int8 data types. EMLL accelerates on-device NMT, ASR and OCR engines of Youdao, Inc.

NetEase Youdao 176 Jun 17, 2022
The Robotics Library (RL) is a self-contained C++ library for rigid body kinematics and dynamics, motion planning, and control.

Robotics Library The Robotics Library (RL) is a self-contained C++ library for rigid body kinematics and dynamics, motion planning, and control. It co

Robotics Library 580 Jun 25, 2022
A GPU (CUDA) based Artificial Neural Network library

Updates - 05/10/2017: Added a new example The program "image_generator" is located in the "/src/examples" subdirectory and was submitted by Ben Bogart

Daniel Frenzel 91 Jun 13, 2022
Header-only library for using Keras models in C++.

frugally-deep Use Keras models in C++ with ease Table of contents Introduction Usage Performance Requirements and Installation FAQ Introduction Would

Tobias Hermann 872 Jun 22, 2022
simple neural network library in ANSI C

Genann Genann is a minimal, well-tested library for training and using feedforward artificial neural networks (ANN) in C. Its primary focus is on bein

Lewis Van Winkle 1.2k Jun 23, 2022
oneAPI Deep Neural Network Library (oneDNN)

oneAPI Deep Neural Network Library (oneDNN) This software was previously known as Intel(R) Math Kernel Library for Deep Neural Networks (Intel(R) MKL-

oneAPI-SRC 2.9k Jun 28, 2022
A lightweight C library for artificial neural networks

Getting Started # acquire source code and compile git clone https://github.com/attractivechaos/kann cd kann; make # learn unsigned addition (30000 sam

Attractive Chaos 606 Jun 10, 2022
LibDEEP BSD-3-ClauseLibDEEP - Deep learning library. BSD-3-Clause

LibDEEP LibDEEP is a deep learning library developed in C language for the development of artificial intelligence-based techniques. Please visit our W

Joao Paulo Papa 18 Mar 15, 2022