43 #ifndef __OPENCV_CORE_MATRIX_OPERATIONS_HPP__
44 #define __OPENCV_CORE_MATRIX_OPERATIONS_HPP__
49 #endif // SKIP_INCLUDES
75 create(_rows, _cols, _type);
81 create(_rows, _cols, _type);
101 create(_dims, _sz, _type);
107 create(_dims, _sz, _type);
113 refcount(m.refcount), datastart(m.datastart), dataend(m.dataend),
114 datalimit(m.datalimit), allocator(m.allocator),
size(&
rows)
129 inline Mat::Mat(
int _rows,
int _cols,
int _type,
void* _data,
size_t _step)
131 data((
uchar*)_data), refcount(0), datastart((
uchar*)_data), dataend(0),
132 datalimit(0), allocator(0),
size(&
rows)
134 size_t esz = CV_ELEM_SIZE(_type), minstep =
cols*esz;
142 if(
rows == 1 ) _step = minstep;
143 CV_DbgAssert( _step >= minstep );
153 data((
uchar*)_data), refcount(0), datastart((
uchar*)_data), dataend(0),
154 datalimit(0), allocator(0),
size(&
rows)
156 size_t esz = CV_ELEM_SIZE(_type), minstep =
cols*esz;
164 if(
rows == 1 ) _step = minstep;
165 CV_DbgAssert( _step >= minstep );
174 template<
typename _Tp>
inline Mat::Mat(
const vector<_Tp>& vec,
bool copyData)
177 datastart(0), dataend(0), allocator(0),
size(&
rows)
195 datastart(0), dataend(0), allocator(0),
size(&
rows)
211 datastart(0), dataend(0), allocator(0),
size(&
rows)
216 step[1] =
sizeof(_Tp);
228 datastart(0), dataend(0), allocator(0),
size(&
rows)
239 ((_Tp*)
data)[0] = pt.
x;
240 ((_Tp*)
data)[1] = pt.
y;
248 datastart(0), dataend(0), allocator(0),
size(&
rows)
259 ((_Tp*)
data)[0] = pt.
x;
260 ((_Tp*)
data)[1] = pt.
y;
261 ((_Tp*)
data)[2] = pt.
z;
269 datastart(0), dataend(0), allocator(0),
size(&
rows)
271 *
this = *commaInitializer;
322 CV_Assert( d.
cols == 1 || d.
rows == 1 );
352 int sz[] = {_rows, _cols};
375 return Mat(*
this, _rowRange, _colRange);
379 {
return Mat(*
this, roi); }
383 return Mat(*
this, ranges);
388 CV_DbgAssert(
dims <= 2);
391 m.
type = (m.
type & ~CONTINUOUS_FLAG) | (
flags & CONTINUOUS_FLAG);
409 for(
int i = 0; i <
dims; i++ )
416 CV_DbgAssert( y == 0 || (
data &&
dims >= 1 && (
unsigned)y < (
unsigned)
size.p[0]) );
422 CV_DbgAssert( y == 0 || (
data &&
dims >= 1 && (
unsigned)y < (
unsigned)
size.p[0]) );
428 CV_DbgAssert( y == 0 || (
data &&
dims >= 1 && (
unsigned)y < (
unsigned)
size.p[0]) );
432 template<
typename _Tp>
inline const _Tp*
Mat::ptr(
int y)
const
434 CV_DbgAssert( y == 0 || (
data &&
dims >= 1 && (
unsigned)y < (
unsigned)
size.p[0]) );
442 (
unsigned)i0 < (
unsigned)
size.p[0] &&
443 (
unsigned)i1 < (
unsigned)
size.p[1] );
450 (
unsigned)i0 < (
unsigned)
size.p[0] &&
451 (
unsigned)i1 < (
unsigned)
size.p[1] );
455 template<
typename _Tp>
inline _Tp*
Mat::ptr(
int i0,
int i1)
458 (
unsigned)i0 < (
unsigned)
size.p[0] &&
459 (
unsigned)i1 < (
unsigned)
size.p[1] );
463 template<
typename _Tp>
inline const _Tp*
Mat::ptr(
int i0,
int i1)
const
466 (
unsigned)i0 < (
unsigned)
size.p[0] &&
467 (
unsigned)i1 < (
unsigned)
size.p[1] );
474 (
unsigned)i0 < (
unsigned)
size.p[0] &&
475 (
unsigned)i1 < (
unsigned)
size.p[1] &&
476 (
unsigned)i2 < (
unsigned)
size.p[2] );
483 (
unsigned)i0 < (
unsigned)
size.p[0] &&
484 (
unsigned)i1 < (
unsigned)
size.p[1] &&
485 (
unsigned)i2 < (
unsigned)
size.p[2] );
489 template<
typename _Tp>
inline _Tp*
Mat::ptr(
int i0,
int i1,
int i2)
492 (
unsigned)i0 < (
unsigned)
size.p[0] &&
493 (
unsigned)i1 < (
unsigned)
size.p[1] &&
494 (
unsigned)i2 < (
unsigned)
size.p[2] );
498 template<
typename _Tp>
inline const _Tp*
Mat::ptr(
int i0,
int i1,
int i2)
const
501 (
unsigned)i0 < (
unsigned)
size.p[0] &&
502 (
unsigned)i1 < (
unsigned)
size.p[1] &&
503 (
unsigned)i2 < (
unsigned)
size.p[2] );
511 CV_DbgAssert( d >= 1 && p );
512 for( i = 0; i <
d; i++ )
514 CV_DbgAssert( (
unsigned)idx[i] < (
unsigned)
size.p[i] );
515 p += idx[i]*
step.
p[i];
524 CV_DbgAssert( d >= 1 && p );
525 for( i = 0; i <
d; i++ )
527 CV_DbgAssert( (
unsigned)idx[i] < (
unsigned)
size.p[i] );
528 p += idx[i]*
step.
p[i];
533 template<
typename _Tp>
inline _Tp&
Mat::at(
int i0,
int i1)
535 CV_DbgAssert(
dims <= 2 &&
data && (
unsigned)i0 < (
unsigned)
size.p[0] &&
538 return ((_Tp*)(
data +
step.
p[0]*i0))[i1];
541 template<
typename _Tp>
inline const _Tp&
Mat::at(
int i0,
int i1)
const
543 CV_DbgAssert(
dims <= 2 &&
data && (
unsigned)i0 < (
unsigned)
size.p[0] &&
546 return ((
const _Tp*)(
data +
step.
p[0]*i0))[i1];
551 CV_DbgAssert(
dims <= 2 &&
data && (
unsigned)pt.
y < (
unsigned)
size.p[0] &&
559 CV_DbgAssert(
dims <= 2 &&
data && (
unsigned)pt.
y < (
unsigned)
size.p[0] &&
562 return ((
const _Tp*)(
data +
step.
p[0]*pt.
y))[pt.
x];
565 template<
typename _Tp>
inline _Tp&
Mat::at(
int i0)
568 (
unsigned)i0 < (
unsigned)(
size.p[0]*
size.p[1]) &&
571 return ((_Tp*)
data)[i0];
578 template<
typename _Tp>
inline const _Tp&
Mat::at(
int i0)
const
581 (
unsigned)i0 < (
unsigned)(
size.p[0]*
size.p[1]) &&
584 return ((
const _Tp*)
data)[i0];
586 return *(
const _Tp*)(
data +
step.
p[0]*i0);
588 return ((
const _Tp*)(
data +
step.
p[0]*i))[j];
591 template<
typename _Tp>
inline _Tp&
Mat::at(
int i0,
int i1,
int i2)
594 return *(_Tp*)
ptr(i0, i1, i2);
596 template<
typename _Tp>
inline const _Tp&
Mat::at(
int i0,
int i1,
int i2)
const
599 return *(
const _Tp*)
ptr(i0, i1, i2);
604 return *(_Tp*)
ptr(idx);
606 template<
typename _Tp>
inline const _Tp&
Mat::at(
const int*
idx)
const
609 return *(
const _Tp*)
ptr(idx);
614 return *(_Tp*)
ptr(idx.
val);
619 return *(
const _Tp*)
ptr(idx.
val);
625 CV_DbgAssert(
elemSize() ==
sizeof(_Tp) );
631 CV_DbgAssert(
elemSize() ==
sizeof(_Tp) );
639 CV_DbgAssert(
elemSize() ==
sizeof(_Tp) );
645 CV_DbgAssert(
elemSize() ==
sizeof(_Tp) );
651 template<
typename _Tp>
inline Mat::operator vector<_Tp>()
const
658 template<
typename _Tp,
int n>
inline Mat::operator
Vec<_Tp, n>()
const
666 convertTo(tmp, tmp.
type());
677 convertTo(tmp, tmp.
type());
694 *(_Tp*)(
data + (
size.p[0]++)*step.p[0]) = elem;
709 CV_DbgAssert(
p[-1] <= 2);
714 inline Mat::MSize::operator
const int*()
const {
return p; }
718 int d =
p[-1], dsz = sz.
p[-1];
722 return p[0] == sz.
p[0] &&
p[1] == sz.
p[1];
724 for(
int i = 0; i <
d; i++ )
725 if(
p[i] != sz.
p[i] )
732 return !(*
this == sz);
739 inline Mat::MStep::operator size_t()
const
741 CV_DbgAssert(
p == buf );
746 CV_DbgAssert(
p == buf );
751 static inline Mat cvarrToMatND(
const CvArr*
arr,
bool copyData=
false,
int coiMode=0)
753 return cvarrToMat(arr, copyData,
true, coiMode);
769 template<
typename _Tp,
int m,
int n,
int nm>
inline void
770 SVD::compute(
const Matx<_Tp, m, n>&
a,
Matx<_Tp, nm, 1>&
w,
Matx<_Tp, m, nm>& u,
Matx<_Tp, n, nm>& vt )
772 assert( nm == MIN(
m,
n));
773 Mat _a(a,
false), _u(u,
false), _w(w,
false), _vt(vt,
false);
778 template<
typename _Tp,
int m,
int n,
int nm>
inline void
781 assert( nm == MIN(
m,
n));
782 Mat _a(a,
false), _w(w,
false);
787 template<
typename _Tp,
int m,
int n,
int nm,
int nb>
inline void
792 assert( nm == MIN(
m,
n));
793 Mat _u(u,
false), _w(w,
false), _vt(vt,
false), _rhs(rhs,
false), _dst(dst,
false);
818 template<
typename _Tp>
inline Mat_<_Tp>::Mat_(
int _dims,
const int* _sz,
const _Tp& _s)
830 template<
typename _Tp>
inline Mat_<_Tp>::Mat_(
int _rows,
int _cols, _Tp* _data,
size_t steps)
834 :
Mat(m, _rowRange, _colRange) {}
839 template<
typename _Tp>
template<
int n>
inline
848 template<
typename _Tp>
template<
int m,
int n>
inline
874 :
Mat(commaInitializer) {}
877 :
Mat(vec, copyData) {}
972 {
return Mat_<_Tp>(*
this, _rowRange, _colRange); }
981 {
return (_Tp*)
ptr(y); }
983 {
return (
const _Tp*)
ptr(y); }
988 (
unsigned)i0 < (
unsigned)
size.p[0] &&
989 (
unsigned)i1 < (
unsigned)
size.p[1] &&
991 return ((_Tp*)(
data +
step.p[0]*i0))[i1];
997 (
unsigned)i0 < (
unsigned)
size.p[0] &&
998 (
unsigned)i1 < (
unsigned)
size.p[1] &&
1000 return ((
const _Tp*)(
data +
step.p[0]*i0))[i1];
1006 (
unsigned)pt.
y < (
unsigned)
size.p[0] &&
1007 (
unsigned)pt.
x < (
unsigned)
size.p[1] &&
1009 return ((_Tp*)(
data +
step.p[0]*pt.
y))[pt.
x];
1015 (
unsigned)pt.
y < (
unsigned)
size.p[0] &&
1016 (
unsigned)pt.
x < (
unsigned)
size.p[1] &&
1018 return ((
const _Tp*)(
data +
step.p[0]*pt.
y))[pt.
x];
1023 return Mat::at<_Tp>(
idx);
1028 return Mat::at<_Tp>(
idx);
1033 return Mat::at<_Tp>(
idx);
1038 return Mat::at<_Tp>(
idx);
1043 return this->at<_Tp>(i0);
1048 return this->at<_Tp>(i0);
1053 return this->at<_Tp>(i0, i1, i2);
1058 return this->at<_Tp>(i0, i1, i2);
1083 template<
typename T1,
typename T2,
typename Op>
inline void
1088 CV_DbgAssert( m1.
size() == m2.
size() );
1090 for( y = 0; y <
rows; y++ )
1092 const T1*
src = m1[
y];
1095 for( x = 0; x <
cols; x++ )
1096 dst[x] = op(src[x]);
1100 template<
typename T1,
typename T2,
typename T3,
typename Op>
inline void
1105 CV_DbgAssert( m1.
size() == m2.
size() );
1107 for( y = 0; y <
rows; y++ )
1109 const T1*
src1 = m1[
y];
1110 const T2*
src2 = m2[
y];
1113 for( x = 0; x <
cols; x++ )
1114 dst[x] = op( src1[x], src2[x] );
1137 :
flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F),
obj((
void*)&s), sz(1, 4) {}
1177 virtual bool elementWise(
const MatExpr& expr)
const;
1178 virtual void assign(
const MatExpr& expr,
Mat&
m,
int type=-1)
const = 0;
1182 virtual void augAssignAdd(
const MatExpr& expr,
Mat&
m)
const;
1183 virtual void augAssignSubtract(
const MatExpr& expr,
Mat&
m)
const;
1184 virtual void augAssignMultiply(
const MatExpr& expr,
Mat&
m)
const;
1185 virtual void augAssignDivide(
const MatExpr& expr,
Mat&
m)
const;
1186 virtual void augAssignAnd(
const MatExpr& expr,
Mat&
m)
const;
1187 virtual void augAssignOr(
const MatExpr& expr,
Mat&
m)
const;
1188 virtual void augAssignXor(
const MatExpr& expr,
Mat&
m)
const;
1224 op->assign(*
this, m);
1242 double dot(
const Mat&
m)
const;
1283 CV_EXPORTS
MatExpr operator * (
const Mat&
a,
double s);
1284 CV_EXPORTS
MatExpr operator * (
double s,
const Mat&
a);
1337 template<
typename _Tp>
static inline MatExpr min(
const Mat_<_Tp>& a,
double s)
1339 return cv::min((
const Mat&)a, s);
1342 template<
typename _Tp>
static inline MatExpr min(
double s,
const Mat_<_Tp>& a)
1344 return cv::min((
const Mat&)a, s);
1347 template<
typename _Tp>
static inline MatExpr max(
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
1349 return cv::max((
const Mat&)a, (
const Mat&)b);
1352 template<
typename _Tp>
static inline MatExpr max(
const Mat_<_Tp>& a,
double s)
1354 return cv::max((
const Mat&)a, s);
1357 template<
typename _Tp>
static inline MatExpr max(
double s,
const Mat_<_Tp>& a)
1359 return cv::max((
const Mat&)a, s);
1362 template<
typename _Tp>
static inline void min(
const Mat_<_Tp>& a,
const Mat_<_Tp>& b, Mat_<_Tp>&
c)
1364 cv::min((
const Mat&)a, (
const Mat&)b, (Mat&)c);
1367 template<
typename _Tp>
static inline void min(
const Mat_<_Tp>& a,
double s, Mat_<_Tp>& c)
1369 cv::min((
const Mat&)a, s, (Mat&)c);
1372 template<
typename _Tp>
static inline void min(
double s,
const Mat_<_Tp>& a, Mat_<_Tp>& c)
1374 cv::min((
const Mat&)a, s, (Mat&)c);
1377 template<
typename _Tp>
static inline void max(
const Mat_<_Tp>& a,
const Mat_<_Tp>& b, Mat_<_Tp>& c)
1379 cv::max((
const Mat&)a, (
const Mat&)b, (Mat&)c);
1382 template<
typename _Tp>
static inline void max(
const Mat_<_Tp>& a,
double s, Mat_<_Tp>& c)
1384 cv::max((
const Mat&)a, s, (Mat&)c);
1387 template<
typename _Tp>
static inline void max(
double s,
const Mat_<_Tp>& a, Mat_<_Tp>& c)
1389 cv::max((
const Mat&)a, s, (Mat&)c);
1410 template<
typename _Tp>
static inline MatExpr abs(
const Mat_<_Tp>&
m)
1412 return cv::abs((
const Mat&)m);
1434 static inline Mat& operator += (
const Mat& a,
const Mat& b)
1440 static inline Mat& operator += (
const Mat& a,
const Scalar& s)
1446 template<
typename _Tp>
static inline
1447 Mat_<_Tp>& operator += (
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
1450 return (Mat_<_Tp>&)
a;
1453 template<
typename _Tp>
static inline
1454 Mat_<_Tp>& operator += (
const Mat_<_Tp>& a,
const Scalar& s)
1457 return (Mat_<_Tp>&)
a;
1460 static inline Mat& operator += (
const Mat& a,
const MatExpr& b)
1462 b.op->augAssignAdd(b, (Mat&)a);
1466 template<
typename _Tp>
static inline
1467 Mat_<_Tp>& operator += (
const Mat_<_Tp>& a,
const MatExpr& b)
1469 b.op->augAssignAdd(b, (Mat&)a);
1470 return (Mat_<_Tp>&)
a;
1473 static inline Mat& operator -= (
const Mat& a,
const Mat& b)
1479 static inline Mat& operator -= (
const Mat& a,
const Scalar& s)
1485 template<
typename _Tp>
static inline
1486 Mat_<_Tp>& operator -= (
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
1489 return (Mat_<_Tp>&)
a;
1492 template<
typename _Tp>
static inline
1493 Mat_<_Tp>& operator -= (
const Mat_<_Tp>& a,
const Scalar& s)
1496 return (Mat_<_Tp>&)
a;
1499 static inline Mat& operator -= (
const Mat& a,
const MatExpr& b)
1501 b.op->augAssignSubtract(b, (Mat&)a);
1505 template<
typename _Tp>
static inline
1506 Mat_<_Tp>& operator -= (
const Mat_<_Tp>& a,
const MatExpr& b)
1508 b.op->augAssignSubtract(b, (Mat&)a);
1509 return (Mat_<_Tp>&)
a;
1512 static inline Mat& operator *= (
const Mat& a,
const Mat& b)
1514 gemm(a, b, 1, Mat(), 0, (Mat&)a, 0);
1518 static inline Mat& operator *= (
const Mat& a,
double s)
1520 a.convertTo((Mat&)a, -1, s);
1524 template<
typename _Tp>
static inline
1525 Mat_<_Tp>& operator *= (
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
1527 gemm(a, b, 1, Mat(), 0, (Mat&)a, 0);
1528 return (Mat_<_Tp>&)
a;
1531 template<
typename _Tp>
static inline
1532 Mat_<_Tp>& operator *= (
const Mat_<_Tp>& a,
double s)
1534 a.convertTo((Mat&)a, -1, s);
1535 return (Mat_<_Tp>&)
a;
1538 static inline Mat& operator *= (
const Mat& a,
const MatExpr& b)
1540 b.op->augAssignMultiply(b, (Mat&)a);
1544 template<
typename _Tp>
static inline
1545 Mat_<_Tp>& operator *= (
const Mat_<_Tp>& a,
const MatExpr& b)
1547 b.op->augAssignMultiply(b, (Mat&)a);
1548 return (Mat_<_Tp>&)
a;
1551 static inline Mat& operator /= (
const Mat& a,
const Mat& b)
1557 static inline Mat& operator /= (
const Mat& a,
double s)
1559 a.convertTo((Mat&)a, -1, 1./s);
1563 template<
typename _Tp>
static inline
1564 Mat_<_Tp>& operator /= (
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
1567 return (Mat_<_Tp>&)
a;
1570 template<
typename _Tp>
static inline
1571 Mat_<_Tp>& operator /= (
const Mat_<_Tp>& a,
double s)
1573 a.convertTo((Mat&)a, -1, 1./s);
1574 return (Mat_<_Tp>&)
a;
1577 static inline Mat& operator /= (
const Mat& a,
const MatExpr& b)
1579 b.op->augAssignDivide(b, (Mat&)a);
1583 template<
typename _Tp>
static inline
1584 Mat_<_Tp>& operator /= (
const Mat_<_Tp>& a,
const MatExpr& b)
1586 b.op->augAssignDivide(b, (Mat&)a);
1587 return (Mat_<_Tp>&)
a;
1592 static inline Mat& operator &= (
const Mat& a,
const Mat& b)
1598 static inline Mat& operator &= (
const Mat& a,
const Scalar& s)
1604 template<
typename _Tp>
static inline Mat_<_Tp>&
1605 operator &= (
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
1608 return (Mat_<_Tp>&)
a;
1611 template<
typename _Tp>
static inline Mat_<_Tp>&
1612 operator &= (
const Mat_<_Tp>& a,
const Scalar& s)
1615 return (Mat_<_Tp>&)
a;
1618 static inline Mat& operator |= (
const Mat& a,
const Mat& b)
1624 static inline Mat& operator |= (
const Mat& a,
const Scalar& s)
1630 template<
typename _Tp>
static inline Mat_<_Tp>&
1631 operator |= (
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
1634 return (Mat_<_Tp>&)
a;
1637 template<
typename _Tp>
static inline Mat_<_Tp>&
1638 operator |= (
const Mat_<_Tp>& a,
const Scalar& s)
1641 return (Mat_<_Tp>&)
a;
1644 static inline Mat& operator ^= (
const Mat& a,
const Mat& b)
1650 static inline Mat& operator ^= (
const Mat& a,
const Scalar& s)
1656 template<
typename _Tp>
static inline Mat_<_Tp>&
1657 operator ^= (
const Mat_<_Tp>& a,
const Mat_<_Tp>& b)
1660 return (Mat_<_Tp>&)
a;
1663 template<
typename _Tp>
static inline Mat_<_Tp>&
1664 operator ^= (
const Mat_<_Tp>& a,
const Scalar& s)
1667 return (Mat_<_Tp>&)
a;
1673 {
split(src, (vector<Mat>&)mv ); }
1710 : m(0), elemSize(0),
ptr(0), sliceStart(0), sliceEnd(0) {}
1713 : m(_m), elemSize(_m->elemSize()),
ptr(0), sliceStart(0), sliceEnd(0)
1715 if( m && m->isContinuous() )
1720 seek((
const int*)0);
1724 : m(_m), elemSize(_m->elemSize()),
ptr(0), sliceStart(0), sliceEnd(0)
1726 CV_Assert(m && m->dims <= 2);
1727 if( m->isContinuous() )
1732 int idx[]={_row, _col};
1737 : m(_m), elemSize(_m->elemSize()),
ptr(0), sliceStart(0), sliceEnd(0)
1739 CV_Assert(m && m->dims <= 2);
1740 if( m->isContinuous() )
1745 int idx[]={_pt.
y, _pt.
x};
1750 : m(it.m), elemSize(it.elemSize),
ptr(it.
ptr), sliceStart(it.sliceStart), sliceEnd(it.sliceEnd)
1764 if( !m || ofs == 0 )
1777 {
return (*
this += -ofs); }
1846 {
return (*
this += -ofs); }
1941 CV_DbgAssert( m->dims <= 2 );
1942 if( m->isContinuous() )
1944 ptrdiff_t ofs = (
const _Tp*)
ptr - (
const _Tp*)m->data;
1945 int y = (
int)(ofs / m->cols),
x = (
int)(ofs - (ptrdiff_t)y*m->cols);
1950 ptrdiff_t ofs = (
uchar*)
ptr - m->data;
1951 int y = (
int)(ofs / m->step),
x = (
int)((ofs -
y*m->step)/
sizeof(_Tp));
1958 {
return a.
m == b.
m && a.
ptr == b.
ptr; }
1960 template<
typename _Tp>
static inline bool
1962 {
return !(a ==
b); }
1964 template<
typename _Tp>
static inline bool
1965 operator == (
const MatConstIterator_<_Tp>& a,
const MatConstIterator_<_Tp>& b)
1966 {
return a.m == b.m && a.ptr == b.ptr; }
1968 template<
typename _Tp>
static inline bool
1969 operator != (
const MatConstIterator_<_Tp>& a,
const MatConstIterator_<_Tp>& b)
1970 {
return a.m != b.m || a.ptr != b.ptr; }
1972 template<
typename _Tp>
static inline bool
1973 operator == (
const MatIterator_<_Tp>& a,
const MatIterator_<_Tp>& b)
1974 {
return a.m == b.m && a.ptr == b.ptr; }
1976 template<
typename _Tp>
static inline bool
1977 operator != (
const MatIterator_<_Tp>& a,
const MatIterator_<_Tp>& b)
1978 {
return a.m != b.m || a.ptr != b.ptr; }
1982 {
return a.ptr < b.ptr; }
1986 {
return a.ptr > b.ptr; }
1990 {
return a.ptr <= b.ptr; }
1994 {
return a.ptr >= b.ptr; }
2007 template<
typename _Tp>
static inline MatConstIterator_<_Tp>
2008 operator + (
const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
2011 template<
typename _Tp>
static inline MatConstIterator_<_Tp>
2012 operator + (ptrdiff_t ofs,
const MatConstIterator_<_Tp>& a)
2015 template<
typename _Tp>
static inline MatConstIterator_<_Tp>
2016 operator - (
const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
2020 {
return *(*
this + i); }
2023 {
return *(_Tp*)MatConstIterator::operator [](i); }
2029 template<
typename _Tp>
static inline MatIterator_<_Tp>
2030 operator + (ptrdiff_t ofs,
const MatIterator_<_Tp>& a)
2033 template<
typename _Tp>
static inline MatIterator_<_Tp>
2034 operator - (
const MatIterator_<_Tp>& a, ptrdiff_t ofs)
2038 {
return *(*
this + i); }
2041 {
return Mat::begin<_Tp>(); }
2044 {
return Mat::end<_Tp>(); }
2047 {
return Mat::begin<_Tp>(); }
2050 {
return Mat::end<_Tp>(); }
2057 CV_DbgAssert( this->it < ((
const Mat_<_Tp>*)this->it.m)->end() );
2058 *this->it = _Tp(v); ++this->it;
2064 CV_DbgAssert( this->it == ((
const Mat_<_Tp>*)this->it.m)->end() );
2070 CV_DbgAssert( this->it == ((
const Mat_<_Tp>*)this->it.m)->end() );
2075 operator << (const Mat_<_Tp>& m, T2
val)
2078 return (commaInitializer,
val);
2084 :
flags(MAGIC_VAL), hdr(0)
2089 :
flags(MAGIC_VAL), hdr(0)
2091 create(_dims, _sizes, _type);
2148 {
return CV_ELEM_SIZE(
flags); }
2151 {
return CV_ELEM_SIZE1(
flags); }
2154 {
return CV_MAT_TYPE(
flags); }
2157 {
return CV_MAT_DEPTH(
flags); }
2160 {
return CV_MAT_CN(
flags); }
2171 CV_DbgAssert((
unsigned)i < (
unsigned)
hdr->
dims);
2194 return (
size_t)(unsigned)i0*
HASH_SCALE + (
unsigned)i1;
2204 size_t h = (unsigned)idx[0];
2208 for( i = 1; i <
d; i++ )
2214 {
return *(_Tp*)((
SparseMat*)
this)->
ptr(i0,
true, hashval); }
2217 {
return *(_Tp*)((
SparseMat*)
this)->
ptr(i0, i1,
true, hashval); }
2219 template<
typename _Tp>
inline _Tp&
SparseMat::ref(
int i0,
int i1,
int i2,
size_t* hashval)
2220 {
return *(_Tp*)((
SparseMat*)
this)->
ptr(i0, i1, i2,
true, hashval); }
2223 {
return *(_Tp*)((
SparseMat*)
this)->
ptr(idx,
true, hashval); }
2227 const _Tp*
p = (
const _Tp*)((
SparseMat*)
this)->
ptr(i0,
false, hashval);
2228 return p ? *p : _Tp();
2233 const _Tp*
p = (
const _Tp*)((
SparseMat*)
this)->
ptr(i0, i1,
false, hashval);
2234 return p ? *p : _Tp();
2237 template<
typename _Tp>
inline _Tp
SparseMat::value(
int i0,
int i1,
int i2,
size_t* hashval)
const
2239 const _Tp*
p = (
const _Tp*)((
SparseMat*)
this)->
ptr(i0, i1, i2,
false, hashval);
2240 return p ? *p : _Tp();
2245 const _Tp*
p = (
const _Tp*)((
SparseMat*)
this)->
ptr(idx,
false, hashval);
2246 return p ? *p : _Tp();
2250 {
return (
const _Tp*)((
SparseMat*)
this)->ptr(i0,
false, hashval); }
2252 template<
typename _Tp>
inline const _Tp*
SparseMat::find(
int i0,
int i1,
size_t* hashval)
const
2253 {
return (
const _Tp*)((
SparseMat*)
this)->ptr(i0, i1,
false, hashval); }
2255 template<
typename _Tp>
inline const _Tp*
SparseMat::find(
int i0,
int i1,
int i2,
size_t* hashval)
const
2256 {
return (
const _Tp*)((
SparseMat*)
this)->ptr(i0, i1, i2,
false, hashval); }
2259 {
return (
const _Tp*)((
SparseMat*)
this)->ptr(idx,
false, hashval); }
2299 : m(0), hashidx(0),
ptr(0)
2304 : m(it.m), hashidx(it.hashidx),
ptr(it.
ptr)
2309 {
return it1.
m == it2.
m && it1.
ptr == it2.
ptr; }
2311 static inline bool operator != (
const SparseMatConstIterator& it1,
const SparseMatConstIterator& it2)
2312 {
return !(it1 == it2); }
2327 {
return *(_Tp*)
ptr; }
2331 return ptr && m && m->hdr ?
2347 hashidx = m->hdr->hashtab.size();
2371 {
return *(_Tp*)
ptr; }
2412 CV_XADD(&this->hdr->refcount, 1);
2432 if( m.
hdr ) CV_XADD(&m.
hdr->refcount, 1);
2461 template<
typename _Tp>
inline void
2467 template<
typename _Tp>
inline
2482 template<
typename _Tp>
inline _Tp&
2484 {
return SparseMat::ref<_Tp>(i0, hashval); }
2486 template<
typename _Tp>
inline _Tp
2488 {
return SparseMat::value<_Tp>(i0, hashval); }
2490 template<
typename _Tp>
inline _Tp&
2492 {
return SparseMat::ref<_Tp>(i0, i1, hashval); }
2494 template<
typename _Tp>
inline _Tp
2496 {
return SparseMat::value<_Tp>(i0, i1, hashval); }
2498 template<
typename _Tp>
inline _Tp&
2500 {
return SparseMat::ref<_Tp>(i0, i1, i2, hashval); }
2502 template<
typename _Tp>
inline _Tp
2504 {
return SparseMat::value<_Tp>(i0, i1, i2, hashval); }
2506 template<
typename _Tp>
inline _Tp&
2508 {
return SparseMat::ref<_Tp>(
idx, hashval); }
2510 template<
typename _Tp>
inline _Tp
2512 {
return SparseMat::value<_Tp>(
idx, hashval); }
2526 template<
typename _Tp>
inline
2530 template<
typename _Tp>
inline
2535 template<
typename _Tp>
inline
2542 template<
typename _Tp>
inline
2551 reinterpret_cast<const SparseMatConstIterator&>(it)); }
2553 template<
typename _Tp>
inline const _Tp&
2555 {
return *(
const _Tp*)this->
ptr; }
2572 template<
typename _Tp>
inline
2576 template<
typename _Tp>
inline
2581 template<
typename _Tp>
inline
2586 template<
typename _Tp>
inline
2595 reinterpret_cast<const SparseMatConstIterator&>(it)); }
2597 template<
typename _Tp>
inline _Tp&
2599 {
return *(_Tp*)this->
ptr; }
int dims
Definition: core_c.h:218
Mat_ diag(int d=0) const
Definition: mat.hpp:934
CvArr CvPoint2D32f double M
Definition: imgproc_c.h:186
GLdouble GLdouble GLdouble r
MatAllocator * allocator
custom allocator
Definition: core.hpp:1976
Definition: core.hpp:1950
Point2i Point
Definition: core.hpp:893
static MatExpr ones(int rows, int cols, int type)
MatIterator_ & operator=(const MatIterator_< _Tp > &it)
copy operator
Definition: mat.hpp:1891
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions ...
Definition: core.hpp:1962
MStep()
Definition: mat.hpp:735
CvPoint2D32f pt[4]
Definition: imgproc_c.h:410
int * p
Definition: core.hpp:1988
uchar * ptr(int i0=0)
returns pointer to i0-th submatrix along the dimension #0
Definition: mat.hpp:414
GLenum GLint GLint y
Definition: core_c.h:613
Mat_ clone() const
Definition: mat.hpp:936
bool empty() const
returns true if matrix data is NULL
Definition: mat.hpp:403
void create(int _rows, int _cols)
equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type)
Definition: mat.hpp:908
MatIterator_ & operator--()
decrements the iterator
Definition: mat.hpp:1911
int depth() const
returns depth of the matrix elements
Definition: mat.hpp:2476
Mat reshape(int cn, int rows=0) const
creates alternative matrix header for the same data, with different
IplImage CvRect * roi
Definition: legacy.hpp:234
value_type channel_type
Definition: core.hpp:1011
const _Tp & operator*() const
the element access operator
Definition: mat.hpp:2554
CV_EXPORTS MatExpr operator~(const Mat &m)
MatExpr()
Definition: mat.hpp:1216
int CvScalar value
Definition: core_c.h:340
A short numerical vector.
Definition: core.hpp:84
_Tp y
Definition: core.hpp:805
Read-write Sparse Matrix Iterator.
Definition: core.hpp:3689
CV_EXPORTS MatExpr operator!=(const Mat &a, const Mat &b)
const void * elem
Definition: core_c.h:1075
SparseMatConstIterator_ & operator++()
moves iterator to the next element
Definition: mat.hpp:2558
int channels() const
Definition: mat.hpp:960
MatIterator_< _Tp > end()
Definition: mat.hpp:643
_Tp & operator*() const
returns the reference to the current element
Definition: mat.hpp:2598
SparseMat_()
the default constructor
Definition: mat.hpp:2392
static void solveZ(InputArray src, OutputArray dst)
finds dst = arg min_{|dst|=1} |m*dst|
Definition: mat.hpp:760
Matrix read-write iterator.
Definition: core.hpp:116
size_t elemSize1() const
returns the size of element channel in bytes.
Definition: mat.hpp:398
SparseMatIterator end()
return the sparse matrix iterator pointing to the element following the last sparse matrix element ...
Definition: mat.hpp:2279
bool isSubmatrix() const
returns true if the matrix is a submatrix of another matrix
Definition: mat.hpp:396
SparseMatIterator begin()
return the sparse matrix iterator pointing to the first sparse matrix element
Definition: mat.hpp:2273
_Tp z
Definition: core.hpp:805
bool operator==(const MSize &sz) const
Definition: mat.hpp:716
int channels() const
returns the number of channels in each matrix element
Definition: mat.hpp:2479
Mat clone() const
returns deep copy of the matrix, i.e. the data is copied
Definition: mat.hpp:332
MatConstIterator_ & operator-=(ptrdiff_t ofs)
shifts the iterator backward by the specified number of elements
Definition: mat.hpp:1845
MatConstIterator & operator++()
increments the iterator
Definition: mat.hpp:1796
CV_EXPORTS_W void bitwise_and(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray())
computes bitwise conjunction of the two arrays (dst = src1 & src2)
SparseMatIterator_()
the default constructor
Definition: mat.hpp:2573
SparseMat()
default constructor
Definition: mat.hpp:2083
Size2i Size
Definition: core.hpp:896
MatConstIterator & operator-=(ptrdiff_t ofs)
shifts the iterator backward by the specified number of elements
Definition: mat.hpp:1776
CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags=DECOMP_LU)
computes inverse or pseudo-inverse matrix
int channels() const
returns element type, similar to CV_MAT_CN(cvmat->type)
Definition: mat.hpp:401
uchar * datalimit
Definition: core.hpp:1973
void create(int dims, const int *_sizes)
equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type)
Definition: mat.hpp:2462
class CV_EXPORTS MatConstIterator
Definition: core.hpp:113
uchar * data
pointer to the data
Definition: core.hpp:1964
CvPoint2D32f float float b
Definition: legacy.hpp:578
void copyTo(OutputArray m) const
copies the matrix content to "m".
const int * idx
Definition: core_c.h:323
Mat_ & adjustROI(int dtop, int dbottom, int dleft, int dright)
some more overriden methods
Definition: mat.hpp:968
int depth() const
Definition: mat.hpp:955
int type() const
Definition: mat.hpp:950
_Tp operator[](ptrdiff_t i) const
returns the i-th matrix element, relative to the current
Definition: mat.hpp:2022
void push_back(const _Tp &elem)
adds element to the end of 1d matrix (or possibly multiple elements when _Tp=Mat) ...
Definition: mat.hpp:682
static Range all()
Definition: operations.hpp:2219
const CvArr * src1
Definition: core_c.h:436
Mat c
Definition: mat.hpp:1255
void convertTo(OutputArray m, int rtype, double alpha=1, double beta=0) const
converts matrix to another datatype with optional scalng. See cvConvertScale.
SparseMatConstIterator_()
the default constructor
Definition: mat.hpp:2527
CvSize size
Definition: calib3d.hpp:212
void addref()
increases the reference counter; use with care to avoid memleaks
Definition: mat.hpp:361
The 2D range class.
Definition: core.hpp:979
uchar * ptr(int i0, bool createMissing, size_t *hashval=0)
specialized variants for 1D, 2D, 3D cases and the generic_type one for n-D case.
static MatExpr eye(int rows, int cols, int type)
GLsizei GLsizei GLuint * obj
GLuint src
Definition: core_c.h:1650
CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, double scale=1, int dtype=-1)
computes element-wise weighted quotient of the two arrays (dst = scale*src1/src2) ...
int int int flags
Definition: highgui_c.h:186
~SparseMat()
the destructor
Definition: mat.hpp:2100
MatConstIterator()
default constructor
Definition: mat.hpp:1709
CV_EXPORTS_W void bitwise_or(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray())
computes bitwise disjunction of the two arrays (dst = src1 | src2)
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: core_c.h:403
Definition: types_c.h:858
int d
Definition: legacy.hpp:3064
CV_EXPORTS MatExpr operator>(const Mat &a, const Mat &b)
_Tp x
Definition: core.hpp:766
MatConstIterator & operator--()
decrements the iterator
Definition: mat.hpp:1779
_Tp & ref(int i0, size_t *hashval=0)
return read-write reference to the specified sparse matrix element.
Definition: mat.hpp:2213
iterator end()
Definition: mat.hpp:2049
Hdr * hdr
Definition: core.hpp:3625
virtual void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const
int depth() const
returns the depth of sparse matrix elements
Definition: mat.hpp:2156
int * refcount
pointer to the reference counter;
Definition: core.hpp:1968
void copySize(const Mat &m)
internal use function; properly re-allocates _size, _step arrays
CV_EXPORTS MatExpr operator-(const Mat &a, const Mat &b)
int depth() const
returns element type, similar to CV_MAT_DEPTH(cvmat->type)
Definition: mat.hpp:400
size_t elemSize() const
returns element size in bytes,
Definition: mat.hpp:397
internal::ParamGenerator< T > Range(T start, T end, IncrementT step)
Definition: ts_gtest.h:15869
uchar * sliceStart
Definition: core.hpp:2979
static void backSubst(InputArray w, InputArray u, InputArray vt, InputArray rhs, OutputArray dst)
performs back substitution
size_t elemSize() const
overridden forms of Mat::elemSize() etc.
Definition: mat.hpp:939
int dims() const
returns the matrix dimensionality
Definition: mat.hpp:2177
int flags
Definition: mat.hpp:1253
void process(const Mat_< T1 > &m1, Mat_< T2 > &m2, Op op)
Definition: mat.hpp:1084
void int step
Definition: core_c.h:403
const CvArr CvArr int method
Definition: imgproc_c.h:281
SparseMat::Node * node() const
returns pointer to the current sparse matrix node. it.node->idx is the index of the current element (...
Definition: mat.hpp:2373
double beta
Definition: mat.hpp:1256
uchar * datastart
helper fields used in locateROI and adjustROI
Definition: core.hpp:1971
CV_EXPORTS MatExpr operator^(const Mat &a, const Mat &b)
virtual void assign(const MatExpr &expr, Mat &m, int type=-1) const =0
SparseMat_ & operator=(const SparseMat &m)
the assignment operator. If DataType<_Tp>.type != m.type(), the m elements are converted ...
Definition: mat.hpp:2441
void assignTo(SparseMat &m, int type=-1) const
Definition: mat.hpp:2129
The 2D size class.
Definition: core.hpp:81
_Tp operator*() const
returns the current matrix element
Definition: mat.hpp:1837
Mat_ col(int x) const
Definition: mat.hpp:932
typedef void(CV_CDECL *CvMouseCallback)(int event
int cols
Definition: core.hpp:1962
Mat colRange(int startcol, int endcol) const
... for the specified column span
Definition: mat.hpp:315
int type() const
returns element type, similar to CV_MAT_TYPE(cvmat->type)
Definition: mat.hpp:399
void push_back_(const void *elem)
internal function
size_t elemSize
Definition: core.hpp:2977
static MatExpr zeros(int rows, int cols, int type)
Matlab-style matrix initialization.
int step
Definition: types_c.h:648
size_t nzcount() const
returns the number of non-zero elements (=the number of hash table nodes)
Definition: mat.hpp:2182
uchar * ptr
Definition: core.hpp:2978
Mat & adjustROI(int dtop, int dbottom, int dleft, int dright)
moves/resizes the current matrix ROI inside the parent matrix.
int channels() const
returns the number of channels
Definition: mat.hpp:2159
GLenum GLenum GLvoid * row
SparseMat & operator=(const SparseMat &m)
assignment operator. This is O(1) operation, i.e. no data is copied
Definition: mat.hpp:2105
size_t buf[2]
Definition: core.hpp:2001
~Mat()
destructor - calls release()
Definition: mat.hpp:274
size_t elemSize() const
returns the size of each element in bytes (not including the overhead - the space occupied by SparseM...
Definition: mat.hpp:2147
Scalar s
Definition: mat.hpp:1257
void seekEnd()
moves iterator to the element after the last element
Definition: mat.hpp:2343
uchar * sliceEnd
Definition: core.hpp:2980
int refcount
Definition: core.hpp:3387
Mat()
default constructor
Definition: mat.hpp:67
int type
Definition: types_c.h:647
Definition: core.hpp:2499
SVD()
the default constructor
Definition: mat.hpp:758
MatIterator_< _Tp > begin()
template methods for iteration over matrix elements.
Definition: mat.hpp:637
template 3D point class.
Definition: core.hpp:777
SparseMatIterator()
the default constructor
Definition: mat.hpp:2352
const _Tp * find(int i0, size_t *hashval=0) const
Return pointer to the specified sparse matrix element if it exists.
Definition: mat.hpp:2249
int dims
Definition: core.hpp:3388
CV_EXPORTS void split(const Mat &src, Mat *mvbegin)
copies each plane of a multi-channel array to a dedicated array
SparseMatConstIterator_ & operator=(const SparseMatConstIterator_ &it)
the assignment operator
Definition: mat.hpp:2548
CV_EXPORTS MatExpr operator==(const Mat &a, const Mat &b)
GLenum GLsizei GLsizei height
GLclampf GLclampf GLclampf alpha
Definition: core_c.h:687
int flags
includes several bit-fields:
Definition: core.hpp:1958
size_t step1(int i=0) const
returns step/elemSize1()
Definition: mat.hpp:402
void copyTo(SparseMat &m) const
copies all the data to the destination matrix. All the previous content of m is erased ...
MatConstIterator_ & operator+=(ptrdiff_t ofs)
shifts the iterator forward by the specified number of elements
Definition: mat.hpp:1839
_Tp & operator*() const
returns the current matrix element
Definition: mat.hpp:1897
CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst)
computes per-element minimum of two arrays (dst = min(src1, src2))
SparseMat_ clone() const
makes full copy of the matrix. All the elements are duplicated
Definition: mat.hpp:2454
sparse matrix node - element of a hash table
Definition: core.hpp:3399
SparseMatIterator_< _Tp > end()
returns sparse matrix iterator pointing to the element following the last sparse matrix element ...
Definition: mat.hpp:2520
Definition: core.hpp:1950
Sparse matrix class.
Definition: core.hpp:3376
void convertTo(SparseMat &m, int rtype, double alpha=1) const
multiplies all the matrix elements by the specified scale factor alpha and converts the results to th...
MatExpr(const MatOp *_op, int _flags, const Mat &_a=Mat(), const Mat &_b=Mat(), const Mat &_c=Mat(), double _alpha=1, double _beta=1, const Scalar &_s=Scalar())
Definition: mat.hpp:1217
Definition: core.hpp:1991
void release()
Definition: mat.hpp:2140
GLenum GLint x
Definition: core_c.h:632
CV_EXPORTS_W void transpose(InputArray src, OutputArray dst)
transposes the matrix
void CvArr
Definition: types_c.h:196
void mul(const float *array, float scalar, float *result, size_t length)
CV_EXPORTS MatExpr abs(const Mat &m)
Comma-separated Matrix Initializer.
Definition: core.hpp:118
const Mat * m
Definition: core.hpp:2976
MatIterator_ & operator-=(ptrdiff_t ofs)
shifts the iterator backward by the specified number of elements
Definition: mat.hpp:1905
Informative template class for OpenCV "scalars".
Definition: core.hpp:1006
MatConstIterator_ & operator++()
increments the iterator
Definition: mat.hpp:1861
size_t step1(int i=0) const
Definition: mat.hpp:966
Mat_ row(int y) const
overridden forms of Mat::row() etc.
Definition: mat.hpp:930
Mat rowRange(int startrow, int endrow) const
... for the specified row span
Definition: mat.hpp:311
int type() const
returns type of the matrix elements
Definition: mat.hpp:2473
uchar * ptr
Definition: core.hpp:3680
static MatExpr eye(int rows, int cols)
Definition: mat.hpp:1697
_Tp value(int i0, size_t *hashval=0) const
return value of the specified sparse matrix element.
Definition: mat.hpp:2225
CV_EXPORTS MatExpr operator<(const Mat &a, const Mat &b)
MatOp()
Definition: mat.hpp:1174
_Tp x
Definition: core.hpp:805
SparseMatIterator_ & operator++()
moves the iterator to the next element
Definition: mat.hpp:2602
const SparseMat * m
Definition: core.hpp:3678
Template Read-Only Sparse Matrix Iterator Class.
Definition: core.hpp:3289
Definition: types_c.h:645
const int * size() const
returns the array of sizes, or NULL if the matrix is not allocated
Definition: mat.hpp:2162
Mat_ cross(const Mat_ &m) const
cross-product
Definition: mat.hpp:924
double const CvArr double beta
Definition: core_c.h:523
Mat & operator=(const Mat &m)
assignment operators
Definition: mat.hpp:281
MatIterator_ & operator+=(ptrdiff_t ofs)
shifts the iterator forward by the specified number of elements
Definition: mat.hpp:1899
MatConstIterator_ & operator=(const MatConstIterator_ &it)
copy operator
Definition: mat.hpp:1831
SparseMatIterator & operator++()
moves iterator to the next element
Definition: mat.hpp:2378
GLboolean GLboolean GLboolean b
Definition: legacy.hpp:633
static MatExpr ones(int rows, int cols)
Definition: mat.hpp:1687
The n-dimensional matrix class.
Definition: core.hpp:1688
static MatExpr zeros(int rows, int cols)
overridden forms of Mat::zeros() etc. Data type is omitted, of course
Definition: mat.hpp:1677
Singular Value Decomposition class.
Definition: core.hpp:2496
MatCommaInitializer_(Mat_< _Tp > *_m)
the constructor, created by "matrix << firstValue" operator, where matrix is cv::Mat ...
Definition: mat.hpp:2052
int rows
Definition: core_c.h:114
static void compute(InputArray src, OutputArray w, OutputArray u, OutputArray vt, int flags=0)
decomposes matrix and stores the results to user-provided matrices
Template matrix class derived from Mat.
Definition: core.hpp:115
Definition: core.hpp:2927
CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1)
subtracts one matrix from another (dst = src1 - src2)
CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha, InputArray src3, double gamma, OutputArray dst, int flags=0)
implements generalized matrix product algorithm GEMM from BLAS
int int y
Definition: highgui_c.h:186
Size operator()() const
Definition: mat.hpp:707
SparseMatIterator_ & operator=(const SparseMatIterator_ &it)
the assignment operator
Definition: mat.hpp:2592
GLsizei const GLfloat * value
Definition: core_c.h:341
void release()
decreases reference counter;
Definition: mat.hpp:364
const MatOp * op
Definition: mat.hpp:1252
int type() const
returns type of sparse matrix elements
Definition: mat.hpp:2153
size_t elemSize1() const
returns elemSize()/channels()
Definition: mat.hpp:2150
MatCommaInitializer_< _Tp > & operator,(T2 v)
the operator that takes the next value and put it to the matrix
Definition: mat.hpp:2055
CV_EXPORTS_W void bitwise_xor(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray())
computes bitwise exclusive-or of the two arrays (dst = src1 ^ src2)
int cols
Definition: core_c.h:109
Node * node(size_t nidx)
Definition: mat.hpp:2267
_Tp val[m *n]
Definition: core.hpp:544
The Template Sparse Matrix class derived from cv::SparseMat.
Definition: core.hpp:3727
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
SparseMat clone() const
creates full copy of the matrix
Definition: mat.hpp:2121
Mat row(int y) const
returns a new matrix header for the specified row
Definition: mat.hpp:309
virtual ~MatOp()
Definition: mat.hpp:1175
const GLubyte * c
Definition: legacy.hpp:633
int int type
Definition: core_c.h:109
const SparseMat::Node * node() const
returns the current node of the sparse matrix. it.node->idx is the current element index ...
Definition: mat.hpp:2329
int int int int int int h
CV_EXPORTS MatExpr operator|(const Mat &a, const Mat &b)
float ** ranges
Definition: imgproc_c.h:435
size_t hashidx
Definition: core.hpp:3679
int int channels
Definition: core_c.h:73
int size[CV_MAX_DIM]
Definition: core.hpp:3395
SparseMatConstIterator & operator++()
moves iterator to the next element
template 2D point class.
Definition: core.hpp:82
_Tp & operator[](ptrdiff_t i) const
returns the i-th matrix element, relative to the current
Definition: mat.hpp:2037
CvPoint2D32f CvPoint2D32f CvPoint2D32f CvPoint2D32f * cross
Definition: legacy.hpp:577
SparseMatIterator_< _Tp > begin()
returns sparse matrix iterator pointing to the first sparse matrix element
Definition: mat.hpp:2514
SparseMatConstIterator()
the default constructor
Definition: mat.hpp:2298
_Tp width
Definition: core.hpp:840
MSize(int *_p)
Definition: mat.hpp:706
_Tp & value() const
returns read-write reference to the current sparse matrix element
Definition: mat.hpp:2370
size_t elemSize1() const
Definition: mat.hpp:945
Read-Only Sparse Matrix Iterator.
Definition: core.hpp:3648
CV_EXPORTS MatExpr operator<=(const Mat &a, const Mat &b)
const char * ptr
Definition: core_c.h:942
CV_EXPORTS MatExpr operator/(const Mat &a, const Mat &b)
GLboolean GLboolean GLboolean GLboolean a
Definition: legacy.hpp:633
CV_EXPORTS void fastFree(void *ptr)
Frees the memory allocated with cv::fastMalloc.
class CV_EXPORTS MatExpr
Definition: core.hpp:110
MatConstIterator & operator+=(ptrdiff_t ofs)
shifts the iterator forward by the specified number of elements
Definition: mat.hpp:1762
Definition: core.hpp:3622
size_t stepT(int i=0) const
returns step()/sizeof(_Tp)
Definition: mat.hpp:965
void deallocate()
deallocates the matrix data
Mat_ & operator=(const Mat &m)
Definition: mat.hpp:879
const size_t & operator[](int i) const
Definition: mat.hpp:737
bool operator!=(const MSize &sz) const
Definition: mat.hpp:730
MatConstIterator_ & operator--()
decrements the iterator
Definition: mat.hpp:1848
Mat_()
default constructor
Definition: mat.hpp:800
void create(int rows, int cols, int type)
allocates new matrix data unless the matrix already has specified size and type.
Definition: mat.hpp:347
const _Tp & value() const
template method returning the current matrix element
Definition: mat.hpp:2326
CvArr * arr
Definition: core_c.h:649
_Tp y
Definition: core.hpp:766
unsigned char uchar
Definition: types_c.h:170
CV_EXPORTS MatExpr operator+(const Mat &a, const Mat &b)
Mat_< _Tp > operator*() const
another form of conversion operator
Definition: mat.hpp:2062
GLuint dst
Definition: calib3d.hpp:134
Definition: core.hpp:1950
int flags
Definition: core.hpp:3624
iterator begin()
iterators; they are smart enough to skip gaps in the end of rows
Definition: mat.hpp:2046
void addref()
manually increments the reference counter to the header.
Definition: mat.hpp:2137
Mat operator()(Range rowRange, Range colRange) const
extracts a rectangular sub-matrix
Definition: mat.hpp:373
::max::max int
Definition: functional.hpp:324
uchar * operator[](ptrdiff_t i) const
returns the i-th matrix element, relative to the current
Definition: mat.hpp:2019
GLubyte GLubyte GLubyte GLubyte w
Mat diag(int d=0) const
... for the specified diagonal
CvPoint2D32f float a
Definition: legacy.hpp:578
size_t nodeCount
Definition: core.hpp:3391
int x
Definition: highgui_c.h:186
uchar * operator*() const
returns the current matrix element
Definition: mat.hpp:1760
CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, InputArray mask=noArray(), int dtype=-1)
adds one matrix to another (dst = src1 + src2)
SparseMatConstIterator & operator=(const SparseMatConstIterator &it)
the assignment operator
Definition: mat.hpp:2315
MatConstIterator & operator=(const MatConstIterator &it)
copy operator
Definition: mat.hpp:1753
int valueOffset
Definition: core.hpp:3389
size_t * p
Definition: core.hpp:2000
_Tp height
Definition: core.hpp:840
CvArr CvArr * temp
Definition: imgproc_c.h:242
MSize size
Definition: core.hpp:2006
Template Read-Write Sparse Matrix Iterator Class.
Definition: core.hpp:3288
GLenum GLenum GLenum GLenum GLenum scale
_Tp & ref(int i0, size_t *hashval=0)
equivalent to SparseMat::ref<_Tp>(i0, hashval)
Definition: mat.hpp:2483
Mat cross(InputArray m) const
computes cross-product of 2 3D vectors
Point pos() const
returns the current iterator position
Definition: mat.hpp:1937
size_t hash(int i0) const
computes the element hash value (1D case)
Definition: mat.hpp:2187
Definition: core.hpp:1458
const CvMat CvSize double alpha
Definition: calib3d.hpp:126
const CvArr const CvArr * src2
Definition: core_c.h:436
Definition: core.hpp:1978
void seek(ptrdiff_t ofs, bool relative=false)
CV_EXPORTS MatExpr operator>=(const Mat &a, const Mat &b)
value_type vec_type
Definition: core.hpp:1012
Mat_ operator()(const Range &rowRange, const Range &colRange) const
Definition: mat.hpp:971
Mat col(int x) const
returns a new matrix header for the specified column
Definition: mat.hpp:310
CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, OutputArray dst, double scale=1, int dtype=-1)
computes element-wise weighted product of the two arrays (dst = scale*src1*src2)
DataType< _Tp >::work_type dot(const Vector< _Tp > &v1, const Vector< _Tp > &v2)
Definition: operations.hpp:2465
bool isContinuous() const
returns true iff the matrix data is continuous
Definition: mat.hpp:395
SparseMatIterator & operator=(const SparseMatIterator &it)
the assignment operator
Definition: mat.hpp:2364
CV_EXPORTS MatExpr operator&(const Mat &a, const Mat &b)
Mat vt
Definition: core.hpp:2529
_Tp operator()(int i0, size_t *hashval=0) const
equivalent to SparseMat::value<_Tp>(i0, hashval)
Definition: mat.hpp:2487
MatConstIterator_()
default constructor
Definition: mat.hpp:1813
int dims
the matrix dimensionality, >= 2
Definition: core.hpp:1960
Matrix read-only iterator.
Definition: core.hpp:117
_Tp * operator[](int y)
more convenient forms of row and element access operators
Definition: mat.hpp:980
size_t total() const
returns the total number of matrix elements
Definition: mat.hpp:404
void assignTo(Mat &m, int type=-1) const
Definition: mat.hpp:339
CV_INLINE CvMat cvMat(int rows, int cols, int type, void *data CV_DEFAULT(NULL))
Definition: types_c.h:733
GLsizeiptr size
Definition: core_c.h:939
MStep & operator=(size_t s)
Definition: mat.hpp:744
CV_EXPORTS Mat cvarrToMat(const CvArr *arr, bool copyData=false, bool allowND=true, int coiMode=0)
converts array (CvMat or IplImage) to cv::Mat
Scalar_< double > Scalar
Definition: core.hpp:968
_Tp & at(int i0=0)
the same as above, with the pointer dereferencing
Definition: mat.hpp:565
Proxy datatype for passing Mat's and vector<>'s as input parameters.
Definition: core.hpp:1400
MStep step
Definition: core.hpp:2007
const int & operator[](int i) const
Definition: mat.hpp:712
vector< uchar > pool
Definition: core.hpp:3393
void initEmpty()
Definition: mat.hpp:58
void create(int dims, const int *_sizes, int _type)
reallocates sparse matrix.
MatIterator_ & operator++()
increments the iterator
Definition: mat.hpp:1924
Definition: core.hpp:1950
CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst)
computes per-element maximum of two arrays (dst = max(src1, src2))
uchar * dataend
Definition: core.hpp:1972
MatIterator_()
the default constructor
Definition: mat.hpp:1874