Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
22 changes: 15 additions & 7 deletions src/colmap/controllers/feature_extraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ class FeatureWriterThread : public Thread {
image_data.camera.has_prior_focal_length ? " (Prior)" : "");
LOG(INFO) << StringPrintf(" Features: %d",
image_data.keypoints.size());
if (image_data.mask.Data()) {
LOG(INFO) << " Mask: Yes";
}

DatabaseTransaction database_transaction(database_);

Expand Down Expand Up @@ -329,13 +332,18 @@ class FeatureExtractorController : public Thread {

std::shared_ptr<Bitmap> camera_mask;
if (!reader_options_.camera_mask_path.empty()) {
camera_mask = std::make_shared<Bitmap>();
if (!camera_mask->Read(reader_options_.camera_mask_path,
/*as_rgb*/ false)) {
LOG(ERROR) << "Cannot read camera mask file: "
<< reader_options_.camera_mask_path
<< ". No mask is going to be used.";
camera_mask.reset();
if (ExistsFile(reader_options_.camera_mask_path)) {
camera_mask = std::make_shared<Bitmap>();
if (!camera_mask->Read(reader_options_.camera_mask_path,
/*as_rgb*/ false)) {
LOG(ERROR) << "Failed to read invalid mask file at: "
<< reader_options_.camera_mask_path
<< ". No mask is going to be used.";
camera_mask.reset();
}
} else {
LOG(ERROR) << "Mask at " << reader_options_.camera_mask_path
<< " does not exist.";
}
}

Expand Down
13 changes: 10 additions & 3 deletions src/colmap/controllers/image_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ ImageReader::ImageReader(const ImageReaderOptions& options, Database* database)
// Ensure trailing slash, so that we can build the correct image name.
options_.image_path =
EnsureTrailingSlash(StringReplace(options_.image_path, "\\", "/"));
options_.mask_path =
EnsureTrailingSlash(StringReplace(options_.mask_path, "\\", "/"));
if (!options_.mask_path.empty()) {
options_.mask_path =
EnsureTrailingSlash(StringReplace(options_.mask_path, "\\", "/"));
}

// Get a list of all files in the image path, sorted by image name.
if (options_.image_list.empty()) {
Expand Down Expand Up @@ -146,7 +148,12 @@ ImageReader::Status ImageReader::Next(Camera* camera,
if (mask && !options_.mask_path.empty()) {
const std::string mask_path =
JoinPaths(options_.mask_path, image->Name() + ".png");
if (ExistsFile(mask_path) && !mask->Read(mask_path, false)) {
if (!ExistsFile(mask_path)) {
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;
return Status::MASK_ERROR;
}
}
Expand Down
Loading