Spaces:
Running
Running
fix: lower motion threshold for better presence detection
Browse files- focus_guardian/main.py +6 -6
focus_guardian/main.py
CHANGED
|
@@ -127,24 +127,24 @@ class GazeDetector:
|
|
| 127 |
avg_motion = sum(self._motion_history) / len(self._motion_history)
|
| 128 |
|
| 129 |
|
| 130 |
-
#
|
| 131 |
-
# User movement is typically 0.
|
| 132 |
-
MOTION_THRESHOLD = 0.
|
| 133 |
|
| 134 |
if avg_motion > MOTION_THRESHOLD:
|
| 135 |
self._consecutive_still = 0
|
| 136 |
return GazeResult(
|
| 137 |
direction=GazeDirection.MONITOR,
|
| 138 |
face_detected=True,
|
| 139 |
-
confidence=min(avg_motion *
|
| 140 |
yaw=0,
|
| 141 |
pitch=0
|
| 142 |
)
|
| 143 |
else:
|
| 144 |
self._consecutive_still += 1
|
| 145 |
|
| 146 |
-
#
|
| 147 |
-
if self._consecutive_still <
|
| 148 |
return GazeResult(GazeDirection.MONITOR, False, 0.3)
|
| 149 |
|
| 150 |
# User gone or very still for too long
|
|
|
|
| 127 |
avg_motion = sum(self._motion_history) / len(self._motion_history)
|
| 128 |
|
| 129 |
|
| 130 |
+
# Lower threshold - detect subtle typing/mouse movements
|
| 131 |
+
# User movement is typically 0.005-0.10, empty room <0.002
|
| 132 |
+
MOTION_THRESHOLD = 0.003
|
| 133 |
|
| 134 |
if avg_motion > MOTION_THRESHOLD:
|
| 135 |
self._consecutive_still = 0
|
| 136 |
return GazeResult(
|
| 137 |
direction=GazeDirection.MONITOR,
|
| 138 |
face_detected=True,
|
| 139 |
+
confidence=min(avg_motion * 20, 1.0),
|
| 140 |
yaw=0,
|
| 141 |
pitch=0
|
| 142 |
)
|
| 143 |
else:
|
| 144 |
self._consecutive_still += 1
|
| 145 |
|
| 146 |
+
# Longer grace period - ~10 seconds of stillness allowed
|
| 147 |
+
if self._consecutive_still < 20:
|
| 148 |
return GazeResult(GazeDirection.MONITOR, False, 0.3)
|
| 149 |
|
| 150 |
# User gone or very still for too long
|