OpenCV
3.1.0
Open Source Computer Vision
|
This class provides methods for continuous n-dimensional CPU and GPU array processing. More...
#include "blob.hpp"
Public Member Functions | |
Blob () | |
Blob (const BlobShape &shape, int type=CV_32F) | |
Constructs blob with specified shape and type . More... | |
Blob (InputArray image, int dstCn=-1) | |
Constucts 4-dimensional blob (so-called batch) from image or array of images. 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) |
Creates blob with specified shape and type . More... | |
int | dims () const |
Returns number of blob dimensions. More... | |
bool | equalShape (const Blob &other) const |
Checks equality of two blobs shapes. More... | |
void | fill (InputArray in) |
Creates blob from cv::Mat or cv::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 & | matRef () |
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 TFloat > | |
TFloat * | 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... | |
int | rows () const |
Returns size of the thrid axis blob. 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... | |
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 () |
Returns reference to cv::UMat, containing blob data (not implemented yet). More... | |
const UMat & | umatRefConst () const |
Returns reference to cv::UMat, containing blob data, for read-only purposes (not implemented yet). More... | |
int | xsize (int axis) const |
Returns the size of the specified axis . 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.
|
explicit |
Constructs blob with specified shape
and type
.
|
explicit |
Constucts 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 images) |
dstCn | specify size of second axis of ouptut blob |
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.
Creates blob with specified shape
and type
.
int cv::dnn::Blob::dims | ( | ) | const |
Returns number of blob dimensions.
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.
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, ...]
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 |
||
) |
TFloat* 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.
int cv::dnn::Blob::rows | ( | ) | const |
Returns size of the thrid axis blob.
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 | ( | ) |
Returns reference to cv::UMat, containing blob data (not implemented yet).
const UMat& cv::dnn::Blob::umatRefConst | ( | ) | const |
Returns reference to cv::UMat, containing blob data, for read-only purposes (not implemented yet).
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.