From ebba05b5f28cc41e4a37cf06724265b973b32517 Mon Sep 17 00:00:00 2001 From: Andrzej Preibisz Date: Tue, 31 Jan 2023 17:06:47 +0100 Subject: [PATCH] Poprawki --- main.py | 12 ++++++++++-- process_video.py | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 26e6283..43b0c76 100644 --- a/main.py +++ b/main.py @@ -28,6 +28,8 @@ if __name__ == "__main__": tfile = tempfile.NamedTemporaryFile(delete=False) tfile.write(upload_movie.read()) video_cap = cv.VideoCapture(tfile.name) + font = cv.FONT_HERSHEY_SIMPLEX + result, num, frames = segment_video(video_cap, fps=3) st.write(f"ZaƂadowano {num} klatek") classifications = [] @@ -38,8 +40,15 @@ if __name__ == "__main__": img_np = np.asarray(img2) classification = classify(img_np[:,:,::-1], model) classifications.append(classification) + cv.putText(img_skeleton, + classification, + (20, 50), + font, 2, + (255, 255, 255), + 6, + cv.LINE_4) + st.image(img_skeleton[:,:,::-1]) - st.write(classification) i = 0 last_letter = '' text = '' @@ -59,7 +68,6 @@ if __name__ == "__main__": frame_index = frames.index(i) letter = classifications[frame_index] last_letter = letter - st.write(last_letter) cv.putText(frame, last_letter, (50, 50), diff --git a/process_video.py b/process_video.py index 4e01ebe..9928645 100644 --- a/process_video.py +++ b/process_video.py @@ -17,6 +17,7 @@ def segment_video(video, fps=5): n = real_fps / fps result = [] + frames_nums = [] i=0 num = 0 while True: @@ -25,10 +26,11 @@ def segment_video(video, fps=5): break if i % n == 0: result.append(frame) + frames_nums.append(i) num += 1 i += 1 - return result, num + return result, num, frames_nums def save_frames(frames, dir): detector = HandDetector(maxHands=1, mode=True, detectionCon=0.7, minTrackCon=0.8)