OpenCV
3.2.0
Open Source Computer Vision
|
This class provides methods for continuous n-dimensional CPU and GPU array processing. More...
#include "blob.hpp"
Public Types | |
enum | AllocFlag { ALLOC_MAT = HEAD_AT_MAT, ALLOC_UMAT = HEAD_AT_UMAT, ALLOC_BOTH = SYNCED } |
enum | DataState { UNINITIALIZED = 0, HEAD_AT_MAT = 1 << 0, HEAD_AT_UMAT = 1 << 1, SYNCED = HEAD_AT_MAT | HEAD_AT_UMAT } |
Public Member Functions | |
Blob () | |
Blob (const BlobShape &shape, int type=CV_32F, int allocFlags=ALLOC_MAT) | |
Constructs blob with specified shape and type . More... | |
Blob (InputArray data) | |
Constructs Blob from existing Mat or UMat. More... | |
void | batchFromImages (InputArray image, int dstCn=-1) |
Works like Blob::fromImages() but in-place. More... | |
int | canonicalAxis (int axis) const |
Converts axis index to canonical format (where 0 <= axis < dims()). More... | |
int | channels () const |
Returns size of the second axis blob. More... | |
int | cols () const |
Returns size of the fourth axis blob. More... | |
void | create (const BlobShape &shape, int type=CV_32F, int allocFlags=ALLOC_MAT) |
Creates blob with specified shape and type . More... | |
int | dims () const |
Returns number of blob dimensions. More... | |
int | elemSize () const |
Returns size of single element in bytes. More... | |
bool | equalShape (const Blob &other) const |
Checks equality of two blobs shapes. More... | |
void | fill (InputArray in) |
Creates blob from Mat or UMat without copying the data. More... | |
void | fill (const BlobShape &shape, int type, void *data, bool deepCopy=true) |
Creates blob from user data. More... | |
Mat | getPlane (int n, int cn) |
Returns slice of first two dimensions. More... | |
Mat | getPlanes (int n) |
Returns slice of first dimension. More... | |
template<typename XMat > | |
XMat & | getRef (bool writeOnly=true) |
template<typename XMat > | |
const XMat & | getRefConst () const |
int | getState () const |
Returns current state of the blob,. More... | |
Mat & | matRef (bool writeOnly=true) |
Returns reference to cv::Mat, containing blob data. More... | |
const Mat & | matRefConst () const |
Returns reference to cv::Mat, containing blob data, for read-only purposes. More... | |
int | num () const |
Returns size of the first axis blob. More... | |
template<int n> | |
size_t | offset (const Vec< int, n > &pos) const |
Returns linear index of the element with specified coordinates in the blob. More... | |
size_t | offset (int n=0, int cn=0, int row=0, int col=0) const |
uchar * | ptr (int n=0, int cn=0, int row=0, int col=0) |
Returns pointer to the blob element with the specified position, stored in CPU memory. More... | |
template<typename Type > | |
Type * | ptr (int n=0, int cn=0, int row=0, int col=0) |
float * | ptrf (int n=0, int cn=0, int row=0, int col=0) |
Blob & | reshape (const BlobShape &shape) |
Changes shape of the blob without copying the data. More... | |
Blob | reshaped (const BlobShape &newShape) const |
Changes shape of the blob without copying the data. More... | |
int | rows () const |
Returns size of the thrid axis blob. More... | |
void | setTo (InputArray value, int allocFlags=-1) |
Sets value to the last used data (if allocFlags = -1). More... | |
BlobShape | shape () const |
Returns shape of the blob. More... | |
Vec4i | shape4 () const |
Returns shape of first four blob axes. More... | |
Blob & | shareFrom (const Blob &blob) |
Shares data from other blob . More... | |
int | size (int axis) const |
Returns the size of the specified axis . More... | |
Size | size2 () const |
Returns cv::Size(cols(), rows()) More... | |
void | sync () const |
Updates Mat and UMat of Blob. More... | |
size_t | total (int startAxis=0, int endAxis=INT_MAX) const |
Computes the product of sizes of axes among the specified axes range [startAxis ; endAxis ). More... | |
int | type () const |
Returns type of the blob. More... | |
UMat & | umatRef (bool writeOnly=true) |
Returns reference to cv::UMat, containing blob data. More... | |
const UMat & | umatRefConst () const |
Returns reference to cv::UMat, containing blob data, for read-only purposes. More... | |
void | updateMat (bool syncData=true) const |
Actualizes data stored inside Mat of Blob; if syncData is false then only shape will be actualized. More... | |
void | updateUMat (bool syncData=true) const |
Actualizes data stored inside Mat of Blob; if syncData is false then only shape will be actualized. More... | |
int | xsize (int axis) const |
Returns the size of the specified axis . More... | |
Static Public Member Functions | |
static Blob | fromImages (InputArray image, int dstCn=-1) |
Constructs 4-dimensional blob (so-called batch) from image or array of images. More... | |
This class provides methods for continuous n-dimensional CPU and GPU array processing.
The class is realized as a wrapper over cv::Mat and cv::UMat. It will support methods for switching and logical synchronization between CPU and GPU.
cv::dnn::Blob::Blob | ( | ) |
|
explicit |
Constructs blob with specified shape
and type
.
cv::dnn::Blob::Blob | ( | InputArray | data | ) |
void cv::dnn::Blob::batchFromImages | ( | InputArray | image, |
int | dstCn = -1 |
||
) |
Works like Blob::fromImages() but in-place.
int cv::dnn::Blob::canonicalAxis | ( | int | axis | ) | const |
Converts axis
index to canonical format (where 0 <= axis
< dims()).
int cv::dnn::Blob::channels | ( | ) | const |
Returns size of the second axis blob.
int cv::dnn::Blob::cols | ( | ) | const |
Returns size of the fourth axis blob.
void cv::dnn::Blob::create | ( | const BlobShape & | shape, |
int | type = CV_32F , |
||
int | allocFlags = ALLOC_MAT |
||
) |
Creates blob with specified shape
and type
.
int cv::dnn::Blob::dims | ( | ) | const |
Returns number of blob dimensions.
int cv::dnn::Blob::elemSize | ( | ) | const |
Returns size of single element in bytes.
bool cv::dnn::Blob::equalShape | ( | const Blob & | other | ) | const |
Checks equality of two blobs shapes.
void cv::dnn::Blob::fill | ( | InputArray | in | ) |
void cv::dnn::Blob::fill | ( | const BlobShape & | shape, |
int | type, | ||
void * | data, | ||
bool | deepCopy = true |
||
) |
Creates blob from user data.
If deepCopy
is false then CPU data will not be allocated.
|
static |
Constructs 4-dimensional blob (so-called batch) from image or array of images.
image | 2-dimensional multi-channel or 3-dimensional single-channel image (or array of such images) |
dstCn | specifies size of second axis of ouptut blob |
Mat cv::dnn::Blob::getPlane | ( | int | n, |
int | cn | ||
) |
Returns slice of first two dimensions.
The behaviour is similar to the following numpy code: blob[n, cn, ...]
Mat cv::dnn::Blob::getPlanes | ( | int | n | ) |
Returns slice of first dimension.
The behaviour is similar to getPlane(), but returns all channels * rows * cols values, corresponding to the n-th value of the first dimension.
XMat& cv::dnn::Blob::getRef | ( | bool | writeOnly = true | ) |
const XMat& cv::dnn::Blob::getRefConst | ( | ) | const |
int cv::dnn::Blob::getState | ( | ) | const |
Returns current state of the blob,.
Mat& cv::dnn::Blob::matRef | ( | bool | writeOnly = true | ) |
Returns reference to cv::Mat, containing blob data.
const Mat& cv::dnn::Blob::matRefConst | ( | ) | const |
Returns reference to cv::Mat, containing blob data, for read-only purposes.
int cv::dnn::Blob::num | ( | ) | const |
Returns size of the first axis blob.
size_t cv::dnn::Blob::offset | ( | int | n = 0 , |
int | cn = 0 , |
||
int | row = 0 , |
||
int | col = 0 |
||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
uchar* cv::dnn::Blob::ptr | ( | int | n = 0 , |
int | cn = 0 , |
||
int | row = 0 , |
||
int | col = 0 |
||
) |
Type* cv::dnn::Blob::ptr | ( | int | n = 0 , |
int | cn = 0 , |
||
int | row = 0 , |
||
int | col = 0 |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
float* cv::dnn::Blob::ptrf | ( | int | n = 0 , |
int | cn = 0 , |
||
int | row = 0 , |
||
int | col = 0 |
||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Changes shape of the blob without copying the data.
Changes shape of the blob without copying the data.
int cv::dnn::Blob::rows | ( | ) | const |
Returns size of the thrid axis blob.
void cv::dnn::Blob::setTo | ( | InputArray | value, |
int | allocFlags = -1 |
||
) |
BlobShape cv::dnn::Blob::shape | ( | ) | const |
Returns shape of the blob.
Vec4i cv::dnn::Blob::shape4 | ( | ) | const |
Returns shape of first four blob axes.
int cv::dnn::Blob::size | ( | int | axis | ) | const |
Returns the size of the specified axis
.
Negative axis
is supported, in this case a counting starts from the last axis, i. e. -1 corresponds to last axis. If non-existing axis was passed then an error will be generated.
size_t cv::dnn::Blob::total | ( | int | startAxis = 0 , |
int | endAxis = INT_MAX |
||
) | const |
Computes the product of sizes of axes among the specified axes range [startAxis
; endAxis
).
startAxis | the first axis to include in the range. |
endAxis | the first axis to exclude from the range. |
Negative axis indexing can be used.
int cv::dnn::Blob::type | ( | ) | const |
Returns type of the blob.
UMat& cv::dnn::Blob::umatRef | ( | bool | writeOnly = true | ) |
Returns reference to cv::UMat, containing blob data.
const UMat& cv::dnn::Blob::umatRefConst | ( | ) | const |
Returns reference to cv::UMat, containing blob data, for read-only purposes.
void cv::dnn::Blob::updateMat | ( | bool | syncData = true | ) | const |
void cv::dnn::Blob::updateUMat | ( | bool | syncData = true | ) | const |
int cv::dnn::Blob::xsize | ( | int | axis | ) | const |
Returns the size of the specified axis
.
Does the same thing as size(int) const, but if non-existing axis will be passed then 1 will be returned, therefore this function always finishes successfully.