import util

FRAME_PATH = "/media/data/mtriet/dataset/scnn_%s_frames" % sys.argv[1]
SUB_PATH = "/media/data/mtriet/raw_video/%s/train" % (sys.argv[1])
WINDOW_SIZE = [16, 32, 64, 128, 256, 512]
OVERLAP_RATE = 0.75
CLASSES = [[], []]  # 0, 1

if len(sys.argv) < 3:
    print('fb pad=True/False')
    sys.exit(1)

for window_size in WINDOW_SIZE:
    for frame_root, sub_folder, sub_files in os.walk(FRAME_PATH):
        for folder in sub_folder:
            subtitles = Subtitle.load_subtitle(SUB_PATH, folder, sys.argv[2])
            frames = sorted(os.listdir(frame_root + '/' + folder))
            sub_index = 0
            for begin_pivot in range(
                    1,
                    len(frames) - window_size,
                    int(window_size *
                        (1 - OVERLAP_RATE))):  # ignore last few frames
                if (begin_pivot > subtitles[sub_index].end) and (
                        sub_index < len(subtitles) - 1):
                    sub_index += 1

                end_pivot = min(begin_pivot + window_size, len(frames))
                segment = range(begin_pivot, begin_pivot + window_size + 1)
                sub_range = subtitles[sub_index].get_range()
                intersection = np.intersect1d(segment, sub_range)
Ejemplo n.º 2
0
import sys
import os

from subtitle import Subtitle

SUB_PATH = "/media/data/mtriet/raw_video/%s/train" % (sys.argv[1])
FRAME_PATH = "/media/data/mtriet/dataset/scnn_%s_frames" % sys.argv[1]

if __name__ == '__main__':
    if len(sys.argv) > 4 or len(sys.argv) < 3:
        print('command fb/bb front_pad rear_pad')
        sys.exit(0)
    for frame_root, sub_folder, _ in os.walk(FRAME_PATH):
        for folder in sub_folder:
            print(folder)
            subtitles = Subtitle.load_subtitle(SUB_PATH, folder, False)

            with open("%s/%s_pad.aqt" % (SUB_PATH, folder), 'w') as f:
                for s in subtitles:
                    f.write(s.to_string(sys.argv[2], sys.argv[3]))