def write(filepath, image):
"""Saves an image or a frame to the specified path.
Parameters
----------
filepath: str
The path to the file.
image: ndarray(float/int)
The image data.
value_range: int (e.g. VALUE_RANGE_0_1)
The value range of the provided image data.
"""
dirpath = os.path.dirname(filepath)
if not os.path.exists(dirpath):
os.makedirs(dirpath)
if image.shape[2] == 3:
image = cast(image)
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
factor = 1
if is_float_image(image):
factor = 255
cv2.imwrite(filepath, image * factor)
评论列表
文章目录