processing fix
This commit is contained in:
parent
0a64ba8b19
commit
d3afeb0e3b
@ -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 = []
|
||||
|
Loading…
Reference in New Issue
Block a user