![]() |
OpenCV
4.6.0
Open Source Computer Vision
|
This class is presented high-level API for neural networks. More...
#include <opencv2/dnn/dnn.hpp>
Public Member Functions | |
Model () | |
Model (const Model &)=default | |
Model (const Net &network) | |
Create model from deep learning network. More... | |
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. More... | |
Model (Model &&)=default | |
Impl * | getImpl () const |
Impl & | getImplRef () const |
Net & | getNetwork_ () |
Net & | getNetwork_ () const |
operator Net & () const | |
Model & | operator= (const Model &)=default |
Model & | operator= (Model &&)=default |
void | predict (InputArray frame, OutputArrayOfArrays outs) const |
Given the input frame, create input blob, run net and return the output blobs . More... | |
Model & | setInputCrop (bool crop) |
Set flag crop for frame. More... | |
Model & | setInputMean (const Scalar &mean) |
Set mean value for frame. More... | |
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. More... | |
Model & | setInputScale (double scale) |
Set scalefactor value for frame. More... | |
Model & | setInputSize (const Size &size) |
Set input size for frame. More... | |
Model & | setInputSize (int width, int height) |
Model & | setInputSwapRB (bool swapRB) |
Set flag swapRB for frame. More... | |
Model & | setPreferableBackend (dnn::Backend backendId) |
Model & | setPreferableTarget (dnn::Target targetId) |
Protected Attributes | |
Ptr< Impl > | impl |
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.
cv::dnn::Model::Model | ( | ) |
|
default |
|
default |
Create model from deep learning network represented in one of the supported formats. An order of model
and config
arguments does not matter.
[in] | model | Binary file contains trained weights. |
[in] | config | Text file contains network configuration. |
cv::dnn::Model::Model | ( | const Net & | network | ) |
Create model from deep learning network.
[in] | network | Net object. |
|
inline |
|
inline |
|
inline |
Net & cv::dnn::Model::getNetwork_ | ( | ) | const |
|
inline |
void cv::dnn::Model::predict | ( | InputArray | frame, |
OutputArrayOfArrays | outs | ||
) | const |
Given the input
frame, create input blob, run net and return the output blobs
.
[in] | frame | The input image. |
[out] | outs | Allocated output blobs, which will store results of the computation. |
Model & cv::dnn::Model::setInputCrop | ( | bool | crop | ) |
Set flag crop for frame.
[in] | crop | Flag which indicates whether image will be cropped after resize or not. |
Set mean value for frame.
[in] | mean | Scalar with mean values which are subtracted from channels. |
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.
[in] | size | New input size. |
[in] | mean | Scalar with mean values which are subtracted from channels. |
[in] | scale | Multiplier for frame values. |
[in] | swapRB | Flag which indicates that swap first and last channels. |
[in] | crop | Flag which indicates whether image will be cropped after resize or not. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) ) |
Model & cv::dnn::Model::setInputScale | ( | double | scale | ) |
Set scalefactor value for frame.
[in] | scale | Multiplier for frame values. |
Set input size for frame.
[in] | size | New input size. |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[in] | width | New input width. |
[in] | height | New input height. |
Model & cv::dnn::Model::setInputSwapRB | ( | bool | swapRB | ) |
Set flag swapRB for frame.
[in] | swapRB | Flag which indicates that swap first and last channels. |
Model & cv::dnn::Model::setPreferableBackend | ( | dnn::Backend | backendId | ) |
Model & cv::dnn::Model::setPreferableTarget | ( | dnn::Target | targetId | ) |
|
protected |