Upgrade to PRO for Only $50/Yearโ€”Limited-Time Offer! ๐Ÿ”ฅ

Tutorial of Bundle Fitting Library for 3D Recon...

Tutorial of Bundle Fitting Library for 3D Reconstructionย (BundleFit)

Tweet

More Decks by Open Source AI Association

Other Decks in Technology

Transcript

  1. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Tutorial

    of Bundle Fitting Library for 3D Reconstruction (BundleFit) Developer: Mikiya Shibuya, Kai Okawa Supporter: Open Source AI Association
  2. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) What

    is BundleFit? Bundle Fitting Library for 3D Reconstruction โ€ข Functions โ€ข Bundel adjustment and pose graph optimization using Ceres Solver โ€ข Ceres Solver: C++ Non-linear optimization OSS library developed by Google โ€ข Provide analytic derivatives for reprojection errors in common image space โ€ข Faster than automatic differentiation โ€ข Support 6 and 7-DOF pose graph optimizations โ€ข If there is a scale change (e.g. monocular Visual SLAM), 7-DOF optimizations are required. โ€ข Compatible with multi-camera systems โ€ข Compatible with multiple cameras fixed to the rig โ€ข Features โ€ข C++17 โ€ข Python wrapper โ€ข Tutorial and sample codes 2
  3. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Table

    of contents โ€ข Preliminary knowledge โ€ข Coordinate transformations and camera projection models โ€ข Rotation matrix and rotation vector โ€ข Schur complement โ€ข Bundle adjustment โ€ข Loop closing and pose graph optimization โ€ข Source code explanation
  4. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Preliminary:

    Coordinate transformations and camera projection models 4
  5. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) ,

    ใƒฏใƒผใƒซใƒ‰ R , Coordinate transformations and projection models Project 3D points onto an image plane โ€ข World coordinate systemโ†’ camera coordinate systemโ†’ image coordinate system โ€ข Coordinate system โ€ข World. : Common for all cameras โ€ข Camera: Fixed to any camera โ€ข Image. : Fixed to any image plane โ€ข Intrinsic parameters โ€ข Image to camera coordinate system conversion โ€ข Extrinsic parameters โ€ข Camera to world coordinate system conversion 5 Relationship between camera and image coordinate systems Relationship between world and camera coordinate systems World coordinate system Camera coordinate system R๐‘ค๐‘ , ๐ญ๐‘ค๐‘ R๐‘๐‘ค , ๐ญ๐‘๐‘ค
  6. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) ,

    ใƒฏใƒผใƒซใƒ‰ R , Coordinate transformations and projection models Camera records a scene by projecting light reflected off objects in space onto the image sensor โ€ข Represented by the intrinsic camera parameter K โ€ข The simplest perspective model ๐‘“๐‘ข , ๐‘“๐‘ฃ ๏ผšFocal length ๐‘๐‘ข , ๐‘๐‘ฃ ๏ผšOptical Center ๐—๐‘ = ๐‘‹๐‘ , ๐‘Œ๐‘ , ๐‘๐‘ T๏ผš3D points in camera coordinate system ๐ณ๐‘ = ๐‘ข, ๐‘ฃ T ๏ผš2D points in image coordinate system Kโ€ฒ โ‰” ๐‘“๐‘ข 0 ๐‘๐‘ข 0 ๐‘“๐‘ฃ ๐‘๐‘ฃ K โ‰” ๐‘“๐‘ข 0 ๐‘๐‘ข 0 ๐‘“๐‘ฃ ๐‘๐‘ฃ 0 0 1 ๐ณ = 1 ๐‘๐‘ Kโ€ฒ๐—๐‘ Relationship between camera and image coordinate systems Relationship between world and camera coordinate systems World coordinate system Camera coordinate system R๐‘ค๐‘ , ๐ญ๐‘ค๐‘ R๐‘๐‘ค , ๐ญ๐‘๐‘ค 6
  7. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Coordinate

    transformations and projection models If the cameraโ€™s coordinate system is different from the worldโ€™s, convert from world to camera coordinates. โ€ข Substitute ๐—๐‘ = R๐‘๐‘ค ๐ญ๐‘๐‘ค ] เดฅ ๐—๐‘ค to the projection model on the previous page ๐ณ = 1 ๐‘๐‘ Kโ€ฒ R๐‘๐‘ค ๐ญ๐‘๐‘ค ] เดฅ ๐—๐‘ค ๐‘ข ๐‘ฃ = 1 ๐‘๐‘ ๐‘“๐‘ข 0 ๐‘๐‘ข 0 ๐‘“๐‘ฃ ๐‘๐‘ฃ ๐‘Ÿ๐‘๐‘ค 11 ๐‘Ÿ๐‘๐‘ค 12 ๐‘Ÿ๐‘๐‘ค 13 ๐‘ก๐‘๐‘ค 1 ๐‘Ÿ๐‘๐‘ค 21 ๐‘Ÿ๐‘๐‘ค 22 ๐‘Ÿ๐‘๐‘ค 23 ๐‘ก๐‘๐‘ค 2 ๐‘Ÿ๐‘๐‘ค 31 ๐‘Ÿ๐‘๐‘ค 32 ๐‘Ÿ๐‘๐‘ค 33 ๐‘ก๐‘๐‘ค 3 ๐‘‹๐‘ค ๐‘Œ๐‘ค ๐‘๐‘ค 1 ๐—๐‘ = ๐‘‹๐‘ , ๐‘Œ๐‘ , ๐‘๐‘ T ๏ผš3D points in camera coordinate system ๐—๐‘ค = ๐‘‹๐‘ค , ๐‘Œ๐‘ค , ๐‘๐‘ค T ๏ผš3D points in world coordinate system R๐‘๐‘ค , ๐ญ๐‘๐‘ค ๏ผšRotation matrix, Translation vector เดฅ ๐—๐‘ค = ๐‘‹๐‘ค , ๐‘Œ๐‘ค , ๐‘๐‘ค , 1 T ๏ผšHomogeneous coordinates of ๐—๐‘ค , ใƒฏใƒผใƒซใƒ‰ R , Relationship between camera and image coordinate systems Relationship between world and camera coordinate systems World coordinate system Camera coordinate system R๐‘ค๐‘ , ๐ญ๐‘ค๐‘ R๐‘๐‘ค , ๐ญ๐‘๐‘ค 7
  8. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Rotation

    matrix and rotation vector The rigid body transformation T (6-DOF) and similarity transformation S (7-DOF) are expressed as follows using rotation matrix R โˆˆ SO 3 , translation vector ๐ญ โˆˆ โ„3, scale parameter ๐‘ , respectively SO 3 ๏ผš Special Orthogonal group of order 3 โ‡’ 3D rotation SE(3) ๏ผš Special Euclidean group of order 3 โ‡’ 3D rotation + translation Sim(3)๏ผš Similarity transformation group of order 3 โ‡’ 3D rotation + translation + scale Lie algebra corresponding to the above Lie group ๐”ฐ๐”ฌ 3 ๏ผŒ ๐”ฐ๐”ข 3 ๏ผŒ ๐”ฐ๐”ฆ๐”ช 3 The matrix representation R (3ร—3) is not suitable as an optimization variable โ€ข Expressed by 9 parameters despite the 3 degrees of freedom โ€ข Needs to also satisfy the conditions of the rotation matrix (orthogonality and determinant 1) 9 H. Strasdat et al., โ€œScale Drift-Aware Large Scale Monocular SLAMโ€, Robotics: Science and Systems VI, 2010
  9. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Rotation

    matrix and rotation vector R is represented by the rotation vector ๐Ž = ๐œ”1 , ๐œ”2 , ๐œ”3 T โˆˆ ๐”ฐ๐”ฌ 3 โ€ข Exponential map from ๐”ฐ๐”ฌ 3 to SO 3 exp โˆถ ๐”ฐ๐”ฌ 3 โ†’ SO 3 ๐Ž โ†’ R โ€ข ๐œƒ = ๐Ž 2 : Rotation angle of ๐Ž โ€ข โˆ™ 2 is L2 norm (Euclidean distance) โ€ข This mapping relation is expressed by the following equation through Rodriguesโ€™ rotation formula I๐‘› is the ๐‘› ร— ๐‘› identity matrix I๐‘› , and โˆ™ ร— is the operator for the skew-symmetric matrix โ€ข The logarithmic map from SO 3 to ๐”ฐ๐”ฌ 3 is denoted as log โˆถ SO 3 โ†’ ๐”ฐ๐”ฌ 3 R โ†’ ๐Ž H. Strasdat et al., โ€œScale Drift-Aware Large Scale Monocular SLAMโ€, Robotics: Science and Systems VI, 2010
  10. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Rotation

    matrix and rotation vector โ€ข Mapping from the camera pose ๐ฉ = ๐ŽT, ๐’—T T โˆˆ ๐”ฐ๐”ข 3 including the translation ๐ฏ to SE(3) โ€ข Mapping from the camera pose ๐ฌ = ๐ŽT, ๐œŽ, ๐’—T T โˆˆ ๐”ฐ๐”ฆ๐”ช 3 including scale ๐œŽ to Sim(3) H. Strasdat et al., โ€œScale Drift-Aware Large Scale Monocular SLAMโ€, Robotics: Science and Systems VI, 2010
  11. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Define

    the block matrix M ๐‘+๐‘ž ร— ๐‘+๐‘ž using the matrices A๐‘ร—๐‘ , B๐‘ร—๐‘ž , C๐‘žร—๐‘ , and D๐‘žร—๐‘ž โ€ข When D is nonsingular, the Schur complement of the partitioned matrix with respect to the block D is M/D๐‘ร—๐‘ โ€ข When A is nonsingular, the Schur complement of the partitioned matrix with respect to the block A is M/A๐‘žร—๐‘ž Schur complement M/D โ‰ก A โˆ’ BDโˆ’1C Mโˆ’1 = M/D โˆ’1 โˆ’ M/D โˆ’1BDโˆ’1 โˆ’Dโˆ’1C M/D โˆ’1 Dโˆ’1 + Dโˆ’1C M/D โˆ’1BDโˆ’1 M โ‰ก A B C D M/A โ‰ก D โˆ’ CAโˆ’1B Mโˆ’1 = Aโˆ’1 + Aโˆ’1B M/๐ด โˆ’1CAโˆ’1 โˆ’Aโˆ’1B M/๐ด โˆ’1 โˆ’ M/๐ด โˆ’1CAโˆ’1 M/๐ด โˆ’1
  12. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) M

    โ‰ก A B C D = เดฅ A B ฮŸ D I๐‘ ฮŸ Dโˆ’1C I๐‘ž = I๐‘ BDโˆ’1 ฮŸ I๐‘ž เดฅ ๐€ ฮŸ ฮŸ ๐ƒ I๐‘ ฮŸ Dโˆ’1C I๐‘ž Let เดฅ A be the Schur complement of the partitioned matrix M with respect to the block D, denoted as เดฅ A โ‰ก M/D๐‘ร—๐‘ โ‰ก A โˆ’ BDโˆ’1C Decompose M into a matrix product containing a block diagonal matrix using เดฅ A XYZ โˆ’1 = Zโˆ’1Yโˆ’1Xโˆ’1, so if เดฅ A and D are nonsingular (invertible) Inverse matrix using Schur complement (for M/D๐‘ร—๐‘ ) A B C D โˆ’1 = I๐‘ ฮŸ โˆ’Dโˆ’1C I๐‘ž เดฅ ๐€โˆ’๐Ÿ ฮŸ ฮŸ ๐ƒโˆ’๐Ÿ I๐‘ โˆ’BDโˆ’1 ฮŸ I๐‘ž = เดฅ Aโˆ’1 ฮŸ โˆ’Dโˆ’1Cเดฅ Aโˆ’1 Dโˆ’1 I๐‘ โˆ’BDโˆ’1 ฮŸ I๐‘ž = เดฅ Aโˆ’1 โˆ’เดฅ Aโˆ’1BDโˆ’1 โˆ’Dโˆ’1Cเดฅ Aโˆ’1 Dโˆ’1 + Dโˆ’1Cเดฅ Aโˆ’1BDโˆ’1
  13. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Decompose

    the linear equation of the block matrix M into a matrix product using the Schur complement เดฅ A: Expand into two equations: Calculate ๐ฑ1 from the first equation, and then substitute the result into the second equation to calculate ๐ฑ2 Solving linear equations using Schur complement (for M/D๐‘ร—๐‘ ) เดฅ A๐ฑ1 = าง ๐›1 , D๐ฑ2 = ๐›2 โˆ’ C๐ฑ1 A B C D ๐ฑ1 ๐ฑ2 = ๐›1 ๐›2 I๐‘ โˆ’BDโˆ’1 ฮŸ I๐‘ž A B C D ๐ฑ1 ๐ฑ2 = I๐‘ โˆ’BDโˆ’1 ฮŸ I๐‘ž ๐›1 ๐›2 เดฅ A ฮŸ C D ๐ฑ1 ๐ฑ2 = าง ๐›1 ๐›2 , where าง ๐›1 โ‰ก ๐›1 โˆ’ BDโˆ’1๐›2 ๐ฑ1 = เดฅ Aโˆ’1 าง ๐›1 ๐ฑ2 = Dโˆ’1 ๐›2 โˆ’ C๐ฑ1 If the size of เดฅ A is small, the computational cost of เดฅ Aโˆ’1 is low If D is a block diagonal matrix, the computational cost of Dโˆ’1 is low
  14. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Let

    เดฅ A be the Schur complement of the partitioned matrix M with respect to the block A, denoted as เดฅ D โ‰ก M/A๐‘žร—๐‘ž โ‰ก D โˆ’ CAโˆ’1B Decompose M into a matrix product containing a block diagonal matrix using เดฅ D XYZ โˆ’1 = Zโˆ’1Yโˆ’1Xโˆ’1, so if A and เดฅ D are nonsingular (invertible) Inverse matrix using Schur complement (for M/A๐‘žร—๐‘ž ) M โ‰ก A B C D = A ฮŸ C เดฅ D I๐‘ Aโˆ’1B ฮŸ I๐‘ž = I๐‘ ฮŸ CAโˆ’1 I๐‘ž ๐€ ฮŸ ฮŸ เดฅ ๐ƒ I๐‘ Aโˆ’1B ฮŸ I๐‘ž A B C D โˆ’1 = I๐‘ โˆ’Aโˆ’1B ฮŸ I๐‘ž ๐€โˆ’๐Ÿ ฮŸ ฮŸ เดฅ ๐ƒโˆ’๐Ÿ I๐‘ ฮŸ โˆ’CAโˆ’1 I๐‘ž = Aโˆ’1 โˆ’Aโˆ’1Bเดฅ Dโˆ’1 ฮŸ เดฅ Dโˆ’1 I๐‘ ฮŸ โˆ’CAโˆ’1 I๐‘ž = Aโˆ’1 + Aโˆ’1Bเดฅ Dโˆ’1CAโˆ’1 โˆ’Aโˆ’1Bเดฅ Dโˆ’1 โˆ’เดฅ Dโˆ’1CAโˆ’1 เดฅ Dโˆ’1
  15. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Decompose

    the linear equation of the block matrix M into a matrix product using the Schur complement เดฅ D: Expand into two equations: Calculate ๐ฑ2 from the first equation, and then substitute the result into the second equation to calculate ๐ฑ1 Solving linear equations using Schur complement (forM/A๐‘žร—๐‘ž ) A B C D ๐ฑ1 ๐ฑ2 = ๐›1 ๐›2 I๐‘ ฮŸ โˆ’CAโˆ’1 I๐‘ž A B C D ๐ฑ1 ๐ฑ2 = I๐‘ ฮŸ โˆ’CAโˆ’1 I๐‘ž ๐›1 ๐›2 A B ฮŸ เดฅ D ๐ฑ1 ๐ฑ2 = ๐›1 าง ๐›2 , where าง ๐›2 โ‰ก ๐›2 โˆ’ CAโˆ’1๐›1 ๐ฑ2 = เดฅ Dโˆ’1 าง ๐›2 ๐ฑ1 = Aโˆ’1 ๐›1 โˆ’ B๐ฑ2 เดฅ D๐ฑ2 = าง ๐›2 , A๐ฑ1 = ๐›1 โˆ’ B๐ฑ2 If the size of เดฅ D is small, the computational cost of เดฅ Dโˆ’1 is low If Ais a block diagonal matrix, the computational cost of Aโˆ’1 is low
  16. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) (

    ) ( ) ( ) ( , ) ( ) , ( ) ( ) ( ) ( ) ( , ) ( , ) ( , ) ( ) ( , , ) ( , Bundle adjustment (BA) Optimize camera poses and 3D points to minimize reprojection errors โ€ข There are errors in the observations of the image sensor โ€ข ๐ณ = 1 ๐‘๐‘ Kโ€ฒ๐—๐‘ between the observed 2D point ๐ณ and 3D point ๐— is not exactly satisfied โ€ข Assume this observation error as a Gaussian distribution and solve it as MAP estimation or maximum likelihood estimation โ€ข Given ๐‘š cameras and ๐‘› 3D points, the camera poses ๐ฉ and 3D points ๐— are estimated so that the sum of the distances (geometric error) between the reprojection point ๐’› ๐ฉ, ๐— of the 3D point observed by each camera and the corresponding 2D point ๐’› is minimized geometric error
  17. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Bundle

    adjustment (BA) โ€ข SfM using images from the Internet โ€ข The exact intrinsic parameters K of the camera are also unknown, so they are optimized simultaneously with BA โ€ข Visual SLAM โ€ข To emphasize calculation speed and stability, it is common practice to perform camera calibration beforehand and consider it as known โ€ข Optimization variables โ€ข Motion-only BA ๏ผšCamera pose ๐ฉ โ€ข Structure-only BA๏ผš3D point ๐— โ€ข Full BA ๏ผšCamera pose ๐ฉ, 3D point ๐— โ€ข Optimization range โ€ข Local BA ๏ผšFrom the latest frame to a fixed number of past frames โ€ข Global BA๏ผšAll images โ€ข When minimizing photometric error, it is called photometric bundle adjustment
  18. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Numerical

    minimization of reprojection error Minimize the error function, assuming observation errors are normally distributed with mean 0 and covariance matrix โˆ‘ โ€ข Since ๐ธ ๐ฑ is a nonlinear function, estimate the value of เทœ ๐ฑ that provides the minimum value through numerical calculation by iterative methods โ€ข Use the camera pose and 3D point positions estimated by epipolar geometry or triangulation as the initial value ๐ฑ0 โ€ข Compute เทœ ๐ฑ by updating it as เทœ ๐ฑ โ†’ เทœ ๐ฑ + ๐›ฟ๐ฑ : pose of camera ๐‘– ๐‘– = 1, โ€ฆ , ๐‘š : position of 3D point ๐‘— ๐‘— = 1, โ€ฆ , ๐‘› โˆˆ ๐”ฐ๐”ข 3 B. Triggs et al., โ€œBundle Adjustment โ€• A Modern Synthesisโ€, International Workshop on Vision Algorithms, 1999
  19. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Newtonโ€™s

    method โ€ข Expand ๐ธ ๐ฑ up to the second order term around the current estimate โ€ข When the right side is differentiated with respect to ๐›ฟ๐ฑ, the ๐›ฟ๐ฑ that gives local minimum satisfies the following equation: โ€ข Gauss-Newton method โ€ข The second term of is sufficiently small compared to the first term, thus it is approximated by .: โ€ข Levenberg-Marquardt Method โ€ข Introduce a damping factor to the left side: Numerical minimization of reprojection error Jacobian: Gradient (vector): Hessian : (where ๐‘˜ is the element number of ๐ž) B. Triggs et al., โ€œBundle Adjustment โ€• A Modern Synthesisโ€, International Workshop on Vision Algorithms, 1999
  20. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Jacobian

    for ๐‘š = ๐‘› = 3 (grey: zero matrix) Calculation of the Jacobian in BA : Differentiate with respect to all camera poses and 3D point positions ๐ฑ โ€ข Problem setting โ€ข Three camera viewpoints and three 3D points ๐‘š = ๐‘› = 3 โ€ข Perspective projection model โ€ข Known intrinsic parameters โ€ข Observation depends only on the pose of camera ๐‘– and the position of 3D point ๐‘— (Many other elements that are being differentiated are zero matrices ) ( ) ( ) ( ) ( , ) ( ) , ( ) ( ) ( ) ( ) ( , ) ( , ) ( , ) ( ) ( , , ) ( , , ) Example of problem setting B. Triggs et al., โ€œBundle Adjustment โ€• A Modern Synthesisโ€, International Workshop on Vision Algorithms, 1999
  21. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Calculation

    of the Jacobian in BA โ€ข ๏ผŒ ๏ผšRelationship of 3D points in the camera and world coordinate systems โ€ข Using the chain law, expand and as follows: โ€ข Expand the projection as follows: โ€ข Differentiate ๏ผŒand by the camera pose and the 3D point position โ€ข can be calculated as follows: ๏ผˆโˆต ๏ผ‰ B. Triggs et al., โ€œBundle Adjustment โ€• A Modern Synthesisโ€, International Workshop on Vision Algorithms, 1999 G. Gallego et al., โ€œA compact formula for the derivative of a 3-d rotation in exponential coordinatesโ€, JMIV, 2015
  22. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Speeding

    up BA using Schur complement โ€ข In BA, it is generally true that: โ€ข The block diagonal matrix, which is formed by the partial derivative elements of only the 3D point parameters, occupies most of the Hessian โ€ข Using the inverse matrix calculation with the Schur complement, the inverse of H เทœ ๐ฑ in Newtonโ€™s method equation H เทœ ๐ฑ ๐›ฟ๐ฑ = โˆ’๐  เทœ ๐ฑ is sped up m โ‰ช ๐‘› m: Number of viewpoints, ๐‘›: Number of 3D points
  23. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Schematic

    case m = ๐‘› ( ) ( ) ( ) ( ) ( ) ( ) Jacobian and Hessian in BA ๐—(1) ๐—(2) ๐—(3) ๐ฉ(1) ๐ฉ(3) ๐ฉ(2) ๐—(1) ๐—(2) ๐—(3) ๐ฉ(1) ๐ฉ(3) ๐ฉ(2) ๐—(1) ๐—(2) ๐—(3) ๐ฉ(1) ๐ฉ(3) ๐ฉ(2) Jacobian Hessian Camera : 3 3D points: 3 Partial derivative by camera pose H๐ฉ๐ฉ Partial derivative by 3D point position H๐ฑ๐ฑ H = H๐ฉ๐ฉ H๐ฉ๐ฑ H๐ฑ๐ฉ H๐ฑ๐ฑ
  24. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Jacobian

    and Hessian in BA ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ๐—(1) ๐—(8) ๐—(2) ๐—(3) ๐—(4) ๐—(5) ๐—(6) ๐—(7) ๐—(10) ๐—(9) ๐—(11) ๐—(12) ๐—(13) ๐—(14) ๐—(15) ๐ฉ(1) ๐ฉ(4) ๐ฉ(5) ๐ฉ(3) ๐ฉ(2) ๐—(1) ๐—(8) ๐—(2) ๐—(3) ๐—(4) ๐—(5) ๐—(6) ๐—(7) ๐—(10) ๐—(9) ๐—(11) ๐—(12) ๐—(13) ๐—(14) ๐—(15) ๐ฉ(1) ๐ฉ(4) ๐ฉ(5) ๐ฉ(3) ๐ฉ(2) ๐—(1) ๐—(8) ๐—(2) ๐—(3) ๐—(4) ๐—(5) ๐—(6) ๐—(7) ๐—(10) ๐—(9) ๐—(11)๐—(12)๐—(13)๐—(14)๐—(15) ๐ฉ(1) ๐ฉ(4) ๐ฉ(5) ๐ฉ(3) ๐ฉ(2) H = H๐ฉ๐ฉ H๐ฉ๐ฑ H๐ฑ๐ฉ H๐ฑ๐ฑ Practical case m โ‰ช ๐‘› Partial derivative by camera pose H๐ฉ๐ฉ Partial derivative by 3D point position H๐ฑ๐ฑ Camera : 5 3D points: 15 Jacobian Hessian
  25. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) In

    the example, D = H๐ฑ๐ฑ is a block diagonal matrix larger than A = H๐ฉ๐ฉ , so we use the Schur complement เดฅ A โ‰ก เดฅ H๐ฉ๐ฉ โ‰ก H/H๐—๐‘ฟ โ‰ก H๐ฉ๐ฉ โˆ’ H๐ฉ๐ฑ H๐ฑ๐ฑ โˆ’1H๐ฑ๐ฉ Expanding this into two equations: Calculate โˆ†๐ฑ1 from the first set and substitute the result into the second equation to calculate โˆ†๐ฑ2 Speeding up BA using Schur complement H๐ฉ๐ฉ H๐ฉ๐ฑ H๐ฑ๐ฉ H๐ฑ๐ฑ โˆ†๐ฑ1 โˆ†๐ฑ2 = ๐›1 ๐›2 เดฅ H๐ฉ๐ฉ ฮŸ H๐ฑ๐ฉ H๐ฑ๐ฑ โˆ†๐ฑ1 โˆ†๐ฑ2 = าง ๐›1 ๐›2 , where าง ๐›1 โ‰ก ๐›1 โˆ’ H๐ฉ๐ฑ H๐ฑ๐ฑ โˆ’1๐›2 โˆ†๐ฑ1 = เดฅ H๐ฉ๐ฉ โˆ’1 าง ๐›1 โˆ†๐ฑ2 = H๐ฑ๐ฑ โˆ’1 ๐›2 โˆ’ H๐ฑ๐ฉ โˆ†๐ฑ1 The size of เดฅ H๐ฉ๐ฉ is relatively small because it is proportional to the number of camera viewpoints H๐ฑ๐ฑ is a block diagonal matrix with respect to 3D points เดฅ H๐ฉ๐ฉ โˆ†๐ฑ1 = าง ๐›1 H๐ฑ๐ฑ โˆ†๐ฑ2 = ๐›2 โˆ’ H๐ฑ๐ฉ โˆ†๐ฑ1
  26. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Loop

    closing 30 Correct the entire camera trajectory โ€ข Recognizing returning from an unknown area to a measured area โ€ข Utilize the accumulation of relative pose becoming zero โ€ข Two-stage processing โ€ข Two-stage processing โ€ข Loop detection โ€ข Loop candidate detection by image retrieval โ€ข Loop verification by Sim(3) estimation โ€ข Loop correction โ€ข Loop construction โ€ข Pose graph optimization considering scale drift โ€ข Global BA
  27. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) (c)

    Correct accumulated errors by PGO and Global BA (b) Move the latest keyframe and its 3D points to construct the loop Loop construction z PGO (+ BA) Latest keyframe Keyframe detected as a loop Loop verification by Sim(3) estimation 31 Geometric verification using Sim(3) estimation & RANSAC โ€ข Compare the shapes of reconstructed 3D points to estimate similarity โ€ข In the case of a monocular camera, scale drift occurs โ€ข Transform and compare 3D points using Sim(3) transformation โ€ข Estimate Sim(3) transformation S from the multiple correspondences of 3D points โ€ข Several methods exist, including Hornโ€™s and Umeyamaโ€™s (a) Loop verification by Sim(3) estimation
  28. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Loop

    verification by Sim(3) estimation 32 Geometric verification using Sim(3) estimation & RANSAC โ€ข Specific processing steps 1. Estimate a provisional S using Sim(3) estimation and RANSAC 2. Search for corresponding points using the provisional S as a guide 3. Obtain an optimized เท  S through motion-only BA extended to Sim(3) 4. Re-estimate the correct corresponding points using this เท  S 5. If the number of correct corresponding points exceeds a certain threshold, determine it as a loop keyframe ๐พ๐‘™ (c) Correct accumulated errors by PGO and Global BA (b) Move the latest keyframe and its 3D points to construct the loop Loop construction z PGO (+ BA) Latest keyframe Keyframe detected as a loop (a) Loop verification by Sim(3) estimation
  29. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) (c)

    Correct accumulated errors by PGO and Global BA (b) Move the latest keyframe and its 3D points to construct the loop Loop construction z PGO (+ BA) Latest keyframe Keyframe detected as a loop (a) Loop verification by Sim(3) estimation Loop construction 33 Move the local map towards the loop keyframe ๐พ๐‘™ 1. Apply the Sim(3) estimated transformation เท  S to the following: โ€ข The latest keyframe ๐พ๐‘– โ€ข The group of keyframes surrounding ๐พ๐‘– โ€ข 3D points ๐—๐‘– and ๐—๐‘ observed from ๐พ๐‘– and 2. Project the 3D points ๐—๐‘™ , which are observed from the keyframes surrounding ๐พ๐‘™ , onto the moved ๐พโ€ฒ๐‘– and , and associate them with 2D points โ€ข If 3D points are duplicated, they are merged
  30. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Scale

    drift-aware pose graph optimization Pose Graph Optimization (PGO) โ€ข Correct camera trajectory errors using constraints when returning to the same location โ€ข In the case of a monocular camera: โ€ข Scale-drift is present (Figure a) โ€ข Scale errors cannot be corrected with 6-DOF PGO (Figure b) โ€ข Errors can be corrected with scale drift-aware 7-DOF PGO (Figure c) 34 Scale drift-aware pose graph optimization (PGO) H. Strasdat, โ€œScale Drift-Aware Large Scale Monocular SLAMโ€, Robotics: Science and Systems VI, 2010๏ผˆimage referenced๏ผ‰
  31. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Scale

    drift-aware pose graph optimization 35 โ€ข Convert SE 3 (rigid) to Sim 3 (similarity) parameters โ€ข Absolute pose: T๐‘– โˆˆ SE 3 โ†’ S๐‘– โˆˆ Sim 3 โ€ข Relative pose: ฮ”T๐‘–๐‘— โˆˆ SE(3) โ†’ ฮ”S๐‘–๐‘— โˆˆ Sim 3 โ€ข Define and minimize residuals and error functions like BA โ€ข Optimize absolute pose S with relative pose ฮ”S as a fixed constraint โ€ข Correct positions of 3D points observed from each KF using estimated S W๏ผšWeight matrix for residuals ๐ฌ โˆˆ ๐”ฐ๐”ฆ๐”ช 3 ๏ผš Lie algebra of S H. Strasdat, โ€œScale Drift-Aware Large Scale Monocular SLAMโ€, Robotics: Science and Systems VI, 2010
  32. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Global

    BA 6-DOF BA for all cameras and 3D points โ€ข In PGO, only the relative camera poses are used as constraints to optimize camera poses โ€ข After PGO, include 3D points for global optimization โ€ข After Global BA: โ€ข During loop closing, local mapping processed in parallel generates new KFs and 3D points โ€ข Propagate corrections to KFs and 3D points not involved in loop closing 36 (c) Correct accumulated errors by PGO and Global BA (b) Move the latest keyframe and its 3D points to construct the loop Loop construction z PGO (+ BA) Latest keyframe Keyframe detected as a loop (a) Loop verification by Sim(3) estimation
  33. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Class

    for Bundle Adjustment bundle_adjuster.h 38 num_threads_: Number of thread use_analytic_diff: Using analytic differentiation Sim3_cache: Reuse of past calculations ๐‘ฅs ๐‘ฆs ๐‘งs shotโ€™s c.s. ๐‘ฅ1 ๐‘ฆ1 ๐‘ง1 ๐‘ฅ2 ๐‘ฆ2 ๐‘ง2 cam1โ€™s c.s. cam2โ€™s c.s. ๐‘ฅo ๐‘ฆo ๐‘งo worldโ€™s c.s. Multi-camera system (2 units) Add a perspective camera model id: camera model ID, fx, fy: focal length, cx, cy: camera center pixel_baseline: base line length of stereo camera (in pixels) pose_offset: pose relative to the shot coordinate system flags: Fixing or optimizing intrinsic parameter and pose_offset Add Equirectangular camera model id: camera model ID, rows, cols: image resolution pose_offset: relative pose in the shot coordinate flags: Fixing or optimizing pose_offset pose_offset Add and get camera (shot) pose id: camera (shot) ID Vec6_t params: ๐”ฐ๐”ข 3 pose parameter Vec7_t params: ๐”ฐ๐”ฆ๐”ช 3 pose parameter
  34. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Class

    for Bundle Adjustment bundle_adjuster.cc 39 Types of loss functions Figure citation: http://ceres-solver.org/nnls_modeling.html Trivial loss: ๐œŒ ๐‘  = ๐‘  Huber loss: ๐œŒ ๐‘  = แ‰Š ๐‘  ๐‘  โ‰ค 1 2 ๐‘  โˆ’ 1 ๐‘  > 1 Soft L1 loss: ๐œŒ ๐‘  = 2 1 + ๐‘  โˆ’ 1 Cauchy loss: ๐œŒ ๐‘  = log 1 + ๐‘  Simple squared error ( ๐‘  is a squared norm ๏ผš ๐‘  = ๐‘“๐‘– 2 ) When the error is small, the behavior is quadratic; when large, it is linear (robust to outliers) Capable of handling severe outliers
  35. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Class

    for Bundle Adjustment bundle_adjuster.cc 40 Add intrinsic parameters of camera model to the problem Fix intrinsic parameters of camera model (not optimized) Fix ext_params* of camera model (not optimized) Add ext_params* to the problem *Pose relative to shot coordinate system (pose_offset in bundle_adjuster.h) Add extrinsic parameter of camera to the problem Fix extrinsic parameters of camera (not optimized)
  36. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Class

    for Bundle Adjustment bundle_adjuster.cc 41 Fix parameters of 3D points to the problem (not optimized) Compute reprojection error and its derivative Set loss function type and its scale parameter Add parameters of 3D points to the problem Add const function to the problem
  37. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Class

    for Bundle Adjustment bundle_adjuster.cc 42 Enable cache (reuse of past calculation results) Utilize sparse Schur complement during optimization Perform optimization Disable cache
  38. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Reprojection

    error reprojection_error.h 43 Compute reprojection error and analytical derivative Compute reprojection error and automatic derivative
  39. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Sample

    code for BA in SE(3) demo_corridor_ba.cc Set intrinsic parameters ๐‘“: focal length, ๐‘Š, ๐ป: image resolution Generate a camera trajectory moving straight ahead of the 3D point cloud, with added randomness 46 Generate a point cloud representing a corridor with a floor and walls on both sides, measuring 4m wide ร— 4m high ร— 20m deep (resolution of 4 10โˆ’1 = 0.444โ€ฆm) ๐‘ฅ ๐‘ฆ ๐‘ง Set the number of viewpoints Set 3D points and noise parameters of camera rotation and translation 4m 4m 20m Generate rotation parameters as r โˆˆ ๐”ฐ๐”ฌ 3 and transform to R โˆˆ SO(3)
  40. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Sample

    code for BA in SE(3) demo_corridor_ba.cc Set R, ๐ญ of the 1st viewpoint (shot) โ€ข Lie::SE3::log(): Transform SE 3 to ๐”ฐ๐”ข 3 โ€ข FLAG_FIX_PARAMS: Fix extrinsic parameters 47 Declare a BA class (with 1 thread, using analytic derivative) Set intrinsic parameters for a perspective projection camera (id=0) FLAG_FIX_INTRINSIC_PARAMS: Fix the intrinsic parameters Set R, ๐ญ of the 0th viewpoint (shot) โ€ข Lie::SE3::log(): Transform SE 3 to ๐”ฐ๐”ข 3 โ€ข FLAG_FIX_PARAMS๏ผšFixe extrinsic parameters Fix the origin and scale Generate noise of camera pose d๐ซ, d๐ญ โˆˆ ๐”ฐ๐”ข 3 Add noise to camera poses for viewpoints (shots) starting from the 2nd Convert R, ๐ญ โˆˆ SE(3) to ๐ซ, ๐ญ โˆˆ ๐”ฐ๐”ข 3 Add noise d๐ซ, d๐ญ to ๐ซ, ๐ญ Set extrinsic parameters for optimization
  41. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Sample

    code for BA in SE(3) demo_corridor_ba.cc 48 Add noise to the i-th 3D point and register it false: Do not fix the parameters of 3D point (set as optimization variables) Compute the observed coordinates ๐‘ข, ๐‘ฃ of the i-th 3D point at the j-th viewpoint (shot) If the 3D point is in front of the camera and the observed coordinates ๐‘ข, ๐‘ฃ is within the image range, set the following as parameters for the reprojection errors: โ€ข Camera model๏ผˆid=0๏ผ‰ โ€ข Coordinates ๐‘ข, ๐‘ฃ at which the j-th viewpoint observed the i-th 3D point โ€ข Set Trivial Loss ๐œŒ ๐‘  = ๐‘  (no alteration to Loss) If the environmental variable โ€SHOW_IMAGEโ€ is set, configure visualization of the results Generate images for visualization Display the images Construct a BA problem setting from the information registered in the solver โ‰ˆ
  42. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Sample

    code for BA in SE(3) demo_corridor_ba.cc 49 Perform BA (Maximum number of iterations: 20) Display the time taken for the optimization of the BA
  43. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Sample

    code for BA in Sim(3) demo_sim3_point_alignment.cc 50 Set the Sim(3) parameters S21 for cam2 to cam1 as: S21 = ๐‘ 21 R21 ๐ญ21 0 1 Set the camera position trj in the world coordinate sysmte by adding noise to 0,0, โˆ’7 Generate a point cloud on a sphere with radius 4, divided into 8 point in the longitude direction and 5 in the the latitude direction ๐‘ฅ ๐‘ฆ ๐‘ง โˆ… ๐œƒ ๐‘Ÿ Compute the translation vector ๐ญ๐‘ค1 from world to cam1 Set the pose of the reference camera 1 Convert Sim(3) parameters S21 from cam2 to cam1 into Sim(3) parameters S๐‘ค2 for world to cam2 transformation โ‰ˆ Set the pose of camera 2 transformed by Sim(3) S๐‘ค2 = ๐‘ ๐‘ค2 R๐‘ค2 ๐ญ๐‘ค2 0 1 = ๐‘ 12 R12 ๐ญ12 0 1 R๐‘ค1 ๐ญ๐‘ค1 0 1 = ๐‘ 21 R21 ๐ญ21 0 1 โˆ’1 R1 ๐ญ1 0 1 = 1 ๐‘ 21 R21 T โˆ’ 1 ๐‘ 21 R21 T๐ญ21 0 1 R๐‘ค1 ๐ญ๐’˜1 0 1
  44. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Sample

    code for BA in Sim(3) demo_sim3_point_alignment.cc 51 Set the 0th viewpoint (shot) as a multi-camera system with three cameras Randomly set the offset from the local (shot) to each camera coordinate system Set intrinsic parameters ๐‘“: focal lengthใ€๐‘Š, ๐ป: image resolution Declare a BA class (with 2 thread, using analytic derivative) Set and fix intrinsic and extrinsic parameters for a perspective projection cameras (id=0, 1, 2) FLAG_FIX_INTRINSIC_PARAMS : Set intrinsic parameters FLAG_FIX_EXTRINSIC_PARAMS: Fix extrinsic parameters offset
  45. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Sample

    code for BA in Sim(3) demo_sim3_point_alignment.cc 52 Fix the SE(3) parameters of the 0th viewpoint (shot), and set the Sim(3) parameters of the 1st viewpoint (shot) as optimization variables Register the i-th 3D points of point1 and 2 as observations for the 0th and 1st viewpoints (shot) true: Set the parameters of the 3D points as optimization varibles Compute the observed coordinate ๐‘ข, ๐‘ฃ of the i-th 3D point at the j-th viewpoint (shot) If the 3D point is in front of the camera and its observed coordinates ๐‘ข, ๐‘ฃ are within the image range, set the following as parameters for the reprojection error: โ€ข Camera model (id=j) โ€ข Coordinates ๐‘ข, ๐‘ฃ at which the 1st viewpoint observes the i-th 3D point โ€ข Set Trivial Loss ๐œŒ ๐‘  = ๐‘  (no alteration to Loss)
  46. Tutorial of Bundle Fitting Library for 3D Reconstruction (BundleFit) Sample

    code for BA in Sim(3) demo_sim3_point_alignment.cc 53 Construct a BA problem setting from the information registered in the solver Perform BA (Maximum number of iterations: 20) Assign the optimized Sim(3) parameters to the variables Display the results of the optimization