44#ifndef OPENCV_CORE_MAT_HPP
45#define OPENCV_CORE_MAT_HPP
48# error mat.hpp header must be compiled as C++
51#include "opencv2/core/matx.hpp"
52#include "opencv2/core/types.hpp"
54#include "opencv2/core/bufferpool.hpp"
64enum AccessFlag { ACCESS_READ=1<<24, ACCESS_WRITE=1<<25,
65 ACCESS_RW=3<<24, ACCESS_MASK=ACCESS_RW, ACCESS_FAST=1<<26 };
66CV_ENUM_FLAGS(AccessFlag)
67__CV_ENUM_FLAGS_BITWISE_AND(AccessFlag,
int, AccessFlag)
71class CV_EXPORTS _OutputArray;
163 FIXED_TYPE = 0x8000 << KIND_SHIFT,
164 FIXED_SIZE = 0x4000 << KIND_SHIFT,
165 KIND_MASK = 31 << KIND_SHIFT,
167 NONE = 0 << KIND_SHIFT,
168 MAT = 1 << KIND_SHIFT,
169 MATX = 2 << KIND_SHIFT,
170 STD_VECTOR = 3 << KIND_SHIFT,
171 STD_VECTOR_VECTOR = 4 << KIND_SHIFT,
172 STD_VECTOR_MAT = 5 << KIND_SHIFT,
173#if OPENCV_ABI_COMPATIBILITY < 500
174 EXPR = 6 << KIND_SHIFT,
176 OPENGL_BUFFER = 7 << KIND_SHIFT,
177 CUDA_HOST_MEM = 8 << KIND_SHIFT,
178 CUDA_GPU_MAT = 9 << KIND_SHIFT,
179 UMAT =10 << KIND_SHIFT,
180 STD_VECTOR_UMAT =11 << KIND_SHIFT,
181 STD_BOOL_VECTOR =12 << KIND_SHIFT,
182 STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT,
183#if OPENCV_ABI_COMPATIBILITY < 500
184 STD_ARRAY =14 << KIND_SHIFT,
186 STD_ARRAY_MAT =15 << KIND_SHIFT
195 template<
typename _Tp>
_InputArray(
const std::vector<_Tp>& vec);
197 template<
typename _Tp>
_InputArray(
const std::vector<std::vector<_Tp> >& vec);
198 _InputArray(
const std::vector<std::vector<bool> >&) =
delete;
200 template<
typename _Tp>
_InputArray(
const _Tp* vec,
int n);
204 _InputArray(
const std::vector<cuda::GpuMat>& d_mat_array);
207 template<
typename _Tp>
_InputArray(
const cudev::GpuMat_<_Tp>& m);
211 template<
typename _Tp, std::
size_t _Nm>
_InputArray(
const std::array<_Tp, _Nm>& arr);
212 template<std::
size_t _Nm>
_InputArray(
const std::array<Mat, _Nm>& arr);
214 template<
typename _Tp>
static _InputArray rawIn(
const std::vector<_Tp>& vec);
215 template<
typename _Tp, std::
size_t _Nm>
static _InputArray rawIn(
const std::array<_Tp, _Nm>& arr);
217 Mat getMat(
int idx=-1)
const;
218 Mat getMat_(
int idx=-1)
const;
219 UMat getUMat(
int idx=-1)
const;
220 void getMatVector(std::vector<Mat>& mv)
const;
221 void getUMatVector(std::vector<UMat>& umv)
const;
222 void getGpuMatVector(std::vector<cuda::GpuMat>& gpumv)
const;
226 int getFlags()
const;
227 void* getObj()
const;
231 int dims(
int i=-1)
const;
232 int cols(
int i=-1)
const;
233 int rows(
int i=-1)
const;
234 Size size(
int i=-1)
const;
235 int sizend(
int* sz,
int i=-1)
const;
237 size_t total(
int i=-1)
const;
238 int type(
int i=-1)
const;
239 int depth(
int i=-1)
const;
240 int channels(
int i=-1)
const;
241 bool isContinuous(
int i=-1)
const;
242 bool isSubmatrix(
int i=-1)
const;
246 size_t offset(
int i=-1)
const;
247 size_t step(
int i=-1)
const;
250 bool isMatVector()
const;
251 bool isUMatVector()
const;
253 bool isVector()
const;
254 bool isGpuMat()
const;
255 bool isGpuMatVector()
const;
263 void init(
int _flags,
const void* _obj);
264 void init(
int _flags,
const void* _obj,
Size _sz);
299 DEPTH_MASK_8U = 1 << CV_8U,
300 DEPTH_MASK_8S = 1 << CV_8S,
301 DEPTH_MASK_16U = 1 << CV_16U,
302 DEPTH_MASK_16S = 1 << CV_16S,
303 DEPTH_MASK_32S = 1 << CV_32S,
304 DEPTH_MASK_32F = 1 << CV_32F,
305 DEPTH_MASK_64F = 1 << CV_64F,
306 DEPTH_MASK_16F = 1 << CV_16F,
307 DEPTH_MASK_ALL = (DEPTH_MASK_64F<<1)-1,
308 DEPTH_MASK_ALL_BUT_8S = DEPTH_MASK_ALL & ~DEPTH_MASK_8S,
309 DEPTH_MASK_ALL_16F = (DEPTH_MASK_16F<<1)-1,
310 DEPTH_MASK_FLT = DEPTH_MASK_32F + DEPTH_MASK_64F
321 template<
typename _Tp>
_OutputArray(cudev::GpuMat_<_Tp>& m);
322 template<
typename _Tp>
_OutputArray(std::vector<_Tp>& vec);
324 template<
typename _Tp>
_OutputArray(std::vector<std::vector<_Tp> >& vec);
325 _OutputArray(std::vector<std::vector<bool> >&) =
delete;
339 template<
typename _Tp>
_OutputArray(
const cudev::GpuMat_<_Tp>& m);
340 template<
typename _Tp>
_OutputArray(
const std::vector<_Tp>& vec);
341 template<
typename _Tp>
_OutputArray(
const std::vector<std::vector<_Tp> >& vec);
344 template<
typename _Tp>
_OutputArray(
const _Tp* vec,
int n);
349 template<
typename _Tp, std::
size_t _Nm>
_OutputArray(std::array<_Tp, _Nm>& arr);
350 template<
typename _Tp, std::
size_t _Nm>
_OutputArray(
const std::array<_Tp, _Nm>& arr);
351 template<std::
size_t _Nm>
_OutputArray(std::array<Mat, _Nm>& arr);
352 template<std::
size_t _Nm>
_OutputArray(
const std::array<Mat, _Nm>& arr);
355 template<
typename _Tp, std::
size_t _Nm>
static _OutputArray rawOut(std::array<_Tp, _Nm>& arr);
357 bool fixedSize()
const;
358 bool fixedType()
const;
360 Mat& getMatRef(
int i=-1)
const;
361 UMat& getUMatRef(
int i=-1)
const;
363 std::vector<cuda::GpuMat>& getGpuMatVecRef()
const;
366 void create(
Size sz,
int type,
int i=-1,
bool allowTransposed=
false, _OutputArray::DepthMask fixedDepthMask=
static_cast<_OutputArray::DepthMask
>(0))
const;
367 void create(
int rows,
int cols,
int type,
int i=-1,
bool allowTransposed=
false, _OutputArray::DepthMask fixedDepthMask=
static_cast<_OutputArray::DepthMask
>(0))
const;
368 void create(
int dims,
const int* size,
int type,
int i=-1,
bool allowTransposed=
false, _OutputArray::DepthMask fixedDepthMask=
static_cast<_OutputArray::DepthMask
>(0))
const;
369 void createSameSize(
const _InputArray& arr,
int mtype)
const;
370 void release()
const;
374 void assign(
const UMat& u)
const;
375 void assign(
const Mat& m)
const;
377 void assign(
const std::vector<UMat>& v)
const;
378 void assign(
const std::vector<Mat>& v)
const;
380 void move(
UMat& u)
const;
381 void move(
Mat& m)
const;
414 template<
typename _Tp>
_InputOutputArray(
const std::vector<std::vector<_Tp> >& vec);
422 template<
typename _Tp, std::
size_t _Nm>
_InputOutputArray(std::array<_Tp, _Nm>& arr);
423 template<
typename _Tp, std::
size_t _Nm>
_InputOutputArray(
const std::array<_Tp, _Nm>& arr);
442typedef InputArray InputArrayOfArrays;
458 USAGE_ALLOCATE_HOST_MEMORY = 1 << 0,
459 USAGE_ALLOCATE_DEVICE_MEMORY = 1 << 1,
460 USAGE_ALLOCATE_SHARED_MEMORY = 1 << 2,
462 __UMAT_USAGE_FLAGS_32BIT = 0x7fffffff
465struct CV_EXPORTS UMatData;
479 virtual UMatData* allocate(
int dims,
const int* sizes,
int type,
480 void* data,
size_t* step, AccessFlag flags,
UMatUsageFlags usageFlags)
const = 0;
482 virtual void deallocate(
UMatData* data)
const = 0;
483 virtual void map(
UMatData* data, AccessFlag accessflags)
const;
484 virtual void unmap(
UMatData* data)
const;
485 virtual void download(
UMatData* data,
void* dst,
int dims,
const size_t sz[],
486 const size_t srcofs[],
const size_t srcstep[],
487 const size_t dststep[])
const;
488 virtual void upload(
UMatData* data,
const void* src,
int dims,
const size_t sz[],
489 const size_t dstofs[],
const size_t dststep[],
490 const size_t srcstep[])
const;
491 virtual void copy(
UMatData* srcdata,
UMatData* dstdata,
int dims,
const size_t sz[],
492 const size_t srcofs[],
const size_t srcstep[],
493 const size_t dstofs[],
const size_t dststep[],
bool sync)
const;
536 enum MemoryFlag { COPY_ON_MAP=1, HOST_COPY_OBSOLETE=2,
537 DEVICE_COPY_OBSOLETE=4, TEMP_UMAT=8, TEMP_COPIED_UMAT=24,
538 USER_ALLOCATED=32, DEVICE_MEM_MAPPED=64,
548 bool hostCopyObsolete()
const;
549 bool deviceCopyObsolete()
const;
550 bool deviceMemMapped()
const;
551 bool copyOnMap()
const;
552 bool tempUMat()
const;
553 bool tempCopiedUMat()
const;
554 void markHostCopyObsolete(
bool flag);
555 void markDeviceCopyObsolete(
bool flag);
556 void markDeviceMemMapped(
bool flag);
566 UMatData::MemoryFlag flags;
572 std::shared_ptr<void> allocatorContext;
574CV_ENUM_FLAGS(UMatData::MemoryFlag)
579 explicit MatSize(
int* _p) CV_NOEXCEPT;
580 int dims()
const CV_NOEXCEPT;
581 Size operator()()
const;
582 const int& operator[](
int i)
const;
583 int& operator[](
int i);
584 operator const int*()
const CV_NOEXCEPT;
585 bool operator == (
const MatSize& sz)
const CV_NOEXCEPT;
586 bool operator != (
const MatSize& sz)
const CV_NOEXCEPT;
594 explicit MatStep(
size_t s) CV_NOEXCEPT;
595 const size_t& operator[](
int i)
const CV_NOEXCEPT;
596 size_t& operator[](
int i) CV_NOEXCEPT;
597 operator size_t()
const;
598 MatStep& operator = (
size_t s);
818 Mat(
int rows,
int cols,
int type);
856 Mat(
int ndims, const
int* sizes,
int type);
863 Mat(const std::vector<
int>& sizes,
int type);
874 Mat(
int ndims, const
int* sizes,
int type, const
Scalar& s);
884 Mat(const std::vector<
int>& sizes,
int type, const
Scalar& s);
910 Mat(
int rows,
int cols,
int type,
void* data,
size_t step=AUTO_STEP);
926 Mat(
Size size,
int type,
void* data,
size_t step=AUTO_STEP);
941 Mat(
int ndims, const
int* sizes,
int type,
void* data, const
size_t* steps=0);
955 Mat(const std::vector<
int>& sizes,
int type,
void* data, const
size_t* steps=0);
1015 template<typename _Tp> explicit
Mat(const std::vector<_Tp>& vec,
bool copyData=false);
1019 template<typename _Tp, typename = typename std::enable_if<std::is_arithmetic<_Tp>::value>::type>
1020 explicit
Mat(const std::initializer_list<_Tp> list);
1024 template<typename _Tp> explicit
Mat(const std::initializer_list<
int> sizes, const std::initializer_list<_Tp> list);
1028 template<typename _Tp,
size_t _Nm> explicit
Mat(const std::array<_Tp, _Nm>& arr,
bool copyData=false);
1032 template<typename _Tp,
int n> explicit
Mat(const
Vec<_Tp, n>& vec,
bool copyData=true);
1036 template<typename _Tp,
int m,
int n> explicit
Mat(const
Matx<_Tp, m, n>& mtx,
bool copyData=true);
1040 template<typename _Tp> explicit
Mat(const
Point_<_Tp>& pt,
bool copyData=true);
1044 template<typename _Tp> explicit
Mat(const
Point3_<_Tp>& pt,
bool copyData=true);
1051 explicit
Mat(const cuda::GpuMat& m);
1129 Mat rowRange(
int startrow,
int endrow) const;
1143 Mat colRange(
int startcol,
int endcol) const;
1198 Mat clone() const CV_NODISCARD;
1238 void convertTo(
OutputArray m,
int rtype,
double alpha=1,
double beta=0 ) const;
1246 void assignTo(
Mat& m,
int type=-1 ) const;
1260 Mat& setTo(InputArray value, InputArray mask=noArray());
1286 Mat reshape(
int cn,
int rows=0) const;
1289 Mat reshape(
int cn,
int newndims, const
int* newsz) const;
1292 Mat reshape(
int cn, const std::vector<
int>& newshape) const;
1336 Mat cross(InputArray m) const;
1346 double dot(InputArray m) const;
1362 static
MatExpr zeros(
int rows,
int cols,
int type);
1375 static
MatExpr zeros(
int ndims, const
int* sz,
int type);
1393 static
MatExpr ones(
int rows,
int cols,
int type);
1406 static
MatExpr ones(
int ndims, const
int* sz,
int type);
1463 void create(
int rows,
int cols,
int type);
1476 void create(
int ndims, const
int* sizes,
int type);
1482 void create(const std::vector<
int>& sizes,
int type);
1522 void reserve(
size_t sz);
1530 void reserveBuffer(
size_t sz);
1548 void push_back_(const
void* elem);
1557 template<typename _Tp>
void push_back(const _Tp& elem);
1562 template<typename _Tp>
void push_back(const
Mat_<_Tp>& elem);
1567 template<typename _Tp>
void push_back(const std::vector<_Tp>& elem);
1580 void pop_back(
size_t nelems=1);
1622 Mat& adjustROI(
int dtop,
int dbottom,
int dleft,
int dright );
1650 Mat operator()(const std::vector<
Range>& ranges) const;
1652 template<typename _Tp> operator std::vector<_Tp>() const;
1653 template<typename _Tp,
int n> operator
Vec<_Tp, n>() const;
1654 template<typename _Tp,
int m,
int n> operator
Matx<_Tp, m, n>() const;
1656 template<typename _Tp, std::
size_t _Nm> operator std::array<_Tp, _Nm>() const;
1732 bool isContinuous() const;
1735 bool isSubmatrix() const;
1742 size_t elemSize() const;
1749 size_t elemSize1() const;
1777 int channels() const;
1784 size_t step1(
int i=0) const;
1798 size_t total() const;
1804 size_t total(
int startDim,
int endDim=INT_MAX) const;
1827 int checkVector(
int elemChannels,
int depth=-1,
bool requireContinuous=true) const;
1835 uchar* ptr(
int i0=0);
1837 const uchar* ptr(
int i0=0) const;
1843 uchar* ptr(
int row,
int col);
1848 const uchar* ptr(
int row,
int col) const;
1851 uchar* ptr(
int i0,
int i1,
int i2);
1853 const uchar* ptr(
int i0,
int i1,
int i2) const;
1856 uchar* ptr(const
int* idx);
1858 const uchar* ptr(const
int* idx) const;
1860 template<
int n> uchar* ptr(const
Vec<
int, n>& idx);
1862 template<
int n> const uchar* ptr(const
Vec<
int, n>& idx) const;
1865 template<typename _Tp> _Tp* ptr(
int i0=0);
1867 template<typename _Tp> const _Tp* ptr(
int i0=0) const;
1872 template<typename _Tp> _Tp* ptr(
int row,
int col);
1877 template<typename _Tp> const _Tp* ptr(
int row,
int col) const;
1879 template<typename _Tp> _Tp* ptr(
int i0,
int i1,
int i2);
1881 template<typename _Tp> const _Tp* ptr(
int i0,
int i1,
int i2) const;
1883 template<typename _Tp> _Tp* ptr(const
int* idx);
1885 template<typename _Tp> const _Tp* ptr(const
int* idx) const;
1887 template<typename _Tp,
int n> _Tp* ptr(const
Vec<
int, n>& idx);
1889 template<typename _Tp,
int n> const _Tp* ptr(const
Vec<
int, n>& idx) const;
1921 template<typename _Tp> _Tp& at(
int i0=0);
1925 template<typename _Tp> const _Tp& at(
int i0=0) const;
1930 template<typename _Tp> _Tp& at(
int row,
int col);
1935 template<typename _Tp> const _Tp& at(
int row,
int col) const;
1942 template<typename _Tp> _Tp& at(
int i0,
int i1,
int i2);
1948 template<typename _Tp> const _Tp& at(
int i0,
int i1,
int i2) const;
1953 template<typename _Tp> _Tp& at(const
int* idx);
1957 template<typename _Tp> const _Tp& at(const
int* idx) const;
1960 template<typename _Tp,
int n> _Tp& at(const
Vec<
int, n>& idx);
1962 template<typename _Tp,
int n> const _Tp& at(const
Vec<
int, n>& idx) const;
1968 template<typename _Tp> _Tp& at(
Point pt);
1973 template<typename _Tp> const _Tp& at(
Point pt) const;
2017 template<typename _Tp> std::reverse_iterator<
MatConstIterator_<_Tp>> rbegin() const;
2030 template<typename _Tp> std::reverse_iterator<
MatConstIterator_<_Tp>> rend() const;
2087 template<typename _Tp, typename Functor>
void forEach(const Functor& operation);
2089 template<typename _Tp, typename Functor>
void forEach(const Functor& operation) const;
2092 Mat& operator = (
Mat&& m);
2094 enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG };
2095 enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 };
2113 const uchar* dataend;
2114 const uchar* datalimit;
2121 static void setDefaultAllocator(
MatAllocator* allocator);
2133 template<
typename _Tp,
typename Functor>
void forEach_impl(
const Functor& operation);
2201 typedef _Tp value_type;
2211 Mat_(
int _rows,
int _cols, const _Tp& value);
2217 Mat_(
int _ndims, const
int* _sizes);
2219 Mat_(
int _ndims, const
int* _sizes, const _Tp& value);
2225 Mat_(
int _rows,
int _cols, _Tp* _data,
size_t _step=AUTO_STEP);
2227 Mat_(
int _ndims, const
int* _sizes, _Tp* _data, const
size_t* _steps=0);
2239 explicit
Mat_(const std::vector<_Tp>& vec,
bool copyData=false);
2240 template<
int n> explicit
Mat_(const
Vec<typename
DataType<_Tp>::channel_type, n>& vec,
bool copyData=true);
2241 template<
int m,
int n> explicit
Mat_(const
Matx<typename
DataType<_Tp>::channel_type, m, n>& mtx,
bool copyData=true);
2242 explicit
Mat_(const
Point_<typename
DataType<_Tp>::channel_type>& pt,
bool copyData=true);
2243 explicit
Mat_(const
Point3_<typename
DataType<_Tp>::channel_type>& pt,
bool copyData=true);
2246 Mat_(std::initializer_list<_Tp> values);
2247 explicit
Mat_(const std::initializer_list<
int> sizes, const std::initializer_list<_Tp> values);
2249 template <std::
size_t _Nm> explicit
Mat_(const std::array<_Tp, _Nm>& arr,
bool copyData=false);
2251 Mat_& operator = (const
Mat& m);
2265 std::reverse_iterator<
iterator> rbegin();
2266 std::reverse_iterator<
iterator> rend();
2272 template<typename Functor>
void forEach(const Functor& operation);
2273 template<typename Functor>
void forEach(const Functor& operation) const;
2286 template<typename T2> operator
Mat_<T2>() const;
2289 Mat_ col(
int x) const;
2290 Mat_ diag(
int d=0) const;
2291 Mat_ clone() const CV_NODISCARD;
2295 size_t elemSize1() const;
2298 int channels() const;
2299 size_t step1(
int i=0) const;
2309 static
MatExpr ones(
int _ndims, const
int* _sizes);
2316 Mat_ operator()( const
Rect& roi ) const;
2317 Mat_ operator()( const
Range* ranges ) const;
2318 Mat_ operator()(const std::vector<
Range>& ranges) const;
2321 _Tp* operator [](
int y);
2322 const _Tp* operator [](
int y) const;
2325 _Tp& operator ()(const
int* idx);
2327 const _Tp& operator ()(const
int* idx) const;
2330 template<
int n> _Tp& operator ()(const
Vec<
int, n>& idx);
2332 template<
int n> const _Tp& operator ()(const
Vec<
int, n>& idx) const;
2335 _Tp& operator ()(
int idx0);
2337 const _Tp& operator ()(
int idx0) const;
2339 _Tp& operator ()(
int row,
int col);
2341 const _Tp& operator ()(
int row,
int col) const;
2343 _Tp& operator ()(
int idx0,
int idx1,
int idx2);
2345 const _Tp& operator ()(
int idx0,
int idx1,
int idx2) const;
2347 _Tp& operator ()(
Point pt);
2348 const _Tp& operator ()(
Point pt) const;
2351 operator std::vector<_Tp>() const;
2354 template<std::
size_t _Nm> operator std::array<_Tp, _Nm>() const;
2357 template<
int n> operator
Vec<typename
DataType<_Tp>::channel_type, n>() const;
2359 template<
int m,
int n> operator
Matx<typename
DataType<_Tp>::channel_type, m, n>() const;
2425 UMat(
const UMat& m,
const std::vector<Range>& ranges);
2429 template<
typename _Tp>
explicit UMat(
const std::vector<_Tp>& vec,
bool copyData=
false);
2436 Mat getMat(AccessFlag flags)
const;
2455 static UMat diag(
const UMat& d) {
return diag(d, USAGE_DEFAULT); }
2476 UMat reshape(
int cn,
int newndims, const
int* newsz) const;
2486 double dot(InputArray m) const;
2494 static UMat
zeros(
int ndims,
const int* sz,
int type) {
return zeros(ndims, sz, type, USAGE_DEFAULT); }
2496 static UMat ones(Size size,
int type,
UMatUsageFlags usageFlags );
2497 static UMat ones(
int ndims,
const int* sz,
int type,
UMatUsageFlags usageFlags );
2498 static UMat ones(
int rows,
int cols,
int type) {
return ones(
rows, cols, type, USAGE_DEFAULT); }
2499 static UMat ones(Size size,
int type) {
return ones(size, type, USAGE_DEFAULT); }
2500 static UMat ones(
int ndims,
const int* sz,
int type) {
return ones(ndims, sz, type, USAGE_DEFAULT); }
2502 static UMat eye(Size size,
int type,
UMatUsageFlags usageFlags );
2503 static UMat eye(
int rows,
int cols,
int type) {
return eye(
rows, cols, type, USAGE_DEFAULT); }
2504 static UMat eye(Size size,
int type) {
return eye(size, type, USAGE_DEFAULT); }
2511 void create(
const std::vector<int>& sizes,
int type,
UMatUsageFlags usageFlags = USAGE_DEFAULT);
2531 UMat operator()(
const Rect& roi )
const;
2532 UMat operator()(
const Range* ranges )
const;
2533 UMat operator()(
const std::vector<Range>& ranges)
const;
2562 int checkVector(
int elemChannels,
int depth=-1,
bool requireContinuous=
true)
const;
2572 void ndoffset(
size_t* ofs)
const;
2574 enum { MAGIC_VAL = 0x42FF0000, AUTO_STEP = 0, CONTINUOUS_FLAG = CV_MAT_CONT_FLAG, SUBMATRIX_FLAG = CV_SUBMAT_FLAG };
2575 enum { MAGIC_MASK = 0xFFFF0000, TYPE_MASK = 0x00000FFF, DEPTH_MASK = 7 };
2709 enum { MAGIC_VAL=0x42FD0000, MAX_DIM=32, HASH_SCALE=0x5bd1e995, HASH_BIT=0x80000000 };
2714 Hdr(
int _dims,
const int* _sizes,
int _type);
2722 std::vector<uchar> pool;
2723 std::vector<size_t> hashtab;
2812 size_t elemSize1() const;
2819 int channels() const;
2822 const
int* size() const;
2824 int size(
int i) const;
2828 size_t nzcount() const;
2831 size_t hash(
int i0) const;
2833 size_t hash(
int i0,
int i1) const;
2835 size_t hash(
int i0,
int i1,
int i2) const;
2837 size_t hash(const
int* idx) const;
2851 uchar*
ptr(
int i0,
bool createMissing,
size_t* hashval=0);
2853 uchar*
ptr(
int i0,
int i1,
bool createMissing,
size_t* hashval=0);
2855 uchar*
ptr(
int i0,
int i1,
int i2,
bool createMissing,
size_t* hashval=0);
2857 uchar*
ptr(const
int* idx,
bool createMissing,
size_t* hashval=0);
2869 template<typename _Tp> _Tp& ref(
int i0,
size_t* hashval=0);
2871 template<typename _Tp> _Tp& ref(
int i0,
int i1,
size_t* hashval=0);
2873 template<typename _Tp> _Tp& ref(
int i0,
int i1,
int i2,
size_t* hashval=0);
2875 template<typename _Tp> _Tp& ref(const
int* idx,
size_t* hashval=0);
2890 template<typename _Tp> _Tp value(
int i0,
size_t* hashval=0) const;
2892 template<typename _Tp> _Tp value(
int i0,
int i1,
size_t* hashval=0) const;
2894 template<typename _Tp> _Tp value(
int i0,
int i1,
int i2,
size_t* hashval=0) const;
2896 template<typename _Tp> _Tp value(const
int* idx,
size_t* hashval=0) const;
2908 template<typename _Tp> const _Tp* find(
int i0,
size_t* hashval=0) const;
2910 template<typename _Tp> const _Tp* find(
int i0,
int i1,
size_t* hashval=0) const;
2912 template<typename _Tp> const _Tp* find(
int i0,
int i1,
int i2,
size_t* hashval=0) const;
2914 template<typename _Tp> const _Tp* find(const
int* idx,
size_t* hashval=0) const;
2918 void erase(
int i0,
int i1,
size_t* hashval=0);
2920 void erase(
int i0,
int i1,
int i2,
size_t* hashval=0);
2922 void erase(const
int* idx,
size_t* hashval=0);
2950 template<typename _Tp> _Tp& value(
Node* n);
2952 template<typename _Tp> const _Tp& value(const
Node* n) const;
2955 Node* node(
size_t nidx);
2956 const
Node* node(
size_t nidx) const;
2958 uchar* newNode(const
int* idx,
size_t hashval);
2959 void removeNode(
size_t hidx,
size_t nidx,
size_t previdx);
2960 void resizeHashTab(
size_t newsize);
3018 int channels() const;
3021 _Tp& ref(
int i0,
size_t* hashval=0);
3023 _Tp& ref(
int i0,
int i1,
size_t* hashval=0);
3025 _Tp& ref(
int i0,
int i1,
int i2,
size_t* hashval=0);
3027 _Tp& ref(const
int* idx,
size_t* hashval=0);
3030 _Tp operator()(
int i0,
size_t* hashval=0) const;
3032 _Tp operator()(
int i0,
int i1,
size_t* hashval=0) const;
3034 _Tp operator()(
int i0,
int i1,
int i2,
size_t* hashval=0) const;
3036 _Tp operator()(const
int* idx,
size_t* hashval=0) const;
3055 typedef uchar* value_type;
3056 typedef ptrdiff_t difference_type;
3057 typedef const uchar** pointer;
3058 typedef uchar* reference;
3060 typedef std::random_access_iterator_tag iterator_category;
3078 const uchar* operator *()
const;
3099 ptrdiff_t lpos()
const;
3100 void seek(ptrdiff_t ofs,
bool relative =
false);
3101 void seek(
const int* _idx,
bool relative =
false);
3106 const uchar* sliceStart;
3107 const uchar* sliceEnd;
3116template<
typename _Tp>
3120 typedef _Tp value_type;
3121 typedef ptrdiff_t difference_type;
3122 typedef const _Tp* pointer;
3123 typedef const _Tp& reference;
3125 typedef std::random_access_iterator_tag iterator_category;
3143 const _Tp& operator *()
const;
3169template<
typename _Tp>
3173 typedef _Tp* pointer;
3174 typedef _Tp& reference;
3176 typedef std::random_access_iterator_tag iterator_category;
3194 _Tp& operator *()
const;
3242 template<
typename _Tp>
const _Tp&
value()
const;
3287 template<
typename _Tp> _Tp&
value()
const;
3310 typedef std::forward_iterator_tag iterator_category;
3323 const _Tp& operator *()
const;
3344 typedef std::forward_iterator_tag iterator_category;
3357 _Tp& operator *()
const;
3439 void init(
const Mat** arrays,
Mat* planes, uchar** ptrs,
int narrays=-1);
3473 virtual bool elementWise(
const MatExpr& expr)
const;
3474 virtual void assign(
const MatExpr& expr,
Mat& m,
int type=-1)
const = 0;
3477 virtual void diag(
const MatExpr& expr,
int d,
MatExpr& res)
const;
3478 virtual void augAssignAdd(
const MatExpr& expr,
Mat& m)
const;
3479 virtual void augAssignSubtract(
const MatExpr& expr,
Mat& m)
const;
3480 virtual void augAssignMultiply(
const MatExpr& expr,
Mat& m)
const;
3481 virtual void augAssignDivide(
const MatExpr& expr,
Mat& m)
const;
3482 virtual void augAssignAnd(
const MatExpr& expr,
Mat& m)
const;
3483 virtual void augAssignOr(
const MatExpr& expr,
Mat& m)
const;
3484 virtual void augAssignXor(
const MatExpr& expr,
Mat& m)
const;
3505 virtual int type(
const MatExpr& expr)
const;
3561 const Mat& _c =
Mat(),
double _alpha = 1,
double _beta = 1,
const Scalar& _s =
Scalar());
3563 operator Mat()
const;
3564 template<
typename _Tp>
operator Mat_<_Tp>()
const;
3571 MatExpr diag(
int d = 0)
const;
3581 double dot(
const Mat& m)
const;
3605template<
typename _Tp,
int m,
int n>
static inline
3607template<
typename _Tp,
int m,
int n>
static inline
3608MatExpr operator + (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) + b; }
3610CV_EXPORTS MatExpr operator - (
const Mat& a,
const Mat& b);
3611CV_EXPORTS MatExpr operator - (
const Mat& a,
const Scalar& s);
3612CV_EXPORTS MatExpr operator - (
const Scalar& s,
const Mat& a);
3613CV_EXPORTS MatExpr operator - (
const MatExpr& e,
const Mat& m);
3614CV_EXPORTS MatExpr operator - (
const Mat& m,
const MatExpr& e);
3615CV_EXPORTS MatExpr operator - (
const MatExpr& e,
const Scalar& s);
3616CV_EXPORTS MatExpr operator - (
const Scalar& s,
const MatExpr& e);
3617CV_EXPORTS MatExpr operator - (
const MatExpr& e1,
const MatExpr& e2);
3618template<
typename _Tp,
int m,
int n>
static inline
3619MatExpr operator - (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a -
Mat(b); }
3620template<
typename _Tp,
int m,
int n>
static inline
3621MatExpr operator - (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) - b; }
3623CV_EXPORTS MatExpr operator - (
const Mat& m);
3624CV_EXPORTS MatExpr operator - (
const MatExpr& e);
3626CV_EXPORTS MatExpr operator * (
const Mat& a,
const Mat& b);
3627CV_EXPORTS MatExpr operator * (
const Mat& a,
double s);
3628CV_EXPORTS MatExpr operator * (
double s,
const Mat& a);
3629CV_EXPORTS MatExpr operator * (
const MatExpr& e,
const Mat& m);
3630CV_EXPORTS MatExpr operator * (
const Mat& m,
const MatExpr& e);
3631CV_EXPORTS MatExpr operator * (
const MatExpr& e,
double s);
3632CV_EXPORTS MatExpr operator * (
double s,
const MatExpr& e);
3633CV_EXPORTS MatExpr operator * (
const MatExpr& e1,
const MatExpr& e2);
3634template<
typename _Tp,
int m,
int n>
static inline
3635MatExpr operator * (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a *
Mat(b); }
3636template<
typename _Tp,
int m,
int n>
static inline
3637MatExpr operator * (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) * b; }
3642CV_EXPORTS MatExpr
operator / (
const MatExpr& e,
const Mat& m);
3643CV_EXPORTS MatExpr
operator / (
const Mat& m,
const MatExpr& e);
3644CV_EXPORTS MatExpr
operator / (
const MatExpr& e,
double s);
3645CV_EXPORTS MatExpr
operator / (
double s,
const MatExpr& e);
3646CV_EXPORTS MatExpr
operator / (
const MatExpr& e1,
const MatExpr& e2);
3647template<
typename _Tp,
int m,
int n>
static inline
3648MatExpr
operator / (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a /
Mat(b); }
3649template<
typename _Tp,
int m,
int n>
static inline
3650MatExpr
operator / (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) / b; }
3652CV_EXPORTS MatExpr operator < (
const Mat& a,
const Mat& b);
3653CV_EXPORTS MatExpr operator < (
const Mat& a,
double s);
3654CV_EXPORTS MatExpr operator < (
double s,
const Mat& a);
3655template<
typename _Tp,
int m,
int n>
static inline
3656MatExpr operator < (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a <
Mat(b); }
3657template<
typename _Tp,
int m,
int n>
static inline
3658MatExpr operator < (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) < b; }
3660CV_EXPORTS MatExpr operator <= (
const Mat& a,
const Mat& b);
3661CV_EXPORTS MatExpr operator <= (
const Mat& a,
double s);
3662CV_EXPORTS MatExpr operator <= (
double s,
const Mat& a);
3663template<
typename _Tp,
int m,
int n>
static inline
3664MatExpr operator <= (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a <=
Mat(b); }
3665template<
typename _Tp,
int m,
int n>
static inline
3666MatExpr operator <= (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) <= b; }
3668CV_EXPORTS MatExpr operator == (
const Mat& a,
const Mat& b);
3669CV_EXPORTS MatExpr operator == (
const Mat& a,
double s);
3670CV_EXPORTS MatExpr operator == (
double s,
const Mat& a);
3671template<
typename _Tp,
int m,
int n>
static inline
3672MatExpr operator == (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a ==
Mat(b); }
3673template<
typename _Tp,
int m,
int n>
static inline
3674MatExpr operator == (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) == b; }
3676CV_EXPORTS MatExpr operator != (
const Mat& a,
const Mat& b);
3677CV_EXPORTS MatExpr operator != (
const Mat& a,
double s);
3678CV_EXPORTS MatExpr operator != (
double s,
const Mat& a);
3679template<
typename _Tp,
int m,
int n>
static inline
3680MatExpr operator != (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a !=
Mat(b); }
3681template<
typename _Tp,
int m,
int n>
static inline
3682MatExpr operator != (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) != b; }
3684CV_EXPORTS MatExpr operator >= (
const Mat& a,
const Mat& b);
3685CV_EXPORTS MatExpr operator >= (
const Mat& a,
double s);
3686CV_EXPORTS MatExpr operator >= (
double s,
const Mat& a);
3687template<
typename _Tp,
int m,
int n>
static inline
3688MatExpr operator >= (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a >=
Mat(b); }
3689template<
typename _Tp,
int m,
int n>
static inline
3690MatExpr operator >= (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) >= b; }
3692CV_EXPORTS MatExpr operator > (
const Mat& a,
const Mat& b);
3693CV_EXPORTS MatExpr operator > (
const Mat& a,
double s);
3694CV_EXPORTS MatExpr operator > (
double s,
const Mat& a);
3695template<
typename _Tp,
int m,
int n>
static inline
3696MatExpr operator > (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a >
Mat(b); }
3697template<
typename _Tp,
int m,
int n>
static inline
3698MatExpr operator > (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) > b; }
3701CV_EXPORTS MatExpr
operator & (
const Mat& a,
const Scalar& s);
3702CV_EXPORTS MatExpr
operator & (
const Scalar& s,
const Mat& a);
3703template<
typename _Tp,
int m,
int n>
static inline
3704MatExpr
operator & (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a &
Mat(b); }
3705template<
typename _Tp,
int m,
int n>
static inline
3706MatExpr
operator & (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) & b; }
3709CV_EXPORTS MatExpr
operator | (
const Mat& a,
const Scalar& s);
3710CV_EXPORTS MatExpr
operator | (
const Scalar& s,
const Mat& a);
3711template<
typename _Tp,
int m,
int n>
static inline
3712MatExpr
operator | (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a |
Mat(b); }
3713template<
typename _Tp,
int m,
int n>
static inline
3714MatExpr
operator | (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) | b; }
3717CV_EXPORTS MatExpr
operator ^ (
const Mat& a,
const Scalar& s);
3718CV_EXPORTS MatExpr
operator ^ (
const Scalar& s,
const Mat& a);
3719template<
typename _Tp,
int m,
int n>
static inline
3720MatExpr
operator ^ (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return a ^
Mat(b); }
3721template<
typename _Tp,
int m,
int n>
static inline
3722MatExpr
operator ^ (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return Mat(a) ^ b; }
3726CV_EXPORTS MatExpr
min(
const Mat& a,
const Mat& b);
3727CV_EXPORTS MatExpr
min(
const Mat& a,
double s);
3728CV_EXPORTS MatExpr
min(
double s,
const Mat& a);
3729template<
typename _Tp,
int m,
int n>
static inline
3730MatExpr
min (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return min(a,
Mat(b)); }
3731template<
typename _Tp,
int m,
int n>
static inline
3732MatExpr
min (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return min(
Mat(a), b); }
3734CV_EXPORTS MatExpr
max(
const Mat& a,
const Mat& b);
3735CV_EXPORTS MatExpr
max(
const Mat& a,
double s);
3736CV_EXPORTS MatExpr
max(
double s,
const Mat& a);
3737template<
typename _Tp,
int m,
int n>
static inline
3738MatExpr
max (
const Mat& a,
const Matx<_Tp, m, n>& b) {
return max(a,
Mat(b)); }
3739template<
typename _Tp,
int m,
int n>
static inline
3740MatExpr
max (
const Matx<_Tp, m, n>& a,
const Mat& b) {
return max(
Mat(a), b); }
3764#include "opencv2/core/mat.inl.hpp"
This type is very similar to InputArray except that it is used for input/output and output function p...
Definition: mat.hpp:295
Definition: bufferpool.hpp:22
Template "trait" class for OpenCV primitive data types.
Definition: traits.hpp:113
Template matrix class derived from Mat
Definition: mat.hpp:2199
void forEach(const Functor &operation)
template methods for for operation over all matrix elements.
Mat_() CV_NOEXCEPT
default constructor
Mat_ row(int y) const
overridden forms of Mat::row() etc.
_Tp * operator[](int y)
more convenient forms of row and element access operators
size_t elemSize() const
overridden forms of Mat::elemSize() etc.
iterator begin()
iterators; they are smart enough to skip gaps in the end of rows
static MatExpr zeros(int rows, int cols)
overridden forms of Mat::zeros() etc. Data type is omitted, of course
Mat_ cross(const Mat_ &m) const
cross-product
void release()
equivalent to Mat::release()
size_t stepT(int i=0) const
returns step()/sizeof(_Tp)
void create(int _rows, int _cols)
equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type)
Mat_ & adjustROI(int dtop, int dbottom, int dleft, int dright)
some more overridden methods
Custom array allocator
Definition: mat.hpp:470
Comma-separated Matrix Initializer
Definition: mat.hpp:515
MatCommaInitializer_(Mat_< _Tp > *_m)
the constructor, created by "matrix << firstValue" operator, where matrix is cv::Mat
MatCommaInitializer_< _Tp > & operator,(T2 v)
the operator that takes the next value and put it to the matrix
Matrix read-only iterator
Definition: mat.hpp:3118
MatConstIterator_()
default constructor
MatConstIterator_(const Mat_< _Tp > *_m, Point _pt)
constructor that sets the iterator to the specified element of the matrix
MatConstIterator_(const MatConstIterator_ &it)
copy constructor
MatConstIterator_(const Mat_< _Tp > *_m, int _row, int _col=0)
constructor that sets the iterator to the specified element of the matrix
MatConstIterator_(const Mat_< _Tp > *_m, const int *_idx)
constructor that sets the iterator to the specified element of the matrix
Point pos() const
returns the current iterator position
MatConstIterator_(const Mat_< _Tp > *_m)
constructor that sets the iterator to the beginning of the matrix
MatConstIterator(const Mat *_m, const int *_idx)
constructor that sets the iterator to the specified element of the matrix
MatConstIterator()
default constructor
Point pos() const
returns the current iterator position
MatConstIterator(const Mat *_m, Point _pt)
constructor that sets the iterator to the specified element of the matrix
MatConstIterator(const MatConstIterator &it)
copy constructor
void pos(int *_idx) const
returns the current iterator position
MatConstIterator(const Mat *_m, int _row, int _col=0)
constructor that sets the iterator to the specified element of the matrix
MatConstIterator(const Mat *_m)
constructor that sets the iterator to the beginning of the matrix
Matrix expression representation This is a list of implemented matrix operations that can be combined...
Definition: mat.hpp:3555
n-dimensional dense array class
Definition: mat.hpp:802
Mat & setTo(InputArray value, InputArray mask=noArray())
Sets all or some of the array elements to the specified value.
MatExpr inv(int method=DECOMP_LU) const
Inverses a matrix.
double dot(InputArray m) const
Computes a dot-product of two vectors.
UMatData * u
interaction with UMat
Definition: mat.hpp:2127
void copyTo(OutputArray m) const
Copies the matrix to another one.
void updateContinuityFlag()
internal use method: updates the continuity flag
MatExpr mul(InputArray m, double scale=1) const
Performs an element-wise multiplication or division of the two matrices.
int dims
the matrix dimensionality, >= 2
Definition: mat.hpp:2105
MatAllocator * allocator
custom allocator
Definition: mat.hpp:2117
uchar * data
pointer to the data
Definition: mat.hpp:2109
Mat reshape(int cn, int rows=0) const
Changes the shape and/or the number of channels of a 2D matrix without copying the data.
uchar * ptr(int i0=0)
Returns a pointer to the specified matrix row.
void addref()
Increments the reference counter.
Mat rowRange(int startrow, int endrow) const
Creates a matrix header for the specified row span.
void assignTo(Mat &m, int type=-1) const
Provides a functional form of convertTo.
MatExpr t() const
Transposes a matrix.
Mat colRange(int startcol, int endcol) const
Creates a matrix header for the specified column span.
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition: mat.hpp:2107
void convertTo(OutputArray m, int rtype, double alpha=1, double beta=0) const
Converts an array to another data type with optional scaling.
static MatAllocator * getStdAllocator()
and the standard allocator
const uchar * datastart
helper fields used in locateROI and adjustROI
Definition: mat.hpp:2112
int flags
Definition: mat.hpp:2103
Matrix read-write iterator
Definition: mat.hpp:3171
MatIterator_(Mat_< _Tp > *_m, int _row, int _col=0)
constructor that sets the iterator to the specified element of the matrix
MatIterator_(Mat_< _Tp > *_m, Point _pt)
constructor that sets the iterator to the specified element of the matrix
MatIterator_()
the default constructor
MatIterator_(Mat_< _Tp > *_m, const int *_idx)
constructor that sets the iterator to the specified element of the matrix
MatIterator_(const MatIterator_ &it)
copy constructor
MatIterator_(Mat_< _Tp > *_m)
constructor that sets the iterator to the beginning of the matrix
Template class for small matrices whose type and size are known at compilation time
Definition: matx.hpp:100
n-ary multi-dimensional array iterator.
Definition: mat.hpp:3430
const Mat ** arrays
the iterated arrays
Definition: mat.hpp:3447
size_t size
the size of each segment (in elements)
Definition: mat.hpp:3457
size_t nplanes
the number of hyper-planes that the iterator steps through
Definition: mat.hpp:3455
NAryMatIterator(const Mat **arrays, uchar **ptrs, int narrays=-1)
the full constructor taking arbitrary number of n-dim matrices
uchar ** ptrs
data pointers
Definition: mat.hpp:3451
NAryMatIterator(const Mat **arrays, Mat *planes, int narrays=-1)
the full constructor taking arbitrary number of n-dim matrices
void init(const Mat **arrays, Mat *planes, uchar **ptrs, int narrays=-1)
the separate iterator initialization method
Mat * planes
the current planes
Definition: mat.hpp:3449
NAryMatIterator()
the default constructor
int narrays
the number of arrays
Definition: mat.hpp:3453
Template class for 3D points specified by its coordinates x, y and z.
Definition: core/types.hpp:240
Template class for 2D points specified by its coordinates x and y.
Definition: core/types.hpp:158
Template class specifying a continuous subsequence (slice) of a sequence.
Definition: core/types.hpp:590
Template class for 2D rectangles
Definition: core/types.hpp:421
Template class for specifying the size of an image or rectangle.
Definition: core/types.hpp:316
Template sparse n-dimensional array class derived from SparseMat
Definition: mat.hpp:2982
SparseMat_(const Mat &m)
converts dense matrix to the sparse form
SparseMat_()
the default constructor
SparseMat_(const SparseMat_ &m)
the copy constructor. This is O(1) operation - no data is copied
SparseMat_(const SparseMat &m)
the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted
SparseMat_ clone() const CV_NODISCARD
makes full copy of the matrix. All the elements are duplicated
SparseMat_(int dims, const int *_sizes)
the full constructor equivalent to SparseMat(dims, _sizes, DataType<_Tp>::type)
Template Read-Only Sparse Matrix Iterator Class.
Definition: mat.hpp:3307
SparseMatConstIterator_(const SparseMatConstIterator_ &it)
the copy constructor
SparseMatConstIterator_(const SparseMat_< _Tp > *_m)
the full constructor setting the iterator to the first sparse matrix element
SparseMatConstIterator_()
the default constructor
Read-Only Sparse Matrix Iterator.
Definition: mat.hpp:3229
const _Tp & value() const
template method returning the current matrix element
SparseMatConstIterator(const SparseMat *_m)
the full constructor setting the iterator to the first sparse matrix element
SparseMatConstIterator(const SparseMatConstIterator &it)
the copy constructor
const SparseMat::Node * node() const
returns the current node of the sparse matrix. it.node->idx is the current element index
void seekEnd()
moves iterator to the element after the last element
SparseMatConstIterator()
the default constructor
The class SparseMat represents multi-dimensional sparse numerical arrays.
Definition: mat.hpp:2704
~SparseMat()
the destructor
SparseMat clone() const CV_NODISCARD
creates full copy of the matrix
SparseMat(int dims, const int *_sizes, int _type)
SparseMat(const SparseMat &m)
SparseMat()
Various SparseMat constructors.
Template Read-Write Sparse Matrix Iterator Class.
Definition: mat.hpp:3341
SparseMatIterator_()
the default constructor
SparseMatIterator_(const SparseMatIterator_ &it)
the copy constructor
SparseMatIterator_(SparseMat_< _Tp > *_m)
the full constructor setting the iterator to the first sparse matrix element
Read-write Sparse Matrix Iterator
Definition: mat.hpp:3273
SparseMatIterator(SparseMat *_m, const int *idx)
the full constructor setting the iterator to the specified sparse matrix element
SparseMatIterator()
the default constructor
SparseMat::Node * node() const
returns pointer to the current sparse matrix node. it.node->idx is the index of the current element (...
SparseMatIterator(const SparseMatIterator &it)
the copy constructor
SparseMatIterator(SparseMat *_m)
the full constructor setting the iterator to the first sparse matrix element
_Tp & value() const
returns read-write reference to the current sparse matrix element
void updateContinuityFlag()
internal use method: updates the continuity flag
UMat(const std::vector< _Tp > &vec, bool copyData=false)
builds matrix from std::vector with or without copying the data
UMat(int rows, int cols, int type, const Scalar &s, UMatUsageFlags usageFlags=USAGE_DEFAULT)
constructs 2D matrix and fills it with the specified value _s.
int cols
number of columns in the matrix; -1 when the matrix has more than 2 dimensions
Definition: mat.hpp:2592
MatAllocator * allocator
custom allocator
Definition: mat.hpp:2595
static MatAllocator * getStdAllocator()
and the standard allocator
UMat & adjustROI(int dtop, int dbottom, int dleft, int dright)
moves/resizes the current matrix ROI inside the parent matrix.
void copySize(const UMat &m)
internal use function; properly re-allocates _size, _step arrays
size_t elemSize1() const
returns the size of element channel in bytes.
size_t elemSize() const
returns element size in bytes,
int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const
returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number...
UMat row(int y) const
returns a new matrix header for the specified row
UMat(UMatUsageFlags usageFlags=USAGE_DEFAULT) CV_NOEXCEPT
default constructor
int channels() const
returns element type, similar to CV_MAT_CN(cvmat->type)
size_t step1(int i=0) const
returns step/elemSize1()
int type() const
returns element type, similar to CV_MAT_TYPE(cvmat->type)
void locateROI(Size &wholeSize, Point &ofs) const
locates matrix header within a parent matrix. See below
UMat(const UMat &m)
copy constructor
MatSize size
dimensional size of the matrix; accessible in various formats
Definition: mat.hpp:2613
int dims
the matrix dimensionality, >= 2
Definition: mat.hpp:2586
int rows
number of rows in the matrix; -1 when the matrix has more than 2 dimensions
Definition: mat.hpp:2589
UMat rowRange(int startrow, int endrow) const
... for the specified row span
UMat operator()(Range rowRange, Range colRange) const
extracts a rectangular sub-matrix
int depth() const
returns element type, similar to CV_MAT_DEPTH(cvmat->type)
void deallocate()
deallocates the matrix data
bool empty() const
returns true if matrix data is NULL
MatStep step
number of bytes each matrix element/row/plane/dimension occupies
Definition: mat.hpp:2616
static UMat diag(const UMat &d, UMatUsageFlags usageFlags)
constructs a square diagonal matrix which main diagonal is vector "d"
void addref()
increases the reference counter; use with care to avoid memleaks
void * handle(AccessFlag accessFlags) const
UMatUsageFlags usageFlags
usage flags for allocator; recommend do not set directly, instead set during construct/create/getUMat
Definition: mat.hpp:2598
void release()
decreases reference counter;
UMat col(int x) const
returns a new matrix header for the specified column
UMat clone() const CV_NODISCARD
returns deep copy of the matrix, i.e. the data is copied
size_t total() const
returns the total number of matrix elements
~UMat()
destructor - calls release()
bool isSubmatrix() const
returns true if the matrix is a submatrix of another matrix
UMatData * u
black-box container of UMat data
Definition: mat.hpp:2607
int flags
Definition: mat.hpp:2583
UMat colRange(int startcol, int endcol) const
... for the specified column span
UMat(int rows, int cols, int type, UMatUsageFlags usageFlags=USAGE_DEFAULT)
constructs 2D matrix of the specified size and type
size_t offset
offset of the submatrix (or 0)
Definition: mat.hpp:2610
UMat(int ndims, const int *sizes, int type, UMatUsageFlags usageFlags=USAGE_DEFAULT)
constructs n-dimensional matrix
bool isContinuous() const
returns true iff the matrix data is continuous
void create(int rows, int cols, int type, UMatUsageFlags usageFlags=USAGE_DEFAULT)
allocates new matrix data unless the matrix already has specified size and type.
UMat(const UMat &m, const Range &rowRange, const Range &colRange=Range::all())
creates a matrix header for a part of the bigger matrix
Template class for short numerical vectors, a partial case of Matx
Definition: matx.hpp:342
Base storage class for GPU memory with reference counting.
Definition: core/cuda.hpp:106
Class with reference counting wrapping special memory type allocation functions from CUDA.
Definition: core/cuda.hpp:731
Smart pointer for OpenGL buffer object with reference counting.
Definition: opengl.hpp:80
void CV_EXPORTS_W copyTo(InputArray src, OutputArray dst, InputArray mask)
This is an overloaded member function, provided for convenience (python) Copies the matrix to another...
CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst)
Calculates per-element maximum of two arrays or an array and a scalar.
CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags=DECOMP_LU)
Finds the inverse or pseudo-inverse of a matrix.
CV_EXPORTS_W void transpose(InputArray src, OutputArray dst)
Transposes a matrix.
CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst)
Calculates per-element minimum of two arrays or an array and a scalar.
CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1)
Calculates the per-element sum of two arrays or an array and a scalar.
CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, double scale=1, int dtype=-1)
Performs per-element division of two arrays or a scalar by an array.
CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, OutputArray dst, double scale=1, int dtype=-1)
Calculates the per-element scaled product of two arrays.
CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1)
Calculates the per-element difference between two arrays or array and a scalar.
@ DECOMP_LU
Definition: base.hpp:135
static _InputOutputArray rawInOut(_Tp &v)
static _InputArray rawIn(_Tp &v)
UMatUsageFlags
Usage flags for allocator
Definition: mat.hpp:454
static _OutputArray rawOut(_Tp &v)
CV_INLINE v_reg< _Tp, n > operator|(const v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
Bitwise OR
CV_INLINE v_reg< _Tp, n > operator&(const v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
Bitwise AND
CV_INLINE v_reg< _Tp, n > operator/(const v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
Divide values
CV_INLINE v_reg< _Tp, n > operator~(const v_reg< _Tp, n > &a)
Bitwise NOT
CV_INLINE v_reg< _Tp, n > operator^(const v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
Bitwise XOR
softfloat abs(softfloat a)
Absolute value
Definition: softfloat.hpp:444
CV_EXPORTS void swap(Mat &a, Mat &b)
Swaps two matrices
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
DualQuat< T > inv(const DualQuat< T > &dq, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
Definition: dualquaternion.inl.hpp:187
the sparse matrix header
Definition: mat.hpp:2713
sparse matrix node - element of a hash table
Definition: mat.hpp:2729
size_t hashval
hash value
Definition: mat.hpp:2731
size_t next
index of the next node in the same hash table entry
Definition: mat.hpp:2733