OpenCV 4.13.0
Open Source Computer Vision
Loading...
Searching...
No Matches
cv::dnn::Model Class Reference

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

#include <opencv2/dnn/dnn.hpp>

Collaboration diagram for cv::dnn::Model:

Public Member Functions

 Model ()
 Model (const Model &)=default
 Model (const Net &network)
 Create model from deep learning network.
 Model (CV_WRAP_FILE_PATH const String &model, CV_WRAP_FILE_PATH 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
ModelenableWinograd (bool useWinograd)
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.
ModelsetOutputNames (const std::vector< String > &outNames)
 Set output names 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 ( )
Python:
cv.dnn.Model(model[, config]) -> <dnn_Model object>
cv.dnn.Model(network) -> <dnn_Model object>

◆ Model() [2/5]

cv::dnn::Model::Model ( const Model & )
default
Python:
cv.dnn.Model(model[, config]) -> <dnn_Model object>
cv.dnn.Model(network) -> <dnn_Model object>
Here is the call graph for this function:

◆ Model() [3/5]

cv::dnn::Model::Model ( Model && )
default
Python:
cv.dnn.Model(model[, config]) -> <dnn_Model object>
cv.dnn.Model(network) -> <dnn_Model object>
Here is the call graph for this function:

◆ Model() [4/5]

cv::dnn::Model::Model ( CV_WRAP_FILE_PATH const String & model,
CV_WRAP_FILE_PATH const String & config = "" )
Python:
cv.dnn.Model(model[, config]) -> <dnn_Model object>
cv.dnn.Model(network) -> <dnn_Model object>

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)
Python:
cv.dnn.Model(model[, config]) -> <dnn_Model object>
cv.dnn.Model(network) -> <dnn_Model object>

Create model from deep learning network.

Parameters
[in]networkNet object.

Member Function Documentation

◆ enableWinograd()

Model & cv::dnn::Model::enableWinograd ( bool useWinograd)
Python:
cv.dnn.Model.enableWinograd(useWinograd) -> retval
See also
Net::enableWinograd
Here is the call graph for this function:

◆ 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
Here is the call graph for this function:

◆ getNetwork_() [2/2]

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

◆ operator Net &()

cv::dnn::Model::operator Net & ( ) const
inline
Here is the call graph for this function:

◆ operator=() [1/2]

Model & cv::dnn::Model::operator= ( const Model & )
default
Here is the call graph for this function:

◆ operator=() [2/2]

Model & cv::dnn::Model::operator= ( Model && )
default
Here is the call graph for this function:

◆ predict()

void cv::dnn::Model::predict ( InputArray frame,
OutputArrayOfArrays outs ) const
Python:
cv.dnn.Model.predict(frame[, outs]) -> outs

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)
Python:
cv.dnn.Model.setInputCrop(crop) -> retval

Set flag crop for frame.

Parameters
[in]cropFlag which indicates whether image will be cropped after resize or not.
Here is the call graph for this function:

◆ setInputMean()

Model & cv::dnn::Model::setInputMean ( const Scalar & mean)
Python:
cv.dnn.Model.setInputMean(mean) -> retval

Set mean value for frame.

Parameters
[in]meanScalar with mean values which are subtracted from channels.
Here is the call graph for this function:

◆ setInputParams()

void cv::dnn::Model::setInputParams ( double scale = 1.0,
const Size & size = Size(),
const Scalar & mean = Scalar(),
bool swapRB = false,
bool crop = false )
Python:
cv.dnn.Model.setInputParams([, scale[, size[, mean[, swapRB[, crop]]]]]) -> None

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) )
Here is the call graph for this function:

◆ setInputScale()

Model & cv::dnn::Model::setInputScale ( const Scalar & scale)
Python:
cv.dnn.Model.setInputScale(scale) -> retval

Set scalefactor value for frame.

Parameters
[in]scaleMultiplier for frame values.
Here is the call graph for this function:

◆ setInputSize() [1/2]

Model & cv::dnn::Model::setInputSize ( const Size & size)
Python:
cv.dnn.Model.setInputSize(size) -> retval
cv.dnn.Model.setInputSize(width, height) -> retval

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.
Here is the call graph for this function:

◆ setInputSize() [2/2]

Model & cv::dnn::Model::setInputSize ( int width,
int height )
inline
Python:
cv.dnn.Model.setInputSize(size) -> retval
cv.dnn.Model.setInputSize(width, height) -> retval

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.
Here is the call graph for this function:

◆ setInputSwapRB()

Model & cv::dnn::Model::setInputSwapRB ( bool swapRB)
Python:
cv.dnn.Model.setInputSwapRB(swapRB) -> retval

Set flag swapRB for frame.

Parameters
[in]swapRBFlag which indicates that swap first and last channels.
Here is the call graph for this function:

◆ setOutputNames()

Model & cv::dnn::Model::setOutputNames ( const std::vector< String > & outNames)
Python:
cv.dnn.Model.setOutputNames(outNames) -> retval

Set output names for frame.

Parameters
[in]outNamesNames for output layers.
Here is the call graph for this function:

◆ setPreferableBackend()

Model & cv::dnn::Model::setPreferableBackend ( dnn::Backend backendId)
Python:
cv.dnn.Model.setPreferableBackend(backendId) -> retval
See also
Net::setPreferableBackend
Here is the call graph for this function:

◆ setPreferableTarget()

Model & cv::dnn::Model::setPreferableTarget ( dnn::Target targetId)
Python:
cv.dnn.Model.setPreferableTarget(targetId) -> retval
See also
Net::setPreferableTarget
Here is the call graph for this function:

Member Data Documentation

◆ impl

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

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