Update app.py
Browse files
app.py
CHANGED
|
@@ -46,7 +46,19 @@ def process_video(video_path):
|
|
| 46 |
cv2.line(frame, trajectory[i - 1], trajectory[i], (255, 0, 0), 2)
|
| 47 |
|
| 48 |
# Draw stumps box
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
cv2.rectangle(frame, stump_box[:2], stump_box[2:], (0, 255, 255), 2)
|
| 51 |
|
| 52 |
# Draw projected path if enough points collected
|
|
|
|
| 46 |
cv2.line(frame, trajectory[i - 1], trajectory[i], (255, 0, 0), 2)
|
| 47 |
|
| 48 |
# Draw stumps box
|
| 49 |
+
# Automatically scale stump area depending on video height/width
|
| 50 |
+
box_width = int(width * 0.12) # 12% width for stumps
|
| 51 |
+
box_height = int(height * 0.1) # 10% height
|
| 52 |
+
stump_center_x = int(width * 0.5) # Middle of the frame
|
| 53 |
+
stump_top_y = int(height * 0.82) # Bottom 20% of frame (near pitch)
|
| 54 |
+
|
| 55 |
+
stump_box = (
|
| 56 |
+
stump_center_x - box_width // 2,
|
| 57 |
+
stump_top_y,
|
| 58 |
+
stump_center_x + box_width // 2,
|
| 59 |
+
stump_top_y + box_height
|
| 60 |
+
)
|
| 61 |
+
|
| 62 |
cv2.rectangle(frame, stump_box[:2], stump_box[2:], (0, 255, 255), 2)
|
| 63 |
|
| 64 |
# Draw projected path if enough points collected
|