Class Dnn

java.lang.Object
org.opencv.dnn.Dnn

public class Dnn extends Object
  • Field Details

  • Constructor Details

    • Dnn

      public Dnn()
  • Method Details

    • getAvailableTargets

      public static List<Integer> getAvailableTargets(int be)
    • readNetFromTensorflow

      public static Net readNetFromTensorflow(String model, String config, int engine, List<String> extraOutputs)
      Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
      Parameters:
      model - path to the .pb file with binary protobuf description of the network architecture
      config - path to the .pbtxt file that contains text graph definition in protobuf format. Resulting Net object is built by text graph using weights from a binary one that let us make it more flexible.
      engine - select DNN engine to be used. With auto selection the new engine is used.
      extraOutputs - specify model outputs explicitly, in addition to the outputs the graph analyzer finds. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTensorflow

      public static Net readNetFromTensorflow(String model, String config, int engine)
      Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
      Parameters:
      model - path to the .pb file with binary protobuf description of the network architecture
      config - path to the .pbtxt file that contains text graph definition in protobuf format. Resulting Net object is built by text graph using weights from a binary one that let us make it more flexible.
      engine - select DNN engine to be used. With auto selection the new engine is used. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTensorflow

      public static Net readNetFromTensorflow(String model, String config)
      Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
      Parameters:
      model - path to the .pb file with binary protobuf description of the network architecture
      config - path to the .pbtxt file that contains text graph definition in protobuf format. Resulting Net object is built by text graph using weights from a binary one that let us make it more flexible. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTensorflow

      public static Net readNetFromTensorflow(String model)
      Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
      Parameters:
      model - path to the .pb file with binary protobuf description of the network architecture Resulting Net object is built by text graph using weights from a binary one that let us make it more flexible. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTensorflow

      public static Net readNetFromTensorflow(MatOfByte bufferModel, MatOfByte bufferConfig, int engine, List<String> extraOutputs)
      Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
      Parameters:
      bufferModel - buffer containing the content of the pb file
      bufferConfig - buffer containing the content of the pbtxt file
      engine - select DNN engine to be used. With auto selection the new engine is used.
      extraOutputs - specify model outputs explicitly, in addition to the outputs the graph analyzer finds. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTensorflow

      public static Net readNetFromTensorflow(MatOfByte bufferModel, MatOfByte bufferConfig, int engine)
      Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
      Parameters:
      bufferModel - buffer containing the content of the pb file
      bufferConfig - buffer containing the content of the pbtxt file
      engine - select DNN engine to be used. With auto selection the new engine is used. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTensorflow

      public static Net readNetFromTensorflow(MatOfByte bufferModel, MatOfByte bufferConfig)
      Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
      Parameters:
      bufferModel - buffer containing the content of the pb file
      bufferConfig - buffer containing the content of the pbtxt file Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTensorflow

      public static Net readNetFromTensorflow(MatOfByte bufferModel)
      Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
      Parameters:
      bufferModel - buffer containing the content of the pb file Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTFLite

      public static Net readNetFromTFLite(String model, int engine)
      Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.
      Parameters:
      model - path to the .tflite file with binary flatbuffers description of the network architecture
      engine - select DNN engine to be used. With auto selection the new engine is used first and falls back to classic. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTFLite

      public static Net readNetFromTFLite(String model)
      Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.
      Parameters:
      model - path to the .tflite file with binary flatbuffers description of the network architecture Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTFLite

      public static Net readNetFromTFLite(MatOfByte bufferModel, int engine)
      Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.
      Parameters:
      bufferModel - buffer containing the content of the tflite file
      engine - select DNN engine to be used. With auto selection the new engine is used first and falls back to classic. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNetFromTFLite

      public static Net readNetFromTFLite(MatOfByte bufferModel)
      Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.
      Parameters:
      bufferModel - buffer containing the content of the tflite file Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Net object.
    • readNet

      public static Net readNet(String model, String config, String framework, int engine)
      Read deep learning network represented in one of the supported formats.
      Parameters:
      model - Binary file contains trained weights. The following file extensions are expected for models from different frameworks: * *.pb (TensorFlow, https://www.tensorflow.org/) * *.bin | *.onnx (OpenVINO, https://software.intel.com/openvino-toolkit) * *.onnx (ONNX, https://onnx.ai/)
      config - Text file contains network configuration. It could be a file with the following extensions: * *.pbtxt (TensorFlow, https://www.tensorflow.org/) * *.xml (OpenVINO, https://software.intel.com/openvino-toolkit)
      framework - Explicit framework name tag to determine a format.
      engine - select DNN engine to be used. With auto selection the new engine is used first and falls back to classic. Please pay attention that the new DNN does not support non-CPU back-ends for now. Use ENGINE_CLASSIC if you want to use other back-ends.
      Returns:
      Net object. This function automatically detects an origin framework of trained model and calls an appropriate function such REF: readNetFromTensorflow, REF: readNetFromONNX. An order of model and config arguments does not matter.
    • readNet

      public static Net readNet(String model, String config, String framework)
      Read deep learning network represented in one of the supported formats.
      Parameters:
      model - Binary file contains trained weights. The following file extensions are expected for models from different frameworks: * *.pb (TensorFlow, https://www.tensorflow.org/) * *.bin | *.onnx (OpenVINO, https://software.intel.com/openvino-toolkit) * *.onnx (ONNX, https://onnx.ai/)
      config - Text file contains network configuration. It could be a file with the following extensions: * *.pbtxt (TensorFlow, https://www.tensorflow.org/) * *.xml (OpenVINO, https://software.intel.com/openvino-toolkit)
      framework - Explicit framework name tag to determine a format. Please pay attention that the new DNN does not support non-CPU back-ends for now. Use ENGINE_CLASSIC if you want to use other back-ends.
      Returns:
      Net object. This function automatically detects an origin framework of trained model and calls an appropriate function such REF: readNetFromTensorflow, REF: readNetFromONNX. An order of model and config arguments does not matter.
    • readNet

      public static Net readNet(String model, String config)
      Read deep learning network represented in one of the supported formats.
      Parameters:
      model - Binary file contains trained weights. The following file extensions are expected for models from different frameworks: * *.pb (TensorFlow, https://www.tensorflow.org/) * *.bin | *.onnx (OpenVINO, https://software.intel.com/openvino-toolkit) * *.onnx (ONNX, https://onnx.ai/)
      config - Text file contains network configuration. It could be a file with the following extensions: * *.pbtxt (TensorFlow, https://www.tensorflow.org/) * *.xml (OpenVINO, https://software.intel.com/openvino-toolkit) Please pay attention that the new DNN does not support non-CPU back-ends for now. Use ENGINE_CLASSIC if you want to use other back-ends.
      Returns:
      Net object. This function automatically detects an origin framework of trained model and calls an appropriate function such REF: readNetFromTensorflow, REF: readNetFromONNX. An order of model and config arguments does not matter.
    • readNet

      public static Net readNet(String model)
      Read deep learning network represented in one of the supported formats.
      Parameters:
      model - Binary file contains trained weights. The following file extensions are expected for models from different frameworks: * *.pb (TensorFlow, https://www.tensorflow.org/) * *.bin | *.onnx (OpenVINO, https://software.intel.com/openvino-toolkit) * *.onnx (ONNX, https://onnx.ai/) file with the following extensions: * *.pbtxt (TensorFlow, https://www.tensorflow.org/) * *.xml (OpenVINO, https://software.intel.com/openvino-toolkit) Please pay attention that the new DNN does not support non-CPU back-ends for now. Use ENGINE_CLASSIC if you want to use other back-ends.
      Returns:
      Net object. This function automatically detects an origin framework of trained model and calls an appropriate function such REF: readNetFromTensorflow, REF: readNetFromONNX. An order of model and config arguments does not matter.
    • readNet

      public static Net readNet(String framework, MatOfByte bufferModel, MatOfByte bufferConfig, int engine)
      Read deep learning network represented in one of the supported formats. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
      Parameters:
      framework - Name of origin framework.
      bufferModel - A buffer with a content of binary file with weights
      bufferConfig - A buffer with a content of text file contains network configuration.
      engine - select DNN engine to be used. With auto selection the new engine is used first and falls back to classic. Please pay attention that the new DNN does not support non-CPU back-ends for now. Use ENGINE_CLASSIC if you want to use other back-ends.
      Returns:
      Net object.
    • readNet

      public static Net readNet(String framework, MatOfByte bufferModel, MatOfByte bufferConfig)
      Read deep learning network represented in one of the supported formats. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
      Parameters:
      framework - Name of origin framework.
      bufferModel - A buffer with a content of binary file with weights
      bufferConfig - A buffer with a content of text file contains network configuration. Please pay attention that the new DNN does not support non-CPU back-ends for now. Use ENGINE_CLASSIC if you want to use other back-ends.
      Returns:
      Net object.
    • readNet

      public static Net readNet(String framework, MatOfByte bufferModel)
      Read deep learning network represented in one of the supported formats. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
      Parameters:
      framework - Name of origin framework.
      bufferModel - A buffer with a content of binary file with weights Please pay attention that the new DNN does not support non-CPU back-ends for now. Use ENGINE_CLASSIC if you want to use other back-ends.
      Returns:
      Net object.
    • readNetFromModelOptimizer

      public static Net readNetFromModelOptimizer(String xml, String bin)
      Load a network from Intel's Model Optimizer intermediate representation.
      Parameters:
      xml - XML configuration file with network's topology.
      bin - Binary file with trained weights.
      Returns:
      Net object. Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine backend.
    • readNetFromModelOptimizer

      public static Net readNetFromModelOptimizer(String xml)
      Load a network from Intel's Model Optimizer intermediate representation.
      Parameters:
      xml - XML configuration file with network's topology.
      Returns:
      Net object. Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine backend.
    • readNetFromModelOptimizer

      public static Net readNetFromModelOptimizer(MatOfByte bufferModelConfig, MatOfByte bufferWeights)
      Load a network from Intel's Model Optimizer intermediate representation.
      Parameters:
      bufferModelConfig - Buffer contains XML configuration with network's topology.
      bufferWeights - Buffer contains binary data with trained weights.
      Returns:
      Net object. Networks imported from Intel's Model Optimizer are launched in Intel's Inference Engine backend.
    • readNetFromONNX

      public static Net readNetFromONNX(String onnxFile, int engine)
      Reads a network model <a href="https://onnx.ai/">ONNX</a>.
      Parameters:
      onnxFile - path to the .onnx file with text description of the network architecture.
      engine - select DNN engine to be used. With auto selection the new engine is used first and falls back to classic. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Network object that ready to do forward, throw an exception in failure cases.
    • readNetFromONNX

      public static Net readNetFromONNX(String onnxFile)
      Reads a network model <a href="https://onnx.ai/">ONNX</a>.
      Parameters:
      onnxFile - path to the .onnx file with text description of the network architecture. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Network object that ready to do forward, throw an exception in failure cases.
    • readNetFromONNX

      public static Net readNetFromONNX(MatOfByte buffer, int engine)
      Reads a network model from <a href="https://onnx.ai/">ONNX</a> in-memory buffer.
      Parameters:
      buffer - in-memory buffer that stores the ONNX model bytes.
      engine - select DNN engine to be used. With auto selection the new engine is used first and falls back to classic. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Network object that ready to do forward, throw an exception in failure cases.
    • readNetFromONNX

      public static Net readNetFromONNX(MatOfByte buffer)
      Reads a network model from <a href="https://onnx.ai/">ONNX</a> in-memory buffer.
      Parameters:
      buffer - in-memory buffer that stores the ONNX model bytes. Please pay attention that the new DNN does not support non-CPU back-ends for now.
      Returns:
      Network object that ready to do forward, throw an exception in failure cases.
    • readTensorFromONNX

      public static Mat readTensorFromONNX(String path)
      Creates blob from .pb file.
      Parameters:
      path - to the .pb file with input tensor.
      Returns:
      Mat.
    • blobFromImage

      public static Mat blobFromImage(Mat image, double scalefactor, Size size, Scalar mean, boolean swapRB, boolean crop, int ddepth)
      Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      image - input image (with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values.
      size - spatial size for output image
      mean - scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      swapRB - flag which indicates that swap first and last channels in 3-channel image is necessary.
      crop - flag which indicates whether image will be cropped after resize or not
      ddepth - Depth of output blob. Choose CV_32F or CV_8U. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImage

      public static Mat blobFromImage(Mat image, double scalefactor, Size size, Scalar mean, boolean swapRB, boolean crop)
      Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      image - input image (with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values.
      size - spatial size for output image
      mean - scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      swapRB - flag which indicates that swap first and last channels in 3-channel image is necessary.
      crop - flag which indicates whether image will be cropped after resize or not if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImage

      public static Mat blobFromImage(Mat image, double scalefactor, Size size, Scalar mean, boolean swapRB)
      Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      image - input image (with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values.
      size - spatial size for output image
      mean - scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      swapRB - flag which indicates that swap first and last channels in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImage

      public static Mat blobFromImage(Mat image, double scalefactor, Size size, Scalar mean)
      Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      image - input image (with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values.
      size - spatial size for output image
      mean - scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true. in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImage

      public static Mat blobFromImage(Mat image, double scalefactor, Size size)
      Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      image - input image (with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values.
      size - spatial size for output image to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true. in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImage

      public static Mat blobFromImage(Mat image, double scalefactor)
      Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      image - input image (with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values. to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true. in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImage

      public static Mat blobFromImage(Mat image)
      Creates 4-dimensional blob from image. Optionally resizes and crops image from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      image - input image (with 1-, 3- or 4-channels). to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true. in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImages

      public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size, Scalar mean, boolean swapRB, boolean crop, int ddepth)
      Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      images - input images (all with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values.
      size - spatial size for output image
      mean - scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      swapRB - flag which indicates that swap first and last channels in 3-channel image is necessary.
      crop - flag which indicates whether image will be cropped after resize or not
      ddepth - Depth of output blob. Choose CV_32F or CV_8U. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImages

      public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size, Scalar mean, boolean swapRB, boolean crop)
      Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      images - input images (all with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values.
      size - spatial size for output image
      mean - scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      swapRB - flag which indicates that swap first and last channels in 3-channel image is necessary.
      crop - flag which indicates whether image will be cropped after resize or not if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImages

      public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size, Scalar mean, boolean swapRB)
      Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      images - input images (all with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values.
      size - spatial size for output image
      mean - scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      swapRB - flag which indicates that swap first and last channels in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImages

      public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size, Scalar mean)
      Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      images - input images (all with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values. in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      size - spatial size for output image
      mean - scalar with mean values which are subtracted from channels. Values are intended to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImages

      public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size)
      Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      images - input images (all with 1-, 3- or 4-channels).
      scalefactor - multiplier for images values. in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      size - spatial size for output image to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImages

      public static Mat blobFromImages(List<Mat> images, double scalefactor)
      Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      images - input images (all with 1-, 3- or 4-channels). to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true.
      scalefactor - multiplier for images values. in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImages

      public static Mat blobFromImages(List<Mat> images)
      Creates 4-dimensional blob from series of images. Optionally resizes and crops images from center, subtract mean values, scales values by scalefactor, swap Blue and Red channels.
      Parameters:
      images - input images (all with 1-, 3- or 4-channels). to be in (mean-R, mean-G, mean-B) order if image has BGR ordering and swapRB is true. in 3-channel image is necessary. if crop is true, input image is resized so one side after resize is equal to corresponding dimension in size and another one is equal or larger. Then, crop from the center is performed. If crop is false, direct resize without cropping and preserving aspect ratio is performed.
      Returns:
      4-dimensional Mat with NCHW dimensions order. Note: The order and usage of scalefactor and mean are (input - mean) * scalefactor.
    • blobFromImageWithParams

      public static Mat blobFromImageWithParams(Mat image, Image2BlobParams param)
      Creates 4-dimensional blob from image with given params. This function is an extension of REF: blobFromImage to meet more image preprocess needs. Given input image and preprocessing parameters, and function outputs the blob.
      Parameters:
      image - input image (all with 1-, 3- or 4-channels).
      param - struct of Image2BlobParams, contains all parameters needed by processing of image to blob.
      Returns:
      4-dimensional Mat.
    • blobFromImageWithParams

      public static Mat blobFromImageWithParams(Mat image)
      Creates 4-dimensional blob from image with given params. This function is an extension of REF: blobFromImage to meet more image preprocess needs. Given input image and preprocessing parameters, and function outputs the blob.
      Parameters:
      image - input image (all with 1-, 3- or 4-channels).
      Returns:
      4-dimensional Mat.
    • blobFromImageWithParams

      public static void blobFromImageWithParams(Mat image, Mat blob, Image2BlobParams param)
    • blobFromImageWithParams

      public static void blobFromImageWithParams(Mat image, Mat blob)
    • blobFromImagesWithParams

      public static Mat blobFromImagesWithParams(List<Mat> images, Image2BlobParams param)
      Creates 4-dimensional blob from series of images with given params. This function is an extension of REF: blobFromImages to meet more image preprocess needs. Given input image and preprocessing parameters, and function outputs the blob.
      Parameters:
      images - input image (all with 1-, 3- or 4-channels).
      param - struct of Image2BlobParams, contains all parameters needed by processing of image to blob.
      Returns:
      4-dimensional Mat.
    • blobFromImagesWithParams

      public static Mat blobFromImagesWithParams(List<Mat> images)
      Creates 4-dimensional blob from series of images with given params. This function is an extension of REF: blobFromImages to meet more image preprocess needs. Given input image and preprocessing parameters, and function outputs the blob.
      Parameters:
      images - input image (all with 1-, 3- or 4-channels).
      Returns:
      4-dimensional Mat.
    • blobFromImagesWithParams

      public static void blobFromImagesWithParams(List<Mat> images, Mat blob, Image2BlobParams param)
    • blobFromImagesWithParams

      public static void blobFromImagesWithParams(List<Mat> images, Mat blob)
    • imagesFromBlob

      public static void imagesFromBlob(Mat blob_, List<Mat> images_)
      Parse a 4D blob and output the images it contains as 2D arrays through a simpler data structure (std::vector<cv::Mat>).
      Parameters:
      blob_ - 4 dimensional array (images, channels, height, width) in floating point precision (CV_32F) from which you would like to extract the images.
      images_ - array of 2D Mat containing the images extracted from the blob in floating point precision (CV_32F). They are non normalized neither mean added. The number of returned images equals the first dimension of the blob (batch size). Every image has a number of channels equals to the second dimension of the blob (depth).
    • writeTextGraph

      public static void writeTextGraph(String model, String output)
      Create a text representation for a binary network stored in protocol buffer format.
      Parameters:
      model - A path to binary network.
      output - A path to output text file to be created. Note: To reduce output file size, trained weights are not included.
    • NMSBoxes

      public static void NMSBoxes(MatOfRect2d bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices, float eta, int top_k)
      Performs non maximum suppression given boxes and corresponding scores.
      Parameters:
      bboxes - a set of bounding boxes to apply NMS.
      scores - a set of corresponding confidences.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS.
      eta - a coefficient in adaptive threshold formula: \(nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\).
      top_k - if &gt;0, keep at most top_k picked indices.
    • NMSBoxes

      public static void NMSBoxes(MatOfRect2d bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices, float eta)
      Performs non maximum suppression given boxes and corresponding scores.
      Parameters:
      bboxes - a set of bounding boxes to apply NMS.
      scores - a set of corresponding confidences.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS.
      eta - a coefficient in adaptive threshold formula: \(nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\).
    • NMSBoxes

      public static void NMSBoxes(MatOfRect2d bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices)
      Performs non maximum suppression given boxes and corresponding scores.
      Parameters:
      bboxes - a set of bounding boxes to apply NMS.
      scores - a set of corresponding confidences.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS.
    • NMSBoxesRotated

      public static void NMSBoxesRotated(MatOfRotatedRect bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices, float eta, int top_k)
    • NMSBoxesRotated

      public static void NMSBoxesRotated(MatOfRotatedRect bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices, float eta)
    • NMSBoxesRotated

      public static void NMSBoxesRotated(MatOfRotatedRect bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices)
    • NMSBoxesBatched

      public static void NMSBoxesBatched(MatOfRect2d bboxes, MatOfFloat scores, MatOfInt class_ids, float score_threshold, float nms_threshold, MatOfInt indices, float eta, int top_k)
      Performs batched non maximum suppression on given boxes and corresponding scores across different classes.
      Parameters:
      bboxes - a set of bounding boxes to apply NMS.
      scores - a set of corresponding confidences.
      class_ids - a set of corresponding class ids. Ids are integer and usually start from 0.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS.
      eta - a coefficient in adaptive threshold formula: \(nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\).
      top_k - if &gt;0, keep at most top_k picked indices.
    • NMSBoxesBatched

      public static void NMSBoxesBatched(MatOfRect2d bboxes, MatOfFloat scores, MatOfInt class_ids, float score_threshold, float nms_threshold, MatOfInt indices, float eta)
      Performs batched non maximum suppression on given boxes and corresponding scores across different classes.
      Parameters:
      bboxes - a set of bounding boxes to apply NMS.
      scores - a set of corresponding confidences.
      class_ids - a set of corresponding class ids. Ids are integer and usually start from 0.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS.
      eta - a coefficient in adaptive threshold formula: \(nms\_threshold_{i+1}=eta\cdot nms\_threshold_i\).
    • NMSBoxesBatched

      public static void NMSBoxesBatched(MatOfRect2d bboxes, MatOfFloat scores, MatOfInt class_ids, float score_threshold, float nms_threshold, MatOfInt indices)
      Performs batched non maximum suppression on given boxes and corresponding scores across different classes.
      Parameters:
      bboxes - a set of bounding boxes to apply NMS.
      scores - a set of corresponding confidences.
      class_ids - a set of corresponding class ids. Ids are integer and usually start from 0.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS.
    • softNMSBoxes

      public static void softNMSBoxes(MatOfRect bboxes, MatOfFloat scores, MatOfFloat updated_scores, float score_threshold, float nms_threshold, MatOfInt indices, long top_k, float sigma)
      Performs soft non maximum suppression given boxes and corresponding scores. Reference: https://arxiv.org/abs/1704.04503
      Parameters:
      bboxes - a set of bounding boxes to apply Soft NMS.
      scores - a set of corresponding confidences.
      updated_scores - a set of corresponding updated confidences.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS.
      top_k - keep at most top_k picked indices.
      sigma - parameter of Gaussian weighting. SEE: SoftNMSMethod
    • softNMSBoxes

      public static void softNMSBoxes(MatOfRect bboxes, MatOfFloat scores, MatOfFloat updated_scores, float score_threshold, float nms_threshold, MatOfInt indices, long top_k)
      Performs soft non maximum suppression given boxes and corresponding scores. Reference: https://arxiv.org/abs/1704.04503
      Parameters:
      bboxes - a set of bounding boxes to apply Soft NMS.
      scores - a set of corresponding confidences.
      updated_scores - a set of corresponding updated confidences.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS.
      top_k - keep at most top_k picked indices. SEE: SoftNMSMethod
    • softNMSBoxes

      public static void softNMSBoxes(MatOfRect bboxes, MatOfFloat scores, MatOfFloat updated_scores, float score_threshold, float nms_threshold, MatOfInt indices)
      Performs soft non maximum suppression given boxes and corresponding scores. Reference: https://arxiv.org/abs/1704.04503
      Parameters:
      bboxes - a set of bounding boxes to apply Soft NMS.
      scores - a set of corresponding confidences.
      updated_scores - a set of corresponding updated confidences.
      score_threshold - a threshold used to filter boxes by score.
      nms_threshold - a threshold used in non maximum suppression.
      indices - the kept indices of bboxes after NMS. SEE: SoftNMSMethod
    • getInferenceEngineBackendType

      @Deprecated public static String getInferenceEngineBackendType()
      Deprecated.
      Returns Inference Engine internal backend API. See values of CV_DNN_BACKEND_INFERENCE_ENGINE_* macros. OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE runtime parameter (environment variable) is ignored since 4.6.0.
      Returns:
      automatically generated
    • setInferenceEngineBackendType

      @Deprecated public static String setInferenceEngineBackendType(String newBackendType)
      Deprecated.
      Specify Inference Engine internal backend API. See values of CV_DNN_BACKEND_INFERENCE_ENGINE_* macros.
      Parameters:
      newBackendType - automatically generated
      Returns:
      previous value of internal backend API
    • resetMyriadDevice

      public static void resetMyriadDevice()
      Release a Myriad device (binded by OpenCV). Single Myriad device cannot be shared across multiple processes which uses Inference Engine's Myriad plugin.
    • getInferenceEngineVPUType

      public static String getInferenceEngineVPUType()
      Returns Inference Engine VPU type. See values of CV_DNN_INFERENCE_ENGINE_VPU_TYPE_* macros.
      Returns:
      automatically generated
    • getInferenceEngineCPUType

      public static String getInferenceEngineCPUType()
      Returns Inference Engine CPU type. Specify OpenVINO plugin: CPU or ARM.
      Returns:
      automatically generated
    • releaseHDDLPlugin

      public static void releaseHDDLPlugin()
      Release a HDDL plugin.