Matching Planar Objects In New Viewpoints ... And Much More – via Homography
Sanja Fidler CSC420: Intro to Image Understanding 1 / 46
Matching Planar Objects In New Viewpoints ... And Much More via - - PowerPoint PPT Presentation
Matching Planar Objects In New Viewpoints ... And Much More via Homography Sanja Fidler CSC420: Intro to Image Understanding 1 / 46 What Transformation Happened To My DVD? Rectangle goes to a parallelogram Sanja Fidler CSC420: Intro to
Sanja Fidler CSC420: Intro to Image Understanding 1 / 46
Rectangle goes to a parallelogram
Sanja Fidler CSC420: Intro to Image Understanding 2 / 46
Affine transformations are combinations of Linear transformations, and Translations x0 y 0
a b e c d f 2 4 x y 1 3 5 Properties of affine transformations: Origin does not necessarily map to origin Lines map to lines Parallel lines remain parallel Ratios are preserved Closed under composition Rectangles go to parallelograms [Source: N. Snavely, slide credit: R. Urtasun]
Sanja Fidler CSC420: Intro to Image Understanding 3 / 46
What about now?
Sanja Fidler CSC420: Intro to Image Understanding 4 / 46
Actually a rectangle goes to quadrilateral
Sanja Fidler CSC420: Intro to Image Understanding 5 / 46
These transformations are a nested set of groups Closed under composition and inverse is a member [source: R. Szeliski]
Sanja Fidler CSC420: Intro to Image Understanding 6 / 46
Homography: w 2 4 x0 y 0 1 3 5 = 2 4 a b c d e f g h i 3 5 2 4 x y 1 3 5 Properties: Origin does not necessarily map to origin Lines map to lines Parallel lines do not necessarily remain parallel Ratios are not preserved Closed under composition Rectangle goes to quadrilateral Affine transformation is a special case, where g = h = 0 and i = 1 [Source: N. Snavely, slide credit: R. Urtasun]
Sanja Fidler CSC420: Intro to Image Understanding 7 / 46
Sanja Fidler CSC420: Intro to Image Understanding 8 / 46
Sanja Fidler CSC420: Intro to Image Understanding 9 / 46
Sanja Fidler CSC420: Intro to Image Understanding 10 / 46
Sanja Fidler CSC420: Intro to Image Understanding 11 / 46
Sanja Fidler CSC420: Intro to Image Understanding 11 / 46
Sanja Fidler CSC420: Intro to Image Understanding 11 / 46
Sanja Fidler CSC420: Intro to Image Understanding 12 / 46
Sanja Fidler CSC420: Intro to Image Understanding 12 / 46
Sanja Fidler CSC420: Intro to Image Understanding 12 / 46
Sanja Fidler CSC420: Intro to Image Understanding 12 / 46
Transformation T is a coordinate-changing machine: [x0, y 0] = T(x, y) What does it mean that T is global? Is the same for any point p Can be described by just a few numbers (parameters) [Source: N. Snavely, slide credit: R. Urtasun]
Sanja Fidler CSC420: Intro to Image Understanding 13 / 46
Example of warping for different transformations:
Sanja Fidler CSC420: Intro to Image Understanding 14 / 46
Forward Warping: Send each pixel f (x) to its corresponding location (x0, y 0) = T(x, y) in g(x0, y 0) Inverse Warping: Each pixel at destination is sampled from original image [source: R. Urtasun]
Sanja Fidler CSC420: Intro to Image Understanding 15 / 46
Sanja Fidler CSC420: Intro to Image Understanding 16 / 46
Sanja Fidler CSC420: Intro to Image Understanding 16 / 46
Sanja Fidler CSC420: Intro to Image Understanding 16 / 46
Sanja Fidler CSC420: Intro to Image Understanding 16 / 46
Sanja Fidler CSC420: Intro to Image Understanding 16 / 46
Sanja Fidler CSC420: Intro to Image Understanding 17 / 46
Sanja Fidler CSC420: Intro to Image Understanding 18 / 46
Sanja Fidler CSC420: Intro to Image Understanding 19 / 46
Sanja Fidler CSC420: Intro to Image Understanding 20 / 46
Sanja Fidler CSC420: Intro to Image Understanding 21 / 46
Sanja Fidler CSC420: Intro to Image Understanding 22 / 46
Sanja Fidler CSC420: Intro to Image Understanding 23 / 46
Sanja Fidler CSC420: Intro to Image Understanding 24 / 46
Sanja Fidler CSC420: Intro to Image Understanding 25 / 46
Sanja Fidler CSC420: Intro to Image Understanding 26 / 46
Sanja Fidler CSC420: Intro to Image Understanding 27 / 46
Sanja Fidler CSC420: Intro to Image Understanding 28 / 46
Sanja Fidler CSC420: Intro to Image Understanding 29 / 46
[Source: Fernando Flores-Mangas] Sanja Fidler CSC420: Intro to Image Understanding 30 / 46
[Source: Fernando Flores-Mangas] Sanja Fidler CSC420: Intro to Image Understanding 30 / 46
[Source: Fernando Flores-Mangas] Sanja Fidler CSC420: Intro to Image Understanding 30 / 46
Match points between pairs of images I and J Compute a transformation between the between matches in I and J : a homography Do it robustly (RANSAC) Warp the first image to the second using the estimated homography
Sanja Fidler CSC420: Intro to Image Understanding 31 / 46
Sanja Fidler CSC420: Intro to Image Understanding 32 / 46
Let (xi, yi) be a point on the reference (model) image, and (x0
i , y 0 i ) its match
in the test image A homography H maps (xi, yi) to (x0
i , y 0 i ):
2 4 ax0
i
ay 0
i
a 3 5 = 2 4 h00 h01 h02 h10 h11 h12 h20 h21 h22 3 5 2 4 xi yi 1 3 5
Sanja Fidler CSC420: Intro to Image Understanding 33 / 46
Let (xi, yi) be a point on the reference (model) image, and (x0
i , y 0 i ) its match
in the test image A homography H maps (xi, yi) to (x0
i , y 0 i ):
2 4 ax0
i
ay 0
i
a 3 5 = 2 4 h00 h01 h02 h10 h11 h12 h20 h21 h22 3 5 2 4 xi yi 1 3 5 We can get rid of that a on the left: x0
i
= h00xi + h01yi + h02 h20xi + h21yi + h22 y 0
i
= h10xi + h11yi + h12 h20xi + h21yi + h22
Sanja Fidler CSC420: Intro to Image Understanding 33 / 46
Let (xi, yi) be a point on the reference (model) image, and (x0
i , y 0 i ) its match
in the test image A homography H maps (xi, yi) to (x0
i , y 0 i ):
2 4 ax0
i
ay 0
i
a 3 5 = 2 4 h00 h01 h02 h10 h11 h12 h20 h21 h22 3 5 2 4 xi yi 1 3 5 We can get rid of that a on the left: x0
i
= h00xi + h01yi + h02 h20xi + h21yi + h22 y 0
i
= h10xi + h11yi + h12 h20xi + h21yi + h22 Hmmmm... Can I still rewrite this into a linear system in h? [Source: R. Urtasun]
Sanja Fidler CSC420: Intro to Image Understanding 33 / 46
From: x0
i
= h00xi + h01yi + h02 h20xi + h21yi + h22 y 0
i
= h10xi + h11yi + h12 h20xi + h21yi + h22 We can easily get this: x0
i (h20xi + h21yi + h22)
= h00xi + h01yi + h02 y 0
i (h20xi + h21yi + h22)
= h10xi + h11yi + h12 Rewriting it a little: h00xi + h01yi + h02 − x0
i (h20xi + h21yi + h22)
= h10xi + h11yi + h12 − y 0
i (h20xi + h21yi + h22)
=
Sanja Fidler CSC420: Intro to Image Understanding 34 / 46
We can re-write these equations: h00xi + h01yi + h02 − x0
i (h20xi − h21yi − h22)
= h10xi + h11yi + h12 − y 0
i (h20xi − h21yi − h22)
= as a linear system!
[Source: R. Urtasun]
Sanja Fidler CSC420: Intro to Image Understanding 35 / 46
Taking all our matches into account:
!"#$#%# %# !"#
Sanja Fidler CSC420: Intro to Image Understanding 36 / 46
Taking all our matches into account:
!"#$#%# %# !"#
How many matches do I need to estimate H? This defines a least squares problem: min
h ||Ah||2 2
Sanja Fidler CSC420: Intro to Image Understanding 36 / 46
Taking all our matches into account:
!"#$#%# %# !"#
How many matches do I need to estimate H? This defines a least squares problem: min
h ||Ah||2 2
Since h is only defined up to scale, solve for unit vector
Sanja Fidler CSC420: Intro to Image Understanding 36 / 46
Taking all our matches into account:
!"#$#%# %# !"#
How many matches do I need to estimate H? This defines a least squares problem: min
h ||Ah||2 2
Since h is only defined up to scale, solve for unit vector Solution: ˆ h = eigenvector of ATA with smallest eigenvalue
Sanja Fidler CSC420: Intro to Image Understanding 36 / 46
Taking all our matches into account:
!"#$#%# %# !"#
How many matches do I need to estimate H? This defines a least squares problem: min
h ||Ah||2 2
Since h is only defined up to scale, solve for unit vector Solution: ˆ h = eigenvector of ATA with smallest eigenvalue Works with 4 or more points
[Source: R. Urtasun]
Sanja Fidler CSC420: Intro to Image Understanding 36 / 46
Given images I and J
1
Compute image features for I and J
2
Match features between I and J
3
Compute homography transformation A between I and J (with RANSAC)
Sanja Fidler CSC420: Intro to Image Understanding 37 / 46
Given images I and J
1
Compute image features for I and J
2
Match features between I and J
3
Compute homography transformation A between I and J (with RANSAC) [Source: N. Snavely]
Sanja Fidler CSC420: Intro to Image Understanding 37 / 46
[Source: R. Queiroz Feitosa]
Sanja Fidler CSC420: Intro to Image Understanding 38 / 46
[Source: R. Queiroz Feitosa]
Sanja Fidler CSC420: Intro to Image Understanding 38 / 46
[Source: R. Queiroz Feitosa]
Sanja Fidler CSC420: Intro to Image Understanding 38 / 46
[Source: Fernando Flores-Mangas]
Sanja Fidler CSC420: Intro to Image Understanding 39 / 46
[Source: Fernando Flores-Mangas]
Sanja Fidler CSC420: Intro to Image Understanding 39 / 46
[Source: Fernando Flores-Mangas]
Sanja Fidler CSC420: Intro to Image Understanding 39 / 46
A homography is a mapping between projective planes You need at least 4 correspondences (matches) to compute it
tform = maketform(’affine’,[x1,y1],[x2,y2]); % Computes affine transformation between points [x1, y1] and [x2, y2]. Needs 3 pairs
tform = maketform(’projective’,[x1,y1],[x2,y2]); % Computes homography between points [x1, y1] and [x2, y2]. Needs 4 pairs of matches imw = imtransform(im, tform, ’bicubic’,’fill’, 0); % Warps the image according to transformation
Sanja Fidler CSC420: Intro to Image Understanding 40 / 46
Problem Detection Description Matching Find Planar Distinctive Objects Scale Invariant Interest Points Local feature: SIFT All features to all features + Affine / Homography Panorama Stitching Scale Invariant Interest Points Local feature: SIFT All features to all features + Homography
Sanja Fidler CSC420: Intro to Image Understanding 41 / 46
Can I walk here during the night? Can we tell this from an image?
Sanja Fidler CSC420: Intro to Image Understanding 42 / 46
Can I walk here during the night? Can we tell this from an image?
Sanja Fidler CSC420: Intro to Image Understanding 42 / 46
It’s Chicago...
http://www.neighborhoodscout.com/il/chicago/crime/
Sanja Fidler CSC420: Intro to Image Understanding 43 / 46
It’s Chicago... Can I walk here during the day?
Sanja Fidler CSC420: Intro to Image Understanding 43 / 46
Idea: Match image to Google’s StreetView images of Chicago!
Sanja Fidler CSC420: Intro to Image Understanding 43 / 46
Our match to StreetView
Sanja Fidler CSC420: Intro to Image Understanding 43 / 46
Lookup the GPS location...
Sanja Fidler CSC420: Intro to Image Understanding 43 / 46
Lookup the crime map for that GPS location
http://www.neighborhoodscout.com/il/chicago/crime/
Sanja Fidler CSC420: Intro to Image Understanding 43 / 46
Lookup the crime map for that GPS location
http://www.neighborhoodscout.com/il/chicago/crime/
Sanja Fidler CSC420: Intro to Image Understanding 43 / 46
Sanja Fidler CSC420: Intro to Image Understanding 44 / 46
Sanja Fidler CSC420: Intro to Image Understanding 44 / 46
So far we matched a known object in a new viewpoint What if we have to match an object to LOTS of images? Or LOTS of
Please read this and we will discuss: Josef Sivic, Andrew Zisserman Video Google: A Text Retrieval Approach to Object Matching in Videos ICCV 2003
Paper link: http://www.robots.ox.ac.uk/~vgg/publications/papers/sivic03.pdf Sanja Fidler CSC420: Intro to Image Understanding 45 / 46
Sanja Fidler CSC420: Intro to Image Understanding 46 / 46