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

Are Point3D and Image 0 indexed? #264

Closed
Coelhomatias opened this issue Feb 29, 2024 · 2 comments
Closed

Are Point3D and Image 0 indexed? #264

Coelhomatias opened this issue Feb 29, 2024 · 2 comments

Comments

@Coelhomatias
Copy link

This is not an issue and only a question. I see that the id's for most classes are initialized with a big number. Is this because it is possible to have the id be 0? I am asking this because in the current project I am working on there is no id=0 on any of the classes and was wondering if the id will never be 0 or am I just lucky?

@sarlinpe
Copy link
Collaborator

IDs are not indices, they are not ordered and are not guaranteed to be continuous. I think that image and point IDs usually start at 1 but most parts of COLMAP won't complain if they are given a value 0.

@jytime
Copy link

jytime commented Mar 24, 2024

For me it works well if you count image and camera from 0, e.g.,:

fidx=0
camera = pycolmap.Camera(model="SIMPLE_PINHOLE", width=image_size[0], height=image_size[1], params=pycolmap_intri_pinhole, camera_id=fidx, )
image = pycolmap.Image(id=fidx, name=f"image_{fidx}", camera_id=camera.camera_id, cam_from_world=cam_from_world)

reconstruction.add_camera(camera)
reconstruction.add_image(image)

However, if you want to add 3D points manually, they start from 1.

for vidx in valid_idx:         
    reconstruction.add_point3D(points3d[vidx], pycolmap.Track(), np.zeros(3))
(Pdb) reconstruction.points3D[0]
*** KeyError: ''
(Pdb) reconstruction.points3D[1]
Point3D(xyz=[-2.73191, 8.97091, 32.4668], color=[0, 0, 0], error=-1, track=Track(length=2))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants