Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,6 @@ def detect_faults(frame, results):
|
|
31 |
conf = box.conf[0]
|
32 |
cls = int(box.cls[0])
|
33 |
|
34 |
-
# Simulated intensity-based fault logic
|
35 |
roi = frame[y1:y2, x1:x2]
|
36 |
if roi.size == 0:
|
37 |
continue
|
@@ -48,8 +47,16 @@ def detect_faults(frame, results):
|
|
48 |
else:
|
49 |
continue
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
cv2.rectangle(annotated_frame, (x1, y1), (x2, y2), color, 2)
|
52 |
-
cv2.putText(annotated_frame, label, (x1, y1 - 10),
|
|
|
53 |
|
54 |
if faults["Thermal Fault"] or faults["Dust Fault"]:
|
55 |
faults["Power Generation Fault"] = True
|
|
|
31 |
conf = box.conf[0]
|
32 |
cls = int(box.cls[0])
|
33 |
|
|
|
34 |
roi = frame[y1:y2, x1:x2]
|
35 |
if roi.size == 0:
|
36 |
continue
|
|
|
47 |
else:
|
48 |
continue
|
49 |
|
50 |
+
# Transparent overlay
|
51 |
+
overlay = annotated_frame.copy()
|
52 |
+
alpha = 0.3
|
53 |
+
cv2.rectangle(overlay, (x1, y1), (x2, y2), color, -1)
|
54 |
+
cv2.addWeighted(overlay, alpha, annotated_frame, 1 - alpha, 0, annotated_frame)
|
55 |
+
|
56 |
+
# Border and label
|
57 |
cv2.rectangle(annotated_frame, (x1, y1), (x2, y2), color, 2)
|
58 |
+
cv2.putText(annotated_frame, f"{label} ({mean_intensity:.1f})", (x1, y1 - 10),
|
59 |
+
cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
|
60 |
|
61 |
if faults["Thermal Fault"] or faults["Dust Fault"]:
|
62 |
faults["Power Generation Fault"] = True
|