Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,8 +34,10 @@ def detect_faults(frame, results, frame_idx, fps):
|
|
| 34 |
roi = frame[y1:y2, x1:x2]
|
| 35 |
if roi.size == 0:
|
| 36 |
continue
|
|
|
|
| 37 |
mean_intensity = np.mean(roi)
|
| 38 |
-
|
|
|
|
| 39 |
if mean_intensity > 240:
|
| 40 |
label = "Burned Solar Panel" if area >= 10000 else "Burned Solar Cell"
|
| 41 |
color = (0, 0, 255)
|
|
@@ -49,14 +51,14 @@ def detect_faults(frame, results, frame_idx, fps):
|
|
| 49 |
continue
|
| 50 |
|
| 51 |
timestamp = round(frame_idx / fps, 2)
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
})
|
| 59 |
-
|
| 60 |
|
| 61 |
cv2.rectangle(annotated_frame, (x1, y1), (x2, y2), color, 2)
|
| 62 |
cv2.putText(annotated_frame, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
|
|
|
|
| 34 |
roi = frame[y1:y2, x1:x2]
|
| 35 |
if roi.size == 0:
|
| 36 |
continue
|
| 37 |
+
|
| 38 |
mean_intensity = np.mean(roi)
|
| 39 |
+
area = (x2 - x1) * (y2 - y1)
|
| 40 |
+
|
| 41 |
if mean_intensity > 240:
|
| 42 |
label = "Burned Solar Panel" if area >= 10000 else "Burned Solar Cell"
|
| 43 |
color = (0, 0, 255)
|
|
|
|
| 51 |
continue
|
| 52 |
|
| 53 |
timestamp = round(frame_idx / fps, 2)
|
| 54 |
+
faults_found.append({
|
| 55 |
+
"Frame": frame_idx,
|
| 56 |
+
"Time (s)": timestamp,
|
| 57 |
+
"Fault Type": label,
|
| 58 |
+
"Confidence": round(float(box.conf[0]), 2) if box.conf is not None else None,
|
| 59 |
+
"Intensity": round(mean_intensity, 2),
|
| 60 |
+
"Box": f"({x1}, {y1}, {x2}, {y2})"
|
| 61 |
+
})
|
| 62 |
|
| 63 |
cv2.rectangle(annotated_frame, (x1, y1), (x2, y2), color, 2)
|
| 64 |
cv2.putText(annotated_frame, label, (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
|