cvg / Hierarchical-Localization

Visual localization made easy with hloc
Apache License 2.0
2.96k stars 551 forks source link

'pycolmap.Image' object has no attribute 'transform_to_image' #367

Closed oxyhexagen closed 4 months ago

oxyhexagen commented 4 months ago

This issue arises at the last line of the sfm pipeline visualization.visualize_sfm_2d(model, images, color_by="depth", n=5)

Traceback (most recent call last):
  File "D:\path2\Hierarchical-Localization\test_pipeline.py", line 47, in <module>
    visualization.visualize_sfm_2d(model, images, color_by="depth", n=5)
  File "D:\path2\Hierarchical-Localization\hloc\visualization.py", line 49, in visualize_sfm_2d
    [
  File "D:\path2\Hierarchical-Localization\hloc\visualization.py", line 50, in <listcomp>
    image.transform_to_image(reconstruction.points3D[j].xyz)[-1]
AttributeError: 'pycolmap.Image' object has no attribute 'transform_to_image'

https://github.com/cvg/Hierarchical-Localization/blob/936040e8d67244cc6c8c9d1667701f3ce87bf075/hloc/visualization.py#L48 I couldn't find this function anywhere. search

And referenced another issue #357 but I'm not sure if my implementation is correct:

z = np.array(
    [
        # image.transform_to_image(reconstruction.points3D[j].xyz)[-1]
        (image.cam_from_world.rotation.matrix() @ reconstruction.points3D[j].xyz + image.cam_from_world.translation)[-1]
        for j in p3ids
    ]
)

Figure_2

sarlinpe commented 4 months ago

Thank you for reporting this, I just fixed it in https://github.com/cvg/Hierarchical-Localization/commit/0eee565379159d1377bdf39129a8239c42d1b4b1.

oxyhexagen commented 4 months ago

Thanks for the quick fix.