fixed some more tests on Windows; changed inheritance Matx -> Vec to Vec -> Matx
This commit is contained in:
@@ -399,104 +399,6 @@ template<> class DataDepth<float> { public: enum { value = CV_32F, fmt=(int)'f'
|
||||
template<> class DataDepth<double> { public: enum { value = CV_64F, fmt=(int)'d' }; };
|
||||
template<typename _Tp> class DataDepth<_Tp*> { public: enum { value = CV_USRTYPE1, fmt=(int)'r' }; };
|
||||
|
||||
/*!
|
||||
A short numerical vector.
|
||||
|
||||
This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements)
|
||||
on which you can perform basic arithmetical operations, access individual elements using [] operator etc.
|
||||
The vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc.,
|
||||
which elements are dynamically allocated in the heap.
|
||||
|
||||
The template takes 2 parameters:
|
||||
-# _Tp element type
|
||||
-# cn the number of elements
|
||||
|
||||
In addition to the universal notation like Vec<float, 3>, you can use shorter aliases
|
||||
for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>.
|
||||
*/
|
||||
template<typename _Tp, int cn> class CV_EXPORTS Vec
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
enum { depth = DataDepth<_Tp>::value, channels = cn, type = CV_MAKETYPE(depth, channels) };
|
||||
|
||||
//! default constructor
|
||||
Vec();
|
||||
|
||||
Vec(_Tp v0); //!< 1-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor
|
||||
explicit Vec(const _Tp* values);
|
||||
|
||||
Vec(const Vec<_Tp, cn>& v);
|
||||
static Vec all(_Tp alpha);
|
||||
//! dot product
|
||||
_Tp dot(const Vec& v) const;
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Vec& v) const;
|
||||
//! per-element multiplication
|
||||
Vec mul(const Vec<_Tp, cn>& v) const;
|
||||
|
||||
/*!
|
||||
cross product of the two 3D vectors.
|
||||
|
||||
For other dimensionalities the exception is raised
|
||||
*/
|
||||
Vec cross(const Vec& v) const;
|
||||
//! convertion to another data type
|
||||
template<typename T2> operator Vec<T2, cn>() const;
|
||||
//! conversion to 4-element CvScalar.
|
||||
operator CvScalar() const;
|
||||
|
||||
Matx<_Tp, 1, cn> t() const;
|
||||
|
||||
/*! element access */
|
||||
const _Tp& operator [](int i) const;
|
||||
_Tp& operator[](int i);
|
||||
const _Tp& operator ()(int i) const;
|
||||
_Tp& operator ()(int i);
|
||||
|
||||
_Tp val[cn]; //< vector elements
|
||||
};
|
||||
|
||||
|
||||
/* \typedef
|
||||
|
||||
Shorter aliases for the most popular specializations of Vec<T,n>
|
||||
*/
|
||||
typedef Vec<uchar, 2> Vec2b;
|
||||
typedef Vec<uchar, 3> Vec3b;
|
||||
typedef Vec<uchar, 4> Vec4b;
|
||||
|
||||
typedef Vec<short, 2> Vec2s;
|
||||
typedef Vec<short, 3> Vec3s;
|
||||
typedef Vec<short, 4> Vec4s;
|
||||
|
||||
typedef Vec<ushort, 2> Vec2w;
|
||||
typedef Vec<ushort, 3> Vec3w;
|
||||
typedef Vec<ushort, 4> Vec4w;
|
||||
|
||||
typedef Vec<int, 2> Vec2i;
|
||||
typedef Vec<int, 3> Vec3i;
|
||||
typedef Vec<int, 4> Vec4i;
|
||||
|
||||
typedef Vec<float, 2> Vec2f;
|
||||
typedef Vec<float, 3> Vec3f;
|
||||
typedef Vec<float, 4> Vec4f;
|
||||
typedef Vec<float, 6> Vec6f;
|
||||
|
||||
typedef Vec<double, 2> Vec2d;
|
||||
typedef Vec<double, 3> Vec3d;
|
||||
typedef Vec<double, 4> Vec4d;
|
||||
typedef Vec<double, 6> Vec6d;
|
||||
|
||||
|
||||
////////////////////////////// Small Matrix ///////////////////////////
|
||||
|
||||
@@ -523,12 +425,11 @@ struct CV_EXPORTS Matx_MulOp {};
|
||||
struct CV_EXPORTS Matx_MatMulOp {};
|
||||
struct CV_EXPORTS Matx_TOp {};
|
||||
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS Matx : public Vec<_Tp, m*n>
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS Matx
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
typedef Vec<_Tp, m*n> base_type;
|
||||
typedef Vec<_Tp, MIN(m, n)> diag_type;
|
||||
typedef Matx<_Tp, MIN(m, n), 1> diag_type;
|
||||
typedef Matx<_Tp, m, n> mat_type;
|
||||
enum { depth = DataDepth<_Tp>::value, rows = m, cols = n, channels = rows*cols,
|
||||
type = CV_MAKETYPE(depth, channels) };
|
||||
@@ -555,15 +456,20 @@ public:
|
||||
_Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
|
||||
explicit Matx(const _Tp* vals); //!< initialize from a plain array
|
||||
|
||||
Matx(const base_type& v);
|
||||
static Matx all(_Tp alpha);
|
||||
static Matx zeros();
|
||||
static Matx ones();
|
||||
static Matx eye();
|
||||
static Matx diag(const Vec<_Tp, MIN(m,n)>& d);
|
||||
static Matx diag(const diag_type& d);
|
||||
static Matx randu(_Tp a, _Tp b);
|
||||
static Matx randn(_Tp a, _Tp b);
|
||||
|
||||
//! dot product computed with the default precision
|
||||
_Tp dot(const Matx<_Tp, m, n>& v) const;
|
||||
|
||||
//! dot product computed in double-precision arithmetics
|
||||
double ddot(const Matx<_Tp, m, n>& v) const;
|
||||
|
||||
//! convertion to another data type
|
||||
template<typename T2> operator Matx<T2, m, n>() const;
|
||||
|
||||
@@ -577,10 +483,10 @@ public:
|
||||
Matx<_Tp, 1, n> row(int i) const;
|
||||
|
||||
//! extract the matrix column
|
||||
Vec<_Tp, m> col(int i) const;
|
||||
Matx<_Tp, m, 1> col(int i) const;
|
||||
|
||||
//! extract the matrix diagonal
|
||||
Vec<_Tp, MIN(m,n)> diag() const;
|
||||
Matx<_Tp, MIN(m,n), 1> diag() const;
|
||||
|
||||
//! transpose the matrix
|
||||
Matx<_Tp, n, m> t() const;
|
||||
@@ -590,7 +496,7 @@ public:
|
||||
|
||||
//! solve linear system
|
||||
template<int l> Matx<_Tp, n, l> solve(const Matx<_Tp, m, l>& rhs, int flags=DECOMP_LU) const;
|
||||
Vec<_Tp, n> solve(const Vec<_Tp, m>& rhs, int method) const;
|
||||
Matx<_Tp, n, 1> solve(const Matx<_Tp, m, 1>& rhs, int method) const;
|
||||
|
||||
//! multiply two matrices element-wise
|
||||
Matx<_Tp, m, n> mul(const Matx<_Tp, m, n>& a) const;
|
||||
@@ -609,6 +515,8 @@ public:
|
||||
Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp);
|
||||
template<int l> Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp);
|
||||
Matx(const Matx<_Tp, n, m>& a, Matx_TOp);
|
||||
|
||||
_Tp val[m*n]; //< matrix elements
|
||||
};
|
||||
|
||||
|
||||
@@ -649,7 +557,100 @@ typedef Matx<float, 4, 4> Matx44f;
|
||||
typedef Matx<double, 4, 4> Matx44d;
|
||||
typedef Matx<float, 6, 6> Matx66f;
|
||||
typedef Matx<double, 6, 6> Matx66d;
|
||||
|
||||
|
||||
/*!
|
||||
A short numerical vector.
|
||||
|
||||
This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements)
|
||||
on which you can perform basic arithmetical operations, access individual elements using [] operator etc.
|
||||
The vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc.,
|
||||
which elements are dynamically allocated in the heap.
|
||||
|
||||
The template takes 2 parameters:
|
||||
-# _Tp element type
|
||||
-# cn the number of elements
|
||||
|
||||
In addition to the universal notation like Vec<float, 3>, you can use shorter aliases
|
||||
for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>.
|
||||
*/
|
||||
template<typename _Tp, int cn> class CV_EXPORTS Vec : public Matx<_Tp, cn, 1>
|
||||
{
|
||||
public:
|
||||
typedef _Tp value_type;
|
||||
enum { depth = DataDepth<_Tp>::value, channels = cn, type = CV_MAKETYPE(depth, channels) };
|
||||
|
||||
//! default constructor
|
||||
Vec();
|
||||
|
||||
Vec(_Tp v0); //!< 1-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor
|
||||
Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor
|
||||
explicit Vec(const _Tp* values);
|
||||
|
||||
Vec(const Vec<_Tp, cn>& v);
|
||||
static Vec all(_Tp alpha);
|
||||
|
||||
//! per-element multiplication
|
||||
Vec mul(const Vec<_Tp, cn>& v) const;
|
||||
|
||||
/*!
|
||||
cross product of the two 3D vectors.
|
||||
|
||||
For other dimensionalities the exception is raised
|
||||
*/
|
||||
Vec cross(const Vec& v) const;
|
||||
//! convertion to another data type
|
||||
template<typename T2> operator Vec<T2, cn>() const;
|
||||
//! conversion to 4-element CvScalar.
|
||||
operator CvScalar() const;
|
||||
|
||||
/*! element access */
|
||||
const _Tp& operator [](int i) const;
|
||||
_Tp& operator[](int i);
|
||||
const _Tp& operator ()(int i) const;
|
||||
_Tp& operator ()(int i);
|
||||
};
|
||||
|
||||
|
||||
/* \typedef
|
||||
|
||||
Shorter aliases for the most popular specializations of Vec<T,n>
|
||||
*/
|
||||
typedef Vec<uchar, 2> Vec2b;
|
||||
typedef Vec<uchar, 3> Vec3b;
|
||||
typedef Vec<uchar, 4> Vec4b;
|
||||
|
||||
typedef Vec<short, 2> Vec2s;
|
||||
typedef Vec<short, 3> Vec3s;
|
||||
typedef Vec<short, 4> Vec4s;
|
||||
|
||||
typedef Vec<ushort, 2> Vec2w;
|
||||
typedef Vec<ushort, 3> Vec3w;
|
||||
typedef Vec<ushort, 4> Vec4w;
|
||||
|
||||
typedef Vec<int, 2> Vec2i;
|
||||
typedef Vec<int, 3> Vec3i;
|
||||
typedef Vec<int, 4> Vec4i;
|
||||
|
||||
typedef Vec<float, 2> Vec2f;
|
||||
typedef Vec<float, 3> Vec3f;
|
||||
typedef Vec<float, 4> Vec4f;
|
||||
typedef Vec<float, 6> Vec6f;
|
||||
|
||||
typedef Vec<double, 2> Vec2d;
|
||||
typedef Vec<double, 3> Vec3d;
|
||||
typedef Vec<double, 4> Vec4d;
|
||||
typedef Vec<double, 6> Vec6d;
|
||||
|
||||
|
||||
//////////////////////////////// Complex //////////////////////////////
|
||||
|
||||
/*!
|
||||
@@ -918,8 +919,6 @@ public:
|
||||
|
||||
//! per-element product
|
||||
Scalar_<_Tp> mul(const Scalar_<_Tp>& t, double scale=1 ) const;
|
||||
//! another helper conversion method. \see cvScalarToRawData
|
||||
template<typename T2> void convertTo(T2* buf, int channels, int unroll_to=0) const;
|
||||
|
||||
// returns (v0, -v1, -v2, -v3)
|
||||
Scalar_<_Tp> conj() const;
|
||||
@@ -930,6 +929,8 @@ public:
|
||||
|
||||
typedef Scalar_<double> Scalar;
|
||||
|
||||
CV_EXPORTS void scalarToRawData(const Scalar& s, void* buf, int type, int unroll_to=0);
|
||||
|
||||
//////////////////////////////// Range /////////////////////////////////
|
||||
|
||||
/*!
|
||||
@@ -2784,28 +2785,25 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
template<typename _Tp, int n> class CV_EXPORTS VecCommaInitializer
|
||||
{
|
||||
public:
|
||||
VecCommaInitializer(Vec<_Tp, n>* _vec);
|
||||
template<typename T2> VecCommaInitializer<_Tp, n>& operator , (T2 val);
|
||||
Vec<_Tp, n> operator *() const;
|
||||
|
||||
Vec<_Tp, n>* vec;
|
||||
int idx;
|
||||
};
|
||||
|
||||
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS MatxCommaInitializer :
|
||||
public VecCommaInitializer<_Tp, m*n>
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS MatxCommaInitializer
|
||||
{
|
||||
public:
|
||||
MatxCommaInitializer(Matx<_Tp, m, n>* _mtx);
|
||||
template<typename T2> MatxCommaInitializer<_Tp, m, n>& operator , (T2 val);
|
||||
Matx<_Tp, m, n> operator *() const;
|
||||
|
||||
Matx<_Tp, m, n>* dst;
|
||||
int idx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename _Tp, int m> class CV_EXPORTS VecCommaInitializer : public MatxCommaInitializer<_Tp, m, 1>
|
||||
{
|
||||
public:
|
||||
VecCommaInitializer(Vec<_Tp, m>* _vec);
|
||||
template<typename T2> VecCommaInitializer<_Tp, m>& operator , (T2 val);
|
||||
Vec<_Tp, m> operator *() const;
|
||||
};
|
||||
|
||||
/*!
|
||||
Automatically Allocated Buffer Class
|
||||
|
||||
|
@@ -1873,15 +1873,15 @@ static inline MatConstIterator operator - (const MatConstIterator& a, ptrdiff_t
|
||||
|
||||
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
||||
operator + (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
|
||||
{ return (MatConstIterator_<_Tp>&)((const MatConstIterator&)a + ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatConstIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
||||
operator + (ptrdiff_t ofs, const MatConstIterator_<_Tp>& a)
|
||||
{ return (MatConstIterator_<_Tp>&)((const MatConstIterator&)a + ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatConstIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> static inline MatConstIterator_<_Tp>
|
||||
operator - (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs)
|
||||
{ return (MatConstIterator_<_Tp>&)((const MatConstIterator&)a - ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a - ofs; return (MatConstIterator_<_Tp>&)t; }
|
||||
|
||||
inline uchar* MatConstIterator::operator [](ptrdiff_t i) const
|
||||
{ return *(*this + i); }
|
||||
@@ -1891,15 +1891,15 @@ template<typename _Tp> inline _Tp MatConstIterator_<_Tp>::operator [](ptrdiff_t
|
||||
|
||||
template<typename _Tp> static inline MatIterator_<_Tp>
|
||||
operator + (const MatIterator_<_Tp>& a, ptrdiff_t ofs)
|
||||
{ return (MatIterator_<_Tp>&)((const MatConstIterator&)a + ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> static inline MatIterator_<_Tp>
|
||||
operator + (ptrdiff_t ofs, const MatIterator_<_Tp>& a)
|
||||
{ return (MatIterator_<_Tp>&)((const MatConstIterator&)a + ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> static inline MatIterator_<_Tp>
|
||||
operator - (const MatIterator_<_Tp>& a, ptrdiff_t ofs)
|
||||
{ return (MatIterator_<_Tp>&)((const MatConstIterator&)a - ofs); }
|
||||
{ MatConstIterator t = (const MatConstIterator&)a - ofs; return (MatIterator_<_Tp>&)t; }
|
||||
|
||||
template<typename _Tp> inline _Tp& MatIterator_<_Tp>::operator [](ptrdiff_t i) const
|
||||
{ return *(*this + i); }
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user