KKowenn commited on
Commit
1ed5218
·
1 Parent(s): 5b34140

Updated app.py with video file upload and pose detection

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import cv2 as cv
3
  import numpy as np
 
4
 
5
  # Paths to your files
6
  model_path = "graph_opt.pb"
@@ -79,16 +80,18 @@ def poseDetector(frame, overlay_img):
79
 
80
  length = int(np.sqrt((points[idTo][0] - points[idFrom][0])**2 + (points[idTo][1] - points[idFrom][1])**2))
81
  reduced_length = int(length * 0.5)
82
- overlay_resized = cv.resize(overlay_img, (reduced_length, int(overlay_img.shape[0] * 0.5)))
83
 
84
- M = cv.getRotationMatrix2D((overlay_resized.shape[1] / 2, overlay_resized.shape[0] / 2), adjusted_angle, 1)
85
- overlay_rotated = cv.warpAffine(overlay_resized, M, (overlay_resized.shape[1], overlay_resized.shape[0]), flags=cv.INTER_LINEAR, borderMode=cv.BORDER_CONSTANT, borderValue=(0, 0, 0, 0))
86
 
87
- wrist_position = points[idTo]
88
- position = (int(wrist_position[0] - overlay_rotated.shape[1] / 2), int(wrist_position[1] - overlay_rotated.shape[0] / 2))
89
 
90
- alpha_mask = overlay_rotated[:, :, 3] / 255.0
91
- overlay_image_alpha(frame, overlay_rotated[:, :, :3], position, alpha_mask)
 
 
 
92
 
93
  t, _ = net.getPerfProfile()
94
  return frame
 
1
  import streamlit as st
2
  import cv2 as cv
3
  import numpy as np
4
+ import tempfile
5
 
6
  # Paths to your files
7
  model_path = "graph_opt.pb"
 
80
 
81
  length = int(np.sqrt((points[idTo][0] - points[idFrom][0])**2 + (points[idTo][1] - points[idFrom][1])**2))
82
  reduced_length = int(length * 0.5)
 
83
 
84
+ if reduced_length > 0 and overlay_img.shape[0] * 0.5 > 0:
85
+ overlay_resized = cv.resize(overlay_img, (reduced_length, int(overlay_img.shape[0] * 0.5)))
86
 
87
+ M = cv.getRotationMatrix2D((overlay_resized.shape[1] / 2, overlay_resized.shape[0] / 2), adjusted_angle, 1)
88
+ overlay_rotated = cv.warpAffine(overlay_resized, M, (overlay_resized.shape[1], overlay_resized.shape[0]), flags=cv.INTER_LINEAR, borderMode=cv.BORDER_CONSTANT, borderValue=(0, 0, 0, 0))
89
 
90
+ wrist_position = points[idTo]
91
+ position = (int(wrist_position[0] - overlay_rotated.shape[1] / 2), int(wrist_position[1] - overlay_rotated.shape[0] / 2))
92
+
93
+ alpha_mask = overlay_rotated[:, :, 3] / 255.0
94
+ overlay_image_alpha(frame, overlay_rotated[:, :, :3], position, alpha_mask)
95
 
96
  t, _ = net.getPerfProfile()
97
  return frame