(globalPointCloud, sparse_point_cloud_df)
| 408 | cameraDistortion = None |
| 409 | |
| 410 | def post_process_point_clouds(globalPointCloud, sparse_point_cloud_df): |
| 411 | # Save point clouds |
| 412 | if len(globalPointCloud) == 0: |
| 413 | merged_df = sparse_point_cloud_df |
| 414 | |
| 415 | else: |
| 416 | point_cloud_df = pd.DataFrame(np.array(globalPointCloud), columns=list('xyzrgb')) |
| 417 | |
| 418 | # drop uncolored points |
| 419 | colored_point_cloud_df = point_cloud_df.loc[point_cloud_df[list('rgb')].max(axis=1) > 0].reset_index() |
| 420 | colored_point_cloud_df['id'] = 0 # ID = 0 is not used for valid sparse map points |
| 421 | |
| 422 | filtered_point_cloud_df = exclude_points(colored_point_cloud_df, sparse_point_cloud_df, radius=args.cell_size) |
| 423 | decimated_df = voxel_decimate(filtered_point_cloud_df, args.cell_size) |
| 424 | |
| 425 | # the dense points clouds have presumably more stable colors at corner points |
| 426 | # rather use them than using the same approach as without dense data |
| 427 | sparse_colored_point_cloud_df = interpolate_missing_properties(colored_point_cloud_df, sparse_point_cloud_df[list('xyz')]) |
| 428 | merged_df = pd.concat([sparse_colored_point_cloud_df, decimated_df]) |
| 429 | |
| 430 | if args.distance_quantile > 0: |
| 431 | dist2 = (merged_df[list('xyz')]**2).sum(axis=1).values |
| 432 | MARGIN = 1.5 |
| 433 | max_dist2 = np.quantile(dist2, args.distance_quantile) * MARGIN**2 |
| 434 | print(f'filtering out points further than {np.sqrt(max_dist2)}m') |
| 435 | merged_df = merged_df.iloc[dist2 < max_dist2] |
| 436 | |
| 437 | return merged_df |
| 438 | |
| 439 | def process_mapping_output(output): |
| 440 | nonlocal savedKeyFrames |
no test coverage detected