8000 Report errors in import_images by sarlinpe · Pull Request #2750 · colmap/colmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Report errors in import_images #2750

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 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 2 additions & 19 deletions src/colmap/controllers/feature_extraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -260,26 +260,9 @@ class FeatureWriterThread : public Thread {
LOG(INFO) << StringPrintf(" Name: %s",
image_data.image.Name().c_str());

if (image_data.status == ImageReader::Status::IMAGE_EXISTS) {
LOG(INFO) << " SKIP: Features for image already extracted.";
} else if (image_data.status == ImageReader::Status::BITMAP_ERROR) {
LOG(ERROR) << "Failed to read image file format.";
} else if (image_data.status ==
ImageReader::Status::CAMERA_SINGLE_DIM_ERROR) {
LOG(ERROR) << "Single camera specified, "
"but images have different dimensions.";
} else if (image_data.status ==
ImageReader::Status::CAMERA_EXIST_DIM_ERROR) {
LOG(ERROR) << "Image previously processed, but current image "
"has different dimensions.";
} else if (image_data.status ==
ImageReader::Status::CAMERA_PARAM_ERROR) {
LOG(ERROR) << "Camera has invalid parameters.";
} else if (image_data.status == ImageReader::Status::FAILURE) {
LOG(ERROR) << "Failed to extract features.";
}

if (image_data.status != ImageReader::Status::SUCCESS) {
LOG(ERROR) << image_data.image.Name() << " "
<< ImageReader::StatusToString(image_data.status);
continue;
}

Expand Down
28 changes: 26 additions & 2 deletions src/colmap/controllers/image_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ ImageReader::Status ImageReader::Next(Camera* camera,
const std::string mask_path =
JoinPaths(options_.mask_path, image->Name() + ".png");
if (ExistsFile(mask_path) && !mask->Read(mask_path, false)) {
// NOTE: Maybe introduce a separate error type MASK_ERROR?
return Status::BITMAP_ERROR;
return Status::MASK_ERROR;
}
}

Expand Down Expand Up @@ -271,4 +270,29 @@ size_t ImageReader::NextIndex() const { return image_index_; }

size_t ImageReader::NumImages() const { return options_.image_list.size(); }

std::string ImageReader::StatusToString(const ImageReader::Status status) {
switch (status) {
case ImageReader::Status::SUCCESS:
return "SUCCESS";
case ImageReader::Status::FAILURE:
return "FAILURE: Failed to process the image.";
case ImageReader::Status::IMAGE_EXISTS:
return "IMAGE_EXISTS: Features for image were already extracted.";
case ImageReader::Status::BITMAP_ERROR:
return "BITMAP_ERROR: Failed to read the image file format.";
case ImageReader::Status::MASK_ERROR:
return "MASK_ERROR: Failed to read the mask file.";
case ImageReader::Status::CAMERA_SINGLE_DIM_ERROR:
return "CAMERA_SINGLE_DIM_ERROR: Single camera specified, but images "
"have different dimensions.";
case ImageReader::Status::CAMERA_EXIST_DIM_ERROR:
return "CAMERA_EXIST_DIM_ERROR: Image previously processed, but current "
"image has different dimensions.";
case ImageReader::Status::CAMERA_PARAM_ERROR:
return "CAMERA_PARAM_ERROR: Camera has invalid parameters.";
default:
return "Unknown";
}
}

} // namespace colmap
3 changes: 3 additions & 0 deletions src/colmap/controllers/image_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class ImageReader {
SUCCESS,
IMAGE_EXISTS,
BITMAP_ERROR,
MASK_ERROR,
CAMERA_SINGLE_DIM_ERROR,
CAMERA_EXIST_DIM_ERROR,
CAMERA_PARAM_ERROR
Expand All @@ -116,6 +117,8 @@ class ImageReader {
size_t NextIndex() const;
size_t NumImages() const;

static std::string StatusToString(Status status);

private:
// Image reader options.
ImageReaderOptions options_;
Expand Down
6 changes: 4 additions & 2 deletions src/pycolmap/pipeline/images.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ void ImportImages(const std::string& database_path,
Image image;
PosePrior pose_prior;
Bitmap bitmap;
if (image_reader.Next(&camera, &image, &pose_prior, &bitmap, nullptr) !=
ImageReader::Status::SUCCESS) {
const ImageReader::Status status =
image_reader.Next(&camera, &image, &pose_prior, &bitmap, nullptr);
if (status != ImageReader::Status::SUCCESS) {
LOG(ERROR) << image.Name() << " " << ImageReader::StatusToString(status);
continue;
}
DatabaseTransaction database_transaction(&database);
Expand Down
Loading
0