dschandra commited on
Commit
c0caffc
·
verified ·
1 Parent(s): c03a5f7

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +20 -10
utils.py CHANGED
@@ -1,11 +1,21 @@
1
- import cv2
2
- import numpy as np
3
-
4
- def draw_boxes(frame, detections, class_names):
5
- for x1, y1, x2, y2, conf, cls_id in detections:
6
- label = class_names[int(cls_id)]
7
- color = (0, 255, 0) if label == 'ball' else (255, 0, 0)
8
- cv2.rectangle(frame, (int(x1), int(y1)), (int(x2), int(y2)), color, 2)
9
- cv2.putText(frame, f"{label} {conf:.2f}", (int(x1), int(y1) - 5),
10
- cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)
 
 
 
 
 
 
 
 
 
 
11
  return frame
 
1
+ def overlay_decision_text(frame, impact_point, hit_stumps, has_impact):
2
+ decision = "NOT OUT"
3
+ color = (0, 255, 0)
4
+
5
+ if has_impact and hit_stumps:
6
+ decision = "OUT"
7
+ color = (0, 0, 255)
8
+
9
+ cv2.putText(frame, f"LBW DECISION: {decision}", (50, 150), cv2.FONT_HERSHEY_SIMPLEX, 2, color, 5)
10
+
11
+ if has_impact:
12
+ cv2.putText(frame, "✔️ Impact Detected", (50, 250), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
13
+ else:
14
+ cv2.putText(frame, "❌ No Pad Impact", (50, 250), cv2.FONT_HERSHEY_SIMPLEX, 1, (100, 100, 100), 2)
15
+
16
+ if hit_stumps:
17
+ cv2.putText(frame, "✔️ Ball Would Hit Stumps", (50, 300), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
18
+ else:
19
+ cv2.putText(frame, "❌ Ball Missed Stumps", (50, 300), cv2.FONT_HERSHEY_SIMPLEX, 1, (100, 100, 100), 2)
20
+
21
  return frame