(full_queue_pipeline, queue)
| 288 | |
| 289 | ### Multiple frames |
| 290 | def union2one(full_queue_pipeline, queue): |
| 291 | queue = full_queue_pipeline(queue) |
| 292 | imgs_list = torch.stack([each['img'] for each in queue]) |
| 293 | points_size = [each['points'].data.shape[0] for each in queue] |
| 294 | metas_map = [] |
| 295 | prev_pos = None |
| 296 | prev_angle = None |
| 297 | for i, each in enumerate(queue): |
| 298 | meta = copy.deepcopy(each['img_metas'].data) |
| 299 | meta['points_size'] = points_size |
| 300 | if i == 0: ## Current Frame |
| 301 | meta['prev_bev'] = False |
| 302 | prev_pos = copy.deepcopy(meta['can_bus'][:3]) |
| 303 | prev_angle = copy.deepcopy(meta['can_bus'][-1]) |
| 304 | meta['can_bus'][:3] = 0 |
| 305 | meta['can_bus'][-1] = 0 |
| 306 | else: |
| 307 | meta['prev_bev'] = True |
| 308 | tmp_pos = copy.deepcopy(meta['can_bus'][:3]) |
| 309 | tmp_angle = copy.deepcopy(meta['can_bus'][-1]) |
| 310 | meta['can_bus'][:3] -= prev_pos |
| 311 | meta['can_bus'][-1] -= prev_angle |
| 312 | prev_pos = copy.deepcopy(tmp_pos) |
| 313 | prev_angle = copy.deepcopy(tmp_angle) |
| 314 | metas_map.append(meta) |
| 315 | |
| 316 | # sweep2key transformation |
| 317 | metas_map[-1]['curr2key'] = torch.eye(4) |
| 318 | metas_map[-1]['currlidar2keycam'] = metas_map[-1]['lidar2cam'] |
| 319 | key_x, key_y = queue[-1]['img_metas'].data['can_bus'][:2] |
| 320 | key_yaw = queue[-1]['img_metas'].data['can_bus'][-2] |
| 321 | for i in range(len(queue)-2, -1, -1): |
| 322 | curr_x = queue[i]['img_metas'].data['can_bus'][0] |
| 323 | curr_y = queue[i]['img_metas'].data['can_bus'][1] |
| 324 | curr2key_x, curr2key_y = get_ego_shift( |
| 325 | key_x - curr_x, |
| 326 | key_y - curr_y, |
| 327 | key_yaw / np.pi * 180 |
| 328 | ) |
| 329 | curr_yaw = queue[i]['img_metas'].data['can_bus'][-2] |
| 330 | curr2key_angle = key_yaw - curr_yaw |
| 331 | # get transmation mats |
| 332 | R = torch.eye(4) |
| 333 | R[:2,:2] = torch.Tensor([[np.cos(curr2key_angle), np.sin(curr2key_angle)], |
| 334 | [-np.sin(curr2key_angle), np.cos(curr2key_angle)]]) |
| 335 | T = torch.eye(4) |
| 336 | T[0,3], T[1,3] = curr2key_x, curr2key_y |
| 337 | curr2key = R @ T |
| 338 | metas_map[i]['curr2key'] = curr2key |
| 339 | metas_map[i]['currlidar2keycam'] = metas_map[i]['lidar2cam'] @ curr2key |
| 340 | |
| 341 | # dense-fusion |
| 342 | points = queue[-1]['points'].data |
| 343 | points = torch.cat([points,torch.zeros(points.shape[0],1)], dim=1) |
| 344 | points[:,4] = 0 |
| 345 | points_list = [points] |
| 346 | for i in range(len(queue)-2, -1, -1): |
| 347 | points_sweep = copy.deepcopy(queue[i]['points'].data) |
no test coverage detected