Skip to content

Commit

Permalink
Merge branch 'main' into fix/open3d
Browse files Browse the repository at this point in the history
  • Loading branch information
B1ueber2y committed Jan 6, 2025
2 parents 418899f + c6ead3a commit f06b6cd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions docs/tutorials/localization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ Now, to run the localization pipeline with points and lines. As shown above, the
.. code-block:: bash
python runners/7scenes/localization.py --dataset $dataset -s stairs --skip_exists \
--localization.optimize.loss_func TrivialLoss \
--localization.optimize.loss_func TrivialLoss
It is also possible to use the rendered depth with the ``--use_dense_depth`` flag, in which case the 3D line map will be built using LIMAP's Fit&Merge (enable merging by adding ``--merging.do_merging``) utilities instead of triangulation.

.. code-block:: bash
python runners/7scenes/localization.py --dataset $dataset -s stairs --skip_exists \
--use_dense_depth \
--localization.optimize.loss_func TrivialLoss \
--localization.optimize.loss_func TrivialLoss
The runner scripts will also run `hloc <https://github.com/cvg/Hierarchical-Localization/tree/master/hloc/pipelines/7Scenes>`_ for extracting and matching the feature points and for comparing the results. The evaluation result will be printed in terminal after localization is finished. You could also evaluate different result ``.txt`` files using the ``--eval`` flag.
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/B1ueber2y/Hierarchical-Localization.git@f91076b#egg=hloc
-e git+https://github.com/B1ueber2y/Hierarchical-Localization.git@dfe106a#egg=hloc
22 changes: 20 additions & 2 deletions runners/7scenes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,16 @@ def create_reference_sfm(full_model, ref_model, blacklist=None, ext=".bin"):

def scene_coordinates(p2D, R_w2c, t_w2c, depth, camera):
assert len(depth) == len(p2D)
p2D_norm = np.stack(pycolmap.Camera(camera._asdict()).image_to_world(p2D))
pycolmap_camera = pycolmap.Camera(
{
"camera_id": camera.id,
"model": camera.model,
"width": camera.width,
"height": camera.height,
"params": camera.params,
}
)
p2D_norm = pycolmap_camera.cam_from_img(p2D)
p2D_h = np.concatenate([p2D_norm, np.ones_like(p2D_norm[:, :1])], 1)
p3D_c = p2D_h * depth[:, None]
p3D_w = (p3D_c - t_w2c) @ R_w2c
Expand Down Expand Up @@ -109,7 +118,16 @@ def project_to_image(p3D, R, t, camera, eps: float = 1e-4, pad: int = 1):
p3D = (p3D @ R.T) + t
visible = p3D[:, -1] >= eps # keep points in front of the camera
p2D_norm = p3D[:, :-1] / p3D[:, -1:].clip(min=eps)
p2D = np.stack(pycolmap.Camera(camera._asdict()).world_to_image(p2D_norm))
pycolmap_camera = pycolmap.Camera(
{
"camera_id": camera.id,
"model": camera.model,
"width": camera.width,
"height": camera.height,
"params": camera.params,
}
)
p2D = pycolmap_camera.img_from_cam(p2D_norm)
size = np.array([camera.width - pad - 1, camera.height - pad - 1])
valid = np.all((p2D >= pad) & (p2D <= size), -1)
valid &= visible
Expand Down

0 comments on commit f06b6cd

Please sign in to comment.