(config, save=True)
| 44 | return raw_scan |
| 45 | |
| 46 | def process_raw(config, save=True): |
| 47 | |
| 48 | def get_cartesian_list(filepaths, columns="XZI", csv_delimiter=","): |
| 49 | cartesian_list = [] |
| 50 | for filepath in filepaths: |
| 51 | points2d = load_pointcloud(filepath, columns, csv_delimiter, as_array=True) |
| 52 | cartesian_list.append(points2d) |
| 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): |
| 95 | # print("lidar.pkl file found:", config.raw_path) |
| 96 | raw_scan = load_raw_scan(config.raw_path) |
| 97 | |
| 98 | |
| 99 | # IMU data |
| 100 | if "quaternions" in raw_scan: |
| 101 | orientation = Orientation(raw_scan["quaternions"], degrees=True) |
| 102 | # for i, euler_angles in enumerate(orientation.euler_list): |
| 103 | # print(f"Euler {i}: {euler_angles.x:.3} {euler_angles.y:.3} {euler_angles.z:.3}") |
no test coverage detected