Spaces:
Running
on
Zero
Running
on
Zero
Update trellis/utils/render_utils.py
Browse files
trellis/utils/render_utils.py
CHANGED
@@ -31,13 +31,7 @@ def yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitchs, rs, fovs):
|
|
31 |
torch.sin(pitch),
|
32 |
]).cuda() * r
|
33 |
extr = utils3d.torch.extrinsics_look_at(orig, torch.tensor([0, 0, 0]).float().cuda(), torch.tensor([0, 0, 1]).float().cuda())
|
34 |
-
|
35 |
-
focal_length = 1.0 / (2.0 * torch.tan(fov / 2.0))
|
36 |
-
intr = torch.tensor([
|
37 |
-
[focal_length, 0, 0.5],
|
38 |
-
[0, focal_length, 0.5],
|
39 |
-
[0, 0, 1]
|
40 |
-
], dtype=torch.float32, device='cuda')
|
41 |
extrinsics.append(extr)
|
42 |
intrinsics.append(intr)
|
43 |
if not is_list:
|
@@ -94,10 +88,9 @@ def render_frames(sample, extrinsics, intrinsics, options={}, colors_overwrite=N
|
|
94 |
|
95 |
|
96 |
def render_video(sample, resolution=512, bg_color=(0, 0, 0), num_frames=300, r=2, fov=40, **kwargs):
|
97 |
-
#
|
98 |
-
|
99 |
-
|
100 |
-
pitch = 0.25 + 0.5 * torch.sin(torch.linspace(0, 2 * 3.1415, num_frames))
|
101 |
yaws = yaws.tolist()
|
102 |
pitch = pitch.tolist()
|
103 |
extrinsics, intrinsics = yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitch, r, fov)
|
|
|
31 |
torch.sin(pitch),
|
32 |
]).cuda() * r
|
33 |
extr = utils3d.torch.extrinsics_look_at(orig, torch.tensor([0, 0, 0]).float().cuda(), torch.tensor([0, 0, 1]).float().cuda())
|
34 |
+
intr = utils3d.torch.intrinsics_from_fov(fov, fov, fov, fov, 1.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
extrinsics.append(extr)
|
36 |
intrinsics.append(intr)
|
37 |
if not is_list:
|
|
|
88 |
|
89 |
|
90 |
def render_video(sample, resolution=512, bg_color=(0, 0, 0), num_frames=300, r=2, fov=40, **kwargs):
|
91 |
+
# Isometric-like camera angle with Y-axis only rotation
|
92 |
+
yaws = torch.linspace(0, 2 * 3.1415, num_frames) # Full rotation around Y-axis
|
93 |
+
pitch = torch.tensor([20.0 * 3.1415 / 180.0] * num_frames) # Fixed pitch at 20 degrees (isometric-like)
|
|
|
94 |
yaws = yaws.tolist()
|
95 |
pitch = pitch.tolist()
|
96 |
extrinsics, intrinsics = yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitch, r, fov)
|