Package org.opencv.dnn
Class Model
- java.lang.Object
- 
- org.opencv.dnn.Model
 
- 
- Direct Known Subclasses:
- ClassificationModel,- DetectionModel,- KeypointsModel,- SegmentationModel,- TextDetectionModel,- TextRecognitionModel
 
 public class Model extends java.lang.ObjectThis 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 SummaryFields Modifier and Type Field Description protected longnativeObj
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedModel(long addr)Model(java.lang.String model)Create model from deep learning network represented in one of the supported formats.Model(java.lang.String model, java.lang.String config)Create model from deep learning network represented in one of the supported formats.Model(Net network)Create model from deep learning network.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Model__fromPtr__(long addr)protected voidfinalize()longgetNativeObjAddr()voidpredict(Mat frame, java.util.List<Mat> outs)Given theinputframe, create input blob, run net and return the outputblobs.ModelsetInputCrop(boolean crop)Set flag crop for frame.ModelsetInputMean(Scalar mean)Set mean value for frame.voidsetInputParams()Set 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.ModelsetInputScale(double scale)Set scalefactor value for frame.ModelsetInputSize(int width, int height)ModelsetInputSize(Size size)Set input size for frame.ModelsetInputSwapRB(boolean swapRB)Set flag swapRB for frame.ModelsetPreferableBackend(int backendId)ModelsetPreferableTarget(int targetId)
 
- 
- 
- 
Constructor Detail- 
Modelprotected Model(long addr) 
 - 
Modelpublic Model(java.lang.String model, java.lang.String config)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.
- config- Text file contains network configuration.
 
 - 
Modelpublic Model(java.lang.String 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.
 
 - 
Modelpublic Model(Net network) Create model from deep learning network.- Parameters:
- network- Net object.
 
 
- 
 - 
Method Detail- 
getNativeObjAddrpublic long getNativeObjAddr() 
 - 
__fromPtr__public static Model __fromPtr__(long addr) 
 - 
setInputSizepublic Model setInputSize(Size size) Set input size for frame.- Parameters:
- size- New input size. Note: If shape of the new blob less than 0, then frame size not change.
- Returns:
- automatically generated
 
 - 
setInputSizepublic Model setInputSize(int width, int height) - Parameters:
- width- New input width.
- height- New input height.
- Returns:
- automatically generated
 
 - 
setInputMeanpublic Model setInputMean(Scalar mean) Set mean value for frame.- Parameters:
- mean- Scalar with mean values which are subtracted from channels.
- Returns:
- automatically generated
 
 - 
setInputScalepublic Model setInputScale(double scale) Set scalefactor value for frame.- Parameters:
- scale- Multiplier for frame values.
- Returns:
- automatically generated
 
 - 
setInputCroppublic Model setInputCrop(boolean crop) Set flag crop for frame.- Parameters:
- crop- Flag which indicates whether image will be cropped after resize or not.
- Returns:
- automatically generated
 
 - 
setInputSwapRBpublic Model setInputSwapRB(boolean swapRB) Set flag swapRB for frame.- Parameters:
- swapRB- Flag which indicates that swap first and last channels.
- Returns:
- automatically generated
 
 - 
setInputParamspublic void setInputParams(double scale, Size size, Scalar mean, boolean swapRB, boolean crop)Set preprocessing parameters for frame.- Parameters:
- size- New input size.
- mean- Scalar with mean values which are subtracted from channels.
- scale- Multiplier for frame values.
- 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) )
 
 - 
setInputParamspublic void setInputParams(double scale, Size size, Scalar mean, boolean swapRB)Set preprocessing parameters for frame.- Parameters:
- size- New input size.
- mean- Scalar with mean values which are subtracted from channels.
- scale- Multiplier for frame values.
- swapRB- Flag which indicates that swap first and last channels. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
 
 - 
setInputParamspublic void setInputParams(double scale, Size size, Scalar mean)Set preprocessing parameters for frame.- Parameters:
- size- New input size.
- mean- Scalar with mean values which are subtracted from channels.
- scale- Multiplier for frame values. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
 
 - 
setInputParamspublic void setInputParams(double scale, Size size)Set preprocessing parameters for frame.- Parameters:
- size- New input size.
- scale- Multiplier for frame values. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
 
 - 
setInputParamspublic 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) )
 
 - 
setInputParamspublic void setInputParams() Set preprocessing parameters for frame. blob(n, c, y, x) = scale * resize( frame(y, x, c) ) - mean(c) )
 - 
predictpublic void predict(Mat frame, java.util.List<Mat> outs) Given theinputframe, create input blob, run net and return the outputblobs.- Parameters:
- outs- Allocated output blobs, which will store results of the computation.
- frame- automatically generated
 
 - 
setPreferableBackendpublic Model setPreferableBackend(int backendId) 
 - 
setPreferableTargetpublic Model setPreferableTarget(int targetId) 
 - 
finalizeprotected void finalize() throws java.lang.Throwable- Overrides:
- finalizein class- java.lang.Object
- Throws:
- java.lang.Throwable
 
 
- 
 
-