"""
python Video&Image2Text.py file_name [-color]
"""
import os
import cv2
import sys
import numpy as np
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import time
chars = '#@&%x*^,. '
color = False
def handle_one_frame(img):
start = time.time()
img = img.convert('L') if not color else img # convert to gray if color is False.
img = np.array(img)
width = img.shape[1]
height = img.shape[0]
output_img = Image.new(mode = 'RGB' if color else 'L', size = (width, height),
color = (255, 255, 255) if color else (255,)) # use '1' rather than 'L' is more clear.
draw = ImageDraw.Draw(output_img) # to write text to image.<