DarkHelp  v1.9.2-1
C++ API for the neural network framework Darknet
Looking for a C++ dev who knows OpenCV?
I'm looking for work. Hire me!
DarkHelp::Config Class Referencefinal

All of DarkHelp's configuration is stored within an instance of this class. More...

#include "DarkHelpConfig.hpp"

Collaboration diagram for DarkHelp::Config:

Public Member Functions

 Config ()
 Constructor. More...
 
 Config (const std::string &cfg_fn, const std::string &weights_fn, const std::string &names_fn="", const bool verify_files_first=true, const EDriver d=EDriver::kDarknet)
 Constructor. More...
 
 ~Config ()
 Destructor. More...
 
Configreset ()
 Reset all config values to their default settings. More...
 

Public Attributes

bool annotation_auto_hide_labels
 Hide the label if the size of the text exceeds the size of the prediction. More...
 
VColours annotation_colours
 The colours to use in DarkHelp::NN::annotate(). More...
 
cv::HersheyFonts annotation_font_face
 Font face to use in DarkHelp::NN::annotate(). Defaults to cv::HersheyFonts::FONT_HERSHEY_SIMPLEX. More...
 
double annotation_font_scale
 Scaling factor used for the font in DarkHelp::NN::annotate(). Defaults to 0.5. More...
 
int annotation_font_thickness
 Thickness of the font in DarkHelp::NN::annotate(). Defaults to 1. More...
 
bool annotation_include_duration
 If set to true then DarkHelp::NN::annotate() will call DarkHelp::NN::duration_string() and display on the top-left of the image the length of time DarkHelp::NN::predict() took to process the image. More...
 
bool annotation_include_timestamp
 If set to true then DarkHelp::NN::annotate() will display a timestamp on the bottom-left corner of the image. More...
 
int annotation_line_thickness
 Thickness of the lines to draw in DarkHelp::NN::annotate(). More...
 
std::set< int > annotation_pixelate_classes
 This can be used to control which classes are pixelated when annotation_pixelate_enabled has been toggled. More...
 
bool annotation_pixelate_enabled
 If set to true then DarkHelp::NN::annotate() will call DarkHelp::pixelate_rectangles() to pixelate the predictions in the output image. More...
 
int annotation_pixelate_size
 The size of the pixelation cell when calling DarkHelp::pixelate_rectangles(). More...
 
float annotation_shade_predictions
 Determines the amount of "shade" used when drawing the prediction rectangles. More...
 
bool annotation_suppress_all_labels
 Completely skip drawing any labels when annotating images. More...
 
std::set< int > annotation_suppress_classes
 Determines which classes to suppress during the call to DarkHelp::NN::annotate(). More...
 
int binary_threshold_block_size
 Block size (in pixels) to use when creating a black-and-white binary image. More...
 
double binary_threshold_constant
 Constant to remove from each pixel value when converting image during thresholding. More...
 
std::string cfg_filename
 Filename (relative or absolute) for the Darknet/YOLO .cfg file. More...
 
bool combine_tile_predictions
 When tiling is enabled, objects may span multiple tiles. More...
 
EDriver driver
 The driver initialization happens in DarkHelp::NN::init(). More...
 
bool enable_debug
 This enables some non-specific debug functionality within the DarkHelp library. More...
 
bool enable_tiles
 Determines if calls to DarkHelp::NN::predict() are sent directly to Darknet, or processed first by DarkHelp::NN::predict_tile() to break the image file into smaller sections. More...
 
bool fix_out_of_bound_values
 Darknet sometimes will return values that are out-of-bound, especially with objects near the edges of the image, or when low detection thresholds. More...
 
float hierarchy_threshold
 Used during prediction. More...
 
bool include_all_names
 Determine if multiple class names are included when labelling an item. More...
 
bool modify_batch_and_subdivisions
 When training, the "batch=..." and "subdivisions=..." values in the .cfg file are typically set to a large value. More...
 
std::string names_filename
 Filename (relative or absolute) for the Darknet/YOLO .names file. More...
 
bool names_include_percentage
 Determines if the name given to each prediction includes the percentage. More...
 
float non_maximal_suppression_threshold
 Non-Maximal Suppression (NMS) threshold suppresses overlapping bounding boxes and only retains the bounding box that has the maximum probability of object detection associated with it. More...
 
bool only_combine_similar_predictions
 When combine_tile_predictions is enabled, this determines if an attempt is made to combine predictions even when the class does not match. More...
 
bool redirect_darknet_output
 Redirect Darknet output to /dev/null (Linux) or NUL: (Windows). More...
 
bool snapping_enabled
 Toggle annotation snapping. More...
 
int snapping_horizontal_tolerance
 Horizontal tolerance (in pixels) used when snapping annotations. More...
 
float snapping_limit_grow
 When snapping is enabled, this is used to establish a maximum for snapping. More...
 
float snapping_limit_shrink
 When snapping is enabled, this is used to establish a minimum for snapping. More...
 
int snapping_vertical_tolerance
 Vertical tolerance (in pixels) used when snapping annotations. More...
 
ESort sort_predictions
 Determines if the predictions will be sorted the next time DarkHelp::NN::predict() is called. More...
 
float threshold
 Image prediction threshold. More...
 
float tile_edge_factor
 This value controls how close to the edge of a tile an object must be to be considered for re-combining when both tiling and recombining have been enabled. More...
 
float tile_rect_factor
 This value controls how close the rectangles needs to line up on two tiles before the predictions are combined. More...
 
bool use_fast_image_resize
 Determine if DarkHelp should use a fast method of resizing images, or a slower but more accurate method. More...
 
std::string weights_filename
 Filename (relative or absolute) for the Darknet/YOLO .weights file. More...
 

Detailed Description

All of DarkHelp's configuration is stored within an instance of this class.

You can either instantiate a DarkHelp::NN object and then access DarkHelp::NN::config to set configuration as desired, or you can intantiate a DarkHelp::Config object and pass it in to the DarkHelp::NN constructor where it will be copied.

Note
Some fields such as the neural network filenames are only used once when DarkHelp::NN::init() is called and then never referenced again.
Since
November 2021

Constructor & Destructor Documentation

◆ Config() [1/2]

DarkHelp::Config::Config ( )

Constructor.

◆ Config() [2/2]

DarkHelp::Config::Config ( const std::string &  cfg_fn,
const std::string &  weights_fn,
const std::string &  names_fn = "",
const bool  verify_files_first = true,
const EDriver  d = EDriver::kDarknet 
)

Constructor.

Note
The order in which you pass the various filenames is not important if verify_files_first is set to true (the default value). This is because DarkHelp::verify_cfg_and_weights() is called to correctly determine which is the .cfg, .weights, and .names file, and swap the names around as necessary so Darknet is given the correct filenames.

References cfg_filename, driver, DarkHelp::kDarknet, names_filename, DarkHelp::verify_cfg_and_weights(), and weights_filename.

Here is the call graph for this function:

◆ ~Config()

DarkHelp::Config::~Config ( )

Destructor.

Member Function Documentation

◆ reset()

DarkHelp::Config & DarkHelp::Config::reset ( )

Reset all config values to their default settings.

References DarkHelp::get_default_annotation_colours(), DarkHelp::kAscending, and DarkHelp::kInvalid.

Here is the call graph for this function:

Member Data Documentation

◆ annotation_auto_hide_labels

bool DarkHelp::Config::annotation_auto_hide_labels

Hide the label if the size of the text exceeds the size of the prediction.

This can help "clean up" some images which contain many small objects. Set to false to always display every label. Set to true if DarkHelp should decide whether a label must be shown or hidden. Defaults to true.

Since
2020-07-03

Examples:

Setting Image
auto_hide_labels=true
auto_hide_labels=false
See also
names_include_percentage
annotation_suppress_all_labels

Referenced by configure(), EnableAnnotationAutoHideLabels(), init(), main(), and process_image().

◆ annotation_colours

VColours DarkHelp::Config::annotation_colours

The colours to use in DarkHelp::NN::annotate().

Defaults to DarkHelp::get_default_annotation_colours().

Remember that OpenCV uses BGR, not RGB. For example, pure red is "(0, 0, 255)".

Referenced by main().

◆ annotation_font_face

cv::HersheyFonts DarkHelp::Config::annotation_font_face

Font face to use in DarkHelp::NN::annotate(). Defaults to cv::HersheyFonts::FONT_HERSHEY_SIMPLEX.

Referenced by configure(), and display_current_msg().

◆ annotation_font_scale

double DarkHelp::Config::annotation_font_scale

Scaling factor used for the font in DarkHelp::NN::annotate(). Defaults to 0.5.

Referenced by display_current_msg(), init(), main(), and SetAnnotationFontScale().

◆ annotation_font_thickness

int DarkHelp::Config::annotation_font_thickness

Thickness of the font in DarkHelp::NN::annotate(). Defaults to 1.

Referenced by configure(), display_current_msg(), and SetAnnotationFontThickness().

◆ annotation_include_duration

bool DarkHelp::Config::annotation_include_duration

If set to true then DarkHelp::NN::annotate() will call DarkHelp::NN::duration_string() and display on the top-left of the image the length of time DarkHelp::NN::predict() took to process the image.

Defaults to true.

When enabed, the duration may look similar to this:

Referenced by configure(), EnableAnnotationIncludeDuration(), init(), main(), process_image(), and process_video().

◆ annotation_include_timestamp

bool DarkHelp::Config::annotation_include_timestamp

If set to true then DarkHelp::NN::annotate() will display a timestamp on the bottom-left corner of the image.

Defaults to false.

When enabled, the timestamp may look similar to this:

Referenced by configure(), EnableAnnotationIncludeTimestamp(), init(), and main().

◆ annotation_line_thickness

int DarkHelp::Config::annotation_line_thickness

Thickness of the lines to draw in DarkHelp::NN::annotate().

Annotations will not be drawn if this is set to 0 (zero). Defaults to 2.

See also
annotation_suppress_all_labels

Referenced by init(), main(), and SetAnnotationLineThickness().

◆ annotation_pixelate_classes

std::set<int> DarkHelp::Config::annotation_pixelate_classes

This can be used to control which classes are pixelated when annotation_pixelate_enabled has been toggled.

By default if pixelation has been enabled then all predictions from all classes are pixelated. If only some classes should be pixelated, then the class IDs can be added to this set.

For example, say your classes are:

  • vehicle
  • person
  • stop sign

If you only want people to be pixelated, then you'd add 1 to this set:

(Classes are always zero-based, so vehicle would be class #0 and person would be class #1.)

See also
DarkHelp::Config::annotation_pixelate_enabled
Since
2022-07-04

◆ annotation_pixelate_enabled

bool DarkHelp::Config::annotation_pixelate_enabled

◆ annotation_pixelate_size

int DarkHelp::Config::annotation_pixelate_size

The size of the pixelation cell when calling DarkHelp::pixelate_rectangles().

This is only used when annotation_pixelate_enabled has also been set to true. The size must be >=5, otherwise pixelation will be ignored.

Setting Image
annotation_pixelate_enabled=false
annotation_pixelate_enabled=true
annotation_pixelate_size=5
annotation_pixelate_enabled=true
annotation_pixelate_size=15
annotation_pixelate_enabled=true
annotation_pixelate_size=25
Since
2022-07-04

Referenced by SetAnnotationPixelateSize().

◆ annotation_shade_predictions

float DarkHelp::Config::annotation_shade_predictions

Determines the amount of "shade" used when drawing the prediction rectangles.

When set to zero, the rectangles are not shaded. When set to 1.0, prediction recangles are completely filled. Values in between are semi-transparent. For example, the default value of 0.25 means the rectangles are filled at 25% opacity.

Since
2020-07-03

Examples:

Setting Image
annotation_shade_predictions=0.0
annotation_shade_predictions=0.25
annotation_shade_predictions=0.50
annotation_shade_predictions=0.75
annotation_shade_predictions=1.0

Referenced by configure(), init(), process_image(), and SetAnnotationShadePredictions().

◆ annotation_suppress_all_labels

bool DarkHelp::Config::annotation_suppress_all_labels

Completely skip drawing any labels when annotating images.

Defaults to false.

Since
2022-04-14
See also
annotation_auto_hide_labels
names_include_percentage
annotation_line_thickness

Referenced by EnableAnnotationSuppressAllLabels(), init(), and process_image().

◆ annotation_suppress_classes

std::set<int> DarkHelp::Config::annotation_suppress_classes

Determines which classes to suppress during the call to DarkHelp::NN::annotate().

Any prediction returned by Darknet for a class listed in this std::set will be ignored: no bounding box will be drawn, and no label will be shown. The set may be modified at any point and will take effect the next time DarkHelp::NN::annotate() is called.

It is initialized by DarkHelp::NN::init() to contain any classes where the label name begins with the text "dont_show" as described in https://github.com/AlexeyAB/darknet/issues/2122.

For example, when considering this annotated image:

If the .names file is modified in this manner:

lock
1
dont_show 2
3
4
...

Then the annotated image will look like this:

Note
This does not suppress the detection of classes. The vector returned when calling DarkHelp::NN::predict() will contain all of the objects found by Darknet, regardless of what classes are listed in DarkHelp::Config::annotation_suppress_classes.

◆ binary_threshold_block_size

int DarkHelp::Config::binary_threshold_block_size

Block size (in pixels) to use when creating a black-and-white binary image.

This is only used when snapping_enabled is set to true or manually calling DarkHelp::NN::snap_annotations(). Default size is 25.

See also
6th parameter of OpenCV's cv::adaptiveThreshold()

Referenced by SetBinaryThresholdBlockSize().

◆ binary_threshold_constant

double DarkHelp::Config::binary_threshold_constant

Constant to remove from each pixel value when converting image during thresholding.

This is only used when snapping_enabled is set to true or manually calling DarkHelp::NN::snap_annotations(). Default is 25.0.

See also
7th parameter of OpenCV's cv::adaptiveThreshold()

Referenced by SetBinaryThresholdConstant().

◆ cfg_filename

std::string DarkHelp::Config::cfg_filename

Filename (relative or absolute) for the Darknet/YOLO .cfg file.

Call DarkHelp::NN::init() after changing this field to force the neural network to be re-loaded.

Referenced by Config(), and GetPredictionResults().

◆ combine_tile_predictions

bool DarkHelp::Config::combine_tile_predictions

When tiling is enabled, objects may span multiple tiles.

When this flag is set to true, DarkHelp will attempt to combine predictions that cross two or more tiles into a single prediction. This has no impact when tiling is off, or when the image processed fits within a single tile. Default is true.

See also
DarkHelp::Config::enable_tiles
DarkHelp::Config::tile_edge_factor
DarkHelp::Config::tile_rect_factor
DarkHelp::Config::only_combine_similar_predictions
Image Description
For example, the image on the left is a portion of a much larger image.
The blue horizontal line in this image shows the location of the boundary between two image tiles.
When combine_tile_predictions=false, the predictions which are split by a tile boundary look like this.
When combine_tile_predictions=true, the predictions split by a tile boundary are re-combined into a single object.

Referenced by configure(), EnableCombineTilePredictions(), and process_image().

◆ driver

EDriver DarkHelp::Config::driver

The driver initialization happens in DarkHelp::NN::init().

If you change this configuration value, you must remember to call DarkHelp::NN::init() to force the neural network to be re-initialized.

Referenced by Config(), and GetPredictionResults().

◆ enable_debug

bool DarkHelp::Config::enable_debug

This enables some non-specific debug functionality within the DarkHelp library.

The exact results of enabling this is undocumented, and will change or may be completely removed without prior notice. It is not meant for the end-user, but instead is used for developers debugging DarkHelp and Darknet. Default value is false.

Referenced by configure(), and init().

◆ enable_tiles

bool DarkHelp::Config::enable_tiles

Determines if calls to DarkHelp::NN::predict() are sent directly to Darknet, or processed first by DarkHelp::NN::predict_tile() to break the image file into smaller sections.

This flag is only checked when DarkHelp::NN::predict() is called. If you call DarkHelp::NN::predict_tile() directly, then it bypasses the check for DarkHelp::Config::enable_tiles and DarkHelp will assume that the image is a candidate for tiling.

Note
Only images which are much larger than the network dimensions will be considered for tiles. If an image is less than approximately 1.5 times the size of the network, then a 1x1 tile (meaning no tiling) will be used.

Both DarkHelp::NN::predict() and DarkHelp::NN::predict_tile() will set the values DarkHelp::NN::tile_size, DarkHelp::NN::vertical_tiles, and DarkHelp::NN::horizontal_tiles once they have finished running. The caller can then reference these to determine what kind of tiling was used. Even when an image is not tiled, these variables will be set; for example, DarkHelp::NN::tile_size may be set to 1x1, and the horizontal and vertical sizes will match the neural network dimensions.

The default value for DarkHelp::Config::enable_tiles is false, meaning that calling DarkHelp::NN::predict() wont automatically result in image tiling.

See also
Image Tiling
DarkHelp::Config::combine_tile_predictions
DarkHelp::NN::horizontal_tiles
DarkHelp::NN::vertical_tiles
DarkHelp::NN::tile_size

Referenced by configure(), EnableTiles(), GetPredictionResults(), init(), main(), and process_image().

◆ fix_out_of_bound_values

bool DarkHelp::Config::fix_out_of_bound_values

Darknet sometimes will return values that are out-of-bound, especially with objects near the edges of the image, or when low detection thresholds.

For example, the X or Y coordinates might be less than zero, or the width and height might extend beyond the edges of the image. When fix_out_of_bound_values is set to true (the default) then the results (DarkHelp::NN::prediction_results) after calling DarkHelp::NN::predict() will be capped so all values are positive and do not extend beyond the edges of the image. When set to false, the exact values as returned by darknet will be used. Defaults to true.

For example:

Image Configuration JSON output comment
    Left portion of the original image. Note the number 13.
fix_out_of_bound_values=false "rect": {"height": 25, "width": 21, "x": -1, "y": 220} The X coordinate is invalid!
fix_out_of_bound_values=true "rect": {"height": 25, "width": 20, "x": 0, "y": 220} Both the X and width have been "fixed".

Referenced by configure().

◆ hierarchy_threshold

float DarkHelp::Config::hierarchy_threshold

Used during prediction.

Defaults to 0.5.

See also
DarkHelp::NN::predict()

Quote:

[...] the network traverses the tree of candidate detections and multiples through the conditional probabilities for each item, e.g. object * animal * feline * house cat. The hierarchical threshold is used in this second step, completely after and separate from whether there is an item or not, to decide whether following the tree further to a more specific class is the right action to take. When this threshold is 0, the tree will basically follow the highest probability branch all the way to a leaf node. [source]

Note
This variable used to be named hierchy_threshold. The typo in the name was fixed in December 2019.

Referenced by init().

◆ include_all_names

bool DarkHelp::Config::include_all_names

Determine if multiple class names are included when labelling an item.

For example, if an object is 95% car or 80% truck, then the label could say "car, truck" when this is set to true, and simply "car" when set to false. Defaults to true.

Referenced by configure(), and EnableIncludeAllNames().

◆ modify_batch_and_subdivisions

bool DarkHelp::Config::modify_batch_and_subdivisions

When training, the "batch=..." and "subdivisions=..." values in the .cfg file are typically set to a large value.

But when loading a neural network for inference as DarkHelp is designed to help with, both of those values in the .cfg should be set to "1". When modify_batch_and_subdivisions is enabled, DarkHelp will edit the configuration file once DarkHelp::NN::init() is called. This ensures the values are set as needed prior to Darknet loading the .cfg file.

The default value for modify_batch_and_subdivisions is true, meaning the .cfg file will be modified. If set to false, DarkHelp will not modify the configuration file.

Example use:

DarkHelp::Config cfg("cars.cfg", "cars_best.weights", "cars.names");
cfg.modify_batch_and_subdivisions = true;
DarkHelp::NN nn(cfg);
Since
Between version 1.1.9 on 2021-03-02 until 1.1.12 on 2021-04-08, this was modified to also toggle the use_cuda_graph=1 flag in the [net] section. See issue #7444 for additional details on use_cuda_graph. Because this new option was suspected of causing some problems with some segfaults and object detection problems in some situations, this code was commented out again in v1.1.13 on 2021-04-08.

Referenced by configure().

◆ names_filename

std::string DarkHelp::Config::names_filename

Filename (relative or absolute) for the Darknet/YOLO .names file.

Call DarkHelp::NN::init() after changing this field to force the neural network to be re-loaded.

Referenced by Config(), and GetPredictionResults().

◆ names_include_percentage

bool DarkHelp::Config::names_include_percentage

Determines if the name given to each prediction includes the percentage.

For example, the name for a prediction might be "dog" when this flag is set to false, or it might be "dog 98%" when set to true. Defaults to true.

Examples:

Setting Image
names_include_percentage=true
names_include_percentage=false
See also
annotation_auto_hide_labels
annotation_suppress_all_labels

Referenced by configure(), EnableNamesIncludePercentage(), GetPredictionResults(), and init().

◆ non_maximal_suppression_threshold

float DarkHelp::Config::non_maximal_suppression_threshold

Non-Maximal Suppression (NMS) threshold suppresses overlapping bounding boxes and only retains the bounding box that has the maximum probability of object detection associated with it.

Defaults to 0.45.

See also
DarkHelp::NN::predict()

Quote:

[...] nms works by looking at all bounding boxes that made it past the 'objectness' threshold and removes the least confident of the boxes that overlap with each other above a certain IOU threshold [source]

(IOU – "intersection over union" – is a ratio that describes how much two areas overlap, where 0.0 means two areas don't overlap at all, and 1.0 means two areas perfectly overlap.)

Referenced by configure(), GetPredictionResults(), init(), and SetNonMaximalSuppression().

◆ only_combine_similar_predictions

bool DarkHelp::Config::only_combine_similar_predictions

When combine_tile_predictions is enabled, this determines if an attempt is made to combine predictions even when the class does not match.

Default is true.

Note that when set to true, this compares all classes for the annotations. For example:

Image Description
Portion of original image.
Annotated image when tiling is enabled and combination is disabled. This shows how the lock and "5" are split across multiple tiles, and how a tiny portion of the "5" seems to initially be annotated as a "6".
The blue lines show where the tile edges are located. There are 4 tiles involved in this example.
Annotated image with full text labels. It is important to note how the small sliver on the right is 49% likely to be a "6" and 20% to be a "5". This is important since by default DarkHelp only combines annotations which have a class in common.
Once DarkHelp::Config::combine_tile_predictions has been enabled, the small sliver on the right was successfully combined into the "5".
The final annotations once combination has been performed.
See also
DarkHelp::Config::combine_tile_predictions
DarkHelp::Config::tile_edge_factor
DarkHelp::Config::tile_rect_factor

Referenced by configure(), and EnableOnlyCombineSimilarPredictions().

◆ redirect_darknet_output

bool DarkHelp::Config::redirect_darknet_output

Redirect Darknet output to /dev/null (Linux) or NUL: (Windows).

Darknet by default generates a lot of output on both STDOUT and STDERR at startup. When this option is set to true, DarkHelp will temporarily redirect both STDOUT and STDERR to discard that output while the network is loading. Once all the network layers are loaded, both STDOUT and STDERR are restored.

The default is false (meaning Darknet's output will be shown).

See also
DarkHelp::toggle_output_redirection()
Since
2022-08-30

Referenced by GetPredictionResults(), and init().

◆ snapping_enabled

bool DarkHelp::Config::snapping_enabled

Toggle annotation snapping.

This automatically creates and uses a binary black-and-white image of the original image to try and "snap" the annotations to an object. Note that this is non-trivial and will slightly increase the processing time. The default is false.

Snapping is mostly intended to be used with dark-coloured items on a light background, such as text on paper. If you turn this on, you may also need to modify DarkHelp::Config::binary_threshold_block_size, DarkHelp::Config::binary_threshold_constant, DarkHelp::Config::snapping_horizontal_tolerance, and DarkHelp::Config::snapping_vertical_tolerance.

See also
DarkHelp::NN::snap_annotations()
DarkHelp::Config::snapping_horizontal_tolerance
Image Setting
snapping_enabled=false
snapping_enabled=true

Referenced by EnableSnapping(), GetPredictionResults(), init(), main(), and process_image().

◆ snapping_horizontal_tolerance

int DarkHelp::Config::snapping_horizontal_tolerance

Horizontal tolerance (in pixels) used when snapping annotations.

This is only used when snapping_enabled is set to true or manually calling DarkHelp::NN::snap_annotations(). Default is 5.

For example, when working with text, you may need to increase this if you want to automatically snap the annotations to grab multiple consecutive words in a sentence. If you want to select a single word, then decrease this value so snapping ends at the end of a word. If you lower it too much, you'll grab individual letters instead of words.

Image Setting
snapping_horizontal_tolerance=1
snapping_vertical_tolerance=1
snapping_horizontal_tolerance=2
snapping_vertical_tolerance=1
snapping_horizontal_tolerance=3
snapping_vertical_tolerance=1
snapping_horizontal_tolerance=7
snapping_vertical_tolerance=1
snapping_horizontal_tolerance=7
snapping_vertical_tolerance=3
snapping_horizontal_tolerance=7
snapping_vertical_tolerance=15

Referenced by init(), and SetSnappingHorizontalTolerance().

◆ snapping_limit_grow

float DarkHelp::Config::snapping_limit_grow

When snapping is enabled, this is used to establish a maximum for snapping.

If the snapped annotation grows to a value greater than this amount, the "snap" is ignored and the original annotation is retained.

The valid range for this is any number larger than or equal to 1.0. If set to 0, then no maximum limit will be applied during snapping. If set to exactly 1, then snapping cannot grow annotations, it can only shrink them. The default is 1.25.

See also
DarkHelp::Config::snapping_enabled
DarkHelp::Config::snapping_limit_shrink

Referenced by SetSnappingLimitGrow().

◆ snapping_limit_shrink

float DarkHelp::Config::snapping_limit_shrink

When snapping is enabled, this is used to establish a minimum for snapping.

If the snapped annotation shrinks to a value smaller than this amount, the "snap" is ignored and the original annotation is retained.

The valid range for this is any number between 0 and 1.0. If set to 0, then no minimum limit will be applied during snapping. If set to exactly 1, then snapping cannot shrink annotations, it can only grow them. The default is 0.4.

See also
DarkHelp::Config::snapping_enabled
DarkHelp::Config::snapping_limit_grow

Referenced by SetSnappingLimitShrink().

◆ snapping_vertical_tolerance

int DarkHelp::Config::snapping_vertical_tolerance

Vertical tolerance (in pixels) used when snapping annotations.

This is only used when snapping_enabled is set to true or manually calling DarkHelp::NN::snap_annotations(). Default is 5.

For example, when working with text, you may need to increase this if you want to automatically snap the annotations to grab an entire paragraph. Smaller values will limit the snap to a single line of text.

See also
DarkHelp::Config::snapping_horizontal_tolerance

Referenced by init(), and SetSnappingVerticalTolerance().

◆ sort_predictions

ESort DarkHelp::Config::sort_predictions

Determines if the predictions will be sorted the next time DarkHelp::NN::predict() is called.

When set to DarkHelp::ESort::kUnsorted, the predictions are in the exact same order as they were returned by Darknet. When set to DarkHelp::ESort::kAscending or DarkHelp::ESort::kDescending, the predictions will be sorted according to DarkHelp::PredictionResult::best_probability.

If annotations will be drawn on the image for visual consumption, then it is often preferable to have the higher probability predictions drawn last so they appear "on top". Otherwise, lower probability predictions may overwrite or obscure the more important ones. This means using DarkHelp::ESort::kAscending (the default).

If you want to process only the first few predictions instead of drawing annotations, then you may want to sort using DarkHelp::ESort::kDescending to ensure you handle the most likely predictions first.

Defaults to DarkHelp::ESort::kAscending.

Referenced by configure().

◆ threshold

float DarkHelp::Config::threshold

Image prediction threshold.

Defaults to 0.5.

See also
DarkHelp::NN::predict()
DarkHelp::NN::annotate()

Quote:

[...] threshold is what is used to determine whether or not there is an object in the predicted bounding box. The network predicts an explicit 'objectness' score separate from the class predictions that if above the threshold indicates that a bounding box will be returned. [source]

Referenced by configure(), GetPredictionResults(), init(), main(), process_image(), and SetThreshold().

◆ tile_edge_factor

float DarkHelp::Config::tile_edge_factor

This value controls how close to the edge of a tile an object must be to be considered for re-combining when both tiling and recombining have been enabled.

The smaller the value, the closer the object must be to the edge of a tile. The factor is multiplied by the width and height of the detected object.

Possible range to consider would be 0.01 to 0.5. If set to zero, then the detected object must be right on the tile boundary to be considered. The default is 0.25.

Image Setting
combine_tile_predictions=false
combine_tile_predictions=true
tile_edge_factor=0.05
combine_tile_predictions=true
tile_edge_factor=0.15
See also
DarkHelp::Config::enable_tiles
DarkHelp::Config::combine_tile_predictions
DarkHelp::Config::only_combine_similar_predictions

Referenced by configure(), init(), and SetTileEdgeFactor().

◆ tile_rect_factor

float DarkHelp::Config::tile_rect_factor

This value controls how close the rectangles needs to line up on two tiles before the predictions are combined.

This is only used when both tiling and recombining have been enabled. As the value approaches 1.0, the closer the rectangles have to be "perfect" to be combined. Values below 1.0 are impossible, and predictions will never be combined. Possible range to consider might be 1.10 to 1.50 or even higher; this also depends on the nature/shape of the objects detected and how the tiles are split up. For example, if the objects are pear-shaped, where the smaller end is on one tile and the larger end on another tile, you may need to increase this value as the object on the different tiles will be of different sizes. The default is 1.20.

Image Setting
tile_rect_factor=1.00
tile_rect_factor=1.10
tile_rect_factor=1.20
See also
DarkHelp::Config::enable_tiles
DarkHelp::Config::combine_tile_predictions
DarkHelp::Config::only_combine_similar_predictions

Referenced by configure(), init(), and SetTileRectFactor().

◆ use_fast_image_resize

bool DarkHelp::Config::use_fast_image_resize

Determine if DarkHelp should use a fast method of resizing images, or a slower but more accurate method.

By default, the OpenCV cv::INTER_NEAREST method will be used. This is faster, but the image quality may be impacted. If this is set to false, then DarkHelp will use OpenCV's INTER_AREA or INTER_CUBIC, which are slower but result in better images.

For "real world" images, the default of true for this option is probably what you want. If you are working with documents that contain black-and-white text, or zoomed-in images such as close-ups of barcodes and components to detect manufacturing detects, you probably want to set this to false.

See also
DarkHelp::fast_resize_ignore_aspect_ratio()
DarkHelp::slow_resize_ignore_aspect_ratio()
Since
2023-07-08

Referenced by EnableUseFastImageResize().

◆ weights_filename

std::string DarkHelp::Config::weights_filename

Filename (relative or absolute) for the Darknet/YOLO .weights file.

Call DarkHelp::NN::init() after changing this field to force the neural network to be re-loaded.

Referenced by Config(), and GetPredictionResults().


The documentation for this class was generated from the following files:
DarkHelp::Config
All of DarkHelp's configuration is stored within an instance of this class.
Definition: DarkHelpConfig.hpp:30
DarkHelp::Config::annotation_pixelate_classes
std::set< int > annotation_pixelate_classes
This can be used to control which classes are pixelated when annotation_pixelate_enabled has been tog...
Definition: DarkHelpConfig.hpp:265
DarkHelp::NN
Instantiate one of these objects by giving it the name of the .cfg and .weights file,...
Definition: DarkHelpNN.hpp:60
DarkHelp::NN::config
Config config
Configuratin for the neural network.
Definition: DarkHelpNN.hpp:447