-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
97 lines (80 loc) · 4.6 KB
/
config.py
File metadata and controls
97 lines (80 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"""
Configuration constants for TouchLess.
All tunable parameters are centralized here for easy adjustment.
Modify these values to customize gesture sensitivity, ML behavior, and system performance.
"""
# --- Hand Landmark IDs ---
INDEX_FINGER_TIP_ID = 8
THUMB_TIP_ID = 4
MIDDLE_FINGER_TIP_ID = 12
RING_FINGER_TIP_ID = 16 # 4ème doigt (annulaire)
WRIST_ID = 0
# --- Gesture Detection ---
PINCH_THRESHOLD = 0.22 # Slightly increased for more reliable detection
LONG_PINCH_DURATION = 0.7 # Slightly longer to prevent accidental toggles
CLICK_COOLDOWN = 0.15 # Reduced for more responsive clicking
MODE_TOGGLE_COOLDOWN = 1.5 # Increased to prevent accidental toggles
# --- Scroll Settings ---
SCROLL_THRESHOLD = 0.002 # Threshold for scroll detection (higher = more stable)
SCROLL_SENSITIVITY = 0.3 # Scroll sensitivity (higher = more scroll per movement)
SCROLL_SMOOTHING = 0.5 # Smoothing factor for scroll (0.0 = direct, 1.0 = very smooth)
# --- Work Area ---
# These values are from calibration. If you need to reach screen edges better,
# run calibration.py again and stretch to your maximum reach.
# Or set to 0.0 and 1.0 to use full camera frame (may be less comfortable)
WORK_AREA_LEFT = 0.0 # Left boundary (0.0 = use full camera frame for better edge reach)
WORK_AREA_RIGHT = 1.0 # Right boundary (1.0 = use full camera frame)
WORK_AREA_TOP = 0.0 # Top boundary (0.0 = use full camera frame)
WORK_AREA_BOTTOM = 1.0 # Bottom boundary (1.0 = use full camera frame)
# --- Jitter Filtering ---
JITTER_THRESHOLD = 0.005 # Simple threshold to filter micro-movements
MOVEMENT_STEP_DIVISOR = 10 # Smooth movement divisor
# --- Mouse Movement Enhancement ---
EDGE_AMPLIFICATION = 2.5 # Amplification factor for edge movement (allows reaching edges with less hand movement)
# Higher values = easier to reach screen edges, but may feel less precise in center
# Recommended range: 1.5 - 3.0
# --- Camera Settings ---
CAMERA_WIDTH = 640
CAMERA_HEIGHT = 480
# --- MediaPipe Settings ---
MAX_NUM_HANDS = 1
MIN_DETECTION_CONFIDENCE = 0.6 # Lowered slightly for better performance while maintaining accuracy
MIN_TRACKING_CONFIDENCE = 0.6 # Lowered slightly for better performance while maintaining accuracy
MODEL_COMPLEXITY = 0 # 0=faster/less accurate, 1=balanced, 2=slower/more accurate (set to 0 for better performance)
# --- Intent Engine Settings ---
INTENT_ATTRACTION_STRENGTH = 0.0 # DISABLED - simplified, no attraction
INTENT_MIN_CONFIDENCE = 0.3
INTENT_MAX_DISTANCE = 200.0
INTENT_UPDATE_INTERVAL = 0.5
# --- Screen Detection Settings ---
SCREEN_DETECTION_ENABLED = False # DISABLED - too slow, causes lag (can enable for testing)
SCREEN_ANALYSIS_INTERVAL = 2.0 # How often to analyze screen (seconds) - only if enabled
SCREEN_DETECTION_CONFIDENCE_THRESHOLD = 0.4 # Minimum confidence for detected objects
# --- ML Predictor Settings ---
ML_PREDICTION_HORIZON = 0.05 # Predict 50ms ahead
ML_SMOOTHING_FACTOR = 0.25 # Simple smoothing (25% prediction, 75% direct)
ML_VELOCITY_SMOOTHING = 0.7
ML_ENABLED = True # Simple ML smoothing
# --- Advanced ML Settings ---
ML_ADAPTIVE_ENABLED = False # DISABLED
ML_FAST_SPEED_THRESHOLD = 300.0 # Pixels per second - above this = fast movement
ML_SLOW_SPEED_THRESHOLD = 50.0 # Pixels per second - below this = slow movement
ML_ERROR_THRESHOLD_HIGH = 20.0 # High prediction error (pixels) - triggers adaptation
ML_ERROR_THRESHOLD_LOW = 5.0 # Low prediction error (pixels) - allows more smoothing
ML_GESTURE_LEARNING = False # Learn gesture patterns from user
ML_DECELERATION_THRESHOLD = 50.0 # Speed change threshold for click prediction
ML_CLICK_SPEED_THRESHOLD = 100.0 # Speed threshold for click intent
ML_SCROLL_VARIANCE_THRESHOLD = 1000.0 # Speed variance threshold for scroll intent
# --- Performance Settings ---
FRAME_SKIP = 0 # Skip every N frames for processing (0 = process all frames, 1 = skip every other)
ENABLE_INTENT_CACHE = True # Cache intent engine calculations for performance
# --- Frame Rate & Dynamic Movement Settings (inspired by handTrack) ---
FPS_DETECTION_WINDOW = 30 # Number of frames to average for FPS calculation
LOW_FPS_THRESHOLD = 20.0 # FPS below this triggers dynamic step adjustment
DYNAMIC_STEP_MULTIPLIER = 1.5 # Multiplier for mouse steps at low FPS
MIN_MOVEMENT_STEP = 1.0 # Minimum movement step in pixels
MAX_MOVEMENT_STEP = 50.0 # Maximum movement step in pixels
# --- Advanced Click Detection (inspired by handTrack) ---
HAND_SIZE_CHANGE_THRESHOLD = 0.15 # Relative hand size change to detect pinch (15% reduction)
HAND_SIZE_SMOOTHING = 0.7 # Smoothing factor for hand size tracking
MIN_HAND_SIZE_FOR_TRACKING = 0.05 # Minimum hand size to consider valid tracking