Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
Perspective & Camera Placement
Lecture 10, September 15th 2015
Announcements • Homework Due 1 week from today
– All models now accessible on-line – Are there any questions?
9/16/15
© Ross Beveridge & Bruce Draper
2
Dodecahedron Beethoven Bunny
Orthographic / Perspective Think About Rays
9/16/15
© Ross Beveridge & Bruce Draper
3
Overview – 3 Formulations
• Differ in placement of the origin • Differ in how they handle z • Form #1:
– Origin at focal point, z values constant • Form #2:
– Origin at image center, z values constent (0) • Form #3:
– Origin at focal point, z proportional to depth
9/16/15
© Ross Beveridge & Bruce Draper, CS 410 CSU 2014
4
The key to perspective projection is that all light rays meet at the PRP (focal point). Notice that we are looking down the Z axis, with the origin at the focal point and the image plane at z = d. v
z
P(x,y,z)
Pv
d
Pz
Py
Perspective Projection Form #1
9/16/15
© Ross Beveridge & Bruce Draper
5
Pu Px d Pz
= Pv Py d Pz =
Pu = Pxd Pz
Pv = Pyd Pz
Pu = Px d Pz
Pv = Py d Pz
by similar triangles:
9/16/15
© Ross Beveridge & Bruce Draper
6
horizontal ver-cal
Perspective Projection Matrix
9/16/15
© Ross Beveridge & Bruce Draper
7
Problem: division of one variable by another is a non-linear operation. Solution: homogeneous coordinates!
1 0 0 0 0 1 0 0 0 0 1 0 0 0 1/d 0
Perspective Matrix (II)
9/16/15
© Ross Beveridge & Bruce Draper
8
Projection Matrix times a Point Point in
Non-normalized Homogeneous
coordinates
Normalized Point in
(u,v) coordinates
uvd1
!
"
####
$
%
&&&&
=
x dz
y dzd1
!
"
#######
$
%
&&&&&&&
=
xyzzd
!
"
#####
$
%
&&&&&
=
1 0 0 00 1 0 00 0 1 00 0 1
d 0
!
"
#####
$
%
&&&&&
xyzw
!
"
####
$
%
&&&&
What about other views? • What if the camera’s focal point isn’t
at the origin? • What if the camera isn’t looking down
the z axis?
9/16/15
© Ross Beveridge & Bruce Draper
Slide 9
Hey, we get to pick the coordinate system! If we aren’t at the origin looking down Z, change the coordinate system so that we are!
X’ = PRT X
Camera Coordinate System
• Focal point is at (0,0,0).
• PRP (not shown) is at (0,0,-d)
• Image u is red • Image v is green • VUP is yellow • Camera z is blue
9/16/15
© Ross Beveridge & Bruce Draper
Slide 10
Formally, the view reference coordinate system
FP
How is this done?
9/16/15
© Ross Beveridge & Bruce Draper
Slide 11
• Placing the camera is a simple translation.
§ What about orientation?
VRP =
vrpxvrpyvrpz1
T =
1 0 0 − fpx0 1 0 − fpy0 0 1 − fpz0 0 0 1
Need to Orient the Camera
9/16/15
© Ross Beveridge & Bruce Draper
Slide 12
• Where is the camera pointing? – Define a “look at” point ( – Similar to axis is axis-angle rotation
• Define which way is up.
Color coded axes: red for x, green for y, blue for z.
Point the Z-Axis away.
9/16/15
© Ross Beveridge & Bruce Draper
Slide 13
• Somewhat counter intuitive at first. • Standard convention is camera looks down the
negative z-axis. – Away from look-at point
Recap, Where Are We?
9/16/15
© Ross Beveridge & Bruce Draper
14
• Translate the camera to the focal point (-fx, -fy, -fz) • Specify a “look-at” point • The normalized vector from the look-at point to the
focal point (i.e. the origin) is the z axis. – The z axis is camera coordinates is called the View
Plane Normal (VPN)
L =
LxLyLz1
n =
nxnynz1
=1
Lx2 + Ly
2 + Lz2⋅
LxLyLz1
xcyczc1
=
? ? ? 0? ? ? 0nx ny nz 0
0 0 0 1
1 0 0 − fpx0 1 0 − fpy0 0 1 − fpz0 0 0 1
xmymzm1
Transformation So Far
9/16/15
© Ross Beveridge & Bruce Draper
15
CAMERA Z AXIS Recognize that this projects translated model points onto a basis vector defining the camera z axis!
CAMERA X AND Y AXIS We need to define unit length basis vectors for these other directions.
How Do You Hold a Camera
9/16/15
© Ross Beveridge & Bruce Draper
16
• Consider life in a world with Gravity. • Gravity means there is an “up”. • Good photographers keep their cameras level. • Which of these looks right to you ….
up
VPN & UP Define Horizontal • The horizontal axis u is perpendicular to • … a plane defined by the VPN and VUP.
9/16/15
© Ross Beveridge & Bruce Draper
17
n = VPNVPN
u = VUP×nVUP×n
v = n×u
Move the World (or the camera)
9/16/15
© Ross Beveridge & Bruce Draper
18
• Translate then Rotate to put the world into camera coordinates
xcyczc1
=
ux uy uz 0
vx vy vz 0
nx ny nz 0
0 0 0 1
1 0 0 − fpx0 1 0 − fpy0 0 1 − fpz0 0 0 1
xmymzm1
Internal camera parameters • VRP, VPN & VUP are “external”
– Often called external camera parameters.
– Position/orientation camera relative to scene.
• “Internal” parameters are camera properties. – Focal length
– Field-of-view
• The projection matrix depends on the FoV
9/16/15
© Ross Beveridge & Bruce Draper
19
Camera Projection Matrices
9/16/15
© Ross Beveridge & Bruce Draper
20
uv−dw
=
1 0 0 00 1 0 00 0 1 00 0 1
d 0
ux uy uz 0
vx vy vz 0
nx ny nz 0
0 0 0 1
1 0 0 − fpx0 1 0 − fpy0 0 1 − fpz0 0 0 1
xmymzm1
uv−dw
=M
xmymzm1
X’=MX =PRT X
Let’s Visualize This…
9/16/15
© Ross Beveridge & Bruce Draper
21
image
fp
Look at point y
x
z
VUP image
fp
Look at point
VPN
u
image
fp VPN
u
World Coordinates + Focal Point + Look-at Point + VUP
Camera Coordinates = RTX
Image Coordinates = PRT X
Now some questions • How many world points (x, y, z) project onto a
single image point (u, v)? • What is the determinant of M = PRT?
– Explain geometrically – (M369 students) Explain algebraically
• Where do points behind the camera project to?
• What about points between the focal point and image plane?
• What about points on the image plane?
9/16/15
© Ross Beveridge & Bruce Draper
22
Example Problem
• Create the projection matrix for the following camera:
• Focal Point at (1,1,1) • Look at point at (0,0,0) • VUP of (0,2,0) • Focal Length = 4
9/16/15
© Ross Beveridge & Bruce Draper
23 9/16/15
© Ross Beveridge & Bruce Draper, CS 410 CSU 2014
Slide 24
General Approach
X’ = PRT X
First Step: T
1 0 0 −10 1 0 −10 0 1 −10 0 0 1
"
#
$$$$
%
&
''''
9/16/15
© Ross Beveridge & Bruce Draper
Slide 25
Next Step: R
You need to calculate u, v, &n
VPN =−1−1−1
VPN = −12 + −12( )+ −12( ) = 3 n = VPNVPN
=
−13
−13
−13
ux uy uz 0
vx vy vz 0
nx ny nz 0
0 0 0 1
!
"
#####
$
%
&&&&&
9/16/15
© Ross Beveridge & Bruce Draper
26
R (continued)
u = (VUP × n) /|VUP × n|
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
−−−⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
−−−3
13
13
1020
31
31
31
020zyxzyx
u = (-2/√3-0, 0-0, 0--2/√3)/|u|
u = (-1/√2, 0, 1/√2)
|u| = √(4/3 + 4/3) = √(8/3) = 2√2/√3
9/16/15
© Ross Beveridge & Bruce Draper
27
R (part III)
v = (-1/ √3, -1/ √3, -1/ √3) × (-1/ √2, 0, 1/√2) = (-1/√6, 2/√6, -1/√6)
v = n × u
⎥⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢⎢
⎣
⎡
−
−−−
⎥⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢⎢
⎣
⎡
−
−−−
210
21
31
31
31
210
21
31
31
31
zyxzyx
Note the magnitude of v!
9/16/15
© Ross Beveridge & Bruce Draper
28
(cont.) Next Step: R
Q: How can you check this?
−12
0 12
0
−16
26
−16
0
−13
−13
−13
0
0 0 0 1
"
#
$$$$$$$$$
%
&
'''''''''
9/16/15
© Ross Beveridge & Bruce Draper
29
Next Step: P
Remember the Focal Length is 4
1 0 0 00 1 0 00 0 1 0
0 0 14
0
!
"
######
$
%
&&&&&&
9/16/15
© Ross Beveridge & Bruce Draper
30
Laying it out: PRT
−12
0 12
0
−16
26
−16
0
−13
−13
−13
0
0 0 0 1
"
#
$$$$$$$$$
%
&
'''''''''
1 0 0 −10 1 0 −10 0 1 −10 0 0 1
"
#
$$$$
%
&
''''
T R P
1 0 0 00 1 0 00 0 1 0
0 0 14
0
!
"
######
$
%
&&&&&&
9/16/15
© Ross Beveridge & Bruce Draper
31
−12
0 12
0
−16
26
−16
0
−13
−13
−13
0
−14 3
−14 3
−14 3
0
"
#
$$$$$$$$$$
%
&
''''''''''
1 0 0 −10 1 0 −10 0 1 −10 0 0 1
"
#
$$$$
%
&
''''
Multiplying PR
9/16/15
© Ross Beveridge & Bruce Draper
32
Final Solution −12
0 12
0
−16
26
−16
0
−13
−13
−13
33
−14 3
−14 3
−14 3
34 3
"
#
$$$$$$$$$$
%
&
''''''''''
Checking the Answer
9/16/15
© Ross Beveridge & Bruce Draper
33
FP - aVPN is the optical axis
(1,1,1) - 4(-1,-1,-1) = (5,5,5)
0041
!
"
####
$
%
&&&&
=
00
−123
−124 3
!
"
######
$
%
&&&&&&
=
12
0 −12
0
−16
26
−16
0
−13
−13
−13
33
−14 3
−14 3
−14 3
34 3
!
"
##########
$
%
&&&&&&&&&&
5551
!
"
####
$
%
&&&&
Your Turn
• Calculate the projection matrix for the following camera: – FP = (9,0,9) – Look-at Point = (100, 0, 1) – VUP = (1,0,0)
• Can you do this?
9/16/15
© Ross Beveridge & Bruce Draper, CS 410 CSU 2014
Slide 34
No! • You also need a focal length
– alternatively, the camera could be orthographic
• Always make sure you have enough information
• Let focal length equal 4 (again)
• Now try it.
9/16/15
© Ross Beveridge & Bruce Draper
35