スライド 1

視覚の幾何学1
呉海元@和歌山大学
参考書
佐藤 淳:
「コンピュータビジョン -視覚の幾何学-」
コロナ社
Single view geometry
Camera model
Single view geom.
カメラモデル(Camera model)
画像内の一点と3次元空間中の光線の関係
?
投影・射影関係によって決定
⇒ この関係を記述するモデルが複数ある
投影( Projections )

投影:m次元からn次元への変換 (m>n)
• CV: 3D to 2D
投影中心
投影面
投影面
平行投影・正射影
透視投影
理想的なカメラ
●3次元空間のある点から発せられた光はレ
ンズによって一点に集光される
●光がレンズに入射する角度に応じて集光さ
れる位置が変わる
●どのような角度で入射した平行な光もすべ
てある一つの平面上に集光される
☆この平面上に撮像素子を置いておけば,ピントの合った画像が得られる
ピンホール・カメラ(pinhole camera)
●視覚を情報処理として考える場合には必ずし
も実際のカメラの物理的な投影をそのまま考え
る必要はない
●カメラの幾何学的な性質のみを考えるのであ
れば、レンズの中心の一点のみに注目し、撮
像素子に至る光はすべてこの一点を通過してく
るものと考えるほうが扱いやすい
●このようなカメラをピンホール・カメラと呼ぶ
ピンホール・カメラ
f
Pinhole
Object
Image plane
●撮像素子が置かれる面を画像面(image plane)
●すべての光が通過する点(pinhole)を光学中心
(optical center)
●光学中心と画像面との間の距離を焦点距離f(focal
length)
ピンホール・カメラ
Pinhole
Object
Image plane
特徴:
●ピント合わせの必要がない
●投影の幾何学的な性質がそのまま保存されている
●視覚の幾何を考えるうえで理想的な性質を持つ
ピンホール・カメラ
●仮想的に画像面(Virtual image plane)を光学中心
の前(対象物側)に置くと、まったく同じ像が上下逆転せ
ずに投影される
●画像面を光学中心の前に出すことによって投影がよ
り扱いやすくなる
●普通、画像面を対象物側に置いて考える
もちろん、光学中心の後ろのまま考える場合もある
Pinhole
Image plane
Virtual
Object
image plane
画像面の場所によって、
数式の±記号の差がある
Pinhole camera image
Amsterdam: what do you see in this picture?
straight
line
size
parallelism/angle
shape
shape
of planes
depth
Photo by Robert Kosara, [email protected]
http://www.kosara.net/gallery/pinholeamsterda
m/pic01.html
Pinhole camera image
Amsterdam
straight line
size
parallelism/angle
shape
shape
of planes
depth
Photo by Robert Kosara, [email protected]
http://www.kosara.net/gallery/pinholeamsterda
m/pic01.html
Pinhole camera image
Amsterdam
straight line
size
parallelism/angle
shape
shape
of planes
depth
Photo by Robert Kosara, [email protected]
http://www.kosara.net/gallery/pinholeamsterda
m/pic01.html
Pinhole camera image
Amsterdam
straight line
size
parallelism/angle
shape
shape
of planes
depth
Photo by Robert Kosara, [email protected]
http://www.kosara.net/gallery/pinholeamsterda
m/pic01.html
Pinhole camera image
Amsterdam
straight line
size
parallelism/angle
shape
shape
of planes
depth
Photo by Robert Kosara, [email protected]
http://www.kosara.net/gallery/pinholeamsterda
m/pic01.html
Pinhole camera image
Amsterdam
straight line
size
parallelism/angle
shape
shape

of planes
parallel to image
depth
Photo by Robert Kosara, [email protected]
http://www.kosara.net/gallery/pinholeamsterda
m/pic01.html
Pinhole camera image
Amsterdam: what do you see?
straight line
size
parallelism/angle
shape
shape

of planes
parallel to image
Depth
?
stereo
- We see spatial shapes rather than individual pixels
motion
size
structure
…
- Knowledge: top-down vision belongs to human
- Stereo & Motion most successful in 3D CV & application
- You can see it but you don't know how…
透視投影 (Perspective Projection)
Pinhole
Virtual
image plane
Image plane
簡略されたモデル:
z
y’
y
O
x
x’
Object
透視投影 (Perspective Projection)


消失点




点⇒点
線⇒線
面⇒面
ポリゴン⇒ポリゴン
遠い物体が小さい
奥行き情報が得られない
透視投影モデル
y’
y
(x’, y’, z’)
(x, y, z)
(x,y,z)から(x’,y’,z’)へ投影:
(相似三角関係より)
z
z’
z
x’
O
x
x’
仮定:
原点をレンズの中心に
Z軸と光軸と同じ
x
z
y
y  z
z
z  z
x  z 
(f = Z’)
●透視投影はZに関し非線形である
★幾何関係だけ考える理論系の人はよくf=1とする
x
同次座標系
Homogenous Coordinates
cartesianworld
coordinates
homogenous world
corrdinates


 

( X , Y , Z )  (kX , kY , kZ , k )
cartesian world
coordinates





C1 C2 C3
(C1 , C2 , C3 , C4 )  ( , , )
C4 C4 C4
homogenous world
corrdinates
カメラのパラメータ
Camera Parameters

画像座標系Image coordinates

画素の有効サイズEffective size of pixel in millimeter
(ximage, yimage)
 画像中心Image center
(ox, oy)
 カメラ座標系Camera coordinates
(xcamera, ycamera)
 ワールド座標系Real world coordinates (X, Y, Z)
 焦点距離Focal length
f
(kx, ky)
カメラのパラメータ
ximage  k x xcamera  ox
yimage  k y ycamera  o y
 ximage  k x
y
0
 image  
 1   0
U image  k x
V
0
 image  
 S   0
U image  k x
V
0
 image  
 S   0
0
ky
0
ox   f
o y   0
1   0
0
f
0
0
ky
0
0
ky
0
X 
0 0  
Y


0 0
Z 
1 0  
1
ox   xcamera 
o y   ycamera 
1   1 
ox  U camera 
o y   Vcamera 
1   S 
fX
fY
Z
カメラのパラメータ
U image  k x
V
0
 image  
 S   0
U image   fk x
V
 0
 image  
 S   0
0
ky
0
0
fk y
0
X 
0 0  
Y


0 0
Z 
1 0  
1
ox   f
o y   0
1   0
0
f
0
ox
oy
1
X 
0  
Y


0
Z 
0  
1
f x  fk x
f y  fk y
カメラの内部パラメータ
Intrinsic Camera Parameters
y
 fx
x
 fy



ox
oy
p (x,y,f)
O
Size:
(Sx,Sy)
ox
(0,0)
xim
o
Pixel
(xim,yim)
y
yim
内部パラメータはワールド座標系内のカメラの位
置と姿勢と依存しない
X 
U image   f x
V
0
 image  
 S   0
0
fy
0
ox
oy
1
0  
Y


0
Z 
0  
1
カメラの内部パラメータII
(x, y)

レンズのひずみ
Lens Distortions
k1 , k2
(xd, yd)
カメラの内部パラメータII
(x, y)


レンズのひずみ
Lens Distortions
(xd, yd)
k1 , k2
Modeled as simple radial distortions
• r2 = xd2+yd2
x  xd (1  k1r 2  k2r 4 )
• (xd , yd) distorted points
y  yd (1  k1r 2  k2r 4 )
• k1 , k2: distortion coefficients
• A model with k2 =0 is still accurate for
a CCD sensor of 500x500 with ~5
pixels distortion on the outer boundary
カメラの外部パラメータ
Extrinsic Camera Parameters

外部パラメータはワールド座標系内のカメラの位置
と姿勢によって決定される
• 平行移動Translation (3x1ベクトル)
• 回転Rotation (3x3行列)
xim
(xim,yim)
yim
O
y
x
p
R
t
P
Zw
Pw
Xw
O
Yw
平行移動(Translation)

(tx, ty, tz) Translation vector
 X camera   X world  t x 
Y
  Y
  t 
 camera   world   y 
 Z camera   Z world  t z 
 X camera  1 0 0 t x   X world 
Y
 0 1 0 t   Y

y   world 
 camera   
 Z camera  0 0 1 t z   Z world 

 


1
0
0
0
1
1

 

 
Translation Matrix
 X camera   X world 
Y
 Y

camera
world

  t

 Z camera   Z world 

 

1
1

 

平行移動(Translation)

Inverse translation
1
0
t
0

0
0
1
0
0
0 tx 
0 t y 
1 tz 

0 1
1
0
t 1  
0

0
1
0
tt1  
0

0
0
1
0
0
0 t x  1 0 0  t x  1
0 t y  0 1 0  t y  0

1 t z  0 0 1  t z  0

 
0 1  0 0 0 1  0
0  tx 
0  t y 
1  tz 

0 1 
0
1
0
0
0
1
0
0
0
0
1
0
0
0
I
0

1
回転(Rotation)
Y

R
Z-軸周り
X  R cos
Y  R sin 

(X’,Y’,Z’)
R

X
Z
X
Y




X   R cos     R cos cos  R sin  sin 
X
Y




Y   R sin     R cos sin   R sin  cos
X   X cos   Y sin 
Y   X sin   Y cos 
(X,Y,Z)
 X  cos
 Y     sin 
  
 Z   0
 sin 
cos
0
0  X 
0  Y 
1  Z 
回転(Rotation)




X-軸周り
Y-軸周り
Z-軸周り
回転なし
0
1
R X  0 cos
0 sin 

 sin  
cos 
0
cos
R Y   0
 sin 
0  sin  
1
0 
0 cos 
cos
R Z   sin 
 0
 sin 
cos
0
1 0 0 
R  0 1 0
0 0 1
0
0
1
回転(Rotation)

Inverse rotation
Z
 
R .R
cos
 sin 

 0

Z T
I
 sin 
cos
0
0  cos
0  sin 
1  0
sin 
cos
0
0 1 0 0
0  0 1 0
1 0 0 1
回転行列は直交行列!! R 1  RT , i.e. RRT  RT R  I
1 i  j
Ri  R j  
0 otherwise
T
回転行列とEuler角

回転行列: 3x3
• 直交行列Orthogonal :
R 1  RT , i.e. RRT  RT R  I
T
 r11 r12 r13  R1 
 
R  rij
 r21 r22 r23   RT2 
33
 r31 r32 r33  RT3 
 
 
• 9 elements => 3+3 constraints (orthogonal) => 2+2 constraints
(unit vectors) => 3 DOF 自由度 (degrees of freedom)

, ,  はX, Y, Z軸周りの回転角



R  R Z RY R X

O
注意:

• 一回一つの角度しか回転できない
• 順番と関係がある
Zw
Xw

Yw

回転行列とEuler角
R  RZ RY RX
cos  cos

R   sin  sin  cos  cos sin 
 cos sin  cos  sin  sin 

 cos  sin 
sin 
 sin  sin  sin   cos cos
cos sin  sin   sin  cos
If angle  is small, then cos =1
and sin = また * + = 
 1   
R   
1   
  
1 

 sin  cos  
cos cos 
O

Zw
Xw

Yw

カメラのパラメータ


ワールド座標系とカメラ座標系の下
tx, ty, tz と r1,1…r3,3 はカメラ外部パラメータ
Xcamera  RXworld  T
 X camera   r1,1 r1, 2
Y
 r
r
camera
2
,
1
2, 2


 Z camera   r3,1 r3, 2

 
0
 1  0
r1,3 t x   X world 



r2,3 t y   Yworld 
r3,3 t z   Z world 


0 1  1 
カメラのパラメータ

ワールド座標系と画像座標系の下で
U image   fk x
V
 0
 image  
 S   0
U image   fk x
V
 0
 image  
 S   0
0
fk y
0
0
fk y
0
ox
oy
1
 X camera 
0 

Y
0  camera 
 Z camera 
0 

1


ox
oy
1
 r1,1 r1, 2
0 
r2,1 r2, 2


0
 r3,1 r3, 2
0 
0
0
r1,3 t x   X world 
r2,3 t y   Yworld 
r3,3 t z   Z world 


0 1  1 
ピンホールカメラモデル
ximage  ox   f x
yimage  oy   f y
r1,1 X world  r1, 2Yworld  r1,3 Z world  t x
r3,1 X world  r3, 2Yworld  r3,3 Z world  t z
r2,1 X world  r2, 2Yworld  r2,3 Z world  t y
r3,1 X world  r3, 2Yworld  r3,3 Z world  t z
透視投影モデル
y’
y
(x’, y’, z’)
(x, y, z)
(x,y,z)から(x’,y’,z’)へ投影:
(相似三角関係より)
z
z’
z
x’
O
x
x’
仮定:
原点をレンズの中心に
Z軸と光軸と同じ
x
z
y
y  z
z
z  z
x  z 
(f = Z’)
●透視投影はZに関し非線形である
★幾何関係だけ考える理論系の人はよくf=1とする
x
正射影 (orthographic projection)
●正射影画像面に垂直な軸に沿って投影するもの
●Z軸方向の情報が失われ, X軸とY軸方向の座標は
そのまま保存される
●正射影はZに関し線形であり数学
的にははるかに扱いやすい
●正射影は実際のカメラによる投影
とは掛け離れたものであり,この投影
モデルがCVの分野に応用できる場
合は稀である
正射影モデル
y
(x’, y’, z’)
(x, y, z)
z
O
x
Projection from (x,y,z) to (x’,y’,z’):
x  x
y  y
or
z   z  const
x  kx
y   ky
z   const
出席チェック
1.ピンホールカメラ(透視投影モデル)の原理図
を描き、撮影された画像の特徴について述べな
さい