camera_utils ¶
Camera trajectory generation utilities for GEN3C 3D cache conditioning.
Functions:¶
fastvideo.pipelines.basic.gen3c.camera_utils.apply_transformation ¶
Apply batch transformation to a matrix.
Source code in fastvideo/pipelines/basic/gen3c/camera_utils.py
fastvideo.pipelines.basic.gen3c.camera_utils.create_horizontal_trajectory ¶
create_horizontal_trajectory(world_to_camera_matrix: Tensor, center_depth: float, positive: bool = True, n_steps: int = 13, distance: float = 0.1, device: str = 'cuda', axis: str = 'x', camera_rotation: str = 'center_facing') -> Tensor
Create a linear camera trajectory along a specified axis.
Source code in fastvideo/pipelines/basic/gen3c/camera_utils.py
fastvideo.pipelines.basic.gen3c.camera_utils.create_spiral_trajectory ¶
create_spiral_trajectory(world_to_camera_matrix: Tensor, center_depth: float, radius_x: float = 0.03, radius_y: float = 0.02, radius_z: float = 0.0, positive: bool = True, camera_rotation: str = 'center_facing', n_steps: int = 13, device: str = 'cuda', start_from_zero: bool = True, num_circles: int = 1) -> Tensor
Create a spiral/circular camera trajectory.
Source code in fastvideo/pipelines/basic/gen3c/camera_utils.py
fastvideo.pipelines.basic.gen3c.camera_utils.generate_camera_trajectory ¶
generate_camera_trajectory(trajectory_type: str, initial_w2c: Tensor, initial_intrinsics: Tensor, num_frames: int, movement_distance: float, camera_rotation: str = 'center_facing', center_depth: float = 1.0, device: str = 'cuda') -> tuple[Tensor, Tensor]
Generate camera trajectory for GEN3C video generation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trajectory_type | str | One of "left", "right", "up", "down", "zoom_in", "zoom_out", "clockwise", "counterclockwise". | required |
initial_w2c | Tensor | Initial world-to-camera matrix (4, 4). | required |
initial_intrinsics | Tensor | Camera intrinsics matrix (3, 3). | required |
num_frames | int | Number of frames in the trajectory. | required |
movement_distance | float | Distance factor for camera movement. | required |
camera_rotation | str | "center_facing", "no_rotation", or "trajectory_aligned". | 'center_facing' |
center_depth | float | Depth of the scene center point. | 1.0 |
device | str | Computation device. | 'cuda' |
Returns:
| Name | Type | Description |
|---|---|---|
generated_w2cs | Tensor | (1, num_frames, 4, 4) world-to-camera matrices. |
generated_intrinsics | Tensor | (1, num_frames, 3, 3) camera intrinsics. |
Source code in fastvideo/pipelines/basic/gen3c/camera_utils.py
fastvideo.pipelines.basic.gen3c.camera_utils.look_at_matrix ¶
look_at_matrix(camera_pos: Tensor, target: Tensor, invert_pos: bool = True) -> Tensor
Create a 4x4 look-at view matrix pointing camera toward target.