CosmickVisions commited on
Commit
018b556
Β·
verified Β·
1 Parent(s): c6ab0b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -559,7 +559,7 @@ class VideoProcessor(VideoProcessorBase):
559
 
560
  # Draw box (skip if tracking is enabled, as tracker will draw boxes)
561
  if not self.enable_tracking:
562
- cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
563
 
564
  # Add label with confidence
565
  label_text = f"{label}: {int(confidence * 100)}%"
@@ -584,11 +584,11 @@ class VideoProcessor(VideoProcessorBase):
584
 
585
  # Draw detected faces (skip if tracking is enabled)
586
  if not self.enable_tracking:
587
- for face in faces:
588
- x, y, w, h = face["box"]
589
-
590
- # Draw box
591
- cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
592
  except Exception as e:
593
  cv2.putText(img, f"Face Detection Error: {str(e)[:30]}",
594
  (10, 120), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 0, 255), 2)
@@ -2221,13 +2221,12 @@ def main():
2221
  if "faces" in detection_stats:
2222
  st.metric("Faces Detected", detection_stats["faces"])
2223
 
2224
- # List with counts
2225
  st.markdown("##### Top Objects")
2226
- for obj, count in list(sorted_objects.items())[:10]:
2227
- st.markdown(f"- **{obj}**: {count} occurrences")
2228
- else:
2229
- st.info("No objects detected in the video.")
2230
-
2231
  with tab2:
2232
  st.markdown("#### πŸ”„ Motion Analysis")
2233
 
 
559
 
560
  # Draw box (skip if tracking is enabled, as tracker will draw boxes)
561
  if not self.enable_tracking:
562
+ cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
563
 
564
  # Add label with confidence
565
  label_text = f"{label}: {int(confidence * 100)}%"
 
584
 
585
  # Draw detected faces (skip if tracking is enabled)
586
  if not self.enable_tracking:
587
+ for face in faces:
588
+ x, y, w, h = face["box"]
589
+
590
+ # Draw box
591
+ cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
592
  except Exception as e:
593
  cv2.putText(img, f"Face Detection Error: {str(e)[:30]}",
594
  (10, 120), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 0, 255), 2)
 
2221
  if "faces" in detection_stats:
2222
  st.metric("Faces Detected", detection_stats["faces"])
2223
 
 
2224
  st.markdown("##### Top Objects")
2225
+ if sorted_objects: # Check if there are any sorted objects
2226
+ for obj, count in list(sorted_objects.items())[:10]:
2227
+ st.markdown(f"- **{obj}**: {count} occurrences")
2228
+ else:
2229
+ st.info("No objects detected in the video.")
2230
  with tab2:
2231
  st.markdown("#### πŸ”„ Motion Analysis")
2232