Load Points From File. Load sunrgbd and scannet points from file. Args: load_dim (int): The dimension of the loaded points. Defaults to 6. coord_type (str): The type of coordinates of points cloud. Available options includes: - 'LIDAR': P
| 940 | |
| 941 | @PIPELINES.register_module() |
| 942 | class LoadPointsFromFile(object): |
| 943 | """Load Points From File. |
| 944 | |
| 945 | Load sunrgbd and scannet points from file. |
| 946 | |
| 947 | Args: |
| 948 | load_dim (int): The dimension of the loaded points. |
| 949 | Defaults to 6. |
| 950 | coord_type (str): The type of coordinates of points cloud. |
| 951 | Available options includes: |
| 952 | - 'LIDAR': Points in LiDAR coordinates. |
| 953 | - 'DEPTH': Points in depth coordinates, usually for indoor dataset. |
| 954 | - 'CAMERA': Points in camera coordinates. |
| 955 | use_dim (list[int]): Which dimensions of the points to be used. |
| 956 | Defaults to [0, 1, 2]. For KITTI dataset, set use_dim=4 |
| 957 | or use_dim=[0, 1, 2, 3] to use the intensity dimension. |
| 958 | shift_height (bool): Whether to use shifted height. Defaults to False. |
| 959 | file_client_args (dict): Config dict of file clients, refer to |
| 960 | https://github.com/open-mmlab/mmcv/blob/master/mmcv/fileio/file_client.py |
| 961 | for more details. Defaults to dict(backend='disk'). |
| 962 | """ |
| 963 | |
| 964 | def __init__(self, |
| 965 | coord_type, |
| 966 | load_dim=6, |
| 967 | use_dim=[0, 1, 2], |
| 968 | shift_height=False, |
| 969 | file_client_args=dict(backend='disk')): |
| 970 | self.shift_height = shift_height |
| 971 | if isinstance(use_dim, int): |
| 972 | use_dim = list(range(use_dim)) |
| 973 | assert max(use_dim) < load_dim, \ |
| 974 | f'Expect all used dimensions < {load_dim}, got {use_dim}' |
| 975 | assert coord_type in ['CAMERA', 'LIDAR', 'DEPTH'] |
| 976 | |
| 977 | self.coord_type = coord_type |
| 978 | self.load_dim = load_dim |
| 979 | self.use_dim = use_dim |
| 980 | self.file_client_args = file_client_args.copy() |
| 981 | self.file_client = None |
| 982 | |
| 983 | def _load_points(self, pts_filename): |
| 984 | """Private function to load point clouds data. |
| 985 | |
| 986 | Args: |
| 987 | pts_filename (str): Filename of point clouds data. |
| 988 | |
| 989 | Returns: |
| 990 | np.ndarray: An array containing point clouds data. |
| 991 | """ |
| 992 | if self.file_client is None: |
| 993 | self.file_client = mmcv.FileClient(**self.file_client_args) |
| 994 | try: |
| 995 | pts_bytes = self.file_client.get(pts_filename) |
| 996 | points = np.frombuffer(pts_bytes, dtype=np.float32) |
| 997 | except ConnectionError: |
| 998 | mmcv.check_file_exist(pts_filename) |
| 999 | if pts_filename.endswith('.npy'): |
no outgoing calls