-
Notifications
You must be signed in to change notification settings - Fork 18
/
vis_video.py
46 lines (40 loc) · 1.24 KB
/
vis_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
"""
GTA-IM Dataset
"""
import argparse
import glob
import os
import os.path as osp
import sys
import cv2
from tqdm import tqdm
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=None)
parser.add_argument('-pa', '--path', default='2020-06-10-21-47-45')
parser.add_argument('-s', '--scale', default=4, type=int, help='down scale')
parser.add_argument(
'-fr', '--frame_rate', default=5, type=int, help='frame_rate'
)
args = parser.parse_args()
args.outpath = args.path + '/vis/'
if not osp.exists(args.outpath):
os.mkdir(args.outpath)
ims = sorted(glob.glob(args.path + '/*.jpg'))
if osp.exists(osp.join(args.outpath, 'video.mp4')):
sys.exit()
img_array = []
for filename in tqdm(ims, desc='frame'):
img = cv2.imread(filename)
height, width, layers = img.shape
size = (width // args.scale, height // args.scale)
img = cv2.resize(img, size, interpolation=cv2.INTER_LINEAR)
img_array.append(img)
out = cv2.VideoWriter(
osp.join(args.outpath, 'video.mp4'),
cv2.VideoWriter_fourcc(*'mp4v'),
args.frame_rate,
size,
)
for i in range(len(img_array)):
out.write(img_array[i])
out.release()