Projective Geometry and Camera Models: Computer Vision Jia-Bin Huang, Virginia Tech
Projective Geometry and Camera Models: Computer Vision Jia-Bin Huang, Virginia Tech
Camera Models
Computer Vision
Jia-Bin Huang, Virginia Tech
Many slides from S. Seitz and D. Hoiem
Administrative stuffs
• HWs
• HW 1 will be back this week
• HW 2 due 11:55 PM on Oct 3.
• Submit your results on shape alignment: link
• Frequently asked questions for HW 2
ws = 7; % Tracking ws x ws patches
[track_x, track_y] = ... % Prob 1.2 Keypoint tracking
trackPoints(pt_x, pt_y, im, ws);
% Visualizing the feature tracks on the first and the last frame
figure(2), imagesc(im{1}), hold off, axis image, colormap gray
hold on, plot(track_x', track_y', 'r');
HW 2 – Feature/Keypoint detection
• Threshold 0.04
• Non-maximum suppression
function [keyXs, keyYs] = getKeypoints(im, tau)
% im: input image; tau: threshold
% keyXs, keyYs: detected keypoints, with dimension [N] x [1]
% Initialization
N = numel(pt_x); % Number of keypoints
nim = numel(im); % Number of images
track_x = zeros(N, nim);
track_y = zeros(N, nim);
track_x(:, 1) = pt_x(:);
track_y(:, 1) = pt_y(:);
for i = 1: 50
end
HW 2 – Local Feature Matching
line
Vanishing
Vanishing
point
• Projection matrix
point
x K R t X
Image formation
f = focal length
c = center of the camera
3D world 2D image
Point of observation
Who is taller?
Which is closer?
Length is not preserved
A’
C’
B’
Parallel?
Perpendicular?
Projective Geometry
What is preserved?
• Straight lines are still straight
Vanishing points and lines
Parallel lines in the world intersect in the image at a
“vanishing point”
Vanishing points
Vanishing points and lines
Vanishing Point Vanishing Point
o o
Vanishing Line
Vertical vanishing
point
(at infinity)
Vanishing
line
Vanishing
Vanishing
point
point
X
Optical
Center
. P Y
(u0, v0) Y Z
. f
. Z
X
v
Camera Center
. u
(tx, ty, tz)
X
u f Z
p
v f Y
Z
Homogeneous coordinates
• Is this a linear transformation?
– no—division by z is nonlinear
Invariant to scaling
x kx
kx
w
x
k y ky ky y
kw
w kw kw w
Homogeneous Cartesian
Coordinates Coordinates
x
f 0 0 0 f x
0 y x y
f 0 0 f y (f , f )
z z z
0 0 1 0 z divide by the third
1 coordinate
Camera to World to 3D
2D Perspective
= pixel coord. camera coord. point
point projection matrix
trans. matrix trans. matrix (4x1)
(3x1) (3x4)
(3x3) (4x4)
Slide Credit: Saverese
Projection matrix
R,T
jw
kw
Ow
iw
x K R t X
x: Image Coordinates: (u,v,1)
K: Intrinsic Matrix (3x3)
R: Rotation (3x3)
t: Translation (3x1)
X: World Coordinates: (X,Y,Z,1)
Projection matrix
x
u f 0 0 0
x K I 0 X
y
wv 0 f
0 0
z
1 0 0 1 0
1
Slide Credit: Saverese
Remove assumption: known optical
center
Intrinsic Assumptions Extrinsic Assumptions
• Unit aspect ratio • No rotation
• No skew • Camera at (0,0,0)
x
u f 0 u0 0
x K I 0 X
y
wv 0 f v0
0
z
1 0 0 1 0
1
Remove assumption: square pixels
x
u 0 u0 0
y
x K I 0 X wv 0 v0
0
z
1 0 0 1 0
1
Remove assumption: non-skewed
pixels
Intrinsic Assumptions Extrinsic Assumptions
• No rotation
• Camera at (0,0,0)
x
u s u0 0
x K I 0 X
y
wv 0 v0
0
z
1 0 0 1 0
1
t kw
Ow
iw
Allow camera translation
x
u 0 u0 1 0 0 t x
x K I t X
y
wv 0
v0 0 1 0 t y
z
1 0 0 1 0 0 1 t z
1
Slide Credit: Saverese
3D Rotation of Points
1 0 0
Rx ( ) 0 cos sin
0 sin cos
p’
cos 0 sin
g
R y ( ) 0 1 0
p
y sin 0 cos
cos sin 0
Rz ( ) sin cos 0
z
0 0 1
Allow camera rotation
x K R t X
x
u s u0 r11 r12 r13 tx
y
wv 0 v0 r21 r22 r23
ty
z
1 0 0 1 r31 r32 r33 t z
1
Degrees of freedom
x K R t X
5 6
x
u s u0 r11 r12 r13 tx
y
wv 0 v0 r21 r22 r23
ty
z
1 0 0 1 r31 r32 r33 t z
1
Vanishing Point = Projection from
Infinity
x
y x xR
p K R t
p KR y p K y R
z
z z R
0
fx R
u f 0 u0 xR u u0
zR
wv 0 f v0 y R
1 0 0 1 z R fy R
v v0
zR
Scaled Orthographic Projection
• Special case of perspective projection
• Object dimensions are small compared to distance to
camera
Image World
x
u f 0 0 0
v 0 y
w f 0 0
• Also called “weak perspective” z
1 0 0 0 s
1
Slide by Steve Seitz
Orthographic Projection - Examples
Orthographic Projection - Examples
Applications in object detection
Far field: object appearance doesn’t change as objects translate
• Homogeneous
coordinates
Next class
Applications of camera model and
projective geometry