From cb02cd0eaa641f9daa576e0d1c15bce67e85b3a7 Mon Sep 17 00:00:00 2001 From: Andrzej Preibisz Date: Mon, 30 Jan 2023 16:28:34 +0100 Subject: [PATCH] WIP --- main.py | 12 +++++++++--- process_video.py | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 5ecbc56..3901d32 100644 --- a/main.py +++ b/main.py @@ -5,9 +5,13 @@ import cv2 as cv import tempfile import numpy as np import tensorflow as tf +from crop_hand_skeleton import crop_hand +from cvzone.HandTrackingModule import HandDetector if __name__ == "__main__": + detector = HandDetector(maxHands=1, mode=True, detectionCon=0.7, minTrackCon=0.8) model = tf.keras.models.load_model('model_pred/VGG16_sign_char_detection_model') + st.set_page_config( page_title="Projekt widzenie" ) @@ -22,13 +26,15 @@ if __name__ == "__main__": tfile = tempfile.NamedTemporaryFile(delete=False) tfile.write(upload_movie.read()) video_cap = cv.VideoCapture(tfile.name) - result, num = segment_video(video_cap, fps=1.5) + result, num = segment_video(video_cap, fps=10) st.write(f"ZaƂadowano {num} klatek") for img in result: - img2= cv.resize(img,dsize=(224,224)) + img_skeleton = crop_hand(img, detector) + img2= cv.resize(img_skeleton,dsize=(224,224)) + #breakpoint() img_np = np.asarray(img2) classification = classify(img_np[:,:,::-1], model) - st.image(img[:,:,::-1]) + st.image(img_skeleton[:,:,::-1]) st.write(classification) diff --git a/process_video.py b/process_video.py index 081dfb6..4e01ebe 100644 --- a/process_video.py +++ b/process_video.py @@ -1,7 +1,7 @@ import cv2 import tensorflow as tf import numpy as np -from crop_hands_skeleton import crop_hands +from crop_hand_skeleton import crop_hand from cvzone.HandTrackingModule import HandDetector class_names = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'del', 'nothing', 'space'] @@ -34,7 +34,7 @@ def save_frames(frames, dir): detector = HandDetector(maxHands=1, mode=True, detectionCon=0.7, minTrackCon=0.8) for i, frame in enumerate(frames): print(i) - cv2.imwrite(f"{dir}/frame{i}.jpg", crop_hands(frame, detector)) + cv2.imwrite(f"{dir}/frame{i}.jpg", crop_hand(frame, detector)) def classify(img, model):