DarkHelp  v1.8.6-4
C++ API for the neural network framework Darknet
Looking for a C++ dev who knows OpenCV?
I'm looking for work. Hire me!
DarkHelp Server

The DarkHelp Server is an application that runs in the backgroud and waits for images to run inference.

DarkHelp Server is configured using a JSON file. When you run DarkHelp Server without any parameters, the default JSON file is shown. It looks like this:

{
"darkhelp": {
"lib": {
"network": {
"cfg": "example.cfg",
"names": "example.names",
"weights": "example_best.weights"
},
"settings": {
"annotation": {
"auto_hide_labels": true,
"font_scale": 0.5,
"font_thickness": 1,
...

The fields in the JSON configuration file are:

JSON Example Description
darkhelp/lib/network/cfg example.cfg DarkHelp::Config::cfg_filename
darkhelp/lib/network/names example.names DarkHelp::Config::names_filename
darkhelp/lib/network/weights example_best.weights DarkHelp::Config::weights_filename
darkhelp/lib/settings/annotation/auto_hide_labels true DarkHelp::Config::annotation_auto_hide_labels
darkhelp/lib/settings/annotation/shade_predictions 0.25 DarkHelp::Config::annotation_shade_predictions
darkhelp/lib/settings/annotation/include_all_names true DarkHelp::Config::include_all_names
darkhelp/lib/settings/annotation/font_scale 0.5 DarkHelp::Config::annotation_font_scale
darkhelp/lib/settings/annotation/font_thickness 1 DarkHelp::Config::annotation_font_thickness
darkhelp/lib/settings/annotation/include_duration true DarkHelp::Config::annotation_include_duration
darkhelp/lib/settings/annotation/include_timestamp false DarkHelp::Config::annotation_include_timestamp
darkhelp/lib/settings/general/debug false DarkHelp::Config::enable_debug
darkhelp/lib/settings/general/driver darknet
opencv
opencvcpu
DarkHelp::EDriver
darkhelp/lib/settings/general/fix_out_of_bound_values true DarkHelp::Config::fix_out_of_bound_values
darkhelp/lib/settings/general/modify_batch_and_subdivisions true DarkHelp::Config::modify_batch_and_subdivisions
darkhelp/lib/settings/general/names_include_percentage true DarkHelp::Config::names_include_percentage
darkhelp/lib/settings/general/non_maximal_suppression_threshold 0.45 DarkHelp::Config::non_maximal_suppression_threshold
darkhelp/lib/settings/general/sort_predictions 0 DarkHelp::Config::sort_predictions (0 = unsorted, 1 = ascending, 2 = descending)
darkhelp/lib/settings/general/threshold 0.5 DarkHelp::Config::threshold
darkhelp/lib/settings/tiling/combine_tile_predictions true DarkHelp::Config::combine_tile_predictions
darkhelp/lib/settings/tiling/enable_tiles false DarkHelp::Config::enable_tiles
darkhelp/lib/settings/tiling/only_combine_similar_predictions true DarkHelp::Config::only_combine_similar_predictions
darkhelp/lib/settings/tiling/tile_edge_factor 0.25 DarkHelp::Config::tile_edge_factor
darkhelp/lib/settings/tiling/tile_rect_factor 1.2 DarkHelp::Config::tile_rect_factor
darkhelp/server/settings/camera/buffersize 3 When a digital camera is used for input, this determines the number of image buffers OpenCV should attempt to use.
darkhelp/server/settings/camera/fps 30 When a digital camera is used for input, this determines the FPS OpenCV should attempt to use.
darkhelp/server/settings/camera/height 480 When a digital camera is used for input, this determines the image height OpenCV should attempt to use.
darkhelp/server/settings/camera/name /dev/video0
3
When a digital camera is used for input, this determines the device name OpenCV should attempt to use. If the name is a digit, then it is converted to int and the camera with that index is opened.
darkhelp/server/settings/camera/save_original_image true When a digital camera is used for input, this determines if the original video frame will be saved in the output directory.
darkhelp/server/settings/camera/width 640 When a digital camera is used for input, this determines the image width OpenCV should attempt to use.
darkhelp/server/settings/clear_output_directory_on_startup true If old images might remain in the input directory, this can be set to true to force all those images to be deleted. If set to false then those old images will be processed as soon as the DarkHelp Server starts.
darkhelp/server/settings/crop_and_save_detected_objects false When set to true, all the objects detected during inference will be cropped and saved in the output directory.
darkhelp/server/settings/exit_if_idle false When set to true, DarkHelp Server will exit once there are no images left to process. Also see idle_time_in_seconds.
darkhelp/server/settings/idle_time_in_seconds 60 When exit_if_idle is set to true, this value determines how long DarkHelp Server waits before exiting.
darkhelp/server/settings/input_directory /tmp/darkhelpserver/input This is the directory DarkHelp Server uses to find new images. Once an image is moved into this folder, the Server will pick it up and run inference on it, storing the results as configured.
darkhelp/server/settings/max_images_to_process_at_once 10 The maximum number of images from the input directory that are processed before run_cmd_after_processing_images is called.
darkhelp/server/settings/output_directory /tmp/darkhelpserver/output This is the directory DarkHelp Server uses to store results and annotations.
darkhelp/server/settings/purge_files_after_cmd_completes true When set to true, all the files in output_directory will be deleted
darkhelp/server/settings/run_cmd_after_processing_images   The name of an external application or script which is called every once in a while after images have been processed.
darkhelp/server/settings/save_annotated_image false When set to true, images will be annotated using DarkHelp and saved in the output directory.
darkhelp/server/settings/save_json_results true When set to true, the results of inference in JSON format will be saved in the output directory.
darkhelp/server/settings/save_txt_annotations false When set to true, the annotations in Darknet format will be saved in the output directory.
darkhelp/server/settings/use_camera_for_input false When set to false, this means images will be loaded from output_directory. When set to true, this means images will be loaded from the digital camera.

So once the settings are saved to a JSON file, start DarkHelp Server like this:

DarkHelpServer settings.json

Note that the JSON file isn't required to have all the settings in it. Only the ones that differ from the default values listed in the table above. For example, if your JSON file looks like this:

{
"darkhelp": {
"lib":{
"network": {
"cfg": "/home/stephane/nn/driving/driving.cfg",
"names": "/home/stephane/nn/driving/driving.names",
"weights": "/home/stephane/nn/driving/driving_best.weights"
}
},
"server": {
"settings": {
"exit_if_idle":true,
"idle_time_in_seconds":600,
"save_json_results":true,
"run_cmd_after_processing_images":"/home/stephane/bin/images_done.sh"
}
}
}
}

Those settings would then be merged with the default values, and the combined settings are also shown on the console when DarkHelp Server starts running.