MCPcopy Create free account
hub / github.com/colmap/colmap / Load

Method Load

src/colmap/mvs/workspace.cc:62–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62void Workspace::Load(const std::vector<std::string>& image_names) {
63 const size_t num_images = model_.images.size();
64 bitmaps_.resize(num_images);
65 depth_maps_.resize(num_images);
66 normal_maps_.resize(num_images);
67
68 auto LoadWorkspaceData = [&, this](const int image_idx) {
69 const size_t width = model_.images.at(image_idx).GetWidth();
70 const size_t height = model_.images.at(image_idx).GetHeight();
71
72 // Read and rescale bitmap
73 auto bitmap = std::make_unique<Bitmap>();
74 bitmap->Read(GetBitmapPath(image_idx), options_.image_as_rgb);
75 if (bitmap->Width() != static_cast<int>(width) ||
76 bitmap->Height() != static_cast<int>(height)) {
77 bitmap->Rescale(static_cast<int>(width), static_cast<int>(height));
78 }
79 bitmaps_[image_idx] = std::move(bitmap);
80
81 // Read and rescale depth map
82 auto depth_map = std::make_unique<DepthMap>();
83 depth_map->Read(GetDepthMapPath(image_idx));
84 if (depth_map->GetWidth() != width || depth_map->GetHeight() != height) {
85 depth_map->Downsize(width, height);
86 }
87 depth_maps_[image_idx] = std::move(depth_map);
88
89 // Read and rescale normal map
90 auto normal_map = std::make_unique<NormalMap>();
91 normal_map->Read(GetNormalMapPath(image_idx));
92 if (normal_map->GetWidth() != width || normal_map->GetHeight() != height) {
93 normal_map->Downsize(width, height);
94 }
95 normal_maps_[image_idx] = std::move(normal_map);
96 };
97
98 const int num_threads = GetEffectiveNumThreads(options_.num_threads);
99 ThreadPool thread_pool(num_threads);
100 Timer timer;
101 timer.Start();
102
103 LOG(INFO) << StringPrintf("Loading workspace data with %d threads...",
104 num_threads);
105 for (size_t i = 0; i < image_names.size(); ++i) {
106 const int image_idx = model_.GetImageIdx(image_names[i]);
107 if (HasBitmap(image_idx) && HasDepthMap(image_idx)) {
108 thread_pool.AddTask(LoadWorkspaceData, image_idx);
109 } else {
110 LOG(WARNING) << StringPrintf(
111 "Ignoring image %s, because input does not exist.",
112 image_names[i].c_str());
113 }
114 }
115 thread_pool.Wait();
116 timer.PrintMinutes();
117}
118
119const Bitmap& Workspace::GetBitmap(const int image_idx) {

Callers 8

BM_GlobalPositioningFunction · 0.45
RunMethod · 0.45
TESTFunction · 0.45
RunMethod · 0.45
TEST_PFunction · 0.45
TESTFunction · 0.45

Calls 15

GetEffectiveNumThreadsFunction · 0.85
StringPrintfFunction · 0.85
sizeMethod · 0.80
GetImageIdxMethod · 0.80
AddTaskMethod · 0.80
PrintMinutesMethod · 0.80
GetWidthMethod · 0.45
GetHeightMethod · 0.45
ReadMethod · 0.45
WidthMethod · 0.45
HeightMethod · 0.45
RescaleMethod · 0.45

Tested by 5

TESTFunction · 0.36
TEST_PFunction · 0.36
TESTFunction · 0.36