8000 Allow png mask without double extension by MotivaCG · Pull Request #3284 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow png mask without double extension #3284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ae9061b
Fix comment in ExistsFile
MotivaCG Apr 25, 2025
b9e08bd
Allow .png masks without double extension (keeping old behaviour as d…
MotivaCG Apr 25, 2025
85e5a2b
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
MotivaCG May 20, 2025
daaa5ae
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
MotivaCG May 22, 2025
519dfc3
Update src/colmap/controllers/image_reader.cc
ahojnnes May 28, 2025
78a1fce
Update src/colmap/mvs/fusion.cc
ahojnnes May 28, 2025
96a40db
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
ahojnnes May 28, 2025
e873d1d
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
ahojnnes Jun 1, 2025
d562a30
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
MotivaCG Jun 1, 2025
9ca7807
Merge branch 'colmap:main' into AllowPngMaskWithoutDoubleExtension
MotivaCG Jun 1, 2025
4ef52fd
Fix: Allow mask_path reassignment
MotivaCG Jun 2, 2025
52c922c
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
ahojnnes Jun 2, 2025
3da4245
Code format: remove extra spaces
MotivaCG Jun 2, 2025
e71a539
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
MotivaCG Jun 2, 2025
10c7df6
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
MotivaCG Jun 4, 2025
4bb10c9
More code formating
MotivaCG Jun 5, 2025
ace9691
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
ahojnnes Jun 5, 2025
b2be584
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
ahojnnes Jun 6, 2025
a5ae7d6
Fix clang check issues
MotivaCG Jun 9, 2025
5595560
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
MotivaCG Jun 11, 2025
141af24
Merge branch 'main' into AllowPngMaskWithoutDoubleExtension
ahojnnes Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/colmap/controllers/image_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,22 @@ ImageReader::Status ImageReader::Next(Rig* rig,
//////////////////////////////////////////////////////////////////////////////

if (mask && !options_.mask_path.empty()) {
const std::string mask_path =
std::string mask_path =
JoinPaths(options_.mask_path, image->Name() + ".png");
if (!ExistsFile(mask_path)) {
LOG(ERROR) << "Mask at " << mask_path << " does not exist.";
return Status::MASK_ERROR;
bool exists_mask = false;
if (HasFileExtension(image->Name(), ".png")) {
std::string alt_mask_path =
JoinPaths(options_.mask_path, image->Name());
if (ExistsFile(alt_mask_path)) {
mask_path = std::move(alt_mask_path);
exists_mask = true;
}
}
if (!exists_mask) {
LOG(ERROR) << "Mask at " << mask_path << " does not exist.";
return Status::MASK_ERROR;
}
}
if (!mask->Read(mask_path, false)) {
LOG(ERROR) << "Failed to read invalid mask file at: " << mask_path;
Expand Down
10 changes: 7 additions & 3 deletions src/colmap/mvs/fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,13 @@ void StereoFusion::InitFusedPixelMask(int image_idx,
size_t height) {
Bitmap mask;
Mat<char>& fused_pixel_mask = fused_pixel_masks_.at(image_idx);
const std::string mask_path =
JoinPaths(options_.mask_path,
workspace_->GetModel().GetImageName(image_idx) + ".png");
const std::string mask_image_name =
workspace_->GetModel().GetImageName(image_idx);
std::string mask_path =
JoinPaths(options_.mask_path, mask_image_name + ".png");
if (!ExistsFile(mask_path) && HasFileExtension(mask_image_name, ".png")) {
mask_path = JoinPaths(options_.mask_path, mask_image_name);
}
fused_pixel_mask = Mat<char>(width, height, 1);
if (!options_.mask_path.empty() && ExistsFile(mask_path) &&
mask.Read(mask_path, false)) {
Expand Down
2 changes: 1 addition & 1 deletion src/colmap/util/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void FileCopy(const std::string& src_path,
const std::string& dst_path,
CopyType type = CopyType::COPY);

// Check if the path points to an existing directory.
// Check if the path points to an existing file.
bool ExistsFile(const std::string& path);

// Check if the path points to an existing directory.
Expand Down
Loading
0