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 TypeMethodDescriptionvoid
close()
Indicates that the model will no longer be used, and does appropriate tidying up and freeing of resources.<S> S
performInference
(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 newOpenCVModel
instance.- 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:ImageInferenceModel
Performs inference on a single-input, to create an output.- Specified by:
performInference
in 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 withinput
in 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:InferenceModel
Indicates that the model will no longer be used, and does appropriate tidying up and freeing of resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceInferenceModel
-