{"id":18876308,"url":"https://github.com/stephanecharette/darkhelp","last_synced_at":"2025-04-04T15:08:36.496Z","repository":{"id":46055944,"uuid":"334858192","full_name":"stephanecharette/DarkHelp","owner":"stephanecharette","description":"C++ wrapper library for Darknet","archived":false,"fork":false,"pushed_at":"2025-03-09T11:24:39.000Z","size":10285,"stargazers_count":162,"open_issues_count":1,"forks_count":28,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T14:11:15.203Z","etag":null,"topics":["computer-vision","cpp","darknet","machine-learning","neural-network","yolo"],"latest_commit_sha":null,"homepage":"https://www.ccoderun.ca/darkhelp/api/Summary.html","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephanecharette.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"stephanecharette","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["paypal.me/ccoderun"]}},"created_at":"2021-02-01T06:54:19.000Z","updated_at":"2025-03-27T07:37:14.000Z","dependencies_parsed_at":"2023-10-11T18:19:25.060Z","dependency_job_id":"0ecea0b3-a24e-4c00-a496-23480ad43d3a","html_url":"https://github.com/stephanecharette/DarkHelp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanecharette%2FDarkHelp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanecharette%2FDarkHelp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanecharette%2FDarkHelp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephanecharette%2FDarkHelp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephanecharette","download_url":"https://codeload.github.com/stephanecharette/DarkHelp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198460,"owners_count":20900080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","cpp","darknet","machine-learning","neural-network","yolo"],"created_at":"2024-11-08T06:12:23.989Z","updated_at":"2025-04-04T15:08:36.480Z","avatar_url":"https://github.com/stephanecharette.png","language":"C++","readme":"# What is the DarkHelp C++ API?\n\nThe 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:\n\n- load a [Darknet](https://github.com/hank-ai/darknet)-style neural network (.cfg, .names, .weights)\n- run inference on images -- either filenames or OpenCV `cv::Mat` images and video frames -- and return [a vector of results](https://www.ccoderun.ca/DarkHelp/api/structDarkHelp_1_1PredictionResult.html#details)\n- optionally annotate images/frames with the inference results\n\nExample annotated image after calling [`DarkHelp::NN::predict()`](https://www.ccoderun.ca/DarkHelp/api/classDarkHelp_1_1NN.html#a827eaa61af42451f0796a4f0adb43013)\nand [`DarkHelp::NN::annotate()`](https://www.ccoderun.ca/DarkHelp/api/classDarkHelp_1_1NN.html#a718c604a24ffb20efca54bbd73d79de5):\n\n![annotated image example](src-doc/shade_25pcnt.png)\n\n# What is the DarkHelp CLI?\n\nDarkHelp also has [a very simple command-line tool](https://www.ccoderun.ca/darkhelp/api/Tool.html) 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.\n\n# What is the DarkHelp Server?\n\nDarkHelp 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.\n\nUnlike 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](https://www.ccoderun.ca/darkhelp/api/Server.html) 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.\n\n# License\n\nDarkHelp is open source and published using the MIT license.  Meaning you can use it in your commercial application.  See license.txt for details.\n\n# How to Build DarkHelp (Linux)\n\nExtremely simple easy-to-follow tutorial on how to build [Darknet](https://github.com/hank-ai/darknet#table-of-contents), DarkHelp, and [DarkMark](https://github.com/stephanecharette/DarkMark).\n\n[![DarkHelp build tutorial](https://github.com/hank-ai/darknet/raw/master/doc/linux_build_thumbnail.jpg)](https://www.youtube.com/watch?v=WTT1s8JjLFk)\n\nDarkHelp requires that [Darknet](https://github.com/hank-ai/darknet) has already been built and installed, since DarkHelp is a *wrapper* for the C functionality available in `libdarknet.so`.\n\n## Building Darknet (Linux)\n\nYou must build and install Darknet first.  See the [Darknet repo](https://github.com/hank-ai/darknet#linux-cmake-method) for details.\n\n## Building DarkHelp (Linux)\n\nNow that Darknet is built and installed, you can go ahead and build DarkHelp.  On Ubuntu:\n\n```sh\nsudo apt-get install build-essential libtclap-dev libmagic-dev libopencv-dev\ncd ~/src\ngit clone https://github.com/stephanecharette/DarkHelp.git\ncd DarkHelp\nmkdir build\ncd build\ncmake -DCMAKE_BUILD_TYPE=Release ..\nmake\nmake package\nsudo dpkg -i darkhelp*.deb\n```\n\n## Building Darknet (Windows)\n\nYou must build and install Darknet first.  See the [Darknet repo](https://github.com/hank-ai/darknet#windows-cmake-method) for details.\n\n## Building DarkHelp (Windows)\n\nOnce you finish building and installing Darknet, run the following commands in the \"Developer Command Prompt for VS\" to build DarkHelp:\n\n```bat\ncd c:\\src\\vcpkg\nvcpkg.exe install tclap:x64-windows\ncd c:\\src\ngit clone https://github.com/stephanecharette/DarkHelp.git\ncd darkhelp\nmkdir build\ncd build\ncmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake ..\nmsbuild.exe /property:Platform=x64;Configuration=Release /target:Build -maxCpuCount -verbosity:normal -detailedSummary DarkHelp.sln\nmsbuild.exe /property:Platform=x64;Configuration=Release PACKAGE.vcxproj\n```\n\nMake sure you update the path to the toolchain file if you used a different directory.  Once that last command finishes, you should have a .exe file you can run to install DarkHelp on your system.\n\n\u003e If the CMake command several lines above gives an error about not finding `Darknet`, and you're certain it is installed correctly, then you can specify the path where CMake can find it.  Try this:\n\n```bat\ncmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:/src/vcpkg/scripts/buildsystems/vcpkg.cmake -DDarknet=\"C:/Program Files/Darknet/lib/darknet.lib\" ..\n```\n\n\u003e If you get an error about `Could not resolve runtime dependencies: darknet.dll`, then copy that DLL into the `src-tool` directory:\n\n```bat\ncopy \"C:\\Program Files\\Darknet\\bin\\darknet.dll\" c:\\src\\DarkHelp\\build\\src-tool\\Release\\\n```\n\n\u003e ...and re-run the command that failed:\n\n```bat\nmsbuild.exe /property:Platform=x64;Configuration=Release PACKAGE.vcxproj\n```\n\n\u003e Similarly, if you get an error about missing either the CUDA or cuDNN DLLs, then you must copy them like what was done when building Darknet.  For example:\n\n```bat\ncopy \"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.2\\bin\\*.dll\" c:\\src\\DarkHelp\\build\\src-tool\\Release\\\ncopy \"C:\\Program Files\\NVIDIA\\CUDNN\\v8.x\\bin\\cudnn64_8.dll\" c:\\src\\DarkHelp\\build\\src-tool\\Release\\\n```\n\n\u003e Once the files have been copied, re-run the last `msbuild.exe` command to generate the NSIS installation package:\n\n```bat\nmsbuild.exe /property:Platform=x64;Configuration=Release PACKAGE.vcxproj\n```\n\n# Example Code\n\nDarkHelp has many optional settings that impact the output, especially [`DarkHelp::NN::annotate()`](https://www.ccoderun.ca/darkhelp/api/classDarkHelp_1_1NN.html#a718c604a24ffb20efca54bbd73d79de5).  See the documentation for [`DarkHelp::Config`](https://www.ccoderun.ca/darkhelp/api/classDarkHelp_1_1Config.html#details) for details.\n\n```cpp\n    // Include DarkHelp.hpp and link against DarkHelp, Darknet, and OpenCV.\n\n    const auto samples_images = {\"dog.jpg\", \"cat.jpg\", \"horse.jpg\"};\n\n    // Only load the neural network once, prior to the loop.  You don't want\n    // to keep reloading the network inside the loop because loading the\n    // network is actually a long process.  Note the order in which the files\n    // are specified is not important.  DarkHelp should automatically detect\n    // the differences between the three file types.\n    DarkHelp::NN nn(\"animals.cfg\", \"animals_best.weights\", \"animals.names\");\n\n    // Customize several settings which alters the output of both Darknet and\n    // DarkHelp.  Note there are many other settings, this is just an example.\n    nn.config.annotation_line_thickness = 1;\n    nn.config.shade_predictions = 0.15;\n    nn.config.snapping_enabled = true;\n    nn.config.threshold = 0.25;\n\n    for (const auto \u0026 filename : samples_images)\n    {\n        // Get the predictions.  On a decent GPU this should take milliseconds,\n        // while on a CPU this will take longer.\n        const auto results = nn.predict(filename);\n\n        // The results are stored in a std::vector, with one entry for each\n        // detected object.  This can be easily displayed on the console or\n        // logged to a file.  Either loop through the vector one entry at a\n        // time, or use the operator\u003c\u003c() to send it to a stream.\n        std::cout \u003c\u003c results \u003c\u003c std::endl;\n\n        // Draw bounding boxes showing the detected objects and save to disk.\n        cv::Mat output = nn.annotate();\n        cv::imwrite(\"output_\" + filename, output, {cv::ImwriteFlags::IMWRITE_PNG_COMPRESSION, 9});\n    }\n```\n\nMore examples showing how to work with both static images and videos can be found in the [src-apps directory](src-apps/) and the [example_project directory](example_project/).\n\n# C++ API Doxygen Output\n\nThe official DarkHelp documentation and web site is at \u003chttps://www.ccoderun.ca/darkhelp/api/namespaceDarkHelp.html\u003e.\n\nSome links to specific useful pages:\n\n- [`DarkHelp` namespace](https://www.ccoderun.ca/darkhelp/api/namespaceDarkHelp.html)\n- [`DarkHelp::NN` class for \"neural network\"](https://www.ccoderun.ca/darkhelp/api/classDarkHelp_1_1NN.html#details)\n- [`DarkHelp::Config` class for configuration items](https://www.ccoderun.ca/darkhelp/api/classDarkHelp_1_1Config.html#details)\n- [Image tiling](https://www.ccoderun.ca/darkhelp/api/Tiling.html)\n- [DarkHelp Server](https://www.ccoderun.ca/darkhelp/api/Server.html)\n\n![tiled image example](src-doc/mailboxes_2x2_tiles_detection.png)\n","funding_links":["https://github.com/sponsors/stephanecharette","paypal.me/ccoderun"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanecharette%2Fdarkhelp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephanecharette%2Fdarkhelp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanecharette%2Fdarkhelp/lists"}