make_video.py 619 Bytes
import cv2
import re
import os
import matplotlib.pyplot as plt
import numpy as np

path = "C:/Datasets/vid2"

count = 0
img_data = []
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('2.avi',fourcc, 10, (380,480))

dir_list = os.listdir(path)
dir_list.sort(key=lambda var:[int(x) if x.isdigit() else x for x in re.findall(r'[^0-9]|[0-9]+', var)])


for img in dir_list:
    img_array = cv2.imread(os.path.join(path, img), cv2.IMREAD_COLOR)
    new_array = cv2.resize(img_array, (380,480))
    #cv2.imwrite('out{}.jpg'.format(count), new_array)
    out.write(new_array)
    count += 1