processing fix

This commit is contained in:
Kamil Guttmann 2023-01-29 17:48:12 +01:00
parent 0a64ba8b19
commit d3afeb0e3b

View File

@ -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 = []