Darknet/YOLO v3.0-149-gb11c9d5
Object Detection Framework
 
Loading...
Searching...
No Matches
darknet.hpp File Reference

Include this file to get access to the new Darknet V3 C++ API. More...

Include dependency graph for darknet.hpp:
This graph shows which files directly or indirectly include this file:

Classes

struct  Darknet::Parm
 Structure returned by Darknet::parse_arguments(). More...
 
struct  Darknet::Prediction
 A much-simplified version of the old API structure DarknetDetection. More...
 

Namespaces

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

Typedefs

using Darknet::Parms = std::vector< Parm >
 Structure returned by Darknet::parse_arguments().
 
using Darknet::Predictions = std::vector< Prediction >
 Each image or video frame may contain many predictions.
 
using Darknet::Probabilities = std::map< int, float >
 The likelyhood of a specific object class having been predicted.
 
using Darknet::Box = DarknetBox
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::Detection = DarknetDetection
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::Image = DarknetImage
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::MStr = std::map< std::string, std::string >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::MStrInt = std::map< std::string, int >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::NetworkPtr = DarknetNetworkPtr
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::SInt = std::set< int >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::SStr = std::set< std::string >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::VFloat = std::vector< float >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::VInt = std::vector< int >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::VScalars = std::vector< cv::Scalar >
 Convenient simple types used in the Darknet/YOLO C++ API.
 
using Darknet::VStr = std::vector< std::string >
 Convenient simple types used in the Darknet/YOLO C++ API.
 

Enumerations

enum class  Darknet::EParmType {
  Darknet::kUnknown ,
  Darknet::kCfgFilename ,
  Darknet::kNamesFilename ,
  Darknet::kWeightsFilename ,
  Darknet::kDirectory ,
  Darknet::kFilename ,
  Darknet::kOther
}
 When parsing command-line parameters, each parameter is assigned a "type". More...
 

Functions

cv::Mat Darknet::annotate (const Darknet::NetworkPtr ptr, const Predictions &predictions, cv::Mat mat)
 Annotate the given image using the predictions from Darknet::predict().
 
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.
 
void Darknet::free_neural_network (Darknet::NetworkPtr &ptr)
 Free the neural network pointer allocated in Darknet::load_neural_network().
 
const Darknet::VScalarsDarknet::get_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::VStrDarknet::get_class_names (const Darknet::NetworkPtr ptr)
 Get access to the vector of names read from the .names file when the configuration was loaded.
 
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.
 
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.
 
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.
 
float Darknet::iou (const cv::Rect &lhs, const cv::Rect &rhs)
 Calculate intersection-over-union given 2 OpenCV rectangles.
 
Darknet::NetworkPtr Darknet::load_neural_network (const Darknet::Parms &parms)
 Load a neural network.
 
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.
 
void Darknet::network_dimensions (Darknet::NetworkPtr &ptr, int &w, int &h, int &c)
 Get the network dimensions (width, height, channels).
 
std::ostream & Darknet::operator<< (std::ostream &os, const Darknet::Prediction &pred)
 Display some information about this specific prediction.
 
std::ostream & Darknet::operator<< (std::ostream &os, const Darknet::Predictions &preds)
 Display some information about all the predictions.
 
Darknet::Parms Darknet::parse_arguments (const Darknet::VStr &v)
 Similar to the other Darknet::parse_arguments(), but uses a vector of strings as input.
 
Darknet::Parms Darknet::parse_arguments (int argc, char *argv[])
 Parse common Darknet command-line parameters with the values from argc and argv in main().
 
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.
 
Predictions Darknet::predict (const Darknet::NetworkPtr ptr, cv::Mat mat)
 Get Darknet to look at the given image or video frame and return all predictions.
 
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.
 
Predictions Darknet::predict_and_annotate (const Darknet::NetworkPtr ptr, cv::Mat mat)
 Combination of Darknet::predict() and Darknet::annotate().
 
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.
 
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().
 
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().
 
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().
 
void Darknet::set_annotation_line_type (Darknet::NetworkPtr ptr, const cv::LineTypes line_type)
 The OpenCV line type can impact performance.
 
void Darknet::set_detection_threshold (Darknet::NetworkPtr ptr, float threshold)
 Detection threshold to use when Darknet::predict() is called.
 
void Darknet::set_gpu_index (int idx)
 Set the GPU index to use.
 
void Darknet::set_non_maximal_suppression_threshold (Darknet::NetworkPtr ptr, float threshold)
 Non-maximal suppression threshold to use when Darknet::predict() is called.
 
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().
 
void Darknet::set_trace (const bool flag)
 Set the Darknet::CfgAndState::is_trace flag.
 
void Darknet::set_verbose (const bool flag)
 Set the Darknet::CfgAndState::is_verbose flag.
 
void Darknet::show_version_info ()
 Display a few lines of text with some version information.
 

Detailed Description

Include this file to get access to the new Darknet V3 C++ API.

https://darknetcv.ai/api/api.html