43 #ifndef __OPENCV_CORE_OPERATIONS_HPP__
44 #define __OPENCV_CORE_OPERATIONS_HPP__
49 #endif // SKIP_INCLUDES
55 #if defined __INTEL_COMPILER && !(defined WIN32 || defined _WIN32) // atomic increment on the linux version of the Intel(tm) compiler
56 #define CV_XADD(addr,delta) _InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(addr)), delta)
57 #elif defined __GNUC__
59 #if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__
60 #ifdef __ATOMIC_SEQ_CST
61 #define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), (delta), __ATOMIC_SEQ_CST)
63 #define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), (delta), 5)
65 #elif __GNUC__*10 + __GNUC_MINOR__ >= 42
67 #if !(defined WIN32 || defined _WIN32) && (defined __i486__ || defined __i586__ || \
68 defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__) || \
69 (defined __GNUC__ && defined _STLPORT_MAJOR) || \
70 defined __EMSCRIPTEN__
72 #define CV_XADD __sync_fetch_and_add
74 #include <ext/atomicity.h>
75 #define CV_XADD __gnu_cxx::__exchange_and_add
79 #include <bits/atomicity.h>
80 #if __GNUC__*10 + __GNUC_MINOR__ >= 34
81 #define CV_XADD __gnu_cxx::__exchange_and_add
83 #define CV_XADD __exchange_and_add
87 #elif defined WIN32 || defined _WIN32 || defined WINCE
89 #define CV_XADD cv::_interlockedExchangeAdd
92 static inline int CV_XADD(
int*
addr,
int delta)
93 {
int tmp = *addr; *addr +=
delta;
return tmp; }
99 # pragma warning(push)
100 # pragma warning(disable:4127) //conditional expression is constant
118 template<
typename _Tp>
static inline _Tp saturate_cast(
uchar v) {
return _Tp(v); }
119 template<
typename _Tp>
static inline _Tp saturate_cast(
schar v) {
return _Tp(v); }
120 template<
typename _Tp>
static inline _Tp saturate_cast(
ushort v) {
return _Tp(v); }
121 template<
typename _Tp>
static inline _Tp saturate_cast(
short v) {
return _Tp(v); }
122 template<
typename _Tp>
static inline _Tp saturate_cast(
unsigned v) {
return _Tp(v); }
123 template<
typename _Tp>
static inline _Tp saturate_cast(
int v) {
return _Tp(v); }
124 template<
typename _Tp>
static inline _Tp saturate_cast(
float v) {
return _Tp(v); }
125 template<
typename _Tp>
static inline _Tp saturate_cast(
double v) {
return _Tp(v); }
128 {
return (
uchar)std::max((
int)
v, 0); }
148 return (
schar)((unsigned)(
v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ?
149 v :
v > 0 ? SCHAR_MAX : SCHAR_MIN);
162 {
return (
ushort)std::max((
int)
v, 0); }
164 {
return (
ushort)std::max((
int)
v, 0); }
166 {
return (
ushort)((unsigned)
v <= (
unsigned)USHRT_MAX ?
v :
v > 0 ? USHRT_MAX : 0); }
174 template<>
inline short saturate_cast<
short>(
ushort v)
175 {
return (
short)
std::min((
int)
v, SHRT_MAX); }
176 template<>
inline short saturate_cast<
short>(
int v)
178 return (
short)((unsigned)(
v - SHRT_MIN) <= (unsigned)USHRT_MAX ?
179 v :
v > 0 ? SHRT_MAX : SHRT_MIN);
181 template<>
inline short saturate_cast<
short>(
unsigned v)
182 {
return (
short)
std::min(
v, (
unsigned)SHRT_MAX); }
183 template<>
inline short saturate_cast<
short>(
float v)
184 {
int iv =
cvRound(
v);
return saturate_cast<
short>(iv); }
185 template<>
inline short saturate_cast<
short>(
double v)
186 {
int iv =
cvRound(
v);
return saturate_cast<
short>(iv); }
188 template<>
inline int saturate_cast<
int>(
float v) {
return cvRound(
v); }
189 template<>
inline int saturate_cast<
int>(
double v) {
return cvRound(
v); }
192 template<>
inline unsigned saturate_cast<
unsigned>(
float v){
return cvRound(
v); }
193 template<>
inline unsigned saturate_cast<
unsigned>(
double v) {
return cvRound(
v); }
198 inline int fast_abs(
short v) {
return std::abs((
int)v); }
201 inline double fast_abs(
double v) {
return std::abs(v); }
255 _Tp v4, _Tp v5, _Tp v6)
264 _Tp v4, _Tp v5, _Tp v6, _Tp v7)
273 _Tp v4, _Tp v5, _Tp v6, _Tp v7,
284 _Tp v4, _Tp v5, _Tp v6, _Tp v7,
291 for(
int i = 10; i <
channels; i++)
val[i] = _Tp(0);
295 template<
typename _Tp,
int m,
int n>
297 _Tp v4, _Tp v5, _Tp v6, _Tp v7,
298 _Tp v8, _Tp v9, _Tp v10, _Tp v11)
306 template<
typename _Tp,
int m,
int n>
308 _Tp v4, _Tp v5, _Tp v6, _Tp v7,
309 _Tp v8, _Tp v9, _Tp v10, _Tp v11,
310 _Tp v12, _Tp v13, _Tp v14, _Tp v15)
316 val[12] = v12;
val[13] = v13;
val[14] = v14;
val[15] = v15;
321 for(
int i = 0; i <
channels; i++ )
val[i] = values[i];
327 for(
int i = 0; i <
m*
n; i++ ) M.
val[i] = alpha;
331 template<
typename _Tp,
int m,
int n>
inline
337 template<
typename _Tp,
int m,
int n>
inline
343 template<
typename _Tp,
int m,
int n>
inline
347 for(
int i = 0; i < MIN(
m,
n); i++)
355 for(
int i = 0; i <
m*
n; i++ ) s +=
val[i]*M.
val[i];
363 for(
int i = 0; i <
m*
n; i++ ) s += (
double)
val[i]*M.
val[i];
369 template<
typename _Tp,
int m,
int n>
inline
373 for(
int i = 0; i < MIN(
m,
n); i++)
378 template<
typename _Tp,
int m,
int n>
inline
387 template<
typename _Tp,
int m,
int n>
inline
396 template<
typename _Tp,
int m,
int n>
template<
typename T2>
400 for(
int i = 0; i <
m*
n; i++ ) M.
val[i] = saturate_cast<T2>(
val[i]);
405 template<
typename _Tp,
int m,
int n>
template<
int m1,
int n1>
inline
408 CV_DbgAssert(m1*n1 ==
m*
n);
413 template<
typename _Tp,
int m,
int n>
414 template<
int m1,
int n1>
inline
417 CV_DbgAssert(0 <= i && i+m1 <=
m && 0 <= j && j+n1 <=
n);
419 for(
int di = 0; di < m1; di++ )
420 for(
int dj = 0; dj < n1; dj++ )
421 s(di, dj) = (*this)(i+di, j+dj);
426 template<
typename _Tp,
int m,
int n>
inline
429 CV_DbgAssert((
unsigned)i < (
unsigned)
m);
434 template<
typename _Tp,
int m,
int n>
inline
437 CV_DbgAssert((
unsigned)j < (
unsigned)
n);
439 for(
int i = 0; i <
m; i++ )
445 template<
typename _Tp,
int m,
int n>
inline
449 for(
int i = 0; i < MIN(
m,
n); i++ )
455 template<
typename _Tp,
int m,
int n>
inline
458 CV_DbgAssert( (
unsigned)i < (
unsigned)
m && (
unsigned)j < (
unsigned)
n );
459 return this->
val[i*n + j];
463 template<
typename _Tp,
int m,
int n>
inline
466 CV_DbgAssert( (
unsigned)i < (
unsigned)
m && (
unsigned)j < (
unsigned)
n );
471 template<
typename _Tp,
int m,
int n>
inline
474 CV_DbgAssert( (
m == 1 ||
n == 1) && (
unsigned)i < (
unsigned)(
m+
n-1) );
479 template<
typename _Tp,
int m,
int n>
inline
482 CV_DbgAssert( (
m == 1 ||
n == 1) && (
unsigned)i < (
unsigned)(
m+
n-1) );
487 template<
typename _Tp1,
typename _Tp2,
int m,
int n>
static inline
490 for(
int i = 0; i <
m*
n; i++ )
491 a.
val[i] = saturate_cast<_Tp1>(a.
val[i] + b.
val[i]);
496 template<
typename _Tp1,
typename _Tp2,
int m,
int n>
static inline
497 Matx<_Tp1, m, n>& operator -= (Matx<_Tp1, m, n>& a,
const Matx<_Tp2, m, n>& b)
499 for(
int i = 0; i <
m*
n; i++ )
500 a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]);
505 template<
typename _Tp,
int m,
int n>
inline
508 for(
int i = 0; i <
m*
n; i++ )
509 val[i] = saturate_cast<_Tp>(a.
val[i] + b.
val[i]);
513 template<
typename _Tp,
int m,
int n>
inline
516 for(
int i = 0; i <
m*
n; i++ )
517 val[i] = saturate_cast<_Tp>(a.
val[i] - b.
val[i]);
521 template<
typename _Tp,
int m,
int n>
template<
typename _T2>
inline
524 for(
int i = 0; i <
m*
n; i++ )
525 val[i] = saturate_cast<_Tp>(a.
val[i] * alpha);
529 template<
typename _Tp,
int m,
int n>
inline
532 for(
int i = 0; i <
m*
n; i++ )
533 val[i] = saturate_cast<_Tp>(a.
val[i] * b.
val[i]);
537 template<
typename _Tp,
int m,
int n>
template<
int l>
inline
540 for(
int i = 0; i <
m; i++ )
541 for(
int j = 0; j <
n; j++ )
544 for(
int k = 0;
k < l;
k++ )
545 s +=
a(i,
k) *
b(
k, j);
551 template<
typename _Tp,
int m,
int n>
inline
554 for(
int i = 0; i <
m; i++ )
555 for(
int j = 0; j <
n; j++ )
556 val[i*n + j] =
a(j, i);
560 template<
typename _Tp,
int m,
int n>
static inline
567 template<
typename _Tp,
int m,
int n>
static inline
568 Matx<_Tp, m, n>
operator - (
const Matx<_Tp, m, n>& a,
const Matx<_Tp, m, n>& b)
570 return Matx<_Tp, m, n>(
a,
b, Matx_SubOp());
574 template<
typename _Tp,
int m,
int n>
static inline
575 Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a,
int alpha)
577 for(
int i = 0; i <
m*
n; i++ )
578 a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
582 template<
typename _Tp,
int m,
int n>
static inline
583 Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a,
float alpha)
585 for(
int i = 0; i <
m*
n; i++ )
586 a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
590 template<
typename _Tp,
int m,
int n>
static inline
591 Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a,
double alpha)
593 for(
int i = 0; i <
m*
n; i++ )
594 a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha);
598 template<
typename _Tp,
int m,
int n>
static inline
599 Matx<_Tp, m, n> operator * (
const Matx<_Tp, m, n>& a,
int alpha)
601 return Matx<_Tp, m, n>(
a,
alpha, Matx_ScaleOp());
604 template<
typename _Tp,
int m,
int n>
static inline
605 Matx<_Tp, m, n> operator * (
const Matx<_Tp, m, n>& a,
float alpha)
607 return Matx<_Tp, m, n>(
a,
alpha, Matx_ScaleOp());
610 template<
typename _Tp,
int m,
int n>
static inline
611 Matx<_Tp, m, n> operator * (
const Matx<_Tp, m, n>& a,
double alpha)
613 return Matx<_Tp, m, n>(
a,
alpha, Matx_ScaleOp());
616 template<
typename _Tp,
int m,
int n>
static inline
617 Matx<_Tp, m, n> operator * (
int alpha,
const Matx<_Tp, m, n>& a)
619 return Matx<_Tp, m, n>(
a,
alpha, Matx_ScaleOp());
622 template<
typename _Tp,
int m,
int n>
static inline
623 Matx<_Tp, m, n> operator * (
float alpha,
const Matx<_Tp, m, n>& a)
625 return Matx<_Tp, m, n>(
a,
alpha, Matx_ScaleOp());
628 template<
typename _Tp,
int m,
int n>
static inline
629 Matx<_Tp, m, n> operator * (
double alpha,
const Matx<_Tp, m, n>& a)
631 return Matx<_Tp, m, n>(
a,
alpha, Matx_ScaleOp());
634 template<
typename _Tp,
int m,
int n>
static inline
635 Matx<_Tp, m, n>
operator - (
const Matx<_Tp, m, n>& a)
637 return Matx<_Tp, m, n>(
a, -1, Matx_ScaleOp());
641 template<
typename _Tp,
int m,
int n,
int l>
static inline
642 Matx<_Tp, m, n> operator * (
const Matx<_Tp, m, l>& a,
const Matx<_Tp, l, n>& b)
644 return Matx<_Tp, m, n>(
a,
b, Matx_MatMulOp());
648 template<
typename _Tp,
int m,
int n>
static inline
649 Vec<_Tp, m> operator * (
const Matx<_Tp, m, n>& a,
const Vec<_Tp, n>& b)
651 Matx<_Tp, m, 1>
c(a, b, Matx_MatMulOp());
652 return reinterpret_cast<const Vec<_Tp, m>&
>(
c);
656 template<
typename _Tp>
static inline
657 Point_<_Tp> operator * (
const Matx<_Tp, 2, 2>& a,
const Point_<_Tp>& b)
659 Matx<_Tp, 2, 1> tmp = a*Vec<_Tp,2>(b.x, b.y);
660 return Point_<_Tp>(tmp.val[0], tmp.val[1]);
664 template<
typename _Tp>
static inline
665 Point3_<_Tp> operator * (
const Matx<_Tp, 3, 3>& a,
const Point3_<_Tp>& b)
667 Matx<_Tp, 3, 1> tmp = a*Vec<_Tp,3>(b.x, b.y, b.z);
668 return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]);
672 template<
typename _Tp>
static inline
673 Point3_<_Tp> operator * (
const Matx<_Tp, 3, 3>& a,
const Point_<_Tp>& b)
675 Matx<_Tp, 3, 1> tmp = a*Vec<_Tp,3>(b.x, b.y, 1);
676 return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]);
680 template<
typename _Tp>
static inline
681 Matx<_Tp, 4, 1> operator * (
const Matx<_Tp, 4, 4>& a,
const Point3_<_Tp>& b)
683 return a*Matx<_Tp, 4, 1>(b.x, b.y, b.z, 1);
687 template<
typename _Tp>
static inline
688 Scalar operator * (
const Matx<_Tp, 4, 4>& a,
const Scalar& b)
690 Matx<double, 4, 1>
c(Matx<double, 4, 4>(a), b, Matx_MatMulOp());
691 return static_cast<const Scalar&
>(
c);
696 Scalar operator * (
const Matx<double, 4, 4>& a,
const Scalar& b)
698 Matx<double, 4, 1>
c(a, b, Matx_MatMulOp());
699 return static_cast<const Scalar&
>(
c);
703 template<
typename _Tp,
int m,
int n>
inline
710 CV_EXPORTS
int LU(
float* A,
size_t astep,
int m,
float* b,
size_t bstep,
int n);
711 CV_EXPORTS
int LU(
double* A,
size_t astep,
int m,
double* b,
size_t bstep,
int n);
712 CV_EXPORTS
bool Cholesky(
float* A,
size_t astep,
int m,
float* b,
size_t bstep,
int n);
713 CV_EXPORTS
bool Cholesky(
double* A,
size_t astep,
int m,
double* b,
size_t bstep,
int n);
721 double p =
LU(temp.
val,
m*
sizeof(_Tp),
m, 0, 0, 0);
724 for(
int i = 0; i <
m; i++ )
744 return a(0,0)*
a(1,1) -
a(0,1)*
a(1,0);
753 return a(0,0)*(
a(1,1)*
a(2,2) -
a(2,1)*
a(1,2)) -
754 a(0,1)*(
a(1,0)*
a(2,2) -
a(2,0)*
a(1,2)) +
755 a(0,2)*(
a(1,0)*
a(2,1) -
a(2,0)*
a(1,1));
759 template<
typename _Tp,
int m>
static inline
762 return Matx_DetOp<_Tp, m>()(a);
766 template<
typename _Tp,
int m,
int n>
static inline
767 double trace(
const Matx<_Tp, m, n>& a)
776 template<
typename _Tp,
int m,
int n>
inline
790 for(
int i = 0; i <
m; i++ )
794 return Cholesky(temp.
val, m*
sizeof(_Tp), m, b.
val, m*
sizeof(_Tp), m);
796 return LU(temp.
val, m*
sizeof(_Tp), m, b.
val, m*
sizeof(_Tp), m) != 0;
826 b(0,0) = (
a(1,1) *
a(2,2) -
a(1,2) *
a(2,1)) * d;
827 b(0,1) = (
a(0,2) *
a(2,1) -
a(0,1) *
a(2,2)) * d;
828 b(0,2) = (
a(0,1) *
a(1,2) -
a(0,2) *
a(1,1)) * d;
830 b(1,0) = (
a(1,2) *
a(2,0) -
a(1,0) *
a(2,2)) * d;
831 b(1,1) = (
a(0,0) *
a(2,2) -
a(0,2) *
a(2,0)) * d;
832 b(1,2) = (
a(0,2) *
a(1,0) -
a(0,0) *
a(1,2)) * d;
834 b(2,0) = (
a(1,0) *
a(2,1) -
a(1,1) *
a(2,0)) * d;
835 b(2,1) = (
a(0,1) *
a(2,0) -
a(0,0) *
a(2,1)) * d;
836 b(2,2) = (
a(0,0) *
a(1,1) -
a(0,1) *
a(1,0)) * d;
842 template<
typename _Tp,
int m,
int n>
inline
851 Mat A(*
this,
false),
B(b,
false);
852 ok = (
invert(A, B, method) != 0);
868 return LU(temp.
val,
m*
sizeof(_Tp),
m, x.
val,
n*
sizeof(_Tp),
n) != 0;
882 x(0) = (
b(0)*
a(1,1) -
b(1)*
a(0,1))*d;
883 x(1) = (
b(1)*
a(0,0) -
b(0)*
a(1,0))*d;
898 x(0) = d*(
b(0)*(
a(1,1)*
a(2,2) -
a(1,2)*
a(2,1)) -
899 a(0,1)*(
b(1)*
a(2,2) -
a(1,2)*
b(2)) +
900 a(0,2)*(
b(1)*
a(2,1) -
a(1,1)*
b(2)));
902 x(1) = d*(
a(0,0)*(
b(1)*
a(2,2) -
a(1,2)*
b(2)) -
903 b(0)*(
a(1,0)*
a(2,2) -
a(1,2)*
a(2,0)) +
904 a(0,2)*(
a(1,0)*
b(2) -
b(1)*
a(2,0)));
906 x(2) = d*(
a(0,0)*(
a(1,1)*
b(2) -
b(1)*
a(2,1)) -
907 a(0,1)*(
a(1,0)*
b(2) -
b(1)*
a(2,0)) +
908 b(0)*(
a(1,0)*
a(2,1) -
a(1,1)*
a(2,0)));
914 template<
typename _Tp,
int m,
int n>
template<
int l>
inline
923 Mat A(*
this,
false),
B(rhs,
false),
X(x,
false);
930 template<
typename _Tp,
int m,
int n>
inline
937 template<
typename _Tp,
typename _AccTp>
static inline
938 _AccTp normL2Sqr(
const _Tp* a,
int n)
942 #if CV_ENABLE_UNROLLED
943 for( ; i <= n - 4; i += 4 )
945 _AccTp
v0 = a[i],
v1 = a[i+1],
v2 = a[i+2],
v3 = a[i+3];
946 s += v0*v0 + v1*v1 + v2*v2 + v3*v3;
958 template<
typename _Tp,
typename _AccTp>
static inline
959 _AccTp normL1(
const _Tp* a,
int n)
963 #if CV_ENABLE_UNROLLED
964 for(; i <= n - 4; i += 4 )
976 template<
typename _Tp,
typename _AccTp>
static inline
977 _AccTp normInf(
const _Tp* a,
int n)
980 for(
int i = 0; i <
n; i++ )
981 s = std::max(s, (_AccTp)
fast_abs(a[i]));
986 template<
typename _Tp,
typename _AccTp>
static inline
987 _AccTp normL2Sqr(
const _Tp* a,
const _Tp* b,
int n)
991 #if CV_ENABLE_UNROLLED
992 for(; i <= n - 4; i += 4 )
994 _AccTp
v0 = _AccTp(a[i] - b[i]),
v1 = _AccTp(a[i+1] - b[i+1]),
v2 = _AccTp(a[i+2] - b[i+2]),
v3 = _AccTp(a[i+3] - b[i+3]);
1000 _AccTp
v = _AccTp(a[i] - b[i]);
1006 CV_EXPORTS
float normL2Sqr_(
const float* a,
const float* b,
int n);
1007 CV_EXPORTS
float normL1_(
const float* a,
const float* b,
int n);
1012 template<>
inline float normL2Sqr(
const float* a,
const float* b,
int n)
1017 for(
int i = 0; i <
n; i++ )
1019 float v = a[i] - b[i];
1026 template<
typename _Tp,
typename _AccTp>
static inline
1027 _AccTp normL1(
const _Tp* a,
const _Tp* b,
int n)
1031 #if CV_ENABLE_UNROLLED
1032 for(; i <= n - 4; i += 4 )
1034 _AccTp
v0 = _AccTp(a[i] - b[i]),
v1 = _AccTp(a[i+1] - b[i+1]),
v2 = _AccTp(a[i+2] - b[i+2]),
v3 = _AccTp(a[i+3] - b[i+3]);
1035 s += std::abs(v0) + std::abs(
v1) + std::abs(
v2) + std::abs(
v3);
1040 _AccTp
v = _AccTp(a[i] - b[i]);
1046 template<>
inline float normL1(
const float* a,
const float* b,
int n)
1051 for(
int i = 0; i <
n; i++ )
1053 float v = a[i] - b[i];
1059 template<>
inline int normL1(
const uchar* a,
const uchar* b,
int n)
1064 template<
typename _Tp,
typename _AccTp>
static inline
1065 _AccTp normInf(
const _Tp* a,
const _Tp* b,
int n)
1068 for(
int i = 0; i <
n; i++ )
1070 _AccTp
v0 = a[i] - b[i];
1071 s = std::max(s, std::abs(v0));
1077 template<
typename _Tp,
int m,
int n>
static inline
1078 double norm(
const Matx<_Tp, m, n>& M)
1080 return std::sqrt(normL2Sqr<_Tp, double>(M.val,
m*n));
1084 template<
typename _Tp,
int m,
int n>
static inline
1085 double norm(
const Matx<_Tp, m, n>& M,
int normType)
1087 return normType ==
NORM_INF ? (
double)normInf<_Tp,
typename DataType<_Tp>::work_type>(M.val,
m*n) :
1088 normType ==
NORM_L1 ? (
double)normL1<_Tp, typename DataType<_Tp>::work_type>(M.
val,
m*n) :
1089 std::
sqrt((
double)normL2Sqr<_Tp, typename DataType<_Tp>::work_type>(M.
val,
m*n));
1093 template<
typename _Tp,
int m,
int n>
static inline
1094 bool operator == (
const Matx<_Tp, m, n>& a,
const Matx<_Tp, m, n>& b)
1096 for(
int i = 0; i <
m*
n; i++ )
1097 if( a.val[i] != b.val[i] )
return false;
1101 template<
typename _Tp,
int m,
int n>
static inline
1102 bool operator != (
const Matx<_Tp, m, n>& a,
const Matx<_Tp, m, n>& b)
1108 template<
typename _Tp,
typename _T2,
int m,
int n>
static inline
1109 MatxCommaInitializer<_Tp, m, n> operator << (const Matx<_Tp, m, n>& mtx, _T2
val)
1111 MatxCommaInitializer<_Tp, m, n> commaInitializer((Matx<_Tp, m, n>*)&mtx);
1112 return (commaInitializer,
val);
1115 template<
typename _Tp,
int m,
int n>
inline
1120 template<
typename _Tp,
int m,
int n>
template<
typename _T2>
inline
1123 CV_DbgAssert(
idx <
m*n );
1128 template<
typename _Tp,
int m,
int n>
inline
1131 CV_DbgAssert(
idx == n*
m );
1141 :
Matx<_Tp, cn, 1>(v0)
1145 :
Matx<_Tp, cn, 1>(v0, v1)
1149 :
Matx<_Tp, cn, 1>(v0, v1, v2)
1153 :
Matx<_Tp, cn, 1>(v0, v1, v2, v3)
1157 :
Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4)
1161 :
Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5)
1165 _Tp v4, _Tp v5, _Tp v6)
1166 :
Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6)
1170 _Tp v4, _Tp v5, _Tp v6, _Tp v7)
1171 :
Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7)
1175 _Tp v4, _Tp v5, _Tp v6, _Tp v7,
1177 :
Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8)
1181 _Tp v4, _Tp v5, _Tp v6, _Tp v7,
1183 :
Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9)
1187 :
Matx<_Tp, cn, 1>(values)
1195 template<
typename _Tp,
int cn>
inline
1197 :
Matx<_Tp, cn, 1>(a, b, op)
1200 template<
typename _Tp,
int cn>
inline
1202 :
Matx<_Tp, cn, 1>(a, b, op)
1205 template<
typename _Tp,
int cn>
template<
typename _T2>
inline
1207 :
Matx<_Tp, cn, 1>(a, alpha, op)
1213 for(
int i = 0; i < cn; i++ ) v.
val[i] = alpha;
1220 for(
int i = 0; i < cn; i++ ) w.
val[i] = saturate_cast<_Tp>(this->val[i]*v.
val[i]);
1256 CV_Error(
CV_StsError,
"for arbitrary-size vector there is no cross-product defined");
1260 template<
typename _Tp,
int cn>
template<
typename T2>
1264 for(
int i = 0; i < cn; i++ ) v.
val[i] = saturate_cast<T2>(this->val[i]);
1272 for( i = 0; i <
std::min(cn, 4); i++ ) s.
val[i] = this->val[i];
1273 for( ; i < 4; i++ ) s.
val[i] = 0;
1279 CV_DbgAssert( (
unsigned)i < (
unsigned)cn );
1280 return this->
val[i];
1285 CV_DbgAssert( (
unsigned)i < (
unsigned)cn );
1286 return this->
val[i];
1291 CV_DbgAssert( (
unsigned)i < (
unsigned)cn );
1292 return this->
val[i];
1297 CV_DbgAssert( (
unsigned)i < (
unsigned)cn );
1298 return this->
val[i];
1301 template<
typename _Tp1,
typename _Tp2,
int cn>
static inline Vec<_Tp1, cn>&
1304 for(
int i = 0; i < cn; i++ )
1305 a.
val[i] = saturate_cast<_Tp1>(a.
val[i] + b.
val[i]);
1309 template<
typename _Tp1,
typename _Tp2,
int cn>
static inline Vec<_Tp1, cn>&
1310 operator -= (Vec<_Tp1, cn>& a,
const Vec<_Tp2, cn>& b)
1312 for(
int i = 0; i < cn; i++ )
1313 a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]);
1317 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1318 operator + (
const Vec<_Tp, cn>& a,
const Vec<_Tp, cn>& b)
1320 return Vec<_Tp, cn>(
a,
b, Matx_AddOp());
1323 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1324 operator - (
const Vec<_Tp, cn>& a,
const Vec<_Tp, cn>& b)
1326 return Vec<_Tp, cn>(
a,
b, Matx_SubOp());
1329 template<
typename _Tp,
int cn>
static inline
1330 Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a,
int alpha)
1332 for(
int i = 0; i < cn; i++ )
1333 a[i] = saturate_cast<_Tp>(a[i]*alpha);
1337 template<
typename _Tp,
int cn>
static inline
1338 Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a,
float alpha)
1340 for(
int i = 0; i < cn; i++ )
1341 a[i] = saturate_cast<_Tp>(a[i]*alpha);
1345 template<
typename _Tp,
int cn>
static inline
1346 Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a,
double alpha)
1348 for(
int i = 0; i < cn; i++ )
1349 a[i] = saturate_cast<_Tp>(a[i]*alpha);
1353 template<
typename _Tp,
int cn>
static inline
1354 Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a,
int alpha)
1356 double ialpha = 1./
alpha;
1357 for(
int i = 0; i < cn; i++ )
1358 a[i] = saturate_cast<_Tp>(a[i]*ialpha);
1362 template<
typename _Tp,
int cn>
static inline
1363 Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a,
float alpha)
1365 float ialpha = 1.f/
alpha;
1366 for(
int i = 0; i < cn; i++ )
1367 a[i] = saturate_cast<_Tp>(a[i]*ialpha);
1371 template<
typename _Tp,
int cn>
static inline
1372 Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a,
double alpha)
1374 double ialpha = 1./
alpha;
1375 for(
int i = 0; i < cn; i++ )
1376 a[i] = saturate_cast<_Tp>(a[i]*ialpha);
1380 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1381 operator * (
const Vec<_Tp, cn>& a,
int alpha)
1383 return Vec<_Tp, cn>(
a,
alpha, Matx_ScaleOp());
1386 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1387 operator * (
int alpha,
const Vec<_Tp, cn>& a)
1389 return Vec<_Tp, cn>(
a,
alpha, Matx_ScaleOp());
1392 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1393 operator * (
const Vec<_Tp, cn>& a,
float alpha)
1395 return Vec<_Tp, cn>(
a,
alpha, Matx_ScaleOp());
1398 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1399 operator * (
float alpha,
const Vec<_Tp, cn>& a)
1401 return Vec<_Tp, cn>(
a,
alpha, Matx_ScaleOp());
1404 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1405 operator * (
const Vec<_Tp, cn>& a,
double alpha)
1407 return Vec<_Tp, cn>(
a,
alpha, Matx_ScaleOp());
1410 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1411 operator * (
double alpha,
const Vec<_Tp, cn>& a)
1413 return Vec<_Tp, cn>(
a,
alpha, Matx_ScaleOp());
1416 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1417 operator / (
const Vec<_Tp, cn>& a,
int alpha)
1419 return Vec<_Tp, cn>(
a, 1./
alpha, Matx_ScaleOp());
1422 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1423 operator / (
const Vec<_Tp, cn>& a,
float alpha)
1425 return Vec<_Tp, cn>(
a, 1.f/
alpha, Matx_ScaleOp());
1428 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1429 operator / (
const Vec<_Tp, cn>& a,
double alpha)
1431 return Vec<_Tp, cn>(
a, 1./
alpha, Matx_ScaleOp());
1434 template<
typename _Tp,
int cn>
static inline Vec<_Tp, cn>
1438 for(
int i = 0; i < cn; i++ ) t.val[i] = saturate_cast<_Tp>(-a.val[i]);
1444 return Vec<_Tp, 4>(saturate_cast<_Tp>(v1[0]*v2[0] - v1[1]*v2[1] - v1[2]*v2[2] - v1[3]*v2[3]),
1445 saturate_cast<_Tp>(v1[0]*v2[1] + v1[1]*v2[0] + v1[2]*v2[3] - v1[3]*v2[2]),
1446 saturate_cast<_Tp>(v1[0]*v2[2] - v1[1]*v2[3] + v1[2]*v2[0] + v1[3]*v2[1]),
1447 saturate_cast<_Tp>(v1[0]*v2[3] + v1[1]*v2[2] - v1[2]*v2[1] + v1[3]*v2[0]));
1472 double nv =
norm(v);
1473 return v * (nv ? 1./nv : 0.);
1476 template<
typename _Tp,
typename _T2,
int cn>
static inline
1477 VecCommaInitializer<_Tp, cn> operator << (const Vec<_Tp, cn>& vec, _T2
val)
1479 VecCommaInitializer<_Tp, cn> commaInitializer((Vec<_Tp, cn>*)&vec);
1480 return (commaInitializer,
val);
1483 template<
typename _Tp,
int cn>
inline
1488 template<
typename _Tp,
int cn>
template<
typename _T2>
inline
1491 CV_DbgAssert( this->
idx < cn );
1492 this->
dst->val[this->
idx++] = saturate_cast<_Tp>(
value);
1496 template<
typename _Tp,
int cn>
inline
1499 CV_DbgAssert( this->
idx == cn );
1508 {
return Complex<T2>(saturate_cast<T2>(re), saturate_cast<T2>(im)); }
1512 template<
typename _Tp>
static inline
1514 {
return a.
re == b.
re && a.
im == b.
im; }
1516 template<
typename _Tp>
static inline
1517 bool operator != (
const Complex<_Tp>& a,
const Complex<_Tp>& b)
1518 {
return a.re != b.re || a.im != b.im; }
1520 template<
typename _Tp>
static inline
1521 Complex<_Tp>
operator + (
const Complex<_Tp>& a,
const Complex<_Tp>& b)
1522 {
return Complex<_Tp>( a.re + b.re, a.im + b.im ); }
1524 template<
typename _Tp>
static inline
1525 Complex<_Tp>& operator += (Complex<_Tp>& a,
const Complex<_Tp>& b)
1526 { a.re += b.re; a.im += b.im;
return a; }
1528 template<
typename _Tp>
static inline
1529 Complex<_Tp>
operator - (
const Complex<_Tp>& a,
const Complex<_Tp>& b)
1530 {
return Complex<_Tp>( a.re - b.re, a.im - b.im ); }
1532 template<
typename _Tp>
static inline
1533 Complex<_Tp>& operator -= (Complex<_Tp>& a,
const Complex<_Tp>& b)
1534 { a.re -= b.re; a.im -= b.im;
return a; }
1536 template<
typename _Tp>
static inline
1537 Complex<_Tp>
operator - (
const Complex<_Tp>& a)
1538 {
return Complex<_Tp>(-a.re, -a.im); }
1540 template<
typename _Tp>
static inline
1541 Complex<_Tp> operator * (
const Complex<_Tp>& a,
const Complex<_Tp>& b)
1542 {
return Complex<_Tp>( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re ); }
1544 template<
typename _Tp>
static inline
1545 Complex<_Tp> operator * (
const Complex<_Tp>& a, _Tp b)
1546 {
return Complex<_Tp>( a.re*
b, a.im*
b ); }
1548 template<
typename _Tp>
static inline
1549 Complex<_Tp> operator * (_Tp b,
const Complex<_Tp>& a)
1550 {
return Complex<_Tp>( a.re*
b, a.im*
b ); }
1552 template<
typename _Tp>
static inline
1553 Complex<_Tp>
operator + (
const Complex<_Tp>& a, _Tp b)
1554 {
return Complex<_Tp>( a.re +
b, a.im ); }
1556 template<
typename _Tp>
static inline
1557 Complex<_Tp>
operator - (
const Complex<_Tp>& a, _Tp b)
1558 {
return Complex<_Tp>( a.re -
b, a.im ); }
1560 template<
typename _Tp>
static inline
1561 Complex<_Tp>
operator + (_Tp b,
const Complex<_Tp>& a)
1562 {
return Complex<_Tp>( a.re +
b, a.im ); }
1564 template<
typename _Tp>
static inline
1565 Complex<_Tp>
operator - (_Tp b,
const Complex<_Tp>& a)
1566 {
return Complex<_Tp>( b - a.re, -a.im ); }
1568 template<
typename _Tp>
static inline
1569 Complex<_Tp>& operator += (Complex<_Tp>& a, _Tp b)
1570 { a.re +=
b;
return a; }
1572 template<
typename _Tp>
static inline
1573 Complex<_Tp>& operator -= (Complex<_Tp>& a, _Tp b)
1574 { a.re -=
b;
return a; }
1576 template<
typename _Tp>
static inline
1577 Complex<_Tp>& operator *= (Complex<_Tp>& a, _Tp b)
1578 { a.re *=
b; a.im *=
b;
return a; }
1580 template<
typename _Tp>
static inline
1581 double abs(
const Complex<_Tp>& a)
1582 {
return std::sqrt( (
double)a.re*a.re + (
double)a.im*a.im); }
1584 template<
typename _Tp>
static inline
1585 Complex<_Tp>
operator / (
const Complex<_Tp>& a,
const Complex<_Tp>& b)
1587 double t = 1./((
double)b.re*b.re + (
double)b.im*b.im);
1588 return Complex<_Tp>( (_Tp)((a.re*b.re + a.im*b.im)*t),
1589 (_Tp)((-a.re*b.im + a.im*b.re)*t) );
1592 template<
typename _Tp>
static inline
1593 Complex<_Tp>& operator /= (Complex<_Tp>& a,
const Complex<_Tp>& b)
1598 template<
typename _Tp>
static inline
1599 Complex<_Tp>
operator / (
const Complex<_Tp>& a, _Tp b)
1602 return Complex<_Tp>( a.re*t, a.im*t );
1605 template<
typename _Tp>
static inline
1606 Complex<_Tp>
operator / (_Tp b,
const Complex<_Tp>& a)
1608 return Complex<_Tp>(
b)/a;
1611 template<
typename _Tp>
static inline
1612 Complex<_Tp> operator /= (
const Complex<_Tp>& a, _Tp b)
1615 a.re *= t; a.im *= t;
return a;
1625 :
x(saturate_cast<_Tp>(pt.
x)),
y(saturate_cast<_Tp>(pt.
y)) {}
1629 {
x = pt.
x;
y = pt.
y;
return *
this; }
1632 {
return Point_<_Tp2>(saturate_cast<_Tp2>(
x), saturate_cast<_Tp2>(
y)); }
1641 {
return saturate_cast<_Tp>(
x*pt.
x +
y*pt.
y); }
1651 a.
x = saturate_cast<_Tp>(a.
x + b.
x);
1652 a.
y = saturate_cast<_Tp>(a.
y + b.
y);
1656 template<
typename _Tp>
static inline Point_<_Tp>&
1657 operator -= (Point_<_Tp>& a,
const Point_<_Tp>& b)
1659 a.
x = saturate_cast<_Tp>(a.x - b.x);
1660 a.y = saturate_cast<_Tp>(a.y - b.y);
1664 template<
typename _Tp>
static inline Point_<_Tp>&
1665 operator *= (Point_<_Tp>& a,
int b)
1667 a.
x = saturate_cast<_Tp>(a.x*
b);
1668 a.y = saturate_cast<_Tp>(a.y*
b);
1672 template<
typename _Tp>
static inline Point_<_Tp>&
1673 operator *= (Point_<_Tp>& a,
float b)
1675 a.
x = saturate_cast<_Tp>(a.x*
b);
1676 a.y = saturate_cast<_Tp>(a.y*
b);
1680 template<
typename _Tp>
static inline Point_<_Tp>&
1681 operator *= (Point_<_Tp>& a,
double b)
1683 a.
x = saturate_cast<_Tp>(a.x*
b);
1684 a.y = saturate_cast<_Tp>(a.y*
b);
1688 template<
typename _Tp>
static inline double norm(
const Point_<_Tp>&
pt)
1689 {
return std::sqrt((
double)pt.x*pt.x + (
double)pt.y*pt.y); }
1691 template<
typename _Tp>
static inline bool operator == (
const Point_<_Tp>& a,
const Point_<_Tp>& b)
1692 {
return a.x == b.x && a.y == b.y; }
1694 template<
typename _Tp>
static inline bool operator != (
const Point_<_Tp>& a,
const Point_<_Tp>& b)
1695 {
return a.x != b.x || a.y != b.y; }
1697 template<
typename _Tp>
static inline Point_<_Tp>
operator + (
const Point_<_Tp>& a,
const Point_<_Tp>& b)
1698 {
return Point_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y) ); }
1700 template<
typename _Tp>
static inline Point_<_Tp>
operator - (
const Point_<_Tp>& a,
const Point_<_Tp>& b)
1701 {
return Point_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y) ); }
1703 template<
typename _Tp>
static inline Point_<_Tp>
operator - (
const Point_<_Tp>& a)
1704 {
return Point_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y) ); }
1706 template<
typename _Tp>
static inline Point_<_Tp> operator * (
const Point_<_Tp>& a,
int b)
1707 {
return Point_<_Tp>( saturate_cast<_Tp>(a.x*
b), saturate_cast<_Tp>(a.y*b) ); }
1709 template<
typename _Tp>
static inline Point_<_Tp> operator * (
int a,
const Point_<_Tp>& b)
1710 {
return Point_<_Tp>( saturate_cast<_Tp>(b.x*
a), saturate_cast<_Tp>(b.y*a) ); }
1712 template<
typename _Tp>
static inline Point_<_Tp> operator * (
const Point_<_Tp>& a,
float b)
1713 {
return Point_<_Tp>( saturate_cast<_Tp>(a.x*
b), saturate_cast<_Tp>(a.y*b) ); }
1715 template<
typename _Tp>
static inline Point_<_Tp> operator * (
float a,
const Point_<_Tp>& b)
1716 {
return Point_<_Tp>( saturate_cast<_Tp>(b.x*
a), saturate_cast<_Tp>(b.y*a) ); }
1718 template<
typename _Tp>
static inline Point_<_Tp> operator * (
const Point_<_Tp>& a,
double b)
1719 {
return Point_<_Tp>( saturate_cast<_Tp>(a.x*
b), saturate_cast<_Tp>(a.y*b) ); }
1721 template<
typename _Tp>
static inline Point_<_Tp> operator * (
double a,
const Point_<_Tp>& b)
1722 {
return Point_<_Tp>( saturate_cast<_Tp>(b.x*
a), saturate_cast<_Tp>(b.y*a) ); }
1731 x(saturate_cast<_Tp>(pt.
x)),
y(saturate_cast<_Tp>(pt.
y)),
z(saturate_cast<_Tp>(pt.
z)) {}
1735 {
return Point3_<_Tp2>(saturate_cast<_Tp2>(
x), saturate_cast<_Tp2>(
y), saturate_cast<_Tp2>(
z)); }
1744 {
x = pt.
x;
y = pt.
y;
z = pt.
z;
return *
this; }
1747 {
return saturate_cast<_Tp>(
x*pt.
x +
y*pt.
y +
z*pt.
z); }
1749 {
return (
double)
x*pt.
x + (
double)
y*pt.
y + (
double)
z*pt.
z; }
1759 a.
x = saturate_cast<_Tp>(a.
x + b.
x);
1760 a.
y = saturate_cast<_Tp>(a.
y + b.
y);
1761 a.
z = saturate_cast<_Tp>(a.
z + b.
z);
1765 template<
typename _Tp>
static inline Point3_<_Tp>&
1766 operator -= (Point3_<_Tp>& a,
const Point3_<_Tp>& b)
1768 a.
x = saturate_cast<_Tp>(a.x - b.x);
1769 a.y = saturate_cast<_Tp>(a.y - b.y);
1770 a.z = saturate_cast<_Tp>(a.z - b.z);
1774 template<
typename _Tp>
static inline Point3_<_Tp>&
1775 operator *= (Point3_<_Tp>& a,
int b)
1777 a.
x = saturate_cast<_Tp>(a.x*
b);
1778 a.y = saturate_cast<_Tp>(a.y*
b);
1779 a.z = saturate_cast<_Tp>(a.z*
b);
1783 template<
typename _Tp>
static inline Point3_<_Tp>&
1784 operator *= (Point3_<_Tp>& a,
float b)
1786 a.
x = saturate_cast<_Tp>(a.x*
b);
1787 a.y = saturate_cast<_Tp>(a.y*
b);
1788 a.z = saturate_cast<_Tp>(a.z*
b);
1792 template<
typename _Tp>
static inline Point3_<_Tp>&
1793 operator *= (Point3_<_Tp>& a,
double b)
1795 a.
x = saturate_cast<_Tp>(a.x*
b);
1796 a.y = saturate_cast<_Tp>(a.y*
b);
1797 a.z = saturate_cast<_Tp>(a.z*
b);
1801 template<
typename _Tp>
static inline double norm(
const Point3_<_Tp>& pt)
1802 {
return std::sqrt((
double)pt.x*pt.x + (
double)pt.y*pt.y + (
double)pt.z*pt.z); }
1804 template<
typename _Tp>
static inline bool operator == (
const Point3_<_Tp>& a,
const Point3_<_Tp>& b)
1805 {
return a.x == b.x && a.y == b.y && a.z == b.z; }
1807 template<
typename _Tp>
static inline bool operator != (
const Point3_<_Tp>& a,
const Point3_<_Tp>& b)
1808 {
return a.x != b.x || a.y != b.y || a.z != b.z; }
1810 template<
typename _Tp>
static inline Point3_<_Tp>
operator + (
const Point3_<_Tp>& a,
const Point3_<_Tp>& b)
1811 {
return Point3_<_Tp>( saturate_cast<_Tp>(a.x + b.x),
1812 saturate_cast<_Tp>(a.y + b.y),
1813 saturate_cast<_Tp>(a.z + b.z)); }
1815 template<
typename _Tp>
static inline Point3_<_Tp>
operator - (
const Point3_<_Tp>& a,
const Point3_<_Tp>& b)
1816 {
return Point3_<_Tp>( saturate_cast<_Tp>(a.x - b.x),
1817 saturate_cast<_Tp>(a.y - b.y),
1818 saturate_cast<_Tp>(a.z - b.z)); }
1820 template<
typename _Tp>
static inline Point3_<_Tp>
operator - (
const Point3_<_Tp>& a)
1821 {
return Point3_<_Tp>( saturate_cast<_Tp>(-a.x),
1822 saturate_cast<_Tp>(-a.y),
1823 saturate_cast<_Tp>(-a.z) ); }
1825 template<
typename _Tp>
static inline Point3_<_Tp> operator * (
const Point3_<_Tp>& a,
int b)
1826 {
return Point3_<_Tp>( saturate_cast<_Tp>(a.x*
b),
1827 saturate_cast<_Tp>(a.y*b),
1828 saturate_cast<_Tp>(a.z*
b) ); }
1830 template<
typename _Tp>
static inline Point3_<_Tp> operator * (
int a,
const Point3_<_Tp>& b)
1831 {
return Point3_<_Tp>( saturate_cast<_Tp>(b.x*
a),
1832 saturate_cast<_Tp>(b.y*a),
1833 saturate_cast<_Tp>(b.z*
a) ); }
1835 template<
typename _Tp>
static inline Point3_<_Tp> operator * (
const Point3_<_Tp>& a,
float b)
1836 {
return Point3_<_Tp>( saturate_cast<_Tp>(a.x*
b),
1837 saturate_cast<_Tp>(a.y*b),
1838 saturate_cast<_Tp>(a.z*
b) ); }
1840 template<
typename _Tp>
static inline Point3_<_Tp> operator * (
float a,
const Point3_<_Tp>& b)
1841 {
return Point3_<_Tp>( saturate_cast<_Tp>(b.x*
a),
1842 saturate_cast<_Tp>(b.y*a),
1843 saturate_cast<_Tp>(b.z*
a) ); }
1845 template<
typename _Tp>
static inline Point3_<_Tp> operator * (
const Point3_<_Tp>& a,
double b)
1846 {
return Point3_<_Tp>( saturate_cast<_Tp>(a.x*
b),
1847 saturate_cast<_Tp>(a.y*b),
1848 saturate_cast<_Tp>(a.z*
b) ); }
1850 template<
typename _Tp>
static inline Point3_<_Tp> operator * (
double a,
const Point3_<_Tp>& b)
1851 {
return Point3_<_Tp>( saturate_cast<_Tp>(b.x*
a),
1852 saturate_cast<_Tp>(b.y*a),
1853 saturate_cast<_Tp>(b.z*
a) ); }
1880 template<
typename _Tp>
static inline Size_<_Tp>
operator + (
const Size_<_Tp>& a,
const Size_<_Tp>& b)
1881 {
return Size_<_Tp>(a.width + b.width, a.height + b.height); }
1882 template<
typename _Tp>
static inline Size_<_Tp>
operator - (
const Size_<_Tp>& a,
const Size_<_Tp>& b)
1883 {
return Size_<_Tp>(a.width - b.width, a.height - b.height); }
1888 template<
typename _Tp>
static inline Size_<_Tp>& operator -= (Size_<_Tp>& a,
const Size_<_Tp>& b)
1889 { a.width -= b.width; a.height -= b.height;
return a; }
1891 template<
typename _Tp>
static inline bool operator == (
const Size_<_Tp>& a,
const Size_<_Tp>& b)
1892 {
return a.width == b.width && a.height == b.height; }
1893 template<
typename _Tp>
static inline bool operator != (
const Size_<_Tp>& a,
const Size_<_Tp>& b)
1894 {
return a.width != b.width || a.height != b.height; }
1917 { a.
x += b.
x; a.
y += b.
y;
return a; }
1918 template<
typename _Tp>
static inline Rect_<_Tp>& operator -= ( Rect_<_Tp>& a,
const Point_<_Tp>& b )
1919 { a.
x -= b.x; a.y -= b.y;
return a; }
1921 template<
typename _Tp>
static inline Rect_<_Tp>& operator += ( Rect_<_Tp>& a,
const Size_<_Tp>& b )
1922 { a.width += b.width; a.height += b.height;
return a; }
1924 template<
typename _Tp>
static inline Rect_<_Tp>& operator -= ( Rect_<_Tp>& a,
const Size_<_Tp>& b )
1925 { a.width -= b.width; a.height -= b.height;
return a; }
1927 template<
typename _Tp>
static inline Rect_<_Tp>& operator &= ( Rect_<_Tp>& a,
const Rect_<_Tp>& b )
1929 _Tp x1 = std::max(a.x, b.x), y1 = std::max(a.y, b.y);
1930 a.width =
std::min(a.x + a.width, b.x + b.width) - x1;
1931 a.height =
std::min(a.y + a.height, b.y + b.height) - y1;
1933 if( a.width <= 0 || a.height <= 0 )
1938 template<
typename _Tp>
static inline Rect_<_Tp>& operator |= ( Rect_<_Tp>& a,
const Rect_<_Tp>& b )
1941 a.width = std::max(a.x + a.width, b.x + b.width) - x1;
1942 a.height = std::max(a.y + a.height, b.y + b.height) - y1;
1951 {
return Rect_<_Tp2>(saturate_cast<_Tp2>(
x), saturate_cast<_Tp2>(
y),
1952 saturate_cast<_Tp2>(
width), saturate_cast<_Tp2>(
height)); }
1965 template<
typename _Tp>
static inline bool operator != (
const Rect_<_Tp>& a,
const Rect_<_Tp>& b)
1967 return a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height;
1970 template<
typename _Tp>
static inline Rect_<_Tp>
operator + (
const Rect_<_Tp>& a,
const Point_<_Tp>& b)
1972 return Rect_<_Tp>( a.x + b.x, a.y + b.y, a.width, a.height );
1975 template<
typename _Tp>
static inline Rect_<_Tp>
operator - (
const Rect_<_Tp>& a,
const Point_<_Tp>& b)
1977 return Rect_<_Tp>( a.x - b.x, a.y - b.y, a.width, a.height );
1980 template<
typename _Tp>
static inline Rect_<_Tp>
operator + (
const Rect_<_Tp>& a,
const Size_<_Tp>& b)
1982 return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height );
1985 template<
typename _Tp>
static inline Rect_<_Tp>
operator & (
const Rect_<_Tp>& a,
const Rect_<_Tp>& b)
1991 template<
typename _Tp>
static inline Rect_<_Tp>
operator | (
const Rect_<_Tp>& a,
const Rect_<_Tp>& b)
2016 { this->
val[0] = this->
val[1] = this->
val[2] = this->
val[3] = 0; }
2019 { this->
val[0] = v0; this->
val[1] = v1; this->
val[2] = v2; this->
val[3] = v3; }
2023 this->
val[0] = saturate_cast<_Tp>(s.
val[0]);
2024 this->
val[1] = saturate_cast<_Tp>(s.
val[1]);
2025 this->val[2] = saturate_cast<_Tp>(s.
val[2]);
2026 this->val[3] = saturate_cast<_Tp>(s.
val[3]);
2030 { this->
val[0] = v0; this->
val[1] = this->
val[2] = this->
val[3] = 0; }
2040 saturate_cast<T2>(this->
val[1]),
2041 saturate_cast<T2>(this->
val[2]),
2042 saturate_cast<T2>(this->
val[3]));
2047 a.
val[0] = saturate_cast<_Tp>(a.
val[0] + b.
val[0]);
2048 a.
val[1] = saturate_cast<_Tp>(a.
val[1] + b.
val[1]);
2049 a.
val[2] = saturate_cast<_Tp>(a.
val[2] + b.
val[2]);
2050 a.
val[3] = saturate_cast<_Tp>(a.
val[3] + b.
val[3]);
2054 template<
typename _Tp>
static inline Scalar_<_Tp>& operator -= (Scalar_<_Tp>& a,
const Scalar_<_Tp>& b)
2056 a.val[0] = saturate_cast<_Tp>(a.val[0] - b.val[0]);
2057 a.val[1] = saturate_cast<_Tp>(a.val[1] - b.val[1]);
2058 a.val[2] = saturate_cast<_Tp>(a.val[2] - b.val[2]);
2059 a.val[3] = saturate_cast<_Tp>(a.val[3] - b.val[3]);
2063 template<
typename _Tp>
static inline Scalar_<_Tp>& operator *= ( Scalar_<_Tp>& a, _Tp
v )
2065 a.val[0] = saturate_cast<_Tp>(a.val[0] * v);
2066 a.val[1] = saturate_cast<_Tp>(a.val[1] * v);
2067 a.val[2] = saturate_cast<_Tp>(a.val[2] * v);
2068 a.val[3] = saturate_cast<_Tp>(a.val[3] * v);
2075 saturate_cast<_Tp>(this->
val[1]*t.
val[1]*scale),
2077 saturate_cast<_Tp>(this->
val[3]*t.
val[3]*scale));
2086 template<
typename _Tp>
static inline bool operator != (
const Scalar_<_Tp>& a,
const Scalar_<_Tp>& b )
2088 return a.val[0] != b.val[0] || a.val[1] != b.val[1] ||
2089 a.val[2] != b.val[2] || a.val[3] != b.val[3];
2092 template<
typename _Tp>
static inline Scalar_<_Tp>
operator + (
const Scalar_<_Tp>& a,
const Scalar_<_Tp>& b)
2094 return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] + b.val[0]),
2095 saturate_cast<_Tp>(a.val[1] + b.val[1]),
2096 saturate_cast<_Tp>(a.val[2] + b.val[2]),
2097 saturate_cast<_Tp>(a.val[3] + b.val[3]));
2100 template<
typename _Tp>
static inline Scalar_<_Tp>
operator - (
const Scalar_<_Tp>& a,
const Scalar_<_Tp>& b)
2102 return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] - b.val[0]),
2103 saturate_cast<_Tp>(a.val[1] - b.val[1]),
2104 saturate_cast<_Tp>(a.val[2] - b.val[2]),
2105 saturate_cast<_Tp>(a.val[3] - b.val[3]));
2108 template<
typename _Tp>
static inline Scalar_<_Tp> operator * (
const Scalar_<_Tp>& a, _Tp alpha)
2110 return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] *
alpha),
2111 saturate_cast<_Tp>(a.val[1] * alpha),
2112 saturate_cast<_Tp>(a.val[2] *
alpha),
2113 saturate_cast<_Tp>(a.val[3] * alpha));
2116 template<
typename _Tp>
static inline Scalar_<_Tp> operator * (_Tp alpha,
const Scalar_<_Tp>& a)
2121 template<
typename _Tp>
static inline Scalar_<_Tp>
operator - (
const Scalar_<_Tp>& a)
2123 return Scalar_<_Tp>(saturate_cast<_Tp>(-a.val[0]), saturate_cast<_Tp>(-a.val[1]),
2124 saturate_cast<_Tp>(-a.val[2]), saturate_cast<_Tp>(-a.val[3]));
2128 template<
typename _Tp>
static inline Scalar_<_Tp>
2129 operator * (
const Scalar_<_Tp>& a,
const Scalar_<_Tp>& b)
2131 return Scalar_<_Tp>(saturate_cast<_Tp>(a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3]),
2132 saturate_cast<_Tp>(a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2]),
2133 saturate_cast<_Tp>(a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1]),
2134 saturate_cast<_Tp>(a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0]));
2137 template<
typename _Tp>
static inline Scalar_<_Tp>&
2138 operator *= (Scalar_<_Tp>& a,
const Scalar_<_Tp>& b)
2147 saturate_cast<_Tp>(-this->
val[1]),
2148 saturate_cast<_Tp>(-this->
val[2]),
2149 saturate_cast<_Tp>(-this->
val[3]));
2154 return this->
val[1] == 0 && this->
val[2] == 0 && this->
val[3] == 0;
2157 template<
typename _Tp>
static inline
2161 saturate_cast<_Tp>(a.
val[1] / alpha),
2162 saturate_cast<_Tp>(a.
val[2] /
alpha),
2163 saturate_cast<_Tp>(a.
val[3] / alpha));
2166 template<
typename _Tp>
static inline
2167 Scalar_<float>
operator / (
const Scalar_<float>& a,
float alpha)
2170 return Scalar_<float>(a.val[0]*s, a.val[1]*s, a.val[2]*s, a.val[3]*s);
2173 template<
typename _Tp>
static inline
2174 Scalar_<double>
operator / (
const Scalar_<double>& a,
double alpha)
2177 return Scalar_<double>(a.val[0]*s, a.val[1]*s, a.val[2]*s, a.val[3]*s);
2180 template<
typename _Tp>
static inline
2181 Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, _Tp alpha)
2187 template<
typename _Tp>
static inline
2188 Scalar_<_Tp>
operator / (_Tp a,
const Scalar_<_Tp>& b)
2190 _Tp s = a/(b[0]*b[0] + b[1]*b[1] + b[2]*b[2] + b[3]*b[3]);
2194 template<
typename _Tp>
static inline
2195 Scalar_<_Tp>
operator / (
const Scalar_<_Tp>& a,
const Scalar_<_Tp>& b)
2197 return a*((_Tp)1/b);
2200 template<
typename _Tp>
static inline
2201 Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a,
const Scalar_<_Tp>& b)
2213 if(
start == 0 &&
end == CV_WHOLE_SEQ_END_INDEX )
2225 {
return !(r1 == r2); }
2227 static inline bool operator !(
const Range&
r)
2228 {
return r.start == r.end; }
2233 r.end = std::max(
r.end,
r.start);
2245 return Range(r1.start + delta, r1.end + delta);
2250 return Range(r1.start + delta, r1.end + delta);
2255 return r1 + (-
delta);
2294 for(
size_t i = 0; i < _size; i++)
2297 Vector(_Tp* _data,
size_t _size,
bool _copyData=
false)
2298 {
set(_data, _size, _copyData); }
2301 {
set((_Tp*)&vec.
val[0], n,
true); }
2303 Vector(
const std::vector<_Tp>& vec,
bool _copyData=
false)
2304 {
set(!vec.empty() ? (_Tp*)&vec[0] : 0, vec.size(), _copyData); }
2343 size_t i, sz =
size();
2347 for( i = 0; i < sz; i++ )
2353 size_t i, sz =
size();
2356 _Tp*
dst = sz ? &vec[0] : 0;
2357 for( i = 0; i < sz; i++ )
2388 void set(_Tp* _data,
size_t _size,
bool _copyData=
false)
2400 for(
size_t i = 0; i < _size; i++ )
2413 newCapacity = std::max(newCapacity, oldSize);
2414 newData =
new _Tp[newCapacity];
2415 newRefcount =
new int(1);
2416 for( i = 0; i < oldSize; i++ )
2428 newSize = std::max(newSize, (
size_t)0);
2433 for( i =
hdr.
size; i < newSize; i++ )
2468 size_t i = 0, n = v1.
size();
2472 const _Tp *ptr1 = &v1[0], *ptr2 = &v2[0];
2474 s += (_Tw)ptr1[i]*ptr2[i];
2485 return (
unsigned)
state;
2492 inline RNG::operator unsigned() {
return next(); }
2495 inline RNG::operator
int() {
return (
int)
next(); }
2497 inline RNG::operator
float() {
return next()*2.3283064365386962890625e-10
f; }
2500 unsigned t =
next();
2501 return (((
uint64)t << 32) |
next())*5.4210108624275221700372640043497e-20;
2504 inline float RNG::uniform(
float a,
float b) {
return ((
float)*
this)*(b -
a) + a; }
2505 inline double RNG::uniform(
double a,
double b) {
return ((
double)*
this)*(b -
a) + a; }
2509 :
type(_type),
maxCount(_maxCount), epsilon(_epsilon) {}
2511 :
type(criteria.
type),
maxCount(criteria.max_iter), epsilon(criteria.epsilon) {}
2560 if(_size > fixed_size)
2562 ptr = cv::allocate<_Tp>(_size);
2571 cv::deallocate<_Tp>(
ptr,
size);
2599 {
if( refcount ) CV_XADD(refcount, 1); }
2603 if( refcount && CV_XADD(refcount, -1) == 1 )
2630 CV_XADD(_refcount, 1);
2633 refcount = _refcount;
2646 :
obj(0), refcount(0)
2651 _Tp* p_casted =
dynamic_cast<_Tp*
>(p.
obj);
2666 _Tp2* obj_casted =
dynamic_cast<_Tp2*
>(
obj);
2671 CV_XADD(refcount, 1);
2684 _Tp2* obj_casted =
dynamic_cast<_Tp2*
>(
obj);
2689 CV_XADD(refcount, 1);
2713 {
write(fs,
string(), value); }
2775 for(
int i = 0; i < cn; i++)
2797 int flags,
const string& typeName=
string());
2843 for(
int i = 0; i < cn; i++)
2869 size_t i,
count = vec.size();
2870 for( i = 0; i <
count; i++ )
2883 char fmt[] = { (
char)((_fmt>>8)+
'1'), (
char)_fmt,
'\0' };
2884 fs->
writeRaw(
string(fmt), !vec.empty() ? (
uchar*)&vec[0] : 0, vec.size()*
sizeof(_Tp) );
2889 template<
typename _Tp>
static inline void write(
FileStorage& fs,
const vector<_Tp>& vec )
2895 template<
typename _Tp>
static inline void write( FileStorage& fs,
const string&
name,
2896 const vector<_Tp>& vec )
2898 WriteStructContext ws(fs, name, CV_NODE_SEQ+(DataType<_Tp>::fmt != 0 ? CV_NODE_FLOW : 0));
2902 CV_EXPORTS_W
void write( FileStorage& fs,
const string& name,
const Mat&
value );
2903 CV_EXPORTS
void write( FileStorage& fs,
const string& name,
const SparseMat&
value );
2905 template<
typename _Tp>
static inline FileStorage&
operator << (FileStorage& fs,
const _Tp&
value)
2907 if( !fs.isOpened() )
2910 CV_Error(
CV_StsError,
"No element name has been given" );
2911 write( fs, fs.elname, value );
2917 CV_EXPORTS FileStorage&
operator << (FileStorage& fs,
const string&
str);
2919 static inline FileStorage&
operator << (FileStorage& fs,
const char*
str)
2920 {
return (fs <<
string(str)); }
2922 static inline FileStorage&
operator << (FileStorage& fs,
char* value)
2923 {
return (fs <<
string(value)); }
2927 : fs(_fs),
node(_node) {}
2950 static inline void read(
const FileNode&
node,
int& value,
int default_value)
2952 value = !node.
node ? default_value :
2957 static inline void read(
const FileNode& node,
bool& value,
bool default_value)
2959 int temp;
read(node, temp, (
int)default_value);
2965 int temp;
read(node, temp, (
int)default_value);
2971 int temp;
read(node, temp, (
int)default_value);
2977 int temp;
read(node, temp, (
int)default_value);
2981 static inline void read(
const FileNode& node,
short& value,
short default_value)
2983 int temp;
read(node, temp, (
int)default_value);
2984 value = saturate_cast<
short>(
temp);
2987 static inline void read(
const FileNode& node,
float& value,
float default_value)
2989 value = !node.node ? default_value :
2990 CV_NODE_IS_INT(node.node->tag) ? (
float)node.node->data.i :
2991 CV_NODE_IS_REAL(node.node->tag) ? (
float)node.node->data.f : 1e30f;
2994 static inline void read(
const FileNode& node,
double& value,
double default_value)
2996 value = !node.node ? default_value :
2997 CV_NODE_IS_INT(node.node->tag) ? (
double)node.node->data.i :
2998 CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300;
3001 static inline void read(
const FileNode& node,
string& value,
const string& default_value)
3003 value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ?
string(node.node->data.str.ptr) :
string(
"");
3006 template<
typename _Tp>
static inline void read(
const FileNode& node, Point_<_Tp>& value,
const Point_<_Tp>& default_value)
3009 value = temp.size() != 2 ? default_value : Point_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]));
3012 template<
typename _Tp>
static inline void read(
const FileNode& node, Point3_<_Tp>& value,
const Point3_<_Tp>& default_value)
3015 value = temp.size() != 3 ? default_value : Point3_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]),
3016 saturate_cast<_Tp>(temp[2]));
3019 template<
typename _Tp>
static inline void read(
const FileNode& node, Size_<_Tp>& value,
const Size_<_Tp>& default_value)
3022 value = temp.size() != 2 ? default_value : Size_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]));
3025 template<
typename _Tp>
static inline void read(
const FileNode& node, Complex<_Tp>& value,
const Complex<_Tp>& default_value)
3028 value = temp.size() != 2 ? default_value : Complex<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]));
3031 template<
typename _Tp>
static inline void read(
const FileNode& node, Rect_<_Tp>& value,
const Rect_<_Tp>& default_value)
3034 value = temp.size() != 4 ? default_value : Rect_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]),
3035 saturate_cast<_Tp>(temp[2]), saturate_cast<_Tp>(temp[3]));
3038 template<
typename _Tp,
int cn>
static inline void read(
const FileNode& node, Vec<_Tp, cn>& value,
const Vec<_Tp, cn>& default_value)
3041 value = temp.size() != cn ? default_value : Vec<_Tp, cn>(&temp[0]);
3044 template<
typename _Tp>
static inline void read(
const FileNode& node, Scalar_<_Tp>& value,
const Scalar_<_Tp>& default_value)
3047 value = temp.size() != 4 ? default_value : Scalar_<_Tp>(saturate_cast<_Tp>(temp[0]), saturate_cast<_Tp>(temp[1]),
3048 saturate_cast<_Tp>(temp[2]), saturate_cast<_Tp>(temp[3]));
3054 read(node, temp, default_temp);
3055 value.start = temp.x; value.end = temp.y;
3058 CV_EXPORTS_W
void read(
const FileNode& node, Mat&
mat,
const Mat& default_mat=Mat() );
3059 CV_EXPORTS
void read(
const FileNode& node, SparseMat& mat,
const SparseMat& default_mat=SparseMat() );
3061 inline FileNode::operator
int()
const
3064 read(*
this, value, 0);
3070 read(*
this, value, 0.
f);
3076 read(*
this, value, 0.);
3082 read(*
this, value, value);
3097 count =
std::min(count, it->remaining);
3099 for(
size_t i = 0; i <
count; i++, ++(*it) )
3100 read(**it, vec[i], _Tp());
3113 char fmt[] = { (
char)((_fmt>>8)+
'1'), (
char)_fmt,
'\0' };
3114 size_t remaining1 = remaining/cn;
3115 count = count < remaining1 ? count : remaining1;
3117 it->readRaw(
string(fmt), !vec.empty() ? (
uchar*)&vec[0] : 0, count*
sizeof(_Tp) );
3122 template<
typename _Tp>
static inline void
3129 template<
typename _Tp>
static inline void
3130 read(
const FileNode& node, vector<_Tp>& vec,
const vector<_Tp>& default_value=vector<_Tp>() )
3133 vec = default_value;
3158 {
read( *it, value, _Tp());
return ++it; }
3160 template<
typename _Tp>
static inline
3163 VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0>
r(&it);
3164 r(vec, (
size_t)INT_MAX);
3168 template<
typename _Tp>
static inline void operator >> (
const FileNode& n, _Tp& value)
3169 {
read( n, value, _Tp()); }
3171 template<
typename _Tp>
static inline void operator >> (
const FileNode& n, vector<_Tp>& vec)
3176 return it1.fs == it2.fs && it1.container == it2.container &&
3177 it1.reader.ptr == it2.reader.ptr && it1.remaining == it2.remaining;
3182 return !(it1 == it2);
3187 return it2.remaining - it1.remaining;
3192 return it1.remaining > it2.remaining;
3204 template<
typename _Tp>
static inline _Tp gcd(_Tp a, _Tp b)
3257 template<
typename _Tp,
class _LT>
void sort( vector<_Tp>& vec, _LT LT=_LT() )
3259 int isort_thresh = 7;
3268 size_t total = vec.size();
3275 stack[0].ub = arr + (total - 1);
3279 _Tp*
left = stack[
sp].lb;
3280 _Tp*
right = stack[sp--].ub;
3284 int i, n = (
int)(right - left) + 1,
m;
3288 if( n <= isort_thresh )
3291 for( ptr = left + 1; ptr <=
right; ptr++ )
3293 for( ptr2 = ptr; ptr2 > left && LT(ptr2[0],ptr2[-1]); ptr2--)
3312 pivot = left + (n/2);
3317 a = left, b = left +
d, c = left + 2*
d;
3318 left = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c :
a))
3319 : (LT(*c, *b) ? b : (LT(*a, *c) ? a :
c));
3321 a = pivot -
d, b = pivot, c = pivot +
d;
3322 pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c :
a))
3323 : (LT(*c, *b) ? b : (LT(*a, *c) ? a :
c));
3325 a = right - 2*
d, b = right -
d, c =
right;
3326 right = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c :
a))
3327 : (LT(*c, *b) ? b : (LT(*a, *c) ? a :
c));
3330 a = left, b = pivot, c =
right;
3331 pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c :
a))
3332 : (LT(*c, *b) ? b : (LT(*a, *c) ? a :
c));
3333 if( pivot != left0 )
3338 left = left1 = left0 + 1;
3339 right = right1 = right0;
3343 while( left <= right && !LT(*pivot, *left) )
3345 if( !LT(*left, *pivot) )
3355 while( left <= right && !LT(*right, *pivot) )
3357 if( !LT(*pivot, *right) )
3359 if( right < right1 )
3377 left = left0, right = right0;
3381 n =
std::min( (
int)(left1 - left0), (
int)(left - left1) );
3382 for( i = 0; i <
n; i++ )
3385 n =
std::min( (
int)(right0 - right1), (
int)(right1 - right) );
3386 for( i = 0; i <
n; i++ )
3388 n = (
int)(left - left1);
3389 m = (
int)(right1 - right);
3396 stack[++
sp].lb = left0;
3397 stack[
sp].ub = left0 + n - 1;
3398 left = right0 -
m + 1, right = right0;
3402 stack[++
sp].lb = right0 -
m + 1;
3403 stack[
sp].ub = right0;
3404 left = left0, right = left0 + n - 1;
3408 left = left0, right = left0 + n - 1;
3411 left = right0 -
m + 1, right = right0;
3454 template<
typename _Tp,
class _EqPredicate>
int
3456 _EqPredicate predicate=_EqPredicate())
3458 int i, j, N = (
int)_vec.size();
3459 const _Tp* vec = &_vec[0];
3464 vector<int> _nodes(N*2);
3465 int (*nodes)[2] = (
int(*)[2])&_nodes[0];
3468 for(i = 0; i < N; i++)
3470 nodes[i][PARENT]=-1;
3475 for( i = 0; i < N; i++ )
3480 while( nodes[root][PARENT] >= 0 )
3481 root = nodes[root][PARENT];
3483 for( j = 0; j < N; j++ )
3485 if( i == j || !predicate(vec[i], vec[j]))
3489 while( nodes[root2][PARENT] >= 0 )
3490 root2 = nodes[root2][PARENT];
3495 int rank = nodes[root][RANK], rank2 = nodes[root2][RANK];
3497 nodes[root2][PARENT] = root;
3500 nodes[root][PARENT] = root2;
3501 nodes[root2][RANK] += rank == rank2;
3504 assert( nodes[root][PARENT] < 0 );
3509 while( (parent = nodes[k][PARENT]) >= 0 )
3511 nodes[
k][PARENT] = root;
3517 while( (parent = nodes[k][PARENT]) >= 0 )
3519 nodes[
k][PARENT] = root;
3530 for( i = 0; i < N; i++ )
3533 while( nodes[root][PARENT] >= 0 )
3534 root = nodes[root][PARENT];
3536 if( nodes[root][RANK] >= 0 )
3537 nodes[root][RANK] = ~nclasses++;
3538 labels[i] = ~nodes[root][RANK];
3553 int count,
int in_front=0 );
3563 CV_Assert(!_seq || _seq->elem_size ==
sizeof(_Tp));
3569 CV_Assert(headerSize >= (
int)
sizeof(
CvSeq));
3586 {
return seq ?
seq->total : 0; }
3589 {
return seq ? CV_MAT_TYPE(
seq->flags) : 0; }
3592 {
return seq ? CV_MAT_DEPTH(
seq->flags) : 0; }
3595 {
return seq ? CV_MAT_CN(
seq->flags) : 0; }
3598 {
return seq ?
seq->elem_size : 0; }
3601 {
return cvSeqElemIdx(
seq, &elem); }
3604 { cvSeqPush(
seq, &elem); }
3607 { cvSeqPushFront(
seq, &elem); }
3610 { cvSeqPushMulti(
seq, elem, (
int)count, 0); }
3613 { cvSeqPushMulti(
seq, elem, (
int)count, 1); }
3628 {
return !
seq ||
seq->total == 0; }
3646 { seqInsert(
seq, idx, &elem); }
3665 cvCvtSeqToArray(
seq, &vec[0], range);
3676 { memset(
this, 0,
sizeof(*
this)); }
3680 cvStartReadSeq(_seq.
seq,
this);
3681 index = seekEnd ? _seq.
seq->total : 0;
3686 cvSetSeqReaderPos(
this, (
int)pos,
false);
3694 {
return *(_Tp*)
ptr; }
3697 {
return *(
const _Tp*)
ptr; }
3701 CV_NEXT_SEQ_ELEM(
sizeof(_Tp), *
this);
3716 CV_PREV_SEQ_ELEM(
sizeof(_Tp), *
this);
3731 cvSetSeqReaderPos(
this, delta, 1);
3733 int n =
seq->total*2;
3743 return (*
this += -delta);
3750 if( std::abs(static_cast<long>(delta)) > n )
3751 delta += delta < 0 ? n : -
n;
3773 static _ClsName dummy;
3774 static void* dummyp = &dummy;
3782 return *a.pp == *b.pp;
3788 delete (_ClsName*)*dbptr;
3795 _ClsName*
obj =
new _ClsName;
3808 ((
const _ClsName*)ptr)->write(fs,
string(name));
3816 return new _ClsName(*(
const _ClsName*)ptr);
3825 virtual void write(std::ostream& out,
const Mat&
m,
const int*
params=0,
int nparams=0)
const = 0;
3826 virtual void write(std::ostream& out,
const void*
data,
int nelems,
int type,
3827 const int*
params=0,
int nparams=0)
const = 0;
3828 static const Formatter*
get(
const char* fmt=
"");
3836 const vector<int>&
params);
3838 const int* params=0);
3845 const vector<int>&
params=vector<int>())
3850 template<
typename _Tp>
static inline Formatted
format(
const vector<Point_<_Tp> >& vec,
3851 const char* fmt,
const vector<int>&
params=vector<int>())
3856 template<
typename _Tp>
static inline Formatted
format(
const vector<Point3_<_Tp> >& vec,
3857 const char* fmt,
const vector<int>&
params=vector<int>())
3869 static inline std::ostream&
operator << (std::ostream& out,
const Mat& mtx)
3882 static inline std::ostream&
operator << (std::ostream& out,
const Formatted& fmtd)
3884 fmtd.fmt->write(out, fmtd.mtx);
3889 template<
typename _Tp>
static inline std::ostream&
operator << (std::ostream& out,
3890 const vector<Point_<_Tp> >& vec)
3897 template<
typename _Tp>
static inline std::ostream&
operator << (std::ostream& out,
3898 const vector<Point3_<_Tp> >& vec)
3907 template<
typename _Tp,
int m,
int n>
inline std::ostream& operator<<(std::ostream& out, const Matx<_Tp, m, n>& matx)
3915 template<
typename _Tp>
inline std::ostream& operator<<(std::ostream& out, const Point_<_Tp>&
p)
3917 out <<
"[" <<
p.x <<
", " <<
p.y <<
"]";
3923 template<
typename _Tp>
inline std::ostream& operator<<(std::ostream& out, const Point3_<_Tp>&
p)
3925 out <<
"[" <<
p.x <<
", " <<
p.y <<
", " <<
p.z <<
"]";
3931 template<
typename _Tp,
int n>
inline std::ostream& operator<<(std::ostream& out, const Vec<_Tp, n>& vec)
3937 for (
int i = 0; i < n - 1; ++i) {
3938 out << (
int)vec[i] <<
", ";
3940 out << (
int)vec[n-1] <<
"]";
3944 for (
int i = 0; i < n - 1; ++i) {
3945 out << vec[i] <<
", ";
3947 out << vec[n-1] <<
"]";
3955 template<
typename _Tp>
inline std::ostream& operator<<(std::ostream& out, const Size_<_Tp>&
size)
3963 template<
typename _Tp>
inline std::ostream& operator<<(std::ostream& out, const Rect_<_Tp>&
rect)
3972 return _create(name).ptr<_Tp>();
3975 template<
typename _Tp>
3979 if (algo_ptr.
empty()) {
3980 CV_Error(
CV_StsUnsupportedFormat,
"unknown/unsupported Ptr type of the second parameter of the method Algorithm::set");
3985 template<
typename _Tp>
3988 this->set<_Tp>(_name.c_str(),
value);
3991 template<
typename _Tp>
3995 if (algo_ptr.
empty()) {
3996 CV_Error(
CV_StsUnsupportedFormat,
"unknown/unsupported Ptr type of the second parameter of the method Algorithm::set");
4001 template<
typename _Tp>
4004 this->set<_Tp>(_name.c_str(),
value);
4042 # pragma warning(pop)
4045 #endif // __cplusplus
sequence
Definition: core.hpp:4132
empty node
Definition: core.hpp:4125
struct CvTermCriteria CvTermCriteria
CvArr CvPoint2D32f double M
Definition: imgproc_c.h:186
CvSeqReader reader
Definition: core.hpp:4243
void release()
decrements the reference counter. If it reaches 0, delete_obj() is called
Definition: operations.hpp:2601
VecWriterProxy(FileStorage *_fs)
Definition: operations.hpp:2866
size_t tell() const
reports the current iterator position
Definition: operations.hpp:3690
FileNode operator*() const
returns the currently observed element
Definition: operations.hpp:3151
Definition: core.hpp:4385
_Tp area() const
the area (width*height)
Definition: operations.hpp:1884
GLdouble GLdouble GLdouble r
bool empty() const
Definition: operations.hpp:2455
bool empty() const
returns true iff obj==NULL
Definition: operations.hpp:2643
MatxCommaInitializer< _Tp, m, n > & operator,(T2 val)
int elemSize
Definition: core.hpp:2674
void deallocate()
deallocates the buffer if it was dynamically allocated
Definition: operations.hpp:2567
short float uchar uchar uchar uchar uchar ushort int uchar ushort int float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float int int int float int int int float int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP char CV_CUDEV_IMPLEMENT_VEC_BINARY_OP ushort CV_CUDEV_IMPLEMENT_VEC_BINARY_OP short CV_CUDEV_IMPLEMENT_VEC_BINARY_OP int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP uint CV_CUDEV_IMPLEMENT_VEC_BINARY_OP float CV_CUDEV_IMPLEMENT_VEC_BINARY_OP double char
Definition: vec_math.hpp:426
Vector(_Tp *_data, size_t _size, bool _copyData=false)
Definition: operations.hpp:2297
_Tp & back()
returns reference to the last sequence element
Definition: operations.hpp:3615
uchar * operator*()
returns pointer to the current pixel
Definition: operations.hpp:2515
CV_EXPORTS_W double norm(InputArray src1, int normType=NORM_L2, InputArray mask=noArray())
computes norm of the selected array part
CvPoint2D32f center
Definition: types_c.h:1175
CV_EXPORTS int _interlockedExchangeAdd(int *addr, int delta)
CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst)
computes square root of each matrix element (dst = src**0.5)
CvPoint2D32f pt[4]
Definition: imgproc_c.h:410
Definition: operations.hpp:716
_Tp dot(const Point3_ &pt) const
dot product
Definition: operations.hpp:1746
const _Tp * arr
Definition: operations.hpp:3436
CvSeq * seq
Definition: types_c.h:1838
GLenum GLint GLint y
Definition: core_c.h:613
CvFileNode * node
Definition: core_c.h:1638
CV_WRAP bool isNone() const
returns true if the node is a "none" object
Definition: operations.hpp:2933
Matx< _Tp, m, n > operator*() const
Definition: operations.hpp:1129
CvSeq * seq
Definition: core.hpp:4339
static Matx eye()
Definition: operations.hpp:344
Definition: operations.hpp:858
double operator()(const Matx< _Tp, m, m > &a) const
Definition: operations.hpp:718
Definition: types_c.h:1021
signed char schar
Definition: types_c.h:174
value_type work_type
Definition: core.hpp:1010
size_t capacity
Definition: operations.hpp:2286
Size_()
various constructors
Definition: operations.hpp:1857
CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high)
fills array with uniformly-distributed random numbers from the range [low, high)
const _Tp * end() const
Definition: operations.hpp:2375
CV_EXPORTS void seqRemoveSlice(CvSeq *seq, CvSlice slice)
Point_< _Tp > tl() const
the top-left corner
Definition: operations.hpp:1913
int CvScalar value
Definition: core_c.h:340
A short numerical vector.
Definition: core.hpp:84
_Tp y
Definition: core.hpp:805
_Tp & reference
Definition: operations.hpp:2276
CV_EXPORTS MatExpr operator!=(const Mat &a, const Mat &b)
bool operator()(const _Tp &a, const _Tp &b) const
Definition: operations.hpp:3428
const void * elem
Definition: core_c.h:1075
_Tp area() const
area (width*height) of the rectangle
Definition: operations.hpp:1948
Definition: operations.hpp:3768
Vec< _Tp, 4 > conjugate(const Vec< _Tp, 4 > &v)
Definition: operations.hpp:1229
CvPoint CvPoint pt2
Definition: core_c.h:1270
CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags)
sorts independently each matrix row or each matrix column
floating-point number
Definition: core.hpp:4127
_Tp * begin()
Definition: operations.hpp:2372
int start
Definition: core.hpp:990
_Tp z
Definition: core.hpp:805
CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev)
fills array with normally-distributed random numbers with the specified mean and the standard deviati...
int int void int total
Definition: core_c.h:1048
CV_WRAP FileNode root(int streamidx=0) const
returns the top-level mapping. YAML supports multiple streams
GLsizei const GLchar ** string
size_t elemSize() const
returns the size of each sequence element
Definition: operations.hpp:3597
static Matx zeros()
Definition: operations.hpp:332
Vector operator()(const Range &r) const
Definition: operations.hpp:2366
VecReaderProxy(FileNodeIterator *_it)
Definition: operations.hpp:3108
void delete_obj()
deletes the object. Override if needed
Definition: operations.hpp:2612
File Storage Node class.
Definition: core.hpp:4119
bool isReal() const
Definition: operations.hpp:2152
Definition: core.hpp:4059
CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags=DECOMP_LU)
computes inverse or pseudo-inverse matrix
void(Algorithm::* Setter)(int)
Definition: core.hpp:4455
class CV_EXPORTS FileNodeIterator
Definition: core.hpp:4107
CV_WRAP bool isMap() const
returns true if the node is a mapping
Definition: operations.hpp:2935
int i
Definition: types_c.h:1836
CvFileNode * operator*()
returns pointer to the underlying file node
Definition: operations.hpp:2947
CvSize CvPoint2D32f int count
Definition: calib3d.hpp:221
int type() const
Definition: operations.hpp:2457
Definition: types_c.h:951
Definition: types_c.h:1138
LineIterator & operator++()
prefix increment operator (++it). shifts iterator to the next pixel
Definition: operations.hpp:2516
Definition: core.hpp:3110
bool operator()(const Matx< _Tp, 3, 3 > &a, const Matx< _Tp, 3, 1 > &b, Matx< _Tp, 3, 1 > &x, int) const
Definition: operations.hpp:891
_Tp & front()
Definition: operations.hpp:2369
const CvSeq * seq
Definition: core_c.h:908
Ptr< _Tp2 > ptr()
cast pointer to another type
Definition: operations.hpp:2660
int end
Definition: core.hpp:990
_Tp * iterator
Definition: operations.hpp:2274
CvPoint2D32f float float b
Definition: legacy.hpp:578
Vector< _Tp > & push_back(const _Tp &elem)
Definition: operations.hpp:2438
const int * idx
Definition: core_c.h:323
void pop_back()
removes the last element from the sequence
Definition: operations.hpp:3633
static Range all()
Definition: operations.hpp:2219
Template Sequence Class derived from CvSeq.
Definition: core.hpp:4263
Definition: operations.hpp:3425
CvSize size
Definition: calib3d.hpp:212
The 2D range class.
Definition: core.hpp:979
_Tp & operator[](size_t i)
Definition: operations.hpp:2364
void copyTo(Vector< _Tp > &vec) const
Definition: operations.hpp:2341
CV_EXPORTS bool Cholesky(float *A, size_t astep, int m, float *b, size_t bstep, int n)
bool operator()(const _Tp &a, const _Tp &b) const
Definition: operations.hpp:3422
GLsizei GLsizei GLuint * obj
_Tp * obj
Definition: core.hpp:1302
GLuint src
Definition: core_c.h:1650
Vector(const Vector &d)
Definition: operations.hpp:2306
void remove(int idx)
removes element at the specified position
Definition: operations.hpp:3654
CV_EXPORTS float normL2Sqr_(const float *a, const float *b, int n)
int int int flags
Definition: highgui_c.h:186
Automatically Allocated Buffer Class.
Definition: core.hpp:3156
Vector(const std::vector< _Tp > &vec, bool _copyData=false)
Definition: operations.hpp:2303
int before_index
Definition: core_c.h:982
FileNodeIterator * it
Definition: operations.hpp:3102
CV_INLINE CvPoint cvPoint(int x, int y)
Definition: types_c.h:1029
const void * elements
Definition: core_c.h:973
GLuint index
Definition: core_c.h:986
Definition: types_c.h:1755
ptrdiff_t operator-(const SeqIterator< _Tp > &a, const SeqIterator< _Tp > &b)
Definition: operations.hpp:3746
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: core_c.h:403
int d
Definition: legacy.hpp:3064
_Tp x
Definition: core.hpp:766
CvRect r
Definition: core_c.h:1282
Range()
Definition: operations.hpp:2209
GLfloat angle
Definition: core_c.h:1297
Point_()
Definition: operations.hpp:1620
CvPoint center
Definition: core_c.h:1290
Definition: operations.hpp:3091
static Matx ones()
Definition: operations.hpp:338
struct CvSize2D32f CvSize2D32f
const _Tp * begin() const
Definition: operations.hpp:2374
CV_WRAP int type() const
returns type of the node
Definition: operations.hpp:2931
CV_WRAP void setAlgorithm(const string &name, const Ptr< Algorithm > &value)
CV_EXPORTS void clearSeq(CvSeq *seq)
size_t index(const _Tp &elem) const
returns index of the specified sequence element
Definition: operations.hpp:3600
Matx< _Tp, m, 1 > col(int i) const
extract the matrix column
Definition: operations.hpp:435
SeqIterator< _Tp > begin() const
returns iterator pointing to the beginning of the sequence
Definition: operations.hpp:3579
double val[4]
Definition: types_c.h:1225
GLXDrawable GLXDrawable read
_Tp re
Definition: core.hpp:714
Point3_ cross(const Point3_ &pt) const
cross product of the 2 3D points
Definition: operations.hpp:1751
CV_EXPORTS MatExpr operator-(const Mat &a, const Mat &b)
Definition: types_c.h:1155
internal::ParamGenerator< T > Range(T start, T end, IncrementT step)
Definition: ts_gtest.h:15869
CV_EXPORTS_W bool solve(InputArray src1, InputArray src2, OutputArray dst, int flags=DECOMP_LU)
solves linear system or a least-square problem
The template scalar class.
Definition: core.hpp:941
diag_type diag() const
extract the matrix diagonal
Definition: operations.hpp:446
FileStorage * fs
Definition: operations.hpp:2799
CV_INLINE CvSize cvSize(int width, int height)
Definition: types_c.h:1145
uint64 state
Definition: core.hpp:2050
_Tp height
Definition: core.hpp:883
Definition: operations.hpp:2863
Vec()
default constructor
Definition: operations.hpp:1137
const CvArr CvArr int method
Definition: imgproc_c.h:281
void addParam(Algorithm &algo, const char *name, int &value, bool readOnly=false, int(Algorithm::*getter)()=0, void(Algorithm::*setter)(int)=0, const string &help=string())
const uchar * ptr0
Definition: core.hpp:2673
CV_EXPORTS_W void write(FileStorage &fs, const string &name, int value)
double ddot(const Point3_ &pt) const
dot product computed in double-precision arithmetics
Definition: operations.hpp:1748
AutoBuffer()
the default contructor
Definition: operations.hpp:2539
CV_INLINE int cvRound(double value)
Definition: types_c.h:308
CvRect rect
Definition: core_c.h:100
CV_EXPORTS string format(const char *fmt,...)
int saturate_cast< int >(float v)
Definition: operations.hpp:188
Definition: types_c.h:1202
RotatedRect()
various constructors
Definition: operations.hpp:2002
int tag
Definition: types_c.h:1830
The 2D size class.
Definition: core.hpp:81
void copyTo(std::vector< _Tp > &vec) const
Definition: operations.hpp:2351
unsigned next()
updates the state and returns the next 32-bit unsigned integer random number
Definition: operations.hpp:2482
const char const char * str
Definition: core_c.h:1552
Ptr< CvFileStorage > fs
the underlying C FileStorage structure
Definition: core.hpp:4101
RNG()
Definition: operations.hpp:2480
Matx< _Tp, 1, n > row(int i) const
extract the matrix row
Definition: operations.hpp:427
int err
Definition: core.hpp:2675
~AutoBuffer()
destructor. calls deallocate()
Definition: operations.hpp:2552
CV_INLINE CvTermCriteria cvTermCriteria(int type, int max_iter, double epsilon)
Definition: types_c.h:1007
CvPoint2D32f double CvTermCriteria criteria
Definition: calib3d.hpp:65
_Tp value_type
Definition: operations.hpp:2273
CV_WRAP FileNode()
the default constructor
Definition: operations.hpp:2925
CV_EXPORTS void * fastMalloc(size_t bufSize)
Allocates memory buffer.
CV_EXPORTS schar * getSeqElem(const CvSeq *seq, int index)
static Matx randu(_Tp a, _Tp b)
Definition: operations.hpp:379
bool operator()(const Matx< _Tp, m, m > &a, const Matx< _Tp, m, n > &b, Matx< _Tp, m, n > &x, int method) const
Definition: operations.hpp:860
FileStorage * fs
Definition: operations.hpp:2886
Definition: operations.hpp:2270
const _Tp & back() const
Definition: operations.hpp:2368
const CvArr * angle
Definition: core_c.h:613
Vec mul(const Vec< _Tp, cn > &v) const
per-element multiplication
Definition: operations.hpp:1217
CvMemStoragePos * pos
Definition: core_c.h:933
CV_EXPORTS std::ostream & operator<<(std::ostream &out, const TickMeter &tm)
Vec conj() const
conjugation (makes sense for complex numbers and quaternions)
CvFileNodeHash * map
Definition: types_c.h:1839
static int isInstance(const void *ptr)
Definition: operations.hpp:3771
static Matx randn(_Tp a, _Tp b)
Definition: operations.hpp:388
File Node Iterator.
Definition: core.hpp:4210
bool empty() const
Definition: operations.hpp:2218
LessThanIdx(const _Tp *_arr)
Definition: operations.hpp:3434
void set(Algorithm *algo, const char *name, int argType, const void *value, bool force=false) const
CV_WRAP bool isNamed() const
returns true if the node has a name
Definition: operations.hpp:2939
Vec< _Tp, 2 > conjugate(const Vec< _Tp, 2 > &v)
Definition: operations.hpp:1224
STL-style Sequence Iterator inherited from the CvSeqReader structure.
Definition: core.hpp:4249
int height
Definition: types_c.h:956
int minusDelta
Definition: core.hpp:2676
bool empty() const
returns true iff the sequence contains no elements
Definition: operations.hpp:3627
VecCommaInitializer< _Tp, m > & operator,(T2 val)
VecReaderProxy(FileNodeIterator *_it)
Definition: operations.hpp:3094
int width
Definition: highgui_c.h:130
bool operator()(int a, int b) const
Definition: operations.hpp:3443
int partition(const vector< _Tp > &_vec, vector< int > &labels, _EqPredicate predicate=_EqPredicate())
Definition: operations.hpp:3455
Complex conj() const
conjugation
Definition: operations.hpp:1509
static Vec all(_Tp alpha)
Definition: operations.hpp:1210
Scalar_< _Tp > conj() const
Definition: operations.hpp:2144
Definition: types_c.h:1364
template 3D point class.
Definition: core.hpp:777
int width
Definition: types_c.h:955
size_t size() const
returns the number of elements in the sequence
Definition: operations.hpp:3585
CvArr const CvMat * mat
Definition: core_c.h:700
Matx< _Tp, m1, n1 > get_minor(int i, int j) const
extract part of the matrix
Definition: operations.hpp:415
CV_EXPORTS int LU(float *A, size_t astep, int m, float *b, size_t bstep, int n)
_Tp y
Definition: core.hpp:883
void set(const string &name, int value)
A complex number class.
Definition: core.hpp:698
CV_EXPORTS_W void exp(InputArray src, OutputArray dst)
computes exponent of each matrix element (dst = e**src)
Ptr & operator=(const Ptr &ptr)
copy operator. Calls ptr.addref() and release() before copying the members
Definition: operations.hpp:2626
CV_EXPORTS MatExpr operator==(const Mat &a, const Mat &b)
size_t size
Definition: operations.hpp:2285
SeqIterator & operator--()
moves iterator to the previous sequence element
Definition: operations.hpp:3714
GLenum GLsizei GLsizei height
CV_EXPORTS void seqPop(CvSeq *seq, void *element=0)
SeqIterator & operator-=(int)
moves iterator backward by the specified offset (possibly negative)
Definition: operations.hpp:3741
GLclampf GLclampf GLclampf alpha
Definition: core_c.h:687
SeqIterator & operator+=(int)
moves iterator forward by the specified offset (possibly negative)
Definition: operations.hpp:3729
void addParam_(Algorithm &algo, const char *name, int argType, void *value, bool readOnly, Algorithm::Getter getter, Algorithm::Setter setter, const string &help=string())
int minusStep
Definition: core.hpp:2677
uchar * ptr
Definition: core.hpp:2672
void pop_front()
removes the first element from the sequence
Definition: operations.hpp:3636
Definition: types_c.h:258
the node has a name (i.e.
Definition: core.hpp:4138
Definition: operations.hpp:2279
const _Tp * arr
Definition: operations.hpp:3444
int channels() const
returns the number of channels in each sequence element
Definition: operations.hpp:3594
TermCriteria()
default constructor
Definition: operations.hpp:2507
static void write(CvFileStorage *_fs, const char *name, const void *ptr, CvAttrList)
Definition: operations.hpp:3802
CV_INLINE CvScalar cvScalar(double val0, double val1 CV_DEFAULT(0), double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0))
Definition: types_c.h:1229
_Tp & front()
returns reference to the first sequence element
Definition: operations.hpp:3621
CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst)
computes per-element minimum of two arrays (dst = min(src1, src2))
int index
Definition: core_c.h:309
~Ptr()
calls release()
Definition: operations.hpp:2617
Matx()
default constructor
Definition: operations.hpp:206
Vector(size_t _size)
Definition: operations.hpp:2290
CvSize int int int CvPoint int delta
Definition: core_c.h:1427
CV_EXPORTS schar * seqPush(CvSeq *seq, const void *element=0)
OutputArray dst
Definition: imgproc.hpp:823
Matx< _Tp, m, n > mul(const Matx< _Tp, m, n > &a) const
multiply two matrices element-wise
Definition: operations.hpp:704
void clear()
Definition: operations.hpp:2456
CvSize2D32f size
Definition: types_c.h:1176
Vector(const Vector &d, const Range &r_)
Definition: operations.hpp:2308
int y
Definition: types_c.h:954
CV_WRAP bool isInt() const
returns true if the node is an integer
Definition: operations.hpp:2936
size_t size_t CvMemStorage * storage
Definition: core_c.h:946
int width
Definition: types_c.h:1140
int const CvArr * from_arr
Definition: core_c.h:1066
CV_EXPORTS schar * seqPushFront(CvSeq *seq, const void *element=0)
CV_EXPORTS int normHamming(const uchar *a, const uchar *b, int n)
Scalar_()
various constructors
Definition: operations.hpp:2015
CV_EXPORTS void seqInsertSlice(CvSeq *seq, int before_index, const CvArr *from_arr)
GLfloat GLfloat GLfloat v2
SeqIterator()
the default constructor
Definition: operations.hpp:3675
const CvMat CvMat CvMat int k
Definition: legacy.hpp:3052
GLenum GLint x
Definition: core_c.h:632
Vector(size_t _size, const _Tp &val)
Definition: operations.hpp:2291
void copyTo(vector< _Tp > &vec, const Range &range=Range::all()) const
copies the whole sequence or the sequence slice to the specified vector
Definition: operations.hpp:3660
A short numerical vector.
Definition: core.hpp:446
CV_WRAP bool isSeq() const
returns true if the node is a sequence
Definition: operations.hpp:2934
void CvArr
Definition: types_c.h:196
GLuint GLuint GLsizei count
Definition: core_c.h:973
Vector< _Tp > clone() const
Definition: operations.hpp:2338
int fast_abs(uchar v)
Definition: operations.hpp:195
size_t size() const
Definition: operations.hpp:2453
CV_EXPORTS MatExpr abs(const Mat &m)
void operator()(const vector< _Tp > &vec) const
Definition: operations.hpp:2867
struct CvFileStorage CvFileStorage
Definition: types_c.h:1740
double ddot(const Point_ &pt) const
dot product computed in double-precision arithmetics
Definition: operations.hpp:1642
CvSlice slice
Definition: core_c.h:1053
void allocate(size_t _size)
allocates the new buffer of size _size. if the _size is small enough, stack-allocated buffer is used ...
Definition: operations.hpp:2555
_Tp x
Definition: core.hpp:883
static CV_WRAP Ptr< Algorithm > _create(const string &name)
_Tp * datastart
Definition: operations.hpp:2283
CvPoint2D32f float float float c
Definition: legacy.hpp:578
int plusDelta
Definition: core.hpp:2676
Definition: types_c.h:1828
Informative template class for OpenCV "scalars".
Definition: core.hpp:1006
Point_< _Tp > br() const
the bottom-right corner
Definition: operations.hpp:1914
_Tp * data
Definition: operations.hpp:2281
CV_EXPORTS MatExpr operator<(const Mat &a, const Mat &b)
CV_EXPORTS void seqPopMulti(CvSeq *seq, void *elements, int count, int in_front=0)
_Tp x
Definition: core.hpp:805
FileNodeIterator end() const
returns iterator pointing to the element following the last node element
Definition: operations.hpp:3146
SeqIterator< _Tp > end() const
returns iterator pointing to the element following the last sequence element
Definition: operations.hpp:3582
GLenum const GLvoid * addr
void addref()
Definition: operations.hpp:2377
const char CvPoint org
Definition: core_c.h:1407
CV_INLINE CvPoint3D32f cvPoint3D32f(double x, double y, double z)
Definition: types_c.h:1084
void release()
Definition: operations.hpp:2378
int depth() const
returns the depth of sequence elements (CV_8U ... CV_64F)
Definition: operations.hpp:3591
int(Algorithm::* Getter)() const
Definition: core.hpp:4454
Definition: types_c.h:645
an integer
Definition: core.hpp:4126
Seq()
the default constructor
Definition: operations.hpp:3560
void reserve(size_t newCapacity)
Definition: operations.hpp:2406
XML/YAML File Storage Class.
Definition: core.hpp:4040
void push_back(const _Tp &elem)
appends the specified element to the end of the sequence
Definition: operations.hpp:3603
Vec< _Tp, m > operator*() const
Definition: operations.hpp:1497
GLboolean GLboolean GLboolean b
Definition: legacy.hpp:633
The n-dimensional matrix class.
Definition: core.hpp:1688
const _Tp * const_iterator
Definition: operations.hpp:2275
bool operator()(const Matx< _Tp, m, m > &a, Matx< _Tp, m, m > &b, int method) const
Definition: operations.hpp:785
struct CvPoint2D32f CvPoint2D32f
CV_EXPORTS_W Scalar trace(InputArray mtx)
computes trace of a matrix
void set(_Tp *_data, size_t _size, bool _copyData=false)
Definition: operations.hpp:2388
Matx< _Tp, m1, n1 > reshape() const
change the matrix shape
Definition: operations.hpp:406
Definition: types_c.h:997
void seek(size_t pos)
positions the iterator within the sequence
Definition: operations.hpp:3684
int int y
Definition: highgui_c.h:186
double f
Definition: types_c.h:1835
void operator()(vector< _Tp > &vec, size_t count) const
Definition: operations.hpp:3109
Definition: core.hpp:3121
GLsizei const GLfloat * value
Definition: core_c.h:341
Point_< int > Point2i
Definition: core.hpp:892
float angle
Definition: types_c.h:1177
OutputArray OutputArray labels
Definition: imgproc.hpp:823
int plusStep
Definition: core.hpp:2677
Matx< _Tp, n, l > solve(const Matx< _Tp, m, l > &rhs, int flags=DECOMP_LU) const
solve linear system
Definition: operations.hpp:915
static Scalar_< _Tp > all(_Tp v0)
returns a scalar with all elements set to v0
Definition: operations.hpp:2032
void get(const Algorithm *algo, const char *name, int argType, void *value) const
ParamType< _Tp >::member_type get(const string &name) const
Definition: operations.hpp:4007
Ptr()
empty constructor
Definition: operations.hpp:2586
Hdr()
Definition: operations.hpp:2281
_Tp val[m *n]
Definition: core.hpp:544
_Tp im
Definition: core.hpp:714
GLuint GLuint GLsizei GLenum type
Definition: core_c.h:114
GLenum const GLfloat * params
Definition: compat.hpp:688
union CvFileNode::@104 data
CV_INLINE CvPoint2D32f cvPoint2D32f(double x, double y)
Definition: types_c.h:1048
const GLubyte * c
Definition: legacy.hpp:633
CvPoint pt1
Definition: core_c.h:1270
CV_WRAP bool isString() const
returns true if the node is a text string
Definition: operations.hpp:2938
void writeRaw(const string &fmt, const uchar *vec, size_t len)
writes one or more numbers of the specified format to the currently written structure ...
CV_EXPORTS MatExpr operator|(const Mat &a, const Mat &b)
CvScalar scale
Definition: core_c.h:518
GLuint const GLchar * name
Definition: core_c.h:1546
VecWriterProxy(FileStorage *_fs)
Definition: operations.hpp:2879
CV_INLINE CvSize2D32f cvSize2D32f(double width, double height)
Definition: types_c.h:1163
int int channels
Definition: core_c.h:73
FileStorage * fs
Definition: operations.hpp:2873
Definition: types_c.h:1173
unsigned short ushort
Definition: types_c.h:171
template 2D point class.
Definition: core.hpp:82
const _Tp & const_reference
Definition: operations.hpp:2277
Definition: operations.hpp:2793
CV_EXPORTS_W void log(InputArray src, OutputArray dst)
computes natural logarithm of absolute value of each matrix element: dst = log(abs(src)) ...
CvPoint2D32f CvPoint2D32f CvPoint2D32f CvPoint2D32f * cross
Definition: legacy.hpp:577
Complex()
constructors
Definition: operations.hpp:1505
CvArr double sp
Definition: imgproc_c.h:125
_Tp width
Definition: core.hpp:840
double ddot(const Matx< _Tp, m, n > &v) const
dot product computed in double-precision arithmetics
Definition: operations.hpp:360
MatxCommaInitializer(Matx< _Tp, m, n > *_mtx)
Definition: operations.hpp:1116
Definition: types_c.h:1223
const char * ptr
Definition: core_c.h:942
_Tp & operator*()
returns reference to the current sequence element
Definition: operations.hpp:3693
CV_EXPORTS MatExpr operator/(const Mat &a, const Mat &b)
static Ptr< _Tp > create(const string &name)
Definition: operations.hpp:3970
CV_WRAP bool isReal() const
returns true if the node is a floating-point number
Definition: operations.hpp:2937
GLboolean GLboolean GLboolean GLboolean a
Definition: legacy.hpp:633
static void * clone(const void *ptr)
Definition: operations.hpp:3812
virtual AlgorithmInfo * info() const
Definition: core.hpp:4461
const _Tp & operator()(int i, int j) const
element access
Definition: operations.hpp:456
CV_EXPORTS void fastFree(void *ptr)
Frees the memory allocated with cv::fastMalloc.
Definition: operations.hpp:3431
Size_ & operator=(const Size_ &sz)
Definition: operations.hpp:1876
Matx< _Tp, n, m > inv(int method=DECOMP_LU) const
invert matrix the matrix
Definition: operations.hpp:843
CV_INLINE CvSlice cvSlice(int start, int end)
Definition: types_c.h:1208
Base class for high-level OpenCV algorithms.
Definition: core.hpp:4390
bool operator()(const Matx< _Tp, 3, 3 > &a, Matx< _Tp, 3, 3 > &b, int) const
Definition: operations.hpp:820
const void * element
Definition: core_c.h:1002
void push_front(const _Tp &elem)
appends the specified element to the front of the sequence
Definition: operations.hpp:3606
Scalar_< _Tp > mul(const Scalar_< _Tp > &t, double scale=1) const
per-element product
Definition: operations.hpp:2072
Point3_()
Definition: operations.hpp:1726
The 2D up-right rectangle class.
Definition: core.hpp:83
int n
Definition: legacy.hpp:3070
CvArr * arr
Definition: core_c.h:649
Definition: operations.hpp:3439
_Tp y
Definition: core.hpp:766
size_t capacity() const
Definition: operations.hpp:2454
void normalize(float *array, size_t length, float maxValue=1)
unsigned char uchar
Definition: types_c.h:170
CV_EXPORTS MatExpr operator+(const Mat &a, const Mat &b)
Definition: core.hpp:4060
static void release(void **dbptr)
Definition: operations.hpp:3784
Definition: types_c.h:1333
Hdr hdr
Definition: operations.hpp:2460
_Tp & back()
Definition: operations.hpp:2367
Cv_iplAllocateImageData Cv_iplDeallocate deallocate
Definition: core_c.h:1512
GLuint dst
Definition: calib3d.hpp:134
CV_WRAP FileNode getFirstTopLevelNode() const
returns the first element of the top-level mapping
Definition: operations.hpp:3195
int int height
Definition: highgui_c.h:130
const CvFileNode * node
Definition: core.hpp:4201
bool operator()(const Matx< _Tp, 2, 2 > &a, const Matx< _Tp, 2, 1 > &b, Matx< _Tp, 2, 1 > &x, int) const
Definition: operations.hpp:875
FileNodeIterator begin() const
returns iterator pointing to the first node element
Definition: operations.hpp:3141
CV_EXPORTS float normL1_(const float *a, const float *b, int n)
FileNodeIterator & readRaw(const string &fmt, uchar *vec, size_t maxCount=(size_t) INT_MAX)
reads the next maxCount elements (or less, if the sequence/mapping last element occurs earlier) to th...
void * parent
Definition: core_c.h:1459
::max::max::max float
Definition: functional.hpp:326
unsigned operator()()
Definition: operations.hpp:2494
bool inside(const Rect_< _Tp > &r) const
checks whether the point is inside the specified rectangle
Definition: operations.hpp:1997
static Matx all(_Tp alpha)
Definition: operations.hpp:324
const CvArr const CvArr const CvArr CvArr * X
Definition: core_c.h:733
CV_EXPORTS void seqRemove(CvSeq *seq, int index)
Line iterator class.
Definition: core.hpp:2657
bool operator()(const Matx< _Tp, 2, 2 > &a, Matx< _Tp, 2, 2 > &b, int) const
Definition: operations.hpp:803
int uniform(int a, int b)
returns uniformly distributed integer random number from [a,b) range
Definition: operations.hpp:2503
Rect_ & operator=(const Rect_ &r)
Definition: operations.hpp:1910
::max::max int
Definition: functional.hpp:324
int index
Definition: core.hpp:4377
Definition: core.hpp:4134
int * refcount
Definition: core.hpp:1303
CV_EXPORTS_W double determinant(InputArray mtx)
computes determinant of a square matrix
void operator()(vector< _Tp > &vec, size_t count) const
Definition: operations.hpp:3095
GLubyte GLubyte GLubyte GLubyte w
CvPoint2D32f float a
Definition: legacy.hpp:578
CV_EXPORTS void writeScalar(FileStorage &fs, int value)
Definition: types_c.h:1075
int x
Definition: highgui_c.h:186
FileNode operator->() const
accesses the currently observed element methods
Definition: operations.hpp:3154
Point pos() const
returns coordinates of the current pixel
Definition: operations.hpp:2529
Smart pointer to dynamically allocated objects.
Definition: core.hpp:1268
Size_< _Tp > size() const
size (width, height) of the rectangle
Definition: operations.hpp:1947
GLboolean GLenum GLenum GLvoid * values
int type() const
returns the type of sequence elements (CV_8UC1 ... CV_64FC(CV_CN_MAX) ...)
Definition: operations.hpp:3588
Definition: types_c.h:219
CV_EXPORTS void swap(Mat &a, Mat &b)
swaps two matrices
_Tp * end()
Definition: operations.hpp:2373
short
Definition: vec_math.hpp:153
const CvMat * B
Definition: calib3d.hpp:161
int step
Definition: core.hpp:2674
float x
Definition: types_c.h:1042
CV_EXPORTS void seqPopFront(CvSeq *seq, void *element=0)
class CV_EXPORTS FileNode
Definition: core.hpp:3941
_Tp height
Definition: core.hpp:840
CvArr CvArr * temp
Definition: imgproc_c.h:242
int x
Definition: types_c.h:953
const _Tp & front() const
Definition: operations.hpp:2370
const CvArr * right
Definition: calib3d.hpp:353
unsigned __int64 uint64
Definition: types_c.h:159
Definition: types_c.h:1040
CV_WRAP size_t size() const
returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise.
Definition: operations.hpp:2940
GLenum GLenum GLenum GLenum GLenum scale
Vector< _Tp > & pop_back()
Definition: operations.hpp:2446
void operator()(const vector< _Tp > &vec) const
Definition: operations.hpp:2880
Definition: operations.hpp:3419
const CvMat CvSize double alpha
Definition: calib3d.hpp:126
Point_ & operator=(const Point_ &pt)
Definition: operations.hpp:1628
Vector(const Vec< _Tp, n > &vec)
Definition: operations.hpp:2300
GLenum GLint GLuint mask
Definition: tracking.hpp:132
int * refcount
Definition: operations.hpp:2284
mapping
Definition: core.hpp:4133
Vector< _Tp > & operator=(const Vector &d)
Definition: operations.hpp:2324
CvArr const CvArr * mask
Definition: core_c.h:288
SeqIterator & operator++()
moves iterator to the next sequence element
Definition: operations.hpp:3699
DataType< _Tp >::work_type dot(const Vector< _Tp > &v1, const Vector< _Tp > &v2)
Definition: operations.hpp:2465
void insert(int idx, const _Tp &elem)
inserts the specified element to the specified position
Definition: operations.hpp:3645
void resize(size_t newSize)
Definition: operations.hpp:2425
int size() const
Definition: operations.hpp:2217
CV_EXPORTS MatExpr operator&(const Mat &a, const Mat &b)
double cross(const Point_ &pt) const
cross-product
Definition: operations.hpp:1645
FileNodeIterator * it
Definition: operations.hpp:3119
bool contains(const Point_< _Tp > &pt) const
checks whether the rectangle contains the point
Definition: operations.hpp:1957
void clear()
removes all the elements from the sequence
Definition: operations.hpp:3630
Point3_ & operator=(const Point3_ &pt)
Definition: operations.hpp:1743
CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst)
raises the input matrix elements to the specified power (b = a**power)
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
_Tp dot(const Matx< _Tp, m, n > &v) const
dot product computed with the default precision
Definition: operations.hpp:352
Scalar_< double > Scalar
Definition: core.hpp:968
bool operator()(int a, int b) const
Definition: operations.hpp:3435
CV_INLINE CvRect cvRect(int x, int y, int width, int height)
Definition: types_c.h:960
_Tp & operator[](int idx)
returns read-write reference to the specified element
Definition: operations.hpp:3573
Rect_()
various constructors
Definition: operations.hpp:1899
static void * read(CvFileStorage *fs, CvFileNode *n)
Definition: operations.hpp:3792
GreaterEqIdx(const _Tp *_arr)
Definition: operations.hpp:3442
Rect_< int > Rect
Definition: core.hpp:897
CV_WRAP bool empty() const
returns true if the node is empty
Definition: operations.hpp:2932
const CvArr * next
Definition: tracking.hpp:102
_Tp * operator->()
helper operators making "Ptr ptr" use very similar to "T* ptr".
Definition: operations.hpp:2637
Matx< _Tp, n, m > t() const
transpose the matrix
Definition: operations.hpp:777
_Tp width
Definition: core.hpp:883
Definition: operations.hpp:783
short float uchar uchar uchar uchar uchar ushort int uchar ushort int float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float float int int int float int int int float int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP char CV_CUDEV_IMPLEMENT_VEC_BINARY_OP ushort CV_CUDEV_IMPLEMENT_VEC_BINARY_OP short CV_CUDEV_IMPLEMENT_VEC_BINARY_OP int CV_CUDEV_IMPLEMENT_VEC_BINARY_OP uint CV_CUDEV_IMPLEMENT_VEC_BINARY_OP float CV_CUDEV_IMPLEMENT_VEC_BINARY_OP double int int uint double
Definition: vec_math.hpp:432
struct CvPoint3D32f CvPoint3D32f
text string in UTF-8 encoding
Definition: core.hpp:4129
_Tp dot(const Point_ &pt) const
dot product
Definition: operations.hpp:1640
void addref()
increments the reference counter
Definition: operations.hpp:2598
Vector()
Definition: operations.hpp:2289
~Vector()
Definition: operations.hpp:2336
void readRaw(const string &fmt, uchar *vec, size_t len) const
reads node elements to the buffer with the specified format
Definition: operations.hpp:3086
GLfloat GLfloat GLfloat GLfloat v3