Skip to content
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

Bugfix for upgrading COLMAP + Adapt to the new pycolmap interface for localization #107

Merged
merged 6 commits into from
Dec 13, 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
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
Loading