opencv将图片合成为视频

opencv将图片合成为视频

import cv2
import os

img = cv2.imread(r"C:\Users\lenovo\Desktop\python\jiqixuexi\pic\image1.jpg")

imgInfo = img.shape

size = (imgInfo[1],imgInfo[0])

print(size)

os.chdir(r"C:\Users\lenovo\Desktop\python\jiqixuexi\pic")

videoWrite = cv2.VideoWriter("2.mp4",-1,100,size)
#  文件名   ,  编码器   ,帧率   ,  图片大小
for i in range(1,100):
    fileName = "image" + str(i) + ".jpg"
    img = cv2.imread(fileName)
    videoWrite.write(img)
print("end!")

opencv将图片合成为视频_第1张图片

你可能感兴趣的:(#,ros-机器视觉,opencv,cv,python,计算机视觉)