Loading...
Searching...
No Matches

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

#include <opencv2/dnn/dnn.hpp>

Inheritance diagram for cv::dnn::Model:
cv::dnn::ClassificationModel cv::dnn::DetectionModel cv::dnn::KeypointsModel cv::dnn::SegmentationModel cv::dnn::TextDetectionModel cv::dnn::TextRecognitionModel cv::dnn::TextDetectionModel_DB cv::dnn::TextDetectionModel_EAST

Public Member Functions

 Model ()
 
 Model (const Model &)=default
 
 Model (const Net &network)
 Create model from deep learning network.
 
 Model (const String &model, const String &config="")
 Create model from deep learning network represented in one of the supported formats. An order of model and config arguments does not matter.
 
 Model (Model &&)=default
 
Impl * getImpl () const
 
Impl & getImplRef () const
 
NetgetNetwork_ ()
 
NetgetNetwork_ () const
 
 operator Net & () const
 
Modeloperator= (const Model &)=default
 
Modeloperator= (Model &&)=default
 
void predict (InputArray frame, OutputArrayOfArrays outs) const
 Given the input frame, create input blob, run net and return the output blobs.
 
ModelsetInputCrop (bool crop)
 Set flag crop for frame.
 
ModelsetInputMean (const Scalar &mean)
 Set mean value for frame.
 
void setInputParams (double scale=1.0, const Size &size=Size(), const Scalar &mean=Scalar(), bool swapRB=false, bool crop=false)
 Set preprocessing parameters for frame.
 
ModelsetInputScale (const Scalar &scale)
 Set scalefactor value for frame.
 
ModelsetInputSize (const Size &size)
 Set input size for frame.
 
ModelsetInputSize (int width, int height)
 
ModelsetInputSwapRB (bool swapRB)
 Set flag swapRB for frame.
 
ModelsetPreferableBackend (dnn::Backend backendId)
 
ModelsetPreferableTarget (dnn::Target targetId)
 

Protected Attributes

Ptr< Impl > impl
 

Detailed Description

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

Model allows to set params for preprocessing input image. Model creates net from file with trained weights and config, sets preprocessing input and runs forward pass.

Constructor & Destructor Documentation

◆ Model() [1/5]

cv::dnn::Model::Model ( )

◆ Model() [2/5]

cv::dnn::Model::Model ( const Model )
default

◆ Model() [3/5]

cv::dnn::Model::Model ( Model &&  )
default

◆ Model() [4/5]

cv::dnn::Model::Model ( const String model,
const String config = "" 
)

Create model from deep learning network represented in one of the supported formats. An order of model and config arguments does not matter.

Parameters
[in]modelBinary file contains trained weights.
[in]configText file contains network configuration.

◆ Model() [5/5]

cv::dnn::Model::Model ( const Net network)

Create model from deep learning network.

Parameters
[in]networkNet object.

Member Function Documentation

◆ getImpl()

Impl * cv::dnn::Model::getImpl ( ) const
inline

◆ getImplRef()

Impl & cv::dnn::Model::getImplRef ( ) const
inline

◆ getNetwork_() [1/2]

Net & cv::dnn::Model::getNetwork_ ( )
inline

◆ getNetwork_() [2/2]

Net & cv::dnn::Model::getNetwork_ ( ) const

◆ operator Net &()

cv::dnn::Model::operator Net & ( ) const
inline

◆ operator=() [1/2]

Model & cv::dnn::Model::operator= ( const Model )
default

◆ operator=() [2/2]

Model & cv::dnn::Model::operator= ( Model &&  )
default

◆ predict()

void cv::dnn::Model::predict ( InputArray  frame,
OutputArrayOfArrays  outs 
) const

Given the input frame, create input blob, run net and return the output blobs.

Parameters
[in]frameThe input image.
[out]outsAllocated output blobs, which will store results of the computation.

◆ setInputCrop()

Model & cv::dnn::Model::setInputCrop ( bool  crop)

Set flag crop for frame.

Parameters
[in]cropFlag which indicates whether image will be cropped after resize or not.

◆ setInputMean()

Model & cv::dnn::Model::setInputMean ( const Scalar mean)

Set mean value for frame.

Parameters
[in]meanScalar with mean values which are subtracted from channels.

◆ setInputParams()

void cv::dnn::Model::setInputParams ( double  scale = 1.0,
const Size size = Size(),
const Scalar mean = Scalar(),
bool  swapRB = false,
bool  crop = false 
)

Set preprocessing parameters for frame.

Parameters
[in]sizeNew input size.
[in]meanScalar with mean values which are subtracted from channels.
[in]scaleMultiplier for frame values.
[in]swapRBFlag which indicates that swap first and last channels.
[in]cropFlag which indicates whether image will be cropped after resize or not. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )

◆ setInputScale()

Model & cv::dnn::Model::setInputScale ( const Scalar scale)

Set scalefactor value for frame.

Parameters
[in]scaleMultiplier for frame values.

◆ setInputSize() [1/2]

Model & cv::dnn::Model::setInputSize ( const Size size)

Set input size for frame.

Parameters
[in]sizeNew input size.
Note
If shape of the new blob less than 0, then frame size not change.

◆ setInputSize() [2/2]

Model & cv::dnn::Model::setInputSize ( int  width,
int  height 
)
inline

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

Parameters
[in]widthNew input width.
[in]heightNew input height.

◆ setInputSwapRB()

Model & cv::dnn::Model::setInputSwapRB ( bool  swapRB)

Set flag swapRB for frame.

Parameters
[in]swapRBFlag which indicates that swap first and last channels.

◆ setPreferableBackend()

Model & cv::dnn::Model::setPreferableBackend ( dnn::Backend  backendId)

◆ setPreferableTarget()

Model & cv::dnn::Model::setPreferableTarget ( dnn::Target  targetId)

Member Data Documentation

◆ impl

Ptr<Impl> cv::dnn::Model::impl
protected

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