cv::SparseMat_< _Tp > Class Template Reference 核心功能 » 基本结构


Template sparse n-dimensional array class derived from SparseMat . 更多...

#include <opencv2/core/mat.hpp>

Inheritance diagram for cv::SparseMat_< _Tp >:
cv::SparseMat

公共类型

typedef SparseMatConstIterator_ < _Tp >  const_iterator
 
typedef SparseMatIterator_ < _Tp >  iterator
 
-  Public Types inherited from cv::SparseMat
enum   {
   MAGIC_VAL =0x42FD0000,
   MAX_DIM =32,
   HASH_SCALE =0x5bd1e995,
   HASH_BIT =0x80000000
}
 
typedef SparseMatConstIterator   const_iterator
 
typedef SparseMatIterator   iterator
 

Public Member Functions

  SparseMat_ ()
  the default constructor 更多...
 
  SparseMat_ (int dims , const int *_sizes)
  the full constructor equivalent 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 更多...
 
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 更多...
 
int  channels () const
  returns the number of channels in each matrix element 更多...
 
SparseMat_   clone () const CV_NODISCARD
  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  depth () const
  returns depth of the matrix elements 更多...
 
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 更多...
 
_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) 更多...
 
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 更多...
 
_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) 更多...
 
int  type () const
  converts sparse matrix to the old-style CvSparseMat. All the elements are copied 更多...
 
-  Public Member Functions inherited from cv::SparseMat
  SparseMat ()
  Various SparseMat 构造函数。 更多...
 
  SparseMat (int dims , const int *_sizes, int _type)
 
  SparseMat (const SparseMat &m)
 
  SparseMat (const Mat &m)
 
  ~SparseMat ()
  the destructor 更多...
 
void  addref ()
  manually increments the reference counter to the header. 更多...
 
void  assignTo ( SparseMat &m, int type =-1) const
 
int  channels () const
  returns the number of channels 更多...
 
void  clear ()
  sets all the sparse matrix elements to 0, which means clearing the hash table. 更多...
 
SparseMat   clone () const CV_NODISCARD
  creates full copy of the 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  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  create (int dims , const int *_sizes, int _type)
  reallocates sparse matrix. 更多...
 
int  depth () const
  returns the depth of sparse matrix elements 更多...
 
int  dims () const
  returns the matrix dimensionality 更多...
 
size_t  elemSize () const
  converts sparse matrix to the old-style representation; all the elements are copied. 更多...
 
size_t  elemSize1 () const
  返回 elemSize() /channels() 更多...
 
SparseMatIterator   end ()
  returns the sparse matrix iterator at the matrix end 更多...
 
SparseMatConstIterator   end () const
  returns the read-only sparse matrix iterator at the matrix end 更多...
 
template<typename _Tp >
SparseMatIterator_ < _Tp >  end ()
  returns the typed sparse matrix iterator at the matrix end 更多...
 
template<typename _Tp >
SparseMatConstIterator_ < _Tp >  end () const
  returns the typed read-only sparse matrix iterator at the matrix end 更多...
 
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) 更多...
 
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) 更多...
 
uchar newNode (const int *idx, size_t hashval)
 
Node node (size_t nidx)
 
const Node node (size_t nidx) const
 
size_t  nzcount () const
  returns the number of non-zero elements (=the number of hash table nodes) 更多...
 
SparseMat operator= (const SparseMat &m)
  assignment operator. This is O(1) operation, i.e. no data is copied 更多...
 
SparseMat operator= (const Mat &m)
  equivalent to the corresponding constructor 更多...
 
void  release ()
 
void  removeNode (size_t hidx, size_t nidx, size_t previdx)
 
void  resizeHashTab (size_t newsize)
 
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  type () const
  returns type of sparse matrix elements 更多...
 
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 更多...
 
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 &  ref (int i0, size_t *hashval=0)
  returns reference to the specified element (1D case) 更多...
 
template<typename _Tp >
_Tp &  ref (int i0, int i1, size_t *hashval=0)
  returns reference to the specified element (2D case) 更多...
 
template<typename _Tp >
_Tp &  ref (int i0, int i1, int i2, size_t *hashval=0)
  returns reference to the specified element (3D case) 更多...
 
template<typename _Tp >
_Tp &  ref (const int *idx, size_t *hashval=0)
  returns reference 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) 更多...
 
SparseMatIterator   begin ()
  returns the sparse matrix iterator at the matrix beginning 更多...
 
template<typename _Tp >
SparseMatIterator_ < _Tp >  begin ()
  returns the sparse matrix iterator at the matrix beginning 更多...
 
SparseMatConstIterator   begin () const
  returns the read-only sparse matrix iterator at the matrix beginning 更多...
 
template<typename _Tp >
SparseMatConstIterator_ < _Tp >  begin () const
  returns the read-only sparse matrix iterator at the matrix beginning 更多...
 

额外继承成员

-  Public Attributes inherited from cv::SparseMat
int  flags
 
Hdr hdr
 

详细描述

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

Member Typedef Documentation

◆  const_iterator

template<typename _Tp>
typedef SparseMatConstIterator_ <_Tp> cv::SparseMat_ < _Tp >:: const_iterator

◆  iterator

template<typename _Tp>
typedef SparseMatIterator_ <_Tp> cv::SparseMat_ < _Tp >:: iterator

Constructor & Destructor Documentation

◆  SparseMat_() [1/5]

template<typename _Tp>
cv::SparseMat_ < _Tp >:: SparseMat_ ( )

the default constructor

◆  SparseMat_() [2/5]

template<typename _Tp>
cv::SparseMat_ < _Tp >:: SparseMat_ ( int  dims ,
const int *  _sizes  
)

the full constructor equivalent to SparseMat(dims, _sizes, DataType<_Tp>::type)

◆  SparseMat_() [3/5]

template<typename _Tp>
cv::SparseMat_ < _Tp >:: SparseMat_ ( const SparseMat m )

the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted

◆  SparseMat_() [4/5]

template<typename _Tp>
cv::SparseMat_ < _Tp >:: SparseMat_ ( const SparseMat_ < _Tp > &  m )

the copy constructor. This is O(1) operation - no data is copied

◆  SparseMat_() [5/5]

template<typename _Tp>
cv::SparseMat_ < _Tp >:: SparseMat_ ( const Mat m )

converts dense matrix to the sparse form

成员函数文档编制

◆  begin() [1/2]

template<typename _Tp>
SparseMatIterator_ <_Tp> cv::SparseMat_ < _Tp >::begin ( )

returns sparse matrix iterator pointing to the first sparse matrix element

◆  begin() [2/2]

template<typename _Tp>
SparseMatConstIterator_ <_Tp> cv::SparseMat_ < _Tp >::begin ( ) const

returns read-only sparse matrix iterator pointing to the first sparse matrix element

◆  channels()

template<typename _Tp>
int cv::SparseMat_ < _Tp >::channels ( ) const

returns the number of channels in each matrix element

◆  clone()

template<typename _Tp>
SparseMat_ cv::SparseMat_ < _Tp >::clone ( ) const

makes full copy of the matrix. All the elements are duplicated

◆  create()

template<typename _Tp>
void cv::SparseMat_ < _Tp >::create ( int  dims ,
const int *  _sizes  
)

equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type)

◆  depth()

template<typename _Tp>
int cv::SparseMat_ < _Tp >::depth ( ) const

returns depth of the matrix elements

◆  end() [1/2]

template<typename _Tp>
SparseMatIterator_ <_Tp> cv::SparseMat_ < _Tp >::end ( )

returns sparse matrix iterator pointing to the element following the last sparse matrix element

◆  end() [2/2]

template<typename _Tp>
SparseMatConstIterator_ <_Tp> cv::SparseMat_ < _Tp >::end ( ) const

returns read-only sparse matrix iterator pointing to the element following the last sparse matrix element

◆  operator()() [1/4]

template<typename _Tp>
_Tp cv::SparseMat_ < _Tp >::operator() ( int  i0 ,
size_t *  hashval = 0  
) const

equivalent to SparseMat::value<_Tp>(i0, hashval)

◆  operator()() [2/4]

template<typename _Tp>
_Tp cv::SparseMat_ < _Tp >::operator() ( int  i0 ,
int  i1 ,
size_t *  hashval = 0  
) const

equivalent to SparseMat::value<_Tp>(i0, i1, hashval)

◆  operator()() [3/4]

template<typename _Tp>
_Tp cv::SparseMat_ < _Tp >::operator() ( int  i0 ,
int  i1 ,
int  i2 ,
size_t *  hashval = 0  
) const

equivalent to SparseMat::value<_Tp>(i0, i1, i2, hashval)

◆  operator()() [4/4]

template<typename _Tp>
_Tp cv::SparseMat_ < _Tp >::operator() ( const int *  idx ,
size_t *  hashval = 0  
) const

equivalent to SparseMat::value<_Tp>(idx, hashval)

◆  operator=() [1/3]

template<typename _Tp>
SparseMat_ & cv::SparseMat_ < _Tp >::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

◆  operator=() [2/3]

template<typename _Tp>
SparseMat_ & cv::SparseMat_ < _Tp >::operator= ( const SparseMat_ < _Tp > &  m )

the assignment operator. This is O(1) operation - no data is copied

◆  operator=() [3/3]

template<typename _Tp>
SparseMat_ & cv::SparseMat_ < _Tp >::operator= ( const Mat m )

converts dense matrix to the sparse form

◆  ref() [1/4]

template<typename _Tp>
_Tp& cv::SparseMat_ < _Tp >::ref ( int  i0 ,
size_t *  hashval = 0  
)

equivalent to SparseMat::ref<_Tp>(i0, hashval)

◆  ref() [2/4]

template<typename _Tp>
_Tp& cv::SparseMat_ < _Tp >::ref ( int  i0 ,
int  i1 ,
size_t *  hashval = 0  
)

equivalent to SparseMat::ref<_Tp>(i0, i1, hashval)

◆  ref() [3/4]

template<typename _Tp>
_Tp& cv::SparseMat_ < _Tp >::ref ( int  i0 ,
int  i1 ,
int  i2 ,
size_t *  hashval = 0  
)

equivalent to SparseMat::ref<_Tp>(i0, i1, i2, hashval)

◆  ref() [4/4]

template<typename _Tp>
_Tp& cv::SparseMat_ < _Tp >::ref ( const int *  idx ,
size_t *  hashval = 0  
)

equivalent to SparseMat::ref<_Tp>(idx, hashval)

◆  type()

template<typename _Tp>
int cv::SparseMat_ < _Tp >::type ( ) const

converts sparse matrix to the old-style CvSparseMat. All the elements are copied

returns type of the matrix elements


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