1import cv2
2import numpy as np
3import glob
4
5img_array = []
6for filename in glob.glob('C:/New folder/Images/*.jpg'):
7 img = cv2.imread(filename)
8 height, width, layers = img.shape
9 size = (width,height)
10 img_array.append(img)
11
12
13out = cv2.VideoWriter('project.avi',cv2.VideoWriter_fourcc(*'DIVX'), 15, size)
14
15for i in range(len(img_array)):
16 out.write(img_array[i])
17out.release()
1 import cv2
2 import numpy as np
3
4 # choose codec according to format needed
5 fourcc = cv2.VideoWriter_fourcc(*'mp4v')
6 video = cv2.VideoWriter('video.avi', fourcc, 1, (width, height))
7
8 for j in range(0,5):
9 img = cv2.imread(str(i) + '.png')
10 video.write(img)
11
12 cv2.destroyAllWindows()
13 video.release()
14