Darknet/YOLO v3.0-177-gfa2353b
Object Detection Framework
 
Loading...
Searching...
No Matches
Darknet Namespace Reference

The namespace for the C++ Darknet API. More...

Classes

class  ArgsAndParms
 
class  CfgAndState
 
class  CfgFile
 A class that represents a Darknet/YOLO configuration file. More...
 
class  CfgLine
 Each non-empty line in a .cfg file is stored as a Darknet::CfgLine object. More...
 
class  CfgSection
 A class that represents a specific section in a configuration file. More...
 
class  Keypoints
 The Keypoints class works with Darknet's V3 API. More...
 
struct  Layer
 
struct  Network
 Neural network structure. Contains all of the layers. Created by Darknet::CfgFile::create_network(). More...
 
struct  NetworkDetails
 A place to store other details related to the neural network which we cannot easily add to the usual Darknet::Network structure. More...
 
struct  NetworkState
 
struct  Output_Object
 This is used to help keep some state between calls to functions fill_network_boxes(), get_yolo_detections(), etc. More...
 
struct  Parm
 Structure returned by Darknet::parse_arguments(). More...
 
struct  Prediction
 A much-simplified version of the old API structure DarknetDetection. More...
 
class  TimingAndTracking
 The timing and tracking functionality is used to find places in the code where optimizations should be made. More...
 
class  TimingRecords
 An object of this type is statically instantiated in Timing.cpp. More...
 
struct  Tree
 

Typedefs

using CfgLines = std::map< std::string, CfgLine >
 Lines are not stored in the order in which they are read.
 
using CfgSections = std::vector< CfgSection >
 
using MArgsAndParms = std::map< std::string, ArgsAndParms >
 The key is the argument name, the value is the details for that argument.
 
using Output_Object_Cache = std::list< Output_Object >
 
using Parms = std::vector< Parm >
 Structure returned by Darknet::parse_arguments().
 
using Predictions = std::vector< Prediction >
 Each image or video frame may contain many predictions.
 
using Probabilities = std::map< int, float >
 The likelyhood of a specific object class having been predicted.
 
using SArgsAndParms = std::set< ArgsAndParms >
 
using Skeleton = VInt
 
using Skeletons = std::vector< Skeleton >
 
using VThreads = std::vector< std::thread >
 
using MStr = std::map< std::string, std::string >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using MStrInt = std::map< std::string, int >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using SStr = std::set< std::string >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using SInt = std::set< int >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using VFloat = std::vector< float >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using VInt = std::vector< int >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using VStr = std::vector< std::string >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using VScalars = std::vector< cv::Scalar >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using NetworkPtr = DarknetNetworkPtr
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Box = DarknetBox
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Detection = DarknetDetection
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Image = DarknetImage
 Convenient simple types used in the Darknet/YOLO C++ API.
 

Enumerations

enum class  EActivation {
  LOGISTIC = ACTIVATION::LOGISTIC ,
  RELU = ACTIVATION::RELU ,
  RELU6 = ACTIVATION::RELU6 ,
  RELIE = ACTIVATION::RELIE ,
  LINEAR = ACTIVATION::LINEAR ,
  RAMP = ACTIVATION::RAMP ,
  TANH = ACTIVATION::TANH ,
  PLSE = ACTIVATION::PLSE ,
  REVLEAKY = ACTIVATION::REVLEAKY ,
  LEAKY = ACTIVATION::LEAKY ,
  ELU = ACTIVATION::ELU ,
  LOGGY = ACTIVATION::LOGGY ,
  STAIR = ACTIVATION::STAIR ,
  HARDTAN = ACTIVATION::HARDTAN ,
  LHTAN = ACTIVATION::LHTAN ,
  SELU = ACTIVATION::SELU ,
  GELU = ACTIVATION::GELU ,
  SWISH = ACTIVATION::SWISH ,
  MISH = ACTIVATION::MISH ,
  HARD_MISH = ACTIVATION::HARD_MISH ,
  NORM_CHAN = ACTIVATION::NORM_CHAN ,
  NORM_CHAN_SOFTMAX = ACTIVATION::NORM_CHAN_SOFTMAX ,
  NORM_CHAN_SOFTMAX_MAXVAL = ACTIVATION::NORM_CHAN_SOFTMAX_MAXVAL
}
 The plan is to eventually remove ACTIVATION completely once we fully switch over to C++. More...
 
enum  EColour {
  kNormal = 0 ,
  kBlack ,
  kRed ,
  kGreen ,
  kBrown ,
  kBlue ,
  kMagenta ,
  kCyan ,
  kLightGrey ,
  kDarkGrey ,
  kBrightRed ,
  kBrightGreen ,
  kYellow ,
  kBrightBlue ,
  kBrightMagenta ,
  kBrightCyan ,
  kBrightWhite
}
 
enum class  ECostType {
  SSE = COST_TYPE::SSE ,
  MASKED = COST_TYPE::MASKED ,
  SMOOTH = COST_TYPE::SMOOTH
}
 The plan is to eventually remove COST_TYPE completely once we fully switch over to C++. More...
 
enum class  EIoULoss {
  IOU = IOU_LOSS::IOU ,
  GIOU = IOU_LOSS::GIOU ,
  MSE = IOU_LOSS::MSE ,
  DIOU = IOU_LOSS::DIOU ,
  CIOU = IOU_LOSS::CIOU
}
 The plan is to eventually remove IOU_LOSS completely once we fully switch over to C++. More...
 
enum class  ELayerType {
  CONVOLUTIONAL ,
  CONNECTED ,
  MAXPOOL ,
  LOCAL_AVGPOOL ,
  SOFTMAX ,
  DROPOUT ,
  ROUTE ,
  COST ,
  AVGPOOL ,
  SHORTCUT ,
  SCALE_CHANNELS ,
  SAM ,
  RNN ,
  LSTM ,
  CRNN ,
  NETWORK ,
  REGION ,
  YOLO ,
  GAUSSIAN_YOLO ,
  REORG ,
  UPSAMPLE ,
  EMPTY ,
  BLANK ,
  CONTRASTIVE ,
  LAYER_LAST_IDX = ELayerType::CONTRASTIVE
}
 This is the new C++ version of what used to be called LAYER_TYPE in the old C code. More...
 
enum class  ELearningRatePolicy {
  CONSTANT = learning_rate_policy::CONSTANT ,
  STEP = learning_rate_policy::STEP ,
  EXP = learning_rate_policy::EXP ,
  POLY = learning_rate_policy::POLY ,
  STEPS = learning_rate_policy::STEPS ,
  SIG = learning_rate_policy::SIG ,
  RANDOM = learning_rate_policy::RANDOM ,
  SGDR = learning_rate_policy::SGDR
}
 The plan is to eventually remove learning_rate_policy completely once we fully switch over to C++. More...
 
enum class  ENMSKind {
  DEFAULT_NMS = NMS_KIND::DEFAULT_NMS ,
  GREEDY_NMS = NMS_KIND::GREEDY_NMS ,
  DIOU_NMS = NMS_KIND::DIOU_NMS ,
  CORNERS_NMS = NMS_KIND::CORNERS_NMS
}
 The plan is to eventually remove NMS_KIND completely once we fully switch over to C++. More...
 
enum class  EParmType {
  kUnknown ,
  kCfgFilename ,
  kNamesFilename ,
  kWeightsFilename ,
  kDirectory ,
  kFilename ,
  kOther
}
 When parsing command-line parameters, each parameter is assigned a "type". More...
 
enum class  EWeightsNormalization {
  NO_NORMALIZATION = WEIGHTS_NORMALIZATION_T::NO_NORMALIZATION ,
  RELU_NORMALIZATION = WEIGHTS_NORMALIZATION_T::RELU_NORMALIZATION ,
  SOFTMAX_NORMALIZATION = WEIGHTS_NORMALIZATION_T::SOFTMAX_NORMALIZATION
}
 The plan is to eventually remove WEIGHTS_NORMALIZATION_T completely once we fully switch over to C++. More...
 
enum class  EWeightsType {
  NO_WEIGHTS = WEIGHTS_TYPE_T::NO_WEIGHTS ,
  PER_FEATURE = WEIGHTS_TYPE_T::PER_FEATURE ,
  PER_CHANNEL = WEIGHTS_TYPE_T::PER_CHANNEL
}
 The plan is to eventually remove WEIGHTS_TYPE_T completely once we fully switch over to C++. More...
 
enum class  EYoloPoint {
  YOLO_CENTER = YOLO_POINT::YOLO_CENTER ,
  YOLO_LEFT_TOP = YOLO_POINT::YOLO_LEFT_TOP ,
  YOLO_RIGHT_BOTTOM = YOLO_POINT::YOLO_RIGHT_BOTTOM
}
 The plan is to eventually remove YOLO_POINT completely once we fully switch over to C++. More...
 

Functions

SInt add_skipped_class (Darknet::NetworkPtr ptr, const int class_to_skip)
 Add the given class index to the set of classes that Darknet must ignore.
 
cv::Mat annotate (const Darknet::NetworkPtr ptr, const Predictions &predictions, cv::Mat mat)
 Annotate the given image using the predictions from Darknet::predict().
 
void assign_default_class_colours (Darknet::Network *net)
 Generate the necessary class colours used to draw bounding boxes and labels.
 
int best_3d_shift (const Darknet::Image &a, const Darknet::Image &b, int min, int max)
 
int best_3d_shift_r (const Darknet::Image &a, const Darknet::Image &b, int min, int max)
 
Darknet::Image bgr_mat_to_rgb_image (const cv::Mat &mat)
 Similar to the original mat_to_image(), but with 2 differences:
 
float bilinear_interpolate (const Darknet::Image &im, float x, float y, int c)
 
Darknet::Image blend_image (const Darknet::Image &fore, const Darknet::Image &back, float alpha)
 
void cfg_layers ()
 
SInt clear_skipped_classes (Darknet::NetworkPtr ptr)
 Clear the set of classes which Darknet must ignore.
 
Darknet::Image collapse_image_layers (const Darknet::Image &source, int border)
 
Darknet::Image collapse_images_horz (const Darknet::Image *ims, int n)
 
Darknet::Image collapse_images_vert (const Darknet::Image *ims, int n)
 
void composite_3d (char *f1, char *f2, const char *out, int delta)
 
void composite_image (const Darknet::Image &source, Darknet::Image &dest, int dx, int dy)
 
void constrain_image (Darknet::Image &im)
 
std::string convert_to_lowercase_alphanum (const std::string &arg)
 Convert to lowercase and remove all but alphanumerics.
 
Darknet::Image copy_image (const Darknet::Image &p)
 
void copy_image_inplace (const Darknet::Image &src, Darknet::Image &dst)
 
Darknet::Image crop_image (const Darknet::Image &im, const int dx, const int dy, const int w, const int h)
 Crop the given image.
 
SInt del_skipped_class (Darknet::NetworkPtr ptr, const int class_to_include)
 Remove the given class index from the set of classes that Darknet must ignore.
 
char * detection_to_json (Darknet::Detection *dets, int nboxes, int classes, const Darknet::VStr &names, long long int frame_id, char *filename)
 
void display_error_msg (const std::string &msg)
 Display the given message in bright red (if colour is enabled). The message is not linefeed terminated.
 
void display_usage ()
 
void display_warning_msg (const std::string &msg)
 Display the given message in yellow (if colour is enabled). The message is not linefeed terminated.
 
void distort_image (Darknet::Image &im, float hue, float sat, float val)
 
void draw_bbox (Darknet::Image &a, const Darknet::Box &bbox, int w, float r, float g, float b)
 Draw the given bounding box. The line thickness can be specified using w.
 
void draw_box (Darknet::Image &a, int x1, int y1, int x2, int y2, float r, float g, float b)
 Draw a bounding box at the rectangle coordinates within an image, using the specified colour.
 
void draw_box_bw (Darknet::Image &a, int x1, int y1, int x2, int y2, float brightness)
 Draw a bounding box on a black-and-white image.
 
void draw_box_width (Darknet::Image &a, int x1, int y1, int x2, int y2, int w, float r, float g, float b)
 Similiar to Darknet::draw_box(), but the line thickness can be specified using w.
 
void draw_box_width_bw (Darknet::Image &a, int x1, int y1, int x2, int y2, int w, float brightness)
 Similar to Darknet::draw_box_bw(), but the line thickness can be specified using w.
 
void draw_detections_v3 (Darknet::Image &im, const Darknet::Detection *dets, const int num, const float thresh, const Darknet::VStr &names, const int classes, const int ext_output)
 This is the function that is called from older Darknet code to draw annotations on an image.
 
void draw_weighted_label (Darknet::Image &a, int r, int c, Darknet::Image &label, const float *rgb, const float alpha)
 Blend the label (actually an image) into the given image.
 
void embed_image (const Darknet::Image &source, Darknet::Image &dest, int dx, int dy)
 
void fill_image (Darknet::Image &m, float s)
 
void fix_out_of_bound_values (Darknet::NetworkPtr ptr, const bool toggle)
 Fix out-of-bound values returned by Darknet::predict() for objects near the edges of images.
 
void flip_image (Darknet::Image &a)
 Flip image left <-> right.
 
Darknet::Image float_to_image (int w, int h, int c, float *data)
 
Darknet::Image float_to_image_scaled (int w, int h, int c, float *data)
 
std::string format_in_colour (const float &f, const EColour &colour, const size_t &len)
 
std::string format_in_colour (const float &f, const size_t &len, const bool inverted=false)
 
std::string format_in_colour (const int &i, const EColour &colour, const size_t &len)
 
std::string format_in_colour (const size_t &st, const EColour &colour, const size_t &len)
 
std::string format_in_colour (const std::string &str, const EColour &colour, const int &len)
 
std::string format_layer_summary (const size_t idx, const Darknet::CfgSection &section, const Darknet::Layer &l)
 
std::string format_loss (const double &loss)
 Format the loss combined with ANSI colours.
 
std::string format_map_accuracy (const float &accuracy)
 Format the mAP% accuracy with ANSI colours.
 
std::string format_map_confusion_matrix_values (const int class_id, std::string name, const float &average_precision, const int &tp, const int &fn, const int &fp, const int &tn, const float &accuracy, const float &error_rate, const float &precision, const float &recall, const float &specificity, const float &false_pos_rate)
 
std::string format_time (const double &seconds_remaining)
 The time used by Darknet is a double, generated from what_time_is_it_now().
 
std::string format_time_remaining (const float &seconds_remaining)
 Format the time remaining using simple-to-read text. The time must be in seconds.
 
void free_data (data &d)
 Frees the "data buffer" used to load images.
 
void free_image (Darknet::Image &im)
 Free the image.
 
void free_neural_network (Darknet::NetworkPtr &ptr)
 Free the neural network pointer allocated in Darknet::load_neural_network().
 
const SArgsAndParmsget_all_possible_arguments ()
 Get all the possible arguments used by Darknet.
 
const Darknet::VScalarsget_class_colours (const Darknet::NetworkPtr ptr)
 Get access to the vector of colours assigned to each class when the .names file was loaded.
 
const Darknet::VStrget_class_names (const Darknet::NetworkPtr ptr)
 Get access to the vector of names read from the .names file when the configuration was loaded.
 
float get_color (int c, int x, int max)
 Generate some "random" colour value to use. Mostly used for labels and charts.
 
std::string get_command_output (const std::string &cmd)
 
std::filesystem::path get_config_filename (const Darknet::NetworkPtr ptr)
 Get the filename of the configuration file that was used to load this neural network.
 
float get_hierarchy_probability (float *x, Tree *hier, int c)
 
Darknet::Image get_image_layer (const Darknet::Image &m, int l)
 Return a specific channel (eg: R, G, B) from an image.
 
std::filesystem::path get_names_filename (const Darknet::NetworkPtr ptr)
 Get the filename of the names file that was used to load this neural network.
 
std::filesystem::path get_weights_filename (const Darknet::NetworkPtr ptr)
 Get the filename of the weights file that was used to load this neural network.
 
Darknet::Image grayscale_image (const Darknet::Image &im)
 
void hierarchy_predictions (float *predictions, int n, Tree *hier, int only_leaves)
 
int hierarchy_top_prediction (float *predictions, Tree *hier, float thresh, int stride)
 
void hsv_to_rgb (Darknet::Image &im)
 
std::string image_as_debug_string (const Darknet::Image &m)
 Convert the image to a debug string to display the data pointer values.
 
Darknet::Image image_distance (Darknet::Image &a, Darknet::Image &b)
 Create a single-channel image for ...?
 
void image_loading_loop (const int idx, load_args args)
 Run the permanent thread image loading loop.
 
cv::Mat image_to_mat (const Darknet::Image &img)
 Convert the usual Darknet::Image format to OpenCV cv::Mat.
 
std::string in_colour (const EColour colour)
 
std::string in_colour (const EColour colour, const double d)
 
std::string in_colour (const EColour colour, const float f)
 
std::string in_colour (const EColour colour, const int i)
 
std::string in_colour (const EColour colour, const std::string &msg)
 
void initialize_new_charts (const Darknet::Network &net)
 Setup the new C++ charts. This is called once just prior to starting training.
 
float iou (const cv::Rect &lhs, const cv::Rect &rhs)
 Calculate intersection-over-union given 2 OpenCV rectangles.
 
Darknet::Image letterbox_image (const Darknet::Image &im, int w, int h)
 
void letterbox_image_into (const Darknet::Image &im, int w, int h, Darknet::Image &boxed)
 
Darknet::Image load_image (const char *filename, int desired_width=0, int desired_height=0, int channels=0)
 Load the given image.
 
void load_names (Darknet::NetworkPtr net, const std::filesystem::path &filename)
 Load all of the names from a text .names file.
 
Darknet::NetworkPtr load_neural_network (const std::filesystem::path &cfg_filename, const std::filesystem::path &names_filename, const std::filesystem::path &weights_filename)
 Load a neural network (.cfg) and the corresponding weights file.
 
Darknet::NetworkPtr load_neural_network (Darknet::Parms &parms)
 Load a neural network.
 
void load_single_image_data (load_args args)
 Load the given image data as described by the load_args parameter.
 
Darknet::Image make_attention_image (int img_size, float *original_delta_cpu, float *original_input_cpu, int w, int h, int c, float alpha)
 The resulting image takes ownership of original_delta_cpu.
 
void make_image_red (Darknet::Image &im)
 
Darknet::Image make_random_image (int w, int h, int c)
 
Darknet::Image mat_to_image (const cv::Mat &mat)
 Convert an OpenCV cv::Mat object to Darknet::Image.
 
void network_dimensions (Darknet::NetworkPtr &ptr, int &w, int &h, int &c)
 Get the network dimensions (width, height, channels).
 
void normalize_image (Darknet::Image &p)
 
void normalize_image2 (Darknet::Image &p)
 
std::ostream & operator<< (std::ostream &os, const Darknet::Prediction &pred)
 Display some information about this specific prediction.
 
std::ostream & operator<< (std::ostream &os, const Darknet::Predictions &preds)
 Display some information about all the predictions.
 
Darknet::Parms parse_arguments (const Darknet::VStr &v)
 Similar to the other Darknet::parse_arguments(), but uses a vector of strings as input.
 
Darknet::Parms parse_arguments (int argc, char *argv[])
 Parse common Darknet command-line parameters with the values from argc and argv in main().
 
Predictions predict (const Darknet::NetworkPtr ptr, const cv::Mat &mat)
 Get Darknet to look at the given image or video frame and return all predictions.
 
Predictions predict (const Darknet::NetworkPtr ptr, const std::filesystem::path &image_filename)
 Get Darknet to look at the given image and return all predictions.
 
Predictions predict (const Darknet::NetworkPtr ptr, Darknet::Image &img, cv::Size original_image_size=cv::Size(0, 0))
 Get Darknet to look at the given image or video frame and return all predictions.
 
Predictions predict_and_annotate (const Darknet::NetworkPtr ptr, cv::Mat mat)
 Combination of Darknet::predict() and Darknet::annotate().
 
void quantize_image (Darknet::Image &im)
 
Darknet::Image random_augment_image (const Darknet::Image &im, const float angle, float aspect, const int low, const int high, const int size)
 Apply a bunch of random augmentations.
 
Darknet::Image random_crop_image (const Darknet::Image &im, const int w, const int h)
 Similar to Darknet::crop_image() but the dx and dy are random values.
 
void random_distort_image (Darknet::Image &im, float hue, float saturation, float exposure)
 
Treeread_tree (const char *filename)
 
Darknet::Image resize_image (const Darknet::Image &im, int w, int h)
 
cv::Mat resize_keeping_aspect_ratio (cv::Mat &mat, cv::Size desired_size, const cv::InterpolationFlags method=cv::InterpolationFlags::INTER_NEAREST)
 Resize the image as close as we can to the given size, but keep the aspect ratio the same as the original image.
 
Darknet::Image resize_max (const Darknet::Image &im, int max)
 
Darknet::Image resize_min (const Darknet::Image &im, int min)
 
cv::Mat rgb_image_to_bgr_mat (const Darknet::Image &img)
 Similar to the original image_to_mat(), but with 2 differences:
 
void rgb_to_hsv (Darknet::Image &im)
 
void rgbgr_image (Darknet::Image &im)
 Do the equivalent of OpenCV's cv::COLOR_BGR2RGB to swap red and blue floats.
 
Darknet::Image rotate_crop_image (const Darknet::Image &im, float rad, float s, int w, int h, float dx, float dy, float aspect)
 
Darknet::Image rotate_image (const Darknet::Image &im, float rad)
 Rotate image.
 
void rotate_image_cw (Darknet::Image &im, int times)
 Rotate image clockwise?
 
void run_image_loading_control_thread (load_args args)
 This runs as a std::thread.
 
void save_image (const Darknet::Image &p, const char *name)
 
void save_image_jpg (const Darknet::Image &im, const char *name)
 
void save_image_png (const Darknet::Image &im, const char *name)
 
void scale_image (Darknet::Image &m, const float s)
 Scale the RGB values in an image by the given amount.
 
void scale_image_channel (Darknet::Image &im, int c, float v)
 
void set_annotation_draw_bb (Darknet::NetworkPtr ptr, const bool toggle)
 Determines if bounding boxes are drawn when calling either Darknet::annotate() or Darknet::predict_and_annotate().
 
void set_annotation_draw_label (Darknet::NetworkPtr ptr, const bool toggle)
 Determines if text labels are drawn above the bounding boxes when calling either Darknet::annotate() or Darknet::predict_and_annotate().
 
void set_annotation_font (Darknet::NetworkPtr ptr, const cv::LineTypes line_type, const cv::HersheyFonts font_face, const int font_thickness, const double font_scale)
 Set the font characteristics to use when drawing the bounding boxes and labels in either Darknet::annotate() or Darknet::predict_and_annotate().
 
void set_annotation_line_type (Darknet::NetworkPtr ptr, const cv::LineTypes line_type)
 The OpenCV line type can impact performance.
 
const Darknet::VScalarsset_class_colours (Darknet::NetworkPtr ptr, const Darknet::VScalars &colours)
 Set the colours to use when drawing annotations.
 
void set_default_keypoints_files (Darknet::Parms &parms)
 Add the default Darknet Keypoints neural network files to the given parms.
 
void set_detection_threshold (Darknet::NetworkPtr ptr, float threshold)
 Detection threshold to use when Darknet::predict() is called.
 
void set_gpu_index (int idx)
 Set the GPU index to use.
 
void set_non_maximal_suppression_threshold (Darknet::NetworkPtr ptr, float threshold)
 Non-maximal suppression threshold to use when Darknet::predict() is called.
 
void set_rounded_corner_bounding_boxes (Darknet::NetworkPtr ptr, const bool toggle, const float roundness)
 This determines if annotations are drawn as circles or rounded rectangles in either Darknet::annotate() or Darknet::predict_and_annotate().
 
void set_trace (const bool flag)
 Set the Darknet::CfgAndState::is_trace flag.
 
void set_verbose (const bool flag)
 Set the Darknet::CfgAndState::is_verbose flag.
 
void show_image (const Darknet::Image &p, const char *name)
 
void show_image_collapsed (const Darknet::Image &p, const char *name)
 
void show_image_layers (const Darknet::Image &p, const char *name)
 
void show_images (Darknet::Image *ims, int n, const char *window)
 
void show_version_info ()
 Display a few lines of text with some version information.
 
SInt skipped_classes (const Darknet::NetworkPtr ptr)
 Return the set of classes which Darknet must ignore.
 
SInt skipped_classes (Darknet::NetworkPtr ptr, const SInt &classes_to_skip)
 Set the classes which Darknet must ignore, completely over-writing all previous values.
 
void stop_image_loading_threads ()
 Stop and join the image loading threads started in Darknet::run_image_loading_control_thread().
 
void test_resize (char *filename)
 
std::string text_to_simple_label (std::string txt)
 Convert the given text to plain alphanumeric ASCII string.
 
Darknet::Image threshold_image (const Darknet::Image &im, float thresh)
 
void translate_image (Darknet::Image m, float s)
 
void update_accuracy_in_new_charts (const int class_index, const float accuracy)
 
void update_loss_in_new_charts (const int current_iteration, const float loss, const float seconds_remaining, const bool dont_show)
 Update the new C++ charts with the given loss and mAP% accuracy value. This is called at every iteration.
 
std::string trim (const std::string &str)
 Trim leading and trailing whitespace from the given string.
 
std::string & trim (std::string &str)
 Trim leading and trailing whitespace from the given string.
 
std::string lowercase (const std::string &str)
 Simple conversion of the string to lowercase.
 
std::string & lowercase (std::string &str)
 Simple conversion of the string to lowercase.
 
void dump (Darknet::Network *net, const Darknet::CfgFile::CommonParms &parms)
 Dump some information on the given network and layers to a text file for debugging.
 
void dump (Darknet::CfgFile &cfg)
 Dump some information on the given network and layers to a text file for debugging.
 
using NamesAndLayers = std::map< std::string, ELayerType >
 Convert between names and Darknet/YOLO layer types.
 
const NamesAndLayersall_names_and_layers ()
 Convert between names and Darknet/YOLO layer types.
 
ELayerType get_layer_type_from_name (const std::string &name)
 Convert between names and Darknet/YOLO layer types.
 
std::string to_string (const ELayerType type)
 Convert between names and Darknet/YOLO layer types.
 
using NamesAndActivationTypes = std::map< std::string, EActivation >
 Convert between names and activation types.
 
const NamesAndActivationTypesall_names_and_activations ()
 Convert between names and activation types.
 
EActivation get_activation_from_name (const std::string &name)
 Convert between names and activation types.
 
std::string to_string (const EActivation activation)
 Convert between names and activation types.
 
using NamesAndLearningRatePolicies = std::map< std::string, ELearningRatePolicy >
 Convert between names and learning rate policies.
 
const NamesAndLearningRatePoliciesall_names_and_learning_rate_policies ()
 Convert between names and learning rate policies.
 
ELearningRatePolicy get_learning_rate_policy_from_name (const std::string &name)
 Convert between names and learning rate policies.
 
std::string to_string (const ELearningRatePolicy policy)
 Convert between names and learning rate policies.
 
using NamesAndIoULoss = std::map< std::string, EIoULoss >
 Convert between names and IoU loss types.
 
const NamesAndIoULossall_names_and_IoU_loss ()
 Convert between names and IoU loss types.
 
EIoULoss get_IoU_loss_from_name (const std::string &name)
 Convert between names and IoU loss types.
 
std::string to_string (const EIoULoss loss)
 Convert between names and IoU loss types.
 
using NamesAndNMSKind = std::map< std::string, ENMSKind >
 Convert between names and NMS kind.
 
const NamesAndNMSKindall_names_and_NMS_kind ()
 Convert between names and NMS kind.
 
ENMSKind get_NMS_kind_from_name (const std::string &name)
 Convert between names and NMS kind.
 
std::string to_string (const ENMSKind nms_kind)
 Convert between names and NMS kind.
 
using NamesAndWeightsType = std::map< std::string, EWeightsType >
 Convert between names and weights types.
 
const NamesAndWeightsTypeall_names_and_weights_types ()
 Convert between names and weights types.
 
EWeightsType get_weights_type_from_name (const std::string &name)
 Convert between names and weights types.
 
std::string to_string (const EWeightsType type)
 Convert between names and weights types.
 
using NamesAndWeightsNormalization = std::map< std::string, EWeightsNormalization >
 Convert between names and weights normalization.
 
const NamesAndWeightsNormalizationall_names_and_weights_normalization ()
 Convert between names and weights normalization.
 
EWeightsNormalization get_weights_normalization_from_name (const std::string &name)
 Convert between names and weights normalization.
 
std::string to_string (const EWeightsNormalization normalization)
 Convert between names and weights normalization.
 
using NamesAndCostTypes = std::map< std::string, ECostType >
 Convert between names and cost types.
 
const NamesAndCostTypesall_names_and_cost_types ()
 Convert between names and cost types.
 
ECostType get_cost_types_from_name (const std::string &name)
 Convert between names and cost types.
 
std::string to_string (const ECostType type)
 Convert between names and cost types.
 
using NamesAndYoloPointTypes = std::map< std::string, EYoloPoint >
 Convert between names and YOLO point types.
 
const NamesAndYoloPointTypesall_names_and_yolo_point_types ()
 Convert between names and YOLO point types.
 
EYoloPoint get_yolo_point_types_from_name (const std::string &name)
 Convert between names and YOLO point types.
 
std::string to_string (const EYoloPoint type)
 Convert between names and YOLO point types.
 

Detailed Description

The namespace for the C++ Darknet API.

Note this namespace contains both public and private API calls. The structures, enums, classes and functions declared in darknet.hpp are part of the public API.

Typedef Documentation

◆ Box

using Darknet::Box = typedef DarknetBox

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ CfgLines

using Darknet::CfgLines = typedef std::map<std::string, CfgLine>

Lines are not stored in the order in which they are read.

Instead, they are stored as a map which allows us to quickly look up a value based on the key. There should be no duplicate keys within a section, nor should the order matter.

◆ CfgSections

using Darknet::CfgSections = typedef std::vector<CfgSection>

◆ Detection

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ Image

using Darknet::Image = typedef DarknetImage

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ MArgsAndParms

using Darknet::MArgsAndParms = typedef std::map<std::string, ArgsAndParms>

The key is the argument name, the value is the details for that argument.

◆ MStr

using Darknet::MStr = typedef std::map<std::string, std::string>

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ MStrInt

using Darknet::MStrInt = typedef std::map<std::string, int>

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ NamesAndActivationTypes

using Darknet::NamesAndActivationTypes = typedef std::map<std::string, EActivation>

Convert between names and activation types.

◆ NamesAndCostTypes

using Darknet::NamesAndCostTypes = typedef std::map<std::string, ECostType>

Convert between names and cost types.

◆ NamesAndIoULoss

using Darknet::NamesAndIoULoss = typedef std::map<std::string, EIoULoss>

Convert between names and IoU loss types.

◆ NamesAndLayers

using Darknet::NamesAndLayers = typedef std::map<std::string, ELayerType>

Convert between names and Darknet/YOLO layer types.

◆ NamesAndLearningRatePolicies

using Darknet::NamesAndLearningRatePolicies = typedef std::map<std::string, ELearningRatePolicy>

Convert between names and learning rate policies.

◆ NamesAndNMSKind

using Darknet::NamesAndNMSKind = typedef std::map<std::string, ENMSKind>

Convert between names and NMS kind.

◆ NamesAndWeightsNormalization

using Darknet::NamesAndWeightsNormalization = typedef std::map<std::string, EWeightsNormalization>

Convert between names and weights normalization.

◆ NamesAndWeightsType

using Darknet::NamesAndWeightsType = typedef std::map<std::string, EWeightsType>

Convert between names and weights types.

◆ NamesAndYoloPointTypes

using Darknet::NamesAndYoloPointTypes = typedef std::map<std::string, EYoloPoint>

Convert between names and YOLO point types.

◆ NetworkPtr

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ Output_Object_Cache

using Darknet::Output_Object_Cache = typedef std::list<Output_Object>

◆ Parms

using Darknet::Parms = typedef std::vector<Parm>

Structure returned by Darknet::parse_arguments().

Since
2024-07-29

◆ Predictions

using Darknet::Predictions = typedef std::vector<Prediction>

Each image or video frame may contain many predictions.

These predictions are stored in a vector in no particular order.

See also
Darknet::predict()
Since
2024-07-24

◆ Probabilities

using Darknet::Probabilities = typedef std::map<int, float>

The likelyhood of a specific object class having been predicted.

This map contains all of the non-zero values. The key is the zero-based class indexes, and the values are the confidences for the classes, between 0.0f and 1.0f.

For example, if "car" is class #2 and "truck" is class #3, and Darknet is 95% certain it found a car and 82% certain it found a truck, the map would then contain "{ {2, 0.95}, {3, 0.82} }".

See also
Darknet::Prediction
Since
2024-07-24

◆ SArgsAndParms

using Darknet::SArgsAndParms = typedef std::set<ArgsAndParms>

◆ SInt

using Darknet::SInt = typedef std::set<int>

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ Skeleton

using Darknet::Skeleton = typedef VInt

◆ Skeletons

using Darknet::Skeletons = typedef std::vector<Skeleton>

◆ SStr

using Darknet::SStr = typedef std::set<std::string>

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ VFloat

using Darknet::VFloat = typedef std::vector<float>

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ VInt

using Darknet::VInt = typedef std::vector<int>

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ VScalars

using Darknet::VScalars = typedef std::vector<cv::Scalar>

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ VStr

using Darknet::VStr = typedef std::vector<std::string>

Convenient simple types used in the Darknet/YOLO C++ API.

Since
2024-07-14

◆ VThreads

using Darknet::VThreads = typedef std::vector<std::thread>

Enumeration Type Documentation

◆ EActivation

enum class Darknet::EActivation
strong

The plan is to eventually remove ACTIVATION completely once we fully switch over to C++.

See also
Darknet::all_names_and_activations()
Darknet::get_activation_from_name()
Darknet::to_string()
Enumerator
LOGISTIC 
RELU 
RELU6 
RELIE 
LINEAR 
RAMP 
TANH 
PLSE 
REVLEAKY 
LEAKY 
ELU 
LOGGY 
STAIR 
HARDTAN 
LHTAN 
SELU 
GELU 
SWISH 
MISH 
HARD_MISH 
NORM_CHAN 
NORM_CHAN_SOFTMAX 
NORM_CHAN_SOFTMAX_MAXVAL 

◆ EColour

Enumerator
kNormal 
kBlack 
kRed 
kGreen 
kBrown 
kBlue 
kMagenta 
kCyan 
kLightGrey 
kDarkGrey 
kBrightRed 
kBrightGreen 
kYellow 
kBrightBlue 
kBrightMagenta 
kBrightCyan 
kBrightWhite 

◆ ECostType

enum class Darknet::ECostType
strong

The plan is to eventually remove COST_TYPE completely once we fully switch over to C++.

See also
Darknet::all_names_and_cost_types()
Darknet::get_cost_types_from_name()
Darknet::to_string()
Enumerator
SSE 
MASKED 
SMOOTH 

◆ EIoULoss

enum class Darknet::EIoULoss
strong

The plan is to eventually remove IOU_LOSS completely once we fully switch over to C++.

See also
Darknet::all_names_and_IoU_loss()
Darknet::get_IoU_loss_from_name()
Darknet::to_string()
Enumerator
IOU 
GIOU 
MSE 
DIOU 
CIOU 

◆ ELayerType

enum class Darknet::ELayerType
strong

This is the new C++ version of what used to be called LAYER_TYPE in the old C code.

See also
Darknet::all_names_and_layers()
Darknet::get_layer_type_from_name()
Darknet::to_string()
Enumerator
CONVOLUTIONAL 

this is used everywhere

CONNECTED 

used in 3 rarely used configurations

MAXPOOL 

used often

LOCAL_AVGPOOL 

only used in yolov4-tiny_contrastive.cfg – obsolete?

SOFTMAX 

used in several non-YOLO configs

DROPOUT 

used in 3 non-YOLO configs

ROUTE 

used often

COST 

used in several non-YOLO configs

AVGPOOL 

used in several non-YOLO configs

SHORTCUT 

used almost everywhere

SCALE_CHANNELS 

only used in 2 configs

SAM 

only used in 3 configs

RNN 

only used in rnn.train.cfg – obsolete?

LSTM 

only used in lstm.train.cfg – obsolete?

CRNN 

only used in 2 non-YOLO configs

NETWORK 

used in every config

REGION 

only used in tiny-yolo_xnor.cfg (which is NOT a YOLO config)

YOLO 

used often

GAUSSIAN_YOLO 

only used in Gaussian_yolov3_BDD.cfg

REORG 

only used in yolov4-sam-mish-csp-reorg-bfm.cfg

UPSAMPLE 

used often, does downsampling instead if l.reverse=1

EMPTY 

UNUSED

BLANK 

UNUSED

CONTRASTIVE 

only used in yolov4-tiny_contrastive.cfg

LAYER_LAST_IDX 

point to the last-used idx

◆ ELearningRatePolicy

enum class Darknet::ELearningRatePolicy
strong

The plan is to eventually remove learning_rate_policy completely once we fully switch over to C++.

See also
Darknet::all_names_and_learning_rate_policies()
Darknet::get_learning_rate_policy_from_name()
Darknet::to_string()
Enumerator
CONSTANT 
STEP 
EXP 
POLY 
STEPS 
SIG 
RANDOM 
SGDR 

◆ ENMSKind

enum class Darknet::ENMSKind
strong

The plan is to eventually remove NMS_KIND completely once we fully switch over to C++.

See also
Darknet::all_names_and_NMS_kind()
Darknet::get_NMS_kind_from_name()
Darknet::to_string()
Enumerator
DEFAULT_NMS 
GREEDY_NMS 
DIOU_NMS 
CORNERS_NMS 

◆ EParmType

enum class Darknet::EParmType
strong

When parsing command-line parameters, each parameter is assigned a "type".

See also
Darknet::Parm
Darknet::parse_arguments()
Since
2024-07-29
Enumerator
kUnknown 

Should be unused. See "kOther" instead for all other parameter types.

kCfgFilename 

The configuration file to load. There should only be 1 parameter of this type.

kNamesFilename 

The names file to load. There should only be 1 parameter of this type.

kWeightsFilename 

The weights file to load. There should only be 1 parameter of this type.

kDirectory 

An existing directory name.

kFilename 

An existing filename which is not one of the 3 neural network files.

kOther 

Any other parameter.

◆ EWeightsNormalization

enum class Darknet::EWeightsNormalization
strong

The plan is to eventually remove WEIGHTS_NORMALIZATION_T completely once we fully switch over to C++.

See also
Darknet::all_names_and_weights_normalization()
Darknet::get_weights_normalization_from_name()
Darknet::to_string()
Enumerator
NO_NORMALIZATION 
RELU_NORMALIZATION 
SOFTMAX_NORMALIZATION 

◆ EWeightsType

enum class Darknet::EWeightsType
strong

The plan is to eventually remove WEIGHTS_TYPE_T completely once we fully switch over to C++.

See also
Darknet::all_names_and_weights_types()
Darknet::get_weights_type_from_name()
Darknet::to_string()
Enumerator
NO_WEIGHTS 
PER_FEATURE 
PER_CHANNEL 

◆ EYoloPoint

enum class Darknet::EYoloPoint
strong

The plan is to eventually remove YOLO_POINT completely once we fully switch over to C++.

See also
Darknet::all_names_and_yolo_point_types()
Darknet::get_yolo_point_types_from_name()
Darknet::to_string()
Enumerator
YOLO_CENTER 
YOLO_LEFT_TOP 
YOLO_RIGHT_BOTTOM 

Function Documentation

◆ add_skipped_class()

Darknet::SInt Darknet::add_skipped_class ( Darknet::NetworkPtr  ptr,
const int  class_to_skip 
)

Add the given class index to the set of classes that Darknet must ignore.

This may be called multiple times if you have many classes you want skipped, or you can call skipped_classes() if you want to set them all at once.

See also
Darknet::skipped_classes()
Darknet::clear_skipped_classes()
Darknet::del_skipped_class()
Since
2024-10-07
Here is the caller graph for this function:

◆ all_names_and_activations()

const Darknet::NamesAndActivationTypes & Darknet::all_names_and_activations ( )

Convert between names and activation types.

Here is the caller graph for this function:

◆ all_names_and_cost_types()

const Darknet::NamesAndCostTypes & Darknet::all_names_and_cost_types ( )

Convert between names and cost types.

Here is the caller graph for this function:

◆ all_names_and_IoU_loss()

const Darknet::NamesAndIoULoss & Darknet::all_names_and_IoU_loss ( )

Convert between names and IoU loss types.

Here is the caller graph for this function:

◆ all_names_and_layers()

const Darknet::NamesAndLayers & Darknet::all_names_and_layers ( )

Convert between names and Darknet/YOLO layer types.

Here is the caller graph for this function:

◆ all_names_and_learning_rate_policies()

const Darknet::NamesAndLearningRatePolicies & Darknet::all_names_and_learning_rate_policies ( )

Convert between names and learning rate policies.

Here is the caller graph for this function:

◆ all_names_and_NMS_kind()

const Darknet::NamesAndNMSKind & Darknet::all_names_and_NMS_kind ( )

Convert between names and NMS kind.

Here is the caller graph for this function:

◆ all_names_and_weights_normalization()

const Darknet::NamesAndWeightsNormalization & Darknet::all_names_and_weights_normalization ( )

Convert between names and weights normalization.

Here is the caller graph for this function:

◆ all_names_and_weights_types()

const Darknet::NamesAndWeightsType & Darknet::all_names_and_weights_types ( )

Convert between names and weights types.

Here is the caller graph for this function:

◆ all_names_and_yolo_point_types()

const Darknet::NamesAndYoloPointTypes & Darknet::all_names_and_yolo_point_types ( )

Convert between names and YOLO point types.

Here is the caller graph for this function:

◆ annotate()

cv::Mat Darknet::annotate ( const Darknet::NetworkPtr  ptr,
const Predictions predictions,
cv::Mat  mat 
)

Annotate the given image using the predictions from Darknet::predict().

See also
Darknet::predict_and_annotate()
Since
2024-07-30
Here is the caller graph for this function:

◆ assign_default_class_colours()

void Darknet::assign_default_class_colours ( Darknet::Network net)

Generate the necessary class colours used to draw bounding boxes and labels.

The colours are stored in Darknet::NetworkDetails at the time the network is loaded, once the total number of classes are known.

This is called automatically when the network is initialized via Darknet::CfgFile. There is no need to manually call this function.

Since
2024-08-06
Here is the call graph for this function:
Here is the caller graph for this function:

◆ best_3d_shift()

int Darknet::best_3d_shift ( const Darknet::Image a,
const Darknet::Image b,
int  min,
int  max 
)
Here is the call graph for this function:

◆ best_3d_shift_r()

int Darknet::best_3d_shift_r ( const Darknet::Image a,
const Darknet::Image b,
int  min,
int  max 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bgr_mat_to_rgb_image()

Darknet::Image Darknet::bgr_mat_to_rgb_image ( const cv::Mat &  mat)

Similar to the original mat_to_image(), but with 2 differences:

  • the input image is in the "natural" OpenCV BGR format (the output image is still in RGB format),
  • this function uses very efficent OpenCV techniques to convert the cv::Mat to Darknet::Image which makes it much faster.

Remember to call Darknet::free_image() when done.

See also
Darknet::rgb_image_to_bgr_mat()
Since
2024-08-23
Todo:
COLOR this function assumes 3-channel images
Here is the call graph for this function:
Here is the caller graph for this function:

◆ bilinear_interpolate()

float Darknet::bilinear_interpolate ( const Darknet::Image im,
float  x,
float  y,
int  c 
)
Here is the caller graph for this function:

◆ blend_image()

Darknet::Image Darknet::blend_image ( const Darknet::Image fore,
const Darknet::Image back,
float  alpha 
)
Here is the call graph for this function:

◆ cfg_layers()

void Darknet::cfg_layers ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_skipped_classes()

Darknet::SInt Darknet::clear_skipped_classes ( Darknet::NetworkPtr  ptr)

Clear the set of classes which Darknet must ignore.

The default is for Darknet/YOLO to not skip any classes, as if this function has been called.

See also
Darknet::skipped_classes()
Darknet::add_skipped_class()
Darknet::del_skipped_class()
Since
2024-10-07
Here is the caller graph for this function:

◆ collapse_image_layers()

Darknet::Image Darknet::collapse_image_layers ( const Darknet::Image source,
int  border 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ collapse_images_horz()

Darknet::Image Darknet::collapse_images_horz ( const Darknet::Image ims,
int  n 
)

◆ collapse_images_vert()

Darknet::Image Darknet::collapse_images_vert ( const Darknet::Image ims,
int  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ composite_3d()

void Darknet::composite_3d ( char *  f1,
char *  f2,
const char *  out,
int  delta 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ composite_image()

void Darknet::composite_image ( const Darknet::Image source,
Darknet::Image dest,
int  dx,
int  dy 
)
Here is the call graph for this function:

◆ constrain_image()

void Darknet::constrain_image ( Darknet::Image im)
Here is the caller graph for this function:

◆ convert_to_lowercase_alphanum()

std::string Darknet::convert_to_lowercase_alphanum ( const std::string &  arg)

Convert to lowercase and remove all but alphanumerics.

Here is the caller graph for this function:

◆ copy_image()

Darknet::Image Darknet::copy_image ( const Darknet::Image p)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_image_inplace()

void Darknet::copy_image_inplace ( const Darknet::Image src,
Darknet::Image dst 
)
Note
Function currently seems to be unused.

◆ crop_image()

Darknet::Image Darknet::crop_image ( const Darknet::Image im,
const int  dx,
const int  dy,
const int  w,
const int  h 
)

Crop the given image.

See also
Darknet::random_crop_image()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ del_skipped_class()

Darknet::SInt Darknet::del_skipped_class ( Darknet::NetworkPtr  ptr,
const int  class_to_include 
)

Remove the given class index from the set of classes that Darknet must ignore.

This may be called multiple times if there are several class indexes you'll like to restore.

See also
Darknet::skipped_classes()
Darknet::clear_skipped_classes()
Darknet::add_skipped_class()
Since
2024-10-07
Here is the caller graph for this function:

◆ detection_to_json()

char * Darknet::detection_to_json ( Darknet::Detection dets,
int  nboxes,
int  classes,
const Darknet::VStr names,
long long int  frame_id,
char *  filename 
)
Here is the caller graph for this function:

◆ display_error_msg()

void Darknet::display_error_msg ( const std::string &  msg)

Display the given message in bright red (if colour is enabled). The message is not linefeed terminated.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_usage()

void Darknet::display_usage ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_warning_msg()

void Darknet::display_warning_msg ( const std::string &  msg)

Display the given message in yellow (if colour is enabled). The message is not linefeed terminated.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ distort_image()

void Darknet::distort_image ( Darknet::Image im,
float  hue,
float  sat,
float  val 
)
Todo:
COLOR - needs to be fixed for 1 <= c <= N
Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_bbox()

void Darknet::draw_bbox ( Darknet::Image a,
const Darknet::Box bbox,
int  w,
float  r,
float  g,
float  b 
)

Draw the given bounding box. The line thickness can be specified using w.

Here is the call graph for this function:

◆ draw_box()

void Darknet::draw_box ( Darknet::Image a,
int  x1,
int  y1,
int  x2,
int  y2,
float  r,
float  g,
float  b 
)

Draw a bounding box at the rectangle coordinates within an image, using the specified colour.

Here is the caller graph for this function:

◆ draw_box_bw()

void Darknet::draw_box_bw ( Darknet::Image a,
int  x1,
int  y1,
int  x2,
int  y2,
float  brightness 
)

Draw a bounding box on a black-and-white image.

Here is the caller graph for this function:

◆ draw_box_width()

void Darknet::draw_box_width ( Darknet::Image a,
int  x1,
int  y1,
int  x2,
int  y2,
int  w,
float  r,
float  g,
float  b 
)

Similiar to Darknet::draw_box(), but the line thickness can be specified using w.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_box_width_bw()

void Darknet::draw_box_width_bw ( Darknet::Image a,
int  x1,
int  y1,
int  x2,
int  y2,
int  w,
float  brightness 
)

Similar to Darknet::draw_box_bw(), but the line thickness can be specified using w.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_detections_v3()

void Darknet::draw_detections_v3 ( Darknet::Image im,
const Darknet::Detection dets,
const int  num,
const float  thresh,
const Darknet::VStr names,
const int  classes,
const int  ext_output 
)

This is the function that is called from older Darknet code to draw annotations on an image.

Todo:
replace qsort() mid priority
Todo:
replace qsort() mid priority
Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_weighted_label()

void Darknet::draw_weighted_label ( Darknet::Image a,
int  r,
int  c,
Darknet::Image label,
const float *  rgb,
const float  alpha 
)

Blend the label (actually an image) into the given image.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump() [1/2]

void Darknet::dump ( Darknet::CfgFile cfg)

Dump some information on the given network and layers to a text file for debugging.

Here is the call graph for this function:

◆ dump() [2/2]

void Darknet::dump ( Darknet::Network net,
const Darknet::CfgFile::CommonParms parms 
)

Dump some information on the given network and layers to a text file for debugging.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ embed_image()

void Darknet::embed_image ( const Darknet::Image source,
Darknet::Image dest,
int  dx,
int  dy 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_image()

void Darknet::fill_image ( Darknet::Image m,
float  s 
)
Here is the caller graph for this function:

◆ fix_out_of_bound_values()

void Darknet::fix_out_of_bound_values ( Darknet::NetworkPtr  ptr,
const bool  toggle 
)

Fix out-of-bound values returned by Darknet::predict() for objects near the edges of images.

When set to true, this will ensure that normalized coordinates are between 0.0 and 1.0, and do not extend beyond the borders of the image or video frame.

Default is true.

See also
Darknet::NetworkDetails::fix_out_of_bound_normalized_coordinates
Since
2024-07-25
Here is the caller graph for this function:

◆ flip_image()

void Darknet::flip_image ( Darknet::Image a)

Flip image left <-> right.

Here is the caller graph for this function:

◆ float_to_image()

Darknet::Image Darknet::float_to_image ( int  w,
int  h,
int  c,
float *  data 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ float_to_image_scaled()

Darknet::Image Darknet::float_to_image_scaled ( int  w,
int  h,
int  c,
float *  data 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_in_colour() [1/5]

std::string Darknet::format_in_colour ( const float &  f,
const EColour colour,
const size_t &  len 
)
Here is the call graph for this function:

◆ format_in_colour() [2/5]

std::string Darknet::format_in_colour ( const float &  f,
const size_t &  len,
const bool  inverted = false 
)
Here is the call graph for this function:

◆ format_in_colour() [3/5]

std::string Darknet::format_in_colour ( const int &  i,
const EColour colour,
const size_t &  len 
)
Here is the call graph for this function:

◆ format_in_colour() [4/5]

std::string Darknet::format_in_colour ( const size_t &  st,
const EColour colour,
const size_t &  len 
)
Here is the call graph for this function:

◆ format_in_colour() [5/5]

std::string Darknet::format_in_colour ( const std::string &  str,
const EColour colour,
const int &  len 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_layer_summary()

std::string Darknet::format_layer_summary ( const size_t  idx,
const Darknet::CfgSection section,
const Darknet::Layer l 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_loss()

std::string Darknet::format_loss ( const double &  loss)

Format the loss combined with ANSI colours.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_map_accuracy()

std::string Darknet::format_map_accuracy ( const float &  accuracy)

Format the mAP% accuracy with ANSI colours.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_map_confusion_matrix_values()

std::string Darknet::format_map_confusion_matrix_values ( const int  class_id,
std::string  name,
const float &  average_precision,
const int &  tp,
const int &  fn,
const int &  fp,
const int &  tn,
const float &  accuracy,
const float &  error_rate,
const float &  precision,
const float &  recall,
const float &  specificity,
const float &  false_pos_rate 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_time()

std::string Darknet::format_time ( const double &  seconds_remaining)

The time used by Darknet is a double, generated from what_time_is_it_now().

It is the number of seconds since epoch with milliseconds and microseconds as decimals. This function will format one of these double using the most intelligent unit necessary.

Here is the caller graph for this function:

◆ format_time_remaining()

std::string Darknet::format_time_remaining ( const float &  seconds_remaining)

Format the time remaining using simple-to-read text. The time must be in seconds.

Here is the caller graph for this function:

◆ free_data()

void Darknet::free_data ( data d)

Frees the "data buffer" used to load images.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_image()

void Darknet::free_image ( Darknet::Image im)

Free the image.

Unlike the C version free_image(), the image object is passed by reference, so the pointer to the data will be reset to nullptr once the memory has been freed. When possible, prefer calling Darknet::free_image().

All images must call either free_image() or Darknet::free_image() to avoid memory leaks.

◆ free_neural_network()

void Darknet::free_neural_network ( Darknet::NetworkPtr ptr)

Free the neural network pointer allocated in Darknet::load_neural_network().

Does nothing if the pointer has already been freed. Will reset the pointer to nullptr once the structure has been freed.

You should call this once you are done with Darknet to avoid memory leaks in your application.

Since
2024-07-25
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_activation_from_name()

Darknet::EActivation Darknet::get_activation_from_name ( const std::string &  name)

Convert between names and activation types.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_all_possible_arguments()

const Darknet::SArgsAndParms & Darknet::get_all_possible_arguments ( )

Get all the possible arguments used by Darknet.

This is not what the user specified to main() but all the possible arguments against which we validate the input.

Here is the caller graph for this function:

◆ get_class_colours()

const Darknet::VScalars & Darknet::get_class_colours ( const Darknet::NetworkPtr  ptr)

Get access to the vector of colours assigned to each class when the .names file was loaded.

Since
2024-08-06

◆ get_class_names()

const Darknet::VStr & Darknet::get_class_names ( const Darknet::NetworkPtr  ptr)

Get access to the vector of names read from the .names file when the configuration was loaded.

Since
2024-08-06
Here is the caller graph for this function:

◆ get_color()

float Darknet::get_color ( int  c,
int  x,
int  max 
)

Generate some "random" colour value to use. Mostly used for labels and charts.

Here is the caller graph for this function:

◆ get_command_output()

std::string Darknet::get_command_output ( const std::string &  cmd)
Here is the caller graph for this function:

◆ get_config_filename()

std::filesystem::path Darknet::get_config_filename ( const Darknet::NetworkPtr  ptr)

Get the filename of the configuration file that was used to load this neural network.

Since
2024-08-29
Here is the caller graph for this function:

◆ get_cost_types_from_name()

Darknet::ECostType Darknet::get_cost_types_from_name ( const std::string &  name)

Convert between names and cost types.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_hierarchy_probability()

float Darknet::get_hierarchy_probability ( float *  x,
Darknet::Tree hier,
int  c 
)

◆ get_image_layer()

Darknet::Image Darknet::get_image_layer ( const Darknet::Image m,
int  l 
)

Return a specific channel (eg: R, G, B) from an image.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_IoU_loss_from_name()

Darknet::EIoULoss Darknet::get_IoU_loss_from_name ( const std::string &  name)

Convert between names and IoU loss types.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_layer_type_from_name()

Darknet::ELayerType Darknet::get_layer_type_from_name ( const std::string &  name)

Convert between names and Darknet/YOLO layer types.

Here is the call graph for this function:

◆ get_learning_rate_policy_from_name()

Darknet::ELearningRatePolicy Darknet::get_learning_rate_policy_from_name ( const std::string &  name)

Convert between names and learning rate policies.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_names_filename()

std::filesystem::path Darknet::get_names_filename ( const Darknet::NetworkPtr  ptr)

Get the filename of the names file that was used to load this neural network.

Since
2024-08-29

◆ get_NMS_kind_from_name()

Darknet::ENMSKind Darknet::get_NMS_kind_from_name ( const std::string &  name)

Convert between names and NMS kind.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_weights_filename()

std::filesystem::path Darknet::get_weights_filename ( const Darknet::NetworkPtr  ptr)

Get the filename of the weights file that was used to load this neural network.

Since
2024-08-29
Here is the caller graph for this function:

◆ get_weights_normalization_from_name()

Darknet::EWeightsNormalization Darknet::get_weights_normalization_from_name ( const std::string &  name)

Convert between names and weights normalization.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_weights_type_from_name()

Darknet::EWeightsType Darknet::get_weights_type_from_name ( const std::string &  name)

Convert between names and weights types.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_yolo_point_types_from_name()

Darknet::EYoloPoint Darknet::get_yolo_point_types_from_name ( const std::string &  name)

Convert between names and YOLO point types.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ grayscale_image()

Darknet::Image Darknet::grayscale_image ( const Darknet::Image im)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ hierarchy_predictions()

void Darknet::hierarchy_predictions ( float *  predictions,
int  n,
Darknet::Tree hier,
int  only_leaves 
)

◆ hierarchy_top_prediction()

int Darknet::hierarchy_top_prediction ( float *  predictions,
Darknet::Tree hier,
float  thresh,
int  stride 
)

◆ hsv_to_rgb()

void Darknet::hsv_to_rgb ( Darknet::Image im)
Todo:
COLOR - cannot do HSV if channels > 3
Here is the call graph for this function:
Here is the caller graph for this function:

◆ image_as_debug_string()

std::string Darknet::image_as_debug_string ( const Darknet::Image m)

Convert the image to a debug string to display the data pointer values.

For example, a tiny 5x3 image might look like this:

Darknet::Image: 5x3x3, data=0x5858cb1514e0
R 0000: 1.00 1.00 1.00 1.00 1.00
R 0005: 1.00 1.00 1.00 0.13 0.13
R 0010: 1.00 1.00 1.00 0.13 0.13
G 0015: 0.25 0.25 0.25 0.25 0.25
G 0020: 0.25 0.25 0.25 0.13 0.13
G 0025: 0.25 0.25 0.25 0.13 0.13
B 0030: 0.50 0.50 0.50 0.50 0.50
B 0035: 0.50 0.50 0.50 1.00 1.00
B 0040: 0.50 0.50 0.50 1.00 1.00
DarknetImage Image
Convenient simple types used in the Darknet/YOLO C++ API.
Definition darknet.hpp:47
Definition darknet_internal.hpp:234

◆ image_distance()

Darknet::Image Darknet::image_distance ( Darknet::Image a,
Darknet::Image b 
)

Create a single-channel image for ...?

Note
Function currently seems to be unused.
Here is the call graph for this function:

◆ image_loading_loop()

void Darknet::image_loading_loop ( const int  idx,
load_args  args 
)

Run the permanent thread image loading loop.

This is started by Darknet::run_image_loading_control_thread(), and is stopped by Darknet::stop_image_loading_threads().

This was originally called run_thread_loop() and used pthread, but has since been re-written to use C++11.

Since
2024-04-02
Todo:
get rid of this busy-loop
Here is the call graph for this function:
Here is the caller graph for this function:

◆ image_to_mat()

cv::Mat Darknet::image_to_mat ( const Darknet::Image img)

Convert the usual Darknet::Image format to OpenCV cv::Mat.

The mat object will be in RGB format, not BGR.

See also
cv::COLOR_RGB2BGR
Darknet::mat_to_image()
Here is the caller graph for this function:

◆ in_colour() [1/5]

std::string Darknet::in_colour ( const EColour  colour)

◆ in_colour() [2/5]

std::string Darknet::in_colour ( const EColour  colour,
const double  d 
)
Here is the call graph for this function:

◆ in_colour() [3/5]

std::string Darknet::in_colour ( const EColour  colour,
const float  f 
)
Here is the call graph for this function:

◆ in_colour() [4/5]

std::string Darknet::in_colour ( const EColour  colour,
const int  i 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ in_colour() [5/5]

std::string Darknet::in_colour ( const EColour  colour,
const std::string &  msg 
)

◆ initialize_new_charts()

void Darknet::initialize_new_charts ( const Darknet::Network net)

Setup the new C++ charts. This is called once just prior to starting training.

See also
Chart
Here is the caller graph for this function:

◆ iou()

float Darknet::iou ( const cv::Rect &  lhs,
const cv::Rect &  rhs 
)

Calculate intersection-over-union given 2 OpenCV rectangles.

Will return a value between 0.0f and 1.0f.

See also
box_iou()
Since
2024-09-07
Here is the caller graph for this function:

◆ letterbox_image()

Darknet::Image Darknet::letterbox_image ( const Darknet::Image im,
int  w,
int  h 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ letterbox_image_into()

void Darknet::letterbox_image_into ( const Darknet::Image im,
int  w,
int  h,
Darknet::Image boxed 
)
Here is the call graph for this function:

◆ load_image()

Darknet::Image Darknet::load_image ( const char *  filename,
int  desired_width = 0,
int  desired_height = 0,
int  channels = 0 
)

Load the given image.

If both desired_width and desired_height have been set, then the image will be resized to match those dimensions. Otherwise, specify 0 (zero) to leave the image dimensions unchanged.

Unless single channel greyscale has been requested, the image returned will be in RGB format, not BGR.

Note
Remember to call Darknet::free_image() once an image is no longer needed.
See also
Darknet::image_to_mat()
Darknet::mat_to_image()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_names()

void Darknet::load_names ( Darknet::NetworkPtr  net,
const std::filesystem::path &  filename 
)

Load all of the names from a text .names file.

The file must exist, and must have the same number of classes as the network.

This will automatically be called if you use Darknet::load_neural_network() from the new recommended V3 API.

You may need to manually call it if you use the old load_network() or load_network_custom() from the original C API. If you don't call it, some default placeholders will be used instead, such as "#0", "#1", etc.

Since
2024-08-06
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_neural_network() [1/2]

Darknet::NetworkPtr Darknet::load_neural_network ( const std::filesystem::path &  cfg_filename,
const std::filesystem::path &  names_filename,
const std::filesystem::path &  weights_filename 
)

Load a neural network (.cfg) and the corresponding weights file.

Remember to call Darknet::free_neural_network() once the neural network is no longer needed.

Since
2024-07-24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_neural_network() [2/2]

Darknet::NetworkPtr Darknet::load_neural_network ( Darknet::Parms parms)

Load a neural network.

Remember to call Darknet::free_neural_network() once the neural network is no longer needed.

See also
Darknet::parse_arguments()
Since
2024-07-29
Here is the call graph for this function:

◆ load_single_image_data()

void Darknet::load_single_image_data ( load_args  args)

Load the given image data as described by the load_args parameter.

This is typically used to load images on a secondary thread, such as image_loading_loop().

Note
The name is misleading. While I initially thought a single image at a time was being loaded, the args.n argument is used to describe the number of images that will be loaded together. This will typically be the batch size divided by the number of worker threads (default is 6 threads).

This was originally called load_thread().

Since
2024-04-02
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lowercase() [1/2]

std::string Darknet::lowercase ( const std::string &  str)

Simple conversion of the string to lowercase.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lowercase() [2/2]

std::string & Darknet::lowercase ( std::string &  str)

Simple conversion of the string to lowercase.

◆ make_attention_image()

Darknet::Image Darknet::make_attention_image ( int  img_size,
float *  original_delta_cpu,
float *  original_input_cpu,
int  w,
int  h,
int  c,
float  alpha 
)

The resulting image takes ownership of original_delta_cpu.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_image_red()

void Darknet::make_image_red ( Darknet::Image im)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_random_image()

Darknet::Image Darknet::make_random_image ( int  w,
int  h,
int  c 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mat_to_image()

Darknet::Image Darknet::mat_to_image ( const cv::Mat &  mat)

Convert an OpenCV cv::Mat object to Darknet::Image.

The cv::Mat is expected to already have been converted from BGR to RGB. The result Darknet::Image floats will be normalized between 0.0 and 1.0. Remember to call Darknet::free_image() when done.

See also
Darknet::bgr_mat_to_rgb_image()
Darknet::rgb_image_to_bgr_mat()
Darknet::image_to_mat()
cv::COLOR_BGR2RGB
Here is the call graph for this function:
Here is the caller graph for this function:

◆ network_dimensions()

void Darknet::network_dimensions ( Darknet::NetworkPtr ptr,
int &  w,
int &  h,
int &  c 
)

Get the network dimensions (width, height, channels).

Since
2024-07-25
Here is the caller graph for this function:

◆ normalize_image()

void Darknet::normalize_image ( Darknet::Image p)
Here is the caller graph for this function:

◆ normalize_image2()

void Darknet::normalize_image2 ( Darknet::Image p)
Note
Function currently seems to be unused.

◆ operator<<() [1/2]

std::ostream & Darknet::operator<< ( std::ostream &  os,
const Darknet::Prediction pred 
)

Display some information about this specific prediction.

Use like this:

std::cout << prediction << std::endl;
Since
2024-08-06
Here is the caller graph for this function:

◆ operator<<() [2/2]

std::ostream & Darknet::operator<< ( std::ostream &  os,
const Darknet::Predictions preds 
)

Display some information about all the predictions.

Use like this:

const auto results = Darknet::predict(ptr, mat);
std::cout << results << std::endl;
Predictions predict(const Darknet::NetworkPtr ptr, const cv::Mat &mat)
Get Darknet to look at the given image or video frame and return all predictions.
Definition darknet.cpp:1120

Output would look similar to this:

prediction results: 5
-> 1/5: #4 prob=0.999923 x=423 y=35 w=206 h=221 entries=1
-> 2/5: #3 prob=0.999828 x=285 y=85 w=138 h=135 entries=1
-> 3/5: #2 prob=0.988380 x=527 y=128 w=31 h=28 entries=1
-> 4/5: #1 prob=0.996240 x=498 y=187 w=26 h=29 entries=1
-> 5/5: #0 prob=0.994430 x=46 y=127 w=43 h=40 entries=1
Since
2024-08-06
Here is the call graph for this function:

◆ parse_arguments() [1/2]

Darknet::Parms Darknet::parse_arguments ( const Darknet::VStr v)

Similar to the other Darknet::parse_arguments(), but uses a vector of strings as input.

Output can be used with Darknet::load_neural_network().

Note
See the full description in the other Darknet::parse_arguments().
Since
2024-07-29
Todo:
confirm that this works just as well on ARM
Here is the call graph for this function:

◆ parse_arguments() [2/2]

Darknet::Parms Darknet::parse_arguments ( int  argc,
char *  argv[] 
)

Parse common Darknet command-line parameters with the values from argc and argv in main().

Output can be used with Darknet::load_neural_network().

This function will attempt to identify the following:

  • .cfg files (Darknet configuration)
  • .names files (Darknet classes)
  • .weights files (Darknet weights)
  • all other files or subdirectories
  • any other non-file parameters

If the .names or .weights files were not found, then attempts will be made to locate a suitable file to use based on the given .cfg file. This means as long as the 3 Darknet files are named in a similar way, there is no need to specify all 3 files. The .cfg file is enough to find the neural network.

In addition, if no Darknet files were found but a "stem" was specified, then this stem will be used to attempt and find all the necessary files. For example, if the following files exist:

  • animals.cfg
  • animals.names
  • animals_best.weights

These files will be found if this function is called with the parameter "anim", since all the files begin with that stem.

Given the example files listed above, the following commands are interpreted the exact same way:

darknet_01_inference_images animals.cfg animals.names animals_best.weights dog.jpg
darknet_01_inference_images animals.names dog.jpg animals_best.weights animals.cfg
darknet_01_inference_images animals.cfg animals.names dog.jpg
darknet_01_inference_images animals.cfg dog.jpg
darknet_01_inference_images ani dog.jpg
Since
2024-07-29
Here is the call graph for this function:
Here is the caller graph for this function:

◆ predict() [1/3]

Darknet::Predictions Darknet::predict ( const Darknet::NetworkPtr  ptr,
const cv::Mat &  mat 
)

Get Darknet to look at the given image or video frame and return all predictions.

This is similar to the other Darknet::predict() that takes a Darknet::Image object as input.

OpenCV cv::Mat images (and video frames) are typically stored in BGR format, not RGB. This function expects the images to be in the usual BGR format for 3-channel networks.

Since
2024-07-24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ predict() [2/3]

Darknet::Predictions Darknet::predict ( const Darknet::NetworkPtr  ptr,
const std::filesystem::path &  image_filename 
)

Get Darknet to look at the given image and return all predictions.

The image must be in a format supported by OpenCV, such as JPG or PNG.

Since
2024-07-25
Here is the call graph for this function:

◆ predict() [3/3]

Darknet::Predictions Darknet::predict ( const Darknet::NetworkPtr  ptr,
Darknet::Image img,
cv::Size  original_image_size = cv::Size(0, 0) 
)

Get Darknet to look at the given image or video frame and return all predictions.

The provided image must be in Darknet's RGB image format. This is similar to the other predict() that takes a cv::Mat object as input.

Note
If the original image size is known, it is best to pass it in so the bounding boxes can be scaled to those dimensions.
Since
2024-08-02

todo pass net by ref or pointer, not copy constructor!

Here is the call graph for this function:

◆ predict_and_annotate()

Darknet::Predictions Darknet::predict_and_annotate ( const Darknet::NetworkPtr  ptr,
cv::Mat  mat 
)

Combination of Darknet::predict() and Darknet::annotate().

Remember to clone mat prior to calling predict_and_annotate() if you need to keep a copy of the original image.

Since
2024-07-30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ quantize_image()

void Darknet::quantize_image ( Darknet::Image im)
Note
Function currently seems to be unused.

◆ random_augment_image()

Darknet::Image Darknet::random_augment_image ( const Darknet::Image im,
const float  angle,
float  aspect,
const int  low,
const int  high,
const int  size 
)

Apply a bunch of random augmentations.

Note
Function currently seems to be unused.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ random_crop_image()

Darknet::Image Darknet::random_crop_image ( const Darknet::Image im,
const int  w,
const int  h 
)

Similar to Darknet::crop_image() but the dx and dy are random values.

Here is the call graph for this function:

◆ random_distort_image()

void Darknet::random_distort_image ( Darknet::Image im,
float  hue,
float  saturation,
float  exposure 
)
Todo:
COLOR - HSV no beuno
Here is the call graph for this function:

◆ read_tree()

Darknet::Tree * Darknet::read_tree ( const char *  filename)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize_image()

Darknet::Image Darknet::resize_image ( const Darknet::Image im,
int  w,
int  h 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize_keeping_aspect_ratio()

cv::Mat Darknet::resize_keeping_aspect_ratio ( cv::Mat &  mat,
cv::Size  desired_size,
const cv::InterpolationFlags  method = cv::InterpolationFlags::INTER_NEAREST 
)

Resize the image as close as we can to the given size, but keep the aspect ratio the same as the original image.

This method will modify the image that is passed in, so clone it beforehand if you need a copy of the original.

Several notes in regards to the resize method:

  • cv::InterpolationFlags::INTER_NEAREST is the fastest resize method, but the quality is poor.
  • cv::InterpolationFlags::INTER_AREA is good when shrinking an image.
  • cv::InterpolationFlags::INTER_CUBIC is good when growing an image
  • cv::InterpolationFlags::INTER_LINEAR is similar to INTER_CUBIC, but faster
Since
2024-09-05
Here is the caller graph for this function:

◆ resize_max()

Darknet::Image Darknet::resize_max ( const Darknet::Image im,
int  max 
)
Note
Function currently seems to be unused.
Here is the call graph for this function:

◆ resize_min()

Darknet::Image Darknet::resize_min ( const Darknet::Image im,
int  min 
)
Note
Function currently seems to be unused.
Here is the call graph for this function:

◆ rgb_image_to_bgr_mat()

cv::Mat Darknet::rgb_image_to_bgr_mat ( const Darknet::Image img)

Similar to the original image_to_mat(), but with 2 differences:

  • the output image is in the "natural" OpenCV BGR format,
  • this function uses very efficient OpenCV techniques to convert the Darknet::Image to cv::Mat which makes it much faster.
See also
Darknet::bgr_mat_to_rgb_image()
Darknet::image_to_mat()
Darknet::mat_to_image()
Since
2024-08-23

◆ rgb_to_hsv()

void Darknet::rgb_to_hsv ( Darknet::Image im)
Note
Function currently seems to be unused.
Todo:
COLOR - cannot do HSV if channels > 3
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rgbgr_image()

void Darknet::rgbgr_image ( Darknet::Image im)

Do the equivalent of OpenCV's cv::COLOR_BGR2RGB to swap red and blue floats.

Here is the caller graph for this function:

◆ rotate_crop_image()

Darknet::Image Darknet::rotate_crop_image ( const Darknet::Image im,
float  rad,
float  s,
int  w,
int  h,
float  dx,
float  dy,
float  aspect 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate_image()

Darknet::Image Darknet::rotate_image ( const Darknet::Image im,
float  rad 
)

Rotate image.

Note
Function currently seems to be unused.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rotate_image_cw()

void Darknet::rotate_image_cw ( Darknet::Image im,
int  times 
)

Rotate image clockwise?

Note
Function currently seems to be unused.

◆ run_image_loading_control_thread()

void Darknet::run_image_loading_control_thread ( load_args  args)

This runs as a std::thread.

It is started by the main thread during training and ensures the data-loading threads are running. This starts the thread that controls all of the permanent image loading threads.

This was originally called load_threads() and used pthread, but has since been re-written to use C++11.

See also
stop_image_loading_threads()
Since
2024-03-31
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_image()

void Darknet::save_image ( const Darknet::Image p,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_image_jpg()

void Darknet::save_image_jpg ( const Darknet::Image im,
const char *  name 
)
Todo:
merge with save_mat_jpg()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_image_png()

void Darknet::save_image_png ( const Darknet::Image im,
const char *  name 
)
Todo:
merge with save_mat_png()
Here is the call graph for this function:

◆ scale_image()

void Darknet::scale_image ( Darknet::Image m,
const float  s 
)

Scale the RGB values in an image by the given amount.

Here is the caller graph for this function:

◆ scale_image_channel()

void Darknet::scale_image_channel ( Darknet::Image im,
int  c,
float  v 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_annotation_draw_bb()

void Darknet::set_annotation_draw_bb ( Darknet::NetworkPtr  ptr,
const bool  toggle 
)

Determines if bounding boxes are drawn when calling either Darknet::annotate() or Darknet::predict_and_annotate().

The default is true.

Since
2024-07-30

◆ set_annotation_draw_label()

void Darknet::set_annotation_draw_label ( Darknet::NetworkPtr  ptr,
const bool  toggle 
)

Determines if text labels are drawn above the bounding boxes when calling either Darknet::annotate() or Darknet::predict_and_annotate().

The default is true.

Since
2024-07-30

◆ set_annotation_font()

void Darknet::set_annotation_font ( Darknet::NetworkPtr  ptr,
const cv::LineTypes  line_type,
const cv::HersheyFonts  font_face,
const int  font_thickness,
const double  font_scale 
)

Set the font characteristics to use when drawing the bounding boxes and labels in either Darknet::annotate() or Darknet::predict_and_annotate().

Parameters
[in]ptrNeural network pointer obtained from Darknet::load_neural_network().
[in]line_typeshould be cv::LineTypes::LINE_4, cv::LineTypes::LINE_8, or cv::LineTypes::CV_LINE_AA. LINE_4 is the fastest but lower quality, while LINE_AA (anti-alias) is the slowest with highest quality. Default is LINE_4. Also see set_annotation_line_type() which modifies the same setting.
[in]font_faceis the OpenCV built-in font to use. Default is cv::HersheyFonts::FONT_HERSHEY_PLAIN.
[in]font_thicknessdetermines how thick the lines are drawn when the text is rendered. Default is 1.
[in]font_scaledetermines how large or small the text is rendered. For example, this could be set to 0.5 for extremely small text, and 1.75 for large text. Default is 1.0.
See also
Darknet::NetworkDetails::cv_line_type
Darknet::NetworkDetails::cv_font_face
Darknet::NetworkDetails::cv_font_thickness
Darknet::NetworkDetails::cv_font_scale
Since
2024-07-30
Here is the caller graph for this function:

◆ set_annotation_line_type()

void Darknet::set_annotation_line_type ( Darknet::NetworkPtr  ptr,
const cv::LineTypes  line_type 
)

The OpenCV line type can impact performance.

Anti-aliased lines are expensive to draw. Possible options for line_type is cv::LineTypes::LINE_4, cv::LineTypes::LINE_8, or cv::LineTypes::CV_LINE_AA. LINE_4 is the fastest but lower quality, while LINE_AA (anti-alias) is the slowest with highest quality. Default is LINE_4.

This setting can also be modified with set_annotation_font().

Since
2024-09-03
Here is the caller graph for this function:

◆ set_class_colours()

const Darknet::VScalars & Darknet::set_class_colours ( Darknet::NetworkPtr  ptr,
const Darknet::VScalars colours 
)

Set the colours to use when drawing annotations.

The colours are in OpenCV's usual BGR format, not RGB. So pure red for example is "{0, 0, 255}" while pure blue would be "{255, 0, 0}". The middle value is green.

Returns
the final colours used, same as if get_class_colours() had been called.
Since
2024-09-22

◆ set_default_keypoints_files()

void Darknet::set_default_keypoints_files ( Darknet::Parms parms)

Add the default Darknet Keypoints neural network files to the given parms.

If parms doesn't seem to reference neural network files, then this function will automatically add the names "Darknet-Keypoints.cfg" and "Darknet-Keypoints.weights".

Since
2024-09-20
Here is the caller graph for this function:

◆ set_detection_threshold()

void Darknet::set_detection_threshold ( Darknet::NetworkPtr  ptr,
float  threshold 
)

Detection threshold to use when Darknet::predict() is called.

Default is 0.25.

See also
Darknet::NetworkDetails::detection_threshold
Since
2024-07-24
Here is the caller graph for this function:

◆ set_gpu_index()

void Darknet::set_gpu_index ( int  idx)

Set the GPU index to use.

This may be set to -1 to indicate no GPU has been selected, or may be set to a 0-based GPU. In normal situations, this must be set prior to calling Darknet::load_neural_network() where the GPU is usually initialized.

If set to -1 and Darknet was compiled with support for CUDA GPUs, then the GPU index will default to 0 when Darknet::load_neural_network() is called. If no CUDA GPU is detected, then the GPU index will be set to -1 and the CPU will be used instead.

Default is -1.

Since
2024-07-25
Here is the caller graph for this function:

◆ set_non_maximal_suppression_threshold()

void Darknet::set_non_maximal_suppression_threshold ( Darknet::NetworkPtr  ptr,
float  threshold 
)

Non-maximal suppression threshold to use when Darknet::predict() is called.

Default is 0.45.

See also
Darknet::NetworkDetails::non_maximal_suppression_threshold
Since
2024-07-24
Here is the caller graph for this function:

◆ set_rounded_corner_bounding_boxes()

void Darknet::set_rounded_corner_bounding_boxes ( Darknet::NetworkPtr  ptr,
const bool  toggle,
const float  roundness 
)

This determines if annotations are drawn as circles or rounded rectangles in either Darknet::annotate() or Darknet::predict_and_annotate().

The defaul is to use square – not rounded – bounding boxes.

Parameters
[in]ptrNeural network pointer obtained from Darknet::load_neural_network().
[in]toggleDetermines if rounded corners are used. The default is false in which case normal "square" bounding boxes are used.
[in]roundnessDetermines how large the rounded corners will appear. The value must be between 0.0 (small rounded corners) and 1.0 (large rounded corners). At the extreme of 1.0, the bounding box will appear as a circle. The default is 0.5, but will only take effect if rounded is also set to true.
Since
2024-07-30
Here is the caller graph for this function:

◆ set_trace()

void Darknet::set_trace ( const bool  flag)

Set the Darknet::CfgAndState::is_trace flag.

When enabled, debug information will be sent to STDOUT. Default value is false.

Note
Enabling trace will also enable verbose.
See also
Darknet::set_verbose()
darknet_set_trace()
Since
2024-07-14
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_verbose()

void Darknet::set_verbose ( const bool  flag)

Set the Darknet::CfgAndState::is_verbose flag.

When enabled, extra information will be sent to STDOUT. Default value is false.

Note
Disabling verbose will also disable trace.
See also
Darknet::set_trace()
darknet_set_verbose()
Since
2024-07-14
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_image()

void Darknet::show_image ( const Darknet::Image p,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_image_collapsed()

void Darknet::show_image_collapsed ( const Darknet::Image p,
const char *  name 
)
Here is the call graph for this function:

◆ show_image_layers()

void Darknet::show_image_layers ( const Darknet::Image p,
const char *  name 
)
Here is the call graph for this function:

◆ show_images()

void Darknet::show_images ( Darknet::Image ims,
int  n,
const char *  window 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ show_version_info()

void Darknet::show_version_info ( )

Display a few lines of text with some version information.

Since
2024-08-29
Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipped_classes() [1/2]

Darknet::SInt Darknet::skipped_classes ( const Darknet::NetworkPtr  ptr)

Return the set of classes which Darknet must ignore.

Default set is empty.

See also
Darknet::skipped_classes()
Darknet::clear_skipped_classes()
Darknet::add_skipped_class()
Darknet::del_skipped_class()
Since
2024-10-07

◆ skipped_classes() [2/2]

Darknet::SInt Darknet::skipped_classes ( Darknet::NetworkPtr  ptr,
const SInt classes_to_skip 
)

Set the classes which Darknet must ignore, completely over-writing all previous values.

If you'd rather add a single class at a time, call add_skipped_class() which can be called repeatedly without overwriting previous settings.

See also
Darknet::skipped_classes()
Darknet::clear_skipped_classes()
Darknet::add_skipped_class()
Darknet::del_skipped_class()
Since
2024-10-07

◆ stop_image_loading_threads()

void Darknet::stop_image_loading_threads ( )

Stop and join the image loading threads started in Darknet::run_image_loading_control_thread().

This was originally called free_load_threads() and used pthread, but has since been re-written to use C++11.

Since
2024-04-02
Here is the caller graph for this function:

◆ test_resize()

void Darknet::test_resize ( char *  filename)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ text_to_simple_label()

std::string Darknet::text_to_simple_label ( std::string  txt)

Convert the given text to plain alphanumeric ASCII string.

Remove whitespace, keep just alphanumeric and underscore. Good to use as a base for a filename.

Here is the caller graph for this function:

◆ threshold_image()

Darknet::Image Darknet::threshold_image ( const Darknet::Image im,
float  thresh 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string() [1/9]

std::string Darknet::to_string ( const EActivation  activation)

Convert between names and activation types.

Here is the call graph for this function:

◆ to_string() [2/9]

std::string Darknet::to_string ( const ECostType  type)

Convert between names and cost types.

Here is the call graph for this function:

◆ to_string() [3/9]

std::string Darknet::to_string ( const EIoULoss  loss)

Convert between names and IoU loss types.

Here is the call graph for this function:

◆ to_string() [4/9]

std::string Darknet::to_string ( const ELayerType  type)

Convert between names and Darknet/YOLO layer types.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string() [5/9]

std::string Darknet::to_string ( const ELearningRatePolicy  policy)

Convert between names and learning rate policies.

Here is the call graph for this function:

◆ to_string() [6/9]

std::string Darknet::to_string ( const ENMSKind  nms_kind)

Convert between names and NMS kind.

Here is the call graph for this function:

◆ to_string() [7/9]

std::string Darknet::to_string ( const EWeightsNormalization  normalization)

Convert between names and weights normalization.

Here is the call graph for this function:

◆ to_string() [8/9]

std::string Darknet::to_string ( const EWeightsType  type)

Convert between names and weights types.

Here is the call graph for this function:

◆ to_string() [9/9]

std::string Darknet::to_string ( const EYoloPoint  type)

Convert between names and YOLO point types.

Here is the call graph for this function:

◆ translate_image()

void Darknet::translate_image ( Darknet::Image  m,
float  s 
)

◆ trim() [1/2]

std::string Darknet::trim ( const std::string &  str)

Trim leading and trailing whitespace from the given string.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trim() [2/2]

std::string & Darknet::trim ( std::string &  str)

Trim leading and trailing whitespace from the given string.

◆ update_accuracy_in_new_charts()

void Darknet::update_accuracy_in_new_charts ( const int  class_index,
const float  accuracy 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_loss_in_new_charts()

void Darknet::update_loss_in_new_charts ( const int  current_iteration,
const float  loss,
const float  seconds_remaining,
const bool  dont_show 
)

Update the new C++ charts with the given loss and mAP% accuracy value. This is called at every iteration.

See also
Chart
Here is the call graph for this function:
Here is the caller graph for this function: