 |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Go to the documentation of this file.
10 #include <ceres/ceres.h>
14 #include <unordered_set>
79 const std::unordered_set<image_t>&
Images()
const;
85 std::unordered_set<camera_t> constant_camera_ids_;
86 std::unordered_set<image_t> image_ids_;
87 std::unordered_set<point3D_t> variable_point3D_ids_;
88 std::unordered_set<point3D_t> constant_point3D_ids_;
89 std::unordered_set<image_t> constant_poses_;
90 std::unordered_map<image_t, std::vector<int>> constant_tvecs_;
153 #if CERES_VERSION_MAJOR < 2
155 #endif // CERES_VERSION_MAJOR
165 const ceres::Problem& problem)
const;
180 const ceres::Solver::Summary&
Summary()
const;
184 ceres::LossFunction* loss_function);
187 void AddImageToProblem(
const image_t image_id,
189 ceres::LossFunction* loss_function);
191 void AddPointToProblem(
const point3D_t point3D_id,
193 ceres::LossFunction* loss_function);
211 class ParallelBundleAdjuster {
215 bool print_summary =
true;
218 int max_num_iterations = 50;
224 int num_threads = -1;
229 int min_num_residuals_for_cpu_multi_threading = 50000;
234 ParallelBundleAdjuster(
const Options& options,
235 const BundleAdjustmentOptions& ba_options,
236 const BundleAdjustmentConfig& config);
238 bool Solve(Reconstruction* reconstruction);
241 const ceres::Solver::Summary& Summary()
const;
245 static bool IsSupported(
const BundleAdjustmentOptions& options,
246 const Reconstruction& reconstruction);
249 void SetUp(Reconstruction* reconstruction);
250 void TearDown(Reconstruction* reconstruction);
252 void AddImagesToProblem(Reconstruction* reconstruction);
253 void AddPointsToProblem(Reconstruction* reconstruction);
255 const Options options_;
256 const BundleAdjustmentOptions ba_options_;
257 BundleAdjustmentConfig config_;
258 ceres::Solver::Summary summary_;
260 size_t num_measurements_;
261 std::vector<pba::CameraT> cameras_;
262 std::vector<pba::Point3D> points3D_;
263 std::vector<pba::Point2D> measurements_;
264 std::unordered_set<camera_t> camera_ids_;
265 std::unordered_set<point3D_t> point3D_ids_;
266 std::vector<int> camera_idxs_;
267 std::vector<int> point3D_idxs_;
268 std::vector<image_t> ordered_image_ids_;
269 std::vector<point3D_t> ordered_point3D_ids_;
270 std::unordered_map<image_t, int> image_id_to_camera_idx_;
293 std::vector<CameraRig>* camera_rigs);
297 std::vector<CameraRig>* camera_rigs,
298 ceres::LossFunction* loss_function);
300 const std::vector<CameraRig>& camera_rigs);
302 void AddImageToProblem(
const image_t image_id,
304 std::vector<CameraRig>* camera_rigs,
305 ceres::LossFunction* loss_function);
307 void AddPointToProblem(
const point3D_t point3D_id,
309 ceres::LossFunction* loss_function);
312 const std::vector<CameraRig>& camera_rigs);
319 std::unordered_map<image_t, CameraRig*> image_id_to_camera_rig_;
322 std::unordered_map<image_t, Eigen::Vector4d*> image_id_to_rig_qvec_;
323 std::unordered_map<image_t, Eigen::Vector3d*> image_id_to_rig_tvec_;
326 std::vector<std::vector<Eigen::Vector4d>> camera_rig_qvecs_;
327 std::vector<std::vector<Eigen::Vector3d>> camera_rig_tvecs_;
331 std::unordered_set<double*> parameterized_qvec_data_;
uint32_t image_t
Definition: types.h:61
int min_num_residuals_for_cpu_multi_threading
Definition: bundle_adjustment.h:130
void SetVariableCamera(const camera_t camera_id)
Definition: bundle_adjustment.cc:132
void PrintSolverSummary(const ceres::Solver::Summary &summary)
Definition: bundle_adjustment.cc:1243
bool HasConstantTvec(const image_t image_id) const
Definition: bundle_adjustment.cc:169
bool refine_extrinsics
Definition: bundle_adjustment.h:111
bool HasConstantPose(const image_t image_id) const
Definition: bundle_adjustment.cc:150
const std::unordered_set< image_t > & Images() const
Definition: bundle_adjustment.cc:173
const std::vector< int > & ConstantTvec(const image_t image_id) const
Definition: bundle_adjustment.cc:187
void RemoveVariablePoint(const point3D_t point3D_id)
Definition: bundle_adjustment.cc:218
Definition: bundle_adjustment.h:27
bool HasImage(const image_t image_id) const
Definition: bundle_adjustment.cc:120
void AddConstantPoint(const point3D_t point3D_id)
Definition: bundle_adjustment.cc:197
std::unordered_set< camera_t > camera_ids_
Definition: bundle_adjustment.h:203
std::unique_ptr< ceres::Problem > problem_
Definition: bundle_adjustment.h:201
BundleAdjustmentOptions()
Definition: bundle_adjustment.h:142
bool print_summary
Definition: bundle_adjustment.h:114
void Solve(const Tensor &A, const Tensor &B, Tensor &X)
Solve AX = B with LU decomposition. A is a square matrix.
Definition: Solve.cpp:22
Definition: reconstruction.h:40
const BundleAdjustmentOptions options_
Definition: bundle_adjustment.h:199
bool refine_relative_poses
Definition: bundle_adjustment.h:278
void ParameterizeCameras(Reconstruction *reconstruction)
Definition: bundle_adjustment.cc:572
uint64_t point3D_t
Definition: types.h:72
bool refine_extra_params
Definition: bundle_adjustment.h:108
LossFunctionType loss_function_type
Definition: bundle_adjustment.h:96
ceres::Solver::Options solver_options
Definition: bundle_adjustment.h:140
std::string gpu_index
Definition: bundle_adjustment.h:118
std::unordered_map< point3D_t, size_t > point3D_num_observations_
Definition: bundle_adjustment.h:204
bool refine_focal_length
Definition: bundle_adjustment.h:102
Definition: bundle_adjustment.h:172
void SetConstantTvec(const image_t image_id, const std::vector< int > &idxs)
Definition: bundle_adjustment.cc:154
bool IsConstantCamera(const camera_t camera_id) const
Definition: bundle_adjustment.cc:136
const double * e
Definition: essential_matrix_poly.h:10
LossFunctionType
Definition: bundle_adjustment.h:95
size_t NumConstantCameras() const
Definition: bundle_adjustment.cc:63
size_t NumPoints() const
Definition: bundle_adjustment.cc:59
size_t NumConstantTvecs() const
Definition: bundle_adjustment.cc:71
Definition: bundle_adjustment.h:276
size_t NumConstantPoses() const
Definition: bundle_adjustment.cc:67
bool refine_principal_point
Definition: bundle_adjustment.h:105
int max_num_images_direct_dense_cpu_solver
Definition: bundle_adjustment.h:134
void SetConstantCamera(const camera_t camera_id)
Definition: bundle_adjustment.cc:128
void RemoveConstantTvec(const image_t image_id)
Definition: bundle_adjustment.cc:165
double max_reproj_error
Definition: bundle_adjustment.h:285
BundleAdjustmentConfig()
Definition: bundle_adjustment.cc:55
void AddImage(const image_t image_id)
Definition: bundle_adjustment.cc:116
int max_num_images_direct_sparse_cpu_solver
Definition: bundle_adjustment.h:135
bool HasConstantPoint(const point3D_t point3D_id) const
Definition: bundle_adjustment.cc:212
size_t NumVariablePoints() const
Definition: bundle_adjustment.cc:75
int max_num_images_direct_sparse_gpu_solver
Definition: bundle_adjustment.h:137
const std::unordered_set< point3D_t > & ConstantPoints() const
Definition: bundle_adjustment.cc:182
void RemoveConstantPoint(const point3D_t point3D_id)
Definition: bundle_adjustment.cc:222
void SetVariablePose(const image_t image_id)
Definition: bundle_adjustment.cc:146
bool Solve(Reconstruction *reconstruction, std::vector< CameraRig > *camera_rigs)
Definition: bundle_adjustment.cc:907
bool use_gpu
Definition: bundle_adjustment.h:117
RigBundleAdjuster(const BundleAdjustmentOptions &options, const Options &rig_options, const BundleAdjustmentConfig &config)
Definition: bundle_adjustment.cc:902
size_t NumImages() const
Definition: bundle_adjustment.cc:57
Definition: bundle_adjustment.h:274
bool Solve(Reconstruction *reconstruction)
Definition: bundle_adjustment.cc:372
double loss_function_scale
Definition: bundle_adjustment.h:99
int min_num_images_gpu_solver
Definition: bundle_adjustment.h:125
void RemoveImage(const image_t image_id)
Definition: bundle_adjustment.cc:124
void SetConstantPose(const image_t image_id)
Definition: bundle_adjustment.cc:140
const std::unordered_set< point3D_t > & VariablePoints() const
Definition: bundle_adjustment.cc:177
Definition: bundle_adjustment.h:93
Definition: AutomaticReconstructionController.h:17
BundleAdjuster(const BundleAdjustmentOptions &options, const BundleAdjustmentConfig &config)
Definition: bundle_adjustment.cc:366
size_t NumResiduals(const Reconstruction &reconstruction) const
Definition: bundle_adjustment.cc:83
ceres::LossFunction * CreateLossFunction() const
Definition: bundle_adjustment.cc:230
bool HasVariablePoint(const point3D_t point3D_id) const
Definition: bundle_adjustment.cc:206
bool Check() const
Definition: bundle_adjustment.cc:247
uint32_t camera_t
Definition: types.h:58
void ParameterizePoints(Reconstruction *reconstruction)
Definition: bundle_adjustment.cc:623
const ceres::Solver::Summary & Summary() const
Definition: bundle_adjustment.cc:404
int max_num_images_direct_dense_gpu_solver
Definition: bundle_adjustment.h:136
size_t NumConstantPoints() const
Definition: bundle_adjustment.cc:79
void AddVariablePoint(const point3D_t point3D_id)
Definition: bundle_adjustment.cc:192
ceres::Solver::Options CreateSolverOptions(const BundleAdjustmentConfig &config, const ceres::Problem &problem) const
Definition: bundle_adjustment.cc:256
BundleAdjustmentConfig config_
Definition: bundle_adjustment.h:200
bool HasPoint(const point3D_t point3D_id) const
Definition: bundle_adjustment.cc:202
ceres::Solver::Summary summary_
Definition: bundle_adjustment.h:202