MCPcopy Index your code
hub / github.com/SpectacularAI/sdk / process

Function process

python/cli/process/process.py:377–806  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

375 return points, images, cameras
376
377def 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')

Callers 1

process.pyFile · 0.85

Calls 8

runMethod · 0.95
VisualizerArgsClass · 0.90
VisualizerClass · 0.90
parse_input_dirFunction · 0.85
auto_configFunction · 0.85
is_already_rectifiedFunction · 0.85
appendMethod · 0.80
convert_distortionFunction · 0.70

Tested by

no test coverage detected