OpenCV  3.1.0
Open Source Computer Vision
Public Member Functions | List of all members
cv::dnn::Blob Class Reference

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...
 
MatmatRef ()
 Returns reference to cv::Mat, containing blob data. More...
 
const MatmatRefConst () 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
 
ucharptr (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)
 
Blobreshape (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...
 
BlobshareFrom (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...
 
UMatumatRef ()
 Returns reference to cv::UMat, containing blob data (not implemented yet). More...
 
const UMatumatRefConst () 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

cv::dnn::Blob::Blob ( )
explicit
cv::dnn::Blob::Blob ( const BlobShape shape,
int  type = CV_32F 
)
explicit

Constructs blob with specified shape and type.

cv::dnn::Blob::Blob ( InputArray  image,
int  dstCn = -1 
)
explicit

Constucts 4-dimensional blob (so-called batch) from image or array of images.

Parameters
image2-dimensional multi-channel or 3-dimensional single-channel image (or array of images)
dstCnspecify size of second axis of ouptut blob

Member Function Documentation

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 
)

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)

Creates blob from cv::Mat or cv::UMat without copying the data.

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, ...]

Mat& cv::dnn::Blob::matRef ( )

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.

template<int n>
size_t cv::dnn::Blob::offset ( const Vec< int, n > &  pos) const

Returns linear index of the element with specified coordinates in the blob.

If n < dims() then unspecified coordinates will be filled by zeros. If n > dims() then extra coordinates will be ignored.

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 
)

Returns pointer to the blob element with the specified position, stored in CPU memory.

n correspond to the first axis, cn - to the second, etc. If dims() > 4 then unspecified coordinates will be filled by zeros. If dims() < 4 then extra coordinates will be ignored.

template<typename TFloat >
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.

Blob& cv::dnn::Blob::reshape ( const BlobShape shape)

Changes shape of the blob without copying the data.

Returns
*this
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.

Blob& cv::dnn::Blob::shareFrom ( const Blob blob)

Shares data from other blob.

Returns
*this
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 cv::dnn::Blob::size2 ( ) const

Returns cv::Size(cols(), rows())

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).

Parameters
startAxisthe first axis to include in the range.
endAxisthe 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.


The documentation for this class was generated from the following file: