Skip to content

Commit 3a5cd12

Browse files
committed
Merge pull request opencv#10527 from csukuangfj:local
2 parents 004a1cd + a286910 commit 3a5cd12

File tree

3 files changed

+171
-21
lines changed

3 files changed

+171
-21
lines changed

modules/core/include/opencv2/core.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,7 @@ class CV_EXPORTS SVD
26292629

26302630
/** @overload
26312631
initializes an empty SVD structure and then calls SVD::operator()
2632-
@param src decomposed matrix.
2632+
@param src decomposed matrix. The depth has to be CV_32F or CV_64F.
26332633
@param flags operation flags (SVD::Flags)
26342634
*/
26352635
SVD( InputArray src, int flags = 0 );
@@ -2642,7 +2642,7 @@ class CV_EXPORTS SVD
26422642
different matrices. Each time, if needed, the previous u,`vt` , and w
26432643
are reclaimed and the new matrices are created, which is all handled by
26442644
Mat::create.
2645-
@param src decomposed matrix.
2645+
@param src decomposed matrix. The depth has to be CV_32F or CV_64F.
26462646
@param flags operation flags (SVD::Flags)
26472647
*/
26482648
SVD& operator ()( InputArray src, int flags = 0 );
@@ -2658,18 +2658,18 @@ class CV_EXPORTS SVD
26582658
SVD::compute(A, w, u, vt);
26592659
@endcode
26602660
2661-
@param src decomposed matrix
2661+
@param src decomposed matrix. The depth has to be CV_32F or CV_64F.
26622662
@param w calculated singular values
26632663
@param u calculated left singular vectors
2664-
@param vt transposed matrix of right singular values
2665-
@param flags operation flags - see SVD::SVD.
2664+
@param vt transposed matrix of right singular vectors
2665+
@param flags operation flags - see SVD::Flags.
26662666
*/
26672667
static void compute( InputArray src, OutputArray w,
26682668
OutputArray u, OutputArray vt, int flags = 0 );
26692669

26702670
/** @overload
26712671
computes singular values of a matrix
2672-
@param src decomposed matrix
2672+
@param src decomposed matrix. The depth has to be CV_32F or CV_64F.
26732673
@param w calculated singular values
26742674
@param flags operation flags - see SVD::Flags.
26752675
*/

modules/core/include/opencv2/core/affine.hpp

Lines changed: 164 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,72 @@ namespace cv
5555
//! @{
5656

5757
/** @brief Affine transform
58-
@todo document
58+
*
59+
* It represents a 4x4 homogeneous transformation matrix \f$T\f$
60+
*
61+
* \f[T =
62+
* \begin{bmatrix}
63+
* R & t\\
64+
* 0 & 1\\
65+
* \end{bmatrix}
66+
* \f]
67+
*
68+
* where \f$R\f$ is a 3x3 rotation matrix and \f$t\f$ is a 3x1 translation vector.
69+
*
70+
* You can specify \f$R\f$ either by a 3x3 rotation matrix or by a 3x1 rotation vector,
71+
* which is converted to a 3x3 rotation matrix by the Rodrigues formula.
72+
*
73+
* To construct a matrix \f$T\f$ representing first rotation around the axis \f$r\f$ with rotation
74+
* angle \f$|r|\f$ in radian (right hand rule) and then translation by the vector \f$t\f$, you can use
75+
*
76+
* @code
77+
* cv::Vec3f r, t;
78+
* cv::Affine3f T(r, t);
79+
* @endcode
80+
*
81+
* If you already have the rotation matrix \f$R\f$, then you can use
82+
*
83+
* @code
84+
* cv::Matx33f R;
85+
* cv::Affine3f T(R, t);
86+
* @endcode
87+
*
88+
* To extract the rotation matrix \f$R\f$ from \f$T\f$, use
89+
*
90+
* @code
91+
* cv::Matx33f R = T.rotation();
92+
* @endcode
93+
*
94+
* To extract the translation vector \f$t\f$ from \f$T\f$, use
95+
*
96+
* @code
97+
* cv::Vec3f t = T.translation();
98+
* @endcode
99+
*
100+
* To extract the rotation vector \f$r\f$ from \f$T\f$, use
101+
*
102+
* @code
103+
* cv::Vec3f r = T.rvec();
104+
* @endcode
105+
*
106+
* Note that since the mapping from rotation vectors to rotation matrices
107+
* is many to one. The returned rotation vector is not necessarily the one
108+
* you used before to set the matrix.
109+
*
110+
* If you have two transformations \f$T = T_1 * T_2\f$, use
111+
*
112+
* @code
113+
* cv::Affine3f T, T1, T2;
114+
* T = T2.concatenate(T1);
115+
* @endcode
116+
*
117+
* To get the inverse transform of \f$T\f$, use
118+
*
119+
* @code
120+
* cv::Affine3f T, T_inv;
121+
* T_inv = T.inv();
122+
* @endcode
123+
*
59124
*/
60125
template<typename T>
61126
class Affine3
@@ -66,45 +131,127 @@ namespace cv
66131
typedef Matx<float_type, 4, 4> Mat4;
67132
typedef Vec<float_type, 3> Vec3;
68133

134+
//! Default constructor. It represents a 4x4 identity matrix.
69135
Affine3();
70136

71137
//! Augmented affine matrix
72138
Affine3(const Mat4& affine);
73139

74-
//! Rotation matrix
140+
/**
141+
* The resulting 4x4 matrix is
142+
*
143+
* \f[
144+
* \begin{bmatrix}
145+
* R & t\\
146+
* 0 & 1\\
147+
* \end{bmatrix}
148+
* \f]
149+
*
150+
* @param R 3x3 rotation matrix.
151+
* @param t 3x1 translation vector.
152+
*/
75153
Affine3(const Mat3& R, const Vec3& t = Vec3::all(0));
76154

77-
//! Rodrigues vector
155+
/**
156+
* Rodrigues vector.
157+
*
158+
* The last row of the current matrix is set to [0,0,0,1].
159+
*
160+
* @param rvec 3x1 rotation vector. Its direction indicates the rotation axis and its length
161+
* indicates the rotation angle in radian (using right hand rule).
162+
* @param t 3x1 translation vector.
163+
*/
78164
Affine3(const Vec3& rvec, const Vec3& t = Vec3::all(0));
79165

80-
//! Combines all contructors above. Supports 4x4, 4x3, 3x3, 1x3, 3x1 sizes of data matrix
166+
/**
167+
* Combines all constructors above. Supports 4x4, 3x4, 3x3, 1x3, 3x1 sizes of data matrix.
168+
*
169+
* The last row of the current matrix is set to [0,0,0,1] when data is not 4x4.
170+
*
171+
* @param data 1-channel matrix.
172+
* when it is 4x4, it is copied to the current matrix and t is not used.
173+
* When it is 3x4, it is copied to the upper part 3x4 of the current matrix and t is not used.
174+
* When it is 3x3, it is copied to the upper left 3x3 part of the current matrix.
175+
* When it is 3x1 or 1x3, it is treated as a rotation vector and the Rodrigues formula is used
176+
* to compute a 3x3 rotation matrix.
177+
* @param t 3x1 translation vector. It is used only when data is neither 4x4 nor 3x4.
178+
*/
81179
explicit Affine3(const Mat& data, const Vec3& t = Vec3::all(0));
82180

83-
//! From 16th element array
181+
//! From 16-element array
84182
explicit Affine3(const float_type* vals);
85183

86-
//! Create identity transform
184+
//! Create an 4x4 identity transform
87185
static Affine3 Identity();
88186

89-
//! Rotation matrix
187+
/**
188+
* Rotation matrix.
189+
*
190+
* Copy the rotation matrix to the upper left 3x3 part of the current matrix.
191+
* The remaining elements of the current matrix are not changed.
192+
*
193+
* @param R 3x3 rotation matrix.
194+
*
195+
*/
90196
void rotation(const Mat3& R);
91197

92-
//! Rodrigues vector
198+
/**
199+
* Rodrigues vector.
200+
*
201+
* It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
202+
*
203+
* @param rvec 3x1 rotation vector. The direction indicates the rotation axis and
204+
* its length indicates the rotation angle in radian (using the right thumb convention).
205+
*/
93206
void rotation(const Vec3& rvec);
94207

95-
//! Combines rotation methods above. Suports 3x3, 1x3, 3x1 sizes of data matrix;
208+
/**
209+
* Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix.
210+
*
211+
* It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
212+
*
213+
* @param data 1-channel matrix.
214+
* When it is a 3x3 matrix, it sets the upper left 3x3 part of the current matrix.
215+
* When it is a 1x3 or 3x1 matrix, it is used as a rotation vector. The Rodrigues formula
216+
* is used to compute the rotation matrix and sets the upper left 3x3 part of the current matrix.
217+
*/
96218
void rotation(const Mat& data);
97219

220+
/**
221+
* Copy the 3x3 matrix L to the upper left part of the current matrix
222+
*
223+
* It sets the upper left 3x3 part of the matrix. The remaining part is unaffected.
224+
*
225+
* @param L 3x3 matrix.
226+
*/
98227
void linear(const Mat3& L);
228+
229+
/**
230+
* Copy t to the first three elements of the last column of the current matrix
231+
*
232+
* It sets the upper right 3x1 part of the matrix. The remaining part is unaffected.
233+
*
234+
* @param t 3x1 translation vector.
235+
*/
99236
void translation(const Vec3& t);
100237

238+
//! @return the upper left 3x3 part
101239
Mat3 rotation() const;
240+
241+
//! @return the upper left 3x3 part
102242
Mat3 linear() const;
243+
244+
//! @return the upper right 3x1 part
103245
Vec3 translation() const;
104246

105-
//! Rodrigues vector
247+
//! Rodrigues vector.
248+
//! @return a vector representing the upper left 3x3 rotation matrix of the current matrix.
249+
//! @warning Since the mapping between rotation vectors and rotation matrices is many to one,
250+
//! this function returns only one rotation vector that represents the current rotation matrix,
251+
//! which is not necessarily the same one set by `rotation(const Vec3& rvec)`.
106252
Vec3 rvec() const;
107253

254+
//! @return the inverse of the current matrix.
108255
Affine3 inv(int method = cv::DECOMP_SVD) const;
109256

110257
//! a.rotate(R) is equivalent to Affine(R, 0) * a;
@@ -113,7 +260,7 @@ namespace cv
113260
//! a.rotate(rvec) is equivalent to Affine(rvec, 0) * a;
114261
Affine3 rotate(const Vec3& rvec) const;
115262

116-
//! a.translate(t) is equivalent to Affine(E, t) * a;
263+
//! a.translate(t) is equivalent to Affine(E, t) * a, where E is an identity matrix
117264
Affine3 translate(const Vec3& t) const;
118265

119266
//! a.concatenate(affine) is equivalent to affine * a;
@@ -136,6 +283,7 @@ namespace cv
136283
template<typename T> static
137284
Affine3<T> operator*(const Affine3<T>& affine1, const Affine3<T>& affine2);
138285

286+
//! V is a 3-element vector with member fields x, y and z
139287
template<typename T, typename V> static
140288
V operator*(const Affine3<T>& affine, const V& vector);
141289

@@ -178,7 +326,7 @@ namespace cv
178326
//! @cond IGNORED
179327

180328
///////////////////////////////////////////////////////////////////////////////////
181-
// Implementaiton
329+
// Implementation
182330

183331
template<typename T> inline
184332
cv::Affine3<T>::Affine3()
@@ -212,6 +360,7 @@ template<typename T> inline
212360
cv::Affine3<T>::Affine3(const cv::Mat& data, const Vec3& t)
213361
{
214362
CV_Assert(data.type() == cv::traits::Type<T>::value);
363+
CV_Assert(data.channels() == 1);
215364

216365
if (data.cols == 4 && data.rows == 4)
217366
{
@@ -276,11 +425,12 @@ void cv::Affine3<T>::rotation(const Vec3& _rvec)
276425
}
277426
}
278427

279-
//Combines rotation methods above. Suports 3x3, 1x3, 3x1 sizes of data matrix;
428+
//Combines rotation methods above. Supports 3x3, 1x3, 3x1 sizes of data matrix;
280429
template<typename T> inline
281430
void cv::Affine3<T>::rotation(const cv::Mat& data)
282431
{
283432
CV_Assert(data.type() == cv::traits::Type<T>::value);
433+
CV_Assert(data.channels() == 1);
284434

285435
if (data.cols == 3 && data.rows == 3)
286436
{
@@ -295,7 +445,7 @@ void cv::Affine3<T>::rotation(const cv::Mat& data)
295445
rotation(_rvec);
296446
}
297447
else
298-
CV_Assert(!"Input marix can be 3x3, 1x3 or 3x1");
448+
CV_Assert(!"Input matrix can only be 3x3, 1x3 or 3x1");
299449
}
300450

301451
template<typename T> inline

modules/core/include/opencv2/core/matx.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Except of the plain constructor which takes a list of elements, Matx can be init
9292
float values[] = { 1, 2, 3};
9393
Matx31f m(values);
9494
@endcode
95-
In case if C++11 features are avaliable, std::initializer_list can be also used to initizlize Matx:
95+
In case if C++11 features are avaliable, std::initializer_list can be also used to initialize Matx:
9696
@code{.cpp}
9797
Matx31f m = { 1, 2, 3};
9898
@endcode

0 commit comments

Comments
 (0)