OpenCV
3.4.18
Open Source Computer Vision
|
Affine transform. More...
#include <opencv2/core/affine.hpp>
Public Types | |
typedef T | float_type |
typedef Matx< float_type, 3, 3 > | Mat3 |
typedef Matx< float_type, 4, 4 > | Mat4 |
typedef Vec< float_type, 3 > | Vec3 |
Public Member Functions | |
Affine3 () | |
Default constructor. It represents a 4x4 identity matrix. More... | |
Affine3 (const Mat4 &affine) | |
Augmented affine matrix. More... | |
Affine3 (const Mat3 &R, const Vec3 &t=Vec3::all(0)) | |
Affine3 (const Vec3 &rvec, const Vec3 &t=Vec3::all(0)) | |
Affine3 (const Mat &data, const Vec3 &t=Vec3::all(0)) | |
Affine3 (const float_type *vals) | |
From 16-element array. More... | |
template<typename Y > | |
Affine3< Y > | cast () const |
Affine3 | concatenate (const Affine3 &affine) const |
a.concatenate(affine) is equivalent to affine * a; More... | |
Affine3 | inv (int method=cv::DECOMP_SVD) const |
void | linear (const Mat3 &L) |
Mat3 | linear () const |
template<typename Y > | |
operator Affine3< Y > () const | |
Affine3 | rotate (const Mat3 &R) const |
a.rotate(R) is equivalent to Affine(R, 0) * a; More... | |
Affine3 | rotate (const Vec3 &rvec) const |
a.rotate(rvec) is equivalent to Affine(rvec, 0) * a; More... | |
void | rotation (const Mat3 &R) |
void | rotation (const Vec3 &rvec) |
void | rotation (const Mat &data) |
Mat3 | rotation () const |
Vec3 | rvec () const |
Affine3 | translate (const Vec3 &t) const |
a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix More... | |
void | translation (const Vec3 &t) |
Vec3 | translation () const |
Static Public Member Functions | |
static Affine3 | Identity () |
Create an 4x4 identity transform. More... | |
Public Attributes | |
Mat4 | matrix |
Affine transform.
It represents a 4x4 homogeneous transformation matrix \(T\)
\[T = \begin{bmatrix} R & t\\ 0 & 1\\ \end{bmatrix} \]
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
If you already have the rotation matrix \(R\), then you can use
To extract the rotation matrix \(R\) from \(T\), use
To extract the translation vector \(t\) from \(T\), use
To extract the rotation vector \(r\) from \(T\), use
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
To get the inverse transform of \(T\), use
typedef T cv::Affine3< T >::float_type |
typedef Matx<float_type, 3, 3> cv::Affine3< T >::Mat3 |
typedef Matx<float_type, 4, 4> cv::Affine3< T >::Mat4 |
typedef Vec<float_type, 3> cv::Affine3< T >::Vec3 |
cv::Affine3< T >::Affine3 | ( | ) |
Default constructor. It represents a 4x4 identity matrix.
cv::Affine3< T >::Affine3 | ( | const Mat4 & | affine | ) |
Augmented affine matrix.
cv::Affine3< T >::Affine3 | ( | const Mat3 & | R, |
const Vec3 & | t = Vec3::all(0) |
||
) |
The resulting 4x4 matrix is
\[ \begin{bmatrix} R & t\\ 0 & 1\\ \end{bmatrix} \]
R | 3x3 rotation matrix. |
t | 3x1 translation vector. |
cv::Affine3< T >::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].
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. |
|
explicit |
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.
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. |
|
explicit |
From 16-element array.
Affine3 cv::Affine3< T >::concatenate | ( | const Affine3< T > & | affine | ) | const |
a.concatenate(affine) is equivalent to affine * a;
|
static |
Create an 4x4 identity transform.
Affine3 cv::Affine3< T >::inv | ( | int | method = cv::DECOMP_SVD | ) | const |
void cv::Affine3< T >::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.
L | 3x3 matrix. |
Mat3 cv::Affine3< T >::linear | ( | ) | const |
Affine3 cv::Affine3< T >::rotate | ( | const Mat3 & | R | ) | const |
a.rotate(R) is equivalent to Affine(R, 0) * a;
Affine3 cv::Affine3< T >::rotate | ( | const Vec3 & | rvec | ) | const |
a.rotate(rvec) is equivalent to Affine(rvec, 0) * a;
void cv::Affine3< T >::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.
R | 3x3 rotation matrix. |
void cv::Affine3< T >::rotation | ( | const Vec3 & | rvec | ) |
Rodrigues vector.
It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
rvec | 3x1 rotation vector. The direction indicates the rotation axis and its length indicates the rotation angle in radian (using the right thumb convention). |
void cv::Affine3< T >::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.
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. |
Mat3 cv::Affine3< T >::rotation | ( | ) | const |
Vec3 cv::Affine3< T >::rvec | ( | ) | const |
Rodrigues vector.
rotation(const Vec3& rvec)
. Affine3 cv::Affine3< T >::translate | ( | const Vec3 & | t | ) | const |
a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix
void cv::Affine3< T >::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.
t | 3x1 translation vector. |
Vec3 cv::Affine3< T >::translation | ( | ) | const |
Mat4 cv::Affine3< T >::matrix |