opencv on mbed
SparseMat_< _Tp > Class Template Reference
[Basic structures]
Template sparse n-dimensional array class derived from SparseMat. More...
#include <mat.hpp>
Inherits cv::SparseMat.
Public Member Functions | |
SparseMat_ () | |
the default constructor | |
SparseMat_ (int dims, const int *_sizes) | |
the full constructor equivelent to SparseMat(dims, _sizes, DataType<_Tp>::type) | |
SparseMat_ (const SparseMat &m) | |
the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted | |
SparseMat_ (const SparseMat_ &m) | |
the copy constructor. This is O(1) operation - no data is copied | |
SparseMat_ (const Mat &m) | |
converts dense matrix to the sparse form | |
SparseMat_ & | operator= (const SparseMat &m) |
converts the old-style sparse matrix to the C++ class. All the elements are copied | |
SparseMat_ & | operator= (const SparseMat_ &m) |
the assignment operator. This is O(1) operation - no data is copied | |
SparseMat_ & | operator= (const Mat &m) |
converts dense matrix to the sparse form | |
SparseMat_ | clone () const |
makes full copy of the matrix. All the elements are duplicated | |
void | create (int dims, const int *_sizes) |
equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type) | |
int | type () const |
converts sparse matrix to the old-style CvSparseMat. All the elements are copied | |
int | depth () const |
returns depth of the matrix elements | |
int | channels () const |
returns the number of channels in each matrix element | |
_Tp & | ref (int i0, size_t *hashval=0) |
equivalent to SparseMat::ref<_Tp>(i0, hashval) | |
_Tp & | ref (int i0, int i1, size_t *hashval=0) |
equivalent to SparseMat::ref<_Tp>(i0, i1, hashval) | |
_Tp & | ref (int i0, int i1, int i2, size_t *hashval=0) |
equivalent to SparseMat::ref<_Tp>(i0, i1, i2, hashval) | |
_Tp & | ref (const int *idx, size_t *hashval=0) |
equivalent to SparseMat::ref<_Tp>(idx, hashval) | |
_Tp | operator() (int i0, size_t *hashval=0) const |
equivalent to SparseMat::value<_Tp>(i0, hashval) | |
_Tp | operator() (int i0, int i1, size_t *hashval=0) const |
equivalent to SparseMat::value<_Tp>(i0, i1, hashval) | |
_Tp | operator() (int i0, int i1, int i2, size_t *hashval=0) const |
equivalent to SparseMat::value<_Tp>(i0, i1, i2, hashval) | |
_Tp | operator() (const int *idx, size_t *hashval=0) const |
equivalent to SparseMat::value<_Tp>(idx, hashval) | |
SparseMatIterator_< _Tp > | begin () |
returns sparse matrix iterator pointing to the first sparse matrix element | |
SparseMatConstIterator_< _Tp > | begin () const |
returns read-only sparse matrix iterator pointing to the first sparse matrix element | |
SparseMatIterator_< _Tp > | end () |
returns sparse matrix iterator pointing to the element following the last sparse matrix element | |
SparseMatConstIterator_< _Tp > | end () const |
returns read-only sparse matrix iterator pointing to the element following the last sparse matrix element | |
void | copyTo (SparseMat &m) const |
copies all the data to the destination matrix. All the previous content of m is erased | |
void | copyTo (Mat &m) const |
converts sparse matrix to dense matrix. | |
void | convertTo (SparseMat &m, int rtype, double alpha=1) const |
multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type | |
void | convertTo (Mat &m, int rtype, double alpha=1, double beta=0) const |
converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. | |
void | create (int dims, const int *_sizes, int _type) |
reallocates sparse matrix. | |
void | clear () |
sets all the sparse matrix elements to 0, which means clearing the hash table. | |
void | addref () |
manually increments the reference counter to the header. | |
size_t | elemSize () const |
converts sparse matrix to the old-style representation; all the elements are copied. | |
size_t | elemSize1 () const |
returns elemSize()/channels() | |
const int * | size () const |
returns the array of sizes, or NULL if the matrix is not allocated | |
int | size (int i) const |
returns the size of i-th matrix dimension (or 0) | |
int | dims () const |
returns the matrix dimensionality | |
size_t | nzcount () const |
returns the number of non-zero elements (=the number of hash table nodes) | |
size_t | hash (int i0) const |
computes the element hash value (1D case) | |
size_t | hash (int i0, int i1) const |
computes the element hash value (2D case) | |
size_t | hash (int i0, int i1, int i2) const |
computes the element hash value (3D case) | |
size_t | hash (const int *idx) const |
computes the element hash value (nD case) | |
template<typename _Tp > | |
_Tp & | value (Node *n) |
returns the value stored in the sparse martix node | |
template<typename _Tp > | |
const _Tp & | value (const Node *n) const |
returns the value stored in the sparse martix node | |
void | erase (int i0, int i1, size_t *hashval=0) |
erases the specified element (2D case) | |
void | erase (int i0, int i1, int i2, size_t *hashval=0) |
erases the specified element (3D case) | |
void | erase (const int *idx, size_t *hashval=0) |
erases the specified element (nD case) | |
uchar * | ptr (int i0, bool createMissing, size_t *hashval=0) |
returns pointer to the specified element (1D case) | |
uchar * | ptr (int i0, int i1, bool createMissing, size_t *hashval=0) |
returns pointer to the specified element (2D case) | |
uchar * | ptr (int i0, int i1, int i2, bool createMissing, size_t *hashval=0) |
returns pointer to the specified element (3D case) | |
uchar * | ptr (const int *idx, bool createMissing, size_t *hashval=0) |
returns pointer to the specified element (nD case) | |
template<typename _Tp > | |
_Tp | value (int i0, size_t *hashval=0) const |
returns value of the specified element (1D case) | |
template<typename _Tp > | |
_Tp | value (int i0, int i1, size_t *hashval=0) const |
returns value of the specified element (2D case) | |
template<typename _Tp > | |
_Tp | value (int i0, int i1, int i2, size_t *hashval=0) const |
returns value of the specified element (3D case) | |
template<typename _Tp > | |
_Tp | value (const int *idx, size_t *hashval=0) const |
returns value of the specified element (nD case) | |
template<typename _Tp > | |
const _Tp * | find (int i0, size_t *hashval=0) const |
returns pointer to the specified element (1D case) | |
template<typename _Tp > | |
const _Tp * | find (int i0, int i1, size_t *hashval=0) const |
returns pointer to the specified element (2D case) | |
template<typename _Tp > | |
const _Tp * | find (int i0, int i1, int i2, size_t *hashval=0) const |
returns pointer to the specified element (3D case) | |
template<typename _Tp > | |
const _Tp * | find (const int *idx, size_t *hashval=0) const |
returns pointer to the specified element (nD case) |
Detailed Description
template<typename _Tp>
class cv::SparseMat_< _Tp >
Template sparse n-dimensional array class derived from SparseMat.
SparseMat_ is a thin wrapper on top of SparseMat created in the same way as Mat_ . It simplifies notation of some operations:
int sz[] = {10, 20, 30};
SparseMat_<double> M(3, sz);
...
M.ref(1, 2, 3) = M(4, 5, 6) + M(7, 8, 9);
Definition at line 2706 of file mat.hpp.
Constructor & Destructor Documentation
SparseMat_ | ( | ) |
the default constructor
SparseMat_ | ( | int | dims, |
const int * | _sizes | ||
) |
the full constructor equivelent to SparseMat(dims, _sizes, DataType<_Tp>::type)
SparseMat_ | ( | const SparseMat & | m ) |
the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted
SparseMat_ | ( | const SparseMat_< _Tp > & | m ) |
the copy constructor. This is O(1) operation - no data is copied
SparseMat_ | ( | const Mat & | m ) |
converts dense matrix to the sparse form
Member Function Documentation
void addref | ( | ) | [inherited] |
manually increments the reference counter to the header.
SparseMatConstIterator_<_Tp> begin | ( | ) | const |
returns read-only sparse matrix iterator pointing to the first sparse matrix element
Reimplemented from SparseMat.
SparseMatIterator_<_Tp> begin | ( | ) |
returns sparse matrix iterator pointing to the first sparse matrix element
Reimplemented from SparseMat.
int channels | ( | ) | const |
returns the number of channels in each matrix element
Reimplemented from SparseMat.
void clear | ( | ) | [inherited] |
sets all the sparse matrix elements to 0, which means clearing the hash table.
SparseMat_ clone | ( | ) | const |
makes full copy of the matrix. All the elements are duplicated
Reimplemented from SparseMat.
void convertTo | ( | SparseMat & | m, |
int | rtype, | ||
double | alpha = 1 |
||
) | const [inherited] |
multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type
void convertTo | ( | Mat & | m, |
int | rtype, | ||
double | alpha = 1 , |
||
double | beta = 0 |
||
) | const [inherited] |
converts sparse matrix to dense n-dim matrix with optional type conversion and scaling.
- Parameters:
-
[out] m - output matrix; if it does not have a proper size or type before the operation, it is reallocated [in] rtype – desired output matrix type or, rather, the depth since the number of channels are the same as the input has; if rtype is negative, the output matrix will have the same type as the input. [in] alpha – optional scale factor [in] beta – optional delta added to the scaled values
void copyTo | ( | SparseMat & | m ) | const [inherited] |
copies all the data to the destination matrix. All the previous content of m is erased
void copyTo | ( | Mat & | m ) | const [inherited] |
converts sparse matrix to dense matrix.
void create | ( | int | dims, |
const int * | _sizes | ||
) |
equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type)
void create | ( | int | dims, |
const int * | _sizes, | ||
int | _type | ||
) | [inherited] |
reallocates sparse matrix.
If the matrix already had the proper size and type, it is simply cleared with clear(), otherwise, the old matrix is released (using release()) and the new one is allocated.
int depth | ( | ) | const |
returns depth of the matrix elements
Reimplemented from SparseMat.
int dims | ( | ) | const [inherited] |
returns the matrix dimensionality
size_t elemSize | ( | ) | const [inherited] |
converts sparse matrix to the old-style representation; all the elements are copied.
returns the size of each element in bytes (not including the overhead - the space occupied by SparseMat::Node elements)
size_t elemSize1 | ( | ) | const [inherited] |
returns elemSize()/channels()
SparseMatIterator_<_Tp> end | ( | ) |
returns sparse matrix iterator pointing to the element following the last sparse matrix element
Reimplemented from SparseMat.
SparseMatConstIterator_<_Tp> end | ( | ) | const |
returns read-only sparse matrix iterator pointing to the element following the last sparse matrix element
Reimplemented from SparseMat.
void erase | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
erases the specified element (2D case)
void erase | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
erases the specified element (3D case)
void erase | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) | [inherited] |
erases the specified element (nD case)
const _Tp* find | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) | const [inherited] |
returns pointer to the specified element (nD case)
const _Tp* find | ( | int | i0, |
size_t * | hashval = 0 |
||
) | const [inherited] |
returns pointer to the specified element (1D case)
Return pointer to the specified sparse matrix element if it exists
`find<_Tp>(i0,...[,hashval])` is equivalent to `(_const Tp*)ptr(i0,...false[,hashval])`.
If the specified element does not exist, the methods return NULL.
const _Tp* find | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) | const [inherited] |
returns pointer to the specified element (2D case)
const _Tp* find | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) | const [inherited] |
returns pointer to the specified element (3D case)
size_t hash | ( | int | i0 ) | const [inherited] |
computes the element hash value (1D case)
size_t hash | ( | int | i0, |
int | i1 | ||
) | const [inherited] |
computes the element hash value (2D case)
size_t hash | ( | int | i0, |
int | i1, | ||
int | i2 | ||
) | const [inherited] |
computes the element hash value (3D case)
size_t hash | ( | const int * | idx ) | const [inherited] |
computes the element hash value (nD case)
size_t nzcount | ( | ) | const [inherited] |
returns the number of non-zero elements (=the number of hash table nodes)
_Tp operator() | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) | const |
equivalent to SparseMat::value<_Tp>(idx, hashval)
_Tp operator() | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) | const |
equivalent to SparseMat::value<_Tp>(i0, i1, hashval)
_Tp operator() | ( | int | i0, |
size_t * | hashval = 0 |
||
) | const |
equivalent to SparseMat::value<_Tp>(i0, hashval)
_Tp operator() | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) | const |
equivalent to SparseMat::value<_Tp>(i0, i1, i2, hashval)
SparseMat_& operator= | ( | const SparseMat_< _Tp > & | m ) |
the assignment operator. This is O(1) operation - no data is copied
SparseMat_& operator= | ( | const SparseMat & | m ) |
converts the old-style sparse matrix to the C++ class. All the elements are copied
the assignment operator. If DataType<_Tp>.type != m.type(), the m elements are converted
Reimplemented from SparseMat.
SparseMat_& operator= | ( | const Mat & | m ) |
converts dense matrix to the sparse form
Reimplemented from SparseMat.
uchar* ptr | ( | int | i0, |
bool | createMissing, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
returns pointer to the specified element (1D case)
specialized variants for 1D, 2D, 3D cases and the generic_type one for n-D case. return pointer to the matrix element.
- if the element is there (it's non-zero), the pointer to it is returned
- if it's not there and createMissing=false, NULL pointer is returned
- if it's not there and createMissing=true, then the new element is created and initialized with 0. Pointer to it is returned
- if the optional hashval pointer is not NULL, the element hash value is not computed, but *hashval is taken instead.
uchar* ptr | ( | int | i0, |
int | i1, | ||
int | i2, | ||
bool | createMissing, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
returns pointer to the specified element (3D case)
uchar* ptr | ( | int | i0, |
int | i1, | ||
bool | createMissing, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
returns pointer to the specified element (2D case)
uchar* ptr | ( | const int * | idx, |
bool | createMissing, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
returns pointer to the specified element (nD case)
_Tp& ref | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) |
equivalent to SparseMat::ref<_Tp>(idx, hashval)
Reimplemented from SparseMat.
_Tp& ref | ( | int | i0, |
size_t * | hashval = 0 |
||
) |
equivalent to SparseMat::ref<_Tp>(i0, hashval)
Reimplemented from SparseMat.
_Tp& ref | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) |
equivalent to SparseMat::ref<_Tp>(i0, i1, i2, hashval)
Reimplemented from SparseMat.
_Tp& ref | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) |
equivalent to SparseMat::ref<_Tp>(i0, i1, hashval)
Reimplemented from SparseMat.
const int* size | ( | ) | const [inherited] |
returns the array of sizes, or NULL if the matrix is not allocated
int size | ( | int | i ) | const [inherited] |
returns the size of i-th matrix dimension (or 0)
int type | ( | ) | const |
converts sparse matrix to the old-style CvSparseMat. All the elements are copied
returns type of the matrix elements
Reimplemented from SparseMat.
_Tp& value | ( | Node * | n ) | [inherited] |
returns the value stored in the sparse martix node
_Tp value | ( | int | i0, |
size_t * | hashval = 0 |
||
) | const [inherited] |
returns value of the specified element (1D case)
return value of the specified sparse matrix element.
`value<_Tp>(i0,...[,hashval])` is equivalent to
{ const _Tp* p = find<_Tp>(i0,...[,hashval]); return p ? *p : _Tp(); }
That is, if the element did not exist, the methods return 0.
_Tp value | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) | const [inherited] |
returns value of the specified element (nD case)
const _Tp& value | ( | const Node * | n ) | const [inherited] |
returns the value stored in the sparse martix node
_Tp value | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) | const [inherited] |
returns value of the specified element (3D case)
_Tp value | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) | const [inherited] |
returns value of the specified element (2D case)
Generated on Tue Jul 12 2022 16:42:43 by 1.7.2