Skip to content

Commit f44c2db

Browse files
araistrickpvl-bot
authored andcommitted
Remove policy_registry from new camera_trajectories file, pass in string mode instead, disabled POI-following by default for all scenes
1 parent d100fec commit f44c2db

File tree

6 files changed

+29
-27
lines changed

6 files changed

+29
-27
lines changed

docs/ConfiguringCameras.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ Indoor video, dynamic & interesting camera motion:
3434

3535
```bash
3636
python -m infinigen.datagen.manage_jobs --output_folder outputs/video_dynamic_indoor --num_scenes 30 \
37-
-configs singleroom rrt_cam_indoors.gin \
38-
-pipeline_configs local_256GB.gin indoor_background_configs.gin monocular_video \
39-
-overrides compute_base_views.min_candidates_ratio=2 compose_indoors.terrain_enabled=False compose_indoors.restrict_single_supported_roomtype=True \
40-
-pipeline_overrides get_cmd.driver_script='infinigen_examples.generate_indoors' iterate_scene_tasks.frame_range=[1,300] \
41-
-warmup_sec 2000 --cleanup big_files --overwrite
37+
--configs singleroom.gin rrt_cam_indoors.gin \
38+
--pipeline_configs local_256GB.gin indoor_background_configs.gin monocular_video \
39+
--overrides compute_base_views.min_candidates_ratio=2 compose_indoors.terrain_enabled=False compose_indoors.restrict_single_supported_roomtype=True \
40+
--pipeline_overrides get_cmd.driver_script='infinigen_examples.generate_indoors' iterate_scene_tasks.frame_range=[1,200] \
41+
--warmup_sec 2000 --cleanup big_files --overwrite
4242
```
4343

4444
In order to create dynamic and varied camera motion, use the `rrt_cam_indoors.gin` and `rrt_cam_nature.gin` configuration files for indoor scenes and nature scenes respectively. This will animate cameras using the animation policy found in [rrt.py](../infinigen/core/util/rrt.py/.py). There are three customizable components used to create such a motion:

infinigen/core/placement/camera_trajectories.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# This source code is licensed under the BSD 3-Clause license found in the LICENSE file in the root directory of this source tree.
33

44
# Authors:
5-
# - Dylan Li: primary author
5+
# - Alexander Raistrick: original placement/camera.py: camera pose proposal, camera random walk animations
6+
# - Dylan Li: refactored to camera_trajectories.py to support RRT option
67
# - Sumanth Maddirala: base view selection
78

89
import logging
@@ -12,7 +13,6 @@
1213
import bpy
1314
import gin
1415
import numpy as np
15-
from numpy.random import uniform as U
1616
from tqdm import tqdm
1717

1818
from infinigen.core.placement.camera import configure_cameras, terrain_camera_query
@@ -31,7 +31,7 @@ def compute_poses(
3131
scene_preprocessed: dict,
3232
init_bounding_box: tuple[np.array, np.array] = None,
3333
init_surfaces: list[bpy.types.Object] = None,
34-
terrain_mesh = None,
34+
terrain_mesh=None,
3535
min_candidates_ratio=5,
3636
min_base_views_ratio=10,
3737
):
@@ -78,8 +78,7 @@ def compute_trajectories(
7878
camera_selection_ratio=None,
7979
min_candidates_ratio=5,
8080
pois=None,
81-
follow_poi_chance=0.0,
82-
policy_registry=None,
81+
animation_mode: str = "random_walk",
8382
validate_pose_func=None,
8483
):
8584
n_cams = len(cam_rigs)
@@ -123,19 +122,22 @@ def compute_trajectories(
123122
if not anim_valid_pose_func(cam):
124123
continue
125124

126-
if policy_registry is None:
127-
if U() < follow_poi_chance and pois is not None and len(pois):
125+
match animation_mode:
126+
case "random_walk":
127+
with gin.config_scope("cam"):
128+
policy = animation_policy.AnimPolicyRandomWalkLookaround()
129+
case "random_walk_forward":
130+
with gin.config_scope("cam"):
131+
policy = animation_policy.AnimPolicyRandomForwardWalk()
132+
case "follow_poi":
128133
policy = animation_policy.AnimPolicyFollowObject(
129134
target_obj=cam, pois=pois, bvh=scene_preprocessed["scene_bvh"]
130135
)
131-
else:
132-
with gin.config_scope("cam"):
133-
policy = animation_policy.AnimPolicyRandomWalkLookaround()
134-
else:
135-
match policy_registry:
136-
case "rrt":
137-
with gin.config_scope("rrt"):
138-
policy = AnimPolicyRRT(obj_groups=obj_groups)
136+
case "rrt":
137+
with gin.config_scope("rrt"):
138+
policy = AnimPolicyRRT(obj_groups=obj_groups)
139+
case _:
140+
raise ValueError(f"Invalid animation mode: {animation_mode}")
139141

140142
logger.info(f"Computing trajectory using {policy=}")
141143

@@ -215,12 +217,12 @@ def animate_trajectories(
215217
obj_groups=None,
216218
follow_poi_chance=0.0,
217219
pois=None,
218-
policy_registry=None,
220+
animation_mode="random_walk",
219221
validate_pose_func=None,
220222
fatal=True,
221223
):
222224
bpy.context.view_layer.update()
223-
# generate potential trajectories
225+
224226
try:
225227
trajectories = compute_trajectories(
226228
cam_rigs=cam_rigs,
@@ -229,7 +231,7 @@ def animate_trajectories(
229231
obj_groups=obj_groups,
230232
follow_poi_chance=follow_poi_chance,
231233
pois=pois,
232-
policy_registry=policy_registry,
234+
animation_mode=animation_mode,
233235
validate_pose_func=validate_pose_func,
234236
)
235237
except ValueError as err:

infinigen_examples/configs_indoor/rrt_cam_indoors.gin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
compose_indoors.animate_cameras_enabled = True
22

3-
animate_trajectories.policy_registry = "rrt"
3+
animate_trajectories.animation_mode = "rrt"
44
animate_trajectories.validate_pose_func = @rrt/validate_cam_pose_rrt
55
compute_trajectories.min_candidates_ratio = 2
66
compute_poses.min_base_views_ratio = 4

infinigen_examples/configs_nature/extras/rrt_cam_nature.gin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
animate_trajectories.policy_registry = "rrt"
1+
animate_trajectories.animation_mode = "rrt"
22
animate_trajectories.validate_pose_func = @rrt/validate_cam_pose_rrt
33
compute_trajectories.min_candidates_ratio = 2
44
compute_poses.min_base_views_ratio = 4

infinigen_examples/configs_nature/scene_types_fluidsim/simulated_river.gin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include 'infinigen_examples/configs_nature/scene_types/river.gin'
22

33
UniformMesher.enclosed=1
4-
animate_cameras.policy_registry = @cam/AnimPolicyRandomForwardWalk
4+
animate_cameras.animation_mode = "random_forward_walk"
55
cam/AnimPolicyRandomForwardWalk.forward_vec = (0,0,-1)
66
cam/AnimPolicyRandomForwardWalk.speed = 1
77
cam/AnimPolicyRandomForwardWalk.step_range = (5, 10)

infinigen_examples/configs_nature/scene_types_fluidsim/tilted_river.gin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include 'infinigen_examples/configs_nature/scene_types/river.gin'
22

33
UniformMesher.enclosed=1
4-
animate_cameras.policy_registry = @cam/AnimPolicyRandomForwardWalk
4+
animate_cameras.animation_mode = "random_forward_walk"
55
cam/AnimPolicyRandomForwardWalk.forward_vec = (0,0,-1)
66
cam/AnimPolicyRandomForwardWalk.speed = 1
77
cam/AnimPolicyRandomForwardWalk.step_range = (5, 10)

0 commit comments

Comments
 (0)