Visual Servoing Platform  version 3.6.1 under development (2023-11-16)
vpDetectorDNNOpenCV::NetConfig Struct Reference

#include <visp3/detection/vpDetectorDNNOpenCV.h>

Public Member Functions

 NetConfig ()
 
 NetConfig (const NetConfig &config)
 
 NetConfig (float confThresh, const float &nmsThresh, const std::vector< std::string > &classNames, const cv::Size &dnnInputSize, const double &filterSizeRatio=0., const cv::Scalar &mean=cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor=2./255., const bool &swapRB=true, const DNNResultsParsingType &parsingType=vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename="", const std::string &configFilename="", const std::string &framework="")
 
 NetConfig (const float &confThresh, const float &nmsThresh, const std::string &classNamesFile, const cv::Size &dnnInputSize, const double &filterSizeRatio=0., const cv::Scalar &mean=cv::Scalar(127.5, 127.5, 127.5), const double &scaleFactor=2./255., const bool &swapRB=true, const DNNResultsParsingType &parsingType=vpDetectorDNNOpenCV::USER_SPECIFIED, const std::string &modelFilename="", const std::string &configFilename="", const std::string &framework="")
 
std::string toString () const
 
NetConfigoperator= (const NetConfig &config)
 

Static Public Member Functions

static std::vector< std::string > parseClassNamesFile (const std::string &filename)
 

Public Attributes

friend vpDetectorDNNOpenCV
 

Friends

void from_json (const json &j, NetConfig &config)
 
void to_json (json &j, const NetConfig &config)
 
std::ostream & operator<< (std::ostream &os, const NetConfig &config)
 

Detailed Description

Structure containing some information required for the configuration of a vpDetectorDNNOpenCV object.

Examples
tutorial-dnn-object-detection-live.cpp, and tutorial-megapose-live-single-object-tracking.cpp.

Definition at line 175 of file vpDetectorDNNOpenCV.h.

Constructor & Destructor Documentation

◆ NetConfig() [1/4]

vpDetectorDNNOpenCV::NetConfig::NetConfig ( )
inline

Default constructor of the structure vpDetectorDNNOpenCV::NetConfig , required for JSON serialization/deserialization.

Definition at line 317 of file vpDetectorDNNOpenCV.h.

◆ NetConfig() [2/4]

vpDetectorDNNOpenCV::NetConfig::NetConfig ( const NetConfig config)
inline

Definition at line 334 of file vpDetectorDNNOpenCV.h.

◆ NetConfig() [3/4]

vpDetectorDNNOpenCV::NetConfig::NetConfig ( float  confThresh,
const float &  nmsThresh,
const std::vector< std::string > &  classNames,
const cv::Size &  dnnInputSize,
const double &  filterSizeRatio = 0.,
const cv::Scalar &  mean = cv::Scalar(127.5, 127.5, 127.5),
const double &  scaleFactor = 2. / 255.,
const bool &  swapRB = true,
const DNNResultsParsingType parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED,
const std::string &  modelFilename = "",
const std::string &  configFilename = "",
const std::string &  framework = "" 
)
inline

Construct a new Net Config object.

Parameters
confThreshThe confidence threshold to keep a detection.
nmsThreshThe Non-Maximum Suppression threshold to merge overlapping detections.
classNamesA vector containing the list of classes the DNN can detect.
dnnInputSizeThe size of the input that the DNN is expecting.
filterSizeRatioThe threshold for the size filter that the user can chose to activate or not (see vpDetectorDNNOpenCV::filterDetectionSingleClassInput and vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information).
meanThe mean value we must deduce to each color channel of the image.
scaleFactorThe scale factor that will be multiplied to each color channel of the image.
swapRBIf true, will swap the red and blue channel of the input image.
parsingTypeThe type of parsing method to use to interpret the DNN raw results.
modelFilenameThe path towards the DNN weights.
configFilenameThe path towards the additional DNN configuration file potentially needed.
frameworkThe type of framework used to store the weights of the DNN.

Definition at line 368 of file vpDetectorDNNOpenCV.h.

◆ NetConfig() [4/4]

vpDetectorDNNOpenCV::NetConfig::NetConfig ( const float &  confThresh,
const float &  nmsThresh,
const std::string &  classNamesFile,
const cv::Size &  dnnInputSize,
const double &  filterSizeRatio = 0.,
const cv::Scalar &  mean = cv::Scalar(127.5, 127.5, 127.5),
const double &  scaleFactor = 2. / 255.,
const bool &  swapRB = true,
const DNNResultsParsingType parsingType = vpDetectorDNNOpenCV::USER_SPECIFIED,
const std::string &  modelFilename = "",
const std::string &  configFilename = "",
const std::string &  framework = "" 
)
inline

Construct a new Net Config object.

Parameters
confThreshThe confidence threshold to keep a detection.
nmsThreshThe Non-Maximum Suppression threshold to merge overlapping detections.
classNamesFileThe path towards the file containing the classes names, written as a YAML string array or one class name by line.
dnnInputSizeThe size of the input that the DNN is expecting.
filterSizeRatioThe threshold for the size filter that the user can chose to activate or not (see vpDetectorDNNOpenCV::filterDetectionSingleClassInput and vpDetectorDNNOpenCV::filterDetectionMultiClassInput methods for more information).
meanThe mean value we must deduce to each color channel of the image.
scaleFactorThe scale factor that will be multiplied to each color channel of the image.
swapRBIf true, will swap the red and blue channel of the input image.
parsingTypeThe type of parsing method to use to interpret the DNN raw results.
modelFilenameThe path towards the DNN weights.
configFilenameThe path towards the additional DNN configuration file potentially needed.
frameworkThe type of framework used to store the weights of the DNN.

Definition at line 402 of file vpDetectorDNNOpenCV.h.

Member Function Documentation

◆ operator=()

NetConfig& vpDetectorDNNOpenCV::NetConfig::operator= ( const NetConfig config)
inline

Definition at line 445 of file vpDetectorDNNOpenCV.h.

◆ parseClassNamesFile()

static std::vector<std::string> vpDetectorDNNOpenCV::NetConfig::parseClassNamesFile ( const std::string &  filename)
inlinestatic

Parse the file containing the list of classes the DNN can detect. These classes can be written either as a YAML array (i.e. ["classname_0", ... ,"classname_last"]) or with one classname by row (without quotes).

For example, in the case of a yaml file called my-classes.yaml, one content could be:

$ cat my-classes.yaml
[ "person", "bicycle", "car"]

And in the case of a text file called my-classes.txt, similar content could be:

$ cat my-classes.txt
person
bicycle
car
Parameters
filenameThe path towards the file containing the list of classes the DNN can detect.
Returns
std::vector<std::string> The list of classes the DNN can detect.

Definition at line 284 of file vpDetectorDNNOpenCV.h.

Referenced by vpDetectorDNNOpenCV::parseClassNamesFile().

◆ toString()

std::string vpDetectorDNNOpenCV::NetConfig::toString ( ) const
inline

Friends And Related Function Documentation

◆ from_json

void from_json ( const json &  j,
NetConfig config 
)
friend

Read the network configuration from JSON. All values are optional and if an argument is not present, the default value defined in the constructor is kept.

Parameters
jThe JSON object, resulting from the parsing of a JSON file.
configThe configuration of the network, that will be initialized from the JSON data.

Definition at line 200 of file vpDetectorDNNOpenCV.h.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const NetConfig config 
)
friend

Definition at line 439 of file vpDetectorDNNOpenCV.h.

◆ to_json

void to_json ( json &  j,
const NetConfig config 
)
friend

Parse a vpDetectorDNNOpenCV::NetConfig into JSON format.

Parameters
jA JSON parser object.
configThe vpDetectorDNNOpenCV::NetConfig that must be parsed into JSON format.

Definition at line 240 of file vpDetectorDNNOpenCV.h.

Member Data Documentation

◆ vpDetectorDNNOpenCV

friend vpDetectorDNNOpenCV::NetConfig::vpDetectorDNNOpenCV

Definition at line 462 of file vpDetectorDNNOpenCV.h.