How aabisunhinged/hand-gesture-control works
Purpose and Entry Points
A Windows-oriented desktop gesture-control application. It uses a webcam plus a packaged hand-landmark model to translate detected hand poses into mouse, volume, media, screenshot, and visual-overlay actions.
Primary launch paths:
• hand gesture control/main.py
• hand gesture control/main.pyw for windowed Python launch
• hand gesture control/run.bat for batch-based startup
Application Orchestration
hand gesture control/main.py is the likely runtime coordinator: it gathers detection-confidence input, opens the camera/UI loop, handles keyboard mode switching (1–4, q, s), and routes each frame through tracking and the active gesture mode.
hand gesture control/main.pyw provides an alternate launcher-oriented entry point, likely avoiding a visible console on Windows.
Hand Tracking and Model Boundary
hand gesture control/hand_tracker.py encapsulates webcam-frame hand detection and landmark extraction. It is the boundary between raw camera images and normalized hand/finger landmark data consumed by gesture logic.
The application depends on MediaPipe-style model inference through:
• hand gesture control/hand_landmarker.task
Detection confidence is user-configurable (default 0.5); this tunes the tracker’s sensitivity versus false detections.
Gesture Interpretation and OS Control
hand gesture control/gesture_control.py owns interpretation of landmarks into control commands and likely calls desktop automation APIs. It defines the behavioral boundary between vision-derived coordinates and operating-system effects.
Its mode-specific command flows are:
• Cursor: index-finger position maps to cursor movement; thumb/index pinch triggers click.
• Volume: thumb/index distance maps to system volume.
• Media: finger-state patterns scroll up/down; fist captures a screenshot.
• Global screenshot: keyboard s triggers capture independently of mode.
Mode State Machine
The runtime maintains one of four active modes. Input can transition mode directly via numeric keys or cyclically through a right-hand gesture with four or more raised fingers. A closed-hand reset prevents repeated transitions while the gesture remains visible.
Relevant coordination paths:
• hand gesture control/main.py
• hand gesture control/gesture_control.py
• hand gesture control/hand_tracker.py
Visual Rectangle/X-Ray Mode
Rectangle mode is a frame-rendering pipeline rather than an OS-control action. When both hands expose thumbs and index fingers, their landmarks define a rectangular region. The app composites an inverted, blue-tinted camera view inside that region while retaining the normal camera image outside, then draws scan-line and corner-bracket effects.
This stage depends on tracker output and is likely rendered in the main camera display loop:
• hand gesture control/main.py
• hand gesture control/hand_tracker.py
Runtime and Platform Assumptions
The project is a local Python desktop process requiring:
• Webcam access
• A GUI/video display runtime
• Mouse/keyboard/screenshot automation permissions
• Windows-compatible volume and window behavior, suggested by .pyw and run.bat
User-facing operating notes and launch guidance reside in:
• hand gesture control/README BEFORE USING.txt
Components 15
Launch
- Runtime coordinator · Runs the camera loop, mode input, and frame routing.
hand gesture control/main.py - Windowed launcher · Launches the application without a Windows console.
hand gesture control/main.pyw - Batch launcher
hand gesture control/run.bat - Operating notes · Provides setup and launch guidance.
Vision Pipeline
- Webcam frames
- Hand tracker · Converts camera frames into hand and finger landmarks.
hand gesture control/hand_tracker.py - Hand landmark model · MediaPipe-style hand landmark inference asset.
hand gesture control/hand_landmarker.task - Hand landmarks
Gesture Control
- Gesture interpreter · Maps landmark patterns and distances to desktop commands.
hand gesture control/gesture_control.py - Four-mode state · Keyboard and raised-finger gestures select the active mode.
Desktop & Display
- Cursor and click · Maps index position to cursor movement and pinch to click.
- Volume, media, screenshot · Applies distance and finger-state commands to OS controls.
- X-ray rectangle renderer · Renders an inverted blue region with scan-line and corner effects.
hand gesture control/main.py - Camera display
- Windows desktop APIs · Requires mouse, keyboard, screenshot, and volume permissions.
Connections 20
- Windowed launcher → Runtime coordinator: windowed launch
- Batch launcher → Runtime coordinator: starts
- Operating notes → Runtime coordinator: documents launch
- Webcam frames → Hand tracker: frames
- Hand landmark model → Hand tracker: inference model
- Runtime coordinator → Hand tracker: configures confidence and reads frames
- Hand tracker → Hand landmarks: extracts
- Hand landmarks → Gesture interpreter: hand coordinates
- Runtime coordinator → Four-mode state: keyboard input 1–4
- Gesture interpreter → Four-mode state: raised-finger transition and reset
- Four-mode state → Gesture interpreter: selects active behavior
- Gesture interpreter → Cursor and click: cursor mode
- Gesture interpreter → Volume, media, screenshot: volume and media modes
- Runtime coordinator → Volume, media, screenshot: global s screenshot
- Cursor and click → Windows desktop APIs: mouse automation
- Volume, media, screenshot → Windows desktop APIs: system control
- Hand landmarks → X-ray rectangle renderer: two-hand rectangle
- Runtime coordinator → X-ray rectangle renderer: routes rectangle mode frames
- X-ray rectangle renderer → Camera display: composited frame
- Runtime coordinator → Camera display: normal display loop