-
Notifications
You must be signed in to change notification settings - Fork 0
/
resize_video_patches.py
42 lines (31 loc) · 1.38 KB
/
resize_video_patches.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
# 2021, Anomaly Detection in Video via Self-Supervised and Multi-Task Learning
# Mariana-Iuliana Georgescu, Antonio Barbalau, Radu Tudor Ionescu Fahad Shahbaz Khan, Marius Popescu, Mubarak Shah, CVPR
# SecurifAI’s NonCommercial Use & No Sharing International Public License.
import glob
import os
import cv2 as cv
import numpy as np
import args
import utils
samples_names = []
folder_base = os.path.join(args.output_folder_base, args.database_name, utils.ProcessingType.TRAIN.value)
videos_names = os.listdir(folder_base)
def resize_video_sample(video_sample, size=(64, 64)):
resized_sample = []
for i in range(len(video_sample)):
sample_obj = video_sample[i]
sample_obj = cv.resize(sample_obj, size, interpolation=cv.INTER_CUBIC)
resized_sample.append(sample_obj)
return resized_sample
for video_name in videos_names:
video_samples_path = glob.glob(os.path.join(folder_base, video_name, args.samples_folder_name, '*.npy'))
print(video_name)
for video_sample_path in video_samples_path:
sample = np.load(video_sample_path)
short_file_name = video_sample_path.split(os.sep)[-1]
if short_file_name.find('_64.npy') == -1:
size = (64, 64)
else:
continue
resized_sample = resize_video_sample(sample, size)
np.save(video_sample_path.replace('.npy', '_64.npy'), resized_sample)