colmap / glomap

GLOMAP - Global Structured-from-Motion Revisited
BSD 3-Clause "New" or "Revised" License
1.3k stars 77 forks source link

Error when running glomap with known intrinsics #17

Closed prajwalchidananda closed 1 month ago

prajwalchidananda commented 1 month ago

When I try to run glomap with known intrinsics, I get an error.

I run the following:

  1. Extraction [Successful]:

    colmap feature_extractor 
    --database_path=colmap.db 
    --image_path=images 
    --image_list_path=image_list/front-forward.txt 
    --ImageReader.mask_path=masks 
    --SiftExtraction.estimate_affine_shape=true 
    --SiftExtraction.domain_size_pooling=true 
    --SiftExtraction.max_image_size 1024 
    --SiftExtraction.use_gpu 1 
    --ImageReader.camera_params "1150.1829440239865,1150.5303670456935,1015.0025765888819,642.95996896837937,-0.039422131833326497,-0.0039337811367714526,-0.0076014014183957779,0.0027881498283923332" 
    --ImageReader.camera_model "OPENCV_FISHEYE" 
    --ImageReader.single_camera 1
  2. Matching [Successful]:

    colmap exhaustive_matcher --database_path colmap.db
  3. Mapping [Unsuccessful]:

    glomap mapper --database_path colmap.db --image_path images --output_path glomap_sparse

    Output:

    Loading Images 199 / 199
    Loading Image Pair 15681 / 15681
    WARNING: Logging before InitGoogleLogging() is written to STDERR
    I0801 03:14:44.972779 34725 colmap_converter.cc:301] Pairs read done. 936 / 15681 are invalid
    I0801 03:14:44.974287 34725 global_mapper.cc:75] Loaded database
    -------------------------------------
    Running preprocessing ...
    -------------------------------------
    I0801 03:14:44.976773 34725 view_graph_manipulation.cc:244] Decompose relative pose for 14745 pairs
    I0801 03:14:44.978384 34725 view_graph_manipulation.cc:294] Decompose relative pose done. 2 pairs are pure rotation
    I0801 03:14:44.978399 34725 timer.cc:87] Elapsed time: 0.00409 [seconds]
    -------------------------------------
    Running view graph calibration ...
    -------------------------------------
    I0801 03:14:44.978415 34725 view_graph_calibration.cc:14] Start ViewGraphCalibrator
    I0801 03:14:44.984500 34725 view_graph_calibration.cc:30] No cameras to optimize
    -------------------------------------
    Running relative pose estimation ...
    -------------------------------------
    I0801 03:14:44.987136 34725 image_undistorter.cc:17] Undistorting images..
    I0801 03:14:45.005755 34725 image_undistorter.cc:43] Image undistortion done
    I0801 03:14:45.006337 34725 relpose_estimation.cc:17] Estimating relative pose for 14745 pairs
    Estimating relative pose: 0%terminate called recursively
    terminate called after throwing an instance of 'std::runtime_error'
    terminate called recursively
    Aborted (core dumped)

Any insights as to why this happens?

prajwalchidananda commented 1 month ago

Interestingly, "SIMPLE_RADIAL" works.

lpanaf commented 1 month ago

Hi, can you maybe share the dataset you used so we can reproduce the error?

ichsan2895 commented 1 month ago

Hello, I also encountered the same error with a fisheye dataset from nerfstudio. Here is the DATASET and existing database at dozer/colmap/database.db

Then run,

glomap mapper \
    --database_path dozer/colmap/database.db \
    --image_path dozer/images \
    --output_path dozer_glomap/
ahojnnes commented 1 month ago

It turns out that poselib does not implement the OPENCV_FISHEYE camera model. It throws an exception, see following code snippet from poselib:

void OpenCVFisheyeCameraModel::project(const std::vector<double> &params, const Eigen::Vector2d &x,
                                       Eigen::Vector2d *xp) {
    throw std::runtime_error("nyi");
}
void OpenCVFisheyeCameraModel::project_with_jac(const std::vector<double> &params, const Eigen::Vector2d &x,
                                                Eigen::Vector2d *xp, Eigen::Matrix2d *jac) {
    throw std::runtime_error("nyi");
}
void OpenCVFisheyeCameraModel::unproject(const std::vector<double> &params, const Eigen::Vector2d &xp,
                                         Eigen::Vector2d *x) {
    throw std::runtime_error("nyi");
}

@vlarsson FYI

vlarsson commented 1 month ago

This should be fixed once https://github.com/PoseLib/PoseLib/pull/104 is merged.

ahojnnes commented 1 month ago

Thanks Viktor, that's great.

vlarsson commented 1 month ago

This is now fixed in PoseLib. There are however some of COLMAPs camera models that are not yet implemented. These will be added once https://github.com/PoseLib/PoseLib/tree/camera_models is finished.