Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpDetectorDNNOpenCV::NetConfig Struct Reference

#include <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 nlohmann::json &j, NetConfig &config)
void to_json (nlohmann::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 190 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 332 of file vpDetectorDNNOpenCV.h.

References vpDetectorDNNOpenCV::USER_SPECIFIED, and vpDetectorDNNOpenCV.

Referenced by from_json, NetConfig(), operator<<, operator=(), and to_json.

◆ NetConfig() [2/4]

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

Definition at line 349 of file vpDetectorDNNOpenCV.h.

References NetConfig().

◆ 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 383 of file vpDetectorDNNOpenCV.h.

References vpDetectorDNNOpenCV::USER_SPECIFIED.

◆ 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 417 of file vpDetectorDNNOpenCV.h.

References parseClassNamesFile(), and vpDetectorDNNOpenCV::USER_SPECIFIED.

Member Function Documentation

◆ operator=()

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

Definition at line 460 of file vpDetectorDNNOpenCV.h.

References NetConfig().

◆ parseClassNamesFile()

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 299 of file vpDetectorDNNOpenCV.h.

Referenced by NetConfig().

◆ toString()

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

◆ from_json

void from_json ( const nlohmann::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 215 of file vpDetectorDNNOpenCV.h.

References vpException::badValue, vpException::dimensionError, vpDetectorDNNOpenCV::dnnResultsParsingTypeFromString(), vpDetectorDNNOpenCV::dnnResultsParsingTypeToString(), and NetConfig().

◆ operator<<

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

Definition at line 454 of file vpDetectorDNNOpenCV.h.

References NetConfig().

◆ to_json

void to_json ( nlohmann::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 255 of file vpDetectorDNNOpenCV.h.

References vpDetectorDNNOpenCV::dnnResultsParsingTypeToString(), and NetConfig().

Member Data Documentation

◆ vpDetectorDNNOpenCV

friend vpDetectorDNNOpenCV::NetConfig::vpDetectorDNNOpenCV

Definition at line 477 of file vpDetectorDNNOpenCV.h.

Referenced by NetConfig().