Load a depth image from file. Required Keys: - depth_img_path Modified Keys: - depth_img - depth_img_shape Args: imdecode_backend (str): The image decoding backend type. The backend argument for :func:`mmcv.imfrombytes`. See :func:`mmcv.im
| 11 | |
| 12 | @TRANSFORMS.register_module() |
| 13 | class LoadDepthFromFile(BaseTransform): |
| 14 | """Load a depth image from file. |
| 15 | |
| 16 | Required Keys: |
| 17 | |
| 18 | - depth_img_path |
| 19 | |
| 20 | Modified Keys: |
| 21 | |
| 22 | - depth_img |
| 23 | - depth_img_shape |
| 24 | |
| 25 | Args: |
| 26 | imdecode_backend (str): The image decoding backend type. The backend |
| 27 | argument for :func:`mmcv.imfrombytes`. |
| 28 | See :func:`mmcv.imfrombytes` for details. |
| 29 | Defaults to 'cv2'. |
| 30 | ignore_empty (bool): Whether to allow loading empty image or file path |
| 31 | not existent. Defaults to False. |
| 32 | backend_args (dict, optional): Instantiates the corresponding file |
| 33 | backend. It may contain `backend` key to specify the file |
| 34 | backend. If it contains, the file backend corresponding to this |
| 35 | value will be used and initialized with the remaining values, |
| 36 | otherwise the corresponding file backend will be selected |
| 37 | based on the prefix of the file path. Defaults to None. |
| 38 | New in version 2.0.0rc4. |
| 39 | """ |
| 40 | |
| 41 | def __init__(self, |
| 42 | imdecode_backend: str = 'cv2', |
| 43 | ignore_empty: bool = False, |
| 44 | *, |
| 45 | backend_args: Optional[dict] = None) -> None: |
| 46 | self.ignore_empty = ignore_empty |
| 47 | self.imdecode_backend = imdecode_backend |
| 48 | |
| 49 | self.backend_args = None |
| 50 | if backend_args is not None: |
| 51 | self.backend_args = backend_args.copy() |
| 52 | |
| 53 | def transform(self, results: dict) -> Optional[dict]: |
| 54 | """Functions to load image. |
| 55 | |
| 56 | Args: |
| 57 | results (dict): Result dict from |
| 58 | :class:`mmengine.dataset.BaseDataset`. |
| 59 | |
| 60 | Returns: |
| 61 | dict: The dict contains loaded image and meta information. |
| 62 | """ |
| 63 | |
| 64 | filename = results['depth_img_path'] |
| 65 | depth_shift = results['depth_shift'] |
| 66 | |
| 67 | try: |
| 68 | depth_img_bytes = mmengine.fileio.get( |
| 69 | filename, backend_args=self.backend_args) |
| 70 | depth_img = mmcv.imfrombytes(depth_img_bytes, |
nothing calls this directly
no outgoing calls
no test coverage detected