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

Tutorial of Geometric Solvers for Reconstructio...

Tutorial of Geometric Solvers for Reconstruction And Pose estimationย (GSRAP)

Avatar for Open Source AI Association

Open Source AI Association

December 20, 2024
Tweet

More Decks by Open Source AI Association

Other Decks in Technology

Transcript

  1. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP) Developer: Kai Okawa, Mikiya Shibuya Supporter: Open Source AI Association 1
  2. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    What is GSRAP? Geometric Solvers for Reconstruction And Pose estimation โ€ข Functions (To be added) โ€ข Relative pose estimation from 2D-2D point correspondences โ€ข Nisterโ€™s Five points algorithm โ€ข Absolute pose estimation from 2D-3D point correspondences โ€ข P3P algorithm, EPnP โ€ข Similarity transformation estimation from 3D-3D point correspondences โ€ข Umeyama algorithm โ€ข RANSAC for outlier rejections โ€ข A versatile framework for rejecting outliers โ€ข Features โ€ข C++17 โ€ข Python wrapper โ€ข Tutorial and sample codes 2
  3. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Table of contents โ€ข Coordinate transformations and camera projection models โ€ข Epipolar geometry โ€ข Fundamental Matrix F โ€ข Essential Matrix E โ€ข Relative pose from 2D-2D corresponding points โ€ข Absolute pose from 2D-3D corresponding points โ€ข Rigid/Similarity transformation from 3D-3D corresponding points โ€ข Algorithm explanation โ€ข P3P algorithm (SE(3) estimation) โ€ข Umeyama algorithm (Sim(3) estimation) โ€ข Random Sample Consensus (RANSAC) โ€ข Source code explanation 3
  4. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Coordinate transformations and camera projection models 4
  5. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    , ใƒฏใƒผใƒซใƒ‰ 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 Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    , ใƒฏใƒผใƒซใƒ‰ 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 Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    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 Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Preliminary: 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) 8 H. Strasdat et al., โ€œScale Drift-Aware Large Scale Monocular SLAMโ€, Robotics: Science and Systems VI, 2010
  9. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Epipolar geometry Spatial correspondence between two cameras and 3D points โ€ข Constraints on correspondence points between images captured in 3D scenes โ€ข Fundamental matrix F๏ผšImage coordinate system (K is unknown) โ€ข Essential matrix E๏ผšCamera coordinate system๏ผˆK is known๏ผ‰ โ€ข Estimates camera pose R๐‘๐‘ค , ๐ญ๐‘๐‘ค from F or E Epipolar plane: โ€ข The plane passing through the camera centers ๐Ž๐Ÿ ๏ผŒ ๐Ž๐Ÿ and the 3D point ๐— Epipolar line ๐ฅ: โ€ข The line where the epipolar plane intersects the image plane Epipole ๐ž: โ€ข The point where the straight line connecting ๐Ž๐Ÿ and ๐Ž๐Ÿ intersects the image plane (All epipolar lines ๐ฅ pass through the epipole ๐ž) Overview of epipolar geometry 10 ๐ณ๐Ÿ ๐— ๐— ? ๐— ? ๐ณ๐Ÿ Epipolar line ๐ฅ๐Ÿ Epipole ๐ž๐Ÿ Epipole ๐ž๐Ÿ O1 O2
  10. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Fundamental matrix F Matrix containing information about the intrinsic camera parameter K and the relative pose between the two cameras is denoted as R | ๐ญ Epipolar constraint: โ€ข When the point เทค ๐ณ1 is determined, it constraints the corresponding เทค ๐ณ2 in the other image โ€ข ๐ฅ2 = Fเทค ๐ณ1 represents the epipolar line in the image ๐ผ2 corresponding to the point เทค ๐ณ1 in the image ๐ผ1 โ€ข When ๐ฅ2 = Fเทค ๐ณ1 is substituted into the equation เทค ๐ณ2 TFเทค ๐ณ1 = 0, it simplifies to เทค ๐ณ2 T๐ฅ2 = 0, representing a vector equation of a line โ€ข F has 7 degrees of freedom โ€ข scale ambiguity โ€ข det F = 0 11 ๐‘ข2 ๐‘ฃ2 1 ๐‘“11 ๐‘“12 ๐‘“13 ๐‘“21 ๐‘“22 ๐‘“23 ๐‘“31 ๐‘“32 ๐‘“33 ๐‘ข1 ๐‘ฃ1 1 = เทค ๐ณ2 TFเทค ๐ณ1 = 0 R. Hartley, A. Zisserman, โ€œMultiple View Geometry in Computer Visionโ€, Cambridge University Press, 2003
  11. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Matrix containing a relative camera pose R | ๐ญ When substituting into ๐ณ2 T F ๐ณ1 = 0, โ€ข K1 ๏ผŒK2 ๏ผšIntrinsic parameters of each camera โ€ข เทœ ๐ณ1 = K1 โˆ’1๐ณ1 ๏ผŒเทœ ๐ณ2 = K2 โˆ’1๐ณ2 ๏ผš A point projected on a plane ๐‘๐‘ =1 (normalized image coordinate system) โ€ข E has 5 degrees of freedom (For details, refer to the paper below) โ€ข scale ambiguity โ€ข det E = 0 โ€ข 2EETE โˆ’ tr EET E = 0 Essential matrix E 12 E โ‰” K2 T F K1 เทค ๐ณ2 T K2 T โˆ’1 E K1 โˆ’1 เทค ๐ณ1 = 0 เทœ ๐ณ2 T E เทœ ๐ณ1 = 0 O. D. Faugeras, S. Maybank , โ€œMotion from point matches: Multiplicity of solutionsโ€, IJCV, Vol.4, 1990
  12. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Essential matrix E Compute R | ๐ญ from E เทœ ๐ณ2 T ๐ญ ร— Rเทœ ๐ณ1 = 0 ๐ณ1 ๐— ๐ณ2 ๐ž๐Ÿ ๐ž๐Ÿ O1 O2 R, ๐ญ เทœ ๐ณ2 T ๐ญ ร— Rเทœ ๐ณ1 = 0 The direction vector of pixel ๐ณ1 in the coordinate system of camera 2 เทœ ๐ณ1 เทœ ๐ณ2 Vector perpendicular to the epipolar plane (i.e. 0 dot product because it is also orthogonal to the direction vector เทœ ๐ณ2 of ๐ณ2 ) The above equation is expressed by the skew- symmetric matrix ๐ญ ร— , E = ๐ญ ร— R The epipolar constraint เทœ ๐ณ2 T E เทœ ๐ณ1 = 0 leads to the equation 13 R. Hartley, A. Zisserman, โ€œMultiple View Geometry in Computer Visionโ€, Cambridge University Press, 2003
  13. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Essential matrix E Compute R | ๐ญ from E โ€ข Perform a Singular Value Decomposition on E (there are sign ambiguity in SVD) โ€ข The are two possible matrix decompositions E = ๐ญ ร— R = SR โ€ข Since the sign of E is ambiguous, the sign of the translation ๐ญ is ambiguous โ€ข There are four possible solutions in total W = 0 โˆ’1 0 1 0 0 0 0 1 and Z = 0 0 0 โˆ’1 0 0 0 0 1 S = U๐‘UT R = UWVT or UWTVT E = U diag 1,1,0 VT ๐ญ = ๐ฎ3 or -๐ฎ3 R | ๐ญ = UWVT| +๐ฎ3 or UWVT| โˆ’๐ฎ3 or UWTVT| +๐ฎ3 or UWTVT| โˆ’๐ฎ3 14 R. Hartley, A. Zisserman, โ€œMultiple View Geometry in Computer Visionโ€, Cambridge University Press, 2003
  14. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    A B (a) A B (b) A Bโ€™ (c) A Bโ€™ (d) โœ” ร— ร— ร— Essential matrix E Compute R | ๐ญ from E When decomposing E, there are four possible solutions for R | ๐ญ as illustrated below โ€ข The correct solution is selected based on the condition that โ€œ3D points are reconstructed in front of both camerasโ€ 15 R. Hartley, A. Zisserman, โ€œMultiple View Geometry in Computer Visionโ€, Cambridge University Press, 2003
  15. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of relative pose from 2D-2D point correspondences 16
  16. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Fundamental matrix estimation The epipolar constraints for ๐‘› points can be expressed as linear equations โ€ข Estimate F using 8-point correspondences (8-point algorithm) โ€ข In linear solution methods, the number of unknowns is 8 due to scale ambiguity (though the intrinsic degrees of freedom are 7) โ€ข In the case of ๐‘› โ‰ฅ 8 โ€ข Calculate F from the all point correspondences with least square methods, such as Singular Value Decomposition (SVD) โ€ข When feature points are distributed on the same plane, the matrix A degenerates โ€ข Estimate R | ๐ญ from the essential matrix E or the homography matrix H 17
  17. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Essential matrix estimation There are two main approaches โ€ข First estimate F using methods like 8-point algorithm, and derive E by substituting into: E โ‰” K2 T F K1 โ€ข Directly compute E using methos like 5-point algorithm โ€ข 5-point algorithm requires fewer point correspondences than 8-point algorithm โ€ข When using RANSAC, the probability of including outliers in randomly sampled correspondences is low, making it possible to find the correct combination of points with fewer iterations 18
  18. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of absolute pose from 2D-3D point correspondences 19
  19. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Perspective-n-Point (PnP) Problem The problem of estimating the camera pose, R and ๐ญ, given the coordinates of n points in 3D space and their corresponding points in the image World Coordinate Camera Coordinate R, 20
  20. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Perspective-n-Point (PnP) Problem P3P problem โ€ข Geometrically, the problem can be solved with a minimum of ๐‘› = 3 corresponding points โ€ข In 1841, Grunert proposed the first solution โ€ข J. A. Grunert, โ€œDas pothenotische problem in erweiterter gestalt nebst bber seine anwendungen in der geodasie,โ€ Grunerts Archiv fur Mathematik und Physik, pages 238โ€“248, 1841 PnP problem โ€ข Minimize the error using points where ๐‘› โ‰ฅ 3 โ€ข EPnP is commonly used as an ๐‘›-point solver (EPnP: Efficient Perspective-n-Point Camera Pose Estimation) โ€ข V. Lepetit, F. Moreno-Noguer, P. Fua, โ€œEPnP: An Accurate O(n) Solution to the PnP Problemโ€, International Journal of Computer Vision (IJCV), 2009 21 Gaku Nakano, โ€œA Versatile Approach for Solving PnP, PnPf, and PnPfr Problemsโ€, ECCV, 2016๏ผˆ่กจใ‚’ๅผ•็”จ๏ผ‰
  21. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Perspective-n-Point (PnP) Problem PnPf, PnPfr Problems โ€ข The problem of estimating focal length ๐‘“ and lens distortion ๐‘˜ in addition to the camera pose โ€ข The minimum number of required points varies depending on the number of unknow parameters The number of correspondences points required for estimation in the PnP problem and its derived problems, considering the unknown parameters PnP PnPf PnPfr Rotation matrix R โœ“ โœ“ โœ“ Translation vector ๐ญ โœ“ โœ“ โœ“ Focal length ๐‘“ โœ“ โœ“ Lens distortion ๐‘˜1 , ๐‘˜2 , ๐‘˜3 โœ“ The number of unknow parameters 6 7 8 (๐‘˜1 ), 10 (๐‘˜1 , ๐‘˜2 , ๐‘˜3 ) The minimum number of required points ๐‘› 3 4 4 (๐‘˜1 ), 5 (๐‘˜1 , ๐‘˜2 , ๐‘˜3 ) 22 Gaku Nakano, โ€œA Versatile Approach for Solving PnP, PnPf, and PnPfr Problemsโ€, ECCV, 2016๏ผˆ่กจใ‚’ๅผ•็”จ๏ผ‰
  22. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of rigid and similarity transformations from 3D-3D point correspondences 23
  23. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of rigid and similarity transformations from 3D-3D point correspondences Rigid transformation โ€ข SE 3 estimation โ€ข Rotation matrix R โˆˆ SO(3), translation vector ๐ญ โˆˆ โ„3 Similarity transformation โ€ข Sim 3 estimation โ€ข Rotation matrix R โˆˆ SO(3), translation vector ๐ญ โˆˆ โ„3, scale parameter ๐‘  24
  24. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Rigid transformation โ€ข SE 3 estimation โ€ข Rotation matrix R โˆˆ SO(3), translation vector ๐ญ Transformation using the estimated R, ๐ญ Point Cloud Library, https://github.com/PointCloudLibrary/pcl/blob/master/test/bunny.pcd (Cite the point cloud data) ๐‘ฅ2 ๐‘ฆ2 ๐‘ง2 1 = R ๐ญ 0 1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ง1 1 R, ๐ญ 25 Estimation of rigid and similarity transformations from 3D-3D point correspondences
  25. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Similarity transformation โ€ข Sim(3) estimation โ€ข Rotation matrix R โˆˆ SO(3), translation vector ๐ญ โˆˆ โ„3, scale parameter ๐‘  R, ๐ญ, s ๐‘ฅ2 ๐‘ฆ2 ๐‘ง2 1 = ๐‘ R ๐ญ 0 1 ๐‘ฅ1 ๐‘ฆ1 ๐‘ง1 1 26 Estimation of rigid and similarity transformations from 3D-3D point correspondences Point Cloud Library, https://github.com/PointCloudLibrary/pcl/blob/master/test/bunny.pcd (Cite the point cloud data) Transformation using the estimated R, ๐ญ, s
  26. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Algorithm explanation: P3P algorithm (Grunertโ€™s method) 27
  27. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) Estimate T โˆˆ SE(3) from three 2D-3D correspondences Consider the tetrahedron formed by the camera center ๐—๐จ and the three 3D points ๐—๐Ÿ , ๐—๐Ÿ , ๐—๐Ÿ‘ 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 2. Estimate the camera pose T โˆˆ SE(3) ๐—๐จ ๐—๐Ÿ ๐—๐Ÿ ๐—๐Ÿ‘ ๐›ผ ๐›ฝ ๐›พ ๐‘Ž ๐‘ ๐‘ ๐‘™2 ๐‘™3 ๐‘™1 ๐ฑ๐Ÿ ๐ฑ๐Ÿ‘ ๐ฑ๐Ÿ Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 28
  28. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 Direction vector of the 3D point ๐ฑ๐’Š in the camera coordinate system เทœ ๐ฑ๐’Š ๐—๐จ ๐—๐Ÿ ๐—๐Ÿ ๐—๐Ÿ‘ ๐›ผ ๐›ฝ ๐›พ ๐‘Ž ๐‘ ๐‘ ๐‘™2 ๐‘™3 ๐‘™1 เทœ ๐ฑ๐Ÿ เทœ ๐ฑ๐Ÿ‘ เทœ ๐ฑ๐Ÿ ๐ฑ๐Ÿ ๐ฑ๐Ÿ ๐ฑ๐Ÿ‘ เทœ ๐ฑ๐’Š = Kโˆ’๐Ÿ๐ฑ๐’Š Kโˆ’๐Ÿ๐ฑ๐’Š Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 29
  29. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 Calculate the angles ๐›ผ, ๐›ฝ, ๐›พ formed by the ray vectors เทœ ๐ฑ๐Ÿ , เทœ ๐ฑ๐Ÿ , เทœ ๐ฑ๐Ÿ‘ ๐›ผ = arccos เทœ ๐ฑ๐Ÿ , เทœ ๐ฑ๐Ÿ‘ , ๐›ฝ = arccos เทœ ๐ฑ๐Ÿ‘ , เทœ ๐ฑ๐Ÿ ,๐›พ = arccos เทœ ๐ฑ๐Ÿ , เทœ ๐ฑ๐Ÿ ๐—๐จ ๐—๐Ÿ ๐—๐Ÿ ๐—๐Ÿ‘ ๐›ผ ๐›ฝ ๐›พ ๐‘Ž ๐‘ ๐‘ ๐‘™2 ๐‘™3 ๐‘™1 เทœ ๐ฑ๐Ÿ เทœ ๐ฑ๐Ÿ‘ เทœ ๐ฑ๐Ÿ ๐ฑ๐Ÿ ๐ฑ๐Ÿ ๐ฑ๐Ÿ‘ Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 30
  30. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 Based on the law of cosines, the following three equations hold (๐‘Ž, ๐‘, ๐‘, ๐›ผ, ๐›ฝ, ๐›พ are known) ๐—๐จ ๐—๐Ÿ ๐—๐Ÿ ๐—๐Ÿ‘ ๐›ผ ๐›ฝ ๐›พ ๐‘Ž ๐‘ ๐‘ ๐‘™2 ๐‘™3 ๐‘™1 ๐‘Ž2 = ๐‘™2 2 + ๐‘™3 2 โˆ’ 2๐‘™2 ๐‘™3 cos๐›ผ ๐‘2 = ๐‘™3 2 + ๐‘™1 2 โˆ’ 2๐‘™3 ๐‘™1 cos๐›ฝ ๐‘2 = ๐‘™1 2 + ๐‘™2 2 โˆ’ 2๐‘™1 ๐‘™2 cos๐›พ เทœ ๐ฑ๐Ÿ เทœ ๐ฑ๐Ÿ‘ เทœ ๐ฑ๐Ÿ ๐ฑ๐Ÿ ๐ฑ๐Ÿ ๐ฑ๐Ÿ‘ Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 31
  31. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 When substituting with ๐‘ข = ๐‘™2 ๐‘™1 , ๐‘ฃ = ๐‘™3 ๐‘™1 , ๐‘Ž2 = ๐‘™1 2 ๐‘ข2 + ๐‘ฃ2 โˆ’ 2๐‘ข๐‘ฃcos๐›ผ ๐‘2 = ๐‘™1 2 1 + ๐‘ฃ2 โˆ’ 2๐‘ฃcos๐›ฝ ๐‘2 = ๐‘™1 2 1 + ๐‘ข2 โˆ’ 2ucos๐›พ ๐‘™1 2 = ๐‘Ž2 ๐‘ข2 + ๐‘ฃ2 โˆ’ 2๐‘ข๐‘ฃcos๐›ผ ๐‘™1 2 = ๐‘2 1 + ๐‘ฃ2 โˆ’ 2๐‘ฃcos๐›ฝ ๐‘™1 2 = ๐‘2 1 + ๐‘ข2 โˆ’ 2๐‘ขcos๐›พ Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 32
  32. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 Substitute the first and third equations into the second equation to eliminate ๐‘™1 , ๐‘ข ๐‘™1 2 = ๐‘2 1 + ๐‘ฃ2 โˆ’ 2๐‘ฃcos๐›ฝ ๐‘™1 2 = ๐‘Ž2 ๐‘ข2 + ๐‘ฃ2 โˆ’ 2๐‘ข๐‘ฃcos๐›ผ ๐‘™1 2 = ๐‘2 1 + ๐‘ข2 โˆ’ 2๐‘ขcos๐›พ ๐ด4 ๐‘ฃ4 + ๐ด3 ๐‘ฃ3 + ๐ด2 ๐‘ฃ2 + ๐ด1 ๐‘ฃ + ๐ด0 = 0 Reduced to a quartic equation Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 33
  33. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 4แˆผ แˆฝ โˆ’ ๐‘Ž2 โˆ’ ๐‘2 ๐‘Ž2 + ๐‘2 โˆ’ ๐‘2 cos๐›ฝ + 2๐‘Ž2๐‘2cos2๐›พcos๐›ฝ + ๐‘2 ๐‘Ž2 โˆ’ ๐‘2 + ๐‘2 cos๐›ผcos๐›พ ๐ด4 = ๐‘Ž2 โˆ’ ๐‘2 โˆ’ ๐‘2 2 โˆ’ 4๐‘2๐‘2cos2๐›ผ 4แˆผ แˆฝ โˆ’ ๐‘Ž2 โˆ’ ๐‘2 ๐‘Ž2 โˆ’ ๐‘2 โˆ’ ๐‘2 cos๐›ฝ + ๐‘Ž2๐‘2 + ๐‘2๐‘2 โˆ’ ๐‘4 cos๐›ผcos๐›พ + 2๐‘2๐‘2cos2๐›ผcos๐›ฝ 2แˆผ แˆฝ ๐‘Ž2 โˆ’ ๐‘2 2 โˆ’ ๐‘4 + 2 ๐‘Ž2 โˆ’ ๐‘2 2cos2๐›ฝ โˆ’ 2๐‘2 ๐‘Ž2 โˆ’ ๐‘2 cos2๐›ผ โˆ’ 4๐‘2 ๐‘Ž2 + ๐‘2 cos๐›ผcos๐›ฝcos๐›พ โˆ’ 2๐‘2 ๐‘Ž2 โˆ’ ๐‘2 cos2๐›พ ๐ด2 = ๐ด0 = ๐‘Ž2 + ๐‘2 โˆ’ ๐‘2 2 โˆ’ 4๐‘Ž2๐‘2cos2๐›พ ๐ด3 = ๐ด1 = ๐ด4 ๐‘ฃ4 + ๐ด3 ๐‘ฃ3 + ๐ด2 ๐‘ฃ2 + ๐ด1 ๐‘ฃ + ๐ด0 = 0 34
  34. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 Solve ๐ด4 ๐‘ฃ4 + ๐ด3 ๐‘ฃ3 + ๐ด2 ๐‘ฃ2 + ๐ด1 ๐‘ฃ + ๐ด0 = 0 for ๐‘ฃ and compute ๐‘™1 , ๐‘™2 , ๐‘™3 Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 ๐‘™1 2 = ๐‘2 1 + ๐‘ฃ2 โˆ’ 2๐‘ฃcos๐›ฝ ๐‘™3 = ๐‘™1 ๐‘ฃ ๐‘Ž2 = ๐‘™1 2 ๐‘ข2 + ๐‘ฃ2 โˆ’ 2๐‘ข๐‘ฃcos๐›ผ ๐‘™2 2 โˆ’ 2๐‘™1 ๐‘™2 ๐‘ฃ๐‘๐‘œ๐‘ ๐›ผ + ๐‘™1 2๐‘ฃ2 โˆ’ ๐‘Ž2 = 0 There are four possible solutions for ๐‘™1 , ๐‘™2 , ๐‘™3 35
  35. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 1. Estimate the lengths of the rays ๐‘™1 , ๐‘™2 , ๐‘™3 Choose one solution out of the four based on the consistency with additional information (1) or (2) (1) Additional sensor information such as GPS (2) Fourth point correspondences Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 36
  36. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    P3P algorithm (Grunertโ€™s method) 2. Estimate the camera pose T โˆˆ SE(3) Compute R, ๐—๐จ by substituting the estimated ๐‘™๐‘– ๐‘™๐‘– เทœ ๐ฑ๐’Š = R ๐—๐’Š โˆ’ ๐—๐จ ๐‘– = 1,2,3 ๐—๐จ ๐—๐Ÿ ๐—๐Ÿ ๐—๐Ÿ‘ ๐›ผ ๐›ฝ ๐›พ ๐‘Ž ๐‘ ๐‘ ๐‘™2 ๐‘™3 ๐‘™1 เทœ ๐ฑ๐Ÿ เทœ ๐ฑ๐Ÿ‘ เทœ ๐ฑ๐Ÿ ๐ฑ๐Ÿ ๐ฑ๐Ÿ ๐ฑ๐Ÿ‘ Cyrill Stachniss, โ€œProjective 3-Point (P3P) Algorithm / Spatial Resectionโ€, Photogrammetry I & II Course, 2021 37
  37. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    ๐’๐ข๐ฆ ๐Ÿ‘ estimation (Umeyama algorithm) Estimate the similarity transformation matrix from ๐‘› 3D-3D point correspondences โ€ข Input: ๐‘› sets of 3D-3D point correspondences X = ๐ฑ1 , ๐ฑ2 , โ‹ฏ , ๐ฑ๐‘› ใ€Y = ๐ฒ1 , ๐ฒ2 , โ‹ฏ , ๐ฒ๐‘› โ€ข Output: R, ๐ญ, ๐‘  โˆˆ Sim(3) โ€ข Minimize the following error function: โ€ข Estimate R, ๐ญ, ๐‘  to align X with Y using a similarity transformation ๐‘’2 R, ๐ญ, ๐‘  = 1 ๐‘› เท ๐‘–=1 ๐‘› ๐ฒ๐‘– โˆ’ ๐‘ R๐ฑ๐‘– + ๐ญ 2 Coordinates of ๐ฑ๐‘– after similarity transformation Shinji Umeyama, โ€œLeast-Squares estimation of transformation parameters between two point patternsโ€, TPAMI, Vol.13, Issue 4, 1991 39
  38. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    ๐’๐ข๐ฆ ๐Ÿ‘ estimation (Umeyama algorithm) Detailed computation procedure: 1. Compute the centroid and covariance matrix of each point cloud 2. Perform Singular Value Decomposition (SVD) on the covariance matrix ฮฃ๐‘ฅ๐‘ฆ 3. Compute R, ๐ญ, ๐‘  from the results of steps 1 and 2 R = USVT ๐ญ = ๐›๐‘ฆ โˆ’ ๐‘ R๐›๐‘ฅ ๐›๐‘ฅ = 1 ๐‘› เท ๐‘–=1 ๐‘› ๐ฑ๐‘– ๐›๐‘ฆ = 1 ๐‘› เท ๐‘–=1 ๐‘› ๐ฒ๐‘– SVD ฮฃ๐‘ฅ๐‘ฆ = UDVT S = แ‰Š ๐ผ diag 1,1, โ‹ฏ , 1, โˆ’1 if det ฮฃ๐‘ฅ๐‘ฆ = 1 if det ฮฃ๐‘ฅ๐‘ฆ = โˆ’1 D = diag ๐‘‘๐‘– , ๐‘‘1 โ‰ฅ ๐‘‘2 โ‰ฅ โ‹ฏ โ‰ฅ ๐‘‘๐‘š โ‰ฅ 0 Shinji Umeyama, โ€œLeast-Squares estimation of transformation parameters between two point patternsโ€, TPAMI, Vol.13, Issue 4, 1991 40 s = 1 ๐œŽ๐‘ฅ 2 tr DS ฮฃ๐‘ฅ๐‘ฆ = 1 ๐‘› เท ๐‘–=1 ๐‘› ๐ฒ๐‘– โˆ’ ๐›๐‘ฆ ๐ฑ๐‘– โˆ’ ๐›๐‘ฅ T ๐œŽ๐‘ฅ = 1 ๐‘› เท ๐‘–=1 ๐‘› ๐ฑ๐‘– โˆ’ ๐›๐‘ฅ 2
  39. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Random Sample Consensus (RANSAC) One of the iterative algorithms to estimate the parameters a mathematical model from observational data containing outliers 42 โ€ข Example: Estimation of line parameters 1. Randomly sample (two) data points for model estimation 2. Estimate the model parameters using the sampled points 3. Count the inliers with a fitting error within the threshold and calculate the score 4. Iterate through steps 1-3 to find the sample yielding the best score 5. Using all inliers identified in step 4, compute the model parameters that minimize the error
  40. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Random Sample Consensus (RANSAC) 43 โ€ข Example: Estimation of line parameters 1. Randomly sample (two) data points for model estimation 2. Estimate the model parameters using the sampled points 3. Count the inliers with a fitting error within the threshold and calculate the score 4. Iterate through steps 1-3 to find the sample yielding the best score 5. Using all inliers identified in step 4, compute the model parameters that minimize the error One of the iterative algorithms to estimate the parameters a mathematical model from observational data containing outliers
  41. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Random Sample Consensus (RANSAC) 44 โ€ข Example: Estimation of line parameters 1. Randomly sample (two) data points for model estimation 2. Estimate the model parameters using the sampled points 3. Count the inliers with a fitting error within the threshold and calculate the score 4. Iterate through steps 1-3 to find the sample yielding the best score 5. Using all inliers identified in step 4, compute the model parameters that minimize the error One of the iterative algorithms to estimate the parameters a mathematical model from observational data containing outliers
  42. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Random Sample Consensus (RANSAC) 45 โ€ข Example: Estimation of line parameters 1. Randomly sample (two) data points for model estimation 2. Estimate the model parameters using the sampled points 3. Count the inliers with a fitting error within the threshold and calculate the score 4. Iterate through steps 1-3 to find the sample yielding the best score 5. Using all inliers identified in step 4, compute the model parameters that minimize the error One of the iterative algorithms to estimate the parameters a mathematical model from observational data containing outliers
  43. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Random Sample Consensus (RANSAC) 46 โ€ข Example: Estimation of line parameters 1. Randomly sample (two) data points for model estimation 2. Estimate the model parameters using the sampled points 3. Count the inliers with a fitting error within the threshold and calculate the score 4. Iterate through steps 1-3 to find the sample yielding the best score 5. Using all inliers identified in step 4, compute the model parameters that minimize the error One of the iterative algorithms to estimate the parameters a mathematical model from observational data containing outliers
  44. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Random Sample Consensus (RANSAC) 47 โ€ข Example: Estimation of line parameters 1. Randomly sample (two) data points for model estimation 2. Estimate the model parameters using the sampled points 3. Count the inliers with a fitting error within the threshold and calculate the score 4. Iterate through steps 1-3 to find the sample yielding the best score 5. Using all inliers identified in step 4, compute the model parameters that minimize the error One of the iterative algorithms to estimate the parameters a mathematical model from observational data containing outliers
  45. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Random Sample Consensus (RANSAC) โ€ข The number of trials ๐‘ required to obtain a correct solution with probability ๐‘ by selecting only inliers from the observed data One of the iterative algorithms to estimate the parameters a mathematical model from observational data containing outliers ๐‘ = log(1 โˆ’ ๐‘) log(1 โˆ’ ๐‘Ÿ๐‘ ) ๐‘  : Number of observed data points used for model computation ๐‘Ÿ : Inlier ratio of observed data ๐‘Ÿ๐‘  = 1 โˆ’ 1 โˆ’ ๐‘ 1 ๐‘ ๐‘Ÿ๐‘ : Probability of sampling only inliers allowing duplicates 48
  46. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Random Sample Consensus (RANSAC) Nearest neighbor search of local feature points Outlier removal using 8-point algorithm and RANSAC Examples of local feature matching (The original images were sourced from the Fountain-P11 dataset) Example: 8-point algorithm 1. Select 8 random points from nearest neighbor pairs to compute F 2. Compute the epipolar line ๐ฅ using F, for each correspondence 3. Check inliers based on distance to ๐ฅ within a threshold 4. After ๐‘ iterations through steps 1-3, compute the final เท  F using least squares from the best Fโ€™s inliers 49
  47. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Solvers implemented in GSRAP (To be added) Estimation of relative pose from 2D-2D point correspondences โ€ข Nisterโ€™s 5-point algorithm (๐‘› โ‰ฅ 5, Essential matrix E) โ€ข D. Nistรฉr, โ€œAn efficient solution to the five-point relative pose problemโ€, TPAMI, Vol.26, Issue 6, pp.756โ€“777, 2004 Estimation of absolute pose R, ๐ญ from 2D-3D point correspondences โ€ข Keโ€™s P3P algorithm (๐‘› = 3) โ€ข T. Ke, S. I. Roumeliotis, โ€œAn Efficient Algebraic Solution to the Perspective-Three-Point Problemโ€, pp.7225-7233, CVPR, 2017 โ€ข EPnP: Efficient Perspective-n-Point Camera Pose Estimation (๐‘› โ‰ฅ 4) โ€ข V. Lepetit, F. Moreno-Noguer, P. Fua, โ€œEPnP: An Accurate O(n) Solution to the PnP Problemโ€, IJCV, 2009 Estimation of similarity transformations R, ๐ญ, s from 3D-3D point correspondences โ€ข Umeyama algorithm (๐‘› โ‰ฅ 3) โ€ข S. Umeyama, โ€œLeast-Squares Estimation of Transformation Parameters Between Two Point Patternsโ€, pp. 376-380, Vol.13, TPAMI, 1991 โ€ป We implemented Nisterโ€™s 5-point algoritm and EPnP withOpenGV, and Keโ€™s P3P algorithm with OpenCV. โ€ข L. Kneip, P. Furgale, "OpenGV: A unified and generalized approach to real-time calibrated geometric vision", ICRA, May 2014 โ€ข OpenCV, https://github.com/opencv/opencv 51 Template-based RANSAC allows consistent implementation for all solvers
  48. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    RANSAC parameters gsrap-def.h The probability of sampling only inliers ๐ฉ Maximum number of sampling Minimum number of sampling A flag that terminates the iteration once it's determined that the probability of only sampling inliers, denoted as ๐‘Ÿ๐‘ , exceeds a specified probability ๐‘, where ๐‘Ÿ is the proportion of inliers calculated based on the best model at that time A flag for calculating the number of trials ๐‘ using non- duplicated sampling. (If the sample size is sufficiently large, approximation is possible.) 53
  49. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    RANSAC algorithm gsrap-def.h Estimate model from the sampled data Randomly sample the minimum number of data required for model estimation Terminate if the number of sampling iterations exceeds the pre-set maximum 54
  50. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    RANSAC algorithm ransac.h Determine the inlier data for a model estimated from any given sample set 55
  51. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    RANSAC algorithm ransac.h The number of the inliers for the best model at that moment Without duplication: ๐‘žno_duplicate = ๐ถ๐‘ฅ ๐‘€ ร— โ‹ฏร— ๐ถโˆ’ ๐‘ โˆ’1 ๐‘€โˆ’ ๐‘ โˆ’1 Where: ๐‘€๏ผšTotal population size ๐ถ๏ผš Number of inliers in the population ๐‘ ๏ผš Sample size Calculate the probability ๐‘ž of sampling only inliers based on the proportion of inliers in the best model With duplication: ๐‘žduplicate = ๐‘Ÿ๐‘  Note: Only the calculation of ๐‘žduplicate considers duplication (in practice, sampling is done without duplication). Strictly speaking, the no-duplication method is more accurate. However, since the sample size of the population ๐‘€ is generally large, ๐‘žno_duplicate is approximately equal to ๐‘žduplicate . 56
  52. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    RANSAC algorithm ransac.h If itr_upperlimit is greater than ๐‘, update it. (This means that as the best model is updated and the inlier proportion ๐‘Ÿ increases, fewer sampling iterations are required.) If the calculate ๐‘ž is greater than the probability of sampling only inliers derived from the current upper limit itr_upperlimit, then compute sample count ๐‘. Calculate the required sampling count ๐‘ from the probability ๐‘ž (preventing division by zero and overflow in the computation of ๐‘) 57
  53. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Source code explanation: Estimation of relative pose from 2D-2D point correspondences 58
  54. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Recovery of R, ๐ญ from E essential_solver.cc Calculate the essential matrix E using Nisterโ€™s 5-point algorithm (Input: Direction vectors of feature points in each image, namely bearings1 and bearings2) Normalize E to set the scale of the translation vector to 1 59 Verify that the first and second singular values are equal, and the third singular value is zero, taking errors into account โˆต SVD E = U diag 1,1,0 VT Perform Singular Value Decomposition (SVD) Define the lambda function to determine whether the determinant of the 3 ร— 3 matrix M is 1 or not, taking errors into account.
  55. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Recovery of R, ๐ญ from E essential_solver.cc 60 If either U or VT represents a reflection transformation (i.e., det โˆ™ < 0), the right-hand and left-hand coordinate systems will swap. Adjust using the last element of W. ๐ญ = ๐ฎ3 or -๐ฎ3 R | ๐ญ = UWVT| +๐ฎ3 or UWVT| โˆ’๐ฎ3 or UWTVT| +๐ฎ3 or UWTVT| โˆ’๐ฎ3 From the four possible R | ๐ญ decomposition of E, select the correct solution based on the condition that โ€œ3D points are reconstructed in front of both camerasโ€
  56. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of E using Nisterโ€™s five points algorithm example_essential_solver.cc Set the parameters for RANSAC Note: std::thread::hardware_concurrency() is a function to retrieve the number of threads supported by the system Compute the E matrix Set the parameters for RANSAC Set a function to check if the eigen values of the E matrix meet the conditions. Generate correspondence information without mismatches 61 Generate camera poses and corresponding points for simulation โ€ข Center coordinates and radius of the 3D point cloud โ€ข Generate the 3D point cloud โ€ข Set the camera poses for the two viewpoints โ€ข Convert the 3D point clouds3D into the direction vectors in each cameraโ€™s coordinate system
  57. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Source code explanation: Estimation of absolute pose from 2D-3D point correspondences 62
  58. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of R, ๐ญ using P3P example_p3p_solver.cc Set the parameters for RANSAC Compute R, ๐ญ Set the parameters for the P3P solver Generate correspondence information without mismatches Generate camera poses and corresponding points for simulation โ€ข Center coordinates and radius of the 3D point cloud โ€ข Generation of the 3D point cloud โ€ข Setting the camera poses for the two viewpoints โ€ข Convert the 3D point cloud to direction vectors in each camera coordinate system Declare for inlier determination based on bearing vector angular errors (for โ€˜PnpInlierCheckParamsUsingProjectedPointโ€™, itโ€˜s based on reprojection error in image space) 63
  59. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of R, ๐ญ using EPnP example_pnp_solver.cc 64 Set the parameters for RANSAC Compute R, ๐ญ Set the parameters for the PnP solver Generate correspondence information without mismatches Generate camera poses and corresponding points for simulation โ€ข Center coordinates and radius of the 3D point cloud โ€ข Generation of the 3D point cloud โ€ข Setting the camera poses for the two viewpoints โ€ข Convert the 3D point cloud to direction vectors in each camera coordinate system Declare for inlier determination based on bearing vector angular errors (for โ€˜AssumePerspectiveCameraโ€™, itโ€˜s based on reprojection error in image space)
  60. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Source code explanation: Estimation of rigid and similarity transformations from 3D-3D point correspondences 65
  61. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Umeyama algorithm sim3_solver.cc Calculate the centroid of each point cloud: ๐›๐‘ฅ = 1 ๐‘› ฯƒ๐‘–=1 ๐‘› ๐ฑ๐‘– , ๐›๐‘ฆ = 1 ๐‘› ฯƒ๐‘–=1 ๐‘› ๐ฒ๐‘– Shift the origin of the coordinate system of each point cloud to its centroid: ๐ฑ๐‘– โˆ’ ๐›๐‘ฅ , ๐ฒ๐‘– โˆ’ ๐›๐‘ฆ Compute the covariance matrix: ฮฃ๐‘ฅ๐‘ฆ = 1 ๐‘› ฯƒ๐‘–=1 ๐‘› ๐ฒ๐‘– โˆ’ ๐›๐‘ฆ ๐ฑ๐‘– โˆ’ ๐›๐‘ฅ T SVD ฮฃ๐‘ฅ๐‘ฆ = UDVT D = diag ๐‘‘๐‘– , ๐‘‘1 โ‰ฅ ๐‘‘2 โ‰ฅ โ‹ฏ โ‰ฅ ๐‘‘๐‘š โ‰ฅ 0 If rank ฮฃ๐‘ฅ๐‘ฆ โ‰ฅ 2, an optimal solution is uniquely determined Ensure the determinant of the rotation matrix (right-hand coordinate system) is 1. If det ฮฃ๐‘ฅ๐‘ฆ = โˆ’1, it's a reflection transformation. S = แ‰Š ๐ผ diag 1,1, โ‹ฏ, 1, โˆ’1 if det ฮฃ๐‘ฅ๐‘ฆ = 1 if det ฮฃ๐‘ฅ๐‘ฆ = โˆ’1 66
  62. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Umeyama algorithm sim3_solver.cc Compute the rotation matrix: R = USVT Compute the scale: s = 1 ๐œŽ๐‘ฅ 2 tr DS Compute the translation vector: ๐ญ = ๐›๐‘ฆ โˆ’ ๐‘ R๐›๐‘ฅ 67
  63. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of Sim 3 using Umeyama algorithm example_sim3_solver.cc True rotation matrix Rgt : Rotation axis 1 1 1 T, rotation angle ๐œ‹ 4 True scale ๐‘ gt True translation vector ๐ญgt Generate 500 random points P1 , within a cube centered at 0 0 0 T with edges of length 1 Transform point cloud P1 using Rgt , ๐ญgt , ๐‘ gt to generate point cloud P2 Generate correspondence information without mismatches 68
  64. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Estimation of Sim 3 using Umeyama algorithm example_sim3_solver.cc Optimize using least squares method with inliers only Set the parameters for RANSAC Calculate R, ๐ญ, and s Set the the threshold for inlier determination 69
  65. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Summary โ€ข Basics of Camera Geometry โ€ข Coordinate transformation and camera projection model โ€ข Epipolar geometry โ€ข Fundamental Matrix F , Essential Matrix E โ€ข Estimation of relative pose, absolute pose, and rigid/similarity transformations using 2D-2D, 2D-3D, and 3D-3D correspondences โ€ข Algorithm Explanation โ€ข P3P, Umeyama Algorithm โ€ข Random Sample Consensus (RANSAC) โ€ข Template-based RANSAC allows consistent implementation for all solvers โ€ข Source code explanation โ€ข RANSAC, Estimation of E matrix and recovery of R, ๐ญ, P3P, EPnP, Umeyama Algorithm and Sim(3) estimation
  66. Tutorial of Geometric Solvers for Reconstruction And Pose estimation (GSRAP)

    Acknowledgements In preparing this document, we would like to express our heartfelt gratitude to Professors Richard Hartley and Andrew Zisserman, authors of the seminal reference book โ€œMultiple View Geometry in Computer Vision,โ€ which offers a detailed explanation of the fundamentals of multi-view geometry. We also wish to extend our deep appreciation to Professor Cyrill Stachniss for sharing his invaluable computer vision lecture materials. Additionally, we are indebted to Dr. Gaku Nakano for granting us the privilege to edit and cite his tables and figures. Finally, our profound thanks go to the numerous individuals who consistently extend their unwavering support.