#coding:utf-8
import cv2
import os
import numpy as np
from PIL import Image, ImageDraw,ImageFont
import glob
fps = 8 #保存视频的FPS,可以适当调整
#可以用(*'DVIX')或(*'X264'),如果都不行先装ffmepg: sudo apt-get install ffmepg
fourcc = cv2.VideoWriter_fourcc(*'MJPG')
saveVideoName = 'myVideoName.avi' #myVideoName.avi是要生成的视频名称
frameSize = (642, 360) #(256,341)是图片尺寸,与图片尺寸不符合会报错
# videoWriter = cv2.VideoWriter(saveVideoName='myvideoname.avi', fourcc=cv2.VideoWriter_fourcc(*'MJPG'), fps=1, frameSize=(256,341)))
videoWriter = cv2.VideoWriter(saveVideoName, fourcc, fps, frameSize)
for i in range(1,38):
img = cv2.imread("bird2/test%s.jpg"%i, -1)
# cv2.imshow("Tracking", 'bird2/test'+str(i)+'.jpg')
videoWriter.write(img)
videoWriter.release()