mirror of https://github.com/opencv/opencv.git
parent
5e7ab8baf3
commit
d2192c0759
6 changed files with 556 additions and 381 deletions
@ -0,0 +1,187 @@ |
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_BASE_HPP__ |
||||
#define __OPENCV_CORE_BASE_HPP__ |
||||
|
||||
#include "opencv2/core/cvdef.h" |
||||
|
||||
namespace cv |
||||
{ |
||||
|
||||
// matrix decomposition types
|
||||
enum { DECOMP_LU = 0, |
||||
DECOMP_SVD = 1, |
||||
DECOMP_EIG = 2, |
||||
DECOMP_CHOLESKY = 3, |
||||
DECOMP_QR = 4, |
||||
DECOMP_NORMAL = 16 |
||||
}; |
||||
|
||||
// norm types
|
||||
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 |
||||
}; |
||||
|
||||
// comparison types
|
||||
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 |
||||
}; |
||||
|
||||
|
||||
|
||||
/////////////// saturate_cast (used in image & signal processing) ///////////////////
|
||||
|
||||
template<typename _Tp> static inline _Tp saturate_cast(uchar v) { return _Tp(v); } |
||||
template<typename _Tp> static inline _Tp saturate_cast(schar v) { return _Tp(v); } |
||||
template<typename _Tp> static inline _Tp saturate_cast(ushort v) { return _Tp(v); } |
||||
template<typename _Tp> static inline _Tp saturate_cast(short v) { return _Tp(v); } |
||||
template<typename _Tp> static inline _Tp saturate_cast(unsigned v) { return _Tp(v); } |
||||
template<typename _Tp> static inline _Tp saturate_cast(int v) { return _Tp(v); } |
||||
template<typename _Tp> static inline _Tp saturate_cast(float v) { return _Tp(v); } |
||||
template<typename _Tp> static inline _Tp saturate_cast(double v) { return _Tp(v); } |
||||
|
||||
template<> inline uchar saturate_cast<uchar>(schar v) { return (uchar)std::max((int)v, 0); } |
||||
template<> inline uchar saturate_cast<uchar>(ushort v) { return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); } |
||||
template<> inline uchar saturate_cast<uchar>(int v) { return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); } |
||||
template<> inline uchar saturate_cast<uchar>(short v) { return saturate_cast<uchar>((int)v); } |
||||
template<> inline uchar saturate_cast<uchar>(unsigned v) { return (uchar)std::min(v, (unsigned)UCHAR_MAX); } |
||||
template<> inline uchar saturate_cast<uchar>(float v) { int iv = cvRound(v); return saturate_cast<uchar>(iv); } |
||||
template<> inline uchar saturate_cast<uchar>(double v) { int iv = cvRound(v); return saturate_cast<uchar>(iv); } |
||||
|
||||
template<> inline schar saturate_cast<schar>(uchar v) { return (schar)std::min((int)v, SCHAR_MAX); } |
||||
template<> inline schar saturate_cast<schar>(ushort v) { return (schar)std::min((unsigned)v, (unsigned)SCHAR_MAX); } |
||||
template<> inline schar saturate_cast<schar>(int v) { return (schar)((unsigned)(v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ? v : v > 0 ? SCHAR_MAX : SCHAR_MIN); } |
||||
template<> inline schar saturate_cast<schar>(short v) { return saturate_cast<schar>((int)v); } |
||||
template<> inline schar saturate_cast<schar>(unsigned v) { return (schar)std::min(v, (unsigned)SCHAR_MAX); } |
||||
template<> inline schar saturate_cast<schar>(float v) { int iv = cvRound(v); return saturate_cast<schar>(iv); } |
||||
template<> inline schar saturate_cast<schar>(double v) { int iv = cvRound(v); return saturate_cast<schar>(iv); } |
||||
|
||||
template<> inline ushort saturate_cast<ushort>(schar v) { return (ushort)std::max((int)v, 0); } |
||||
template<> inline ushort saturate_cast<ushort>(short v) { return (ushort)std::max((int)v, 0); } |
||||
template<> inline ushort saturate_cast<ushort>(int v) { return (ushort)((unsigned)v <= (unsigned)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); } |
||||
template<> inline ushort saturate_cast<ushort>(unsigned v) { return (ushort)std::min(v, (unsigned)USHRT_MAX); } |
||||
template<> inline ushort saturate_cast<ushort>(float v) { int iv = cvRound(v); return saturate_cast<ushort>(iv); } |
||||
template<> inline ushort saturate_cast<ushort>(double v) { int iv = cvRound(v); return saturate_cast<ushort>(iv); } |
||||
|
||||
template<> inline short saturate_cast<short>(ushort v) { return (short)std::min((int)v, SHRT_MAX); } |
||||
template<> inline short saturate_cast<short>(int v) { return (short)((unsigned)(v - SHRT_MIN) <= (unsigned)USHRT_MAX ? v : v > 0 ? SHRT_MAX : SHRT_MIN); } |
||||
template<> inline short saturate_cast<short>(unsigned v) { return (short)std::min(v, (unsigned)SHRT_MAX); } |
||||
template<> inline short saturate_cast<short>(float v) { int iv = cvRound(v); return saturate_cast<short>(iv); } |
||||
template<> inline short saturate_cast<short>(double v) { int iv = cvRound(v); return saturate_cast<short>(iv); } |
||||
|
||||
template<> inline int saturate_cast<int>(float v) { return cvRound(v); } |
||||
template<> inline int saturate_cast<int>(double v) { return cvRound(v); } |
||||
|
||||
// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
|
||||
template<> inline unsigned saturate_cast<unsigned>(float v) { return cvRound(v); } |
||||
template<> inline unsigned saturate_cast<unsigned>(double v) { return cvRound(v); } |
||||
|
||||
|
||||
|
||||
////////////////// forward declarations for important OpenCV types //////////////////
|
||||
|
||||
template<typename _Tp, int cn> class CV_EXPORTS Vec; |
||||
template<typename _Tp, int m, int n> class CV_EXPORTS Matx; |
||||
|
||||
template<typename _Tp> class CV_EXPORTS Complex; |
||||
template<typename _Tp> class CV_EXPORTS Point_; |
||||
template<typename _Tp> class CV_EXPORTS Point3_; |
||||
template<typename _Tp> class CV_EXPORTS Size_; |
||||
template<typename _Tp> class CV_EXPORTS Rect_; |
||||
template<typename _Tp> class CV_EXPORTS Scalar_; |
||||
|
||||
class CV_EXPORTS RotatedRect; |
||||
class CV_EXPORTS Range; |
||||
class CV_EXPORTS TermCriteria; |
||||
class CV_EXPORTS KeyPoint; |
||||
class CV_EXPORTS DMatch; |
||||
|
||||
class CV_EXPORTS Mat; |
||||
class CV_EXPORTS SparseMat; |
||||
typedef Mat MatND; |
||||
|
||||
template<typename _Tp> class CV_EXPORTS Mat_; |
||||
template<typename _Tp> class CV_EXPORTS MatIterator_; |
||||
template<typename _Tp> class CV_EXPORTS MatConstIterator_; |
||||
|
||||
namespace ogl |
||||
{ |
||||
class CV_EXPORTS Buffer; |
||||
class CV_EXPORTS Texture2D; |
||||
class CV_EXPORTS Arrays; |
||||
} |
||||
|
||||
namespace gpu |
||||
{ |
||||
class CV_EXPORTS GpuMat; |
||||
} |
||||
|
||||
} // cv
|
||||
|
||||
#endif //__OPENCV_CORE_BASE_HPP__
|
@ -0,0 +1,362 @@ |
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_MATX_HPP__ |
||||
#define __OPENCV_CORE_MATX_HPP__ |
||||
|
||||
#include "opencv2/core/cvdef.h" |
||||
#include "opencv2/core/base.hpp" |
||||
#include "opencv2/core/traits.hpp" |
||||
|
||||
namespace cv |
||||
{ |
||||
|
||||
////////////////////////////// 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 = DataType<_Tp>::depth, |
||||
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 |
||||
*/ |
||||
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; |
||||
|
||||
/*!
|
||||
traits |
||||
*/ |
||||
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 = DataType<channel_type>::depth, |
||||
channels = m * n, |
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8), |
||||
type = CV_MAKETYPE(depth, channels) |
||||
}; |
||||
}; |
||||
|
||||
|
||||
|
||||
/////////////////////// Vec (used as element of multi-channel images /////////////////////
|
||||
|
||||
/*!
|
||||
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 = Matx<_Tp, cn, 1>::depth, |
||||
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; |
||||
|
||||
/*!
|
||||
traits |
||||
*/ |
||||
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 = DataType<channel_type>::depth, |
||||
channels = cn, |
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8), |
||||
type = CV_MAKETYPE(depth, channels) |
||||
}; |
||||
}; |
||||
|
||||
} // cv
|
||||
|
||||
#endif // __OPENCV_CORE_MATX_HPP__
|
@ -1,3 +1,4 @@ |
||||
include/opencv2/core/base.hpp |
||||
include/opencv2/core.hpp |
||||
include/opencv2/core/utility.hpp |
||||
../java/generator/src/cpp/core_manual.hpp |
||||
|
Loading…
Reference in new issue