Spaces:
Sleeping
Sleeping
Update table_occupancy.py
Browse files- table_occupancy.py +4 -2
table_occupancy.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import cv2
|
|
|
|
| 2 |
|
| 3 |
def is_table_occupied(image):
|
| 4 |
-
#
|
|
|
|
| 5 |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 6 |
nonzero = cv2.countNonZero(gray)
|
| 7 |
-
return nonzero > 20000
|
|
|
|
| 1 |
import cv2
|
| 2 |
+
import numpy as np
|
| 3 |
|
| 4 |
def is_table_occupied(image):
|
| 5 |
+
# Convert image to grayscale and count non-zero pixels
|
| 6 |
+
# This is a simple heuristic to detect if a table is occupied
|
| 7 |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 8 |
nonzero = cv2.countNonZero(gray)
|
| 9 |
+
return nonzero > 20000 # Threshold can be adjusted based on testing
|