princeton-vl / infinigen

Infinite Photorealistic Worlds using Procedural Generation
https://infinigen.org
BSD 3-Clause "New" or "Revised" License
5.14k stars 430 forks source link

Multiple camera rigs triggers assertion error in get_camera_ids() #229

Open bugByteMe opened 2 months ago

bugByteMe commented 2 months ago

Describe the bug

Cameras are not correctly organized when camera rigs are set more than one, which triggers assertion error.

I have added the following debug code for get_camera_ids() in camera.py

def get_cameras_ids() -> list[tuple]:

    res = []
    col = bpy.data.collections[CAMERA_RIGS_DIRNAME]
    print(col.objects)
    for i, root in enumerate(col.objects):
        print("[root] i = ", i)
        print("       name = ", root.name)
        print("        loc = ", root.location)
        for j, subcam in enumerate(root.children):
            print("  [child] j = ", j)
            print("          name = ", subcam.name)
            print("           loc = ", subcam.location)
            assert subcam.name == camera_name(i, j)
            res.append((i, j))

    return res

and found incorrect camera organization which triggers assertion error. (shown below)

Steps to Reproduce

Override the configs with

camera.spawn_camera_rigs.n_camera_rigs = 4

camera.spawn_camera_rigs.camera_rig_config = [
    {'loc': (0, 0, 0), 'rot_euler': (0, 0, 0)}
]

change monocular_video.gin to:

iterate_scene_tasks.frame_range = [1, 2]
iterate_scene_tasks.view_block_size = 2
iterate_scene_tasks.cam_block_size = 2
iterate_scene_tasks.cam_id_ranges = [4, 1]

Call get_camera_ids() after pose_cameras. I actually found this bug in rendering stage. But for quicker reproduce, call this function in generate_scene().

    p.run_stage(
        'pose_cameras', 
        lambda: cam_util.configure_cameras(camera_rigs, bbox, scene_preprocessed), 
        use_chance=False
    )
    camera_ids=cam_util.get_cameras_ids()

This will triggers assertion error, with the following debug info I print:

[root] i =  0
       name =  CameraRigs/0
        loc =  <Vector (-51.2120, -26.3052, -15.5964)>
  [child] j =  0
          name =  CameraRigs/0/0
           loc =  <Vector (0.0000, 0.0000, 0.0000)>
[root] i =  1
       name =  CameraRigs/0/0
        loc =  <Vector (0.0000, 0.0000, 0.0000)>
[root] i =  2
       name =  CameraRigs/1
        loc =  <Vector (70.1523, 20.7909, -15.3666)>
  [child] j =  0
          name =  CameraRigs/1/0
           loc =  <Vector (0.0000, 0.0000, 0.0000)>

This seems not a correct organization of a camera. Camera names are disordered and some camera rig has no children.

What version of the code were you using?

Tell us the commit & commit hash from git log

commit 18be26c9b4a7b375442d23569b737d8e2169e372 (HEAD -> main, origin/main, origin/HEAD)
Author: Zeyu Ma <31351547+mazeyu@users.noreply.github.com>
Date:   Tue Apr 2 11:16:34 2024 -0700

    Bugfix v1.2.5 - Terrain bugfix for multi-task command; Terrain.bounds and Terrain.populated_bounds parameter

    * fix reinitializing terrain

    * add bounds and populated_bounds for terrain

What command did you run?

python -m infinigen.datagen.manage_jobs --output_folder /home/guojiarui/gen/under_water_syn_monot2 --num_scenes 1 \
--configs under_water.gin simple.gin base_simple.gin \
--pipeline_configs local_32GB.gin monocular_video.gin \
--pipeline_overrides LocalScheduleHandler.use_gpu=False \
-p compose_scene.max_fish_schools=5 compose_scene.animate_cameras_enabled=False

in which base_simple.gin overrides:

camera.spawn_camera_rigs.n_camera_rigs = 4

camera.spawn_camera_rigs.camera_rig_config = [
    {'loc': (0, 0, 0), 'rot_euler': (0, 0, 0)}
]

monocular_video.gin has been changed to:

iterate_scene_tasks.frame_range = [1, 2]
iterate_scene_tasks.view_block_size = 2
iterate_scene_tasks.cam_block_size = 2
iterate_scene_tasks.cam_id_ranges = [4, 1]

What are your FULL output logs?

Provide the FULL output logs from your command as a txt file. coarse_error.txt

If this is your first time running Infinigen, what are the full install logs?**

Run pip install -vv -e . > logs.txt 2>&1 and send logs.txt as an attachment.

Not first time.

Platform

Additional context

Add any other context about the problem here.

araistrick commented 1 month ago

Hello, apologies for the issue, i will patch it ASAP. In the meantime I believe you can just remove this assert.