Class cv::Affine3#

Affine transform. View details

Collaboration diagram for cv::Affine3:

Detailed Description#

Affine transform.

It represents a 4x4 homogeneous transformation matrix \(T\)

\[\begin{split}T = \begin{bmatrix} R & t\\ 0 & 1\\ \end{bmatrix} \end{split}\]

where \(R\) is a 3x3 rotation matrix and \(t\) is a 3x1 translation vector.

You can specify \(R\) either by a 3x3 rotation matrix or by a 3x1 rotation vector, which is converted to a 3x3 rotation matrix by the Rodrigues formula.

To construct a matrix \(T\) representing first rotation around the axis \(r\) with rotation angle \(|r|\) in radian (right hand rule) and then translation by the vector \(t\), you can use

cv::Vec3f r, t;
cv::Affine3f T(r, t);

If you already have the rotation matrix \(R\), then you can use

cv::Matx33f R;
cv::Affine3f T(R, t);

To extract the rotation matrix \(R\) from \(T\), use

cv::Matx33f R = T.rotation();

To extract the translation vector \(t\) from \(T\), use

cv::Vec3f t = T.translation();

To extract the rotation vector \(r\) from \(T\), use

cv::Vec3f r = T.rvec();

Note that since the mapping from rotation vectors to rotation matrices is many to one. The returned rotation vector is not necessarily the one you used before to set the matrix.

If you have two transformations \(T = T_1 * T_2\), use

cv::Affine3f T, T1, T2;
T = T2.concatenate(T1);

To get the inverse transform of \(T\), use

cv::Affine3f T, T_inv;
T_inv = T.inv();

Member Typedef Documentation#

float_type#

typedef T cv::Affine3::float_type

Mat3#

typedef Matx< float_type, 3, 3 > cv::Affine3::Mat3

Mat4#

typedef Matx< float_type, 4, 4 > cv::Affine3::Mat4

Vec3#

typedef Vec< float_type, 3 > cv::Affine3::Vec3

Constructor & Destructor Documentation#

Affine3()#

cv::Affine3::Affine3()

Default constructor. It represents a 4x4 identity matrix.

Affine3()#

cv::Affine3::Affine3(const float_type * vals)

From 16-element array.

Affine3()#

cv::Affine3::Affine3(
const Mat & data,
const Vec3 & t = Vec3::all(0) )

Combines all constructors above. Supports 4x4, 3x4, 3x3, 1x3, 3x1 sizes of data matrix.

The last row of the current matrix is set to [0,0,0,1] when data is not 4x4.

Parameters

  • data — 1-channel matrix. when it is 4x4, it is copied to the current matrix and t is not used. When it is 3x4, it is copied to the upper part 3x4 of the current matrix and t is not used. When it is 3x3, it is copied to the upper left 3x3 part of the current matrix. When it is 3x1 or 1x3, it is treated as a rotation vector and the Rodrigues formula is used to compute a 3x3 rotation matrix.

  • t — 3x1 translation vector. It is used only when data is neither 4x4 nor 3x4.

Affine3()#

cv::Affine3::Affine3(
const Mat3 & R,
const Vec3 & t = Vec3::all(0) )

The resulting 4x4 matrix is

\[\begin{split} \begin{bmatrix} R & t\\ 0 & 1\\ \end{bmatrix} \end{split}\]

Parameters

  • R — 3x3 rotation matrix.

  • t — 3x1 translation vector.

Affine3()#

cv::Affine3::Affine3(const Mat4 & affine)

Augmented affine matrix.

Affine3()#

cv::Affine3::Affine3(
const Vec3 & rvec,
const Vec3 & t = Vec3::all(0) )

Rodrigues vector.

The last row of the current matrix is set to [0,0,0,1].

Parameters

  • rvec — 3x1 rotation vector. Its direction indicates the rotation axis and its length indicates the rotation angle in radian (using right hand rule).

  • t — 3x1 translation vector.

Member Function Documentation#

cast()#

template<typename Y>
Affine3< Y > cv::Affine3::cast()

concatenate()#

Affine3 cv::Affine3::concatenate(const Affine3 & affine)

a.concatenate(affine) is equivalent to affine * a;

inv()#

Affine3 cv::Affine3::inv(int method = cv::DECOMP_SVD)

Returns

the inverse of the current matrix.

linear()#

Mat3 cv::Affine3::linear()

Returns

the upper left 3x3 part

linear()#

void cv::Affine3::linear(const Mat3 & L)

Copy the 3x3 matrix L to the upper left part of the current matrix

It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.

Parameters

  • L — 3x3 matrix.

operator Affine3< Y >()#

template<typename Y>
cv::Affine3::operator Affine3< Y >()

rotate()#

Affine3 cv::Affine3::rotate(const Mat3 & R)

a.rotate(R) is equivalent to Affine(R, 0) * a;

rotate()#

Affine3 cv::Affine3::rotate(const Vec3 & rvec)

a.rotate(rvec) is equivalent to Affine(rvec, 0) * a;

rotation()#

Mat3 cv::Affine3::rotation()

Returns

the upper left 3x3 part

rotation()#

void cv::Affine3::rotation(const Mat & data)

Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix.

It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.

Parameters

  • data — 1-channel matrix. When it is a 3x3 matrix, it sets the upper left 3x3 part of the current matrix. When it is a 1x3 or 3x1 matrix, it is used as a rotation vector. The Rodrigues formula is used to compute the rotation matrix and sets the upper left 3x3 part of the current matrix.

rotation()#

void cv::Affine3::rotation(const Mat3 & R)

Rotation matrix.

Copy the rotation matrix to the upper left 3x3 part of the current matrix. The remaining elements of the current matrix are not changed.

Parameters

  • R — 3x3 rotation matrix.

rotation()#

void cv::Affine3::rotation(const Vec3 & rvec)

Rodrigues vector.

It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.

Parameters

  • rvec — 3x1 rotation vector. The direction indicates the rotation axis and its length indicates the rotation angle in radian (using the right thumb convention).

rvec()#

Vec3 cv::Affine3::rvec()

Rodrigues vector.

Warning

Since the mapping between rotation vectors and rotation matrices is many to one, this function returns only one rotation vector that represents the current rotation matrix, which is not necessarily the same one set by rotation(const Vec3& rvec).

Returns

a vector representing the upper left 3x3 rotation matrix of the current matrix.

translate()#

Affine3 cv::Affine3::translate(const Vec3 & t)

a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix

translation()#

Vec3 cv::Affine3::translation()

Returns

the upper right 3x1 part

translation()#

void cv::Affine3::translation(const Vec3 & t)

Copy t to the first three elements of the last column of the current matrix

It sets the upper right 3x1 part of the matrix. The remaining part is unaffected.

Parameters

  • t — 3x1 translation vector.

Identity()#

static Affine3 cv::Affine3::Identity()

Create an 4x4 identity transform.

Member Data Documentation#

matrix#

Mat4 cv::Affine3::matrix

Source file#

The documentation for this class was generated from the following file: