Shortcuts

mmcv.image.imwrite

mmcv.image.imwrite(img: numpy.ndarray, file_path: str, params: Optional[list] = None, auto_mkdir: Optional[bool] = None, file_client_args: Optional[dict] = None, *, backend_args: Optional[dict] = None)bool[源代码]

Write image to file.

警告

The parameter auto_mkdir will be deprecated in the future and every file clients will make directory automatically.

参数
  • img (ndarray) – Image array to be written.

  • file_path (str) – Image file path.

  • params (None or list) – Same as opencv imwrite() interface.

  • auto_mkdir (bool) – If the parent folder of file_path does not exist, whether to create it automatically. It will be deprecated.

  • file_client_args (dict, optional) – Arguments to instantiate a FileClient. See mmengine.fileio.FileClient for details. Default: None. It will be deprecated in future. Please use backend_args instead. Deprecated in version 2.0.0rc4.

  • backend_args (dict, optional) – Instantiates the corresponding file backend. It may contain backend key to specify the file backend. If it contains, the file backend corresponding to this value will be used and initialized with the remaining values, otherwise the corresponding file backend will be selected based on the prefix of the file path. Defaults to None. New in version 2.0.0rc4.

返回

Successful or not.

返回类型

bool

实际案例

>>> # write to hard disk client
>>> ret = mmcv.imwrite(img, '/path/to/img.jpg')
>>> # infer the file backend by the prefix s3
>>> ret = mmcv.imwrite(img, 's3://bucket/img.jpg')
>>> # manually set the file backend petrel
>>> ret = mmcv.imwrite(img, 's3://bucket/img.jpg', backend_args={
...     'backend': 'petrel'})
Read the Docs v: 2.x
Versions
latest
stable
2.x
v2.0.1
v2.0.0
1.x
v1.7.1
v1.7.0
v1.6.2
v1.6.1
v1.6.0
v1.5.3
v1.5.2_a
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.18
v1.3.17
v1.3.16
v1.3.15
v1.3.14
v1.3.13
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.