datumaro.util.image#
Module Attributes
filename -> height, width |
Functions
|
|
|
|
|
|
|
|
|
|
|
Reads an image in the HWC Grayscale/BGR(A) [0; 255] format (default dtype is uint8). |
|
Loads image metadata from a file with the following format: |
|
|
|
Saves image_meta to the path specified by image_meta_path in the format defined in load_image_meta_file's documentation. |
Classes
|
Cache: |
- datumaro.util.image.load_image(path: str, dtype: ~typing.Union[~numpy.dtype[~typing.Any], None, type[typing.Any], ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]], str, tuple[typing.Any, int], tuple[typing.Any, typing.Union[typing.SupportsIndex, collections.abc.Sequence[typing.SupportsIndex]]], list[typing.Any], ~numpy._typing._dtype_like._DTypeDict, tuple[typing.Any, typing.Any]] = <class 'numpy.uint8'>, crypter: ~datumaro.components.crypter.Crypter = <datumaro.components.crypter.NullCrypter object>)[source]#
Reads an image in the HWC Grayscale/BGR(A) [0; 255] format (default dtype is uint8).
- datumaro.util.image.copyto_image(src: Union[str, IOBase], dst: Union[str, IOBase], src_crypter: Crypter, dst_crypter: Crypter) None [source]#
- datumaro.util.image.save_image(dst: ~typing.Union[str, ~io.IOBase], image: ~numpy.ndarray, ext: ~typing.Optional[str] = None, create_dir: bool = False, dtype: ~typing.Union[~numpy.dtype[~typing.Any], None, type[typing.Any], ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]], str, tuple[typing.Any, int], tuple[typing.Any, typing.Union[typing.SupportsIndex, collections.abc.Sequence[typing.SupportsIndex]]], list[typing.Any], ~numpy._typing._dtype_like._DTypeDict, tuple[typing.Any, typing.Any]] = <class 'numpy.uint8'>, crypter: ~datumaro.components.crypter.Crypter = <datumaro.components.crypter.NullCrypter object>, **kwargs) None [source]#
- datumaro.util.image.encode_image(image: ~numpy.ndarray, ext: str, dtype: ~typing.Union[~numpy.dtype[~typing.Any], None, type[typing.Any], ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]], str, tuple[typing.Any, int], tuple[typing.Any, typing.Union[typing.SupportsIndex, collections.abc.Sequence[typing.SupportsIndex]]], list[typing.Any], ~numpy._typing._dtype_like._DTypeDict, tuple[typing.Any, typing.Any]] = <class 'numpy.uint8'>, **kwargs) bytes [source]#
- datumaro.util.image.decode_image(image_bytes: bytes, dtype: ~typing.Union[~numpy.dtype[~typing.Any], None, type[typing.Any], ~numpy._typing._dtype_like._SupportsDType[~numpy.dtype[~typing.Any]], str, tuple[typing.Any, int], tuple[typing.Any, typing.Union[typing.SupportsIndex, collections.abc.Sequence[typing.SupportsIndex]]], list[typing.Any], ~numpy._typing._dtype_like._DTypeDict, tuple[typing.Any, typing.Any]] = <class 'numpy.uint8'>) ndarray [source]#
- datumaro.util.image.find_images(dirpath: str, exts: Optional[Union[str, Iterable[str]]] = None, recursive: bool = False, max_depth: Optional[int] = None, min_depth: Optional[int] = None) Iterator[str] [source]#
- class datumaro.util.image.lazy_image(path: str, loader: ~typing.Optional[~typing.Callable[[str], ~numpy.ndarray]] = None, cache: ~typing.Union[bool, ~datumaro.util.image_cache.ImageCache] = True, crypter: ~datumaro.components.crypter.Crypter = <datumaro.components.crypter.NullCrypter object>)[source]#
Bases:
object
- Cache:
False: do not cache
True: use the global cache
ImageCache instance: an object to be used as cache
- datumaro.util.image.load_image_meta_file(image_meta_path: str) Dict[str, Tuple[int, int]] [source]#
Loads image metadata from a file with the following format:
<image name 1> <height 1> <width 1>
<image name 2> <height 2> <width 2>
…
Shell-like comments and quoted fields are allowed.
This can be useful to support datasets in which image dimensions are required to interpret annotations.