forked from ZPdesu/Barbershop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_to_video.py
30 lines (24 loc) · 1.04 KB
/
image_to_video.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
import cv2
import numpy as np
import glob
img_array = []
for filename in sorted(glob.glob('input/face/sample_video_1_frames_processed/*.png'), key=lambda x:int(x[53:-4])):
img = cv2.imread(filename)
height, width, layers = img.shape
size = (width, height)
img_array.append(img)
out = cv2.VideoWriter('output/video/sample_video_1_frames_processed.avi', cv2.VideoWriter_fourcc(*'DIVX'), 30, size)
for i in range(len(img_array)):
out.write(img_array[i])
out.release()
# 파일 이름이 'output/vid1_frame0_vid2_frame0_vid2_frame0_realistic.png'의 형식이라 가정, mask 제외 결과 이미지만 영상으로 변환
# img_array = []
# for filename in sorted(glob.glob('output/vid1_frame*.png'), key=lambda x:int(x[17:-14].split('_')[0])):
# img = cv2.imread(filename)
# height, width, layers = img.shape
# size = (width, height)
# img_array.append(img)
# out = cv2.VideoWriter('output/result.mp4', cv2.VideoWriter_fourcc(*'DIVX'), 30, size)
# for i in range(len(img_array)):
# out.write(img_array[i])
# out.release()