OpenCV  4.5.2
Open Source Computer Vision
Modules | Namespaces | Classes | Typedefs | Enumerations | Functions
Core functionality

Modules

 Basic structures
 
 C structures and operations
 
 Operations on arrays
 
 Asynchronous API
 
 XML/YAML Persistence
 
 Clustering
 
 Utility and system functions and macros
 
 OpenGL interoperability
 
 Intel IPP Asynchronous C/C++ Converters
 
 Optimization Algorithms
 
 DirectX interoperability
 
 Eigen support
 
 OpenCL support
 
 Intel VA-API/OpenCL (CL-VA) interoperability
 
 Hardware Acceleration Layer
 
 Parallel Processing
 

Namespaces

 cv::traits
 

Classes

class  cv::Affine3< T >
 Affine transform. More...
 
class  cv::BufferPoolController
 
class  cv::DualQuat< _Tp >
 
class  cv::Quat< _Tp >
 
class  cv::QuatEnum
 

Typedefs

typedef Affine3< double > cv::Affine3d
 
typedef Affine3< float > cv::Affine3f
 
using cv::DualQuatd = DualQuat< double >
 
using cv::DualQuatf = DualQuat< float >
 
using cv::Quatd = Quat< double >
 
using cv::Quatf = Quat< float >
 

Enumerations

enum  cv::CovarFlags {
  cv::COVAR_SCRAMBLED = 0,
  cv::COVAR_NORMAL = 1,
  cv::COVAR_USE_AVG = 2,
  cv::COVAR_SCALE = 4,
  cv::COVAR_ROWS = 8,
  cv::COVAR_COLS = 16
}
 Covariation flags. More...
 
enum  cv::QuatEnum::EulerAnglesType {
  cv::QuatEnum::INT_XYZ,
  cv::QuatEnum::INT_XZY,
  cv::QuatEnum::INT_YXZ,
  cv::QuatEnum::INT_YZX,
  cv::QuatEnum::INT_ZXY,
  cv::QuatEnum::INT_ZYX,
  cv::QuatEnum::INT_XYX,
  cv::QuatEnum::INT_XZX,
  cv::QuatEnum::INT_YXY,
  cv::QuatEnum::INT_YZY,
  cv::QuatEnum::INT_ZXZ,
  cv::QuatEnum::INT_ZYZ,
  cv::QuatEnum::EXT_XYZ,
  cv::QuatEnum::EXT_XZY,
  cv::QuatEnum::EXT_YXZ,
  cv::QuatEnum::EXT_YZX,
  cv::QuatEnum::EXT_ZXY,
  cv::QuatEnum::EXT_ZYX,
  cv::QuatEnum::EXT_XYX,
  cv::QuatEnum::EXT_XZX,
  cv::QuatEnum::EXT_YXY,
  cv::QuatEnum::EXT_YZY,
  cv::QuatEnum::EXT_ZXZ,
  cv::QuatEnum::EXT_ZYZ
}
 Enum of Euler angles type. More...
 
enum  cv::QuatAssumeType {
  cv::QUAT_ASSUME_NOT_UNIT,
  cv::QUAT_ASSUME_UNIT
}
 Unit quaternion flag. More...
 

Functions

template<typename T >
Quat< T > cv::acos (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::acosh (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::asin (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::asinh (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::atan (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::atanh (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::cos (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::cosh (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::crossProduct (const Quat< T > &p, const Quat< T > &q)
 
template<typename T >
Quat< T > cv::exp (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::inv (const Quat< T > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
 
template<typename T >
Quat< T > cv::log (const Quat< T > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
 
template<typename T >
static Affine3< T > cv::operator* (const Affine3< T > &affine1, const Affine3< T > &affine2)
 
template<typename T , typename V >
static V cv::operator* (const Affine3< T > &affine, const V &vector)
 V is a 3-element vector with member fields x, y and z. More...
 
static Vec3f cv::operator* (const Affine3f &affine, const Vec3f &vector)
 
static Vec3d cv::operator* (const Affine3d &affine, const Vec3d &vector)
 
template<typename T >
Quat< T > cv::operator* (const T, const Quat< T > &)
 
template<typename T >
Quat< T > cv::operator* (const Quat< T > &, const T)
 
template<typename _Tp >
std::ostream & cv::operator<< (std::ostream &, const DualQuat< _Tp > &)
 
template<typename _Tp >
std::ostream & cv::operator<< (std::ostream &, const Quat< _Tp > &)
 
template<typename S >
std::ostream & cv::operator<< (std::ostream &, const Quat< S > &)
 
template<typename T >
Quat< T > cv::power (const Quat< T > &q, const Quat< T > &p, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
 
template<typename T >
Quat< T > cv::power (const Quat< T > &q, const T x, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
 
template<typename T >
Quat< T > cv::sin (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::sinh (const Quat< T > &q)
 
template<typename S >
Quat< S > cv::sqrt (const Quat< S > &q, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT)
 
void cv::swap (Mat &a, Mat &b)
 Swaps two matrices. More...
 
void cv::swap (UMat &a, UMat &b)
 
template<typename T >
Quat< T > cv::tan (const Quat< T > &q)
 
template<typename T >
Quat< T > cv::tanh (const Quat< T > &q)
 

Detailed Description

Typedef Documentation

typedef Affine3<double> cv::Affine3d
typedef Affine3<float> cv::Affine3f
using cv::DualQuatd = typedef DualQuat<double>
using cv::DualQuatf = typedef DualQuat<float>
using cv::Quatd = typedef Quat<double>
using cv::Quatf = typedef Quat<float>

Enumeration Type Documentation

#include <opencv2/core.hpp>

Covariation flags.

Enumerator
COVAR_SCRAMBLED 

The output covariance matrix is calculated as:

\[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...],\]

The covariance matrix will be nsamples x nsamples. Such an unusual covariance matrix is used for fast PCA of a set of very large vectors (see, for example, the EigenFaces technique for face recognition). Eigenvalues of this "scrambled" matrix match the eigenvalues of the true covariance matrix. The "true" eigenvectors can be easily calculated from the eigenvectors of the "scrambled" covariance matrix.

COVAR_NORMAL 

The output covariance matrix is calculated as:

\[\texttt{scale} \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...] \cdot [ \texttt{vects} [0]- \texttt{mean} , \texttt{vects} [1]- \texttt{mean} ,...]^T,\]

covar will be a square matrix of the same size as the total number of elements in each input vector. One and only one of COVAR_SCRAMBLED and COVAR_NORMAL must be specified.

COVAR_USE_AVG 

If the flag is specified, the function does not calculate mean from the input vectors but, instead, uses the passed mean vector. This is useful if mean has been pre-calculated or known in advance, or if the covariance matrix is calculated by parts. In this case, mean is not a mean vector of the input sub-set of vectors but rather the mean vector of the whole set.

COVAR_SCALE 

If the flag is specified, the covariance matrix is scaled. In the "normal" mode, scale is 1./nsamples . In the "scrambled" mode, scale is the reciprocal of the total number of elements in each input vector. By default (if the flag is not specified), the covariance matrix is not scaled ( scale=1 ).

COVAR_ROWS 

If the flag is specified, all the input vectors are stored as rows of the samples matrix. mean should be a single-row vector in this case.

COVAR_COLS 

If the flag is specified, all the input vectors are stored as columns of the samples matrix. mean should be a single-column vector in this case.

Enum of Euler angles type.

Without considering the possibility of using two different convertions for the definition of the rotation axes , there exists twelve possible sequences of rotation axes, divided into two groups:

  • Proper Euler angles (Z-X-Z, X-Y-X, Y-Z-Y, Z-Y-Z, X-Z-X, Y-X-Y)
  • Tait–Bryan angles (X-Y-Z, Y-Z-X, Z-X-Y, X-Z-Y, Z-Y-X, Y-X-Z).

The three elemental rotations may be extrinsic (rotations about the axes xyz of the original coordinate system, which is assumed to remain motionless), or intrinsic(rotations about the axes of the rotating coordinate system XYZ, solidary with the moving body, which changes its orientation after each elemental rotation).

Extrinsic and intrinsic rotations are relevant.

The definition of the Euler angles is as following,

  • \(\theta_1 \) represents the first rotation angle,
  • \(\theta_2 \) represents the second rotation angle,
  • \(\theta_3 \) represents the third rotation angle.

For intrinsic rotations in the order of X-Y-Z, the rotation matrix R can be calculated by:

\[R =X(\theta_1) Y(\theta_2) Z(\theta_3) \]

For extrinsic rotations in the order of X-Y-Z, the rotation matrix R can be calculated by:

\[R =Z({\theta_3}) Y({\theta_2}) X({\theta_1})\]

where

\[X({\theta})={\begin{bmatrix}1&0&0\\0&\cos {\theta_1} &-\sin {\theta_1} \\0&\sin {\theta_1} &\cos {\theta_1} \\\end{bmatrix}}, Y({\theta})={\begin{bmatrix}\cos \theta_{2}&0&\sin \theta_{2}\\0&1 &0 \\\ -sin \theta_2& 0&\cos \theta_{2} \\\end{bmatrix}}, Z({\theta})={\begin{bmatrix}\cos\theta_{3} &-\sin \theta_3&0\\\sin \theta_3 &\cos \theta_3 &0\\0&0&1\\\end{bmatrix}}. \]

The function is designed according to this set of conventions:

  • Right handed reference frames are adopted, and the right hand rule is used to determine the sign of angles.
  • Each matrix is meant to represent an active rotation (the composing and composed matrices are supposed to act on the coordinates of vectors defined in the initial fixed reference frame and give as a result the coordinates of a rotated vector defined in the same reference frame).
  • For \(\theta_1\) and \(\theta_3\), the valid range is (−π, π].

    For \(\theta_2\), the valid range is [−π/2, π/2] or [0, π].

    For Tait–Bryan angles, the valid range of \(\theta_2\) is [−π/2, π/2]. When transforming a quaternion to Euler angles, the solution of Euler angles is unique in condition of \( \theta_2 \in (−π/2, π/2)\) . If \(\theta_2 = −π/2 \) or \( \theta_2 = π/2\), there are infinite solutions. The common name for this situation is gimbal lock. For Proper Euler angles,the valid range of \(\theta_2\) is in [0, π]. The solutions of Euler angles are unique in condition of \( \theta_2 \in (0, π)\) . If \(\theta_2 =0 \) or \(\theta_2 =π \), there are infinite solutions and gimbal lock will occur.

Enumerator
INT_XYZ 

Intrinsic rotations with the Euler angles type X-Y-Z.

INT_XZY 

Intrinsic rotations with the Euler angles type X-Z-Y.

INT_YXZ 

Intrinsic rotations with the Euler angles type Y-X-Z.

INT_YZX 

Intrinsic rotations with the Euler angles type Y-Z-X.

INT_ZXY 

Intrinsic rotations with the Euler angles type Z-X-Y.

INT_ZYX 

Intrinsic rotations with the Euler angles type Z-Y-X.

INT_XYX 

Intrinsic rotations with the Euler angles type X-Y-X.

INT_XZX 

Intrinsic rotations with the Euler angles type X-Z-X.

INT_YXY 

Intrinsic rotations with the Euler angles type Y-X-Y.

INT_YZY 

Intrinsic rotations with the Euler angles type Y-Z-Y.

INT_ZXZ 

Intrinsic rotations with the Euler angles type Z-X-Z.

INT_ZYZ 

Intrinsic rotations with the Euler angles type Z-Y-Z.

EXT_XYZ 

Extrinsic rotations with the Euler angles type X-Y-Z.

EXT_XZY 

Extrinsic rotations with the Euler angles type X-Z-Y.

EXT_YXZ 

Extrinsic rotations with the Euler angles type Y-X-Z.

EXT_YZX 

Extrinsic rotations with the Euler angles type Y-Z-X.

EXT_ZXY 

Extrinsic rotations with the Euler angles type Z-X-Y.

EXT_ZYX 

Extrinsic rotations with the Euler angles type Z-Y-X.

EXT_XYX 

Extrinsic rotations with the Euler angles type X-Y-X.

EXT_XZX 

Extrinsic rotations with the Euler angles type X-Z-X.

EXT_YXY 

Extrinsic rotations with the Euler angles type Y-X-Y.

EXT_YZY 

Extrinsic rotations with the Euler angles type Y-Z-Y.

EXT_ZXZ 

Extrinsic rotations with the Euler angles type Z-X-Z.

EXT_ZYZ 

Extrinsic rotations with the Euler angles type Z-Y-Z.

#include <opencv2/core/quaternion.hpp>

Unit quaternion flag.

Enumerator
QUAT_ASSUME_NOT_UNIT 

This flag is specified by default. If this flag is specified, the input quaternions are assumed to be not unit quaternions. It can guarantee the correctness of the calculations, although the calculation speed will be slower than the flag QUAT_ASSUME_UNIT.

QUAT_ASSUME_UNIT 

If this flag is specified, the input quaternions are assumed to be unit quaternions which will save some computations. However, if this flag is specified without unit quaternion, the program correctness of the result will not be guaranteed.

Function Documentation

template<typename T >
Quat<T> cv::acos ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); acos(q); ```

template<typename T >
Quat<T> cv::acosh ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); acosh(q); ```

template<typename T >
Quat<T> cv::asin ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); asin(q); ```

template<typename T >
Quat<T> cv::asinh ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); asinh(q); ```

template<typename T >
Quat<T> cv::atan ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); atan(q); ```

template<typename T >
Quat<T> cv::atanh ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); atanh(q); ```

template<typename T >
Quat<T> cv::cos ( const Quat< T > &  q)
template<typename T >
Quat<T> cv::cosh ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); cosh(q); ```

template<typename T >
Quat<T> cv::crossProduct ( const Quat< T > &  p,
const Quat< T > &  q 
)

#include <opencv2/core/quaternion.hpp>

For example ``` Quatd q{1,2,3,4}; Quatd p{5,6,7,8}; crossProduct(p, q); ```

template<typename T >
Quat<T> cv::exp ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example: ``` Quatd q{1,2,3,4}; cout << exp(q) << endl; ```

Examples:
samples/cpp/polar_transforms.cpp.
template<typename T >
Quat<T> cv::inv ( const Quat< T > &  q,
QuatAssumeType  assumeUnit = QUAT_ASSUME_NOT_UNIT 
)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.
assumeUnitif QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations.

For example ``` Quatd q(1,2,3,4); inv(q);

QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; q = q.normalize(); inv(q, assumeUnit);//This assumeUnit means p is a unit quaternion ```

template<typename T >
Quat<T> cv::log ( const Quat< T > &  q,
QuatAssumeType  assumeUnit = QUAT_ASSUME_NOT_UNIT 
)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.
assumeUnitif QUAT_ASSUME_UNIT, q assume to be a unit quaternion and this function will save some computations.

For example ``` Quatd q1{1,2,3,4}; cout << log(q1) << endl; ```

Examples:
samples/cpp/polar_transforms.cpp, and samples/cpp/stitching_detailed.cpp.
template<typename T >
static Affine3<T> cv::operator* ( const Affine3< T > &  affine1,
const Affine3< T > &  affine2 
)
static
template<typename T , typename V >
static V cv::operator* ( const Affine3< T > &  affine,
const V &  vector 
)
static

#include <opencv2/core/affine.hpp>

V is a 3-element vector with member fields x, y and z.

static Vec3f cv::operator* ( const Affine3f affine,
const Vec3f vector 
)
static
static Vec3d cv::operator* ( const Affine3d affine,
const Vec3d vector 
)
static
template<typename T >
Quat<T> cv::operator* ( const T  ,
const Quat< T > &   
)
template<typename T >
Quat<T> cv::operator* ( const Quat< T > &  ,
const T   
)
template<typename _Tp >
std::ostream& cv::operator<< ( std::ostream &  ,
const DualQuat< _Tp > &   
)
template<typename _Tp >
std::ostream& cv::operator<< ( std::ostream &  ,
const Quat< _Tp > &   
)
template<typename S >
std::ostream& cv::operator<< ( std::ostream &  ,
const Quat< S > &   
)
template<typename T >
Quat<T> cv::power ( const Quat< T > &  q,
const Quat< T > &  p,
QuatAssumeType  assumeUnit = QUAT_ASSUME_NOT_UNIT 
)

#include <opencv2/core/quaternion.hpp>

Parameters
pbase quaternion of power function.
qindex quaternion of power function.
assumeUnitif QUAT_ASSUME_UNIT, quaternion \(p\) assume to be a unit quaternion and this function will save some computations.

For example ``` Quatd p(1,2,3,4); Quatd q(5,6,7,8); power(p, q);

QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; p = p.normalize(); power(p, q, assumeUnit); //This assumeUnit means p is a unit quaternion ```

template<typename T >
Quat<T> cv::power ( const Quat< T > &  q,
const T  x,
QuatAssumeType  assumeUnit = QUAT_ASSUME_NOT_UNIT 
)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.
xindex of exponentiation.
assumeUnitif QUAT_ASSUME_UNIT, quaternion q assume to be a unit quaternion and this function will save some computations.

For example ``` Quatd q(1,2,3,4); power(q, 2.0);

QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT; double angle = CV_PI; Vec3d axis{0, 0, 1}; Quatd q1 = Quatd::createFromAngleAxis(angle, axis); //generate a unit quat by axis and angle power(q1, 2.0, assumeUnit);//This assumeUnit means q1 is a unit quaternion. ```

Note
the type of the index should be the same as the quaternion.
template<typename T >
Quat<T> cv::sin ( const Quat< T > &  q)
template<typename T >
Quat<T> cv::sinh ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); sinh(q); ```

template<typename S >
Quat<S> cv::sqrt ( const Quat< S > &  q,
QuatAssumeType  assumeUnit = QUAT_ASSUME_NOT_UNIT 
)
void cv::swap ( Mat a,
Mat b 
)

#include <opencv2/core.hpp>

Swaps two matrices.

Examples:
samples/cpp/lkdemo.cpp, and samples/cpp/warpPerspective_demo.cpp.
void cv::swap ( UMat a,
UMat b 
)

#include <opencv2/core.hpp>

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<typename T >
Quat<T> cv::tan ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); tan(q); ```

template<typename T >
Quat<T> cv::tanh ( const Quat< T > &  q)

#include <opencv2/core/quaternion.hpp>

Parameters
qa quaternion.

For example ``` Quatd q(1,2,3,4); tanh(q); ```

See also
sinh, cosh