Skip to content

Commit

Permalink
Bugfix for upgrading COLMAP + Adapt to the new pycolmap interface for…
Browse files Browse the repository at this point in the history
… localization (#107)
  • Loading branch information
B1ueber2y authored Dec 13, 2024
1 parent 9048e7e commit dfc4fc5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion limap/base/bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ void bind_line_linker(py::module &m) {

void bind_camera(py::module &m) {
// TODO: use pycolmap
py::enum_<colmap::CameraModelId> PyCameraModelId(m, "CameraModelId");
py::enum_<colmap::CameraModelId> PyCameraModelId(m, "CameraModelId",
py::module_local());
PyCameraModelId.value("INVALID", colmap::CameraModelId::kInvalid);
PyCameraModelId.value("SIMPLE_PINHOLE",
colmap::CameraModelId::kSimplePinhole);
Expand Down
8 changes: 4 additions & 4 deletions limap/estimators/absolute_pose/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def pl_estimate_absolute_pose(
campose (:class:`limap.base.CameraPose`, optional): \
Initial camera pose, only useful for pose refinement \
(when ``cfg["ransac"]["method"]`` is :py:obj:`None`)
inliers_line (list[int], optional): \
Indices of line inliers, only useful for pose refinement
inliers_point (list[int], optional): \
Indices of point inliers, only useful for pose refinement
inliers_line (:class:`np.array`, optional): \
Boolean mask of line inliers, only useful for pose refinement
inliers_point (:class:`np.array`, optional): \
Boolean mask of point inliers, only useful for pose refinement
jointloc_cfg (dict, optional): Config for joint optimization, \
fields refer to :class:`limap.optimize.LineLocConfig`, \
pass :py:obj:`None` for default
Expand Down
2 changes: 1 addition & 1 deletion limap/estimators/absolute_pose/joint_pose_estimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ JointPoseEstimator::JointPoseEstimator(
l2ds_ = &l2ds;
p3ds_ = &p3ds;
p2ds_ = &p2ds;
cam_ = Camera(cam.K());
cam_ = Camera("PINHOLE", cam.K());
num_data_ = p3ds.size() + l3d_ids.size();

if (loc_config_.cost_function == E3DLineLineDist2 ||
Expand Down
8 changes: 4 additions & 4 deletions limap/optimize/hybrid_localization/hybrid_localization.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class LineLocEngine {
CHECK_EQ(l3ds.size(), l2ds.size());
this->l3ds = l3ds;
this->l2ds = l2ds;
this->cam = Camera(K);
this->cam = Camera("PINHOLE", K);
this->campose = CameraPose(R, T);
}
void Initialize(const std::vector<Line3d> &l3ds,
Expand All @@ -60,7 +60,7 @@ class LineLocEngine {
K(1, 1) = kvec(1);
K(0, 2) = kvec(2);
K(1, 2) = kvec(3);
this->cam = Camera(K);
this->cam = Camera("PINHOLE", K);
this->campose = CameraPose(qvec, tvec);
}
void SetUp();
Expand Down Expand Up @@ -103,7 +103,7 @@ class JointLocEngine : public LineLocEngine {
this->p2ds = p2ds;
this->l3ds = l3ds;
this->l2ds = l2ds;
this->cam = Camera(K);
this->cam = Camera("PINHOLE", K);
this->campose = CameraPose(R, T);
}
void Initialize(const std::vector<Line3d> &l3ds,
Expand All @@ -121,7 +121,7 @@ class JointLocEngine : public LineLocEngine {
K(1, 1) = kvec(1);
K(0, 2) = kvec(2);
K(1, 2) = kvec(3);
this->cam = Camera(K);
this->cam = Camera("PINHOLE", K);
this->campose = CameraPose(qvec, tvec);
}
};
Expand Down
2 changes: 1 addition & 1 deletion limap/runners/hybrid_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_hloc_keypoints_from_log(
p2ds = logs["loc"][query_img_name]["keypoints_query"]
p3d_ids = logs["loc"][query_img_name]["points3D_ids"]
p3ds = [ref_sfm.points3D[j].xyz for j in p3d_ids]
inliers = logs["loc"][query_img_name]["PnP_ret"]["inliers"]
inliers = logs["loc"][query_img_name]["PnP_ret"]["inlier_mask"]

p2ds, p3ds = np.array(p2ds), np.array(p3ds)
if resize_scales is not None and query_img_name in resize_scales:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ clang-format==19.1.0
pytlsd@git+https://github.com/iago-suarez/pytlsd.git@37ac583
deeplsd@git+https://github.com/cvg/DeepLSD.git@88c589d
gluestick@git+https://github.com/cvg/GlueStick.git@0f28efd
-e git+https://github.com/cvg/Hierarchical-Localization.git@abb2520#egg=hloc
-e git+https://github.com/B1ueber2y/Hierarchical-Localization.git@1d14d71#egg=hloc

0 comments on commit dfc4fc5

Please sign in to comment.