forked from ReNginx/FR-SRGAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vid4_Video.py
48 lines (39 loc) · 1.41 KB
/
Vid4_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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import cv2
#from cv2 import VideoWriter, VideoWriter_fourcc, imread, resize
import os
import numpy as np
lr_img_root = "Data/FRVSR_VID4/LR/walk"
hr_img_root = "Data/FRVSR_VID4/HR/walk"
# Edit each frame's appearing time!
fps = 24
fourcc = cv2.VideoWriter_fourcc('M', 'P', '4','v')
videoWriter_hr = cv2.VideoWriter("Data/hr_test.mp4", fourcc, fps, (704, 480))
videoWriter_lr = cv2.VideoWriter("Data/lr_test.mp4", fourcc, fps, (176, 120))
lr_im_names = os.listdir(lr_img_root)
lr_im_names.sort()
#print(lr_im_names)
for im_name in lr_im_names:
# print(im_name)
# print(os.path.join(lr_img_root, str(im_name)))
if cv2.imread(os.path.join(lr_img_root,im_name)) is not None:
# print(os.path.join(lr_img_root,str(im_name)))
frame = cv2.imread(os.path.join(lr_img_root,str(im_name)))
# print(frame.shape)
cv2.imshow('frame', frame)
#frame = (np.uint8(frame)).transpose((1, 2, 0))
videoWriter_lr.write(frame)
else:
pass
hr_im_names = os.listdir(hr_img_root)
hr_im_names.sort()
for im_name in hr_im_names:
if cv2.imread(os.path.join(hr_img_root,im_name)) is not None:
frame = cv2.imread(os.path.join(hr_img_root,str(im_name)))
#frame = (np.uint8(frame)).transpose((1, 2, 0))
#frame = cv2.resize(frame, (704, 480))
videoWriter_hr.write(frame)
else:
pass
videoWriter_lr.release()
videoWriter_hr.release()
cv2.destroyAllWindows()