import cv2 class ImageWriter: """ A flexible and more optimzed image writer against opencv image writer. """ def __init__(self, image_path): self._image_path = image_path # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def write(self, frame): "Writes a frame onto photo file - the frame needs to be in BGR format" cv2.imwrite(self._image_path, frame)