Download presentation
Presentation is loading. Please wait.
1
Geometry 3: Stereo Reconstruction
Introduction to Computer Vision Ronen Basri Weizmann Institute of Science
2
Material covered Pinhole camera model, perspective projection
Two view geometry, general case: Epipolar geometry, the essential matrix Camera calibration, the fundamental matrix Two view geometry, degenerate cases Homography (planes, camera rotation) A taste of projective geometry Stereo vision: 3D reconstruction from two views Multi-view geometry, reconstruction through factorization
3
Summary of last lecture
Homography Perspective (calibrated) Perspective (uncalibrated) Orthographic Form πβπ»π π π πΈπ=0 π π πΉπ=0 Properties One-to-one (group) Concentric epipolar lines Parallel epipolar lines DOFs 8(5) 8(7) 4 Eqs/pnt 2 1 Minimal configuration 5+ (8,linear) 7+ (8,linear) Depth No Yes, up to scale Yes, projective structure Affine structure (third view required for Euclidean structure)
4
Camera rotation Images obtained by rotating the camera about its optical axis are related by homography: πβπ
π (π‘=0) Verify that π does not depend on π: π₯ β² = π( π 11 π+ π 12 π+ π 13 π) π 31 π+ π 32 π+ π 33 π , π¦ β² = π( π 21 π+ π 22 π+ π 23 π) π 31 π+ π 32 π+ π 33 π π₯ β² = π 11 π₯+ π 12 π¦+ π 13 π π 31 π₯+ π 32 π¦+ π 33 π , π¦ β² = π( π 11 π₯+ π 12 π¦+ π 13 π) π 31 π₯+ π 32 π¦+ π 33 π
5
Planar scene For a planar scene πβπ»π, with π»=π
+ 1 π π‘ π π
π=π
π+π‘ and ππ+ππ+ππ=π ππ₯+ππ¦+ππ= ππ π π₯ β² = π( π 11 π+ π 12 π+ π 13 π+ π‘ π₯ ) π 31 π+ π 32 π+ π 33 π+ π‘ π§ π¦ β² = π( π 21 π+ π 22 π+ π 23 π+ π‘ π¦ ) π 31 π+ π 32 π+ π 33 π+ π‘ π§ π₯ β² = π 11 π₯+ π 12 π¦+ π 13 π+ π‘ π₯ π/π π 31 π₯+ π 32 π¦+ π 33 π+ π‘ π§ π/π π¦ β² = π 21 π₯+ π 22 π¦+ π 23 π+ π‘ π¦ π/π π 31 π₯+ π 32 π¦+ π 33 π+ π‘ π§ π/π
6
Epipolar lines πβ² π πΈπ=0 epipolar plane epipolar lines epipolar lines
Baseline O Oβ πβ² π πΈπ=0
7
Rectification Rectification: rotation and scaling of each cameraβs coordinate frame to make the epipolar lines horizontal and equi-height, by bringing the two image planes to be parallel to the baseline Rectification is achieved by applying homography to each of the two images
8
Rectification π» π π» π Baseline O Oβ πβ² π π» π βπ πΈ π» π β1 π=0
9
Cyclopean coordinates
Given a rectified stereo rig with baseline length π, we place the origin at the midpoint between the camera centers. a point π,π,π is projected to: Left image: π₯ π = π(πβπ/2) π , π¦ π = ππ π Right image: π₯ π = π(π+π/2) π , π¦ π = ππ π Cyclopean coordinates: π= π( π₯ π + π₯ π ) 2( π₯ π β π₯ π ) , Y= π( π¦ π + π¦ π ) 2( π₯ π β π₯ π ) , π= ππ π₯ π β π₯ π
10
Disparity π₯ π β π₯ π = ππ π Disparity is inverse proportional to depth
Constant disparity βΊ constant depth Larger baseline, more stable reconstruction of depth (but more occlusions, correspondence is harder) (Note that disparity is defined in a rectified rig in a cyclopean coordinate frame)
11
The correspondence problem
Stereo matching is ill-posed: Matching ambiguity: different regions may look similar
12
The correspondence problem
Stereo matching is ill-posed: Matching ambiguity: different regions may look similar Specular reflectance: multiple depth values
13
Random dot stereogram Depth is perceived from a pair of random dot images Stereo perception is based solely on local information (low level)
14
Moving random dots
15
Compared elements for correspondence
Single pixel intensities Pixel color Small window (e.g. 3Γ3 or 5Γ5), often using normalized correlation to offset gain Features and edges Mini segments
16
Dynamic programming Each pair of epipolar lines is compared independently Local cost, sum of unary term and binary term Unary term: cost of a single match Binary term: cost of change of disparity (occlusion) Analogous to string matching (βdiffβ in Unix)
17
String matching Swing β String S t r i n g Start S w i n g End
18
String matching Cost: #substitutions + #insertions + #deletions
S w i n g
20
Stereo with dynamic programming
Shortest path in a grid Diagonals: constant disparity Moving along the diagonal β pay unary cost (cost of pixel match) Move sideways β pay binary cost, i.e. disparity change (occlusion, right or left) Cost prefers fronto-parallel planes. Penalty is paid for tilted planes
21
Dynamic programming on a grid
Start π ππ = max ( π πβ1,π + πΆ πβ1,πβπ,π , π πβ1,πβ1 + πΆ πβ1,πβ1βπ,π , π πβ1,πβ1 + πΆ π,πβ1βπ,π ) Complexity?
22
Probability interpretation: the Viterbi algorithm
Markov chain States: discrete set of disparity π π 1 ,β¦, π π = π 1 ( π 1 ) π=2 π π π π π π πβ1,π ( π πβ1 , π π ) Log probabilities: product βΉ sum
23
Probability interpretation: the Viterbi algorithm
Markov chain States: discrete set of disparity β log π π 1 ,β¦, π π =β log π 1 π 1 β π=2 π (log π π π π +log π πβ1,π π πβ1 , π π ) Maximum likelihood: minimize sum of negative logs Viterbi algorithm: equivalent to shortest path
24
Dynamic programming: pros and cons
Advantages: Simple, efficient Achieves global optimum Generally works well Disadvantages:
25
Dynamic programming: pros and cons
Advantages: Simple, efficient Achieves global optimum Generally works well Disadvantages: Works separately on each epipolar line, does not enforce smoothness across epipolars Prefers fronto-parallel planes Too local? (considers only immediate neighbors)
26
Markov random field Graph πΊ= π,πΈ In our case: graph is a 4-connected grid representing one image States: disparity Minimize energy of the form πΈ(π)= (π,π)βπΈ π π,π π π , π π + πβπ π· π ( π π ) Interpreted as negative log probabilities
27
Iterated conditional modes (ICM)
Initialize states (= disparities) for every pixel Update repeatedly each pixel by the most likely disparity given the values assigned to its neighbors: min π π πβπ©(π) π π,π π π , π π + π· π ( π π ) Markov blanket: the state of a pixel only depends on the states of its immediate neighbors Similar to Gauss-Seidel iterations Slow convergence to (often bad) local minimum
28
Graph cuts: expansion moves
Assume π· π₯ is non-negative and π π₯,π¦ is metric: π π₯,π₯ =0 π π₯,π¦ =π π¦,π₯ π π₯,π¦ β€π π₯,π§ +π π§,π¦ We can apply more semi-global moves using minimal s-t cuts Converges faster to a better (local) minimum
29
Ξ±-Expansion In any one round, expansion move allows each pixel to either change its state to Ξ±, or maintain its previous state Each round is implemented via max flow/min cut One iteration: apply expansion moves sequentially with all possible disparity values Repeat till convergence
30
Ξ±-Expansion Every round achieves a globally optimal solution over one expansion move Energy decreases (non-increasing) monotonically between rounds At convergence energy is optimal with respect to all expansion moves, and within a scale factor from the global optimum: πΈ( π ππ₯ππππ πππ )β€2ππΈ( π β ) where π= max πΌβ π½βπ π(πΌ,π½) min πΌβ π½βπ π(πΌ,π½)
31
Ξ±-Expansion (1D example)
π π π π
32
Ξ±-Expansion (1D example)
πΌ πΌ
33
Ξ±-Expansion (1D example)
πΌ π· π (πΌ) π· π (πΌ) π ππ πΌ,πΌ =0 πΌ
34
Ξ±-Expansion (1D example)
πΌ But what about π ππ ( π π , π π )? π· π ( π π ) π· π ( π π ) πΌ
35
Ξ±-Expansion (1D example)
πΌ π ππ ( π π , π π ) π· π ( π π ) π· π ( π π ) πΌ
36
Ξ±-Expansion (1D example)
πΌ π· π (πΌ) π ππ ( π π ,πΌ) π· π ( π π ) πΌ
37
Ξ±-Expansion (1D example)
πΌ π· π (πΌ) π ππ (πΌ, π π ) π· π ( π π ) πΌ
38
Ξ±-Expansion (1D example)
πΌ π ππ ( π π ,πΌ) π ππ (πΌ, π π ) π ππ ( π π , π π ) Such a cut cannot be obtained due to triangle inequality: π ππ (πΌ, π π ) β€π ππ π π , π π + π ππ ( π π ,πΌ) πΌ
39
Common metrics Potts model: π π₯,π¦ = 0 π₯=π¦ 1 π₯β π¦ π π₯,π¦ = π₯βπ¦
π π₯,π¦ = 0 π₯=π¦ 1 π₯β π¦ π π₯,π¦ = π₯βπ¦ π π₯,π¦ = π₯βπ¦ 2 Truncated β 1 : π π₯,π¦ = π₯βπ¦ π₯βπ¦ <π π otherwise Truncated squared difference is not a metric
40
Reconstruction with graph-cuts
Original Result Ground truth
41
A different application: detect skyline
Input: one image, oriented with sky above Objective: find the skyline in the image Graph: grid Two states: sky, ground Unary (data) term: State = sky, low if blue, otherwise high State = ground, high if blue, otherwise low Binary term for vertical connections: If state(node)=sky then state(node above)=sky (infinity if not) If state(node)=ground then state(node below)= ground Solve with expansion move. This is a two state problem, and so graph cut finds the global optimum in one expansion move
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.