(config, pcd, save=True)
| 53 | return cartesian_list |
| 54 | |
| 55 | def postprocess_3D(config, pcd, save=True): |
| 56 | # move Z offset and scale pointcloud |
| 57 | pcd = transform(pcd, translate=(0, 0, config.get("3D","Z_OFFSET"))) # Z offset in mm |
| 58 | scene_scale = config.get("3D","SCALE") # mm -> 0.001 m |
| 59 | if scene_scale !=1: |
| 60 | pcd = transform(pcd, scale=scene_scale) |
| 61 | |
| 62 | |
| 63 | # ANGULAR LOOKUP ("TEXTURING") |
| 64 | if config.get("ENABLE_VERTEXCOLOUR") and os.path.exists(config.pano_path): |
| 65 | colors = angular_lookup(angular_from_cartesian(np.asarray(pcd.points)), # angular_points |
| 66 | cv2.imread(config.pano_path), # pano |
| 67 | scale=config.get("VERTEXCOLOUR","SCALE"), |
| 68 | z_rotate=config.get("VERTEXCOLOUR","Z_ROTATE")) |
| 69 | |
| 70 | pcd.colors = o3d.utility.Vector3dVector(np.asarray(colors)) |
| 71 | |
| 72 | else: # colorize pointcloud by mapping intensities to colormap |
| 73 | pcd = colormap_pcd(pcd, gamma=1, cmap="viridis") |
| 74 | |
| 75 | if save: |
| 76 | save_pointcloud_threaded(pcd, config.pcd_path, ply_ascii=config.get("3D","ASCII")) |
| 77 | |
| 78 | |
| 79 | # FILTER OUTLIER POINTS |
| 80 | if config.get("ENABLE_FILTERING"): |
| 81 | low_pcd = downsample(pcd, voxel_size=config.get("FILTERING", "VOXEL_SIZE")) |
| 82 | |
| 83 | nb_points = config.get("FILTERING", "NB_POINTS") |
| 84 | radius = config.get("FILTERING", "RADIUS") |
| 85 | filtered_low_pcd = filter_outliers(low_pcd, nb_points=nb_points, radius=radius) |
| 86 | |
| 87 | pcd = filter_by_reference(pcd, filtered_low_pcd, radius=radius) |
| 88 | if save: |
| 89 | save_pointcloud_threaded(pcd, config.filtered_pcd_path, ply_ascii=config.get("3D","ASCII")) |
| 90 | |
| 91 | return pcd |
| 92 | |
| 93 | # load raw data dict from pickle file |
| 94 | if os.path.exists(config.raw_path): |
no test coverage detected