OpenCV  4.10.0
Open Source Computer Vision
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
cv::gapi::onnx::Params< Net > Class Template Reference

#include <opencv2/gapi/infer/onnx.hpp>

Collaboration diagram for cv::gapi::onnx::Params< Net >:

Public Member Functions

 Params (const std::string &model)
 Class constructor.
 
GBackend backend () const
 
Params< Net > & cfgAddExecutionProvider (ep::CoreML &&ep)
 Adds execution provider for runtime.
 
Params< Net > & cfgAddExecutionProvider (ep::CUDA &&ep)
 Adds execution provider for runtime.
 
Params< Net > & cfgAddExecutionProvider (ep::DirectML &&ep)
 Adds execution provider for runtime.
 
Params< Net > & cfgAddExecutionProvider (ep::OpenVINO &&ep)
 Adds execution provider for runtime.
 
Params< Net > & cfgAddExecutionProvider (ep::TensorRT &&ep)
 Adds execution provider for runtime.
 
Params< Net > & cfgDisableMemPattern ()
 Disables the memory pattern optimization.
 
Params< Net > & cfgInputLayers (const typename PortCfg< Net >::In &layer_names)
 Specifies sequence of network input layers names for inference.
 
Params< Net > & cfgMeanStd (const typename PortCfg< Net >::NormCoefs &m, const typename PortCfg< Net >::NormCoefs &s)
 Specifies mean value and standard deviation for preprocessing.
 
Params< Net > & cfgNormalize (const typename PortCfg< Net >::Normalize &normalizations)
 Specifies normalize parameter for preprocessing.
 
Params< Net > & cfgOutputLayers (const typename PortCfg< Net >::Out &layer_names)
 Specifies sequence of output layers names for inference.
 
Params< Net > & cfgPostProc (const std::vector< cv::GMatDesc > &out_metas, const PostProc &remap_function)
 Configures graph output and provides the post processing function from user.
 
Params< Net > & cfgPostProc (const std::vector< cv::GMatDesc > &out_metas, const PostProc &remap_function, const std::vector< std::string > &names_to_remap)
 
Params< Net > & cfgPostProc (std::vector< cv::GMatDesc > &&out_metas, PostProc &&remap_function)
 
Params< Net > & cfgPostProc (std::vector< cv::GMatDesc > &&out_metas, PostProc &&remap_function, std::vector< std::string > &&names_to_remap)
 
Params< Net > & constInput (const std::string &layer_name, const cv::Mat &data, TraitAs hint=TraitAs::TENSOR)
 Sets a constant input.
 
cv::util::any params () const
 
std::string tag () const
 

Protected Attributes

detail::ParamDesc desc
 

Detailed Description

template<typename Net>
class cv::gapi::onnx::Params< Net >

Contains description of inference parameters and kit of functions that fill this parameters.

Constructor & Destructor Documentation

◆ Params()

template<typename Net >
cv::gapi::onnx::Params< Net >::Params ( const std::string &  model)
inline

Class constructor.

Constructs Params based on model information and sets default values for other inference description parameters.

Parameters
modelPath to model (.onnx file).

Member Function Documentation

◆ backend()

template<typename Net >
GBackend cv::gapi::onnx::Params< Net >::backend ( ) const
inline
Here is the call graph for this function:

◆ cfgAddExecutionProvider() [1/5]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgAddExecutionProvider ( ep::CoreML &&  ep)
inline

Adds execution provider for runtime.

The function is used to add ONNX Runtime CoreML Execution Provider options.

Parameters
epCoreML Execution Provider options.
See also
cv::gapi::onnx::ep::CoreML.
Returns
the reference on modified object.

◆ cfgAddExecutionProvider() [2/5]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgAddExecutionProvider ( ep::CUDA &&  ep)
inline

Adds execution provider for runtime.

The function is used to add ONNX Runtime CUDA Execution Provider options.

Parameters
epCUDA Execution Provider options.
See also
cv::gapi::onnx::ep::CUDA.
Returns
the reference on modified object.

◆ cfgAddExecutionProvider() [3/5]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgAddExecutionProvider ( ep::DirectML &&  ep)
inline

Adds execution provider for runtime.

The function is used to add ONNX Runtime DirectML Execution Provider options.

Parameters
epDirectML Execution Provider options.
See also
cv::gapi::onnx::ep::DirectML.
Returns
the reference on modified object.

◆ cfgAddExecutionProvider() [4/5]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgAddExecutionProvider ( ep::OpenVINO &&  ep)
inline

Adds execution provider for runtime.

The function is used to add ONNX Runtime OpenVINO Execution Provider options.

Parameters
epOpenVINO Execution Provider options.
See also
cv::gapi::onnx::ep::OpenVINO.
Returns
the reference on modified object.

◆ cfgAddExecutionProvider() [5/5]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgAddExecutionProvider ( ep::TensorRT &&  ep)
inline

Adds execution provider for runtime.

The function is used to add ONNX Runtime TensorRT Execution Provider options.

Parameters
epTensorRT Execution Provider options.
See also
cv::gapi::onnx::ep::TensorRT.
Returns
the reference on modified object.

◆ cfgDisableMemPattern()

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgDisableMemPattern ( )
inline

Disables the memory pattern optimization.

Returns
the reference on modified object.

◆ cfgInputLayers()

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgInputLayers ( const typename PortCfg< Net >::In &  layer_names)
inline

Specifies sequence of network input layers names for inference.

The function is used to associate data of graph inputs with input layers of network topology. Number of names has to match the number of network inputs. If a network has only one input layer, there is no need to call it as the layer is associated with input automatically but this doesn't prevent you from doing it yourself. Count of names has to match to number of network inputs.

Parameters
layer_namesstd::array<std::string, N> where N is the number of inputs as defined in the G_API_NET. Contains names of input layers.
Returns
the reference on modified object.

◆ cfgMeanStd()

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgMeanStd ( const typename PortCfg< Net >::NormCoefs &  m,
const typename PortCfg< Net >::NormCoefs &  s 
)
inline

Specifies mean value and standard deviation for preprocessing.

The function is used to set mean value and standard deviation for preprocessing of input data.

Parameters
mstd::array<cv::Scalar, N> where N is the number of inputs as defined in the G_API_NET. Contains mean values.
sstd::array<cv::Scalar, N> where N is the number of inputs as defined in the G_API_NET. Contains standard deviation values.
Returns
the reference on modified object.

◆ cfgNormalize()

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgNormalize ( const typename PortCfg< Net >::Normalize &  normalizations)
inline

Specifies normalize parameter for preprocessing.

The function is used to set normalize parameter for preprocessing of input data.

Parameters
normalizationsstd::array<cv::Scalar, N> where N is the number of inputs as defined in the G_API_NET. Сontains bool values that enabled or disabled normalize of input data.
Returns
the reference on modified object.

◆ cfgOutputLayers()

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgOutputLayers ( const typename PortCfg< Net >::Out &  layer_names)
inline

Specifies sequence of output layers names for inference.

The function is used to associate data of graph outputs with output layers of network topology. If a network has only one output layer, there is no need to call it as the layer is associated with output automatically but this doesn't prevent you from doing it yourself. Count of names has to match to number of network outputs or you can set your own output but for this case you have to additionally use cfgPostProc function.

Parameters
layer_namesstd::array<std::string, N> where N is the number of outputs as defined in the G_API_NET. Contains names of output layers.
Returns
the reference on modified object.

◆ cfgPostProc() [1/4]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgPostProc ( const std::vector< cv::GMatDesc > &  out_metas,
const PostProc remap_function 
)
inline

Configures graph output and provides the post processing function from user.

The function is used when you work with networks with dynamic outputs. Since we can't know dimensions of inference result needs provide them for construction of graph output. This dimensions can differ from inference result. So you have to provide PostProc function that gets information from inference result and fill output which is constructed by dimensions from out_metas.

Parameters
out_metasOut meta information about your output (type, dimension).
remap_functionPost processing function, which has two parameters. First is onnx result, second is graph output. Both parameters is std::map that contain pair of layer's name and cv::Mat.
Returns
the reference on modified object.

◆ cfgPostProc() [2/4]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgPostProc ( const std::vector< cv::GMatDesc > &  out_metas,
const PostProc remap_function,
const std::vector< std::string > &  names_to_remap 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. The function has additional parameter names_to_remap. This parameter provides information about output layers which will be used for inference and post processing function.

Parameters
out_metasOut meta information.
remap_functionPost processing function.
names_to_remapNames of output layers. network's inference will be done on these layers. Inference's result will be processed in post processing function using these names.
Returns
the reference on modified object.

◆ cfgPostProc() [3/4]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgPostProc ( std::vector< cv::GMatDesc > &&  out_metas,
PostProc &&  remap_function 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Function with a rvalue parameters.

Parameters
out_metasrvalue out meta information about your output (type, dimension).
remap_functionrvalue post processing function, which has two parameters. First is onnx result, second is graph output. Both parameters is std::map that contain pair of layer's name and cv::Mat.
Returns
the reference on modified object.

◆ cfgPostProc() [4/4]

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::cfgPostProc ( std::vector< cv::GMatDesc > &&  out_metas,
PostProc &&  remap_function,
std::vector< std::string > &&  names_to_remap 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Function with a rvalue parameters and additional parameter names_to_remap.

Parameters
out_metasrvalue out meta information.
remap_functionrvalue post processing function.
names_to_remaprvalue names of output layers. network's inference will be done on these layers. Inference's result will be processed in post processing function using these names.
Returns
the reference on modified object.

◆ constInput()

template<typename Net >
Params< Net > & cv::gapi::onnx::Params< Net >::constInput ( const std::string &  layer_name,
const cv::Mat data,
TraitAs  hint = TraitAs::TENSOR 
)
inline

Sets a constant input.

The function is used to set constant input. This input has to be a prepared tensor since preprocessing is disabled for this case. You should provide name of network layer which will receive provided data.

Parameters
layer_nameName of network layer.
datacv::Mat that contains data which will be associated with network layer.
hintType of input (TENSOR).
Returns
the reference on modified object.

◆ params()

template<typename Net >
cv::util::any cv::gapi::onnx::Params< Net >::params ( ) const
inline

◆ tag()

template<typename Net >
std::string cv::gapi::onnx::Params< Net >::tag ( ) const
inline

Member Data Documentation

◆ desc

template<typename Net >
detail::ParamDesc cv::gapi::onnx::Params< Net >::desc
protected

The documentation for this class was generated from the following file: