ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
automatic_reconstruction.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 <string>
11 
13 #include "retrieval/resources.h"
14 #include "util/option_manager.h"
15 #include "util/threading.h"
16 
17 namespace colmap {
18 
20 public:
21  enum class DataType { INDIVIDUAL, VIDEO, INTERNET };
22  enum class Quality { LOW, MEDIUM, HIGH, EXTREME };
23  enum class Mesher { POISSON, DELAUNAY };
24 
25  struct Options {
26  // The path to the workspace folder in which all results are stored.
27  std::string workspace_path;
28 
29  // The path to the image folder which are used as input.
30  std::string image_path;
31 
32  // The path to the mask folder which are used as input.
33  std::string mask_path;
34 
35  // The path to the vocabulary tree for feature matching.
37 
38  // The type of input data used to choose optimal mapper settings.
40 
41  // Whether to perform low- or high-quality reconstruction.
43 
44  // Whether to use shared intrinsics or not.
45  bool single_camera = false;
46 
47  // Which camera model to use for images.
48  std::string camera_model = "SIMPLE_RADIAL";
49 
50  // Whether to perform sparse mapping.
51  bool sparse = true;
52 
53 // Whether to perform dense mapping.
54 #ifdef CUDA_ENABLED
55  bool dense = true;
56 #else
57  bool dense = false;
58 #endif
59 
60  // The meshing algorithm to be used.
61 #ifdef CGAL_ENABLED
63 #else
65 #endif
66 
67  // Whether to perform surface texturing.
68  bool texturing = true;
69 
70  // The number of threads to use in all stages.
71  int num_threads = -1;
72 
73  // Whether to use the GPU in feature extraction and matching.
74 #ifdef CUDA_ENABLED
75  bool use_gpu = true;
76 #else
77  bool use_gpu = false;
78 #endif
79 
80  // Index of the GPU used for GPU stages. For multi-GPU computation,
81  // you should separate multiple GPU indices by comma, e.g., "0,1,2,3".
82  // By default, all GPUs will be used in all stages.
83  std::string gpu_index = "-1";
84  };
85 
87  const Options& options,
88  ReconstructionManager* reconstruction_manager);
89 
90  void Stop() override;
91 
92 protected:
93  virtual void RunDenseMapper();
94 
95  // Hook methods for derived classes to customize behavior
96  virtual void OnFusedPointsGenerated(size_t reconstruction_idx,
97  const std::vector<PlyPoint>& points) {}
98  virtual void OnMeshGenerated(size_t reconstruction_idx,
99  const std::string& mesh_path) {}
100  virtual void OnTexturedMeshGenerated(size_t reconstruction_idx,
101  const std::string& textured_path) {}
102 
103  // Protected members for derived classes
108 
109 private:
110  void Run() override;
111  void RunFeatureExtraction();
112  void RunFeatureMatching();
113  void RunSparseMapper();
114 
115  std::unique_ptr<Thread> feature_extractor_;
116  std::unique_ptr<Thread> exhaustive_matcher_;
117  std::unique_ptr<Thread> sequential_matcher_;
118  std::unique_ptr<Thread> vocab_tree_matcher_;
119 };
120 
121 } // namespace colmap
warp.h
colmap::AutomaticReconstructionController::DataType
DataType
Definition: automatic_reconstruction.h:21
colmap::OptionManager::ModifyForHighQuality
void ModifyForHighQuality()
Definition: option_manager.cc:155
colmap::OptionManager::image_path
std::shared_ptr< std::string > image_path
Definition: option_manager.h:100
QtCompat::endl
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
colmap::AutomaticReconstructionController::Options::image_path
std::string image_path
Definition: automatic_reconstruction.h:30
colmap::ImageReaderOptions::image_path
std::string image_path
Definition: image_reader.h:23
colmap::AutomaticReconstructionController::OnTexturedMeshGenerated
virtual void OnTexturedMeshGenerated(size_t reconstruction_idx, const std::string &textured_path)
Definition: automatic_reconstruction.h:100
colmap::AutomaticReconstructionController::Quality::HIGH
@ HIGH
fusion.h
colmap::OptionManager::exhaustive_matching
std::shared_ptr< ExhaustiveMatchingOptions > exhaustive_matching
Definition: option_manager.h:106
colmap::CreateDirIfNotExists
void CreateDirIfNotExists(const std::string &path)
Definition: misc.cc:112
download.h
colmap::AutomaticReconstructionController::RunDenseMapper
virtual void RunDenseMapper()
Definition: automatic_reconstruction.cc:262
colmap::AutomaticReconstructionController::Options::mesher
Mesher mesher
Definition: automatic_reconstruction.h:64
x
normal_z x
Definition: my_point_types.h:165
texturing_controller.h
option_manager.h
colmap::Thread::GetTimer
const Timer & GetTimer() const
Definition: threading.cc:154
colmap::MaybeDownloadAndCacheFile
std::filesystem::path MaybeDownloadAndCacheFile(const std::string &uri)
colmap::OptionManager::sift_extraction
std::shared_ptr< SiftExtractionOptions > sift_extraction
Definition: option_manager.h:103
colmap::AutomaticReconstructionController::reconstruction_manager_
ReconstructionManager * reconstruction_manager_
Definition: automatic_reconstruction.h:106
colmap::Bitmap::IsRGB
bool IsRGB() const
Definition: bitmap.h:261
colmap::ExistsFile
bool ExistsFile(const std::string &path)
Definition: misc.cc:100
colmap::OptionManager
Definition: option_manager.h:38
colmap::AutomaticReconstructionController::Options::dense
bool dense
Definition: automatic_reconstruction.h:57
colmap::AutomaticReconstructionController
Definition: automatic_reconstruction.h:19
colmap::SequentialFeatureMatcher
Definition: matching.h:422
colmap::AutomaticReconstructionController::DataType::INDIVIDUAL
@ INDIVIDUAL
colmap::OptionManager::delaunay_meshing
std::shared_ptr< mvs::DelaunayMeshingOptions > delaunay_meshing
Definition: option_manager.h:119
colmap::mvs::StereoFusion
Definition: fusion.h:82
colmap::Bitmap::SetPixel
bool SetPixel(const int x, const int y, const BitmapColor< uint8_t > &color)
Definition: bitmap.cc:199
colmap::GetDirList
std::vector< std::string > GetDirList(const std::string &path)
Definition: misc.cc:195
colmap::JoinPaths
std::string JoinPaths(T const &... paths)
Definition: misc.h:128
colmap::Bitmap
Definition: bitmap.h:51
colmap::ImageReaderOptions::mask_path
std::string mask_path
Definition: image_reader.h:32
colmap::AutomaticReconstructionController::options_
const Options options_
Definition: automatic_reconstruction.h:104
colmap::OptionManager::ModifyForInternetData
void ModifyForInternetData()
Definition: option_manager.cc:109
colmap::Camera::InitializeWithName
void InitializeWithName(const std::string &model_name, const double focal_length, const size_t width, const size_t height)
Definition: camera.cc:212
colmap::Thread
Definition: threading.h:74
colmap::TexturingReconstruction
Definition: texturing_controller.h:74
colmap::ReconstructionManager::Get
const Reconstruction & Get(const size_t idx) const
Definition: reconstruction_manager.cc:56
colmap::Bitmap::Allocate
bool Allocate(const int width, const int height, const bool as_rgb)
Definition: bitmap.cc:104
color
math::float4 color
Definition: LineSetBuffers.cpp:46
colmap::WriteBinaryPlyPoints
void WriteBinaryPlyPoints(const std::string &path, const std::vector< PlyPoint > &points, const bool write_normal, const bool write_rgb)
Definition: ply.cc:369
colmap::mvs::PatchMatchController
Definition: patch_match.h:227
colmap::AutomaticReconstructionController::DataType::INTERNET
@ INTERNET
colmap::AutomaticReconstructionController::Options::use_gpu
bool use_gpu
Definition: automatic_reconstruction.h:77
colmap::ImageReaderOptions::camera_model
std::string camera_model
Definition: image_reader.h:39
colmap::AutomaticReconstructionController::AutomaticReconstructionController
AutomaticReconstructionController(const Options &options, ReconstructionManager *reconstruction_manager)
Definition: automatic_reconstruction.cc:48
colmap::AutomaticReconstructionController::Options::vocab_tree_path
std::string vocab_tree_path
Definition: automatic_reconstruction.h:36
colmap::Camera::SetPrincipalPointX
void SetPrincipalPointX(const double ppx)
Definition: camera.cc:158
colmap::AutomaticReconstructionController::DataType::VIDEO
@ VIDEO
testing.h
undistortion.h
colmap::ExistsCameraModelWithName
bool ExistsCameraModelWithName(const std::string &model_name)
Definition: camera_models.cc:94
meshing.h
colmap::Bitmap::IsGrey
bool IsGrey() const
Definition: bitmap.h:263
width
int width
Definition: FileIOFactory.cpp:142
colmap::WarpImageBetweenCameras
void WarpImageBetweenCameras(const Camera &source_camera, const Camera &target_camera, const Bitmap &source_image, Bitmap *target_image)
Definition: warp.cc:51
colmap::AutomaticReconstructionController::Options::num_threads
int num_threads
Definition: automatic_reconstruction.h:71
height
int height
Definition: FileIOFactory.cpp:143
colmap::AutomaticReconstructionController::Mesher::POISSON
@ POISSON
matching.h
y
normal_z y
Definition: my_point_types.h:168
random.h
automatic_reconstruction.h
colmap::AutomaticReconstructionController::OnFusedPointsGenerated
virtual void OnFusedPointsGenerated(size_t reconstruction_idx, const std::vector< PlyPoint > &points)
Definition: automatic_reconstruction.h:96
colmap::OptionManager::ModifyForLowQuality
void ModifyForLowQuality()
Definition: option_manager.cc:113
extraction.h
colmap::Bitmap::Width
int Width() const
Definition: bitmap.h:249
colmap::AutomaticReconstructionController::Options::texturing
bool texturing
Definition: automatic_reconstruction.h:68
colmap::DownsampleImage
void DownsampleImage(const float *data, const int rows, const int cols, const int new_rows, const int new_cols, float *downsampled)
Definition: warp.cc:226
e
const double * e
Definition: essential_matrix_poly.h:10
misc.h
colmap::AutomaticReconstructionController::Stop
void Stop() override
Definition: automatic_reconstruction.cc:159
colmap::ImageReaderOptions::database_path
std::string database_path
Definition: image_reader.h:20
colmap::Bitmap::Height
int Height() const
Definition: bitmap.h:250
colmap::AutomaticReconstructionController::Options::camera_model
std::string camera_model
Definition: automatic_reconstruction.h:48
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(TestIdenticalCameras)
Definition: warp_test.cc:91
colmap::mvs::StereoFusion::GetFusedPointsVisibility
const std::vector< std::vector< int > > & GetFusedPointsVisibility() const
Definition: fusion.cc:142
colmap::AutomaticReconstructionController::Options
Definition: automatic_reconstruction.h:25
colmap::OptionManager::ModifyForVideoData
void ModifyForVideoData()
Definition: option_manager.cc:97
colmap::AutomaticReconstructionController::Options::quality
Quality quality
Definition: automatic_reconstruction.h:42
colmap::AutomaticReconstructionController::Options::mask_path
std::string mask_path
Definition: automatic_reconstruction.h:33
colmap::ImageReaderOptions::single_camera
bool single_camera
Definition: image_reader.h:42
colmap::AutomaticReconstructionController::Quality::EXTREME
@ EXTREME
colmap::ReconstructionManager::Write
void Write(const std::string &path, const OptionManager *options) const
Definition: reconstruction_manager.cc:83
colmap::Thread::Start
virtual void Start()
Definition: threading.cc:50
colmap::AutomaticReconstructionController::Options::single_camera
bool single_camera
Definition: automatic_reconstruction.h:45
colmap::OptionManager::poisson_meshing
std::shared_ptr< mvs::PoissonMeshingOptions > poisson_meshing
Definition: option_manager.h:118
colmap::ExistsDir
bool ExistsDir(const std::string &path)
Definition: misc.cc:104
colmap::ImageReaderOptions
Definition: image_reader.h:18
colmap::VocabTreeFeatureMatcher
Definition: matching.h:443
colmap::AutomaticReconstructionController::Quality
Quality
Definition: automatic_reconstruction.h:22
colmap::AutomaticReconstructionController::OnMeshGenerated
virtual void OnMeshGenerated(size_t reconstruction_idx, const std::string &mesh_path)
Definition: automatic_reconstruction.h:98
image
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:184
colmap::OptionManager::sift_matching
std::shared_ptr< SiftMatchingOptions > sift_matching
Definition: option_manager.h:105
colmap::AutomaticReconstructionController::Options::data_type
DataType data_type
Definition: automatic_reconstruction.h:39
colmap::mvs::WritePointsVisibility
void WritePointsVisibility(const std::string &path, const std::vector< std::vector< int >> &points_visibility)
Definition: fusion.cc:635
points
int points
Definition: FileIOFactory.cpp:144
colmap::OptionManager::bundle_adjustment
std::shared_ptr< BundleAdjustmentOptions > bundle_adjustment
Definition: option_manager.h:113
colmap::AutomaticReconstructionController::active_thread_
Thread * active_thread_
Definition: automatic_reconstruction.h:107
incremental_mapper.h
colmap::OptionManager::ModifyForMediumQuality
void ModifyForMediumQuality()
Definition: option_manager.cc:134
colmap::OptionManager::ModifyForIndividualData
void ModifyForIndividualData()
Definition: option_manager.cc:91
colmap::AutomaticReconstructionController::Options::workspace_path
std::string workspace_path
Definition: automatic_reconstruction.h:27
colmap::BitmapColor
Definition: bitmap.h:30
colmap::WarpImageWithHomographyBetweenCameras
void WarpImageWithHomographyBetweenCameras(const Eigen::Matrix3d &H, const Camera &source_camera, const Camera &target_camera, const Bitmap &source_image, Bitmap *target_image)
Definition: warp.cc:124
colmap::retrieval::kDefaultVocabTreeUri
const static std::string kDefaultVocabTreeUri
Definition: resources.h:25
colmap::Reconstruction::NumRegImages
size_t NumRegImages() const
Definition: reconstruction.h:440
colmap::Thread::Thread
Thread()
Definition: threading.cc:38
colmap::OptionManager::patch_match_stereo
std::shared_ptr< mvs::PatchMatchOptions > patch_match_stereo
Definition: option_manager.h:116
colmap::OptionManager::database_path
std::shared_ptr< std::string > database_path
Definition: option_manager.h:99
colmap::ReconstructionManager
Definition: reconstruction_manager.h:16
colmap::AutomaticReconstructionController::Mesher::DELAUNAY
@ DELAUNAY
colmap::WarpImageWithHomography
void WarpImageWithHomography(const Eigen::Matrix3d &H, const Bitmap &source_image, Bitmap *target_image)
Definition: warp.cc:98
reconstruction_manager.h
colmap::Thread::Wait
virtual void Wait()
Definition: threading.cc:86
colmap::AutomaticReconstructionController::Mesher
Mesher
Definition: automatic_reconstruction.h:23
threading.h
colmap::SmoothImage
void SmoothImage(const float *data, const int rows, const int cols, const float sigma_r, const float sigma_c, float *smoothed)
Definition: warp.cc:215
colmap::UndistortCameraOptions::max_image_size
int max_image_size
Definition: undistortion.h:28
colmap::OptionManager::ModifyForExtremeQuality
void ModifyForExtremeQuality()
Definition: option_manager.cc:168
colmap::Thread::Stop
virtual void Stop()
Definition: threading.cc:65
colmap::ExhaustiveFeatureMatcher
Definition: matching.h:388
colmap::AutomaticReconstructionController::Options::sparse
bool sparse
Definition: automatic_reconstruction.h:51
resources.h
colmap::OptionManager::sequential_matching
std::shared_ptr< SequentialMatchingOptions > sequential_matching
Definition: option_manager.h:107
colmap::OptionManager::mapper
std::shared_ptr< IncrementalMapperOptions > mapper
Definition: option_manager.h:114
colmap::SiftFeatureExtractor
Definition: extraction.h:25
colmap::OptionManager::stereo_fusion
std::shared_ptr< mvs::StereoFusionOptions > stereo_fusion
Definition: option_manager.h:117
colmap::mvs::StereoFusion::GetFusedPoints
const std::vector< PlyPoint > & GetFusedPoints() const
Definition: fusion.cc:138
colmap::UndistortCameraOptions
Definition: undistortion.h:18
colmap
Definition: AutomaticReconstructionController.h:17
colmap::Bitmap::GetPixel
bool GetPixel(const int x, const int y, BitmapColor< uint8_t > *color) const
Definition: bitmap.cc:178
colmap::OptionManager::AddAllOptions
void AddAllOptions()
Definition: option_manager.cc:178
colmap::Thread::IsStopped
bool IsStopped()
Definition: threading.cc:97
colmap::OptionManager::vocab_tree_matching
std::shared_ptr< VocabTreeMatchingOptions > vocab_tree_matching
Definition: option_manager.h:108
colmap::Timer::PrintMinutes
void PrintMinutes() const
Definition: timer.cc:93
cloudViewer::IncrementalMapperController
colmap::IncrementalMapperController IncrementalMapperController
Definition: ReconstructionWidget.h:38
colmap::AutomaticReconstructionController::Quality::LOW
@ LOW
colmap::ResampleImageBilinear
void ResampleImageBilinear(const float *data, const int rows, const int cols, const int new_rows, const int new_cols, float *resampled)
Definition: warp.cc:174
colmap::COLMAPUndistorter
Definition: undistortion.h:43
colmap::AutomaticReconstructionController::Quality::MEDIUM
@ MEDIUM
colmap::ReconstructionManager::Read
size_t Read(const std::string &path)
Definition: reconstruction_manager.cc:77
patch::to_string
std::string to_string(const T &n)
Definition: Common.h:20
colmap::mvs::PoissonMeshing
bool PoissonMeshing(const PoissonMeshingOptions &options, const std::string &input_path, const std::string &output_path)
Definition: meshing.cc:123
colmap::AutomaticReconstructionController::Options::gpu_index
std::string gpu_index
Definition: automatic_reconstruction.h:83
colmap::ReconstructionManager::Size
size_t Size() const
Definition: reconstruction_manager.cc:54
colmap::OptionManager::texturing
std::shared_ptr< TexturingOptions > texturing
Definition: option_manager.h:120
colmap::Camera
Definition: camera.h:20
colmap::AutomaticReconstructionController::option_manager_
OptionManager option_manager_
Definition: automatic_reconstruction.h:105
colmap::OptionManager::image_reader
std::shared_ptr< ImageReaderOptions > image_reader
Definition: option_manager.h:102
patch_match.h