(args)
| 375 | return points, images, cameras |
| 376 | |
| 377 | def process(args): |
| 378 | import spectacularAI |
| 379 | import cv2 |
| 380 | import shutil |
| 381 | import tempfile |
| 382 | import numpy as np |
| 383 | import pandas as pd |
| 384 | |
| 385 | PC_AND_MESH_FORMATS = ['ply', 'pcd', 'obj'] |
| 386 | |
| 387 | # Overwrite format if output is set to pointcloud |
| 388 | for fmt in PC_AND_MESH_FORMATS: |
| 389 | if args.output.endswith('.' + fmt): |
| 390 | args.format = fmt |
| 391 | break |
| 392 | |
| 393 | useMono = None |
| 394 | |
| 395 | # Globals |
| 396 | savedKeyFrames = {} |
| 397 | pointClouds = {} |
| 398 | sparsePointColors = {} |
| 399 | blurScores = {} |
| 400 | frameWidth = -1 |
| 401 | frameHeight = -1 |
| 402 | intrinsics = None |
| 403 | visualizer = None |
| 404 | isTracking = False |
| 405 | finalMapWritten = False |
| 406 | exposureTime = 0 |
| 407 | rollingShutterTime = 0 |
| 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') |
no test coverage detected