1 // This file is part of OpenMVG, an Open Multiple View Geometry C++ library. 2 3 // Copyright (c) 2018 Pierre MOULON. 4 5 // This Source Code Form is subject to the terms of the Mozilla Public 6 // License, v. 2.0. If a copy of the MPL was not distributed with this 7 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 9 #ifndef OPENMVG_SFM_STELLAR_STELLAR_SOLVER_HPP 10 #define OPENMVG_SFM_STELLAR_STELLAR_SOLVER_HPP 11 12 #include "openMVG/sfm/pipelines/stellar/relative_scale.hpp" 13 #include "openMVG/sfm/sfm_data.hpp" 14 15 namespace openMVG { 16 namespace sfm { 17 18 struct Matches_Provider; 19 struct Features_Provider; 20 21 using StellarPod = Pair_Set; 22 23 struct Stellar_Solver 24 { 25 Stellar_Solver 26 ( 27 const StellarPod & stellar_pod, 28 const Hash_Map<Pair, Pose3> & relative_poses, 29 const SfM_Data & sfm_data, 30 const Matches_Provider * matches_provider, 31 const Features_Provider * features_provider, 32 const bool use_all_matches = false, 33 const bool use_threading = false 34 ); 35 36 bool Solve(Poses & poses); 37 38 private: 39 40 std::vector<Pair_Set> ListEdge2Uplets(); 41 42 // Solve the relative scale for some triplet of poses (2-uplet of edges) 43 bool Solve2UpletsRelativeScales 44 ( 45 const std::vector<Pair_Set> & edge_two_uplets, 46 std::vector<Relative_Scale> & relative_scales 47 ); 48 49 // Solve the local to global coordinates of the poses. 50 // Re-conciliate the translation relative scale to the same coordinate system. 51 bool SolveStellarPoses 52 ( 53 const IndexT & central_node_id, 54 const std::vector<Relative_Scale> & relative_scales, 55 Hash_Map<IndexT, geometry::Pose3> & triplet_poses 56 ); 57 58 /// Optimize a stellar pod by using track triangulation & BA (Bundle Adjustment) 59 /// Default mode use only the tracks linked to the triplet pair 60 /// The b_use_all_matches make usage of all the tracks linked to the used view index 61 /// so a larger number of tracks can be used. It enhances the results, but make the BA slower. 62 bool Optimize 63 ( 64 SfM_Data & stellar_pod_reconstruction, 65 const Hash_Map<IndexT, geometry::Pose3> & triplet_poses, 66 const std::vector<Relative_Scale> & relative_scales 67 ); 68 69 private: 70 StellarPod stellar_pod_; 71 // Store if we use all the matches relating to the considered view id, 72 // or only the one linked to the input relative pairs. 73 bool use_all_matches_; 74 bool use_threading_; 75 76 // General property from the scene: 77 const SfM_Data & sfm_data_; 78 const Matches_Provider * matches_provider_; 79 const Features_Provider * features_provider_; 80 // Relative motion cache: 81 const Hash_Map<Pair, Pose3> & relative_poses_; 82 }; 83 84 } // namespace sfm 85 } // namespace openMVG 86 87 #endif // OPENMVG_SFM_STELLAR_STELLAR_DEFINITIONS_HPP 88