2009年2月7日土曜日

MATLABでキャリブレーションできるらしい?

MATLAB camera calibration toolboxでキャリブレーションすると、ほとんどARToolkitPlusが必要とするのと同じ形式でパラメタが得られるらしい。

Description of Calibration Parametersの項を見ると、2次元ベクトルであるfc, cc(これがARToolkitPlusのパラメタfc_x, fc_y, cc_x, cc_yにあたるのだろう)と、5次元ベクトルであるkc, そしてスカラalpha_cが得られる結果であるらしい。

そして、First Calibration Exampleのページを見ると、
Notice that the skew coefficient alpha_c and the 6th order radial distortion coefficient (the last entry of kc) have not been estimated (this is the default mode). Therefore, the angle between the x and y pixel axes is 90 degrees. In most practical situations, this is a very good assumption.
と書いてある。つまり、alpha_cはピクセルのx軸とy軸のなす角度の90度からのズレを表していて、これは普通無視して良く、実際ARToolkitPlusのキャリブレーションパラメタに対応するパラメタはない。一方で、ARToolkitPlusはkc_1からkc_6までを要求するが、このToolboxではkc_6は計算しないのがデフォルト。という事は得られた5次元ベクトルkcの要素を順にkc_1,..., kc_5とし、kc_6は0とすれば良いわけだ。

ARToolkitPlusのカメラキャリブレーションファイルの形式
ARToolKitPlus_CamCal_Rev02
xsize ysize cc_x cc_y fc_x fc_y kc1 kc2 kc3 kc3 kc5 kc6 iter
と比較すると、結局、iterは好きな数を指定し、xsize, ysizeはキャリブレーションに用いた画像のサイズを指定し、そしてcc_x, cc_y, fc_x, fc_y, kc1,..., kc_6はこのツールボックスの出力から得られる事になる。

Matlabを持っていないので試せないけれどね。

追記:というか、ARToolkitPlusのページには、
Improved camera calibration model (MATLAB camera calibration toolbox support)

As of version 2.0, ARToolKitPlus is compatible with the camera calibration
model used by Jean-Yves Bouguet's Camera Calibration Toolbox for MATLAB. An improved version of the toolbox (highly recommended) that includes automated corner/calibration object detection is available
from the Graphics Media Lab at Moscow State University.

The ASCII-file containing the camera calibration parameters should look as follows:
[line1]: ARToolKitPlus_CamCal_Rev02
[line2]: xsize ysize cc_x cc_y fc_x fc_y kc1 kc2 kc3 kc3 kc5 kc6 iter

xsize, ysize: calibrated frame dimensions (does not have to match the frame dimensions at runtime)
cc_x, cc_y: principal point location (in pixels)
fc_x, fc_y: focal length (in pixels)
kc1..kc6: radial/tangential distortion coefficients (kc6 currently not in use)
iter: number of iterations for distortion compensation

It is strongly recommended to enable undistortion lookup tables when using the improved calibration model.
A detailed description of the calibration parameters is available here.
と書いてあるので、kc_1からkc_5までをツールボックスの出力から取得して、kc_6は0にするという事で本当にかまわないようだ。それから、iterは大きい方が計算精度が上がるが時間がかかる、と。いいなー。MATLAB欲しいなあ。

0 件のコメント: