1、 python-opencv将图片 / 视频帧写为视频
import cv2
fps = 24 #视频帧率
fourcc = cv2.cv.CV_FOURCC('M','J','P','G')
videoWriter = cv2.VideoWriter('D:/testResults/match/flower2.avi', fourcc, fps, (1360,480)) #(1360,480)为视频大小
for i in range(1,300):
p1=0
p2=i
img12 = cv2.imread('D:/testResults/img_'+str(p1)+'_'+str(p2)+'.jpg')
# cv2.imshow('img', img12)
# cv2.waitKey(1000/int(fps))
videoWriter.write(img12)
videoWriter.release()
具体cv2.VideoWriter()的用法请参考官方文档:http://docs.opencv.org/2.4/search.html?q=cv2.VideoWriter