Python视频图像播放中加入文字

def preprocessing():
    print("开始获取数据...")
    img_path = gb.glob(os.path.join(datasetDir, '*.tif'))
    rawImgs = []
    opImgs = []
    for i, curFrame in enumerate(img_path):
        print("curFrame: ", curFrame)
        img = cv2.imread(curFrame)
        font = cv2.FONT_HERSHEY_SIMPLEX  # 使用默认字体
        img = cv2.putText(img, str(i+1), (0, 20), font, 0.8, (255, 255, 255), 1)  # #添加文字,1.2表示字体大小,(0,40)是初始的位置,(255,255,255)表示颜色,2表示粗细
        cv2.namedWindow("rawImageFrame", 0)
        cv2.resizeWindow("rawImageFrame", 360, 240)
        cv2.imshow('rawImageFrame', img)
        cv2.waitKey(30)
    cv2.destroyAllWindows()

视频中加入文字,并且动态播放

结果展示:

猜你喜欢

转载自blog.csdn.net/mago2015/article/details/82693925
今日推荐