0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Blender上のシミュレーションでカメラ行列(Intrinsic)を理解する

0
Last updated at Posted at 2026-09-28

この記事について

この記事では、カメラ行列の一つであるIntrinsicを、Blender上での実験を通して理解します。

カメラ行列

カメラ行列には、intrinsic, extrinsicという2つの行列が存在します。

Extrinsic:三次元空間の座標(World Coordinate)→カメラ座標(Camera Coordinate)に変換
Intrinsic:カメラ座標(Camera Coordinate)→ピクセルの座標(Pixel Coordinate)に変換

Extrisicは、カメラがある位置、ある角度に置かれているときに、とある三次元空間上の物体がカメラから見て位置$(x,y,z)$に見えるという関係を表します。

Intrinsicは、カメラから見て物体が$(x,y,z)$にあるなら、画像上では$(X,Y)$に映るという関係を表します。

Intrinsic

焦点距離を$f$(m), 画像のサイズを$N$,$M$(pixels), 画像の中心を$c_x,c_y$(pixels),
カメラのセンサーサイズを$w,h$(m)として、$ a = f N / w, b =f M / h$ とすると

Intrinsic$K$は、以下のようになります。


K =\left[
\begin{matrix} 
a & 0 & c_x & 0 \\ 
0 & b & c_y & 0 \\
0 & 0 & 1   & 0 \\
\end{matrix}
\right]

Blenderを用いた実験

CGソフトBlenderを用いて、実際に3次元シーンから画像をレンダリングし、実際に上記のIntrinsicを用いて計算した通りの位置に物体が写っているか検証します。

シーン

Intrinsic_exp_setting.png

設定

平面 (背景として置くだけなので、スケール値は十分大きければ問題なし)

x y z
位置 0 0 10
回転 0 0 0
スケール 3.600 3.600 3.600

キューブ (カメラに向く面を4色に色分け)

x y z
位置 0 0 9
回転 0 0 0
スケール 1.000 1.000 1.000

カメラ(視線方向はZ軸正) 

x y z
位置 0 0 0
回転 180 0 180
スケール 1.000 1.000 1.000

照明(Area, 1000 W)

x y z
位置 0 0 -5
回転 180 0 0
スケール 1.000 1.000 1.000

カメラの設定

焦点距離: 50 mm
センサーサイズ: 36 mm

に設定

出力(Output)

出力する画像のサイズを

Resolution X: 1080 px
Resolution Y: 1080 px

に設定 (今回は、簡単のため正方形のセンサーに合わせる)

理論値の計算

今回、カメラは三次元空間(World Coordinate)の原点上にあるため、三次元空間の座標とカメラ座標は一致します。

また、Pythonのplotlyで画像を読み込むため、画像の原点は画像の左上となり、$a, b$はともに負の値になります。
$m, n = 1080 (px), w,h = 36 (mm), f = 50 (mm) $より、$a = b = -1500 $
$c_x, c_y = 1080/2 = 540 (px) $

カメラのIntrinsicは、


K =\left[
\begin{matrix} 
-1500 & 0 & 540 & 0 \\ 
0 & -1500 & 540 & 0 \\
0 & 0 & 1   & 0 \\
\end{matrix}
\right]

ここで、キューブ下面の左上の点P$(x,y,z) = (1,1,8)$がピクセル座標上でどの位置に見えるかの理論値を計算してみましょう。(赤い部分の角)
点Pの座標は非同次座標(Homogeneous Coordinate)で表すと$(1,1,8,1)$


KP =\left[
\begin{matrix} 
-1500 & 0 & 540 & 0 \\ 
0 & -1500 & 540 & 0 \\
0 & 0 & 1   & 0 \\
\end{matrix}
\right]
\left[
\begin{matrix} 
1  \\ 
1 \\
8 \\
1 \\
\end{matrix}
\right]

=

\left[
\begin{matrix} 
2,820  \\ 
2,820 \\
8 \\
\end{matrix}
\right]



=

\left[
\begin{matrix} 
352.5  \\ 
352.5 \\
1 \\
\end{matrix}
\right]

上記より、点Pは、画像上の(352,352),(353,353)付近に見えるはずです。

結果

PythonのPlotlyで画像の読み込みと可視化を行った結果

intrinsic_exp.png

(352,352),(353,353)付近にキューブの左上の点が写されていることが確認できます。
intrinsicexp_zoom.png

Plotlyの可視化結果では、マウスを画像にホバーさせることで、その画素の画素値が表示させるため、簡単に画素値を確認することができます。

参考文献

MITのFoudation of Computer VisionというサイトのSection 39のCamera Modeling and Calibrationに記載されている説明、数式を参考にしています。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?