45 #ifndef OPENCV_CORE_MATRIX_OPERATIONS_HPP
46 #define OPENCV_CORE_MATRIX_OPERATIONS_HPP
49 # error mat.inl.hpp header must be compiled as C++
53 #pragma warning( push )
54 #pragma warning( disable: 4127 5054 )
57 #if defined(CV_SKIP_DISABLE_CLANG_ENUM_WARNINGS)
59 #elif defined(CV_FORCE_DISABLE_CLANG_ENUM_WARNINGS)
60 #define CV_DISABLE_CLANG_ENUM_WARNINGS
61 #elif defined(__clang__) && defined(__has_warning)
62 #if __has_warning("-Wdeprecated-enum-enum-conversion") && __has_warning("-Wdeprecated-anon-enum-enum-conversion")
63 #define CV_DISABLE_CLANG_ENUM_WARNINGS
66 #ifdef CV_DISABLE_CLANG_ENUM_WARNINGS
67 #pragma clang diagnostic push
68 #pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"
69 #pragma clang diagnostic ignored "-Wdeprecated-anon-enum-enum-conversion"
81 template<
typename _Tp>
static inline
84 CV_StaticAssert(
sizeof(_Tp) <=
CV_CN_MAX,
"sizeof(_Tp) is too large");
85 const int elemSize =
sizeof(_Tp);
92 {
flags = _flags;
obj = (
void*)_obj; }
95 {
flags = _flags;
obj = (
void*)_obj;
sz = _sz; }
108 template<
typename _Tp>
inline
112 template<
typename _Tp, std::
size_t _Nm>
inline
116 template<std::
size_t _Nm>
inline
124 template<
typename _Tp>
inline
128 template<
typename _Tp>
inline
132 template<
typename _Tp,
int m,
int n>
inline
136 template<
typename _Tp>
inline
140 template<
typename _Tp>
inline
159 template<
typename _Tp>
inline
168 template<
typename _Tp, std::
size_t _Nm>
inline
173 v.obj = (
void*)
arr.data();
183 return *(
const Mat*)
obj;
207 template<
typename _Tp>
inline
211 template<
typename _Tp, std::
size_t _Nm>
inline
215 template<std::
size_t _Nm>
inline
219 template<
typename _Tp>
inline
223 template<
typename _Tp>
inline
227 template<
typename _Tp>
inline
231 template<
typename _Tp,
int m,
int n>
inline
235 template<
typename _Tp>
inline
239 template<
typename _Tp>
inline
243 template<
typename _Tp, std::
size_t _Nm>
inline
247 template<std::
size_t _Nm>
inline
251 template<
typename _Tp>
inline
255 template<
typename _Tp>
inline
259 template<
typename _Tp>
inline
263 template<
typename _Tp,
int m,
int n>
inline
267 template<
typename _Tp>
inline
305 template<
typename _Tp>
inline
314 template<
typename _Tp, std::
size_t _Nm>
inline
319 v.obj = (
void*)
arr.data();
333 template<
typename _Tp>
inline
337 template<
typename _Tp, std::
size_t _Nm>
inline
341 template<std::
size_t _Nm>
inline
345 template<
typename _Tp>
inline
349 template<
typename _Tp>
inline
353 template<
typename _Tp>
inline
357 template<
typename _Tp,
int m,
int n>
inline
361 template<
typename _Tp>
inline
365 template<
typename _Tp>
inline
369 template<
typename _Tp, std::
size_t _Nm>
inline
373 template<std::
size_t _Nm>
inline
377 template<
typename _Tp>
inline
381 template<
typename _Tp>
inline
385 template<
typename _Tp>
inline
389 template<
typename _Tp,
int m,
int n>
inline
393 template<
typename _Tp>
inline
433 template<
typename _Tp>
inline
442 template<
typename _Tp, std::
size_t _Nm>
inline
447 v.obj = (
void*)
arr.data();
461 template<
typename _Tp>
inline
464 cols(1),
data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0),
size(&
rows),
step(0)
472 datalimit = dataend = datastart +
rows *
step[0];
478 template<
typename _Tp,
typename>
inline
486 template<
typename _Tp>
inline
490 size_t size_total = 1;
498 template<
typename _Tp, std::
size_t _Nm>
inline
501 cols(1),
data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0),
size(&
rows),
step(0)
509 datalimit = dataend = datastart +
rows *
step[0];
515 template<
typename _Tp,
int n>
inline
516 Mat::Mat(
const Vec<_Tp, n>& vec,
bool copyData)
518 datastart(0), dataend(0), datalimit(0), allocator(0), u(0),
size(&
rows),
step(0)
524 datalimit = dataend = datastart +
rows *
step[0];
531 template<
typename _Tp,
int m,
int n>
inline
532 Mat::Mat(
const Matx<_Tp,m,n>&
M,
bool copyData)
534 datastart(0), dataend(0), datalimit(0), allocator(0), u(0),
size(&
rows),
step(0)
539 step[1] =
sizeof(_Tp);
541 datalimit = dataend = datastart +
rows *
step[0];
547 template<
typename _Tp>
inline
548 Mat::Mat(
const Point_<_Tp>&
pt,
bool copyData)
550 datastart(0), dataend(0), datalimit(0), allocator(0), u(0),
size(&
rows),
step(0)
556 datalimit = dataend = datastart +
rows *
step[0];
566 template<
typename _Tp>
inline
567 Mat::Mat(
const Point3_<_Tp>&
pt,
bool copyData)
569 datastart(0), dataend(0), datalimit(0), allocator(0), u(0),
size(&
rows),
step(0)
575 datalimit = dataend = datastart +
rows *
step[0];
586 template<
typename _Tp>
inline
587 Mat::Mat(
const MatCommaInitializer_<_Tp>& commaInitializer)
589 datastart(0), dataend(0), allocator(0), u(0),
size(&
rows)
591 *
this = commaInitializer.operator Mat_<_Tp>();
595 Mat Mat::row(
int y)
const
597 return Mat(*
this, Range(
y,
y + 1), Range::all());
601 Mat Mat::col(
int x)
const
603 return Mat(*
this, Range::all(), Range(
x,
x + 1));
607 Mat Mat::rowRange(
int startrow,
int endrow)
const
609 return Mat(*
this, Range(startrow, endrow), Range::all());
613 Mat Mat::rowRange(
const Range&
r)
const
615 return Mat(*
this,
r, Range::all());
619 Mat Mat::colRange(
int startcol,
int endcol)
const
621 return Mat(*
this, Range::all(), Range(startcol, endcol));
625 Mat Mat::colRange(
const Range&
r)
const
627 return Mat(*
this, Range::all(),
r);
631 Mat Mat::operator()( Range _rowRange, Range _colRange )
const
633 return Mat(*
this, _rowRange, _colRange);
637 Mat Mat::operator()(
const Rect& roi )
const
639 return Mat(*
this, roi);
643 Mat Mat::operator()(
const Range*
ranges)
const
645 return Mat(*
this,
ranges);
651 return Mat(*
this,
ranges);
655 bool Mat::isContinuous()
const
657 return (
flags & CONTINUOUS_FLAG) != 0;
661 bool Mat::isSubmatrix()
const
663 return (
flags & SUBMATRIX_FLAG) != 0;
667 size_t Mat::elemSize()
const
675 size_t Mat::elemSize1()
const
706 const uchar* Mat::ptr(
int y)
const
712 template<
typename _Tp>
inline
719 template<
typename _Tp>
inline
720 const _Tp* Mat::ptr(
int y)
const
723 return (
const _Tp*)(
data +
step.p[0] *
y);
727 uchar* Mat::ptr(
int i0,
int i1)
737 const uchar* Mat::ptr(
int i0,
int i1)
const
746 template<
typename _Tp>
inline
747 _Tp* Mat::ptr(
int i0,
int i1)
756 template<
typename _Tp>
inline
757 const _Tp* Mat::ptr(
int i0,
int i1)
const
763 return (
const _Tp*)(
data + i0 *
step.p[0] + i1 *
step.p[1]);
767 uchar* Mat::ptr(
int i0,
int i1,
int i2)
778 const uchar* Mat::ptr(
int i0,
int i1,
int i2)
const
788 template<
typename _Tp>
inline
789 _Tp* Mat::ptr(
int i0,
int i1,
int i2)
799 template<
typename _Tp>
inline
800 const _Tp* Mat::ptr(
int i0,
int i1,
int i2)
const
807 return (
const _Tp*)(
data + i0 *
step.p[0] + i1 *
step.p[1] + i2 *
step.p[2]);
816 for( i = 0; i < d; i++ )
825 const uchar* Mat::ptr(
const int*
idx)
const
830 for( i = 0; i < d; i++ )
838 template<
typename _Tp>
inline
839 _Tp* Mat::ptr(
const int*
idx)
844 for( i = 0; i < d; i++ )
852 template<
typename _Tp>
inline
853 const _Tp* Mat::ptr(
const int*
idx)
const
858 for( i = 0; i < d; i++ )
863 return (
const _Tp*)p;
866 template<
int n>
inline
867 uchar* Mat::ptr(
const Vec<int, n>&
idx)
869 return Mat::ptr(
idx.val);
872 template<
int n>
inline
873 const uchar* Mat::ptr(
const Vec<int, n>&
idx)
const
875 return Mat::ptr(
idx.val);
878 template<
typename _Tp,
int n>
inline
879 _Tp* Mat::ptr(
const Vec<int, n>&
idx)
882 return Mat::ptr<_Tp>(
idx.val);
885 template<
typename _Tp,
int n>
inline
886 const _Tp* Mat::ptr(
const Vec<int, n>&
idx)
const
889 return Mat::ptr<_Tp>(
idx.val);
893 template<
typename _Tp>
inline
894 _Tp& Mat::at(
int i0,
int i1)
901 return ((_Tp*)(
data +
step.p[0] * i0))[i1];
904 template<
typename _Tp>
inline
905 const _Tp& Mat::at(
int i0,
int i1)
const
912 return ((
const _Tp*)(
data +
step.p[0] * i0))[i1];
915 template<
typename _Tp>
inline
926 template<
typename _Tp>
inline
927 const _Tp& Mat::at(
Point pt)
const
937 template<
typename _Tp>
inline
944 if( isContinuous() ||
size.p[0] == 1 )
945 return ((_Tp*)
data)[i0];
947 return *(_Tp*)(
data +
step.p[0] * i0);
948 int i = i0 /
cols, j = i0 - i *
cols;
949 return ((_Tp*)(
data +
step.p[0] * i))[j];
952 template<
typename _Tp>
inline
953 const _Tp& Mat::at(
int i0)
const
959 if( isContinuous() ||
size.p[0] == 1 )
960 return ((
const _Tp*)
data)[i0];
962 return *(
const _Tp*)(
data +
step.p[0] * i0);
963 int i = i0 /
cols, j = i0 - i *
cols;
964 return ((
const _Tp*)(
data +
step.p[0] * i))[j];
967 template<
typename _Tp>
inline
968 _Tp& Mat::at(
int i0,
int i1,
int i2)
971 return *(_Tp*)ptr(i0, i1, i2);
974 template<
typename _Tp>
inline
975 const _Tp& Mat::at(
int i0,
int i1,
int i2)
const
978 return *(
const _Tp*)ptr(i0, i1, i2);
981 template<
typename _Tp>
inline
982 _Tp& Mat::at(
const int*
idx)
985 return *(_Tp*)ptr(
idx);
988 template<
typename _Tp>
inline
989 const _Tp& Mat::at(
const int*
idx)
const
992 return *(
const _Tp*)ptr(
idx);
995 template<
typename _Tp,
int n>
inline
996 _Tp& Mat::at(
const Vec<int, n>&
idx)
999 return *(_Tp*)ptr(
idx.val);
1002 template<
typename _Tp,
int n>
inline
1003 const _Tp& Mat::at(
const Vec<int, n>&
idx)
const
1006 return *(
const _Tp*)ptr(
idx.val);
1009 template<
typename _Tp>
inline
1010 MatConstIterator_<_Tp> Mat::begin()
const
1013 return MatConstIterator_<_Tp>();
1015 return MatConstIterator_<_Tp>((
const Mat_<_Tp>*)
this);
1018 template<
typename _Tp>
inline
1024 MatConstIterator_<_Tp> it((
const Mat_<_Tp>*)
this);
1029 template<
typename _Tp>
inline
1030 MatConstIterator_<_Tp>
Mat::end()
const
1033 return MatConstIterator_<_Tp>();
1035 MatConstIterator_<_Tp> it((
const Mat_<_Tp>*)
this);
1040 template<
typename _Tp>
inline
1049 template<
typename _Tp>
inline
1050 MatIterator_<_Tp> Mat::begin()
1053 return MatIterator_<_Tp>();
1055 return MatIterator_<_Tp>((Mat_<_Tp>*)
this);
1058 template<
typename _Tp>
inline
1064 MatIterator_<_Tp> it((Mat_<_Tp>*)
this);
1069 template<
typename _Tp>
inline
1073 return MatIterator_<_Tp>();
1075 MatIterator_<_Tp> it((Mat_<_Tp>*)
this);
1080 template<
typename _Tp>
inline
1089 template<
typename _Tp,
typename Functor>
inline
1090 void Mat::forEach(
const Functor&
operation) {
1094 template<
typename _Tp,
typename Functor>
inline
1095 void Mat::forEach(
const Functor&
operation)
const {
1097 (
const_cast<Mat*
>(
this))->forEach<_Tp>(
operation);
1100 template<
typename _Tp>
inline
1108 template<
typename _Tp, std::
size_t _Nm>
inline
1116 template<
typename _Tp,
int n>
inline
1117 Mat::operator Vec<_Tp, n>()
const
1123 return Vec<_Tp, n>((_Tp*)
data);
1126 convertTo(tmp, tmp.type());
1130 template<
typename _Tp,
int m,
int n>
inline
1131 Mat::operator Matx<_Tp, m, n>()
const
1136 return Matx<_Tp, m, n>((_Tp*)
data);
1137 Matx<_Tp, m, n> mtx;
1139 convertTo(tmp, tmp.type());
1143 template<
typename _Tp>
inline
1144 void Mat::push_back(
const _Tp&
elem)
1154 if( !isSubmatrix() && isContinuous() && tmp <= datalimit )
1163 template<
typename _Tp>
inline
1164 void Mat::push_back(
const Mat_<_Tp>& m)
1166 push_back((
const Mat&)m);
1170 void Mat::push_back(
const MatExpr& expr)
1172 push_back(
static_cast<Mat
>(expr));
1176 template<
typename _Tp>
inline
1196 Size MatSize::operator()()
const
1199 return Size(p[1], p[0]);
1203 const int& MatSize::operator[](
int i)
const
1206 #ifdef __OPENCV_BUILD
1213 int& MatSize::operator[](
int i)
1216 #ifdef __OPENCV_BUILD
1231 return !(*
this == sz);
1241 p = buf; p[0] = p[1] = 0;
1247 p = buf; p[0] = s; p[1] = 0;
1251 const size_t& MatStep::operator[](
int i)
const CV_NOEXCEPT
1262 inline MatStep::operator size_t()
const
1268 inline MatStep& MatStep::operator = (
size_t s)
1279 template<
typename _Tp>
inline
1286 template<
typename _Tp>
inline
1287 Mat_<_Tp>::Mat_(
int _rows,
int _cols)
1288 : Mat(_rows, _cols, traits::Type<_Tp>::
value)
1292 template<
typename _Tp>
inline
1293 Mat_<_Tp>::Mat_(
int _rows,
int _cols,
const _Tp&
value)
1294 : Mat(_rows, _cols, traits::Type<_Tp>::
value)
1299 template<
typename _Tp>
inline
1300 Mat_<_Tp>::Mat_(
Size _sz)
1301 : Mat(_sz.height, _sz.width, traits::Type<_Tp>::
value)
1304 template<
typename _Tp>
inline
1305 Mat_<_Tp>::Mat_(
Size _sz,
const _Tp&
value)
1306 : Mat(_sz.height, _sz.width, traits::Type<_Tp>::
value)
1311 template<
typename _Tp>
inline
1312 Mat_<_Tp>::Mat_(
int _dims,
const int* _sz)
1313 : Mat(_dims, _sz, traits::Type<_Tp>::
value)
1316 template<
typename _Tp>
inline
1317 Mat_<_Tp>::Mat_(
int _dims,
const int* _sz,
const _Tp& _s)
1318 : Mat(_dims, _sz, traits::Type<_Tp>::
value,
Scalar(_s))
1321 template<
typename _Tp>
inline
1322 Mat_<_Tp>::Mat_(
int _dims,
const int* _sz, _Tp* _data,
const size_t* _steps)
1323 : Mat(_dims, _sz, traits::Type<_Tp>::
value, _data, _steps)
1326 template<
typename _Tp>
inline
1327 Mat_<_Tp>::Mat_(
const Mat_<_Tp>& m,
const Range*
ranges)
1331 template<
typename _Tp>
inline
1336 template<
typename _Tp>
inline
1337 Mat_<_Tp>::Mat_(
const Mat& m)
1344 template<
typename _Tp>
inline
1345 Mat_<_Tp>::Mat_(
const Mat_& m)
1349 template<
typename _Tp>
inline
1350 Mat_<_Tp>::Mat_(
int _rows,
int _cols, _Tp* _data,
size_t steps)
1351 : Mat(_rows, _cols, traits::Type<_Tp>::
value, _data, steps)
1354 template<
typename _Tp>
inline
1355 Mat_<_Tp>::Mat_(
const Mat_& m,
const Range& _rowRange,
const Range& _colRange)
1356 : Mat(m, _rowRange, _colRange)
1359 template<
typename _Tp>
inline
1360 Mat_<_Tp>::Mat_(
const Mat_& m,
const Rect& roi)
1364 template<
typename _Tp>
template<
int n>
inline
1365 Mat_<_Tp>::Mat_(
const Vec<
typename DataType<_Tp>::channel_type, n>& vec,
bool copyData)
1366 : Mat(n / DataType<_Tp>::
channels, 1, traits::Type<_Tp>::
value, (void*)&vec)
1373 template<
typename _Tp>
template<
int m,
int n>
inline
1374 Mat_<_Tp>::Mat_(
const Matx<
typename DataType<_Tp>::channel_type, m, n>&
M,
bool copyData)
1375 : Mat(m, n / DataType<_Tp>::
channels, traits::Type<_Tp>::
value, (void*)&
M)
1382 template<
typename _Tp>
inline
1383 Mat_<_Tp>::Mat_(
const Point_<
typename DataType<_Tp>::channel_type>&
pt,
bool copyData)
1384 : Mat(2 / DataType<_Tp>::
channels, 1, traits::Type<_Tp>::
value, (void*)&
pt)
1391 template<
typename _Tp>
inline
1392 Mat_<_Tp>::Mat_(
const Point3_<
typename DataType<_Tp>::channel_type>&
pt,
bool copyData)
1393 : Mat(3 / DataType<_Tp>::
channels, 1, traits::Type<_Tp>::
value, (void*)&
pt)
1400 template<
typename _Tp>
inline
1401 Mat_<_Tp>::Mat_(
const MatCommaInitializer_<_Tp>& commaInitializer)
1402 : Mat(commaInitializer)
1405 template<
typename _Tp>
inline
1407 : Mat(vec, copyData)
1410 template<
typename _Tp>
inline
1415 template<
typename _Tp>
inline
1420 template<
typename _Tp>
template<std::
size_t _Nm>
inline
1422 : Mat(
arr, copyData)
1425 template<
typename _Tp>
inline
1426 Mat_<_Tp>& Mat_<_Tp>::operator = (
const Mat& m)
1435 Mat::operator = (m);
1443 m.convertTo(*
this,
type());
1447 template<
typename _Tp>
inline
1448 Mat_<_Tp>& Mat_<_Tp>::operator = (
const Mat_& m)
1454 template<
typename _Tp>
inline
1455 Mat_<_Tp>& Mat_<_Tp>::operator = (
const _Tp& s)
1457 typedef typename DataType<_Tp>::vec_type VT;
1458 Mat::operator=(
Scalar((
const VT&)s));
1462 template<
typename _Tp>
inline
1463 void Mat_<_Tp>::create(
int _rows,
int _cols)
1468 template<
typename _Tp>
inline
1469 void Mat_<_Tp>::create(
Size _sz)
1474 template<
typename _Tp>
inline
1475 void Mat_<_Tp>::create(
int _dims,
const int* _sz)
1480 template<
typename _Tp>
inline
1481 void Mat_<_Tp>::release()
1487 template<
typename _Tp>
inline
1488 Mat_<_Tp> Mat_<_Tp>::cross(
const Mat_& m)
const
1490 return Mat_<_Tp>(Mat::cross(m));
1493 template<
typename _Tp>
template<
typename T2>
inline
1494 Mat_<_Tp>::operator Mat_<T2>()
const
1496 return Mat_<T2>(
static_cast<const Mat&
>(*
this));
1499 template<
typename _Tp>
inline
1500 Mat_<_Tp> Mat_<_Tp>::row(
int y)
const
1502 return Mat_(*
this, Range(
y,
y+1), Range::all());
1505 template<
typename _Tp>
inline
1506 Mat_<_Tp> Mat_<_Tp>::col(
int x)
const
1508 return Mat_(*
this, Range::all(), Range(
x,
x+1));
1511 template<
typename _Tp>
inline
1512 Mat_<_Tp> Mat_<_Tp>::diag(
int d)
const
1514 return Mat_(Mat::diag(d));
1517 template<
typename _Tp>
inline
1518 Mat_<_Tp> Mat_<_Tp>::clone()
const
1520 return Mat_(Mat::clone());
1523 template<
typename _Tp>
inline
1524 size_t Mat_<_Tp>::elemSize()
const
1530 template<
typename _Tp>
inline
1531 size_t Mat_<_Tp>::elemSize1()
const
1537 template<
typename _Tp>
inline
1544 template<
typename _Tp>
inline
1551 template<
typename _Tp>
inline
1558 template<
typename _Tp>
inline
1559 size_t Mat_<_Tp>::stepT(
int i)
const
1561 return step.p[i] / elemSize();
1564 template<
typename _Tp>
inline
1565 size_t Mat_<_Tp>::step1(
int i)
const
1567 return step.p[i] / elemSize1();
1570 template<
typename _Tp>
inline
1571 Mat_<_Tp>& Mat_<_Tp>::adjustROI(
int dtop,
int dbottom,
int dleft,
int dright )
1573 return (Mat_<_Tp>&)(Mat::adjustROI(dtop, dbottom, dleft, dright));
1576 template<
typename _Tp>
inline
1577 Mat_<_Tp> Mat_<_Tp>::operator()(
const Range& _rowRange,
const Range& _colRange )
const
1579 return Mat_<_Tp>(*
this, _rowRange, _colRange);
1582 template<
typename _Tp>
inline
1583 Mat_<_Tp> Mat_<_Tp>::operator()(
const Rect& roi )
const
1585 return Mat_<_Tp>(*
this, roi);
1588 template<
typename _Tp>
inline
1589 Mat_<_Tp> Mat_<_Tp>::operator()(
const Range*
ranges )
const
1591 return Mat_<_Tp>(*
this,
ranges);
1594 template<
typename _Tp>
inline
1597 return Mat_<_Tp>(*
this,
ranges);
1600 template<
typename _Tp>
inline
1601 _Tp* Mat_<_Tp>::operator [](
int y)
1607 template<
typename _Tp>
inline
1608 const _Tp* Mat_<_Tp>::operator [](
int y)
const
1611 return (
const _Tp*)(
data +
y*
step.p[0]);
1614 template<
typename _Tp>
inline
1615 _Tp& Mat_<_Tp>::operator ()(
int i0,
int i1)
1622 return ((_Tp*)(
data +
step.p[0] * i0))[i1];
1625 template<
typename _Tp>
inline
1626 const _Tp& Mat_<_Tp>::operator ()(
int i0,
int i1)
const
1633 return ((
const _Tp*)(
data +
step.p[0] * i0))[i1];
1636 template<
typename _Tp>
inline
1637 _Tp& Mat_<_Tp>::operator ()(
Point pt)
1647 template<
typename _Tp>
inline
1648 const _Tp& Mat_<_Tp>::operator ()(
Point pt)
const
1658 template<
typename _Tp>
inline
1659 _Tp& Mat_<_Tp>::operator ()(
const int*
idx)
1661 return Mat::at<_Tp>(
idx);
1664 template<
typename _Tp>
inline
1665 const _Tp& Mat_<_Tp>::operator ()(
const int*
idx)
const
1667 return Mat::at<_Tp>(
idx);
1670 template<
typename _Tp>
template<
int n>
inline
1671 _Tp& Mat_<_Tp>::operator ()(
const Vec<int, n>&
idx)
1673 return Mat::at<_Tp>(
idx);
1676 template<
typename _Tp>
template<
int n>
inline
1677 const _Tp& Mat_<_Tp>::operator ()(
const Vec<int, n>&
idx)
const
1679 return Mat::at<_Tp>(
idx);
1682 template<
typename _Tp>
inline
1683 _Tp& Mat_<_Tp>::operator ()(
int i0)
1685 return this->at<_Tp>(i0);
1688 template<
typename _Tp>
inline
1689 const _Tp& Mat_<_Tp>::operator ()(
int i0)
const
1691 return this->at<_Tp>(i0);
1694 template<
typename _Tp>
inline
1695 _Tp& Mat_<_Tp>::operator ()(
int i0,
int i1,
int i2)
1697 return this->at<_Tp>(i0, i1, i2);
1700 template<
typename _Tp>
inline
1701 const _Tp& Mat_<_Tp>::operator ()(
int i0,
int i1,
int i2)
const
1703 return this->at<_Tp>(i0, i1, i2);
1706 template<
typename _Tp>
inline
1714 template<
typename _Tp>
template<std::
size_t _Nm>
inline
1722 template<
typename _Tp>
template<
int n>
inline
1723 Mat_<_Tp>::operator Vec<typename DataType<_Tp>::channel_type, n>()
const
1727 #if defined _MSC_VER
1728 const Mat* pMat = (
const Mat*)
this;
1729 return pMat->operator Vec<typename DataType<_Tp>::channel_type, n>();
1731 return this->Mat::operator Vec<typename DataType<_Tp>::channel_type, n>();
1735 template<
typename _Tp>
template<
int m,
int n>
inline
1736 Mat_<_Tp>::operator Matx<typename DataType<_Tp>::channel_type, m, n>()
const
1740 #if defined _MSC_VER
1741 const Mat* pMat = (
const Mat*)
this;
1742 Matx<typename DataType<_Tp>::channel_type, m, n> res = pMat->operator Matx<typename DataType<_Tp>::channel_type, m, n>();
1745 Matx<typename DataType<_Tp>::channel_type, m, n> res = this->Mat::operator Matx<typename DataType<_Tp>::channel_type, m, n>();
1750 template<
typename _Tp>
inline
1751 MatConstIterator_<_Tp> Mat_<_Tp>::begin()
const
1753 return Mat::begin<_Tp>();
1756 template<
typename _Tp>
inline
1759 return Mat::rbegin<_Tp>();
1762 template<
typename _Tp>
inline
1765 return Mat::end<_Tp>();
1768 template<
typename _Tp>
inline
1771 return Mat::rend<_Tp>();
1774 template<
typename _Tp>
inline
1775 MatIterator_<_Tp> Mat_<_Tp>::begin()
1777 return Mat::begin<_Tp>();
1780 template<
typename _Tp>
inline
1783 return Mat::rbegin<_Tp>();
1786 template<
typename _Tp>
inline
1789 return Mat::end<_Tp>();
1792 template<
typename _Tp>
inline
1795 return Mat::rend<_Tp>();
1798 template<
typename _Tp>
template<
typename Functor>
inline
1799 void Mat_<_Tp>::forEach(
const Functor&
operation) {
1803 template<
typename _Tp>
template<
typename Functor>
inline
1804 void Mat_<_Tp>::forEach(
const Functor&
operation)
const {
1808 template<
typename _Tp>
inline
1809 Mat_<_Tp>::Mat_(Mat_&& m)
1814 template<
typename _Tp>
inline
1815 Mat_<_Tp>& Mat_<_Tp>::operator = (Mat_&& m)
1821 template<
typename _Tp>
inline
1822 Mat_<_Tp>::Mat_(Mat&& m)
1829 template<
typename _Tp>
inline
1830 Mat_<_Tp>& Mat_<_Tp>::operator = (Mat&& m)
1839 Mat::operator = ((Mat&&)m);
1848 m.convertTo(*
this,
type());
1852 template<
typename _Tp>
inline
1853 Mat_<_Tp>::Mat_(MatExpr&& e)
1864 SparseMat SparseMat::clone()
const
1872 size_t SparseMat::elemSize()
const
1878 size_t SparseMat::elemSize1()
const
1904 return hdr ? hdr->size : 0;
1913 return hdr->size[i];
1921 return hdr ? hdr->dims : 0;
1925 size_t SparseMat::nzcount()
const
1927 return hdr ? hdr->nodeCount : 0;
1930 template<
typename _Tp>
inline
1931 _Tp& SparseMat::ref(
int i0,
size_t* hashval)
1933 return *(_Tp*)((SparseMat*)
this)->ptr(i0,
true, hashval);
1936 template<
typename _Tp>
inline
1937 _Tp& SparseMat::ref(
int i0,
int i1,
size_t* hashval)
1939 return *(_Tp*)((SparseMat*)
this)->ptr(i0, i1,
true, hashval);
1942 template<
typename _Tp>
inline
1943 _Tp& SparseMat::ref(
int i0,
int i1,
int i2,
size_t* hashval)
1945 return *(_Tp*)((SparseMat*)
this)->ptr(i0, i1, i2,
true, hashval);
1948 template<
typename _Tp>
inline
1949 _Tp& SparseMat::ref(
const int*
idx,
size_t* hashval)
1951 return *(_Tp*)((SparseMat*)
this)->ptr(
idx,
true, hashval);
1954 template<
typename _Tp>
inline
1957 const _Tp* p = (
const _Tp*)((SparseMat*)
this)->ptr(i0,
false, hashval);
1958 return p ? *p : _Tp();
1961 template<
typename _Tp>
inline
1964 const _Tp* p = (
const _Tp*)((SparseMat*)
this)->ptr(i0, i1,
false, hashval);
1965 return p ? *p : _Tp();
1968 template<
typename _Tp>
inline
1971 const _Tp* p = (
const _Tp*)((SparseMat*)
this)->ptr(i0, i1, i2,
false, hashval);
1972 return p ? *p : _Tp();
1975 template<
typename _Tp>
inline
1978 const _Tp* p = (
const _Tp*)((SparseMat*)
this)->ptr(
idx,
false, hashval);
1979 return p ? *p : _Tp();
1982 template<
typename _Tp>
inline
1983 const _Tp* SparseMat::find(
int i0,
size_t* hashval)
const
1985 return (
const _Tp*)((SparseMat*)
this)->ptr(i0,
false, hashval);
1988 template<
typename _Tp>
inline
1989 const _Tp* SparseMat::find(
int i0,
int i1,
size_t* hashval)
const
1991 return (
const _Tp*)((SparseMat*)
this)->ptr(i0, i1,
false, hashval);
1994 template<
typename _Tp>
inline
1995 const _Tp* SparseMat::find(
int i0,
int i1,
int i2,
size_t* hashval)
const
1997 return (
const _Tp*)((SparseMat*)
this)->ptr(i0, i1, i2,
false, hashval);
2000 template<
typename _Tp>
inline
2001 const _Tp* SparseMat::find(
const int*
idx,
size_t* hashval)
const
2003 return (
const _Tp*)((SparseMat*)
this)->ptr(
idx,
false, hashval);
2006 template<
typename _Tp>
inline
2009 return *(_Tp*)((
uchar*)n + hdr->valueOffset);
2012 template<
typename _Tp>
inline
2015 return *(
const _Tp*)((
const uchar*)n + hdr->valueOffset);
2019 SparseMat::Node* SparseMat::node(
size_t nidx)
2021 return (Node*)(
void*)&hdr->pool[nidx];
2025 const SparseMat::Node* SparseMat::node(
size_t nidx)
const
2027 return (
const Node*)(
const void*)&hdr->pool[nidx];
2031 SparseMatIterator SparseMat::begin()
2033 return SparseMatIterator(
this);
2037 SparseMatConstIterator SparseMat::begin()
const
2039 return SparseMatConstIterator(
this);
2045 SparseMatIterator it(
this);
2053 SparseMatConstIterator it(
this);
2058 template<
typename _Tp>
inline
2059 SparseMatIterator_<_Tp> SparseMat::begin()
2061 return SparseMatIterator_<_Tp>(
this);
2064 template<
typename _Tp>
inline
2065 SparseMatConstIterator_<_Tp> SparseMat::begin()
const
2067 return SparseMatConstIterator_<_Tp>(
this);
2070 template<
typename _Tp>
inline
2073 SparseMatIterator_<_Tp> it(
this);
2078 template<
typename _Tp>
inline
2081 SparseMatConstIterator_<_Tp> it(
this);
2090 template<
typename _Tp>
inline
2091 SparseMat_<_Tp>::SparseMat_()
2096 template<
typename _Tp>
inline
2097 SparseMat_<_Tp>::SparseMat_(
int _dims,
const int* _sizes)
2098 : SparseMat(_dims, _sizes, traits::Type<_Tp>::
value)
2101 template<
typename _Tp>
inline
2102 SparseMat_<_Tp>::SparseMat_(
const SparseMat& m)
2105 *
this = (
const SparseMat_<_Tp>&)m;
2110 template<
typename _Tp>
inline
2111 SparseMat_<_Tp>::SparseMat_(
const SparseMat_<_Tp>& m)
2113 this->
flags = m.flags;
2116 CV_XADD(&this->hdr->refcount, 1);
2119 template<
typename _Tp>
inline
2120 SparseMat_<_Tp>::SparseMat_(
const Mat& m)
2126 template<
typename _Tp>
inline
2127 SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (
const SparseMat_<_Tp>& m)
2131 if( m.hdr ) CV_XADD(&m.hdr->refcount, 1);
2139 template<
typename _Tp>
inline
2140 SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (
const SparseMat& m)
2143 return (*
this = (
const SparseMat_<_Tp>&)m);
2148 template<
typename _Tp>
inline
2149 SparseMat_<_Tp>& SparseMat_<_Tp>::operator = (
const Mat& m)
2151 return (*
this = SparseMat(m));
2154 template<
typename _Tp>
inline
2155 SparseMat_<_Tp> SparseMat_<_Tp>::clone()
const
2162 template<
typename _Tp>
inline
2163 void SparseMat_<_Tp>::create(
int _dims,
const int* _sizes)
2168 template<
typename _Tp>
inline
2174 template<
typename _Tp>
inline
2180 template<
typename _Tp>
inline
2186 template<
typename _Tp>
inline
2187 _Tp& SparseMat_<_Tp>::ref(
int i0,
size_t* hashval)
2189 return SparseMat::ref<_Tp>(i0, hashval);
2192 template<
typename _Tp>
inline
2193 _Tp SparseMat_<_Tp>::operator()(
int i0,
size_t* hashval)
const
2195 return SparseMat::value<_Tp>(i0, hashval);
2198 template<
typename _Tp>
inline
2199 _Tp& SparseMat_<_Tp>::ref(
int i0,
int i1,
size_t* hashval)
2201 return SparseMat::ref<_Tp>(i0, i1, hashval);
2204 template<
typename _Tp>
inline
2205 _Tp SparseMat_<_Tp>::operator()(
int i0,
int i1,
size_t* hashval)
const
2207 return SparseMat::value<_Tp>(i0, i1, hashval);
2210 template<
typename _Tp>
inline
2211 _Tp& SparseMat_<_Tp>::ref(
int i0,
int i1,
int i2,
size_t* hashval)
2213 return SparseMat::ref<_Tp>(i0, i1, i2, hashval);
2216 template<
typename _Tp>
inline
2217 _Tp SparseMat_<_Tp>::operator()(
int i0,
int i1,
int i2,
size_t* hashval)
const
2219 return SparseMat::value<_Tp>(i0, i1, i2, hashval);
2222 template<
typename _Tp>
inline
2223 _Tp& SparseMat_<_Tp>::ref(
const int*
idx,
size_t* hashval)
2225 return SparseMat::ref<_Tp>(
idx, hashval);
2228 template<
typename _Tp>
inline
2229 _Tp SparseMat_<_Tp>::operator()(
const int*
idx,
size_t* hashval)
const
2231 return SparseMat::value<_Tp>(
idx, hashval);
2234 template<
typename _Tp>
inline
2235 SparseMatIterator_<_Tp> SparseMat_<_Tp>::begin()
2237 return SparseMatIterator_<_Tp>(
this);
2240 template<
typename _Tp>
inline
2241 SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::begin()
const
2243 return SparseMatConstIterator_<_Tp>(
this);
2246 template<
typename _Tp>
inline
2249 SparseMatIterator_<_Tp> it(
this);
2254 template<
typename _Tp>
inline
2257 SparseMatConstIterator_<_Tp> it(
this);
2267 MatConstIterator::MatConstIterator()
2268 : m(0), elemSize(0), ptr(0), sliceStart(0), sliceEnd(0)
2272 MatConstIterator::MatConstIterator(
const Mat* _m)
2273 : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
2275 if( m && m->isContinuous() )
2278 sliceStart = m->ptr();
2279 sliceEnd = sliceStart + m->total()*elemSize;
2281 seek((
const int*)0);
2285 MatConstIterator::MatConstIterator(
const Mat* _m,
int _row,
int _col)
2286 : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
2289 if( m->isContinuous() )
2292 sliceStart = m->ptr();
2293 sliceEnd = sliceStart + m->total()*elemSize;
2295 int idx[] = {_row, _col};
2300 MatConstIterator::MatConstIterator(
const Mat* _m,
Point _pt)
2301 : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0)
2304 if( m->isContinuous() )
2307 sliceStart = m->ptr();
2308 sliceEnd = sliceStart + m->total()*elemSize;
2310 int idx[] = {_pt.y, _pt.x};
2315 MatConstIterator::MatConstIterator(
const MatConstIterator& it)
2316 : m(it.m), elemSize(it.elemSize), ptr(it.ptr), sliceStart(it.sliceStart), sliceEnd(it.sliceEnd)
2320 MatConstIterator& MatConstIterator::operator = (
const MatConstIterator& it )
2322 m = it.m; elemSize = it.elemSize; ptr = it.ptr;
2323 sliceStart = it.sliceStart; sliceEnd = it.sliceEnd;
2335 if( !m || ofs == 0 )
2337 ptrdiff_t ofsb = ofs*elemSize;
2339 if( ptr < sliceStart || sliceEnd <= ptr )
2350 return (*
this += -ofs);
2354 MatConstIterator& MatConstIterator::operator --()
2356 if( m && (ptr -= elemSize) < sliceStart )
2365 MatConstIterator MatConstIterator::operator --(
int)
2367 MatConstIterator b = *
this;
2373 MatConstIterator& MatConstIterator::operator ++()
2375 if( m && (ptr += elemSize) >= sliceEnd )
2383 inline MatConstIterator MatConstIterator::operator ++(
int)
2385 MatConstIterator b = *
this;
2392 bool operator == (
const MatConstIterator& a,
const MatConstIterator& b)
2394 return a.m == b.m && a.ptr == b.ptr;
2398 bool operator != (
const MatConstIterator& a,
const MatConstIterator& b)
2404 bool operator < (
const MatConstIterator& a,
const MatConstIterator& b)
2406 return a.ptr < b.ptr;
2410 bool operator > (
const MatConstIterator& a,
const MatConstIterator& b)
2412 return a.ptr > b.ptr;
2416 bool operator <= (
const MatConstIterator& a,
const MatConstIterator& b)
2418 return a.ptr <= b.ptr;
2422 bool operator >= (
const MatConstIterator& a,
const MatConstIterator& b)
2424 return a.ptr >= b.ptr;
2428 ptrdiff_t
operator - (
const MatConstIterator& b,
const MatConstIterator& a)
2431 return ((
size_t)(-1) >> 1);
2432 if( a.sliceEnd == b.sliceEnd )
2433 return (b.ptr - a.ptr)/
static_cast<ptrdiff_t
>(b.elemSize);
2435 return b.lpos() - a.lpos();
2439 MatConstIterator
operator + (
const MatConstIterator& a, ptrdiff_t ofs)
2441 MatConstIterator b = a;
2446 MatConstIterator
operator + (ptrdiff_t ofs,
const MatConstIterator& a)
2448 MatConstIterator b = a;
2453 MatConstIterator
operator - (
const MatConstIterator& a, ptrdiff_t ofs)
2455 MatConstIterator b = a;
2461 const uchar* MatConstIterator::operator [](ptrdiff_t i)
const
2463 return *(*
this + i);
2470 template<
typename _Tp>
inline
2471 MatConstIterator_<_Tp>::MatConstIterator_()
2474 template<
typename _Tp>
inline
2475 MatConstIterator_<_Tp>::MatConstIterator_(
const Mat_<_Tp>* _m)
2476 : MatConstIterator(_m)
2479 template<
typename _Tp>
inline
2480 MatConstIterator_<_Tp>::MatConstIterator_(
const Mat_<_Tp>* _m,
int _row,
int _col)
2481 : MatConstIterator(_m, _row, _col)
2484 template<
typename _Tp>
inline
2485 MatConstIterator_<_Tp>::MatConstIterator_(
const Mat_<_Tp>* _m,
Point _pt)
2486 : MatConstIterator(_m, _pt)
2489 template<
typename _Tp>
inline
2490 MatConstIterator_<_Tp>::MatConstIterator_(
const MatConstIterator_& it)
2491 : MatConstIterator(it)
2494 template<
typename _Tp>
inline
2495 MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator = (
const MatConstIterator_& it )
2497 MatConstIterator::operator = (it);
2501 template<
typename _Tp>
inline
2504 return *(_Tp*)(this->ptr);
2507 template<
typename _Tp>
inline
2514 template<
typename _Tp>
inline
2517 return (*
this += -ofs);
2520 template<
typename _Tp>
inline
2521 MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator --()
2523 MatConstIterator::operator --();
2527 template<
typename _Tp>
inline
2528 MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator --(
int)
2530 MatConstIterator_ b = *
this;
2531 MatConstIterator::operator --();
2535 template<
typename _Tp>
inline
2536 MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator ++()
2538 MatConstIterator::operator ++();
2542 template<
typename _Tp>
inline
2543 MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator ++(
int)
2545 MatConstIterator_ b = *
this;
2546 MatConstIterator::operator ++();
2551 template<
typename _Tp>
inline
2557 if( m->isContinuous() )
2559 ptrdiff_t ofs = (
const _Tp*)ptr - (
const _Tp*)m->data;
2560 int y = (int)(ofs / m->cols);
2561 int x = (int)(ofs - (ptrdiff_t)
y * m->cols);
2566 ptrdiff_t ofs = (
uchar*)ptr - m->data;
2567 int y = (
int)(ofs / m->step);
2568 int x = (int)((ofs -
y * m->step)/
sizeof(_Tp));
2574 template<
typename _Tp>
static inline
2575 bool operator == (
const MatConstIterator_<_Tp>& a,
const MatConstIterator_<_Tp>& b)
2577 return a.m == b.m && a.ptr == b.ptr;
2580 template<
typename _Tp>
static inline
2581 bool operator != (
const MatConstIterator_<_Tp>& a,
const MatConstIterator_<_Tp>& b)
2583 return a.m != b.m || a.ptr != b.ptr;
2586 template<
typename _Tp>
static inline
2587 MatConstIterator_<_Tp>
operator + (
const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
2589 MatConstIterator t = (
const MatConstIterator&)a + ofs;
2590 return (MatConstIterator_<_Tp>&)t;
2593 template<
typename _Tp>
static inline
2594 MatConstIterator_<_Tp>
operator + (ptrdiff_t ofs,
const MatConstIterator_<_Tp>& a)
2596 MatConstIterator t = (
const MatConstIterator&)a + ofs;
2597 return (MatConstIterator_<_Tp>&)t;
2600 template<
typename _Tp>
static inline
2601 MatConstIterator_<_Tp>
operator - (
const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
2603 MatConstIterator t = (
const MatConstIterator&)a - ofs;
2604 return (MatConstIterator_<_Tp>&)t;
2607 template<
typename _Tp>
inline
2608 const _Tp& MatConstIterator_<_Tp>::operator [](ptrdiff_t i)
const
2610 return *(_Tp*)MatConstIterator::operator [](i);
2617 template<
typename _Tp>
inline
2618 MatIterator_<_Tp>::MatIterator_()
2619 : MatConstIterator_<_Tp>()
2622 template<
typename _Tp>
inline
2623 MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m)
2624 : MatConstIterator_<_Tp>(_m)
2627 template<
typename _Tp>
inline
2628 MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m,
int _row,
int _col)
2629 : MatConstIterator_<_Tp>(_m, _row, _col)
2632 template<
typename _Tp>
inline
2633 MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m,
Point _pt)
2634 : MatConstIterator_<_Tp>(_m, _pt)
2637 template<
typename _Tp>
inline
2638 MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m,
const int* _idx)
2639 : MatConstIterator_<_Tp>(_m, _idx)
2642 template<
typename _Tp>
inline
2643 MatIterator_<_Tp>::MatIterator_(
const MatIterator_& it)
2644 : MatConstIterator_<_Tp>(it)
2647 template<
typename _Tp>
inline
2648 MatIterator_<_Tp>& MatIterator_<_Tp>::operator = (
const MatIterator_<_Tp>& it )
2650 MatConstIterator::operator = (it);
2654 template<
typename _Tp>
inline
2657 return *(_Tp*)(this->ptr);
2660 template<
typename _Tp>
inline
2667 template<
typename _Tp>
inline
2674 template<
typename _Tp>
inline
2675 MatIterator_<_Tp>& MatIterator_<_Tp>::operator --()
2677 MatConstIterator::operator --();
2681 template<
typename _Tp>
inline
2682 MatIterator_<_Tp> MatIterator_<_Tp>::operator --(
int)
2684 MatIterator_ b = *
this;
2685 MatConstIterator::operator --();
2689 template<
typename _Tp>
inline
2690 MatIterator_<_Tp>& MatIterator_<_Tp>::operator ++()
2692 MatConstIterator::operator ++();
2696 template<
typename _Tp>
inline
2697 MatIterator_<_Tp> MatIterator_<_Tp>::operator ++(
int)
2699 MatIterator_ b = *
this;
2700 MatConstIterator::operator ++();
2704 template<
typename _Tp>
inline
2705 _Tp& MatIterator_<_Tp>::operator [](ptrdiff_t i)
const
2707 return *(*
this + i);
2711 template<
typename _Tp>
static inline
2712 bool operator == (
const MatIterator_<_Tp>& a,
const MatIterator_<_Tp>& b)
2714 return a.m == b.m && a.ptr == b.ptr;
2717 template<
typename _Tp>
static inline
2718 bool operator != (
const MatIterator_<_Tp>& a,
const MatIterator_<_Tp>& b)
2720 return a.m != b.m || a.ptr != b.ptr;
2723 template<
typename _Tp>
static inline
2724 MatIterator_<_Tp>
operator + (
const MatIterator_<_Tp>& a, ptrdiff_t ofs)
2726 MatConstIterator t = (
const MatConstIterator&)a + ofs;
2727 return (MatIterator_<_Tp>&)t;
2730 template<
typename _Tp>
static inline
2731 MatIterator_<_Tp>
operator + (ptrdiff_t ofs,
const MatIterator_<_Tp>& a)
2733 MatConstIterator t = (
const MatConstIterator&)a + ofs;
2734 return (MatIterator_<_Tp>&)t;
2737 template<
typename _Tp>
static inline
2738 MatIterator_<_Tp>
operator - (
const MatIterator_<_Tp>& a, ptrdiff_t ofs)
2740 MatConstIterator t = (
const MatConstIterator&)a - ofs;
2741 return (MatIterator_<_Tp>&)t;
2749 SparseMatConstIterator::SparseMatConstIterator()
2750 : m(0), hashidx(0), ptr(0)
2754 SparseMatConstIterator::SparseMatConstIterator(
const SparseMatConstIterator& it)
2755 : m(it.m), hashidx(it.hashidx), ptr(it.ptr)
2758 inline SparseMatConstIterator& SparseMatConstIterator::operator = (
const SparseMatConstIterator& it)
2763 hashidx = it.hashidx;
2769 template<
typename _Tp>
inline
2772 return *(
const _Tp*)ptr;
2776 const SparseMat::Node* SparseMatConstIterator::node()
const
2778 return (ptr && m && m->hdr) ? (
const SparseMat::Node*)(
const void*)(ptr - m->hdr->valueOffset) : 0;
2782 SparseMatConstIterator SparseMatConstIterator::operator ++(
int)
2784 SparseMatConstIterator it = *
this;
2790 void SparseMatConstIterator::seekEnd()
2794 hashidx = m->hdr->hashtab.size();
2801 bool operator == (
const SparseMatConstIterator& it1,
const SparseMatConstIterator& it2)
2803 return it1.m == it2.m && it1.ptr == it2.ptr;
2807 bool operator != (
const SparseMatConstIterator& it1,
const SparseMatConstIterator& it2)
2809 return !(it1 == it2);
2817 SparseMatIterator::SparseMatIterator()
2821 SparseMatIterator::SparseMatIterator(SparseMat* _m)
2822 : SparseMatConstIterator(_m)
2826 SparseMatIterator::SparseMatIterator(
const SparseMatIterator& it)
2827 : SparseMatConstIterator(it)
2831 SparseMatIterator& SparseMatIterator::operator = (
const SparseMatIterator& it)
2833 (SparseMatConstIterator&)*
this = it;
2837 template<
typename _Tp>
inline
2844 SparseMat::Node* SparseMatIterator::node()
const
2846 return (SparseMat::Node*)SparseMatConstIterator::node();
2850 SparseMatIterator& SparseMatIterator::operator ++()
2852 SparseMatConstIterator::operator ++();
2857 SparseMatIterator SparseMatIterator::operator ++(
int)
2859 SparseMatIterator it = *
this;
2868 template<
typename _Tp>
inline
2869 SparseMatConstIterator_<_Tp>::SparseMatConstIterator_()
2872 template<
typename _Tp>
inline
2873 SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(
const SparseMat_<_Tp>* _m)
2874 : SparseMatConstIterator(_m)
2877 template<
typename _Tp>
inline
2878 SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(
const SparseMat* _m)
2879 : SparseMatConstIterator(_m)
2884 template<
typename _Tp>
inline
2885 SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(
const SparseMatConstIterator_<_Tp>& it)
2886 : SparseMatConstIterator(it)
2889 template<
typename _Tp>
inline
2890 SparseMatConstIterator_<_Tp>& SparseMatConstIterator_<_Tp>::operator = (
const SparseMatConstIterator_<_Tp>& it)
2892 return reinterpret_cast<SparseMatConstIterator_<_Tp>&
>
2893 (*
reinterpret_cast<SparseMatConstIterator*
>(
this) =
2894 reinterpret_cast<const SparseMatConstIterator&
>(it));
2897 template<
typename _Tp>
inline
2900 return *(
const _Tp*)this->ptr;
2903 template<
typename _Tp>
inline
2904 SparseMatConstIterator_<_Tp>& SparseMatConstIterator_<_Tp>::operator ++()
2906 SparseMatConstIterator::operator ++();
2910 template<
typename _Tp>
inline
2911 SparseMatConstIterator_<_Tp> SparseMatConstIterator_<_Tp>::operator ++(
int)
2913 SparseMatConstIterator_<_Tp> it = *
this;
2914 SparseMatConstIterator::operator ++();
2922 template<
typename _Tp>
inline
2923 SparseMatIterator_<_Tp>::SparseMatIterator_()
2926 template<
typename _Tp>
inline
2927 SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat_<_Tp>* _m)
2928 : SparseMatConstIterator_<_Tp>(_m)
2931 template<
typename _Tp>
inline
2932 SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat* _m)
2933 : SparseMatConstIterator_<_Tp>(_m)
2936 template<
typename _Tp>
inline
2937 SparseMatIterator_<_Tp>::SparseMatIterator_(
const SparseMatIterator_<_Tp>& it)
2938 : SparseMatConstIterator_<_Tp>(it)
2941 template<
typename _Tp>
inline
2942 SparseMatIterator_<_Tp>& SparseMatIterator_<_Tp>::operator = (
const SparseMatIterator_<_Tp>& it)
2944 return reinterpret_cast<SparseMatIterator_<_Tp>&
>
2945 (*
reinterpret_cast<SparseMatConstIterator*
>(
this) =
2946 reinterpret_cast<const SparseMatConstIterator&
>(it));
2949 template<
typename _Tp>
inline
2952 return *(_Tp*)this->ptr;
2955 template<
typename _Tp>
inline
2956 SparseMatIterator_<_Tp>& SparseMatIterator_<_Tp>::operator ++()
2958 SparseMatConstIterator::operator ++();
2962 template<
typename _Tp>
inline
2963 SparseMatIterator_<_Tp> SparseMatIterator_<_Tp>::operator ++(
int)
2965 SparseMatIterator_<_Tp> it = *
this;
2966 SparseMatConstIterator::operator ++();
2974 template<
typename _Tp>
inline
2975 MatCommaInitializer_<_Tp>::MatCommaInitializer_(Mat_<_Tp>* _m)
2979 template<
typename _Tp>
template<
typename T2>
inline
2980 MatCommaInitializer_<_Tp>& MatCommaInitializer_<_Tp>::operator , (T2 v)
2982 CV_DbgAssert( this->it < ((
const Mat_<_Tp>*)this->it.m)->end() );
2988 template<
typename _Tp>
inline
2989 MatCommaInitializer_<_Tp>::operator Mat_<_Tp>()
const
2991 CV_DbgAssert( this->it == ((
const Mat_<_Tp>*)this->it.m)->end() );
2992 return Mat_<_Tp>(*this->it.m);
2996 template<
typename _Tp,
typename T2>
static inline
2997 MatCommaInitializer_<_Tp>
operator << (
const Mat_<_Tp>& m, T2 val)
2999 MatCommaInitializer_<_Tp> commaInitializer((Mat_<_Tp>*)&m);
3000 return (commaInitializer, val);
3008 Mat& Mat::operator = (
const MatExpr& e)
3010 e.op->assign(e, *
this);
3014 template<
typename _Tp>
inline
3015 Mat_<_Tp>::Mat_(
const MatExpr& e)
3020 template<
typename _Tp>
inline
3021 Mat_<_Tp>& Mat_<_Tp>::operator = (
const MatExpr& e)
3027 template<
typename _Tp>
inline
3028 MatExpr Mat_<_Tp>::zeros(
int rows,
int cols)
3033 template<
typename _Tp>
inline
3034 MatExpr Mat_<_Tp>::zeros(
Size sz)
3039 template<
typename _Tp>
inline
3040 MatExpr Mat_<_Tp>::ones(
int rows,
int cols)
3045 template<
typename _Tp>
inline
3046 MatExpr Mat_<_Tp>::ones(
Size sz)
3051 template<
typename _Tp>
inline
3052 MatExpr Mat_<_Tp>::eye(
int rows,
int cols)
3057 template<
typename _Tp>
inline
3058 MatExpr Mat_<_Tp>::eye(
Size sz)
3065 : op(0),
flags(0), a(Mat()), b(Mat()), c(Mat()),
alpha(0),
beta(0), s()
3069 MatExpr::MatExpr(
const MatOp* _op,
int _flags,
const Mat& _a,
const Mat& _b,
3070 const Mat& _c,
double _alpha,
double _beta,
const Scalar& _s)
3071 : op(_op),
flags(_flags), a(_a), b(_b), c(_c),
alpha(_alpha),
beta(_beta), s(_s)
3075 MatExpr::operator Mat()
const
3078 op->assign(*
this, m);
3082 template<
typename _Tp>
inline
3083 MatExpr::operator Mat_<_Tp>()
const
3091 template<
typename _Tp>
static inline
3092 MatExpr
min(
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
3094 return cv::min((
const Mat&)a, (
const Mat&)b);
3097 template<
typename _Tp>
static inline
3098 MatExpr
min(
const Mat_<_Tp>& a,
double s)
3100 return cv::min((
const Mat&)a, s);
3103 template<
typename _Tp>
static inline
3104 MatExpr
min(
double s,
const Mat_<_Tp>& a)
3106 return cv::min((
const Mat&)a, s);
3109 template<
typename _Tp>
static inline
3110 MatExpr
max(
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
3112 return cv::max((
const Mat&)a, (
const Mat&)b);
3115 template<
typename _Tp>
static inline
3116 MatExpr
max(
const Mat_<_Tp>& a,
double s)
3118 return cv::max((
const Mat&)a, s);
3121 template<
typename _Tp>
static inline
3122 MatExpr
max(
double s,
const Mat_<_Tp>& a)
3124 return cv::max((
const Mat&)a, s);
3127 template<
typename _Tp>
static inline
3128 MatExpr
abs(
const Mat_<_Tp>& m)
3130 return cv::abs((
const Mat&)m);
3137 b.op->augAssignAdd(b, a);
3142 const Mat&
operator += (
const Mat& a,
const MatExpr& b)
3144 b.op->augAssignAdd(b, (Mat&)a);
3148 template<
typename _Tp>
static inline
3149 Mat_<_Tp>&
operator += (Mat_<_Tp>& a,
const MatExpr& b)
3151 b.op->augAssignAdd(b, a);
3155 template<
typename _Tp>
static inline
3156 const Mat_<_Tp>&
operator += (
const Mat_<_Tp>& a,
const MatExpr& b)
3158 b.op->augAssignAdd(b, (Mat&)a);
3165 b.op->augAssignSubtract(b, a);
3170 const Mat&
operator -= (
const Mat& a,
const MatExpr& b)
3172 b.op->augAssignSubtract(b, (Mat&)a);
3176 template<
typename _Tp>
static inline
3177 Mat_<_Tp>&
operator -= (Mat_<_Tp>& a,
const MatExpr& b)
3179 b.op->augAssignSubtract(b, a);
3183 template<
typename _Tp>
static inline
3184 const Mat_<_Tp>&
operator -= (
const Mat_<_Tp>& a,
const MatExpr& b)
3186 b.op->augAssignSubtract(b, (Mat&)a);
3193 b.op->augAssignMultiply(b, a);
3198 const Mat&
operator *= (
const Mat& a,
const MatExpr& b)
3200 b.op->augAssignMultiply(b, (Mat&)a);
3204 template<
typename _Tp>
static inline
3205 Mat_<_Tp>&
operator *= (Mat_<_Tp>& a,
const MatExpr& b)
3207 b.op->augAssignMultiply(b, a);
3211 template<
typename _Tp>
static inline
3212 const Mat_<_Tp>&
operator *= (
const Mat_<_Tp>& a,
const MatExpr& b)
3214 b.op->augAssignMultiply(b, (Mat&)a);
3221 b.op->augAssignDivide(b, a);
3226 const Mat&
operator /= (
const Mat& a,
const MatExpr& b)
3228 b.op->augAssignDivide(b, (Mat&)a);
3232 template<
typename _Tp>
static inline
3233 Mat_<_Tp>&
operator /= (Mat_<_Tp>& a,
const MatExpr& b)
3235 b.op->augAssignDivide(b, a);
3239 template<
typename _Tp>
static inline
3240 const Mat_<_Tp>&
operator /= (
const Mat_<_Tp>& a,
const MatExpr& b)
3242 b.op->augAssignDivide(b, (Mat&)a);
3249 template<
typename _Tp>
inline
3259 CV_Error(Error::StsNotImplemented,
"");
3266 UMat UMat::row(
int y)
const
3268 return UMat(*
this, Range(
y,
y + 1), Range::all());
3272 UMat UMat::col(
int x)
const
3274 return UMat(*
this, Range::all(), Range(
x,
x + 1));
3278 UMat UMat::rowRange(
int startrow,
int endrow)
const
3280 return UMat(*
this, Range(startrow, endrow), Range::all());
3284 UMat UMat::rowRange(
const Range&
r)
const
3286 return UMat(*
this,
r, Range::all());
3290 UMat UMat::colRange(
int startcol,
int endcol)
const
3292 return UMat(*
this, Range::all(), Range(startcol, endcol));
3296 UMat UMat::colRange(
const Range&
r)
const
3298 return UMat(*
this, Range::all(),
r);
3302 UMat UMat::operator()( Range _rowRange, Range _colRange )
const
3304 return UMat(*
this, _rowRange, _colRange);
3308 UMat UMat::operator()(
const Rect& roi )
const
3310 return UMat(*
this, roi);
3314 UMat UMat::operator()(
const Range*
ranges)
const
3316 return UMat(*
this,
ranges);
3322 return UMat(*
this,
ranges);
3326 bool UMat::isContinuous()
const
3328 return (
flags & CONTINUOUS_FLAG) != 0;
3332 bool UMat::isSubmatrix()
const
3334 return (
flags & SUBMATRIX_FLAG) != 0;
3338 size_t UMat::elemSize()
const
3346 size_t UMat::elemSize1()
const
3370 size_t UMat::step1(
int i)
const
3372 return step.p[i] / elemSize1();
3376 inline bool UMatData::hostCopyObsolete()
const {
return (
flags & HOST_COPY_OBSOLETE) != 0; }
3377 inline bool UMatData::deviceCopyObsolete()
const {
return (
flags & DEVICE_COPY_OBSOLETE) != 0; }
3378 inline bool UMatData::deviceMemMapped()
const {
return (
flags & DEVICE_MEM_MAPPED) != 0; }
3379 inline bool UMatData::copyOnMap()
const {
return (
flags & COPY_ON_MAP) != 0; }
3380 inline bool UMatData::tempUMat()
const {
return (
flags & TEMP_UMAT) != 0; }
3381 inline bool UMatData::tempCopiedUMat()
const {
return (
flags & TEMP_COPIED_UMAT) == TEMP_COPIED_UMAT; }
3383 inline void UMatData::markDeviceMemMapped(
bool flag)
3386 flags |= DEVICE_MEM_MAPPED;
3388 flags &= ~DEVICE_MEM_MAPPED;
3391 inline void UMatData::markHostCopyObsolete(
bool flag)
3394 flags |= HOST_COPY_OBSOLETE;
3396 flags &= ~HOST_COPY_OBSOLETE;
3398 inline void UMatData::markDeviceCopyObsolete(
bool flag)
3401 flags |= DEVICE_COPY_OBSOLETE;
3403 flags &= ~DEVICE_COPY_OBSOLETE;
3414 #pragma warning( pop )
3417 #ifdef CV_DISABLE_CLANG_ENUM_WARNINGS
3418 #undef CV_DISABLE_CLANG_ENUM_WARNINGS
3419 #pragma clang diagnostic pop
Matrix expression representation This is a list of implemented matrix operations that can be combined...
Definition: mat.hpp:3586
CV_EXPORTS MatExpr min(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr operator-(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr abs(const Mat &m)
Calculates an absolute value of each matrix element.
CV_EXPORTS MatExpr operator!=(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr max(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr operator>=(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr operator+(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr operator<=(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr operator==(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr operator>(const Mat &a, const Mat &b)
CV_EXPORTS MatExpr operator<(const Mat &a, const Mat &b)
_Tp height
the height
Definition: types.hpp:363
_Tp width
the width
Definition: types.hpp:362
static _OutputArray rawOut(std::vector< _Tp > &vec)
InputArrayOfArrays Size InputOutputArray InputOutputArray OutputArrayOfArrays OutputArrayOfArrays OutputArray OutputArray OutputArray int flags
Definition: calib3d.hpp:1617
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...
static _InputOutputArray rawInOut(_Tp &v)
Rect2i Rect
Definition: types.hpp:489
Point2i Point
Definition: types.hpp:209
Size2i Size
Definition: types.hpp:370
static _InputArray rawIn(_Tp &v)
static bool operator!=(const Matx< _Tp, m, n > &a, const Matx< _Tp, m, n > &b)
CV__DEBUG_NS_BEGIN class CV_EXPORTS _OutputArray
Definition: mat.hpp:72
Scalar_< double > Scalar
Definition: types.hpp:702
static _OutputArray rawOut(_Tp &v)
@ USAGE_DEFAULT
Definition: mat.hpp:465
@ ACCESS_READ
Definition: mat.hpp:65
@ ACCESS_RW
Definition: mat.hpp:66
@ ACCESS_WRITE
Definition: mat.hpp:65
int rows
Definition: core_c.h:257
int CvScalar value
Definition: core_c.h:720
int int void int total
Definition: core_c.h:1689
const CvArr const CvArr const CvArr CvArr int flags
Definition: core_c.h:1342
int int channels
Definition: core_c.h:100
double double end
Definition: core_c.h:1381
const void * elem
Definition: core_c.h:1715
int cols
Definition: core_c.h:221
double const CvArr double beta
Definition: core_c.h:1094
const int * idx
Definition: core_c.h:668
CvMemStoragePos * pos
Definition: core_c.h:1573
CvSize size
Definition: core_c.h:112
int int type
Definition: core_c.h:221
void int step
Definition: core_c.h:905
CvArr * arr
Definition: core_c.h:1247
int depth
Definition: core_c.h:100
void * data
Definition: core_c.h:427
const CvArr CvArr * x
Definition: core_c.h:1195
double alpha
Definition: core_c.h:1093
int dims
Definition: core_c.h:464
const int * sizes
Definition: core_c.h:440
const CvArr * y
Definition: core_c.h:1187
#define CV_64F
Definition: interface.h:79
#define CV_8U
Definition: interface.h:73
#define CV_MAT_DEPTH(flags)
Definition: interface.h:83
#define CV_CN_MAX
Definition: interface.h:69
unsigned char uchar
Definition: interface.h:51
#define CV_MAKETYPE(depth, cn)
Definition: interface.h:85
CV_INLINE v_reg< _Tp, n > operator*(const v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
Multiply values.
CV_INLINE v_reg< _Tp, n > & operator-=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > & operator*=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > & operator/=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
CV_INLINE v_reg< _Tp, n > & operator+=(v_reg< _Tp, n > &a, const v_reg< _Tp, n > &b)
softfloat max(const softfloat &a, const softfloat &b)
Definition: softfloat.hpp:440
softfloat min(const softfloat &a, const softfloat &b)
Min and Max functions.
Definition: softfloat.hpp:437
#define CV_MAT_TYPE_MASK
Definition: cvdef.h:496
#define CV_MAT_CONT_FLAG
Definition: cvdef.h:499
#define CV_ELEM_SIZE1(type)
Definition: cvdef.h:508
#define CV_Error(code, msg)
Call the error handler.
Definition: base.hpp:320
#define CV_MAT_CN(flags)
Definition: cvdef.h:495
#define CV_NOEXCEPT
Definition: cvdef.h:800
#define CV_MAT_TYPE(flags)
Definition: cvdef.h:497
#define CV__DEBUG_NS_BEGIN
Definition: cvdef.h:69
#define CV__DEBUG_NS_END
Definition: cvdef.h:70
#define CV_Assert(expr)
Checks a condition at runtime and throws exception if it fails.
Definition: base.hpp:342
#define CV_DbgAssert(expr)
Definition: base.hpp:375
#define CV_ELEM_SIZE(type)
Definition: cvdef.h:510
CV_EXPORTS void swap(Mat &a, Mat &b)
Swaps two matrices.
std::ostream & operator<<(std::ostream &, const DualQuat< _Tp > &)
CvPoint2D32f pt[4]
Definition: imgproc_c.h:571
CvArr CvPoint2D32f double M
Definition: imgproc_c.h:270
CvRect r
Definition: imgproc_c.h:984
float ** ranges
Definition: imgproc_c.h:636
CvArr CvPoint offset
Definition: imgproc_c.h:88
CvArr CvArr IplConvKernel int operation
Definition: imgproc_c.h:330
CvArr CvArr * temp
Definition: imgproc_c.h:329
"black box" representation of the file storage associated with a file on disk.
Definition: calib3d.hpp:441
static uchar abs(uchar a)
Definition: cvstd.hpp:66
float x
Definition: types_c.h:978
float y
Definition: types_c.h:979
double val[4]
Definition: types_c.h:1368
@ value
Definition: traits.hpp:386