OpenCV for Unity  2.6.3
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
OpenCVForUnity.DnnModule.Model Class Reference

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

Inheritance diagram for OpenCVForUnity.DnnModule.Model:
OpenCVForUnity.DisposableOpenCVObject OpenCVForUnity.DisposableObject OpenCVForUnity.DnnModule.ClassificationModel OpenCVForUnity.DnnModule.DetectionModel OpenCVForUnity.DnnModule.KeypointsModel OpenCVForUnity.DnnModule.SegmentationModel OpenCVForUnity.DnnModule.TextDetectionModel OpenCVForUnity.DnnModule.TextRecognitionModel OpenCVForUnity.DnnModule.TextDetectionModel_DB OpenCVForUnity.DnnModule.TextDetectionModel_EAST

Public Member Functions

IntPtr getNativeObjAddr ()
 
 Model (string model, 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 (string model)
 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 (Net network)
 Create model from deep learning network. More...
 
Model setInputSize (Size size)
 Set input size for frame. More...
 
Model setInputSize (int width, int height)
 
Model setInputMean (Scalar mean)
 Set mean value for frame. More...
 
Model setInputScale (Scalar scale)
 Set scalefactor value for frame. More...
 
Model setInputCrop (bool crop)
 Set flag crop for frame. More...
 
Model setInputSwapRB (bool swapRB)
 Set flag swapRB for frame. More...
 
Model setOutputNames (List< string > outNames)
 Set output names for frame. More...
 
void setInputParams (double scale, Size size, Scalar mean, bool swapRB, bool crop)
 Set preprocessing parameters for frame. More...
 
void setInputParams (double scale, Size size, Scalar mean, bool swapRB)
 Set preprocessing parameters for frame. More...
 
void setInputParams (double scale, Size size, Scalar mean)
 Set preprocessing parameters for frame. More...
 
void setInputParams (double scale, Size size)
 Set preprocessing parameters for frame. More...
 
void setInputParams (double scale)
 Set preprocessing parameters for frame. More...
 
void setInputParams ()
 Set preprocessing parameters for frame. More...
 
void predict (Mat frame, List< Mat > outs)
 Given the input frame, create input blob, run net and return the output blobs. More...
 
Model setPreferableBackend (int backendId)
 
Model setPreferableTarget (int targetId)
 
Model enableWinograd (bool useWinograd)
 
- Public Member Functions inherited from OpenCVForUnity.DisposableObject
void Dispose ()
 
void ThrowIfDisposed ()
 

Static Public Member Functions

static Model __fromPtr__ (IntPtr addr)
 
- Static Public Member Functions inherited from OpenCVForUnity.DisposableObject
static IntPtr ThrowIfNullIntPtr (IntPtr ptr)
 

Protected Member Functions

override void Dispose (bool disposing)
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableOpenCVObject
 DisposableOpenCVObject ()
 
 DisposableOpenCVObject (IntPtr ptr)
 
 DisposableOpenCVObject (bool isEnabledDispose)
 
 DisposableOpenCVObject (IntPtr ptr, bool isEnabledDispose)
 
- Protected Member Functions inherited from OpenCVForUnity.DisposableObject
 DisposableObject ()
 
 DisposableObject (bool isEnabledDispose)
 

Additional Inherited Members

- Properties inherited from OpenCVForUnity.DisposableObject
bool IsDisposed [get, protected set]
 
bool IsEnabledDispose [get, set]
 

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/3]

OpenCVForUnity.DnnModule.Model.Model ( string  model,
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() [2/3]

OpenCVForUnity.DnnModule.Model.Model ( string  model)

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() [3/3]

OpenCVForUnity.DnnModule.Model.Model ( Net  network)

Create model from deep learning network.

Parameters
[in]networkNet object.

Member Function Documentation

◆ __fromPtr__()

static Model OpenCVForUnity.DnnModule.Model.__fromPtr__ ( IntPtr  addr)
static

◆ Dispose()

override void OpenCVForUnity.DnnModule.Model.Dispose ( bool  disposing)
protectedvirtual

◆ enableWinograd()

Model OpenCVForUnity.DnnModule.Model.enableWinograd ( bool  useWinograd)

◆ getNativeObjAddr()

IntPtr OpenCVForUnity.DnnModule.Model.getNativeObjAddr ( )

◆ predict()

void OpenCVForUnity.DnnModule.Model.predict ( Mat  frame,
List< Mat 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 OpenCVForUnity.DnnModule.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 OpenCVForUnity.DnnModule.Model.setInputMean ( Scalar  mean)

Set mean value for frame.

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

◆ setInputParams() [1/6]

void OpenCVForUnity.DnnModule.Model.setInputParams ( double  scale,
Size  size,
Scalar  mean,
bool  swapRB,
bool  crop 
)

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) )

◆ setInputParams() [2/6]

void OpenCVForUnity.DnnModule.Model.setInputParams ( double  scale,
Size  size,
Scalar  mean,
bool  swapRB 
)

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) )

◆ setInputParams() [3/6]

void OpenCVForUnity.DnnModule.Model.setInputParams ( double  scale,
Size  size,
Scalar  mean 
)

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) )

◆ setInputParams() [4/6]

void OpenCVForUnity.DnnModule.Model.setInputParams ( double  scale,
Size  size 
)

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) )

◆ setInputParams() [5/6]

void OpenCVForUnity.DnnModule.Model.setInputParams ( double  scale)

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) )

◆ setInputParams() [6/6]

void OpenCVForUnity.DnnModule.Model.setInputParams ( )

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 OpenCVForUnity.DnnModule.Model.setInputScale ( Scalar  scale)

Set scalefactor value for frame.

Parameters
[in]scaleMultiplier for frame values.

◆ setInputSize() [1/2]

Model OpenCVForUnity.DnnModule.Model.setInputSize ( 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 OpenCVForUnity.DnnModule.Model.setInputSize ( int  width,
int  height 
)

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 OpenCVForUnity.DnnModule.Model.setInputSwapRB ( bool  swapRB)

Set flag swapRB for frame.

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

◆ setOutputNames()

Model OpenCVForUnity.DnnModule.Model.setOutputNames ( List< string >  outNames)

Set output names for frame.

Parameters
[in]outNamesNames for output layers.

◆ setPreferableBackend()

Model OpenCVForUnity.DnnModule.Model.setPreferableBackend ( int  backendId)

◆ setPreferableTarget()

Model OpenCVForUnity.DnnModule.Model.setPreferableTarget ( int  targetId)

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