normalize xyz into [-1, 1], and recenter pose
(poses, sc, hwf)
| 156 | return m |
| 157 | |
| 158 | def normalize_recenter_pose(poses, sc, hwf): |
| 159 | ''' normalize xyz into [-1, 1], and recenter pose ''' |
| 160 | target_pose = poses.reshape(poses.shape[0],3,4) |
| 161 | target_pose[:,:3,3] = target_pose[:,:3,3] * sc |
| 162 | |
| 163 | x_norm = target_pose[:,0,3] |
| 164 | y_norm = target_pose[:,1,3] |
| 165 | z_norm = target_pose[:,2,3] |
| 166 | |
| 167 | tpose_ = target_pose+0 |
| 168 | |
| 169 | # find the center of pose |
| 170 | center = np.array([x_norm.mean(), y_norm.mean(), z_norm.mean()]) |
| 171 | bottom = np.reshape([0,0,0,1.], [1,4]) |
| 172 | |
| 173 | # pose avg |
| 174 | vec2 = normalize(tpose_[:, :3, 2].sum(0)) |
| 175 | up = tpose_[:, :3, 1].sum(0) |
| 176 | hwf=np.array(hwf).transpose() |
| 177 | c2w = np.concatenate([viewmatrix(vec2, up, center), hwf], 1) |
| 178 | c2w = np.concatenate([c2w[:3,:4], bottom], -2) |
| 179 | |
| 180 | bottom = np.tile(np.reshape(bottom, [1,1,4]), [tpose_.shape[0],1,1]) |
| 181 | poses = np.concatenate([tpose_[:,:3,:4], bottom], -2) |
| 182 | poses = np.linalg.inv(c2w) @ poses |
| 183 | return poses[:,:3,:].reshape(poses.shape[0],12) |
| 184 | |
| 185 | class SevenScenes(data.Dataset): |
| 186 | def __init__(self, scene, data_path, train, transform=None, |
nothing calls this directly
no test coverage detected