Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 12: Structure from motion CS6670: Computer Vision Noah Snavely.

Similar presentations


Presentation on theme: "Lecture 12: Structure from motion CS6670: Computer Vision Noah Snavely."— Presentation transcript:

1 Lecture 12: Structure from motion CS6670: Computer Vision Noah Snavely

2 Readings Szeliski, Chapter 7.1 – 7.4

3 Announcements Project 2 due Sunday, March 13 – Two-person groups Quiz on Monday

4 Large-scale structure from motion Dubrovnik, Croatia. 4,619 images (out of an initial 57,845). Total reconstruction time: 23 hours Number of cores: 352

5 Structure from motion Given many images, how can we a) figure out where they were all taken from? b) build a 3D model of the scene? This is (roughly) the structure from motion problem

6 Structure from motion Input: images with points in correspondence p i,j = (u i,j,v i,j ) Output structure: 3D location x i for each point p i motion: camera parameters R j, t j possibly K j Objective function: minimize reprojection error Reconstruction (side) (top)

7 Camera calibration and triangulation Suppose we know 3D points – And have matches between these points and an image – How can we compute the camera parameters? Suppose we have know camera parameters, each of which observes a point – How can we compute the 3D location of that point?

8 Structure from motion SfM solves both of these problems at once A kind of chicken-and-egg problem – (but solvable)

9 Photo Tourism

10 First step: how to get correspondence? Feature detection and matching

11 Feature detection Detect features using SIFT [Lowe, IJCV 2004]

12 Feature detection Detect features using SIFT [Lowe, IJCV 2004]

13 Feature matching Match features between each pair of images

14 Feature matching Refine matching using RANSAC to estimate fundamental matrix between each pair

15 Image connectivity graph (graph layout produced using the Graphviz toolkit: http://www.graphviz.org/)http://www.graphviz.org/

16 p 1,1 p 1,2 p 1,3 Image 1 Image 2 Image 3 x1x1 x4x4 x3x3 x2x2 x5x5 x6x6 x7x7 R1,t1R1,t1 R2,t2R2,t2 R3,t3R3,t3

17 Structure from motion Camera 1 Camera 2 Camera 3 R 1,t 1 R 2,t 2 R 3,t 3 p1p1 p4p4 p3p3 p2p2 p5p5 p6p6 p7p7 minimize f (R, T, P)f (R, T, P)

18 Problem size Trevi Fountain collection 466 input photos + > 100,000 3D points = very large optimization problem

19 Incremental structure from motion

20

21

22 Photo Explorer

23

24

25

26

27 Questions? 3-minute break

28 Related topic: Drift copy of first image (x n,y n ) (x 1,y 1 ) – add another copy of first image at the end – this gives a constraint: y n = y 1 – there are a bunch of ways to solve this problem add displacement of (y 1 – y n )/(n - 1) to each image after the first compute a global warp: y’ = y + ax run a big optimization problem, incorporating this constraint – best solution, but more complicated – known as “bundle adjustment”

29 Global optimization Minimize a global energy function: – What are the variables? The translation t j = (x j, y j ) for each image I j – What is the objective function? We have a set of matched features p i,j = (u i,j, v i,j ) – We’ll call these tracks For each point match (p i,j, p i,j+1 ): p i,j+1 – p i,j = t j+1 – t j I1I1 I2I2 I3I3 I4I4 p 1,1 p 1,2 p 1,3 p 2,2 p 2,3 p 2,4 p 3,3 p 3,4 p 4,4 p 4,1 track

30 Global optimization I1I1 I2I2 I3I3 I4I4 p 1,1 p 1,2 p 1,3 p 2,2 p 2,3 p 2,4 p 3,3 p 3,4 p 4,4 p 4,1 p 1,2 – p 1,1 = t 2 – t 1 p 1,3 – p 1,2 = t 3 – t 2 p 2,3 – p 2,2 = t 3 – t 2 … v 4,1 – v 4,4 = y 1 – y 4 minimize w ij = 1 if track i is visible in images j and j+1 0 otherwise

31 Global optimization I1I1 I2I2 I3I3 I4I4 p 1,1 p 1,2 p 1,3 p 2,2 p 2,3 p 2,4 p 3,3 p 3,4 p 4,4 p 4,1 A 2m x 2n 2n x 1 x 2m x 1 b

32 Global optimization Defines a least squares problem: minimize Solution: Problem: there is no unique solution for ! (det = 0) We can add a global offset to a solution and get the same error A 2m x 2n 2n x 1 x 2m x 1 b

33 Ambiguity in global location Each of these solutions has the same error Called the gauge ambiguity Solution: fix the position of one image (e.g., make the origin of the 1 st image (0,0)) (0,0) (-100,-100) (200,-200)

34 Solving for camera rotation Instead of spherically warping the images and solving for translation, we can directly solve for the rotation R j of each camera Can handle tilt / twist

35 Solving for rotations R1R1 R2R2 f I1I1 I2I2 p 12 = (u 12, v 12 ) p 11 = (u 11, v 11 ) (u 11, v 11, f) = p 11 R 1 p 11 R 2 p 22

36 Solving for rotations minimize

37 3D rotations How many degrees of freedom are there? How do we represent a rotation? – Rotation matrix (too many degrees of freedom) – Euler angles (e.g. yaw, pitch, and roll) – bad idea – Quaternions (4-vector on unit sphere) Usually involves non-linear optimization

38 p 1,1 p 1,2 p 1,3 Image 1 Image 2 Image 3 x1x1 x4x4 x3x3 x2x2 x5x5 x6x6 x7x7 R1,t1R1,t1 R2,t2R2,t2 R3,t3R3,t3

39 SfM objective function Given point x and rotation and translation R, t Minimize sum of squared reprojection errors: predicted image location observed image location

40 Solving structure from motion Minimizing g is difficult – g is non-linear due to rotations, perspective division – lots of parameters: 3 for each 3D point, 6 for each camera – difficult to initialize – gauge ambiguity: error is invariant to a similarity transform (translation, rotation, uniform scale) Many techniques use non-linear least-squares (NLLS) optimization (bundle adjustment) – Levenberg-Marquardt is one common algorithm for NLLS – Lourakis, The Design and Implementation of a Generic Sparse Bundle Adjustment Software Package Based on the Levenberg-Marquardt Algorithm, http://www.ics.forth.gr/~lourakis/sba/ http://www.ics.forth.gr/~lourakis/sba/ – http://en.wikipedia.org/wiki/Levenberg- Marquardt_algorithm http://en.wikipedia.org/wiki/Levenberg- Marquardt_algorithm

41 Extensions to SfM Can also solve for intrinsic parameters (focal length, radial distortion, etc.) Can use a more robust function than squared error, to avoid fitting to outliers For more information, see: Triggs, et al, “Bundle Adjustment – A Modern Synthesis”, Vision Algorithms 2000.

42 Questions?


Download ppt "Lecture 12: Structure from motion CS6670: Computer Vision Noah Snavely."

Similar presentations


Ads by Google