Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
5/24/2017 Stereopsis 1
Stereopsis
Raul Queiroz Feitosa
5/24/2017 Stereopsis 2
Objetive
This chapter introduces the basic techniques for a 3
dimensional scene reconstruction based on a set of projections
of individual points on two calibrated cameras.
5/24/2017 Stereopsis 3
Content
Introduction
Reconstruction
The Correspondence Problem
Rectification
5/24/2017 Stereopsis 4
Introduction
Correspondence
Detection of corresponding points in a pair of stereo
images.
Reconstruction
Based on a set of corresponding points, compute its 3D
position in the world.
5/24/2017 Stereopsis 5
Content
Introduction
Reconstruction
The Correspondence Problem
Rectification
5/24/2017 Stereopsis 6
Midpoint Triangulation
R
OP1 P1P2 P2O´ OO´ + = + + =
O
´
R´ P1
P2
P
O´
p ^
p´ normalized
frames
^
OP1
P1P2
P2O´
OO´
5/24/2017 Stereopsis 7
Midpoint Triangulation
OP1 P1P2 P2O´ OO´ + = + + (a,b and c can be computed) = a p ^ b (p Rp´) ^ ^
where R is the rotation matrix of the right camera frame and t is the vector
connecting the principal points, both in relation to the left camera frame.
Expressing the equation in the normalized left camera frame, yields:
OP1
P1P2
P2O’
OO’
t
a p ^
b (p Rp´) ^ ^
cRp´ ^
O
´
R´ P1
P2
P
O´
p ^
p´ normalized
frames
^
c R p´ ^
t
R
5/24/2017 Stereopsis 8
Midpoint Triangulation
Algorithm
Given p, p´, K, R, t, K´, R´ and t´
1. Compute
p= K -1 p
p´=K´ -1 p´
R=RR´-1 (→ rotation relative to the left camera frame)
t=-RR´-1 t´+t (→ translation relative to the left camera frame)
^
^
5/24/2017 Stereopsis 9
Midpoint Triangulation
Algorithm (cont.)
2. Compute a, b and c such that
a p + b (p Rp´)+ c Rp´=t
3. Compute CP in the left camera frame with
CP= a p + b (p Rp´)/2
4. If you wish, transform CP to the world frame,
WP= R-1 (CP – t )
^ ^ ^ ^
^ ^ ^
t ≠ t
5/24/2017 Stereopsis 10
Linear Reconstruction
It is a system with 4 independent linear equations ([p] e [p´] have rank 2).
It can be applied for more than 2 cameras.
z p = M P
z´ p´ = M´ P
p M P = 0
p´ M ´ P = 0
[p] M
[p´] M´ P = 0
5/24/2017 Stereopsis 11
Geometric Reconstruction
The point Q with images q e q’ where the rays do intercept are such that d2(p,q) + d2(p´,q´) under qTF q´ =0 is minimum a non linear system.
O
’
R R’ P1
P2
P
O’
p ^
p’ ^
q q’ ^
quadros
normalizados
^
Q
5/24/2017 Stereopsis 12
Geometric Reconstruction
Algorithm – geometric interpretation The noise free projections lie on a pair of corresponding
epipolar lines
θ(t)
p
q
l=FTq΄
e left image
θ΄(t)
p΄
q΄
l΄=Fq
e΄
right image
measured
points
optimal
points
epipolar
line
epipolar
line
5/24/2017 Stereopsis 13
Geometric Reconstruction
Algorithm outline
1. Parameterize the pencil of epipolar lines in the left image by a
parameter t l(t )
2. Using the fundamental matrix F, compute the corresponding epipolar
line in the right image l´(t )
3. Express the distance d2(p,l(t )) + d2(p´,l´(t )) explicitly as function of t
a polynomial of degree 6.
4. Find the value of t that minimizes this distance.
5. Compute q and q’ and from them Q.
Details can be found in
Multiple View Geometry in computer Vision, Hartley,R. and Zisserman, A., pp 315…
5/24/2017 Stereopsis 14
Evaluation on Real Images
From
Multiple View Geometry in computer Vision, Hartley,R. and Zisserman, A., pp 315…
0.6
0.5
0.4
0.3
0.2
0.1
0
Rec
onst
ruct
ion E
rror
0 0.05 0.1 0.15
Standard Deviation of Gaussian noise
Midpoint
Geometric
5/24/2017 Stereopsis 15
Evaluation on Real Images
Points are less precisely located along the rays as the
rays become more parallel
uncertainty regions
5/24/2017 Stereopsis 17
Content
Introduction
Reconstruction
The Correspondence Problem
Rectification
5/24/2017 Stereopsis 18
The Correspondence Problem
Introduction Assume the point P in space emits light with the same energy in all
directions (i.e. the surface around P is Lambertian)
then
I(p) =I´(p´) (brightness constancy constraint)
where p and p´ are the images of P in the views I and I´.
The correspondence problem consists of establishing relationships between p and p´, i.e.
I(p) =I´( h(p) ) ( h → deformation)
P
I1 I’ O O’
p p’
5/24/2017 Stereopsis 19
The Correspondence Problem
Introduction
It is difficult to locate an accurate match for points lying
in uniform neighborhoods.
Also difficult is the location of points close to edges.
Therefore, before we start searching for pairs of
corresponding points, it is convenient to establish which
points in one image have good characteristics for an
accurate match.
They must be in neighborhoods with high dynamics.
5/24/2017 Stereopsis 20
The Correspondence Problem
Local deformation models
We look for transformations h that model the deformation
on a domain W(p) around p=[u v]T.
Translational model
h(p) = p +Δp
Affine model
h(p) = A p + Δp,
where A R2×2
Transformation in intensity values
I(p) =I’( h(p) ) + η( h(p) )
W(p) Δp
W(p) (A,Δp)
5/24/2017 Stereopsis 21
The Correspondence Problem
Matching by Sum of Squared Differences (SSD)
We choose a class of transformation and look for the
particular transformation h that minimizes the effects of
noise integrated over a window W(p), i. e.,
If I(p)=constant, for p W(p), the same happens for I´, and
the norm being minimized does not depend on h!!!!
(blank wall effect)
pp
ppWh
hIIh~
2~~minargˆ
5/24/2017 Stereopsis 22
The Correspondence Problem
Matching by Normalized Cross-Correlation (NCC)
SSD is not invariant to scaling and shifts in image intensities
(deviation from the Lambertian assumptions).
The Normalized Cross-Correlation (NCC)
where and are the mean intensities of I and I’ on W(p).
-1 ≤ NCC ≤ 1. If =1, I(p) and I’( h(p) ) match perfectly.
pp
p
pp
pp
WW
W
IhIII
IhIIIhNCC
22 ~~
~~
I I
5/24/2017 Stereopsis 23
The Correspondence Problem
Matching by NCC
For the translational model → h(p) = p +Δp.
W(p) → - =
I(p)
I _
I(p)- I _
→ - =
I’(p+Δp)
I’ _
I’(p+Δp) -I’ _
→ v1
→ v2
NCC=
_______
||v1|| ||v2||
v1 ·v2
NCC is equal to the
cosine
between v1 and v2 W(p)
5/24/2017 Stereopsis 24
The Correspondence Problem
Matching by NCC (example)
5/24/2017 Stereopsis 25
Least Square Matching
Affine model → p´ = h(p) = A p +Δp
Let’s assume that
Thus
u´=a11u+ a12v+b1
and
v´=a21u+ a22v+b2
2
1
2221
1211 , , ,
b
b
aa
aa
v
u
v
uppp A
5/24/2017 Stereopsis 26
Least Square Matching
Affine model → p´ = h(p) = A p +Δp
Matching is established if (SSD)
→
that can be written in more compact form as …
vdv
Iud
u
IvuIvuIvuI
, ,, 00
2220210
112011000
,-,
dbdavdaug
dbdavdaugvuIvuI
v
u
5/24/2017 Stereopsis 27
Least Square Matching
Affine model → p’ = h(p) = A p +Δp
Matching is established if (SSD)
where
x ,, 00 vuIvuI
2222111211 dbdadadbdadaT x
vvvuuu gvguggvgug 0000
5/24/2017 Stereopsis 28
Least Square Matching
Affine model → p’ = h(p) = A p +Δp
Stacking the equation generated by each point in W(p) yields
It is a over determined system whose solution is given by
x = W† y
x
vnvnvununu
vvvuuu
nnnn gvguggvgug
gvguggvgug
vuIvuI
vuIvuI
,,
,,
0000
01010101
00
010111
y W
5/24/2017 Stereopsis 29
Least Square Matching
Affine model → p’ = h(p) = A p +Δp
1. Start with, k=0 and
2. k=k+1; for each (u,v) in W(p) apply the transformation to compute I’ (u’,v’), gu’ and gv’ .
3. Build the equation (previous slide) and compute x
4. Update the parameters
5. Repeat steps 2 to 4 till ||x|| goes below a certain limit.
0
2
0
100 ,10
01
b
bpA
k
k
kk
kk
kk
kk
db
db
dada
dada
2
11
2221
12111 , ppAA
5/24/2017 Stereopsis 30
Building a dense correspondence
new seed
N
new seed
W
good
match
new seed
E
new seed
S
Region Growing right
image
refine location
select a seed
good
match?
save match
create new
seeds (NSEW)
seeds?
save
matches
left
image
seed
repository
match
repository
START
END
yes
yes
no
no
5/24/2017 Stereopsis 31
Region Growing
Building a dense correspondence map with Region Growing
1. Select a seed of corresponding points manually, and add it in To_Check_List .
2. Take the first pair, delete it in To_Check_List and add it to Checked_List .
3. Refine location in right image using a correlation based method
4. If constrast > min_contrast AND correlation > min_correlation,
Put pair in the Match_List.
Add to the To_Check_List its neighbors d pixels to the North, to the South, to the East and to the West, as long as they belong neither to Checked_List nor to To_Check_List .
5. Do steps 2 to 4 till To_Check_List is empty.
5/24/2017 Stereopsis 32
Region Growing
Example
left image right image
watch
5/24/2017 Stereopsis 33
Content
Introduction
Reconstruction
The Correspondence Problem
Rectification
5/24/2017 Stereopsis 34
Rectification
Transforms a pair of stereo images in such a way that
both images stay on a single plane parallel to the baseline, and
conjugate epipolar lines are collinear and horizontal.
O O’
P
baseline
The search for corresponding points becomes 1D.
conjugate
epipolar lines
5/24/2017 Stereopsis 35
Rectification
Example:
original
images
rectified
images
Rectification
Find two projective transformations H and H’
p =H p and p’= H’p’
that applied to each image make matching points have
approximately the same v-coordinate
Clearly, since the new image planes are parallel to the
base line, the epipoles are in the infinity.
5/24/2017 Stereopsis 36
~ ~
5/24/2017 37
Recall Projective Geometry
2 Dimensional
If a point x lies on line l
xT l = 0
The intersection x of two lines l1 and l2
x = l1× l2
The line joining points x1 and x2
l = x1× x2
Note that in P2 parallel lines intersect at infinity
(a,b,c)×(a,b,c') = ( b(c'-c), a(c-c'), 0)
Stereopsis
5/24/2017 38
Recall Projective Geometry
2 Dimensional
P2 R2
x =(kx1,kx2,k)T =(x1,x2,1)T for k ≠ 0 x =(x1,x2)T
x∞ =(kx1,kx2,0)T=(x1,x2,0)T for k ≠ 0 -
l =(kl1,kl2,k)T =(l1,l2,1)T for k ≠ 0 l =(a,b,c)T
l ∞=(0,0,k)T for k ≠ 0 -
po
ints
li
nes
points at
infinity
lines at
infinity
Stereopsis
Mapping epipole to infinity
Assume that
u0 =0 and v0 =0 (the origin is in the image center)
epipole e = [ f, 0, 1]T lies on the u-axis.
So, the transformation
𝐺 =
1 0 00 1 0−1𝑓 0 1
takes the epipole to the point at infinity [ f, 0, 0]T
5/24/2017 39 Stereopsis
Mapping epipole to infinit
For an arbitrarily placed point of interest p0 and
epipole e, the mapping H that makes epipolar lines
run parallel to the u axis is H=GRT, where
T is a transformation that moves p0 to the origin,
R is a rotation about the origin taking the epipole to a
point on the u –axis, and
𝐺 =
1 0 00 1 0−1𝑓 0 1
5/24/2017 40 Stereopsis
The matching transformation
Let p and p′ be a pair of corresponding points.
Recall that F p′ represents the epipolar line on the left
image induced by point p′ on the right image.
After the left image is ressampled by H, the new epipolar line will be H-TF p ′ (why?)
The mapping matrix H’ to be applied to the right
image must be such that
H’ -T FTp =H-TF p′
Many matching transformations satisfy this
condition.
5/24/2017 More on Calibration and Reconstruction 41
horizontal epipolar line
on the left image
horizontal epipolar line
on the right image
Algorithm outline i. Identify a set of image-to-image matches
ii. Compute the fundamental matrix F and find the epipoles e
and e’.
iii. Select the projective transformation H that maps the epipole
e to the point at infinite [ f, 0, 0]T
iv. Find the matching projective transformation H’ that
minimizes the relative displacement of matching points
along the u axis (distortion)
𝑑 𝐻𝒑𝑖 , 𝐻′𝒑𝑖′
𝑖
v. Resample both images according H and H’.
5/24/2017 42 Stereopsis
Details can be found in
Multiple View Geometry in computer Vision, Hartley,R. and Zisserman, A., section 11.12 pp 302…
Example
Input Images
5/24/2017 43 Stereopsis
Example
Rectified Images
5/24/2017 44 Stereopsis
5/24/2017 Stereopsis 45
Rectification
Remarks:
The search for corresponding points becomes 1D.
It is possible to find a match for almost every pixel →
dense match map.
Compensates rotation over the image plane, which
improves cross correlation.
Reconstruction can be done from rectified images.
Assignments
RECONSTRUCTION:
Download the MATLAB (IteractiveTriangulation) program that demonstrates stereo
reconstruction interactively. Experiment with different reconstruction approaches. Run the
TextureOverlayDemo program and experiment with the 3D model.
REGION GROWING + NORMALIZED CROSS CORRELATION:
Download the MATLAB demo program for Region Growing. Choose a pair of stereo
images and experiment with different parameter values. Important: follow the instructions
in the read.me file before running the program.
RECTIFICATION:
Download the MATLAB demo program for uncalibrated image rectification. Just run the
demo using a stereo pair as input.
Read the MATLAB documentation and follow the examples on Uncalibrated Stereo
Image Rectification.
5/24/2017 Stereopsis 46
5/24/2017 Stereopsis 47
Next Topic
More on
Calibration