覚え書きブログ

3次元計測の覚え書き(カメラとプロジェクターのキャリブレーション編)

前回カラーマッチングにより得られたデコード画像(プロジェクターの座標系への変換テーブル)を用いたプロジェクターのキャリブレーションについて、コードの内容を基にまとめてみた。
読んだコードは、以下のkeibekibeさんのmain_projcalib.cppである。
https://github.com/kibekibe/structured_light/blob/master/projcalib_from_decoded_imgs/main_projcalib.cpp

文章で書き下すのが面倒なので、ipadのメモを貼り付けておく。。。

最後のステレオキャリブレーションに関しては、stereocalibrateとstereorectifyを用いて、プロジェクタとカメラ間のパラメータを求めている。
https://docs.opencv.org/3.0-beta/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#stereocalibrate
https://docs.opencv.org/3.0-beta/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html#stereorectify

stereocalibrateでは、以下のプロジェクターとカメラ間の回転R、並進行列Tと、Essential matrix Eと、Fundamental matrix Fを求めている。
R – Output rotation matrix between the 1st and the 2nd camera coordinate systems.
T – Output translation vector between the coordinate systems of the cameras.
E – Output essential matrix.
F – Output fundamental matrix.

また、stereorectifyでは、以下のrectification transformationなどを求めている。
R1 – Output 3x3 rectification transform (rotation matrix) for the first camera.
R2 – Output 3x3 rectification transform (rotation matrix) for the second camera.
P1 – Output 3x4 projection matrix in the new (rectified) coordinate systems for the first camera.
P2 – Output 3x4 projection matrix in the new (rectified) coordinate systems for the second camera.
Q – Output 4 \times 4 disparity-to-depth mapping matrix (see reprojectImageTo3D() ).