Showing
1 changed file
with
23 additions
and
0 deletions
etc/make_video.py
0 → 100644
| 1 | +import cv2 | ||
| 2 | +import re | ||
| 3 | +import os | ||
| 4 | +import matplotlib.pyplot as plt | ||
| 5 | +import numpy as np | ||
| 6 | + | ||
| 7 | +path = "C:/Datasets/vid15" | ||
| 8 | + | ||
| 9 | +count = 0 | ||
| 10 | +img_data = [] | ||
| 11 | +fourcc = cv2.VideoWriter_fourcc(*'XVID') | ||
| 12 | +out = cv2.VideoWriter('15.avi',fourcc, 10, (270,450)) | ||
| 13 | + | ||
| 14 | +dir_list = os.listdir(path) | ||
| 15 | +dir_list.sort(key=lambda var:[int(x) if x.isdigit() else x for x in re.findall(r'[^0-9]|[0-9]+', var)]) | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +for img in dir_list: | ||
| 19 | + img_array = cv2.imread(os.path.join(path, img), cv2.IMREAD_COLOR) | ||
| 20 | + new_array = cv2.resize(img_array, (270,450)) | ||
| 21 | + #cv2.imwrite('out{}.jpg'.format(count), new_array) | ||
| 22 | + out.write(new_array) | ||
| 23 | + count += 1 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment