Point sample. Sampling data to a certain number. Required Keys: - points - pts_instance_mask (optional) - pts_semantic_mask (optional) Modified Keys: - points - pts_instance_mask (optional) - pts_semantic_mask (optional) Args: num_points (int): N
| 83 | |
| 84 | @TRANSFORMS.register_module() |
| 85 | class PointSample(BaseTransform): |
| 86 | """Point sample. |
| 87 | |
| 88 | Sampling data to a certain number. |
| 89 | |
| 90 | Required Keys: |
| 91 | |
| 92 | - points |
| 93 | - pts_instance_mask (optional) |
| 94 | - pts_semantic_mask (optional) |
| 95 | |
| 96 | Modified Keys: |
| 97 | |
| 98 | - points |
| 99 | - pts_instance_mask (optional) |
| 100 | - pts_semantic_mask (optional) |
| 101 | |
| 102 | Args: |
| 103 | num_points (int): Number of points to be sampled. |
| 104 | sample_range (float, optional): The range where to sample points. |
| 105 | If not None, the points with depth larger than `sample_range` are |
| 106 | prior to be sampled. Defaults to None. |
| 107 | replace (bool): Whether the sampling is with or without replacement. |
| 108 | Defaults to False. |
| 109 | """ |
| 110 | |
| 111 | def __init__(self, |
| 112 | num_points: int, |
| 113 | sample_range: Optional[float] = None, |
| 114 | replace: bool = False) -> None: |
| 115 | self.num_points = num_points |
| 116 | self.sample_range = sample_range |
| 117 | self.replace = replace |
| 118 | |
| 119 | def transform(self, input_dict: dict) -> dict: |
| 120 | """Transform function to sample points to in indoor scenes. |
| 121 | |
| 122 | Args: |
| 123 | input_dict (dict): Result dict from loading pipeline. |
| 124 | |
| 125 | Returns: |
| 126 | dict: Results after sampling, 'points', 'pts_instance_mask' |
| 127 | and 'pts_semantic_mask' keys are updated in the result dict. |
| 128 | """ |
| 129 | points = input_dict['points'] |
| 130 | |
| 131 | # if the depth map is all-zero |
| 132 | if len(points) == 0: |
| 133 | return input_dict |
| 134 | |
| 135 | points, choices = self._points_random_sampling(points, |
| 136 | self.num_points, |
| 137 | self.sample_range, |
| 138 | self.replace, |
| 139 | return_choices=True) |
| 140 | input_dict['points'] = points |
| 141 | |
| 142 | pts_instance_mask = input_dict.get('pts_instance_mask', None) |
nothing calls this directly
no outgoing calls
no test coverage detected