Introduction to 3 D Vision Computer Vision CSC

  • Slides: 38
Download presentation
Introduction to 3 D Vision Computer Vision CSC I 6716 Spring 2004 Topic 6

Introduction to 3 D Vision Computer Vision CSC I 6716 Spring 2004 Topic 6 of Part 2 Calibration Zhigang Zhu, NAC 8/203 A http: //www-cs. engr. ccny. cuny. edu/~zhu/Vision. Course-2004. html

Introduction to Computer Vision n Calibration: Find the intrinsic and extrinsic parameters l l

Introduction to Computer Vision n Calibration: Find the intrinsic and extrinsic parameters l l l n l Basic equations (from Lecture 5) Estimating the Image center using vanishing points l SVD (Singular Value Decomposition) and Homogeneous System l Focal length, Aspect ratio, and extrinsic parameters l Discussion: Why not do all the parameters together? Projection Matrix Approach (…after-class reading) l l l n Problem and assumptions Direct parameter estimation approach Projection matrix approach Direct Parameter Estimation Approach l n Lecture Outline Estimating the projection matrix M Computing the camera parameters from M Discussion Comparison and Summary l Any difference?

Introduction to Computer Vision n Given one or more images of a calibration pattern,

Introduction to Computer Vision n Given one or more images of a calibration pattern, Estimate l The intrinsic parameters l The extrinsic parameters, or l BOTH Issues: Accuracy of Calibration l How to design and measure the calibration pattern n l n l Distribution of the control points to assure stability of solution – not coplanar Construction tolerance one or two order of magnitude smaller than the desired accuracy of calibration e. g. 0. 01 mm tolerance versus 0. 1 mm desired accuracy How to extract the image correspondences n n Problem and Assumptions Corner detection? Line fitting? Algorithms for camera calibration given both 3 D-2 D pairs Alternative approach: 3 D from un-calibrated camera

Introduction to Camera Model Computer Vision xim Image frame (xim, yim) yim n Coordinate

Introduction to Camera Model Computer Vision xim Image frame (xim, yim) yim n Coordinate Systems l l n Frame Grabber Frame coordinates (xim, yim) pixels Image coordinates (x, y) in mm Camera coordinates (X, Y, Z) World coordinates (Xw, Yw, Zw) Camera Parameters l l Y Pose / Camera X O y x Z p Object / World Zw P Pw Xw Yw Intrinsic Parameters (of the camera and the frame grabber): link the frame coordinates of an image point with its corresponding camera coordinates Extrinsic parameters: define the location and orientation of the camera coordinate system with respect to the world coordinate system

Introduction to Linear Computer Vision n World to Camera l l l n l

Introduction to Linear Computer Vision n World to Camera l l l n l l Camera: P = (X, Y, Z)T Image: p = (x, y)T Not linear equations Image to Frame l l n Camera: P = (X, Y, Z)T World: Pw = (Xw, Yw, Zw)T Transform: R, T Camera to Image l n Version of Perspective Projection Neglecting distortion Frame (xim, yim)T World to Frame l l (Xw, Yw, Zw)T -> (xim, yim)T Effective focal lengths n fx = f/sx, fy=f/sy

Introduction to Computer Vision Direct Parameter Method n Extrinsic Parameters l R, 3 x

Introduction to Computer Vision Direct Parameter Method n Extrinsic Parameters l R, 3 x 3 rotation matrix n Three angles a, b, g l T, 3 -D translation vector n Intrinsic Parameters l fx, fy : effective focal length in pixel n a = fx/fy = sy/sx, and fx l (ox, oy): known Image center -> (x, y) known l k 1, radial distortion coefficient: neglect it in the basic algorithm n Same Denominator in the two Equations l l Known : (Xw, Yw, Zw) and its (x, y) Unknown: rpq, Tx, Ty, fx, fy

Introduction to Computer Vision n Linear Equations Linear Equation of 8 unknowns v =

Introduction to Computer Vision n Linear Equations Linear Equation of 8 unknowns v = (v 1, …, v 8) l Aspect ratio: a = fx/fy l Point pairs , {(Xi, Yi, , Zi) <-> (xi, yi) } drop the ‘ and subscript “w”

Introduction to Computer Vision n n Homogeneous System of N Linear Equations l Given

Introduction to Computer Vision n n Homogeneous System of N Linear Equations l Given N corresponding pairs {(Xi, Yi, , Zi) <-> (xi, yi) }, i=1, 2, …N l 8 unknowns v = (v 1, …, v 8)T, 7 independent parameters The system has a nontrivial solution (up to a scale) l IF N >= 7 and N points are not coplanar => Rank (A) = 7 l Can be determined from the SVD of A

Introduction to Computer Vision n SVD: definition Singular Value Decomposition: l Any mxn matrix

Introduction to Computer Vision n SVD: definition Singular Value Decomposition: l Any mxn matrix can be written as the product of three matrices U 1 n n Appendix A. 6 Singular values si are fully determined by A n D is diagonal: dij =0 if i j; dii = si (i=1, 2, …, n) n s 1 s 2 … s. N 0 Both U and V are not unique n Columns of each are mutual orthogonal vectors V 1

Introduction to Computer Vision n 1. Singularity and Condition Number l l nxn A

Introduction to Computer Vision n 1. Singularity and Condition Number l l nxn A is nonsingular IFF all singular values are nonzero Condition number : degree of singularity of A n n Rank (A) = number of nonzero singular values 3. Inverse of a square Matrix l l n A is ill-conditioned if 1/C is comparable to the arithmetic precision of your machine; almost singular 2. Rank of a square matrix A l n SVD: properties If A is nonsingular In general, the pseudo-inverse of A 4. Eigenvalues and Eigenvectors (questions) l l l Eigenvalues of both ATA and AAT are si 2 (si > 0) The columns of U are the eigenvectors of AAT (mxm) The columns of V are the eigenvectors of ATA (nxn)

Introduction to Computer Vision n SVD: Application 1 Least Square l l Solve a

Introduction to Computer Vision n SVD: Application 1 Least Square l l Solve a system of m equations for n unknowns x(m >= n) A is a mxn matrix of the coefficients b ( 0) is the m-D vector of the data Solution: nxn matrix l Pseudo-inverse How to solve: compute the pseudo-inverse of ATA by SVD n n (ATA)+ is more likely to coincide with (ATA)-1 given m > n Always a good idea to look at the condition number of ATA

Introduction to Computer Vision n Homogeneous System l l n SVD: Application 2 m

Introduction to Computer Vision n Homogeneous System l l n SVD: Application 2 m equations for n unknowns x(m >= n-1) Rank (A) = n-1 (by looking at the SVD of A) A non-trivial solution (up to a arbitrary scale) by SVD: Simply proportional to the eigenvector corresponding to the only zero eigenvalue of ATA (nxn matrix) Note: l All the other eigenvalues are positive because Rank (A)=n-1 l For a proof, see Textbook p. 324 -325 l In practice, the eigenvector (i. e. vn) corresponding to the minimum eigenvalue of ATA, i. e. sn 2

Introduction to Computer Vision n Problem Statements l l n SVD: Application 3 Numerical

Introduction to Computer Vision n Problem Statements l l n SVD: Application 3 Numerical estimate of a matrix A whose entries are not independent Errors introduced by noise alter the estimate to Enforcing Constraints by SVD l Take orthogonal matrix A as an example l Find the closest matrix to , which satisfies the constraints exactly n n n SVD of Observation: D = I (all the singular values are 1) if A is orthogonal Solution: changing the singular values to those expected

Introduction to Computer Vision n Homogeneous System of N Linear Equations l Given N

Introduction to Computer Vision n Homogeneous System of N Linear Equations l Given N corresponding pairs {(Xi, Yi, , Zi) <-> (xi, yi) }, i=1, 2, …N l 8 unknowns v = (v 1, …, v 8)T, 7 independent parameters The system has a nontrivial solution (up to a scale) l IF N >= 7 and N points are not coplanar => Rank (A) = 7 l Can be determined from the SVD of A l Rows of VT: eigenvectors {ei} of ATA l Solution: the 8 th row e 8 corresponding to the only zero singular value l 8=0 Practical Consideration l The errors in localizing image and world points may make the rank of A to be maximum (8) l In this case select the eigenvector corresponding to the smallest eigenvalue.

Introduction to Scale Factor and Aspect Ratio Computer Vision n Equations for scale factor

Introduction to Scale Factor and Aspect Ratio Computer Vision n Equations for scale factor g and aspect ratio a v 1 v 2 v 3 v 4 v 5 n Knowledge: R is an orthogonal matrix n Second row (i=j=2): n First row (i=j=1) v 6 v 7 v 8

Introduction to Computer Vision Rotation R and Translation T n Equations for first 2

Introduction to Computer Vision Rotation R and Translation T n Equations for first 2 rows of R and T given a and |g| n First 2 rows of R and T can be found up to a common sign s (+ or -) n The third row of the rotation matrix by vector product n Remaining Questions : l l l How to find the sign s? Is R orthogonal? How to find Tz and fx, fy?

Introduction to Find the sign s Computer Vision xim (xim, yim) yim n n

Introduction to Find the sign s Computer Vision xim (xim, yim) yim n n Facts: l fx > 0 l Zc >0 l x known l Xw, Yw, Zw known Solution Þ Check the sign of Xc Þ Should be opposite to x Y X O y x Z p Zw P Pw Xw Yw

Introduction to Rotation R : Orthogonality Computer Vision n Question: l n First 2

Introduction to Rotation R : Orthogonality Computer Vision n Question: l n First 2 rows of R are calculated without using the mutual orthogonal constraint Solution: l Use SVD of estimate R Replace the diagonal matrix D with the 3 x 3 identity matrix

Introduction to Find Tz, Fx and Fy Computer Vision n Solution l Solve the

Introduction to Find Tz, Fx and Fy Computer Vision n Solution l Solve the system of N linear equations with two unknown n Tx, fx ai 1 ai 2 l Least Square method l SVD method to find inverse bi

Introduction to Computer Vision Direct n parameter Calibration Summary Algorithm (p 130 -131) 1.

Introduction to Computer Vision Direct n parameter Calibration Summary Algorithm (p 130 -131) 1. 2. 3. 4. 5. 6. 7. 8. 9. Measure N 3 D coordinates (Xi, Yi, Zi) Locate their corresponding image points (xi, yi) - Edge, Corner, Hough Build matrix A of a homogeneous system Av = 0 Compute SVD of A , solution v Determine aspect ratio a and scale |g| Recover the first two rows of R and the first two components of T up to a sign Determine sign s of g by checking the projection equation Compute the 3 rd row of R by vector product, and enforce orthogonality constraint by SVD Solve Tz and fx using Least Square and SVD, then fy = fx / a Zw Xw Yw

Introduction to Computer Vision n Discussions Questions l Can we select an arbitrary image

Introduction to Computer Vision n Discussions Questions l Can we select an arbitrary image center for solving other parameters? l How to find the image center (ox, oy)? l How about to include the radial distortion? l Why not solve all the parameters once ? n How many unknown with ox, oy? --- 20 ? ? ? – projection matrix method

Introduction to Computer Vision n Estimating the Image Center Vanishing points: l Due to

Introduction to Computer Vision n Estimating the Image Center Vanishing points: l Due to perspective, all parallel lines in 3 D space appear to meet in a point on the image - the vanishing point, which is the common intersection of all the image lines

Introduction to Computer Vision n Estimating the Image Center Vanishing points: l Due to

Introduction to Computer Vision n Estimating the Image Center Vanishing points: l Due to perspective, all parallel lines in 3 D space appear to meet in a point on the image - the vanishing point, which is the common intersection of all the image lines VP 1

Introduction to Estimating the Image Center Computer Vision n n Vanishing points: l Due

Introduction to Estimating the Image Center Computer Vision n n Vanishing points: l Due to perspective, all parallel lines in 3 D space appear to meet in a point on the image - the vanishing point, which is the common intersection of all the image lines Important property: l Vector OV (from the center of projection to the vanishing point) is parallel to the parallel lines Y Z X O VP 1

Introduction to Computer Vision n Estimating the Image Center Vanishing points: l Due to

Introduction to Computer Vision n Estimating the Image Center Vanishing points: l Due to perspective, all parallel lines in 3 D space appear to meet in a point on the image - the vanishing point, which is the common intersection of all the image lines VP 1 VP 2

Introduction to Computer Vision n VP 3 Estimating the Image Center Orthocenter Theorem: l

Introduction to Computer Vision n VP 3 Estimating the Image Center Orthocenter Theorem: l Input: three mutually orthogonal sets of parallel lines in an image l T: a triangle on the image plane defined by the three vanishing points l Image center = orthocenter of triangle T l Orthocenter of a triangle is the common intersection of the three altitudes VP 1 VP 2

Introduction to Computer Vision n VP 3 Estimating the Image Center Orthocenter Theorem: l

Introduction to Computer Vision n VP 3 Estimating the Image Center Orthocenter Theorem: l Input: three mutually orthogonal sets of parallel lines in an image l T: a triangle on the image plane defined by the three vanishing points l Image center = orthocenter of triangle T l Orthocenter of a triangle is the common intersection of the three altitudes VP 1 VP 2

Introduction to Computer Vision n n VP 3 Estimating the Image Center Orthocenter Theorem:

Introduction to Computer Vision n n VP 3 Estimating the Image Center Orthocenter Theorem: l Input: three mutually orthogonal sets of parallel lines in an image l T: a triangle on the image plane defined by the three vanishing points l Image center = orthocenter of triangle T l Orthocenter of a triangle is the common intersection of the three altitudes Orthocenter Theorem: l WHY? h 3 h 1 VP 1 h 1 VP 2 (ox, oy)

Introduction to Computer Vision Estimating the Image Center n Assumptions: l Known aspect ratio

Introduction to Computer Vision Estimating the Image Center n Assumptions: l Known aspect ratio l Without lens distortions n Questions: l Can we solve both aspect ratio and the image center? l How about with lens distortions? VP 3 h 1 h 1 VP 2 VP 1 (ox, oy) ?

Introduction to Computer Vision Direct n parameter Calibration Summary Algorithm (p 130 -131) 0.

Introduction to Computer Vision Direct n parameter Calibration Summary Algorithm (p 130 -131) 0. Estimate image center (and aspect ratio) 1. Measure N 3 D coordinates (Xi, Yi, Zi) 2. Locate their corresponding image (xi, yi) Edge, Corner, Hough 3. Build matrix A of a homogeneous system Av = 0 4. Compute SVD of A , solution v 5. Determine aspect ratio a and scale |g| 6. Recover the first two rows of R and the first two components of T up to a sign 7. Determine sign s of g by checking the projection equation 8. Compute the 3 rd row of R by vector product, and enforce orthogonality constraint by SVD 9. Solve Tz and fx using Least Square and SVD , then fy = fx / a Zw Xw Yw

Introduction to Computer Vision Remaining Issues and Possible Solution n Original assumptions: l Without

Introduction to Computer Vision Remaining Issues and Possible Solution n Original assumptions: l Without lens distortions l Known aspect ratio when estimating image center l Known image center when estimating others including aspect ratio n New Assumptions l Without lens distortion l Aspect ratio is approximately 1, or a = fx/fy = 4: 3 ; image center about (M/2, N/2) given a Mx. N image n Solution (? ) 1. Using a = 1 to find image center (ox, oy) 2. Using the estimated center to find others including a 3. Refine image center using new a ; if change still significant, go to step 2; otherwise stop l Projection Matrix Approach

Introduction to Computer Vision n Projective Space l Add fourth coordinate n l l

Introduction to Computer Vision n Projective Space l Add fourth coordinate n l l Only extrinsic parameters World to camera 3 x 3 Matrix Eint l l n u/w =xim, v/w =yim 3 x 4 Matrix Eext l n Pw = (Xw, Yw, Zw, 1)T Define (u, v, w)T such that n n Linear Matrix Equation of perspective projection Only intrinsic parameters Camera to frame Simple Matrix Product! Projective Matrix M= Mint. Mext l l l (Xw, Yw, Zw)T -> (xim, yim)T Linear Transform from projective space to projective plane M defined up to a scale factor – 11 independent entries

Introduction to Computer Vision n World – Frame Transform l l l n Projection

Introduction to Computer Vision n World – Frame Transform l l l n Projection Matrix M Drop “im” and “w” N pairs (xi, yi) <-> (Xi, Yi, Zi) Linear equations of m 3 x 4 Projection Matrix M l Both intrinsic (4) and extrinsic (6) – 10 parameters

Introduction to Computer Step Vision n World – Frame Transform l l n 1:

Introduction to Computer Step Vision n World – Frame Transform l l n 1: Estimation of projection matrix Drop “im” and “w” N pairs (xi, yi) <-> (Xi, Yi, Zi) Linear equations of m l l 2 N equations, 11 independent variables N >=6 , SVD => m up to a unknown scale

Introduction to Computer Vision Step 2: Computing camera parameters n 3 x 4 Projection

Introduction to Computer Vision Step 2: Computing camera parameters n 3 x 4 Projection Matrix M l Both intrinsic and extrinsic n From M^ to parameters (p 134 -135) l Find scale |g| by using unit vector R 3 T l Determine Tz and sign of g from m 34 (i. e. q 43) l Obtain R 3 T l Find (Ox, Oy) by dot products of Rows q 1. q 3, q 2. q 3, using the orthogonal constraints of R l Determine fx and fy from q 1 and q 2 (Eq. 6. 19) Wrong? ? ? ) l All the remainings: R 1 T, R 2 T, Tx, Ty l Enforce orthognoality on R?

Introduction to Computer Vision Comparisons n Direct parameter method and Projection Matrix method n

Introduction to Computer Vision Comparisons n Direct parameter method and Projection Matrix method n Properties in Common: l l n Linear system first, Parameter decomposition second Results should be exactly the same Differences l Number of variables in homogeneous systems Matrix method: All parameters at once, 2 N Equations of 12 variables n Direct method in three steps: N Equations of 8 variables, N equations of 2 Variables, Image Center – maybe more stable Assumptions n Matrix method: simpler, and more general; sometime projection matrix is sufficient so no need for parameter decompostion n Direct method: Assume known image center in the first two steps, n l

Introduction to Computer Vision n n Pick up a well-known technique or a few

Introduction to Computer Vision n n Pick up a well-known technique or a few Design and construct calibration patterns (with known 3 D) Make sure what parameters you want to find for your camera Run algorithms on ideal simulated data l l n n Guidelines for Calibration You can either use the data of the real calibration pattern or using computer generated data Define a virtual camera with known intrinsic and extrinsic parameters Generate 2 D points from the 3 D data using the virtual camera Run algorithms on the 2 D-3 D data set Add noises in the simulated data to test the robustness Run algorithms on the real data (images of calibration target) If successful, you are all set Otherwise: l l Check how you select the distribution of control points Check the accuracy in 3 D and 2 D localization Check the robustness of your algorithms again Develop your own algorithms NEW METHODS?

Introduction to Next Computer Vision n 3 D reconstruction using two cameras Stereo Vision

Introduction to Next Computer Vision n 3 D reconstruction using two cameras Stereo Vision n. Homework #3 online, Due April 13 before midnight