Move cv::Matx and cv::Vec to separate header
This commit is contained in:
@@ -53,6 +53,9 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "opencv2/core/cvstd.hpp"
|
||||
#include "opencv2/core/base.hpp"
|
||||
#include "opencv2/core/traits.hpp"
|
||||
#include "opencv2/core/matx.hpp"
|
||||
#include "opencv2/core/types.hpp"
|
||||
|
||||
#ifndef SKIP_INCLUDES
|
||||
@@ -72,45 +75,13 @@
|
||||
*/
|
||||
namespace cv {
|
||||
|
||||
template<typename _Tp> class CV_EXPORTS Size_;
|
||||
template<typename _Tp> class CV_EXPORTS Point_;
|
||||
template<typename _Tp> class CV_EXPORTS Rect_;
|
||||
template<typename _Tp, int cn> class CV_EXPORTS Vec;
|
||||
template<typename _Tp, int m, int n> class CV_EXPORTS Matx;
|
||||
|
||||
class Mat;
|
||||
class SparseMat;
|
||||
typedef Mat MatND;
|
||||
|
||||
namespace ogl {
|
||||
class Buffer;
|
||||
class Texture2D;
|
||||
class Arrays;
|
||||
}
|
||||
|
||||
namespace gpu {
|
||||
class GpuMat;
|
||||
}
|
||||
|
||||
class CV_EXPORTS MatExpr;
|
||||
class CV_EXPORTS MatOp_Base;
|
||||
class CV_EXPORTS MatArg;
|
||||
class CV_EXPORTS MatConstIterator;
|
||||
|
||||
template<typename _Tp> class CV_EXPORTS Mat_;
|
||||
template<typename _Tp> class CV_EXPORTS MatIterator_;
|
||||
template<typename _Tp> class CV_EXPORTS MatConstIterator_;
|
||||
template<typename _Tp> class CV_EXPORTS MatCommaInitializer_;
|
||||
|
||||
// matrix decomposition types
|
||||
enum { DECOMP_LU=0, DECOMP_SVD=1, DECOMP_EIG=2, DECOMP_CHOLESKY=3, DECOMP_QR=4, DECOMP_NORMAL=16 };
|
||||
enum { NORM_INF=1, NORM_L1=2, NORM_L2=4, NORM_L2SQR=5, NORM_HAMMING=6, NORM_HAMMING2=7, NORM_TYPE_MASK=7, NORM_RELATIVE=8, NORM_MINMAX=32 };
|
||||
enum { CMP_EQ=0, CMP_GT=1, CMP_GE=2, CMP_LT=3, CMP_LE=4, CMP_NE=5 };
|
||||
enum { GEMM_1_T=1, GEMM_2_T=2, GEMM_3_T=4 };
|
||||
enum { DFT_INVERSE=1, DFT_SCALE=2, DFT_ROWS=4, DFT_COMPLEX_OUTPUT=16, DFT_REAL_OUTPUT=32,
|
||||
DCT_INVERSE = DFT_INVERSE, DCT_ROWS=DFT_ROWS };
|
||||
|
||||
|
||||
/*!
|
||||
The standard OpenCV exception class.
|
||||
Instances of the class are thrown by various functions and methods in the case of critical errors.
|
||||
@@ -239,298 +210,9 @@ public:
|
||||
void destroy(pointer p) { p->~_Tp(); }
|
||||
};
|
||||
|
||||
/////////////////////// Vec (used as element of multi-channel images /////////////////////
|
||||
|
||||
|
||||
////////////////////////////// Small Matrix ///////////////////////////
|
||||
|
||||
/*!
|
||||
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>.
|
||||
*/
|
||||
|
||||
struct CV_EXPORTS Matx_AddOp {};
|
||||
struct CV_EXPORTS Matx_SubOp {};
|
||||
struct CV_EXPORTS Matx_ScaleOp {};
|
||||
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:
|
||||
typedef _Tp value_type;
|
||||
typedef Matx<_Tp, (m < n ? 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) };
|
||||
|
||||
//! default constructor
|
||||
Matx();
|
||||
|
||||
Matx(_Tp v0); //!< 1x1 matrix
|
||||
Matx(_Tp v0, _Tp v1); //!< 1x2 or 2x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2); //!< 1x3 or 3x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 1x4, 2x2 or 4x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 1x5 or 5x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 1x6, 2x3, 3x2 or 6x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 1x7 or 7x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 1x8, 2x4, 4x2 or 8x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 1x9, 3x3 or 9x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 1x10, 2x5 or 5x2 or 10x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3,
|
||||
_Tp v4, _Tp v5, _Tp v6, _Tp v7,
|
||||
_Tp v8, _Tp v9, _Tp v10, _Tp v11); //!< 1x12, 2x6, 3x4, 4x3, 6x2 or 12x1 matrix
|
||||
Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3,
|
||||
_Tp v4, _Tp v5, _Tp v6, _Tp v7,
|
||||
_Tp v8, _Tp v9, _Tp v10, _Tp v11,
|
||||
_Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix
|
||||
explicit Matx(const _Tp* vals); //!< initialize from a plain array
|
||||
|
||||
static Matx all(_Tp alpha);
|
||||
static Matx zeros();
|
||||
static Matx ones();
|
||||
static Matx eye();
|
||||
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;
|
||||
|
||||
//! change the matrix shape
|
||||
template<int m1, int n1> Matx<_Tp, m1, n1> reshape() const;
|
||||
|
||||
//! extract part of the matrix
|
||||
template<int m1, int n1> Matx<_Tp, m1, n1> get_minor(int i, int j) const;
|
||||
|
||||
//! extract the matrix row
|
||||
Matx<_Tp, 1, n> row(int i) const;
|
||||
|
||||
//! extract the matrix column
|
||||
Matx<_Tp, m, 1> col(int i) const;
|
||||
|
||||
//! extract the matrix diagonal
|
||||
diag_type diag() const;
|
||||
|
||||
//! transpose the matrix
|
||||
Matx<_Tp, n, m> t() const;
|
||||
|
||||
//! invert matrix the matrix
|
||||
Matx<_Tp, n, m> inv(int method=DECOMP_LU) const;
|
||||
|
||||
//! 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;
|
||||
|
||||
//! multiply two matrices element-wise
|
||||
Matx<_Tp, m, n> mul(const Matx<_Tp, m, n>& a) const;
|
||||
|
||||
//! element access
|
||||
const _Tp& operator ()(int i, int j) const;
|
||||
_Tp& operator ()(int i, int j);
|
||||
|
||||
//! 1D element access
|
||||
const _Tp& operator ()(int i) const;
|
||||
_Tp& operator ()(int i);
|
||||
|
||||
Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp);
|
||||
Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp);
|
||||
template<typename _T2> Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp);
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
typedef Matx<float, 1, 2> Matx12f;
|
||||
typedef Matx<double, 1, 2> Matx12d;
|
||||
typedef Matx<float, 1, 3> Matx13f;
|
||||
typedef Matx<double, 1, 3> Matx13d;
|
||||
typedef Matx<float, 1, 4> Matx14f;
|
||||
typedef Matx<double, 1, 4> Matx14d;
|
||||
typedef Matx<float, 1, 6> Matx16f;
|
||||
typedef Matx<double, 1, 6> Matx16d;
|
||||
|
||||
typedef Matx<float, 2, 1> Matx21f;
|
||||
typedef Matx<double, 2, 1> Matx21d;
|
||||
typedef Matx<float, 3, 1> Matx31f;
|
||||
typedef Matx<double, 3, 1> Matx31d;
|
||||
typedef Matx<float, 4, 1> Matx41f;
|
||||
typedef Matx<double, 4, 1> Matx41d;
|
||||
typedef Matx<float, 6, 1> Matx61f;
|
||||
typedef Matx<double, 6, 1> Matx61d;
|
||||
|
||||
typedef Matx<float, 2, 2> Matx22f;
|
||||
typedef Matx<double, 2, 2> Matx22d;
|
||||
typedef Matx<float, 2, 3> Matx23f;
|
||||
typedef Matx<double, 2, 3> Matx23d;
|
||||
typedef Matx<float, 3, 2> Matx32f;
|
||||
typedef Matx<double, 3, 2> Matx32d;
|
||||
|
||||
typedef Matx<float, 3, 3> Matx33f;
|
||||
typedef Matx<double, 3, 3> Matx33d;
|
||||
|
||||
typedef Matx<float, 3, 4> Matx34f;
|
||||
typedef Matx<double, 3, 4> Matx34d;
|
||||
typedef Matx<float, 4, 3> Matx43f;
|
||||
typedef Matx<double, 4, 3> Matx43d;
|
||||
|
||||
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;
|
||||
|
||||
//! conjugation (makes sense for complex numbers and quaternions)
|
||||
Vec conj() 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;
|
||||
|
||||
/*! element access */
|
||||
const _Tp& operator [](int i) const;
|
||||
_Tp& operator[](int i);
|
||||
const _Tp& operator ()(int i) const;
|
||||
_Tp& operator ()(int i);
|
||||
|
||||
Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp);
|
||||
Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp);
|
||||
template<typename _T2> Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp);
|
||||
};
|
||||
|
||||
|
||||
/* \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<int, 6> Vec6i;
|
||||
typedef Vec<int, 8> Vec8i;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
CV_EXPORTS void scalarToRawData(const Scalar& s, void* buf, int type, int unroll_to=0);
|
||||
|
||||
|
||||
/////////////////////////////// DataType ////////////////////////////////
|
||||
|
||||
template<typename _Tp, int m, int n> class DataType<Matx<_Tp, m, n> >
|
||||
{
|
||||
public:
|
||||
typedef Matx<_Tp, m, n> value_type;
|
||||
typedef Matx<typename DataType<_Tp>::work_type, m, n> work_type;
|
||||
typedef _Tp channel_type;
|
||||
typedef value_type vec_type;
|
||||
enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = m*n,
|
||||
fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt,
|
||||
type = CV_MAKETYPE(depth, channels) };
|
||||
};
|
||||
|
||||
template<typename _Tp, int cn> class DataType<Vec<_Tp, cn> >
|
||||
{
|
||||
public:
|
||||
typedef Vec<_Tp, cn> value_type;
|
||||
typedef Vec<typename DataType<_Tp>::work_type, cn> work_type;
|
||||
typedef _Tp channel_type;
|
||||
typedef value_type vec_type;
|
||||
enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = cn,
|
||||
fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt,
|
||||
type = CV_MAKETYPE(depth, channels) };
|
||||
};
|
||||
|
||||
|
||||
//////////////////// generic_type ref-counting pointer class for C/C++ objects ////////////////////////
|
||||
|
||||
/*!
|
||||
|
Reference in New Issue
Block a user