MCPcopy Create free account
hub / github.com/DragonisCV/RAM / imwrite

Function imwrite

ram/utils/img_util.py:135–153  ·  view source on GitHub ↗

Write image to file. Args: img (ndarray): Image array to be written. file_path (str): Image file path. params (None or list): Same as opencv's :func:`imwrite` interface. auto_mkdir (bool): If the parent folder of `file_path` does not exist, whether to

(img, file_path, params=None, auto_mkdir=True)

Source from the content-addressed store, hash-verified

133
134
135def imwrite(img, file_path, params=None, auto_mkdir=True):
136 """Write image to file.
137
138 Args:
139 img (ndarray): Image array to be written.
140 file_path (str): Image file path.
141 params (None or list): Same as opencv's :func:`imwrite` interface.
142 auto_mkdir (bool): If the parent folder of `file_path` does not exist,
143 whether to create it automatically.
144
145 Returns:
146 bool: Successful or not.
147 """
148 if auto_mkdir:
149 dir_name = os.path.abspath(os.path.dirname(file_path))
150 os.makedirs(dir_name, exist_ok=True)
151 ok = cv2.imwrite(file_path, img, params)
152 if not ok:
153 raise IOError('Failed in writing images.')
154
155
156def crop_border(imgs, crop_border):

Callers 7

saveFunction · 0.90
save_imageMethod · 0.90
dist_validationMethod · 0.90
nondist_validationMethod · 0.90
save_imageMethod · 0.90
save_imageMethod · 0.90
nondist_validationMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected