Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Camera stuff

Camera matrix P
The perspective matrix (camera matrix) P is a 3 × 4 matrix which converts points from 3D to
pixels on camera (using homogeneous coordinates):

𝑝𝑖𝑥𝑒𝑙𝑥 𝑝𝑜𝑖𝑛𝑡𝑥
𝑝𝑜𝑖𝑛𝑡𝑦
( 𝑝𝑖𝑥𝑒𝑙𝑦 )=𝑃 ×( )
𝑝𝑜𝑖𝑛𝑡𝑧
ℎ𝑜𝑚𝑜𝑔𝑒𝑛𝑜𝑢𝑠𝑃𝑎𝑟𝑡
1
It can be constructed by a multiplication of intrinsic and extrinsic camera parameters:

𝑃 = 𝐾 × [ 𝑅|𝒕 ]
𝑓𝑥 𝑠 𝑥0
Where 𝐾 = ( 0 𝑓𝑦 𝑦0 ) is the intrinsic parameters matrix ( 𝑓 are focal lengths and 𝑥0 , 𝑦0 are
0 0 1
the principal point in pixels), and [ 𝑅|𝒕 ] is the extrinsic parameters matrix which includes 𝑅 - the
rotation transformation and t the translation vector which transforms points from the lab frame of
reference to the camera frame of reference.

The camera origin 𝐶 and rotation 𝑅 c relative to the lab coordinates can be obtained using:

0 = 𝑅𝑪 + 𝒕 ⟹ 𝑪 = −𝑅 −1 𝒕

𝑅𝐶 = 𝑅 −1
The opposite transformation is given by:

𝒕 = −𝑅𝑪
The camera direction (z axis in camera coordinates) can be given by:

R−1 𝑧̂
(Need to add Pdf from the good website)
(Add camera geometry book)
Epipolar lines
𝑥
Homogeneous representation of points: (𝑥, 𝑦
𝑦) → ( )
1
𝑎
Homogeneous representation of lines: 𝑎𝑥 + 𝑏𝑦 + 𝑐 = 0 → (𝑏 )
𝑐
The fundamental matrix F
Derivation:
𝑃+ 𝑃 = 𝐼 (𝑝𝑠𝑒𝑢𝑑𝑜 𝑖𝑛𝑣𝑒𝑟𝑠𝑒)

𝑋(𝜆) = 𝑃+ 𝑥 + 𝜆𝑪

𝑙 = 𝑃′ 𝐶 × 𝑃′ 𝑃+ 𝑥

𝐹 = [𝑒 ′ ]× 𝑃′ 𝑃+

𝑙 ′ = 𝐹𝑥 𝑙 = 𝐹 𝑇 𝑥′
𝑇
𝑥 ′ 𝐹𝑥 = 𝑥 ′𝑇 𝑙′ = 0

Converting picture coordinates in matlab


Plotting the lines using fplot needs the form:
𝑎 𝑐
𝑦 = 𝑎′ 𝑥 + 𝑐 ′ → 𝑎′ = − ; 𝑏 ′ = −1; 𝑐 ′ = −
𝑏 𝑏

Matlab images have their y axis flipped hence need to be flipped:

𝑦′ = ℎ + 1 − 𝑦

For adding a crop zone (location of a part of a full image):

𝑦 ′′ = ℎ + 1 − (𝑦 + 𝑐𝑧𝑦 )

𝑥 ′′ = 𝑥 + 𝑐𝑧𝑥

You might also like