Class Model
java.lang.Object
org.opencv.dnn.Model
- Direct Known Subclasses:
ClassificationModel, DetectionModel, KeypointsModel, SegmentationModel, TextDetectionModel, TextRecognitionModel
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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedModel(long addr) Create model from deep learning network represented in one of the supported formats.Create model from deep learning network represented in one of the supported formats.Create model from deep learning network. -
Method Summary
Modifier and TypeMethodDescriptionstatic Model__fromPtr__(long addr) enableWinograd(boolean useWinograd) protected voidfinalize()longvoidGiven theinputframe, create input blob, run net and return the outputblobs.setInputCrop(boolean crop) Set flag crop for frame.setInputMean(Scalar mean) Set mean value for frame.voidSet preprocessing parameters for frame.voidsetInputParams(double scale) Set preprocessing parameters for frame.voidsetInputParams(double scale, Size size) Set preprocessing parameters for frame.voidsetInputParams(double scale, Size size, Scalar mean) Set preprocessing parameters for frame.voidsetInputParams(double scale, Size size, Scalar mean, boolean swapRB) Set preprocessing parameters for frame.voidsetInputParams(double scale, Size size, Scalar mean, boolean swapRB, boolean crop) Set preprocessing parameters for frame.setInputScale(Scalar scale) Set scalefactor value for frame.setInputSize(int width, int height) setInputSize(Size size) Set input size for frame.setInputSwapRB(boolean swapRB) Set flag swapRB for frame.setOutputNames(List<String> outNames) Set output names for frame.setPreferableBackend(int backendId) setPreferableTarget(int targetId)
-
Field Details
-
nativeObj
protected final long nativeObj
-
-
Constructor Details
-
Model
protected Model(long addr) -
Model
-
Model
Create model from deep learning network represented in one of the supported formats. An order ofmodelandconfigarguments does not matter.- Parameters:
model- Binary file contains trained weights.
-
Model
Create model from deep learning network.- Parameters:
network- Net object.
-
-
Method Details
-
getNativeObjAddr
public long getNativeObjAddr() -
__fromPtr__
-
setInputSize
-
setInputSize
- Parameters:
width- New input width.height- New input height.- Returns:
- automatically generated
-
setInputMean
-
setInputScale
-
setInputCrop
Set flag crop for frame.- Parameters:
crop- Flag which indicates whether image will be cropped after resize or not.- Returns:
- automatically generated
-
setInputSwapRB
Set flag swapRB for frame.- Parameters:
swapRB- Flag which indicates that swap first and last channels.- Returns:
- automatically generated
-
setOutputNames
-
setInputParams
Set preprocessing parameters for frame.- Parameters:
scale- Multiplier for frame values.size- New input size.mean- Scalar with mean values which are subtracted from channels.swapRB- Flag which indicates that swap first and last channels.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) )
-
setInputParams
Set preprocessing parameters for frame.- Parameters:
scale- Multiplier for frame values.size- New input size.mean- Scalar with mean values which are subtracted from channels.swapRB- Flag which indicates that swap first and last channels. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
-
setInputParams
Set preprocessing parameters for frame.- Parameters:
scale- Multiplier for frame values. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )size- New input size.mean- Scalar with mean values which are subtracted from channels.
-
setInputParams
Set preprocessing parameters for frame.- Parameters:
scale- Multiplier for frame values. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )size- New input size.
-
setInputParams
public void setInputParams(double scale) Set preprocessing parameters for frame.- Parameters:
scale- Multiplier for frame values. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
-
setInputParams
public void setInputParams()Set preprocessing parameters for frame. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) ) -
predict
-
setPreferableBackend
-
setPreferableTarget
-
enableWinograd
-
finalize
-