Filter points by the range. Required Keys: - points - pts_instance_mask (optional) Modified Keys: - points - pts_instance_mask (optional) Args: point_cloud_range (list[float]): Point cloud range.
| 224 | |
| 225 | @TRANSFORMS.register_module() |
| 226 | class PointsRangeFilter(BaseTransform): |
| 227 | """Filter points by the range. |
| 228 | |
| 229 | Required Keys: |
| 230 | |
| 231 | - points |
| 232 | - pts_instance_mask (optional) |
| 233 | |
| 234 | Modified Keys: |
| 235 | |
| 236 | - points |
| 237 | - pts_instance_mask (optional) |
| 238 | |
| 239 | Args: |
| 240 | point_cloud_range (list[float]): Point cloud range. |
| 241 | """ |
| 242 | |
| 243 | def __init__(self, point_cloud_range: List[float]) -> None: |
| 244 | self.pcd_range = np.array(point_cloud_range, dtype=np.float32) |
| 245 | |
| 246 | def transform(self, input_dict: dict) -> dict: |
| 247 | """Transform function to filter points by the range. |
| 248 | |
| 249 | Args: |
| 250 | input_dict (dict): Result dict from loading pipeline. |
| 251 | |
| 252 | Returns: |
| 253 | dict: Results after filtering, 'points', 'pts_instance_mask' |
| 254 | and 'pts_semantic_mask' keys are updated in the result dict. |
| 255 | """ |
| 256 | points = input_dict['points'] |
| 257 | points_mask = points.in_range_3d(self.pcd_range) |
| 258 | clean_points = points[points_mask] |
| 259 | if len(clean_points) < 100: |
| 260 | print('Warning: <100 points after PointsRangeFilter and', |
| 261 | 'so we keep the original points!') |
| 262 | else: |
| 263 | input_dict['points'] = clean_points |
| 264 | points_mask = points_mask.numpy() |
| 265 | |
| 266 | pts_instance_mask = input_dict.get('pts_instance_mask', None) |
| 267 | pts_semantic_mask = input_dict.get('pts_semantic_mask', None) |
| 268 | |
| 269 | if pts_instance_mask is not None: |
| 270 | input_dict['pts_instance_mask'] = pts_instance_mask[ |
| 271 | points_mask] |
| 272 | |
| 273 | if pts_semantic_mask is not None: |
| 274 | input_dict['pts_semantic_mask'] = pts_semantic_mask[ |
| 275 | points_mask] |
| 276 | |
| 277 | return input_dict |
| 278 | |
| 279 | def __repr__(self) -> str: |
| 280 | """str: Return a string that describes the module.""" |
| 281 | repr_str = self.__class__.__name__ |
| 282 | repr_str += f'(point_cloud_range={self.pcd_range.tolist()})' |
| 283 | return repr_str |
nothing calls this directly
no outgoing calls
no test coverage detected