(cfg)
| 174 | |
| 175 | |
| 176 | def load_data_dict(cfg): |
| 177 | paths = cfg.paths |
| 178 | length, width, height = get_video_lwh(cfg.video_path) |
| 179 | if cfg.static_cam: |
| 180 | R_w2c = torch.eye(3).repeat(length, 1, 1) |
| 181 | else: |
| 182 | traj = torch.load(cfg.paths.slam) |
| 183 | if cfg.use_dpvo: # DPVO |
| 184 | traj_quat = torch.from_numpy(traj[:, [6, 3, 4, 5]]) |
| 185 | R_w2c = quaternion_to_matrix(traj_quat).mT |
| 186 | else: # SimpleVO |
| 187 | R_w2c = torch.from_numpy(traj[:, :3, :3]) |
| 188 | if cfg.f_mm is not None: |
| 189 | K_fullimg = create_camera_sensor(width, height, cfg.f_mm)[2].repeat(length, 1, 1) |
| 190 | else: |
| 191 | K_fullimg = estimate_K(width, height).repeat(length, 1, 1) |
| 192 | |
| 193 | data = { |
| 194 | "length": torch.tensor(length), |
| 195 | "bbx_xys": torch.load(paths.bbx)["bbx_xys"], |
| 196 | "kp2d": torch.load(paths.vitpose), |
| 197 | "K_fullimg": K_fullimg, |
| 198 | "cam_angvel": compute_cam_angvel(R_w2c), |
| 199 | "f_imgseq": torch.load(paths.vit_features), |
| 200 | } |
| 201 | return data |
| 202 | |
| 203 | def save_npz(pred, save_path): |
| 204 | path1, path2, path3 = f'{save_path}'.split('/')[0:3] |
no test coverage detected