forked from JingyunLiang/VRT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownscale_vid.py
26 lines (20 loc) · 913 Bytes
/
downscale_vid.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
import cv2
import os
def downscale_images(input_folder, output_folder, scale_factor):
if not os.path.exists(output_folder):
os.makedirs(output_folder)
for filename in os.listdir(input_folder):
if filename.endswith(".jpg") or filename.endswith(".png"):
img_path = os.path.join(input_folder, filename)
img = cv2.imread(img_path)
# resize image down
width = int(img.shape[1] * scale_factor)
height = int(img.shape[0] * scale_factor)
resized_img = cv2.resize(img, (width, height))
# save
output_path = os.path.join(output_folder, filename)
cv2.imwrite(output_path, resized_img)
if __name__ == "__main__":
input_folder = "testsets/gopro_test_GT/GOPR0871_11_00_this_one"
output_folder = "testsets/downscaled/gopro/00"
downscale_images(input_folder, output_folder, 0.25)