Class OpenCVModel
Object
OpenCVModel
- All Implemented Interfaces:
AutoCloseable,ImageInferenceModel<org.opencv.core.Mat>,InferenceModel
A model that can be used for inference using OpenCV's DNN
module.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Indicates that the model will no longer be used, and does appropriate tidying up and freeing of resources.<S> SperformInference(org.opencv.core.Mat input, String inputName, List<String> outputNames, CheckedFunction<List<org.opencv.core.Mat>, S, OperationFailedException> convertFunction) Performs inference on a single-input, to create an output.
-
Constructor Details
-
OpenCVModel
public OpenCVModel(org.opencv.dnn.Net model) Creates a newOpenCVModelinstance.- Parameters:
model- An OpenCV model used for inference.
-
-
Method Details
-
performInference
public <S> S performInference(org.opencv.core.Mat input, String inputName, List<String> outputNames, CheckedFunction<List<org.opencv.core.Mat>, S, throws OperationFailedExceptionOperationFailedException> convertFunction) Description copied from interface:ImageInferenceModelPerforms inference on a single-input, to create an output.- Specified by:
performInferencein interfaceImageInferenceModel<org.opencv.core.Mat>- Type Parameters:
S- the data-type the output is exposed as.- Parameters:
input- the input for inference.inputName- the name associated withinputin the model.outputNames-convertFunction- converts the output to type<S>.- Returns:
- the converted output.
- Throws:
OperationFailedException- if the inference cannot successfully complete.
-
close
public void close()Description copied from interface:InferenceModelIndicates that the model will no longer be used, and does appropriate tidying up and freeing of resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceInferenceModel
-