opencv2/dnn/dnn.hpp#

#include <ostream>
#include <vector>
#include <opencv2/core.hpp>
#include <opencv2/core/async.hpp>
#include <../dnn/version.hpp>
#include <opencv2/dnn/dict.hpp>
#include <opencv2/dnn/layer.hpp>
#include <opencv2/dnn/dnn.inl.hpp>
#include <opencv2/dnn/utils/inference_engine.hpp>

Include dependency graph for dnn.hpp:

opencv2/dnn/dnn.hpp Node1 opencv2/dnn/dnn.hpp Node2 ostream Node1->Node2 Node3 vector Node1->Node3 Node4 opencv2/core.hpp Node1->Node4 Node52 opencv2/core/async.hpp Node1->Node52 Node54 ../dnn/version.hpp Node1->Node54 Node55 opencv2/dnn/dict.hpp Node1->Node55 Node57 opencv2/dnn/layer.hpp Node1->Node57 Node59 opencv2/dnn/dnn.inl.hpp Node1->Node59 Node60 opencv2/dnn/utils/inference _engine.hpp Node1->Node60 Node5 opencv2/core/cvdef.h Node4->Node5 Node12 opencv2/core/base.hpp Node4->Node12 Node16 opencv2/core/cvstd.hpp Node4->Node16 Node32 opencv2/core/traits.hpp Node4->Node32 Node33 opencv2/core/matx.hpp Node4->Node33 Node38 opencv2/core/types.hpp Node4->Node38 Node40 opencv2/core/mat.hpp Node4->Node40 Node44 opencv2/core/persistence.hpp Node4->Node44 Node45 opencv2/core/operations.hpp Node4->Node45 Node47 opencv2/core/cvstd.inl.hpp Node4->Node47 Node48 opencv2/core/utility.hpp Node4->Node48 Node51 opencv2/core/optim.hpp Node4->Node51 Node6 opencv2/core/version.hpp Node5->Node6 Node7 limits Node5->Node7 Node8 opencv2/core/hal/interface.h Node5->Node8 Node10 cstdint Node5->Node10 Node11 cv_cpu_dispatch.h Node5->Node11 Node9 cstddef Node8->Node9 Node8->Node10 Node12->Node5 Node13 opencv2/opencv_modules.hpp Node12->Node13 Node14 climits Node12->Node14 Node15 algorithm Node12->Node15 Node12->Node16 Node26 opencv2/core/fwddecl.hpp Node12->Node26 Node27 opencv2/core/neon_utils.hpp Node12->Node27 Node28 opencv2/core/vsx_utils.hpp Node12->Node28 Node30 opencv2/core/exception.hpp Node12->Node30 Node31 opencv2/core/check.hpp Node12->Node31 Node16->Node5 Node16->Node9 Node16->Node15 Node17 cstring Node16->Node17 Node18 cctype Node16->Node18 Node19 string Node16->Node19 Node20 utility Node16->Node20 Node21 cstdlib Node16->Node21 Node22 cmath Node16->Node22 Node23 cvstd_wrapper.hpp Node16->Node23 Node23->Node5 Node23->Node19 Node24 memory Node23->Node24 Node25 type_traits Node23->Node25 Node26->Node5 Node27->Node5 Node28->Node5 Node29 assert.h Node28->Node29 Node30->Node5 Node30->Node16 Node31->Node5 Node31->Node16 Node31->Node26 Node32->Node5 Node33->Node5 Node33->Node12 Node33->Node32 Node34 opencv2/core/saturate.hpp Node33->Node34 Node36 initializer_list Node33->Node36 Node37 opencv2/core/matx.inl.hpp Node33->Node37 Node34->Node5 Node34->Node14 Node35 opencv2/core/fast_math.hpp Node34->Node35 Node35->Node5 Node35->Node22 Node38->Node3 Node38->Node5 Node38->Node7 Node38->Node14 Node38->Node16 Node38->Node33 Node39 cfloat Node38->Node39 Node40->Node25 Node40->Node33 Node40->Node38 Node41 opencv2/core/bufferpool.hpp Node40->Node41 Node42 array Node40->Node42 Node43 opencv2/core/mat.inl.hpp Node40->Node43 Node44->Node38 Node44->Node40 Node45->Node2 Node46 cstdio Node45->Node46 Node48->Node2 Node48->Node4 Node49 functional Node48->Node49 Node50 mutex Node48->Node50 Node51->Node4 Node52->Node40 Node53 chrono Node52->Node53 Node55->Node1 Node55->Node2 Node55->Node4 Node56 map Node55->Node56 Node58 opencv2/dnn.hpp Node57->Node58 Node58->Node1 Node60->Node1

opencv2/dnn/dnn.hpp Node1 opencv2/dnn/dnn.hpp Node2 ostream Node1->Node2 Node3 vector Node1->Node3 Node4 opencv2/core.hpp Node1->Node4 Node52 opencv2/core/async.hpp Node1->Node52 Node54 ../dnn/version.hpp Node1->Node54 Node55 opencv2/dnn/dict.hpp Node1->Node55 Node57 opencv2/dnn/layer.hpp Node1->Node57 Node59 opencv2/dnn/dnn.inl.hpp Node1->Node59 Node60 opencv2/dnn/utils/inference _engine.hpp Node1->Node60 Node5 opencv2/core/cvdef.h Node4->Node5 Node12 opencv2/core/base.hpp Node4->Node12 Node16 opencv2/core/cvstd.hpp Node4->Node16 Node32 opencv2/core/traits.hpp Node4->Node32 Node33 opencv2/core/matx.hpp Node4->Node33 Node38 opencv2/core/types.hpp Node4->Node38 Node40 opencv2/core/mat.hpp Node4->Node40 Node44 opencv2/core/persistence.hpp Node4->Node44 Node45 opencv2/core/operations.hpp Node4->Node45 Node47 opencv2/core/cvstd.inl.hpp Node4->Node47 Node48 opencv2/core/utility.hpp Node4->Node48 Node51 opencv2/core/optim.hpp Node4->Node51 Node6 opencv2/core/version.hpp Node5->Node6 Node7 limits Node5->Node7 Node8 opencv2/core/hal/interface.h Node5->Node8 Node10 cstdint Node5->Node10 Node11 cv_cpu_dispatch.h Node5->Node11 Node9 cstddef Node8->Node9 Node8->Node10 Node12->Node5 Node13 opencv2/opencv_modules.hpp Node12->Node13 Node14 climits Node12->Node14 Node15 algorithm Node12->Node15 Node12->Node16 Node26 opencv2/core/fwddecl.hpp Node12->Node26 Node27 opencv2/core/neon_utils.hpp Node12->Node27 Node28 opencv2/core/vsx_utils.hpp Node12->Node28 Node30 opencv2/core/exception.hpp Node12->Node30 Node31 opencv2/core/check.hpp Node12->Node31 Node16->Node5 Node16->Node9 Node16->Node15 Node17 cstring Node16->Node17 Node18 cctype Node16->Node18 Node19 string Node16->Node19 Node20 utility Node16->Node20 Node21 cstdlib Node16->Node21 Node22 cmath Node16->Node22 Node23 cvstd_wrapper.hpp Node16->Node23 Node23->Node5 Node23->Node19 Node24 memory Node23->Node24 Node25 type_traits Node23->Node25 Node26->Node5 Node27->Node5 Node28->Node5 Node29 assert.h Node28->Node29 Node30->Node5 Node30->Node16 Node31->Node5 Node31->Node16 Node31->Node26 Node32->Node5 Node33->Node5 Node33->Node12 Node33->Node32 Node34 opencv2/core/saturate.hpp Node33->Node34 Node36 initializer_list Node33->Node36 Node37 opencv2/core/matx.inl.hpp Node33->Node37 Node34->Node5 Node34->Node14 Node35 opencv2/core/fast_math.hpp Node34->Node35 Node35->Node5 Node35->Node22 Node38->Node3 Node38->Node5 Node38->Node7 Node38->Node14 Node38->Node16 Node38->Node33 Node39 cfloat Node38->Node39 Node40->Node25 Node40->Node33 Node40->Node38 Node41 opencv2/core/bufferpool.hpp Node40->Node41 Node42 array Node40->Node42 Node43 opencv2/core/mat.inl.hpp Node40->Node43 Node44->Node38 Node44->Node40 Node45->Node2 Node46 cstdio Node45->Node46 Node48->Node2 Node48->Node4 Node49 functional Node48->Node49 Node50 mutex Node48->Node50 Node51->Node4 Node52->Node40 Node53 chrono Node52->Node53 Node55->Node1 Node55->Node2 Node55->Node4 Node56 map Node55->Node56 Node58 opencv2/dnn.hpp Node57->Node58 Node58->Node1 Node60->Node1

This graph shows which files directly or indirectly include dnn.hpp:

incby nc8a7cf034f opencv2/dnn/all_layers.hpp n884fda277d opencv2/dnn.hpp nc8a7cf034f->n884fda277d nf394cddfac opencv2/dnn/utils/debug_utils.hpp nff502ad36d opencv2/dnn/dnn.hpp nf394cddfac->nff502ad36d n0b3ce81988 opencv2/dnn/dict.hpp n0b3ce81988->nff502ad36d nff502ad36d->n0b3ce81988 n8f71958174 opencv2/dnn/utils/inference_engine.hpp nff502ad36d->n8f71958174 n1f590f3374 opencv2/dnn/layer.hpp nff502ad36d->n1f590f3374 n884fda277d->nff502ad36d n652930f76d opencv2/dnn_superres.hpp n652930f76d->n884fda277d n8f71958174->nff502ad36d n31abec1ee2 opencv2/dnn/layer.details.hpp n31abec1ee2->n1f590f3374 n1f590f3374->n884fda277d ncfd40fef64 opencv2/dnn/layer_reg.private.hpp ncfd40fef64->n884fda277d n3d71776062 opencv2/dnn/shape_utils.hpp n3d71776062->nff502ad36d

incby nc8a7cf034f opencv2/dnn/all_layers.hpp n884fda277d opencv2/dnn.hpp nc8a7cf034f->n884fda277d nf394cddfac opencv2/dnn/utils/debug_utils.hpp nff502ad36d opencv2/dnn/dnn.hpp nf394cddfac->nff502ad36d n0b3ce81988 opencv2/dnn/dict.hpp n0b3ce81988->nff502ad36d nff502ad36d->n0b3ce81988 n8f71958174 opencv2/dnn/utils/inference_engine.hpp nff502ad36d->n8f71958174 n1f590f3374 opencv2/dnn/layer.hpp nff502ad36d->n1f590f3374 n884fda277d->nff502ad36d n652930f76d opencv2/dnn_superres.hpp n652930f76d->n884fda277d n8f71958174->nff502ad36d n31abec1ee2 opencv2/dnn/layer.details.hpp n31abec1ee2->n1f590f3374 n1f590f3374->n884fda277d ncfd40fef64 opencv2/dnn/layer_reg.private.hpp ncfd40fef64->n884fda277d n3d71776062 opencv2/dnn/shape_utils.hpp n3d71776062->nff502ad36d

Classes#

struct cv::dnn::Arg
struct cv::dnn::ArgData
class cv::dnn::BackendNode

Derivatives of this class encapsulates functions of certain backends. More…

class cv::dnn::BackendWrapper

Derivatives of this class wraps cv::Mat for different backends and targets. More…

class cv::dnn::ClassificationModel

This class represents high-level API for classification models. More…

class cv::dnn::DetectionModel

This class represents high-level API for object detection networks. More…

class cv::dnn::Graph

Represents graph or subgraph of a model. The graph (in mathematical terms it’s rather a multigraph) is represented as a topologically-sorted linear sequence of operations. Each operation is a smart pointer to a Layer (some of its derivative class instance), which includes a list of inputs and outputs, as well as an optional list of subgraphs (e.g. ‘If’ contains 2 subgraphs). More…

struct cv::dnn::Image2BlobParams

Processing params of image to blob. More…

class cv::dnn::KeypointsModel

This class represents high-level API for keypoints models. More…

class cv::dnn::Layer

This interface class allows to build new Layers - are building blocks of networks. More…

class cv::dnn::LayerParams

This class provides all data needed to initialize layer. More…

class cv::dnn::Model

This class is presented high-level API for neural networks. More…

class cv::dnn::Net

This class allows to create and manipulate comprehensive artificial neural networks. More…

class cv::dnn::SegmentationModel

This class represents high-level API for segmentation models. More…

class cv::dnn::TextDetectionModel

Base class for text detection networks. More…

class cv::dnn::TextDetectionModel_DB

This class represents high-level API for text detection DL networks compatible with DB model. More…

class cv::dnn::TextDetectionModel_EAST

This class represents high-level API for text detection DL networks compatible with EAST model. More…

class cv::dnn::TextRecognitionModel

This class represents high-level API for text recognition networks. More…

class cv::dnn::Tokenizer

High-level tokenizer wrapper for DNN usage. More…

Namespaces#

namespace cv
namespace cv::dnn
namespace cv::dnn::accessor

Enumerations#

enum cv::dnn::ArgKind {
DNN_ARG_EMPTY =0,
DNN_ARG_CONST =1,
DNN_ARG_INPUT =2,
DNN_ARG_OUTPUT =3,
DNN_ARG_TEMP =4,
DNN_ARG_PATTERN =5
}
enum cv::dnn::Backend {
DNN_BACKEND_DEFAULT = 0,
DNN_BACKEND_INFERENCE_ENGINE = 2,
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 cv::dnn::EngineType {
ENGINE_CLASSIC =1,
ENGINE_NEW =2,
ENGINE_AUTO =3,
ENGINE_ORT =4
}
enum cv::dnn::ImagePaddingMode {
DNN_PMODE_NULL = 0,
DNN_PMODE_CROP_CENTER = 1,
DNN_PMODE_LETTERBOX = 2
}

Enum of image processing mode. To facilitate the specialization pre-processing requirements of the dnn model. For example, the letter box often used in the Yolo series of models. More…

enum cv::dnn::ModelFormat {
DNN_MODEL_GENERIC = 0,
DNN_MODEL_ONNX = 1,
DNN_MODEL_TF = 2,
DNN_MODEL_TFLITE = 3
}
enum cv::dnn::ProfilingMode {
DNN_PROFILE_NONE = 0,
DNN_PROFILE_SUMMARY = 1,
DNN_PROFILE_DETAILED = 2
}
enum cv::dnn::SoftNMSMethod {
SOFTNMS_LINEAR = 1,
SOFTNMS_GAUSSIAN = 2
}

Enum of Soft NMS methods. More…

enum cv::dnn::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,
DNN_TARGET_CPU_FP16
}

Enum of target devices for computations. More…

enum cv::dnn::TracingMode {
DNN_TRACE_NONE = 0,
DNN_TRACE_ALL = 1,
DNN_TRACE_OP = 2
}

Functions#

std::string cv::dnn::argKindToString (ArgKind kind)
Mat cv::dnn::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.

void cv::dnn::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.

Mat cv::dnn::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.

void cv::dnn::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.

Mat cv::dnn::blobFromImagesWithParams (InputArrayOfArrays images, const Image2BlobParams &param=Image2BlobParams())

Creates 4-dimensional blob from series of images with given params.

void cv::dnn::blobFromImagesWithParams (InputArrayOfArrays images, OutputArray blob, const Image2BlobParams &param=Image2BlobParams())
Mat cv::dnn::blobFromImageWithParams (InputArray image, const Image2BlobParams &param=Image2BlobParams())

Creates 4-dimensional blob from image with given params.

void cv::dnn::blobFromImageWithParams (InputArray image, OutputArray blob, const Image2BlobParams &param=Image2BlobParams())
void cv::dnn::enableModelDiagnostics (bool isDiagnosticsMode)

Enables detailed logging of the DNN model loading with CV DNN API.

std::vector< std::pair< Backend, Target > > cv::dnn::getAvailableBackends ()
std::vector< Target > cv::dnn::getAvailableTargets (dnn::Backend be)
void cv::dnn::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>).

std::string cv::dnn::modelFormatToString (ModelFormat modelFormat)
void cv::dnn::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.

void cv::dnn::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 cv::dnn::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 cv::dnn::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.

void cv::dnn::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)
Net cv::dnn::readNet (const String &framework, const std::vector< uchar > &bufferModel, const std::vector< uchar > &bufferConfig=std::vector< uchar >(), int engine=ENGINE_AUTO)

Read deep learning network represented in one of the supported formats.

Net cv::dnn::readNet (CV_WRAP_FILE_PATH const String &model, CV_WRAP_FILE_PATH const String &config=“”, const String &framework=“”, int engine=ENGINE_AUTO)

Read deep learning network represented in one of the supported formats.

Net cv::dnn::readNetFromModelOptimizer (const std::vector< uchar > &bufferModelConfig, const std::vector< uchar > &bufferWeights)

Load a network from Intel’s Model Optimizer intermediate representation.

Net cv::dnn::readNetFromModelOptimizer (const uchar *bufferModelConfigPtr, size_t bufferModelConfigSize, const uchar *bufferWeightsPtr, size_t bufferWeightsSize)

Load a network from Intel’s Model Optimizer intermediate representation.

Net cv::dnn::readNetFromModelOptimizer (CV_WRAP_FILE_PATH const String &xml, CV_WRAP_FILE_PATH const String &bin=“”)

Load a network from Intel’s Model Optimizer intermediate representation.

Net cv::dnn::readNetFromONNX (const char *buffer, size_t sizeBuffer, int engine=ENGINE_AUTO)

Reads a network model from ONNX in-memory buffer.

Net cv::dnn::readNetFromONNX (const std::vector< uchar > &buffer, int engine=ENGINE_AUTO)

Reads a network model from ONNX in-memory buffer.

Net cv::dnn::readNetFromONNX (CV_WRAP_FILE_PATH const String &onnxFile, int engine=ENGINE_AUTO)

Reads a network model ONNX.

Net cv::dnn::readNetFromTensorflow (const char *bufferModel, size_t lenModel, const char *bufferConfig=NULL, size_t lenConfig=0, int engine=ENGINE_AUTO, const std::vector< String > &extraOutputs=std::vector< String >())

Reads a network model stored in TensorFlow framework’s format.

Net cv::dnn::readNetFromTensorflow (const std::vector< uchar > &bufferModel, const std::vector< uchar > &bufferConfig=std::vector< uchar >(), int engine=ENGINE_AUTO, const std::vector< String > &extraOutputs=std::vector< String >())

Reads a network model stored in TensorFlow framework’s format.

Net cv::dnn::readNetFromTensorflow (CV_WRAP_FILE_PATH const String &model, CV_WRAP_FILE_PATH const String &config=String(), int engine=ENGINE_AUTO, const std::vector< String > &extraOutputs=std::vector< String >())

Reads a network model stored in TensorFlow framework’s format.

Net cv::dnn::readNetFromTFLite (const char *bufferModel, size_t lenModel, int engine=ENGINE_AUTO)

Reads a network model stored in TFLite framework’s format.

Net cv::dnn::readNetFromTFLite (const std::vector< uchar > &bufferModel, int engine=ENGINE_AUTO)

Reads a network model stored in TFLite framework’s format.

Net cv::dnn::readNetFromTFLite (CV_WRAP_FILE_PATH const String &model, int engine=ENGINE_AUTO)

Reads a network model stored in TFLite framework’s format.

Mat cv::dnn::readTensorFromONNX (CV_WRAP_FILE_PATH const String &path)

Creates blob from .pb file.

void cv::dnn::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.

void cv::dnn::writeTextGraph (CV_WRAP_FILE_PATH const String &model, CV_WRAP_FILE_PATH const String &output)

Create a text representation for a binary network stored in protocol buffer format.