Skip to content

colmap_to_json KeyError #3759

Description

@stevenre3d

In colmap_to_json, on this line:

if image_rename_map is not None:
            name = image_rename_map[name]

the image_rename_map Dict keys look like 'images/'+name, but we're trying to index it using just name, which results in a KeyError.

I ran into this because I built a colmap model that uses a cube rig. Each face of the cube is its own camera. So the images hierachy looks like:

rig1/front/imageN.jpg
rig1/back/imageN.jpg
rig1/left/imageN.jpg
rig1/right/imageN.jpg
rig1/up/imageN.jpg
rig1/down/imageN.jpg

for my N frames. When importing to ns, the image hierarchy gets flattened and numbered as frame_#.jpg, with the key being 'images/rig1/front/imageN.jpg'. Then when we go to use the dict, we try to look up using the key 'rig1/front/imageN.jpg' which results in the KeyError.

I don't see this when my images aren't already in a nested hierarchy, so maybe there is a separate path further up the callstack that is creating the bad keys.

Steps to reproduce the behavior:

  1. Create a colmap model with a rig that has multiple cameras
  2. Use the folder-per-camera option
  3. Copy the trained colmap files into {PROCESSED_DATA_DIR}
  4. Use ns-process-data images --data {DATA_PATH} --output-dir {PROCESSED_DATA_DIR} --skip-colmap to import the images, rename them, downsample them, and attempt to generate the transforms.json

Expected Behavior:
No KeyError. Image rename mapping works. json is created without issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions