MCPcopy Create free account
hub / github.com/IRMVLab/SemGauss-SLAM / transform_to_frame

Function transform_to_frame

utils/slam_helpers.py:111–146  ·  view source on GitHub ↗

Function to transform Isotropic Gaussians from world frame to camera frame. Args: params: dict of parameters time_idx: time index to transform to gaussians_grad: enable gradients for Gaussians camera_grad: enable gradients for camera pose Return

(params, time_idx, gaussians_grad, camera_grad)

Source from the content-addressed store, hash-verified

109 return depth_silhouette
110
111def transform_to_frame(params, time_idx, gaussians_grad, camera_grad):
112 """
113 Function to transform Isotropic Gaussians from world frame to camera frame.
114
115 Args:
116 params: dict of parameters
117 time_idx: time index to transform to
118 gaussians_grad: enable gradients for Gaussians
119 camera_grad: enable gradients for camera pose
120
121 Returns:
122 transformed_pts: Transformed Centers of Gaussians
123 """
124 # Get Frame Camera Pose
125 if camera_grad:
126 cam_rot = F.normalize(params['cam_unnorm_rots'][..., time_idx])
127 cam_tran = params['cam_trans'][..., time_idx]
128 else:
129 cam_rot = F.normalize(params['cam_unnorm_rots'][..., time_idx].detach())
130 cam_tran = params['cam_trans'][..., time_idx].detach()
131 rel_w2c = torch.eye(4).cuda().float()
132 rel_w2c[:3, :3] = build_rotation(cam_rot)
133 rel_w2c[:3, 3] = cam_tran
134
135 # Get Centers and norm Rots of Gaussians in World Frame
136 if gaussians_grad:
137 pts = params['means3D']
138 else:
139 pts = params['means3D'].detach()
140
141 # Transform Centers and Unnorm Rots of Gaussians to Camera Frame
142 pts_ones = torch.ones(pts.shape[0], 1).cuda().float()
143 pts4 = torch.cat((pts, pts_ones), dim=1)
144 transformed_pts = (rel_w2c @ pts4.T).T[:, :3]
145
146 return transformed_pts

Callers 4

get_lossFunction · 0.90
add_new_gaussiansFunction · 0.90
report_progressFunction · 0.90
evalFunction · 0.90

Calls 1

build_rotationFunction · 0.90

Tested by

no test coverage detected