File size: 1,228 Bytes
59b2a81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
'''
    This file is designed to resize the video sequence to the target resolution
'''
import os, sys, shutil
import cv2

if __name__ == "__main__":
    input_folder = "/nfs/turbo/jjparkcv-turbo-large/boyangwa/model_results/SVD_results"
    store_path = "/nfs/turbo/jjparkcv-turbo-large/boyangwa/model_results/SVD_results_resized"    
    target_height, target_width = 256, 384

    if os.path.exists(store_path):
        shutil.rmtree(store_path)
    os.makedirs(store_path)

    for video_name in sorted(os.listdir(input_folder)):
        print("We are processing ", video_name)
        sub_video_folder = os.path.join(input_folder, video_name)
        sub_store_folder = os.path.join(store_path, video_name)
        os.makedirs(sub_store_folder)

        for img_name in os.listdir(sub_video_folder):
            if not img_name.endswith("jpg") and not img_name.endswith("png"):
                continue

            img_path = os.path.join(sub_video_folder, img_name)
            store_img_path = os.path.join(sub_store_folder, img_name)
            img = cv2.imread(img_path)

            # Resize 
            img = cv2.resize(img, (target_width, target_height))
            cv2.imwrite(store_img_path, img)