-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwithv2.py
More file actions
26 lines (18 loc) · 732 Bytes
/
withv2.py
File metadata and controls
26 lines (18 loc) · 732 Bytes
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
import cv2
import os
import re
def sorted_alphanumeric(data):
convert = lambda text: int(text) if text.isdigit() else text.lower()
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
return sorted(data, key=alphanum_key)
image_folder = 'i3'
video_name = 'videoBASE3P.avi'
images = [img for img in sorted_alphanumeric(os.listdir(image_folder)) if img.endswith(".png")]
frame = cv2.imread(os.path.join(image_folder, images[0]))
height, width, layers = frame.shape
#fourcc = cv2.VideoWriter_fourcc(*'mp4v')
video = cv2.VideoWriter(video_name, 0, 30, (width,height))
for image in images:
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()