forked from daxesh020500/Object-Detection-and-tracking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIma_Vid.py
31 lines (29 loc) · 926 Bytes
/
Ima_Vid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2
import numpy as np
import os
from os.path import isfile, join
pathIn = r'D:\Images\\'
pathOut = 'video.avi'
fps = 0.5
frame_array = []
files = [f for f in os.listdir(pathIn) if isfile(join(pathIn, f))]
# for sorting the file names properly
files.sort(key=lambda x: x[5:-4])
files.sort()
frame_array = []
files = [f for f in os.listdir(pathIn) if isfile(join(pathIn, f))]
# for sorting the file names properly
files.sort(key=lambda x: x[5:-4])
for i in range(len(files)):
filename = pathIn + files[i]
# reading each files
img = cv2.imread(filename)
height, width, layers = img.shape
size = (width, height)
# inserting the frames into an image array
frame_array.append(img)
out = cv2.VideoWriter(pathOut, cv2.VideoWriter_fourcc(*'DIVX'), fps, size)
for i in range(len(frame_array)):
# writing to a image array
out.write(frame_array[i])
out.release()