From d3afeb0e3bbfde4a189976aaec72c6020947b8fe Mon Sep 17 00:00:00 2001 From: Kamil Guttmann Date: Sun, 29 Jan 2023 17:48:12 +0100 Subject: [PATCH] processing fix --- process_video.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/process_video.py b/process_video.py index 8196409..f28da94 100644 --- a/process_video.py +++ b/process_video.py @@ -16,15 +16,17 @@ def segment_video(video, fps=5): result = [] i=0 + num = 0 while True: ret, frame = video.read() if ret == False: break if i % n == 0: result.append(frame) + num += 1 i += 1 - return result, i + return result, num def save_frames(frames, dir): for i, frame in enumerate(frames): @@ -41,7 +43,7 @@ def classify(img, model): def read_saved_frames(dir, n): result = [] - for i in range(n+1): + for i in range(n): img = tf.keras.utils.load_img(f"{dir}/frame{i}.jpg", target_size = [224, 224]) result.append(img) return result @@ -52,6 +54,7 @@ if __name__ == "__main__": model = tf.keras.models.load_model('model_pred/VGG16_sign_char_detection_model') frames, num = segment_video(video, 20) + print(num) save_frames(frames, "frames") frames = read_saved_frames("frames", num) result = []