mrdja.ransaclp.get_ransac_data_from_filename

mrdja.ransaclp.get_ransac_data_from_filename(filename: str, ransac_iterator: Callable, ransac_iterations: int = 100, threshold: float = 0.1, audit_cloud: bool = False, verbosity_level: int = 0, inherited_verbose_string: str = '', seed: int | None = None) Dict[source]

Gets the ransac data from a file.

The ransac data is a dictionary with the following keys: - filename: the filename - audit_before_sanitizing: the audit of the point cloud before sanitizing; it is a dictionary with the following keys:

  • number_pcd_points: the number of points in the point cloud

  • has_normals: whether the point cloud has normals

  • has_colors: whether the point cloud has colors

  • is_empty: whether the point cloud is empty

  • max_x: the maximum x coordinate

  • min_x: the minimum x coordinate

  • max_y: the maximum y coordinate

  • min_y: the minimum y coordinate

  • max_z: the maximum z coordinate

  • min_z: the minimum z coordinate

  • all_points_finite: whether all the points are finite

  • all_points_unique: whether all the points are unique

  • audit_after_sanitizing: the audit of the point cloud after sanitizing

  • number_pcd_points: the number of points in the point cloud

  • ransac_iterations_results: the results of the ransac iterations. It is a list, where each element is a dictionary with the following keys:
    • current_random_points: the current random points chosen to estimate the line

    • current_line: the current line estimated from the random points. Right now it is a numpy array with two points, the same as the current_random_points

    • threshold: the maximum distance from the line to consider a point as an inlier

    • number_inliers: the number of inliers

    • indices_inliers: the indices of the inliers in the point cloud

  • ransac_best_iteration_results: the best iteration results

Parameters:
  • filename (str) – The filename.

  • ransac_iterator (Callable, function that takes the point cloud data and returns the ransac data.) – The ransac iterator.

  • ransac_iterations (int) – The number of ransac iterations.

  • threshold (float) – The threshold.

  • audit_cloud (bool) – Whether to audit the cloud.

  • verbosity_level (int) – The verbosity level.

  • inherited_verbose_string (str) – The inherited verbose string.

  • seed (int) – The seed.

Returns:

The ransac data.

Return type:

dict

Example:

>>> import open3d as o3d
>>> import mrdja.ransaclp as ransaclp
>>> import mrdja.ransac.coreransac as coreransac
>>> office_dataset = o3d.data.OfficePointClouds()
>>> office_filename = office_dataset.paths[0]
>>> ransac_iterator = coreransac.get_ransac_line_iteration_results
>>> ransac_iterations = 200
>>> threshold = 0.02
>>> seed = 42
>>> ransac_data = ransaclp.get_ransac_data_from_filename(office_filename, ransac_iterator = ransac_iterator, 
                                                   ransac_iterations = ransac_iterations, 
                                                   threshold = threshold, audit_cloud=True, seed = seed)
>>> ransac_data["filename"]
'/home/user/open3d_data/extract/OfficePointClouds/cloud_bin_0.ply'
>>> ransac_data["audit_before_sanitizing"]
{'number_pcd_points': 276871,
'has_normals': True,
'has_colors': True,
'is_empty': False,
'max_x': 3.5121824741363525,
'min_x': 0.00390625,
'max_y': 2.80859375,
'min_y': 0.47265625,
'max_z': 2.7512423992156982,
'min_z': 0.94921875,
'all_points_finite': True,
'all_points_unique': True}
>>> ransac_data["audit_after_sanitizing"]
{'number_pcd_points': 276871,
'has_normals': True,
'has_colors': True,
'is_empty': False,
'max_x': 3.5121824741363525,
'min_x': 0.00390625,
'max_y': 2.80859375,
'min_y': 0.47265625,
'max_z': 2.7512423992156982,
'min_z': 0.94921875,
'all_points_finite': True,
'all_points_unique': True}
>>> ransac_data["number_pcd_points"]
276871
>>> iterations_results = ransac_data["ransac_iterations_results"]
>>> len(iterations_results)
200
>>> first_iteration_results = iterations_results[0]
>>> first_iteration_results["current_random_points"]
array([[1.88671875, 1.96484375, 1.91060746],
[3.18359375, 1.89562058, 2.45703125]])
>>> first_iteration_results["current_line"]
array([[1.88671875, 1.96484375, 1.91060746],
[3.18359375, 1.89562058, 2.45703125]])
>>> first_iteration_results["threshold"]
0.02
>>> first_iteration_results["number_inliers"]
203
>>> first_iteration_results["indices_inliers"][:5]
array([ 58884,  59966,  60516,  61070, 138037])
>>> best_iteration_results = ransac_data["ransac_best_iteration_results"]
>>> best_iteration_results["current_random_points"]
array([[1.85546875, 2.67396379, 2.08203125],
[0.85546875, 2.57869077, 2.52734375]])
>>> best_iteration_results["current_line"]
array([[1.85546875, 2.67396379, 2.08203125],
[0.85546875, 2.57869077, 2.52734375]])
>>> best_iteration_results["threshold"]
0.02
>>> best_iteration_results["number_inliers"]
2128
>>> best_iteration_results["indices_inliers"][:5]
array([24335, 25743, 25746, 25897, 26405])