OpenCV  4.7.0-dev
Open Source Computer Vision
Namespaces | Classes | Typedefs | Enumerations | Functions
cv::dnn Namespace Reference

Namespaces

 accessor
 
 details
 

Classes

struct  _Range
 
class  AbsLayer
 
class  AccumLayer
 
class  AcoshLayer
 
class  AcosLayer
 
class  ActivationLayer
 
class  ActivationLayerInt8
 
class  ArgLayer
 ArgMax/ArgMin layer. More...
 
class  AsinhLayer
 
class  AsinLayer
 
class  AtanhLayer
 
class  AtanLayer
 
class  BackendNode
 Derivatives of this class encapsulates functions of certain backends. More...
 
class  BackendWrapper
 Derivatives of this class wraps cv::Mat for different backends and targets. More...
 
class  BaseConvolutionLayer
 
class  BatchNormLayer
 
class  BatchNormLayerInt8
 
class  BlankLayer
 
class  BNLLLayer
 
class  CeilLayer
 
class  CeluLayer
 
class  ChannelsPReLULayer
 
class  ClassificationModel
 This class represents high-level API for classification models. More...
 
class  CompareLayer
 
class  ConcatLayer
 
class  ConstLayer
 
class  ConvolutionLayer
 
class  ConvolutionLayerInt8
 
class  CorrelationLayer
 
class  CoshLayer
 
class  CosLayer
 
class  CropAndResizeLayer
 
class  CropLayer
 
class  CumSumLayer
 
class  DataAugmentationLayer
 
class  DeconvolutionLayer
 
class  DequantizeLayer
 
class  DetectionModel
 This class represents high-level API for object detection networks. More...
 
class  DetectionOutputLayer
 Detection output layer. More...
 
class  Dict
 This class implements name-value dictionary, values are instances of DictValue. More...
 
struct  DictValue
 This struct stores the scalar value (or array) of one of the following type: double, cv::String or int64. More...
 
class  EltwiseLayer
 Element wise operation on inputs. More...
 
class  EltwiseLayerInt8
 
class  ELULayer
 
class  ErfLayer
 
class  ExpLayer
 
class  FlattenLayer
 
class  FloorLayer
 
class  FlowWarpLayer
 
class  GatherLayer
 Gather layer. More...
 
class  GRULayer
 GRU recurrent one-layer. More...
 
class  HardSigmoidLayer
 
class  HardSwishLayer
 
class  InnerProductLayer
 
class  InnerProductLayerInt8
 
class  InterpLayer
 Bilinear resize layer from https://github.com/cdmh/deeplab-public-ver2. More...
 
class  KeypointsModel
 This class represents high-level API for keypoints models. More...
 
class  Layer
 This interface class allows to build new Layers - are building blocks of networks. More...
 
class  LayerFactory
 Layer factory allows to create instances of registered layers. More...
 
class  LayerParams
 This class provides all data needed to initialize layer. More...
 
class  LogLayer
 
class  LRNLayer
 
class  LSTMLayer
 LSTM recurrent layer. More...
 
class  MaxUnpoolLayer
 
class  MishLayer
 
class  Model
 This class is presented high-level API for neural networks. More...
 
class  MVNLayer
 
class  NaryEltwiseLayer
 
class  Net
 This class allows to create and manipulate comprehensive artificial neural networks. More...
 
class  NormalizeBBoxLayer
 \( L_p \) - normalization layer. More...
 
class  NotLayer
 
class  PaddingLayer
 Adds extra values for specific axes. More...
 
class  PermuteLayer
 
class  PoolingLayer
 
class  PoolingLayerInt8
 
class  PowerLayer
 
class  PriorBoxLayer
 
class  ProposalLayer
 
class  QuantizeLayer
 
class  ReciprocalLayer
 
class  ReduceLayer
 
class  ReduceLayerInt8
 
class  RegionLayer
 
class  ReLU6Layer
 
class  ReLULayer
 
class  ReorgLayer
 
class  RequantizeLayer
 
class  ReshapeLayer
 
class  ResizeLayer
 Resize input 4-dimensional blob by nearest neighbor or bilinear strategy. More...
 
class  RNNLayer
 Classical recurrent layer. More...
 
class  RoundLayer
 
class  ScaleLayer
 
class  ScaleLayerInt8
 
class  ScatterLayer
 
class  ScatterNDLayer
 
class  SegmentationModel
 This class represents high-level API for segmentation models. More...
 
class  SeluLayer
 
class  ShiftLayer
 
class  ShiftLayerInt8
 
class  ShrinkLayer
 
class  ShuffleChannelLayer
 
class  SigmoidLayer
 
class  SignLayer
 
class  SinhLayer
 
class  SinLayer
 
class  SliceLayer
 
class  SoftmaxLayer
 
class  SoftmaxLayerInt8
 
class  SoftplusLayer
 
class  SoftsignLayer
 
class  SplitLayer
 
class  SqrtLayer
 
class  SwishLayer
 
class  TanHLayer
 
class  TanLayer
 
class  TextDetectionModel
 Base class for text detection networks. More...
 
class  TextDetectionModel_DB
 This class represents high-level API for text detection DL networks compatible with DB model. More...
 
class  TextDetectionModel_EAST
 This class represents high-level API for text detection DL networks compatible with EAST model. More...
 
class  TextRecognitionModel
 This class represents high-level API for text recognition networks. More...
 
class  ThresholdedReluLayer
 
class  TileLayer
 

Typedefs

typedef std::map< std::string, std::vector< LayerFactory::Constructor > > LayerFactory_Impl
 
typedef std::vector< int > MatShape
 

Enumerations

enum  Backend {
  DNN_BACKEND_DEFAULT = 0,
  DNN_BACKEND_HALIDE,
  DNN_BACKEND_INFERENCE_ENGINE,
  DNN_BACKEND_OPENCV,
  DNN_BACKEND_VKCOM,
  DNN_BACKEND_CUDA,
  DNN_BACKEND_WEBNN,
  DNN_BACKEND_TIMVX,
  DNN_BACKEND_CANN
}
 Enum of computation backends supported by layers. More...
 
enum  SoftNMSMethod {
  SoftNMSMethod::SOFTNMS_LINEAR = 1,
  SoftNMSMethod::SOFTNMS_GAUSSIAN = 2
}
 Enum of Soft NMS methods. More...
 
enum  Target {
  DNN_TARGET_CPU = 0,
  DNN_TARGET_OPENCL,
  DNN_TARGET_OPENCL_FP16,
  DNN_TARGET_MYRIAD,
  DNN_TARGET_VULKAN,
  DNN_TARGET_FPGA,
  DNN_TARGET_CUDA,
  DNN_TARGET_CUDA_FP16,
  DNN_TARGET_HDDL,
  DNN_TARGET_NPU
}
 Enum of target devices for computations. More...
 

Functions

Mat blobFromImage (InputArray image, double scalefactor=1.0, const Size &size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F)
 Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels. More...
 
void blobFromImage (InputArray image, OutputArray blob, double scalefactor=1.0, const Size &size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F)
 Creates 4-dimensional blob from image. More...
 
Mat blobFromImages (InputArrayOfArrays images, double scalefactor=1.0, Size size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F)
 Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels. More...
 
void blobFromImages (InputArrayOfArrays images, OutputArray blob, double scalefactor=1.0, Size size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false, int ddepth=CV_32F)
 Creates 4-dimensional blob from series of images. More...
 
static MatShape concat (const MatShape &a, const MatShape &b)
 
void enableModelDiagnostics (bool isDiagnosticsMode)
 Enables detailed logging of the DNN model loading with CV DNN API. More...
 
std::vector< std::pair< Backend, Target > > getAvailableBackends ()
 
std::vector< TargetgetAvailableTargets (dnn::Backend be)
 
cv::String getInferenceEngineBackendType ()
 Returns Inference Engine internal backend API. More...
 
cv::String getInferenceEngineCPUType ()
 Returns Inference Engine CPU type. More...
 
cv::String getInferenceEngineVPUType ()
 Returns Inference Engine VPU type. More...
 
LayerFactory_ImplgetLayerFactoryImpl ()
 
MutexgetLayerFactoryMutex ()
 Get the mutex guarding LayerFactory_Impl, see getLayerFactoryImpl() function. More...
 
static Mat getPlane (const Mat &m, int n, int cn)
 
void imagesFromBlob (const cv::Mat &blob_, OutputArrayOfArrays images_)
 Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure (std::vector<cv::Mat>). More...
 
static bool isAllOnes (const MatShape &inputShape, int startPos, int endPos)
 
void NMSBoxes (const std::vector< Rect > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0)
 Performs non maximum suppression given boxes and corresponding scores. More...
 
void NMSBoxes (const std::vector< Rect2d > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0)
 
void NMSBoxes (const std::vector< RotatedRect > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0)
 
void NMSBoxesBatched (const std::vector< Rect > &bboxes, const std::vector< float > &scores, const std::vector< int > &class_ids, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0)
 Performs batched non maximum suppression on given boxes and corresponding scores across different classes. More...
 
void NMSBoxesBatched (const std::vector< Rect2d > &bboxes, const std::vector< float > &scores, const std::vector< int > &class_ids, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0)
 
static int normalize_axis (int axis, int dims)
 Converts axis from [-dims; dims) (similar to Python's slice notation) to [0; dims) range. More...
 
static int normalize_axis (int axis, const MatShape &shape)
 
static Range normalize_axis_range (const Range &r, int axisSize)
 
template<typename _Tp >
static std::ostream & operator<< (std::ostream &out, const std::vector< _Tp > &shape)
 
template<typename _Tp >
static void print (const std::vector< _Tp > &shape, const String &name="")
 
Net readNet (const String &model, const String &config="", const String &framework="")
 Read deep learning network represented in one of the supported formats. More...
 
Net readNet (const String &framework, const std::vector< uchar > &bufferModel, const std::vector< uchar > &bufferConfig=std::vector< uchar >())
 Read deep learning network represented in one of the supported formats. More...
 
Net readNetFromCaffe (const String &prototxt, const String &caffeModel=String())
 Reads a network model stored in Caffe framework's format. More...
 
Net readNetFromCaffe (const std::vector< uchar > &bufferProto, const std::vector< uchar > &bufferModel=std::vector< uchar >())
 Reads a network model stored in Caffe model in memory. More...
 
Net readNetFromCaffe (const char *bufferProto, size_t lenProto, const char *bufferModel=NULL, size_t lenModel=0)
 Reads a network model stored in Caffe model in memory. More...
 
Net readNetFromDarknet (const String &cfgFile, const String &darknetModel=String())
 Reads a network model stored in Darknet model files. More...
 
Net readNetFromDarknet (const std::vector< uchar > &bufferCfg, const std::vector< uchar > &bufferModel=std::vector< uchar >())
 Reads a network model stored in Darknet model files. More...
 
Net readNetFromDarknet (const char *bufferCfg, size_t lenCfg, const char *bufferModel=NULL, size_t lenModel=0)
 Reads a network model stored in Darknet model files. More...
 
Net readNetFromModelOptimizer (const String &xml, const String &bin)
 Load a network from Intel's Model Optimizer intermediate representation. More...
 
Net readNetFromModelOptimizer (const std::vector< uchar > &bufferModelConfig, const std::vector< uchar > &bufferWeights)
 Load a network from Intel's Model Optimizer intermediate representation. More...
 
Net readNetFromModelOptimizer (const uchar *bufferModelConfigPtr, size_t bufferModelConfigSize, const uchar *bufferWeightsPtr, size_t bufferWeightsSize)
 Load a network from Intel's Model Optimizer intermediate representation. More...
 
Net readNetFromONNX (const String &onnxFile)
 Reads a network model ONNX. More...
 
Net readNetFromONNX (const char *buffer, size_t sizeBuffer)
 Reads a network model from ONNX in-memory buffer. More...
 
Net readNetFromONNX (const std::vector< uchar > &buffer)
 Reads a network model from ONNX in-memory buffer. More...
 
Net readNetFromTensorflow (const String &model, const String &config=String())
 Reads a network model stored in TensorFlow framework's format. More...
 
Net readNetFromTensorflow (const std::vector< uchar > &bufferModel, const std::vector< uchar > &bufferConfig=std::vector< uchar >())
 Reads a network model stored in TensorFlow framework's format. More...
 
Net readNetFromTensorflow (const char *bufferModel, size_t lenModel, const char *bufferConfig=NULL, size_t lenConfig=0)
 Reads a network model stored in TensorFlow framework's format. More...
 
Net readNetFromTorch (const String &model, bool isBinary=true, bool evaluate=true)
 Reads a network model stored in Torch7 framework's format. More...
 
Mat readTensorFromONNX (const String &path)
 Creates blob from .pb file. More...
 
Mat readTorchBlob (const String &filename, bool isBinary=true)
 Loads blob which was serialized as torch.Tensor object of Torch7 framework. More...
 
void releaseHDDLPlugin ()
 Release a HDDL plugin. More...
 
void resetMyriadDevice ()
 Release a Myriad device (binded by OpenCV). More...
 
cv::String setInferenceEngineBackendType (const cv::String &newBackendType)
 Specify Inference Engine internal backend API. More...
 
static MatShape shape (const int *dims, const int n)
 
static MatShape shape (const Mat &mat)
 
static MatShape shape (const MatSize &sz)
 
static MatShape shape (const UMat &mat)
 
static MatShape shape (int a0, int a1=-1, int a2=-1, int a3=-1)
 
void shrinkCaffeModel (const String &src, const String &dst, const std::vector< String > &layersTypes=std::vector< String >())
 Convert all weights of Caffe network to half precision floating point. More...
 
void skipModelImport (bool skip)
 Skip model import after diagnostic run in readNet() functions. More...
 
static Mat slice (const Mat &m, const _Range &r0)
 
static Mat slice (const Mat &m, const _Range &r0, const _Range &r1)
 
static Mat slice (const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2)
 
static Mat slice (const Mat &m, const _Range &r0, const _Range &r1, const _Range &r2, const _Range &r3)
 
void softNMSBoxes (const std::vector< Rect > &bboxes, const std::vector< float > &scores, std::vector< float > &updated_scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, size_t top_k=0, const float sigma=0.5, SoftNMSMethod method=SoftNMSMethod::SOFTNMS_GAUSSIAN)
 Performs soft non maximum suppression given boxes and corresponding scores. Reference: https://arxiv.org/abs/1704.04503. More...
 
template<typename _Tp >
static std::string toString (const std::vector< _Tp > &shape, const String &name="")
 
static int total (const MatShape &shape, int start=-1, int end=-1)
 
static int total (const Mat &mat, int start=-1, int end=-1)
 
void writeTextGraph (const String &model, const String &output)
 Create a text representation for a binary network stored in protocol buffer format. More...
 

Function Documentation

◆ concat()

static MatShape cv::dnn::concat ( const MatShape a,
const MatShape b 
)
inlinestatic

◆ getInferenceEngineBackendType()

cv::String cv::dnn::getInferenceEngineBackendType ( )

Returns Inference Engine internal backend API.

See values of CV_DNN_BACKEND_INFERENCE_ENGINE_* macros.

OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE runtime parameter (environment variable) is ignored since 4.6.0.

Deprecated:

◆ getInferenceEngineCPUType()

cv::String cv::dnn::getInferenceEngineCPUType ( )

Returns Inference Engine CPU type.

Specify OpenVINO plugin: CPU or ARM.

◆ getInferenceEngineVPUType()

cv::String cv::dnn::getInferenceEngineVPUType ( )

Returns Inference Engine VPU type.

See values of CV_DNN_INFERENCE_ENGINE_VPU_TYPE_* macros.

◆ getPlane()

static Mat cv::dnn::getPlane ( const Mat m,
int  n,
int  cn 
)
inlinestatic

◆ isAllOnes()

static bool cv::dnn::isAllOnes ( const MatShape inputShape,
int  startPos,
int  endPos 
)
inlinestatic

◆ normalize_axis() [1/2]

static int cv::dnn::normalize_axis ( int  axis,
int  dims 
)
inlinestatic

Converts axis from [-dims; dims) (similar to Python's slice notation) to [0; dims) range.

◆ normalize_axis() [2/2]

static int cv::dnn::normalize_axis ( int  axis,
const MatShape shape 
)
inlinestatic

◆ normalize_axis_range()

static Range cv::dnn::normalize_axis_range ( const Range r,
int  axisSize 
)
inlinestatic

◆ operator<<()

template<typename _Tp >
static std::ostream& cv::dnn::operator<< ( std::ostream &  out,
const std::vector< _Tp > &  shape 
)
inlinestatic

◆ print()

template<typename _Tp >
static void cv::dnn::print ( const std::vector< _Tp > &  shape,
const String name = "" 
)
inlinestatic

◆ releaseHDDLPlugin()

void cv::dnn::releaseHDDLPlugin ( )

Release a HDDL plugin.

◆ resetMyriadDevice()

void cv::dnn::resetMyriadDevice ( )

Release a Myriad device (binded by OpenCV).

Single Myriad device cannot be shared across multiple processes which uses Inference Engine's Myriad plugin.

◆ setInferenceEngineBackendType()

cv::String cv::dnn::setInferenceEngineBackendType ( const cv::String newBackendType)

Specify Inference Engine internal backend API.

See values of CV_DNN_BACKEND_INFERENCE_ENGINE_* macros.

Returns
previous value of internal backend API
Deprecated:

◆ shape() [1/5]

static MatShape cv::dnn::shape ( const int *  dims,
const int  n 
)
inlinestatic

◆ shape() [2/5]

static MatShape cv::dnn::shape ( const Mat mat)
inlinestatic

◆ shape() [3/5]

static MatShape cv::dnn::shape ( const MatSize sz)
inlinestatic

◆ shape() [4/5]

static MatShape cv::dnn::shape ( const UMat mat)
inlinestatic

◆ shape() [5/5]

static MatShape cv::dnn::shape ( int  a0,
int  a1 = -1,
int  a2 = -1,
int  a3 = -1 
)
inlinestatic

◆ skipModelImport()

void cv::dnn::skipModelImport ( bool  skip)

Skip model import after diagnostic run in readNet() functions.

Parameters
[in]skipIndicates whether to skip the import.

This is an internal OpenCV function not intended for users.

◆ slice() [1/4]

static Mat cv::dnn::slice ( const Mat m,
const _Range r0 
)
inlinestatic

◆ slice() [2/4]

static Mat cv::dnn::slice ( const Mat m,
const _Range r0,
const _Range r1 
)
inlinestatic

◆ slice() [3/4]

static Mat cv::dnn::slice ( const Mat m,
const _Range r0,
const _Range r1,
const _Range r2 
)
inlinestatic

◆ slice() [4/4]

static Mat cv::dnn::slice ( const Mat m,
const _Range r0,
const _Range r1,
const _Range r2,
const _Range r3 
)
inlinestatic

◆ toString()

template<typename _Tp >
static std::string cv::dnn::toString ( const std::vector< _Tp > &  shape,
const String name = "" 
)
inlinestatic

◆ total() [1/2]

static int cv::dnn::total ( const MatShape shape,
int  start = -1,
int  end = -1 
)
inlinestatic

◆ total() [2/2]

static int cv::dnn::total ( const Mat mat,
int  start = -1,
int  end = -1 
)
inlinestatic