Skip to content

Commit

Permalink
Add camera parameters sampling needed for live3d: fov, principal poin…
Browse files Browse the repository at this point in the history
…t, camera radius, camera roll.
  • Loading branch information
YanniZhangYZ committed Oct 11, 2023
1 parent 55040d2 commit c811e35
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eg3d/camera_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Live3DCameraPoseSampler:
'''
@staticmethod
def sample(horizontal_mean, vertical_mean, roll_mean_deg = 0, horizontal_stddev=0, vertical_stddev=0, roll_stddev_deg=2, radius_mean=2.7, radius_stddev=0.1, batch_size=1, device='cpu'):
def sample(horizontal_mean, vertical_mean, lookat_position = torch.tensor([0, 0, 0], device='cpu'), roll_mean_deg = 0, horizontal_stddev=0, vertical_stddev=0, roll_stddev_deg=2, radius_mean=2.7, radius_stddev=0.1, batch_size=1, device='cpu'):
h = (torch.rand((batch_size, 1), device=device) * 2 - 1) * horizontal_stddev + horizontal_mean
v = (torch.rand((batch_size, 1), device=device) * 2 - 1) * vertical_stddev + vertical_mean
v = torch.clamp(v, 1e-5, math.pi - 1e-5)
Expand All @@ -161,7 +161,7 @@ def sample(horizontal_mean, vertical_mean, roll_mean_deg = 0, horizontal_stddev=
camera_origins[:, 2:3] = (radius_stddev * torch.randn((batch_size, 1), device=device) + radius_mean) * torch.sin(phi) * torch.sin(math.pi - theta)
camera_origins[:, 1:2] = (radius_stddev * torch.randn((batch_size, 1), device=device) + radius_mean) * torch.cos(phi)

forward_vectors = math_utils.normalize_vecs(-camera_origins)
forward_vectors = math_utils.normalize_vecs(lookat_position -camera_origins)

# Sample roll from a normal distribution with mean 0 and std deviation 2 degrees.
roll_stddev_rad = math.radians(roll_stddev_deg)
Expand Down

0 comments on commit c811e35

Please sign in to comment.