The C
API is a wrapper around some of the most common C++
DarkHelp objects and methods. If you have the ability to use C++
, you should instead be using the objects in DarkHelpNN.hpp
and DarkHelpConfig.hpp
.
void Annotate | ( | DarkHelpPtr | ptr, |
const char *const | output_image_filename | ||
) |
Calls DarkHelp::NN::annotate() on the last image and results from either PredictFN() or Predict().
The results will be saved to output_image_filename
in either PNG
or JPG
format depending on the file extension.
References DarkHelp::NN::annotate().
Referenced by main().
DarkHelpPtr CreateDarkHelpNN | ( | const char *const | fn1, |
const char *const | fn2, | ||
const char *const | fn3 | ||
) |
Create a DarkHelp::NN object.
The order in which the filenames are specified is not important. The files should be the .cfg file, the
.names file, and the
.weights file.
When done with the neural network, remember to call DestroyDarkHelpNN().
Referenced by main().
const char* DarkHelpVersion | ( | ) |
Get the DarkHelp version string, such as "1.6.1-2"
.
References DarkHelp::version().
Referenced by main().
const char* DarknetVersion | ( | ) |
Get the "short" Darknet version string, such as "2.0-78"
.
Referenced by main().
void DestroyDarkHelpNN | ( | DarkHelpPtr | ptr | ) |
Destroy the neural network object previously created with CreateDarkHelpNN().
Referenced by main().
bool EnableAnnotationAutoHideLabels | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::annotation_auto_hide_labels.
References DarkHelp::Config::annotation_auto_hide_labels, and DarkHelp::NN::config.
Referenced by main().
bool EnableAnnotationIncludeDuration | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::annotation_include_duration.
References DarkHelp::Config::annotation_include_duration, and DarkHelp::NN::config.
Referenced by main().
bool EnableAnnotationIncludeTimestamp | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::annotation_include_timestamp.
References DarkHelp::Config::annotation_include_timestamp, and DarkHelp::NN::config.
Referenced by main().
bool EnableAnnotationPixelate | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::annotation_pixelate_enabled.
References DarkHelp::Config::annotation_pixelate_enabled, and DarkHelp::NN::config.
bool EnableAnnotationSuppressAllLabels | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::annotation_suppress_all_labels.
References DarkHelp::Config::annotation_suppress_all_labels, and DarkHelp::NN::config.
bool EnableCombineTilePredictions | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::combine_tile_predictions.
References DarkHelp::Config::combine_tile_predictions, and DarkHelp::NN::config.
bool EnableIncludeAllNames | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::include_all_names.
References DarkHelp::NN::config, and DarkHelp::Config::include_all_names.
bool EnableNamesIncludePercentage | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::names_include_percentage.
References DarkHelp::NN::config, and DarkHelp::Config::names_include_percentage.
Referenced by main().
bool EnableOnlyCombineSimilarPredictions | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::only_combine_similar_predictions.
References DarkHelp::NN::config, and DarkHelp::Config::only_combine_similar_predictions.
bool EnableSnapping | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::snapping_enabled.
References DarkHelp::NN::config, and DarkHelp::Config::snapping_enabled.
Referenced by main().
bool EnableTiles | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::enable_tiles.
References DarkHelp::NN::config, and DarkHelp::Config::enable_tiles.
Referenced by main().
bool EnableUseFastImageResize | ( | DarkHelpPtr | ptr, |
bool | enabled | ||
) |
Enable or disable DarkHelp::Config::use_fast_image_resize.
References DarkHelp::NN::config, and DarkHelp::Config::use_fast_image_resize.
const char* GetPredictionResults | ( | DarkHelpPtr | ptr | ) |
Get the last detection results from either PredictFN() or Predict().
The results will be formatted as a JSON string.
char*
buffer used to return the JSON is static, so don't attempt to use this function call simultaneously from multiple threads, otherwise you risk corrupting the returned text or causing strange undefined behaviour. References DarkHelp::Config::cfg_filename, DarkHelp::NN::config, DarkHelp::Config::driver, DarkHelp::NN::duration_string(), DarkHelp::Config::enable_tiles, DarkHelp::NN::horizontal_tiles, DarkHelp::NN::names, DarkHelp::Config::names_filename, DarkHelp::Config::names_include_percentage, DarkHelp::NN::network_size(), DarkHelp::Config::non_maximal_suppression_threshold, DarkHelp::NN::original_image, DarkHelp::NN::prediction_results, DarkHelp::Config::redirect_darknet_output, DarkHelp::Config::snapping_enabled, DarkHelp::Config::threshold, DarkHelp::NN::tile_size, DarkHelp::NN::vertical_tiles, and DarkHelp::Config::weights_filename.
Referenced by main().
int Predict | ( | DarkHelpPtr | ptr, |
const int | width, | ||
const int | height, | ||
uint8_t * | image, | ||
const int | number_of_bytes | ||
) |
Calls DarkHelp::NN::predict() with the given image.
The image data is presumed to be similar to OpenCV's cv::Mat
objects, meaning the bytes need to be in BGR format, not RGB. The number of channels will automatically be determined by dividing the number of bytes by the width and height.
References DarkHelp::NN::predict(), and DarkHelp::NN::prediction_results.
int PredictFN | ( | DarkHelpPtr | ptr, |
const char *const | image_filename | ||
) |
Calls DarkHelp::NN::predict() with the given image filename.
References DarkHelp::NN::predict(), and DarkHelp::NN::prediction_results.
Referenced by main().
double SetAnnotationFontScale | ( | DarkHelpPtr | ptr, |
double | scale | ||
) |
Set the font scale to use when annotating predictions.
References DarkHelp::Config::annotation_font_scale, and DarkHelp::NN::config.
Referenced by main().
int SetAnnotationFontThickness | ( | DarkHelpPtr | ptr, |
int | thickness | ||
) |
Set the font thickness to use when annotating predictions.
References DarkHelp::Config::annotation_font_thickness, and DarkHelp::NN::config.
Referenced by main().
int SetAnnotationLineThickness | ( | DarkHelpPtr | ptr, |
int | thickness | ||
) |
Set the line thickness to use when annotating predictions.
References DarkHelp::Config::annotation_line_thickness, and DarkHelp::NN::config.
Referenced by main().
int SetAnnotationPixelateSize | ( | DarkHelpPtr | ptr, |
int | size | ||
) |
Set the pixelation size to use when EnableAnnotationPixelate() has been enabled.
References DarkHelp::Config::annotation_pixelate_size, and DarkHelp::NN::config.
float SetAnnotationShadePredictions | ( | DarkHelpPtr | ptr, |
float | shading | ||
) |
Set the amount of shading to use when annotating predictions.
References DarkHelp::Config::annotation_shade_predictions, and DarkHelp::NN::config.
Referenced by main().
int SetBinaryThresholdBlockSize | ( | DarkHelpPtr | ptr, |
int | blocksize | ||
) |
Set the value for DarkHelp::Config::binary_threshold_block_size.
References DarkHelp::Config::binary_threshold_block_size, and DarkHelp::NN::config.
double SetBinaryThresholdConstant | ( | DarkHelpPtr | ptr, |
double | threshold | ||
) |
Set the value for DarkHelp::Config::binary_threshold_constant.
References DarkHelp::Config::binary_threshold_constant, and DarkHelp::NN::config.
float SetNonMaximalSuppression | ( | DarkHelpPtr | ptr, |
float | nms | ||
) |
Set the NMS (non maximal suppression) threshold used with Darknet
.
References DarkHelp::NN::config, and DarkHelp::Config::non_maximal_suppression_threshold.
int SetSnappingHorizontalTolerance | ( | DarkHelpPtr | ptr, |
int | tolerance | ||
) |
Set the value for DarkHelp::Config::snapping_horizontal_tolerance.
References DarkHelp::NN::config, and DarkHelp::Config::snapping_horizontal_tolerance.
float SetSnappingLimitGrow | ( | DarkHelpPtr | ptr, |
float | limit | ||
) |
Set the value for DarkHelp::Config::snapping_limit_grow.
References DarkHelp::NN::config, and DarkHelp::Config::snapping_limit_grow.
float SetSnappingLimitShrink | ( | DarkHelpPtr | ptr, |
float | limit | ||
) |
Set the value for DarkHelp::Config::snapping_limit_shrink.
References DarkHelp::NN::config, and DarkHelp::Config::snapping_limit_shrink.
int SetSnappingVerticalTolerance | ( | DarkHelpPtr | ptr, |
int | tolerance | ||
) |
Set the value for DarkHelp::Config::snapping_vertical_tolerance.
References DarkHelp::NN::config, and DarkHelp::Config::snapping_vertical_tolerance.
float SetThreshold | ( | DarkHelpPtr | ptr, |
float | threshold | ||
) |
Set the detection threshold used with Darknet
and DarkHelp
.
References DarkHelp::NN::config, and DarkHelp::Config::threshold.
Referenced by main().
float SetTileEdgeFactor | ( | DarkHelpPtr | ptr, |
float | factor | ||
) |
Set the value for DarkHelp::Config::tile_edge_factor.
References DarkHelp::NN::config, and DarkHelp::Config::tile_edge_factor.
float SetTileRectFactor | ( | DarkHelpPtr | ptr, |
float | factor | ||
) |
Set the value for DarkHelp::Config::tile_rect_factor.
References DarkHelp::NN::config, and DarkHelp::Config::tile_rect_factor.
void ToggleOutputRedirection | ( | ) |
Calls DarkHelp::toggle_output_redirection() to either hide or show output on STDOUT
and STDERR
.
This can be used to hide the large amount of output generated by Darknet
when it first loads a neural network.
References DarkHelp::toggle_output_redirection().