ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
bundle_adjustment.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include "base/reconstruction.h"
11 #include "util/option_manager.h"
12 #include "util/threading.h"
13 
14 namespace colmap {
15 
16 // Class that controls the global bundle adjustment procedure.
18 public:
20  Reconstruction* reconstruction);
21 
22 private:
23  void Run();
24 
25  const OptionManager options_;
26  Reconstruction* reconstruction_;
27 };
28 
29 } // namespace colmap
colmap::PrintHeading1
void PrintHeading1(const std::string &heading)
Definition: misc.cc:225
colmap::Image::NumPoints3D
point2D_t NumPoints3D() const
Definition: image.h:265
colmap::Point3D::Track
const class Track & Track() const
Definition: point3d.h:106
QtCompat::endl
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
colmap::image_t
uint32_t image_t
Definition: types.h:61
colmap::BundleAdjustmentOptions::min_num_residuals_for_cpu_multi_threading
int min_num_residuals_for_cpu_multi_threading
Definition: bundle_adjustment.h:130
colmap::BundleAdjustmentConfig::SetVariableCamera
void SetVariableCamera(const camera_t camera_id)
Definition: bundle_adjustment.cc:132
manifold.h
colmap::BundleAdjustmentController::BundleAdjustmentController
BundleAdjustmentController(const OptionManager &options, Reconstruction *reconstruction)
Definition: bundle_adjustment.cc:65
colmap::Track::Length
size_t Length() const
Definition: track.h:82
colmap::PrintSolverSummary
void PrintSolverSummary(const ceres::Solver::Summary &summary)
Definition: bundle_adjustment.cc:1243
colmap::BundleAdjustmentOptions::LossFunctionType::CAUCHY
@ CAUCHY
option_manager.h
colmap::BundleAdjustmentOptions::LossFunctionType::SOFT_L1
@ SOFT_L1
Eigen::Matrix3x4d
Matrix< double, 3, 4 > Matrix3x4d
Definition: types.h:39
camera_models.h
colmap::Thread::GetTimer
const Timer & GetTimer() const
Definition: threading.cc:154
colmap::BundleAdjustmentConfig::HasConstantTvec
bool HasConstantTvec(const image_t image_id) const
Definition: bundle_adjustment.cc:169
colmap::BundleAdjustmentOptions::refine_extrinsics
bool refine_extrinsics
Definition: bundle_adjustment.h:111
colmap::BundleAdjustmentConfig::HasConstantPose
bool HasConstantPose(const image_t image_id) const
Definition: bundle_adjustment.cc:150
colmap::ComposeProjectionMatrix
Eigen::Matrix3x4d ComposeProjectionMatrix(const Eigen::Vector4d &qvec, const Eigen::Vector3d &tvec)
Definition: projection.cc:39
colmap::OptionManager
Definition: option_manager.h:38
colmap::BundleAdjustmentConfig::Images
const std::unordered_set< image_t > & Images() const
Definition: bundle_adjustment.cc:173
colmap::Reconstruction::FilterObservationsWithNegativeDepth
size_t FilterObservationsWithNegativeDepth()
Definition: reconstruction.cc:684
colmap::BundleAdjustmentConfig::ConstantTvec
const std::vector< int > & ConstantTvec(const image_t image_id) const
Definition: bundle_adjustment.cc:187
colmap::BundleAdjustmentConfig::RemoveVariablePoint
void RemoveVariablePoint(const point3D_t point3D_id)
Definition: bundle_adjustment.cc:218
colmap::BundleAdjustmentConfig
Definition: bundle_adjustment.h:27
colmap::SetSubsetManifold
void SetSubsetManifold(int size, const std::vector< int > &constant_params, ceres::Problem *problem, double *params)
Definition: manifold.h:29
colmap::BundleAdjustmentConfig::HasImage
bool HasImage(const image_t image_id) const
Definition: bundle_adjustment.cc:120
colmap::Thread
Definition: threading.h:74
CHECK_OPTION_LT
#define CHECK_OPTION_LT(val1, val2)
Definition: logging.h:32
colmap::BundleAdjustmentConfig::AddConstantPoint
void AddConstantPoint(const point3D_t point3D_id)
Definition: bundle_adjustment.cc:197
colmap::BundleAdjuster::camera_ids_
std::unordered_set< camera_t > camera_ids_
Definition: bundle_adjustment.h:203
colmap::VectorContainsDuplicateValues
bool VectorContainsDuplicateValues(const std::vector< T > &vector)
Definition: misc.h:143
colmap::BundleAdjuster::problem_
std::unique_ptr< ceres::Problem > problem_
Definition: bundle_adjustment.h:201
cost_functions.h
CHECK_OPTION_GE
#define CHECK_OPTION_GE(val1, val2)
Definition: logging.h:33
colmap::BundleAdjustmentOptions::print_summary
bool print_summary
Definition: bundle_adjustment.h:114
cloudViewer::core::Solve
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
Point3D::Point3D
Point3D(T x=0., T y=0., T z=0.)
Definition: Common.h:120
colmap::BundleAdjustmentController
Definition: bundle_adjustment.h:17
cuda.h
colmap::Reconstruction
Definition: reconstruction.h:40
colmap::BundleAdjuster::options_
const BundleAdjustmentOptions options_
Definition: bundle_adjustment.h:199
colmap::RigBundleAdjuster::Options::refine_relative_poses
bool refine_relative_poses
Definition: bundle_adjustment.h:278
bundle_adjustment.h
colmap::SimpleRadialCameraModel::model_id
static const int model_id
Definition: camera_models.h:196
colmap::BundleAdjuster::ParameterizeCameras
void ParameterizeCameras(Reconstruction *reconstruction)
Definition: bundle_adjustment.cc:572
colmap::point3D_t
uint64_t point3D_t
Definition: types.h:72
projection.h
colmap::BundleAdjustmentOptions::refine_extra_params
bool refine_extra_params
Definition: bundle_adjustment.h:108
colmap::BundleAdjustmentOptions::loss_function_type
LossFunctionType loss_function_type
Definition: bundle_adjustment.h:96
colmap::BundleAdjustmentOptions::solver_options
ceres::Solver::Options solver_options
Definition: bundle_adjustment.h:140
colmap::BundleAdjustmentOptions::gpu_index
std::string gpu_index
Definition: bundle_adjustment.h:118
colmap::PrintHeading2
void PrintHeading2(const std::string &heading)
Definition: misc.cc:231
colmap::BundleAdjuster::point3D_num_observations_
std::unordered_map< point3D_t, size_t > point3D_num_observations_
Definition: bundle_adjustment.h:204
colmap::BundleAdjustmentOptions::refine_focal_length
bool refine_focal_length
Definition: bundle_adjustment.h:102
colmap::BundleAdjuster
Definition: bundle_adjustment.h:172
colmap::BundleAdjustmentConfig::SetConstantTvec
void SetConstantTvec(const image_t image_id, const std::vector< int > &idxs)
Definition: bundle_adjustment.cc:154
colmap::BundleAdjustmentConfig::IsConstantCamera
bool IsConstantCamera(const camera_t camera_id) const
Definition: bundle_adjustment.cc:136
colmap::Camera::ExtraParamsIdxs
const std::vector< size_t > & ExtraParamsIdxs() const
Definition: camera.cc:71
colmap::SetBestCudaDevice
void SetBestCudaDevice(const int gpu_index)
Definition: cuda.cc:67
colmap::CalculateSquaredReprojectionError
double CalculateSquaredReprojectionError(const Eigen::Vector2d &point2D, const Eigen::Vector3d &point3D, const Eigen::Vector4d &qvec, const Eigen::Vector3d &tvec, const Camera &camera)
Definition: projection.cc:111
misc.h
colmap::SetQuaternionManifold
void SetQuaternionManifold(ceres::Problem *problem, double *quat_xyzw)
Definition: manifold.h:19
colmap::Reconstruction::RegImageIds
const std::vector< image_t > & RegImageIds() const
Definition: reconstruction.h:504
colmap::BundleAdjustmentConfig::NumConstantCameras
size_t NumConstantCameras() const
Definition: bundle_adjustment.cc:63
colmap::BundleAdjustmentConfig::NumPoints
size_t NumPoints() const
Definition: bundle_adjustment.cc:59
Point3D
Definition: Common.h:117
bundle_adjustment.h
timer.h
colmap::BundleAdjustmentConfig::NumConstantTvecs
size_t NumConstantTvecs() const
Definition: bundle_adjustment.cc:71
colmap::BundleAdjustmentOptions::LossFunctionType::TRIVIAL
@ TRIVIAL
colmap::RigBundleAdjuster::Options
Definition: bundle_adjustment.h:276
colmap::BundleAdjustmentConfig::NumConstantPoses
size_t NumConstantPoses() const
Definition: bundle_adjustment.cc:67
colmap::BundleAdjustmentOptions::refine_principal_point
bool refine_principal_point
Definition: bundle_adjustment.h:105
colmap::BundleAdjustmentOptions::max_num_images_direct_dense_cpu_solver
int max_num_images_direct_dense_cpu_solver
Definition: bundle_adjustment.h:134
colmap::BundleAdjustmentConfig::SetConstantCamera
void SetConstantCamera(const camera_t camera_id)
Definition: bundle_adjustment.cc:128
colmap::BundleAdjustmentConfig::RemoveConstantTvec
void RemoveConstantTvec(const image_t image_id)
Definition: bundle_adjustment.cc:165
colmap::ConcatenatePoses
void ConcatenatePoses(const Eigen::Vector4d &qvec1, const Eigen::Vector3d &tvec1, const Eigen::Vector4d &qvec2, const Eigen::Vector3d &tvec2, Eigen::Vector4d *qvec12, Eigen::Vector3d *tvec12)
Definition: pose.cc:183
reconstruction.h
image
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:184
colmap::RigBundleAdjuster::Options::max_reproj_error
double max_reproj_error
Definition: bundle_adjustment.h:285
colmap::BundleAdjustmentConfig::BundleAdjustmentConfig
BundleAdjustmentConfig()
Definition: bundle_adjustment.cc:55
colmap::BundleAdjustmentConfig::AddImage
void AddImage(const image_t image_id)
Definition: bundle_adjustment.cc:116
colmap::OptionManager::bundle_adjustment
std::shared_ptr< BundleAdjustmentOptions > bundle_adjustment
Definition: option_manager.h:113
colmap::BundleAdjustmentOptions::max_num_images_direct_sparse_cpu_solver
int max_num_images_direct_sparse_cpu_solver
Definition: bundle_adjustment.h:135
colmap::BundleAdjustmentConfig::HasConstantPoint
bool HasConstantPoint(const point3D_t point3D_id) const
Definition: bundle_adjustment.cc:212
cloudViewer::visualization::rendering::EntityType::Camera
@ Camera
colmap::BundleAdjustmentConfig::NumVariablePoints
size_t NumVariablePoints() const
Definition: bundle_adjustment.cc:75
colmap::RotationMatrixToQuaternion
Eigen::Vector4d RotationMatrixToQuaternion(const Eigen::Matrix3d &rot_mat)
Definition: pose.cc:70
colmap::QuaternionToRotationMatrix
Eigen::Matrix3d QuaternionToRotationMatrix(const Eigen::Vector4d &qvec)
Definition: pose.cc:75
colmap::BundleAdjustmentOptions::max_num_images_direct_sparse_gpu_solver
int max_num_images_direct_sparse_gpu_solver
Definition: bundle_adjustment.h:137
colmap::Camera::ParamsData
const double * ParamsData() const
Definition: camera.h:184
colmap::BundleAdjustmentConfig::ConstantPoints
const std::unordered_set< point3D_t > & ConstantPoints() const
Definition: bundle_adjustment.cc:182
colmap::BundleAdjustmentConfig::RemoveConstantPoint
void RemoveConstantPoint(const point3D_t point3D_id)
Definition: bundle_adjustment.cc:222
colmap::BundleAdjustmentConfig::SetVariablePose
void SetVariablePose(const image_t image_id)
Definition: bundle_adjustment.cc:146
colmap::RigBundleAdjuster::Solve
bool Solve(Reconstruction *reconstruction, std::vector< CameraRig > *camera_rigs)
Definition: bundle_adjustment.cc:907
threading.h
colmap::BundleAdjustmentOptions::use_gpu
bool use_gpu
Definition: bundle_adjustment.h:117
colmap::Point3D::XYZ
const Eigen::Vector3d & XYZ() const
Definition: point3d.h:74
colmap::Camera::PrincipalPointIdxs
const std::vector< size_t > & PrincipalPointIdxs() const
Definition: camera.cc:67
colmap::RigBundleAdjuster::RigBundleAdjuster
RigBundleAdjuster(const BundleAdjustmentOptions &options, const Options &rig_options, const BundleAdjustmentConfig &config)
Definition: bundle_adjustment.cc:902
colmap::GetEffectiveNumThreads
int GetEffectiveNumThreads(const int num_threads)
Definition: threading.cc:269
colmap::BundleAdjustmentConfig::NumImages
size_t NumImages() const
Definition: bundle_adjustment.cc:57
colmap::BundleAdjuster::Solve
bool Solve(Reconstruction *reconstruction)
Definition: bundle_adjustment.cc:372
colmap::Camera::FocalLengthIdxs
const std::vector< size_t > & FocalLengthIdxs() const
Definition: camera.cc:63
colmap::BundleAdjustmentOptions::loss_function_scale
double loss_function_scale
Definition: bundle_adjustment.h:99
colmap::BundleAdjustmentOptions::min_num_images_gpu_solver
int min_num_images_gpu_solver
Definition: bundle_adjustment.h:125
colmap::BundleAdjustmentConfig::RemoveImage
void RemoveImage(const image_t image_id)
Definition: bundle_adjustment.cc:124
colmap::BundleAdjustmentConfig::SetConstantPose
void SetConstantPose(const image_t image_id)
Definition: bundle_adjustment.cc:140
colmap::BundleAdjustmentConfig::VariablePoints
const std::unordered_set< point3D_t > & VariablePoints() const
Definition: bundle_adjustment.cc:177
colmap::BundleAdjustmentOptions
Definition: bundle_adjustment.h:93
colmap
Definition: AutomaticReconstructionController.h:17
colmap::BundleAdjuster::BundleAdjuster
BundleAdjuster(const BundleAdjustmentOptions &options, const BundleAdjustmentConfig &config)
Definition: bundle_adjustment.cc:366
colmap::BundleAdjustmentConfig::NumResiduals
size_t NumResiduals(const Reconstruction &reconstruction) const
Definition: bundle_adjustment.cc:83
colmap::BundleAdjustmentOptions::CreateLossFunction
ceres::LossFunction * CreateLossFunction() const
Definition: bundle_adjustment.cc:230
colmap::BundleAdjustmentConfig::HasVariablePoint
bool HasVariablePoint(const point3D_t point3D_id) const
Definition: bundle_adjustment.cc:206
colmap::BundleAdjustmentOptions::Check
bool Check() const
Definition: bundle_adjustment.cc:247
colmap::Timer::PrintMinutes
void PrintMinutes() const
Definition: timer.cc:93
colmap::Camera::NumParams
size_t NumParams() const
Definition: camera.h:174
colmap::camera_t
uint32_t camera_t
Definition: types.h:58
colmap::BundleAdjuster::ParameterizePoints
void ParameterizePoints(Reconstruction *reconstruction)
Definition: bundle_adjustment.cc:623
colmap::BundleAdjuster::Summary
const ceres::Solver::Summary & Summary() const
Definition: bundle_adjustment.cc:404
colmap::BundleAdjustmentOptions::max_num_images_direct_dense_gpu_solver
int max_num_images_direct_dense_gpu_solver
Definition: bundle_adjustment.h:136
colmap::BundleAdjustmentConfig::NumConstantPoints
size_t NumConstantPoints() const
Definition: bundle_adjustment.cc:79
colmap::BundleAdjustmentConfig::AddVariablePoint
void AddVariablePoint(const point3D_t point3D_id)
Definition: bundle_adjustment.cc:192
CAMERA_MODEL_SWITCH_CASES
#define CAMERA_MODEL_SWITCH_CASES
Definition: camera_models.h:110
colmap::Reconstruction::Camera
const class Camera & Camera(const camera_t camera_id) const
Definition: reconstruction.h:450
colmap::BundleAdjustmentOptions::CreateSolverOptions
ceres::Solver::Options CreateSolverOptions(const BundleAdjustmentConfig &config, const ceres::Problem &problem) const
Definition: bundle_adjustment.cc:256
colmap::Camera
Definition: camera.h:20
colmap::BundleAdjuster::config_
BundleAdjustmentConfig config_
Definition: bundle_adjustment.h:200
colmap::BundleAdjustmentConfig::HasPoint
bool HasPoint(const point3D_t point3D_id) const
Definition: bundle_adjustment.cc:202
colmap::Reconstruction::Point3D
const class Point3D & Point3D(const point3D_t point3D_id) const
Definition: reconstruction.h:458
colmap::Point3D
Definition: point3d.h:23
colmap::BundleAdjuster::summary_
ceres::Solver::Summary summary_
Definition: bundle_adjustment.h:202
colmap::Reconstruction::Image
const class Image & Image(const image_t image_id) const
Definition: reconstruction.h:454