RyeCatcher commited on
Commit
6d64654
·
verified ·
1 Parent(s): 33de174

fix: lower motion threshold for better presence detection

Browse files
Files changed (1) hide show
  1. 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
- # Higher threshold - ignore small screen changes
131
- # User movement is typically 0.02-0.10, empty room <0.005
132
- MOTION_THRESHOLD = 0.01
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 * 10, 1.0),
140
  yaw=0,
141
  pitch=0
142
  )
143
  else:
144
  self._consecutive_still += 1
145
 
146
- # Grace period - ~3 seconds of stillness allowed
147
- if self._consecutive_still < 6:
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