public class Dnn extends Object
Constructor and Description |
---|
Dnn() |
Modifier and Type | Method and Description |
---|---|
static Mat |
blobFromImage(Mat image)
Creates 4-dimensional blob from image.
|
static Mat |
blobFromImage(Mat image,
double scalefactor)
Creates 4-dimensional blob from image.
|
static Mat |
blobFromImage(Mat image,
double scalefactor,
Size size)
Creates 4-dimensional blob from image.
|
static Mat |
blobFromImage(Mat image,
double scalefactor,
Size size,
Scalar mean)
Creates 4-dimensional blob from image.
|
static Mat |
blobFromImage(Mat image,
double scalefactor,
Size size,
Scalar mean,
boolean swapRB)
Creates 4-dimensional blob from image.
|
static Mat |
blobFromImage(Mat image,
double scalefactor,
Size size,
Scalar mean,
boolean swapRB,
boolean crop)
Creates 4-dimensional blob from image.
|
static Mat |
blobFromImage(Mat image,
double scalefactor,
Size size,
Scalar mean,
boolean swapRB,
boolean crop,
int ddepth)
Creates 4-dimensional blob from image.
|
static Mat |
blobFromImages(List<Mat> images)
Creates 4-dimensional blob from series of images.
|
static Mat |
blobFromImages(List<Mat> images,
double scalefactor)
Creates 4-dimensional blob from series of images.
|
static Mat |
blobFromImages(List<Mat> images,
double scalefactor,
Size size)
Creates 4-dimensional blob from series of images.
|
static Mat |
blobFromImages(List<Mat> images,
double scalefactor,
Size size,
Scalar mean)
Creates 4-dimensional blob from series of images.
|
static Mat |
blobFromImages(List<Mat> images,
double scalefactor,
Size size,
Scalar mean,
boolean swapRB)
Creates 4-dimensional blob from series of images.
|
static Mat |
blobFromImages(List<Mat> images,
double scalefactor,
Size size,
Scalar mean,
boolean swapRB,
boolean crop)
Creates 4-dimensional blob from series of images.
|
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.
|
static Mat |
blobFromImagesWithParams(List<Mat> images)
Creates 4-dimensional blob from series of images with given params.
|
static Mat |
blobFromImagesWithParams(List<Mat> images,
Image2BlobParams param)
Creates 4-dimensional blob from series of images with given params.
|
static void |
blobFromImagesWithParams(List<Mat> images,
Mat blob) |
static void |
blobFromImagesWithParams(List<Mat> images,
Mat blob,
Image2BlobParams param) |
static Mat |
blobFromImageWithParams(Mat image)
Creates 4-dimensional blob from image with given params.
|
static Mat |
blobFromImageWithParams(Mat image,
Image2BlobParams param)
Creates 4-dimensional blob from image with given params.
|
static void |
blobFromImageWithParams(Mat image,
Mat blob) |
static void |
blobFromImageWithParams(Mat image,
Mat blob,
Image2BlobParams param) |
static List<Integer> |
getAvailableTargets(int be) |
static String |
getInferenceEngineBackendType()
Deprecated.
|
static String |
getInferenceEngineCPUType()
Returns Inference Engine CPU type.
|
static String |
getInferenceEngineVPUType()
Returns Inference Engine VPU type.
|
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>).
|
static void |
NMSBoxes(MatOfRect2d bboxes,
MatOfFloat scores,
float score_threshold,
float nms_threshold,
MatOfInt indices)
Performs non maximum suppression given boxes and corresponding scores.
|
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.
|
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.
|
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.
|
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.
|
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.
|
static void |
NMSBoxesRotated(MatOfRotatedRect bboxes,
MatOfFloat scores,
float score_threshold,
float nms_threshold,
MatOfInt indices) |
static void |
NMSBoxesRotated(MatOfRotatedRect bboxes,
MatOfFloat scores,
float score_threshold,
float nms_threshold,
MatOfInt indices,
float eta) |
static void |
NMSBoxesRotated(MatOfRotatedRect bboxes,
MatOfFloat scores,
float score_threshold,
float nms_threshold,
MatOfInt indices,
float eta,
int top_k) |
static Net |
readNet(String model)
Read deep learning network represented in one of the supported formats.
|
static Net |
readNet(String framework,
MatOfByte bufferModel)
Read deep learning network represented in one of the supported formats.
|
static Net |
readNet(String framework,
MatOfByte bufferModel,
MatOfByte bufferConfig)
Read deep learning network represented in one of the supported formats.
|
static Net |
readNet(String model,
String config)
Read deep learning network represented in one of the supported formats.
|
static Net |
readNet(String model,
String config,
String framework)
Read deep learning network represented in one of the supported formats.
|
static Net |
readNetFromCaffe(MatOfByte bufferProto)
Reads a network model stored in Caffe model in memory.
|
static Net |
readNetFromCaffe(MatOfByte bufferProto,
MatOfByte bufferModel)
Reads a network model stored in Caffe model in memory.
|
static Net |
readNetFromCaffe(String prototxt)
Reads a network model stored in <a href="http://caffe.berkeleyvision.org">Caffe</a> framework's format.
|
static Net |
readNetFromCaffe(String prototxt,
String caffeModel)
Reads a network model stored in <a href="http://caffe.berkeleyvision.org">Caffe</a> framework's format.
|
static Net |
readNetFromDarknet(MatOfByte bufferCfg)
Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
|
static Net |
readNetFromDarknet(MatOfByte bufferCfg,
MatOfByte bufferModel)
Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
|
static Net |
readNetFromDarknet(String cfgFile)
Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
|
static Net |
readNetFromDarknet(String cfgFile,
String darknetModel)
Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
|
static Net |
readNetFromModelOptimizer(MatOfByte bufferModelConfig,
MatOfByte bufferWeights)
Load a network from Intel's Model Optimizer intermediate representation.
|
static Net |
readNetFromModelOptimizer(String xml)
Load a network from Intel's Model Optimizer intermediate representation.
|
static Net |
readNetFromModelOptimizer(String xml,
String bin)
Load a network from Intel's Model Optimizer intermediate representation.
|
static Net |
readNetFromONNX(MatOfByte buffer)
Reads a network model from <a href="https://onnx.ai/">ONNX</a>
in-memory buffer.
|
static Net |
readNetFromONNX(String onnxFile)
Reads a network model <a href="https://onnx.ai/">ONNX</a>.
|
static Net |
readNetFromTensorflow(MatOfByte bufferModel)
Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
|
static Net |
readNetFromTensorflow(MatOfByte bufferModel,
MatOfByte bufferConfig)
Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
|
static Net |
readNetFromTensorflow(String model)
Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
|
static Net |
readNetFromTensorflow(String model,
String config)
Reads a network model stored in <a href="https://www.tensorflow.org/">TensorFlow</a> framework's format.
|
static Net |
readNetFromTFLite(MatOfByte bufferModel)
Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.
|
static Net |
readNetFromTFLite(String model)
Reads a network model stored in <a href="https://www.tensorflow.org/lite">TFLite</a> framework's format.
|
static Net |
readNetFromTorch(String model)
Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.
|
static Net |
readNetFromTorch(String model,
boolean isBinary)
Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.
|
static Net |
readNetFromTorch(String model,
boolean isBinary,
boolean evaluate)
Reads a network model stored in <a href="http://torch.ch">Torch7</a> framework's format.
|
static Mat |
readTensorFromONNX(String path)
Creates blob from .pb file.
|
static Mat |
readTorchBlob(String filename)
Loads blob which was serialized as torch.Tensor object of Torch7 framework.
|
static Mat |
readTorchBlob(String filename,
boolean isBinary)
Loads blob which was serialized as torch.Tensor object of Torch7 framework.
|
static void |
releaseHDDLPlugin()
Release a HDDL plugin.
|
static void |
resetMyriadDevice()
Release a Myriad device (binded by OpenCV).
|
static String |
setInferenceEngineBackendType(String newBackendType)
Deprecated.
|
static void |
shrinkCaffeModel(String src,
String dst)
Convert all weights of Caffe network to half precision floating point.
|
static void |
shrinkCaffeModel(String src,
String dst,
List<String> layersTypes)
Convert all weights of Caffe network to half precision floating point.
|
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.
|
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.
|
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.
|
static void |
writeTextGraph(String model,
String output)
Create a text representation for a binary network stored in protocol buffer format.
|
public static final int DNN_BACKEND_DEFAULT
public static final int DNN_BACKEND_HALIDE
public static final int DNN_BACKEND_INFERENCE_ENGINE
public static final int DNN_BACKEND_OPENCV
public static final int DNN_BACKEND_VKCOM
public static final int DNN_BACKEND_CUDA
public static final int DNN_BACKEND_WEBNN
public static final int DNN_BACKEND_TIMVX
public static final int DNN_BACKEND_CANN
public static final int DNN_LAYOUT_UNKNOWN
public static final int DNN_LAYOUT_ND
public static final int DNN_LAYOUT_NCHW
public static final int DNN_LAYOUT_NCDHW
public static final int DNN_LAYOUT_NHWC
public static final int DNN_LAYOUT_NDHWC
public static final int DNN_LAYOUT_PLANAR
public static final int DNN_PMODE_NULL
public static final int DNN_PMODE_CROP_CENTER
public static final int DNN_PMODE_LETTERBOX
public static final int SoftNMSMethod_SOFTNMS_LINEAR
public static final int SoftNMSMethod_SOFTNMS_GAUSSIAN
public static final int DNN_TARGET_CPU
public static final int DNN_TARGET_OPENCL
public static final int DNN_TARGET_OPENCL_FP16
public static final int DNN_TARGET_MYRIAD
public static final int DNN_TARGET_VULKAN
public static final int DNN_TARGET_FPGA
public static final int DNN_TARGET_CUDA
public static final int DNN_TARGET_CUDA_FP16
public static final int DNN_TARGET_HDDL
public static final int DNN_TARGET_NPU
public static final int DNN_TARGET_CPU_FP16
public static Net readNetFromDarknet(String cfgFile, String darknetModel)
cfgFile
- path to the .cfg file with text description of the network architecture.darknetModel
- path to the .weights file with learned network.public static Net readNetFromDarknet(String cfgFile)
cfgFile
- path to the .cfg file with text description of the network architecture.public static Net readNetFromDarknet(MatOfByte bufferCfg, MatOfByte bufferModel)
bufferCfg
- A buffer contains a content of .cfg file with text description of the network architecture.bufferModel
- A buffer contains a content of .weights file with learned network.public static Net readNetFromDarknet(MatOfByte bufferCfg)
bufferCfg
- A buffer contains a content of .cfg file with text description of the network architecture.public static Net readNetFromCaffe(String prototxt, String caffeModel)
prototxt
- path to the .prototxt file with text description of the network architecture.caffeModel
- path to the .caffemodel file with learned network.public static Net readNetFromCaffe(String prototxt)
prototxt
- path to the .prototxt file with text description of the network architecture.public static Net readNetFromCaffe(MatOfByte bufferProto, MatOfByte bufferModel)
bufferProto
- buffer containing the content of the .prototxt filebufferModel
- buffer containing the content of the .caffemodel filepublic static Net readNetFromCaffe(MatOfByte bufferProto)
bufferProto
- buffer containing the content of the .prototxt filepublic static Net readNetFromTensorflow(String model, String config)
model
- path to the .pb file with binary protobuf description of the network architectureconfig
- 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.public static Net readNetFromTensorflow(String model)
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.public static Net readNetFromTensorflow(MatOfByte bufferModel, MatOfByte bufferConfig)
bufferModel
- buffer containing the content of the pb filebufferConfig
- buffer containing the content of the pbtxt filepublic static Net readNetFromTensorflow(MatOfByte bufferModel)
bufferModel
- buffer containing the content of the pb filepublic static Net readNetFromTFLite(String model)
model
- path to the .tflite file with binary flatbuffers description of the network architecturepublic static Net readNetFromTFLite(MatOfByte bufferModel)
bufferModel
- buffer containing the content of the tflite filepublic static Net readNetFromTorch(String model, boolean isBinary, boolean evaluate)
model
- path to the file, dumped from Torch by using torch.save() function.isBinary
- specifies whether the network was serialized in ascii mode or binary.evaluate
- specifies testing phase of network. If true, it's similar to evaluate() method in Torch.long
type of C language,
which has various bit-length on different systems.
The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
List of supported layers (i.e. object instances derived from Torch nn.Module class):
- nn.Sequential
- nn.Parallel
- nn.Concat
- nn.Linear
- nn.SpatialConvolution
- nn.SpatialMaxPooling, nn.SpatialAveragePooling
- nn.ReLU, nn.TanH, nn.Sigmoid
- nn.Reshape
- nn.SoftMax, nn.LogSoftMax
Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.public static Net readNetFromTorch(String model, boolean isBinary)
model
- path to the file, dumped from Torch by using torch.save() function.isBinary
- specifies whether the network was serialized in ascii mode or binary.long
type of C language,
which has various bit-length on different systems.
The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
List of supported layers (i.e. object instances derived from Torch nn.Module class):
- nn.Sequential
- nn.Parallel
- nn.Concat
- nn.Linear
- nn.SpatialConvolution
- nn.SpatialMaxPooling, nn.SpatialAveragePooling
- nn.ReLU, nn.TanH, nn.Sigmoid
- nn.Reshape
- nn.SoftMax, nn.LogSoftMax
Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.public static Net readNetFromTorch(String model)
model
- path to the file, dumped from Torch by using torch.save() function.long
type of C language,
which has various bit-length on different systems.
The loading file must contain serialized <a href="https://github.com/torch/nn/blob/master/doc/module.md">nn.Module</a> object
with importing network. Try to eliminate a custom objects from serialazing data to avoid importing errors.
List of supported layers (i.e. object instances derived from Torch nn.Module class):
- nn.Sequential
- nn.Parallel
- nn.Concat
- nn.Linear
- nn.SpatialConvolution
- nn.SpatialMaxPooling, nn.SpatialAveragePooling
- nn.ReLU, nn.TanH, nn.Sigmoid
- nn.Reshape
- nn.SoftMax, nn.LogSoftMax
Also some equivalents of these classes from cunn, cudnn, and fbcunn may be successfully imported.public static Net readNet(String model, String config, String framework)
model
- Binary file contains trained weights. The following file
extensions are expected for models from different frameworks:
* *.caffemodel
(Caffe, http://caffe.berkeleyvision.org/)
* *.pb
(TensorFlow, https://www.tensorflow.org/)
* *.t7
| *.net
(Torch, http://torch.ch/)
* *.weights
(Darknet, https://pjreddie.com/darknet/)
* *.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:
* *.prototxt
(Caffe, http://caffe.berkeleyvision.org/)
* *.pbtxt
(TensorFlow, https://www.tensorflow.org/)
* *.cfg
(Darknet, https://pjreddie.com/darknet/)
* *.xml
(OpenVINO, https://software.intel.com/openvino-toolkit)framework
- Explicit framework name tag to determine a format.model
and config
arguments does not matter.public static Net readNet(String model, String config)
model
- Binary file contains trained weights. The following file
extensions are expected for models from different frameworks:
* *.caffemodel
(Caffe, http://caffe.berkeleyvision.org/)
* *.pb
(TensorFlow, https://www.tensorflow.org/)
* *.t7
| *.net
(Torch, http://torch.ch/)
* *.weights
(Darknet, https://pjreddie.com/darknet/)
* *.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:
* *.prototxt
(Caffe, http://caffe.berkeleyvision.org/)
* *.pbtxt
(TensorFlow, https://www.tensorflow.org/)
* *.cfg
(Darknet, https://pjreddie.com/darknet/)
* *.xml
(OpenVINO, https://software.intel.com/openvino-toolkit)model
and config
arguments does not matter.public static Net readNet(String model)
model
- Binary file contains trained weights. The following file
extensions are expected for models from different frameworks:
* *.caffemodel
(Caffe, http://caffe.berkeleyvision.org/)
* *.pb
(TensorFlow, https://www.tensorflow.org/)
* *.t7
| *.net
(Torch, http://torch.ch/)
* *.weights
(Darknet, https://pjreddie.com/darknet/)
* *.bin
| *.onnx
(OpenVINO, https://software.intel.com/openvino-toolkit)
* *.onnx
(ONNX, https://onnx.ai/)
file with the following extensions:
* *.prototxt
(Caffe, http://caffe.berkeleyvision.org/)
* *.pbtxt
(TensorFlow, https://www.tensorflow.org/)
* *.cfg
(Darknet, https://pjreddie.com/darknet/)
* *.xml
(OpenVINO, https://software.intel.com/openvino-toolkit)model
and config
arguments does not matter.public static Net readNet(String framework, MatOfByte bufferModel, MatOfByte bufferConfig)
framework
- Name of origin framework.bufferModel
- A buffer with a content of binary file with weightsbufferConfig
- A buffer with a content of text file contains network configuration.public static Net readNet(String framework, MatOfByte bufferModel)
framework
- Name of origin framework.bufferModel
- A buffer with a content of binary file with weightspublic static Mat readTorchBlob(String filename, boolean isBinary)
filename
- automatically generatedisBinary
- automatically generatedpublic static Mat readTorchBlob(String filename)
filename
- automatically generatedpublic static Net readNetFromModelOptimizer(String xml, String bin)
xml
- XML configuration file with network's topology.bin
- Binary file with trained weights.public static Net readNetFromModelOptimizer(String xml)
xml
- XML configuration file with network's topology.public static Net readNetFromModelOptimizer(MatOfByte bufferModelConfig, MatOfByte bufferWeights)
bufferModelConfig
- Buffer contains XML configuration with network's topology.bufferWeights
- Buffer contains binary data with trained weights.public static Net readNetFromONNX(String onnxFile)
onnxFile
- path to the .onnx file with text description of the network architecture.public static Net readNetFromONNX(MatOfByte buffer)
buffer
- in-memory buffer that stores the ONNX model bytes.public static Mat readTensorFromONNX(String path)
path
- to the .pb file with input tensor.public static Mat blobFromImage(Mat image, double scalefactor, Size size, Scalar mean, boolean swapRB, boolean crop, int ddepth)
image
from center,
subtract mean
values, scales values by scalefactor
, swap Blue and Red channels.image
- input image (with 1-, 3- or 4-channels).scalefactor
- multiplier for images
values.size
- spatial size for output imagemean
- 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 notddepth
- 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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImage(Mat image, double scalefactor, Size size, Scalar mean, boolean swapRB, boolean crop)
image
from center,
subtract mean
values, scales values by scalefactor
, swap Blue and Red channels.image
- input image (with 1-, 3- or 4-channels).scalefactor
- multiplier for images
values.size
- spatial size for output imagemean
- 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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImage(Mat image, double scalefactor, Size size, Scalar mean, boolean swapRB)
image
from center,
subtract mean
values, scales values by scalefactor
, swap Blue and Red channels.image
- input image (with 1-, 3- or 4-channels).scalefactor
- multiplier for images
values.size
- spatial size for output imagemean
- 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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImage(Mat image, double scalefactor, Size size, Scalar mean)
image
from center,
subtract mean
values, scales values by scalefactor
, swap Blue and Red channels.image
- input image (with 1-, 3- or 4-channels).scalefactor
- multiplier for images
values.size
- spatial size for output imagemean
- 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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImage(Mat image, double scalefactor, Size size)
image
from center,
subtract mean
values, scales values by scalefactor
, swap Blue and Red channels.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImage(Mat image, double scalefactor)
image
from center,
subtract mean
values, scales values by scalefactor
, swap Blue and Red channels.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImage(Mat image)
image
from center,
subtract mean
values, scales values by scalefactor
, swap Blue and Red channels.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size, Scalar mean, boolean swapRB, boolean crop, int ddepth)
images
from center, subtract mean
values, scales values by scalefactor
,
swap Blue and Red channels.images
- input images (all with 1-, 3- or 4-channels).size
- spatial size for output imagemean
- 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.scalefactor
- multiplier for images
values.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 notddepth
- 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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size, Scalar mean, boolean swapRB, boolean crop)
images
from center, subtract mean
values, scales values by scalefactor
,
swap Blue and Red channels.images
- input images (all with 1-, 3- or 4-channels).size
- spatial size for output imagemean
- 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.scalefactor
- multiplier for images
values.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size, Scalar mean, boolean swapRB)
images
from center, subtract mean
values, scales values by scalefactor
,
swap Blue and Red channels.images
- input images (all with 1-, 3- or 4-channels).size
- spatial size for output imagemean
- 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.scalefactor
- multiplier for images
values.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size, Scalar mean)
images
from center, subtract mean
values, scales values by scalefactor
,
swap Blue and Red channels.images
- input images (all with 1-, 3- or 4-channels).size
- spatial size for output imagemean
- 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.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImages(List<Mat> images, double scalefactor, Size size)
images
from center, subtract mean
values, scales values by scalefactor
,
swap Blue and Red channels.images
- input images (all with 1-, 3- or 4-channels).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.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImages(List<Mat> images, double scalefactor)
images
from center, subtract mean
values, scales values by scalefactor
,
swap Blue and Red channels.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImages(List<Mat> images)
images
from center, subtract mean
values, scales values by scalefactor
,
swap Blue and Red channels.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.scalefactor
and mean
are (input - mean) * scalefactor.public static Mat blobFromImageWithParams(Mat image, Image2BlobParams param)
image
- input image (all with 1-, 3- or 4-channels).param
- struct of Image2BlobParams, contains all parameters needed by processing of image to blob.public static Mat blobFromImageWithParams(Mat image)
image
- input image (all with 1-, 3- or 4-channels).public static void blobFromImageWithParams(Mat image, Mat blob, Image2BlobParams param)
public static Mat blobFromImagesWithParams(List<Mat> images, Image2BlobParams param)
images
- input image (all with 1-, 3- or 4-channels).param
- struct of Image2BlobParams, contains all parameters needed by processing of image to blob.public static Mat blobFromImagesWithParams(List<Mat> images)
images
- input image (all with 1-, 3- or 4-channels).public static void blobFromImagesWithParams(List<Mat> images, Mat blob, Image2BlobParams param)
public static void imagesFromBlob(Mat blob_, List<Mat> images_)
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).public static void shrinkCaffeModel(String src, String dst, List<String> layersTypes)
src
- Path to origin model from Caffe framework contains single
precision floating point weights (usually has .caffemodel
extension).dst
- Path to destination model with updated weights.layersTypes
- Set of layers types which parameters will be converted.
By default, converts only Convolutional and Fully-Connected layers'
weights.
Note: Shrinked model has no origin float32 weights so it can't be used
in origin Caffe framework anymore. However the structure of data
is taken from NVidia's Caffe fork: https://github.com/NVIDIA/caffe.
So the resulting model may be used there.public static void shrinkCaffeModel(String src, String dst)
src
- Path to origin model from Caffe framework contains single
precision floating point weights (usually has .caffemodel
extension).dst
- Path to destination model with updated weights.
By default, converts only Convolutional and Fully-Connected layers'
weights.
Note: Shrinked model has no origin float32 weights so it can't be used
in origin Caffe framework anymore. However the structure of data
is taken from NVidia's Caffe fork: https://github.com/NVIDIA/caffe.
So the resulting model may be used there.public static void writeTextGraph(String model, String output)
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.public static void NMSBoxes(MatOfRect2d bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices, float eta, int top_k)
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 >0
, keep at most top_k
picked indices.public static void NMSBoxes(MatOfRect2d bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices, float eta)
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\).public static void NMSBoxes(MatOfRect2d bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices)
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.public static void NMSBoxesRotated(MatOfRotatedRect bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices, float eta, int top_k)
public static void NMSBoxesRotated(MatOfRotatedRect bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices, float eta)
public static void NMSBoxesRotated(MatOfRotatedRect bboxes, MatOfFloat scores, float score_threshold, float nms_threshold, MatOfInt indices)
public static void NMSBoxesBatched(MatOfRect2d bboxes, MatOfFloat scores, MatOfInt class_ids, float score_threshold, float nms_threshold, MatOfInt indices, float eta, int top_k)
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 >0
, keep at most top_k
picked indices.public static void NMSBoxesBatched(MatOfRect2d bboxes, MatOfFloat scores, MatOfInt class_ids, float score_threshold, float nms_threshold, MatOfInt indices, float eta)
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\).public static void NMSBoxesBatched(MatOfRect2d bboxes, MatOfFloat scores, MatOfInt class_ids, float score_threshold, float nms_threshold, MatOfInt indices)
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.public static void softNMSBoxes(MatOfRect bboxes, MatOfFloat scores, MatOfFloat updated_scores, float score_threshold, float nms_threshold, MatOfInt indices, long top_k, float sigma)
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: SoftNMSMethodpublic static void softNMSBoxes(MatOfRect bboxes, MatOfFloat scores, MatOfFloat updated_scores, float score_threshold, float nms_threshold, MatOfInt indices, long top_k)
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: SoftNMSMethodpublic static void softNMSBoxes(MatOfRect bboxes, MatOfFloat scores, MatOfFloat updated_scores, float score_threshold, float nms_threshold, MatOfInt indices)
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@Deprecated public static String getInferenceEngineBackendType()
CV_DNN_BACKEND_INFERENCE_ENGINE_*
macros.
OPENCV_DNN_BACKEND_INFERENCE_ENGINE_TYPE
runtime parameter (environment variable) is ignored since 4.6.0.@Deprecated public static String setInferenceEngineBackendType(String newBackendType)
CV_DNN_BACKEND_INFERENCE_ENGINE_*
macros.newBackendType
- automatically generatedpublic static void resetMyriadDevice()
public static String getInferenceEngineVPUType()
CV_DNN_INFERENCE_ENGINE_VPU_TYPE_*
macros.public static String getInferenceEngineCPUType()
public static void releaseHDDLPlugin()
Copyright © 2024. All rights reserved.