import numpy as np
import cv2
from PIL import Image, ImageDraw, ImageFont


def put_text(img, text, xy, fill=(255, 255, 255), size=20, font='SourceHanSansCN-Bold.otf'):
    img = Image.fromarray(img)
    draw = ImageDraw.Draw(img)
    font = ImageFont.truetype(font, size, encoding='utf-8')
    draw.text(xy, text, fill, font=font)
    return np.asarray(img)


if __name__ == '__main__':
	im = np.zeros((100, 200, 3), dtype='uint8')
	im = put_text(im, "你好 World!!!", (5, 5))
	cv2.imshow('a', im)
	cv2.waitKey()

@@ -4,30 +4,99 @@
 ort 
-numpy as np%0Aimport cv2
+os%0A%0Aimport cv2%0Aimport numpy as np%0Afrom mutagen.mp3 import MP3%0Afrom mutagen.wave import WAVE
 %0Afro
@@ -427,36 +427,672 @@
 )%0A%0A%0A
-if __name__ == '__main__':%0A%09
+def to_frame(cap):%0A    while True:%0A        ret, frame = cap.read()%0A        if not ret:%0A            break%0A        yield frame%0A%0A%0Adef get_time_secs(fn):%0A    assert os.path.isfile(fn), f'get_time_secs(%7Bfn%7D)?'%0A    if fn.endswith('.mp4'):%0A        cap = cv2.VideoCapture(fn)%0A        time_secs = cap.get(7) / cap.get(5)%0A        cap.release()%0A        return time_secs%0A    elif fn.endswith('.mp3'):%0A        return MP3(fn).info.length%0A    elif fn.endswith('.wav'):%0A        return WAVE(fn).info.length%0A    else:%0A        assert False, f'get_time_secs(%7Bfn%7D)?'%0A%0A%0Aif __name__ == '__main__':%0A    for fn in %5B'r.mp4', 'r.wav'%5D:%0A        r = get_time_secs(fn)%0A        print(fn, r)%0A    
 im =
@@ -1131,17 +1131,20 @@
 uint8')%0A
-%09
+    
 im = put
@@ -1176,17 +1176,20 @@
 (5, 5))%0A
-%09
+    
 cv2.imsh
@@ -1204,9 +1204,12 @@
 im)%0A
-%09
+    
 cv2.

Update cvutils.py