|
Mat | cv::dnn::blobFromImage (InputArray image, double scalefactor=1.0, const Size &size=Size(), const Scalar &mean=Scalar(), bool swapRB=true, bool crop=true) |
| 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. More...
|
|
Mat | cv::dnn::blobFromImages (const std::vector< Mat > &images, double scalefactor=1.0, Size size=Size(), const Scalar &mean=Scalar(), bool swapRB=true, bool crop=true) |
| 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. More...
|
|
void | cv::dnn::NMSBoxes (const std::vector< Rect > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, std::vector< int > &indices, const float eta=1.f, const int top_k=0) |
| Performs non maximum suppression given boxes and corresponding scores. More...
|
|
Net | cv::dnn::readNetFromCaffe (const String &prototxt, const String &caffeModel=String()) |
| Reads a network model stored in Caffe framework's format. More...
|
|
Net | cv::dnn::readNetFromCaffe (const char *bufferProto, size_t lenProto, const char *bufferModel=NULL, size_t lenModel=0) |
| Reads a network model stored in Caffe model in memory. More...
|
|
Net | cv::dnn::readNetFromDarknet (const String &cfgFile, const String &darknetModel=String()) |
| Reads a network model stored in Darknet model files. More...
|
|
Net | cv::dnn::readNetFromTensorflow (const String &model, const String &config=String()) |
| Reads a network model stored in TensorFlow framework's format. More...
|
|
Net | cv::dnn::readNetFromTensorflow (const char *bufferModel, size_t lenModel, const char *bufferConfig=NULL, size_t lenConfig=0) |
| Reads a network model stored in TensorFlow framework's format. More...
|
|
Net | cv::dnn::readNetFromTorch (const String &model, bool isBinary=true) |
| Reads a network model stored in Torch7 framework's format. More...
|
|
Mat | cv::dnn::readTorchBlob (const String &filename, bool isBinary=true) |
| Loads blob which was serialized as torch.Tensor object of Torch7 framework. More...
|
|
void | cv::dnn::shrinkCaffeModel (const String &src, const String &dst, const std::vector< String > &layersTypes=std::vector< String >()) |
| Convert all weights of Caffe network to half precision floating point. More...
|
|
Functionality of this module is designed only for forward pass computations (i. e. network testing). A network training is in principle not supported.
Mat cv::dnn::blobFromImage |
( |
InputArray |
image, |
|
|
double |
scalefactor = 1.0 , |
|
|
const Size & |
size = Size() , |
|
|
const Scalar & |
mean = Scalar() , |
|
|
bool |
swapRB = true , |
|
|
bool |
crop = true |
|
) |
| |
Python: |
---|
| retval | = | cv.dnn.blobFromImage( | image[, scalefactor[, size[, mean[, swapRB[, 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). |
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. |
scalefactor | multiplier for image 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 corresponing 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-dimansional Mat with NCHW dimensions order.
Mat cv::dnn::blobFromImages |
( |
const std::vector< Mat > & |
images, |
|
|
double |
scalefactor = 1.0 , |
|
|
Size |
size = Size() , |
|
|
const Scalar & |
mean = Scalar() , |
|
|
bool |
swapRB = true , |
|
|
bool |
crop = true |
|
) |
| |
Python: |
---|
| retval | = | cv.dnn.blobFromImages( | images[, scalefactor[, size[, mean[, swapRB[, 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). |
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. |
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 corresponing 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-dimansional Mat with NCHW dimensions order.
Net cv::dnn::readNetFromTorch |
( |
const String & |
model, |
|
|
bool |
isBinary = true |
|
) |
| |
Python: |
---|
| retval | = | cv.dnn.readNetFromTorch( | model[, isBinary] | ) |
Reads a network model stored in Torch7 framework's format.
- Parameters
-
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. |
- Returns
- Net object.
- Note
- Ascii mode of Torch serializer is more preferable, because binary mode extensively use
long
type of C language, which has various bit-length on different systems.
The loading file must contain serialized nn.Module 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.