MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / get_camera_from_tensor

Function get_camera_from_tensor

utils/pose_utils.py:57–84  ·  view source on GitHub ↗

Convert quaternion and translation to transformation matrix.

(inputs)

Source from the content-addressed store, hash-verified

55 return rot
56
57def get_camera_from_tensor(inputs):
58 """
59 Convert quaternion and translation to transformation matrix.
60
61 """
62 if not isinstance(inputs, torch.Tensor):
63 inputs = torch.tensor(inputs).cuda()
64
65 N = len(inputs.shape)
66 if N == 1:
67 inputs = inputs.unsqueeze(0)
68 # quad, T = inputs[:, :4], inputs[:, 4:]
69 # # normalize quad
70 # quad = F.normalize(quad)
71 # R = quad2rotation(quad)
72 # RT = torch.cat([R, T[:, :, None]], 2)
73 # # Add homogenous row
74 # homogenous_row = torch.tensor([0, 0, 0, 1]).cuda()
75 # RT = torch.cat([RT, homogenous_row[None, None, :].repeat(N, 1, 1)], 1)
76 # if N == 1:
77 # RT = RT[0]
78 # return RT
79
80 quad, T = inputs[:, :4], inputs[:, 4:]
81 w2c = torch.eye(4).to(inputs).float()
82 w2c[:3, :3] = quad2rotation(quad)
83 w2c[:3, 3] = T
84 return w2c
85
86def quadmultiply(q1, q2):
87 """

Callers 2

save_poseFunction · 0.90
renderFunction · 0.90

Calls 1

quad2rotationFunction · 0.85

Tested by

no test coverage detected