Class OpenCVModel

Object
OpenCVModel
All Implemented Interfaces:
AutoCloseable, ImageInferenceModel<org.opencv.core.Mat>, InferenceModel

public class OpenCVModel extends Object implements ImageInferenceModel<org.opencv.core.Mat>
A model that can be used for inference using OpenCV's DNN module.
Author:
Owen Feehan
  • Constructor Details

    • OpenCVModel

      public OpenCVModel(org.opencv.dnn.Net model)
      Creates a new OpenCVModel 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,OperationFailedException> convertFunction) throws OperationFailedException
      Description copied from interface: ImageInferenceModel
      Performs inference on a single-input, to create an output.
      Specified by:
      performInference in interface ImageInferenceModel<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 with input 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 interface AutoCloseable
      Specified by:
      close in interface InferenceModel