| OpenCV 5.0.0alpha Open Source Computer Vision

Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
cv::gapi::ie::Params< Net > Class Template Reference

This structure provides functions that fill inference parameters for "OpenVINO Toolkit" model. More...

`#include <opencv2/gapi/infer/ie.hpp>`

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

## Public Member Functions
| Params (const std::string &model, const std::string &device)
| Params (const std::string &model, const std::string &weights, const std::string &device)
| Class constructor.
GBackend | backend () const
Params< Net > & | cfgBatchSize (const size_t size)
| Specifies the inference batch size.
Params & | cfgContextParams (const cv::util::any &ctx_cfg)
| Specifies configuration for RemoteContext in InferenceEngine.
Params & | cfgContextParams (cv::util::any &&ctx_cfg)
Params< Net > & | cfgInferMode (InferMode mode)
| Specifies which api will be used to run inference.
Params< Net > & | cfgInputLayers (const typename PortCfg< Net >::In &layer_names)
| Specifies sequence of network input layers names for inference.
Params< Net > & | cfgInputLayout (detail::AttrMap< std::string > layout_map)
Params< Net > & | cfgInputLayout (std::string layout)
| Specifies the input layout for model.
Params< Net > & | cfgInputReshape (const std::map< std::string, std::vector< std::size_t > > &reshape_table)
| Specifies new input shapes for the network inputs.
Params< Net > & | cfgInputReshape (const std::string &layer_name, const std::vector< size_t > &layer_dims)
Params< Net > & | cfgInputReshape (const std::unordered_set< std::string > &layer_names)
Params< Net > & | cfgInputReshape (std::map< std::string, std::vector< std::size_t > > &&reshape_table)
Params< Net > & | cfgInputReshape (std::string &&layer_name, std::vector< size_t > &&layer_dims)
Params< Net > & | cfgInputReshape (std::unordered_set< std::string > &&layer_names)
Params & | cfgNumRequests (size_t nireq)
| Specifies number of asynchronous inference requests.
Params< Net > & | cfgOutputLayers (const typename PortCfg< Net >::Out &layer_names)
| Specifies sequence of network output layers names for inference.
Params< Net > & | cfgOutputLayout (detail::AttrMap< std::string > layout_map)
Params< Net > & | cfgOutputLayout (std::string layout)
| Specifies the output layout for model.
Params< Net > & | cfgOutputPrecision (detail::ParamDesc::PrecisionMapT precision_map)
Params< Net > & | cfgOutputPrecision (detail::ParamDesc::PrecisionT precision)
| Specifies the output precision for model.
Params< Net > & | cfgPreprocessingParams (const cv::gapi::wip::onevpl::Device &device, const cv::gapi::wip::onevpl::Context &ctx)
Params< Net > & | cfgResize (detail::AttrMap< int > interpolation)
Params< Net > & | cfgResize (int interpolation)
| Specifies resize interpolation algorithm.
Params< Net > & | constInput (const std::string &layer_name, const cv::Mat &data, TraitAs hint=TraitAs::TENSOR)
| Specifies a constant input.
cv::util::any | params () const
Params & | pluginConfig (const IEConfig &cfg)
| Specifies OpenVINO plugin configuration.
Params & | pluginConfig (IEConfig &&cfg)
std::string | tag () const

## Protected Attributes
detail::ParamDesc | desc

## Detailed Description

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

This structure provides functions that fill inference parameters for "OpenVINO Toolkit" model.

## Constructor & Destructor Documentation

## ◆ Params() [1/2]

template<typename Net >

cv::gapi::ie::Params< Net >::Params | ( | const std::string & | model,
|  | const std::string & | weights,
|  | const std::string & | device )
| inline

Class constructor.

Constructs Params based on model information and specifies default values for other inference description parameters. Model is loaded and compiled using "OpenVINO Toolkit".

Parameters

  model | Path to topology IR (.xml file).
  weights | Path to weights (.bin file).
  device | target device to use.

## ◆ Params() [2/2]

template<typename Net >

cv::gapi::ie::Params< Net >::Params | ( | const std::string & | model,
|  | const std::string & | device )
| inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Use this constructor to work with pre-compiled network. Model is imported from a pre-compiled blob.

Parameters

  model | Path to model.
  device | target device to use.

## Member Function Documentation

## ◆ backend()

template<typename Net >

GBackend cv::gapi::ie::Params< Net >::backend | ( |  | ) | const
| inline

Here is the call graph for this function:

## ◆ cfgBatchSize()

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgBatchSize | ( | const size_t | size | ) |
| inline

Specifies the inference batch size.

The function is used to specify inference batch size. Follow https://docs.openvinotoolkit.org/latest/classInferenceEngine_1_1CNNNetwork.html#a8e9d19270a48aab50cb5b1c43eecb8e9 for additional information

Parameters

  size | batch size which will be used.

Returns
  reference to this parameter structure.

Here is the call graph for this function:

## ◆ cfgContextParams() [1/2]

template<typename Net >

Params & cv::gapi::ie::Params< Net >::cfgContextParams | ( | const cv::util::any & | ctx_cfg | ) |
| inline

Specifies configuration for RemoteContext in InferenceEngine.

When RemoteContext is configured the backend imports the networks using the context. It also expects cv::MediaFrames to be actually remote, to operate with blobs via the context.

Parameters

  ctx_cfg | cv::util::any value which holds InferenceEngine::ParamMap.

Returns
  reference to this parameter structure.

## ◆ cfgContextParams() [2/2]

template<typename Net >

Params & cv::gapi::ie::Params< Net >::cfgContextParams | ( | cv::util::any && | ctx_cfg | ) |
| 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 an rvalue parameter.

Parameters

  ctx_cfg | cv::util::any value which holds InferenceEngine::ParamMap.

Returns
  reference to this parameter structure.

## ◆ cfgInferMode()

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInferMode | ( | InferMode | mode | ) |
| inline

Specifies which api will be used to run inference.

The function is used to specify mode for OpenVINO inference. OpenVINO has two options to run inference:

1. Asynchronous (using StartAsync: https://docs.openvino.ai/latest/classInferenceEngine_1_1InferRequest.html#doxid-class-inference-engine-1-1-infer-request-1a405293e8423d82a5b45f642a3bef0d24)
2. Synchronous (using Infer: https://docs.openvino.ai/latest/classInferenceEngine_1_1InferRequest.html#doxid-class-inference-engine-1-1-infer-request-1a3391ce30894abde730523e9ca9371ce8) By default asynchronous mode is used.

Parameters

  mode | Inference mode which will be used.

Returns
  reference to this parameter structure.

## ◆ cfgInputLayers()

template<typename Net >

Params< Net > & cv::gapi::ie::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 cv::gapi::infer<> inputs with the model inputs. Number of names has to match the number of network inputs as defined in G_API_NET(). In case a network has only single input layer, there is no need to specify name manually.

Parameters

  layer_names | std::array<std::string, N> where N is the number of inputs as defined in the G_API_NET. Contains names of input layers.

Returns
  reference to this parameter structure.

## ◆ cfgInputLayout() [1/2]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInputLayout | ( | detail::AttrMap< std::string > | layout_map | ) |
| inline

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

Parameters

  layout_map | Map of pairs: name of corresponding input layer and its layout in string representation ("NCHW", "NHWC", etc)

Returns
  reference to this parameter structure.

## ◆ cfgInputLayout() [2/2]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInputLayout | ( | std::string | layout | ) |
| inline

Specifies the input layout for model.

The function is used to set an input layout for model.

Parameters

  layout | Layout in string representation ("NCHW", "NHWC", etc) will be applied to all input layers.

Returns
  reference to this parameter structure.

## ◆ cfgInputReshape() [1/6]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInputReshape | ( | const std::map< std::string, std::vector< std::size_t > > & | reshape_table | ) |
| inline

Specifies new input shapes for the network inputs.

The function is used to specify new input shapes for the network inputs. Follow https://docs.openvinotoolkit.org/latest/classInferenceEngine_1_1networkNetwork.html for additional information.

Parameters

  reshape_table | Map of pairs: name of corresponding data and its dimension.

Returns
  reference to this parameter structure.

## ◆ cfgInputReshape() [2/6]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInputReshape | ( | const std::string & | layer_name,
|  | const std::vector< size_t > & | layer_dims )
| inline

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

Parameters

  layer_name | Name of layer.
  layer_dims | New dimensions for this layer.

Returns
  reference to this parameter structure.

## ◆ cfgInputReshape() [3/6]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInputReshape | ( | const std::unordered_set< std::string > & | layer_names | ) |
| inline

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

Parameters

  layer_names | set of names of network layers that will be used for network reshape.

Returns
  reference to this parameter structure.

## ◆ cfgInputReshape() [4/6]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInputReshape | ( | std::map< std::string, std::vector< std::size_t > > && | reshape_table | ) |
| inline

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

## ◆ cfgInputReshape() [5/6]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInputReshape | ( | std::string && | layer_name,
|  | std::vector< size_t > && | layer_dims )
| inline

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

## ◆ cfgInputReshape() [6/6]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgInputReshape | ( | std::unordered_set< std::string > && | layer_names | ) |
| inline

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

Parameters

  layer_names | rvalue set of the selected layers will be reshaped automatically its input image size.

Returns
  reference to this parameter structure.

## ◆ cfgNumRequests()

template<typename Net >

Params & cv::gapi::ie::Params< Net >::cfgNumRequests | ( | size_t | nireq | ) |
| inline

Specifies number of asynchronous inference requests.

Parameters

  nireq | Number of inference asynchronous requests.

Returns
  reference to this parameter structure.

## ◆ cfgOutputLayers()

template<typename Net >

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

Specifies sequence of network output layers names for inference.

The function is used to associate cv::gapi::infer<> outputs with the model outputs. Number of names has to match the number of network outputs as defined in G_API_NET(). In case a network has only single output layer, there is no need to specify name manually.

Parameters

  layer_names | std::array<std::string, N> where N is the number of outputs as defined in the G_API_NET. Contains names of output layers.

Returns
  reference to this parameter structure.

## ◆ cfgOutputLayout() [1/2]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgOutputLayout | ( | detail::AttrMap< std::string > | layout_map | ) |
| inline

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

Parameters

  layout_map | Map of pairs: name of corresponding output layer and its layout in string representation ("NCHW", "NHWC", etc)

Returns
  reference to this parameter structure.

## ◆ cfgOutputLayout() [2/2]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgOutputLayout | ( | std::string | layout | ) |
| inline

Specifies the output layout for model.

The function is used to set an output layout for model.

Parameters

  layout | Layout in string representation ("NCHW", "NHWC", etc) will be applied to all output layers.

Returns
  reference to this parameter structure.

## ◆ cfgOutputPrecision() [1/2]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgOutputPrecision | ( | detail::ParamDesc::PrecisionMapT | precision_map | ) |
| inline

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

Parameters

  precision_map | Map of pairs: name of corresponding output layer and its precision in OpenCV format (CV_8U, CV_32F, ...)

Returns
  reference to this parameter structure.

## ◆ cfgOutputPrecision() [2/2]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgOutputPrecision | ( | detail::ParamDesc::PrecisionT | precision | ) |
| inline

Specifies the output precision for model.

The function is used to set an output precision for model.

Parameters

  precision | Precision in OpenCV format (CV_8U, CV_32F, ...) will be applied to all output layers.

Returns
  reference to this parameter structure.

## ◆ cfgPreprocessingParams()

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgPreprocessingParams | ( | const cv::gapi::wip::onevpl::Device & | device,
|  | const cv::gapi::wip::onevpl::Context & | ctx )
| inline

Here is the call graph for this function:

## ◆ cfgResize() [1/2]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgResize | ( | detail::AttrMap< int > | interpolation | ) |
| inline

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

Parameters

  interpolation | Map of pairs: name of corresponding input layer and its resize algorithm.

Returns
  reference to this parameter structure.

## ◆ cfgResize() [2/2]

template<typename Net >

Params< Net > & cv::gapi::ie::Params< Net >::cfgResize | ( | int | interpolation | ) |
| inline

Specifies resize interpolation algorithm.

The function is used to configure resize preprocessing for input layer.

Parameters

  interpolation | Resize interpolation algorithm. Supported algorithms: INTER_LINEAR, INTER_AREA.

Returns
  reference to this parameter structure.

## ◆ constInput()

template<typename Net >

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

Specifies a constant input.

The function is used to set a constant input. This input has to be a preprocessed tensor if its type is TENSOR. Need to provide name of the network layer which will receive provided data.

Parameters

  layer_name | Name of network layer.
  data | cv::Mat that contains data which will be associated with network layer.
  hint | Input type

See also
  cv::gapi::ie::TraitAs.

Returns
  reference to this parameter structure.

## ◆ params()

template<typename Net >

cv::util::any cv::gapi::ie::Params< Net >::params | ( |  | ) | const
| inline

## ◆ pluginConfig() [1/2]

template<typename Net >

Params & cv::gapi::ie::Params< Net >::pluginConfig | ( | const IEConfig & | cfg | ) |
| inline

Specifies OpenVINO plugin configuration.

The function is used to set configuration for OpenVINO plugin. Some parameters can be different for each plugin. Please follow https://docs.openvinotoolkit.org/latest/index.html to check information about specific plugin.

Parameters

  cfg | Map of pairs: (config parameter name, config parameter value).

Returns
  reference to this parameter structure.

## ◆ pluginConfig() [2/2]

template<typename Net >

Params & cv::gapi::ie::Params< Net >::pluginConfig | ( | IEConfig && | cfg | ) |
| 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 parameter.

Parameters

  cfg | rvalue map of pairs: (config parameter name, config parameter value).

Returns
  reference to this parameter structure.

## ◆ tag()

template<typename Net >

std::string cv::gapi::ie::Params< Net >::tag | ( |  | ) | const
| inline

## Member Data Documentation

## ◆ desc

template<typename Net >

detail::ParamDesc cv::gapi::ie::Params< Net >::desc
| protected

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

- opencv2/gapi/infer/ie.hpp