Spaces:
Sleeping
Sleeping
Update detect_people.py
Browse files- detect_people.py +5 -3
detect_people.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
import cv2
|
|
|
|
| 2 |
|
| 3 |
def detect_people_from_image(image):
|
|
|
|
| 4 |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 5 |
height, width = gray.shape
|
| 6 |
-
#
|
| 7 |
if cv2.countNonZero(gray) > (height * width * 0.2):
|
| 8 |
-
return 3 #
|
| 9 |
-
return 1
|
|
|
|
| 1 |
import cv2
|
| 2 |
+
import numpy as np
|
| 3 |
|
| 4 |
def detect_people_from_image(image):
|
| 5 |
+
# Convert image to grayscale
|
| 6 |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 7 |
height, width = gray.shape
|
| 8 |
+
# Simple heuristic: count non-zero pixels to simulate people detection
|
| 9 |
if cv2.countNonZero(gray) > (height * width * 0.2):
|
| 10 |
+
return 3 # Simulate 3 people detected
|
| 11 |
+
return 1 # Simulate 1 person detected
|