回転ベクトルから行列への変換/逆変換を行う&br;
Converts to/from rotation matrix from/to rotation vector
#contents
*int cvRodrigues2( CvMat* src, CvMat* dst, CvMat* jacobian = 0); [#q0236be2]
回転ベクトルを行列に変換したり,その逆変換を行う.
回転ベクトルはQuaternion表記っぽい.&br;
Converts the rotation matrix to the rotation vector or converts in opposite way.
The rotation vector is expressed in [[Quaternion>http://en.wikipedia.org/wiki/Quaternion]].
**引数 [#ze18659a]
-src:CvMat*型のベクトルか行列 (Vector or matrix)
-dst:CvMat*型の行列かベクトル (Matrix or vector)
-jacobian:CvMat*型(3x9) か (9x3)のヤコビアン行列.省略可能 (Jacobian matrix. extra option)
**返り値 [#y528b8e0]
-成功したら1,それ以外なら0が返る
-Returns 1 when succeeded, otherwise 0
*void cv::Rodrigues(Mat src, Mat dst, Mat jacobian = 0) [#wb615f2b]
C++インタフェースの関数。実態はCの関数。
**引数 [#i71e293f]
-src:Mat型のベクトルが行列 (Vector or matrix, technically InputArray)
-dst:Mat型の行列かベクトル (Matrix or vector, technically OutputArray)
-jacobian:Mat型(3x9)か(9x3)のヤコビアン行列。省略可能 (Jacobian matrix, extra option)
**返り値 [#t83af52d]
-void なのでなし
-成功以外ならdstに全部0が埋まって返ってくる
-If not succeeded, dst will be filled with 0
*解説 [#o3321c11]
-srcとdstはそれぞれ( (1x3) か (3x1) ) か (3x3)のベクトル,もしくは行列である必要がある.
-srcが行列ならdstはベクトル,srcがベクトルならdstは行列になる.
-3つの回転角から回転行列を作る場合,基準とする軸の順番を考慮しないと,うまくいかない.
--これを一意に決めるのが「Quaternion表記」である.
--詳細は省くが,回転行列による変換は1本の軸に依る回転と考えられ,その直線の向きと回転角度だけで表せる.
--3つの回転角に対して4次元ベクトルで表すのが特徴.(故にQuaternion)
--3次元ベクトルの比率で基準となる角度が決まり,ベクトルの要素の和で回転角が決まる.
-jacobianにCvMat*型の行列(3x9か9x3)を指定すると,編微分係数行列を返す
-The src or the dst needs to be a vector ( size either (1x3) or (3x1) ), and the other one needs to be a matrix (3x3).
-It doesn't work if both variables are same size.
--The rotation matrix can be expressed by 3 rotation angle for the 3 axises. On the other hand, there's still an ambiguation on from which axis to rotate.
--The ambiguation can be resolved by using "Quaternion".
--See the detail on Wikipedia about [[Quaternion>http://en.wikipedia.org/wiki/Quaternion]]
--Quaternion expresses the 3 rotation angle by 4 parameters.
--3 parameters express 1 axis, and the other parameter expresses the rotation angle on the axis.
--In OpenCV, the 3 parameters for the axis are expressed by ratio of the 3 parameters in the vector. 4th parameter is expressed by the sum of the 3 parameters.
-(Option)If the jacobian matrix (size 3x9 of 9x3) is given, this function returns the partial derivative coefficient matrix
*サンプルコード [#sb9dc12e]
CvMat *R = cvCreateMat(3,1,CV_64F);
CvMat *Rx = cvCreateMat(3,3,CV_64F);
cvmSet(R, 0, 0, 30*CV_PI/180);
cvRodrigues2(R, Rx);
これだと,あまり有り難味が無いコードだけれどね.
*実体ファイル [#pcb155d5]
-[[:OpenCV 1.0]][[:OpenCV 1.1]]
--cv/include/cv.h
--cv/src/cvcalibration.cpp
-[[:OpenCV 2.3]]以降
--modules/calib3d/include/opencv2/calib3d/calib3d.hpp
--modules/calib3d/src/calibration.cpp
ジャンル[[:OpenCV]][[:OpenCV 1.0]][[:OpenCV 2.3]][[:OpenCV 2.4]]準拠
-->%pi
%pi =
3.1415927
-->x = (30/180) * %pi
x =
0.5235988
-->y = (10/180) * %pi
y =
0.1745329
-->z = %pi / 2
z =
1.5707963
-->rx = [1 0 0 ; 0 cos(x) -sin(x); 0 sin(x) cos(x)]
rx =
1. 0. 0.
0. 0.8660254 - 0.5
0. 0.5 0.8660254
-->ry = [cos(y) 0 -sin(y); 0 1 0; sin(y) 0 cos(y)]
ry =
0.9848078 0. - 0.1736482
0. 1. 0.
0.1736482 0. 0.9848078
-->rz = [cos(z) sin(z) 0;-sin(z) cos(z) 0 ; 0 0 1]
rz =
6.123D-17 1. 0.
- 1. 6.123D-17 0.
0. 0. 1.
-->R = rz * ry * rx
R =
6.030D-17 0.8660254 - 0.5
- 0.9848078 0.0868241 0.1503837
0.1736482 0.4924039 0.8528685
-->R(1,2)
ans =
0.8660254
-->xx = atan(R(3,2),R(3,3))
xx =
0.5235988
-->yy = -asin(R(3,1))
yy =
- 0.1745329
-->zz = atan(R(2,1),R(1,1))
zz =
- 1.5707963