How ironpateli/gesture-controlled-desktop-assistant- works
Purpose and Entry Points
Gesture Assistant is a Windows desktop utility that turns webcam hand gestures into configurable OS/media actions. The normal entry point is the persistent system-tray process in tray.py; it owns recognition lifecycle, preview visibility, configuration access, startup integration, and clean shutdown. Direct development entry points are main.py for the camera/inference engine and config_gui.py for settings.
Grounding: tray.py, main.py, config_gui.py.
Tray Process and Windows Lifecycle
The tray layer starts idle to minimize resource use, enforces a single instance through a named Windows mutex, and exposes start/stop recognition, preview, configuration, startup, and exit controls. It communicates state to the user through Windows notifications. Windows-specific startup shortcuts and registry integration are separated from the recognition engine.
Grounding: tray.py, windows_integration.py, setup_shortcuts.py.
Live Recognition Pipeline
When enabled, the camera engine lazily loads OpenCV/MediaPipe, captures webcam frames, extracts MediaPipe’s 21 hand landmarks, and accumulates normalized 20-frame sequences. Pose coordinates are wrist-relative and scale-normalized; handedness is normalized by mirroring left-hand poses, while wrist movement remains available for motion classification. Preview rendering is optional and recognition continues without it.
Grounding: main.py, runtime_model.py, gesture_model_runtime.npz.
Model Inference and Rejection Boundary
The packaged runtime deliberately avoids PyTorch: main.py loads the exported NumPy parameter archive and runs the one-layer LSTM implemented in runtime_model.py. Predictions are rejected when classified as none or below the confidence threshold, forming the boundary between noisy visual inference and OS side effects. The runtime artifact is bundled read-only with the application; user-writable data belongs under %LOCALAPPDATA%\GestureAssistant.
Grounding: main.py, runtime_model.py, gesture_model_runtime.npz.
Action Gating and Dispatch
Recognized gestures pass through a monotonic-clock timing gate before dispatch. action_timing.py applies action-category cooldowns, release-to-rearm behavior for one-shot static gestures, and longer protection for app/script launches; this makes behavior independent of camera FPS. actions.py then reloads gesture mappings during operation, blocks disabled gestures, and executes built-in controls, keyboard shortcuts, executables, URIs, or scripts.
Grounding: action_timing.py, actions.py, main.py.
User Configuration and Application Discovery
The Tkinter configuration editor manages gesture enablement and mappings stored in a user configuration file. Configuration is intentionally live-read so edits do not require restarting recognition. Application-oriented selection/discovery is isolated from the editor and execution layers, including Start Menu discovery and caching.
Grounding: config_gui.py, actions.py, app_discovery.py.
Training-to-Runtime Delivery Pipeline
Development data collection records labeled 20×21×3 landmark sequences. Training uses a PyTorch LSTM checkpoint, then exports weights to the NumPy runtime archive and validates inference parity. This separates heavyweight ML tooling from the distributed runtime. Legacy detector/model assets under archive/phase1 are retained only as historical artifacts and are not part of active execution.
Grounding: collect_data.py, train_classifier.py, export_runtime_model.py.
Packaging and Infrastructure
The target runtime is Windows 10/11 with a webcam, Python during development, and bundled dependencies for end users. PyInstaller packaging creates the executable distribution; Inno Setup creates a per-user installer. Build scripts package the runtime model and application assets while excluding training-only dependencies such as PyTorch from deployment.
Grounding: build_app.ps1, build_installer.ps1, installer/GestureAssistant.iss.
Main entry points: tray.py Tray process · main.py Camera & recognition · gesture_model_runtime.npz Runtime model archive · config_gui.py Settings editor
Components 18
Desktop Runtime
Persistent Windows utility and live gesture path.
- Tray process · Owns recognition lifecycle, preview, startup, and shutdown.
tray.py - Windows integration · Provides mutex, notifications, startup shortcuts, and registry integration.
windows_integration.py - Shortcut setup
setup_shortcuts.py - Camera & recognition · Captures frames, extracts landmarks, and runs optional preview.
main.py - NumPy LSTM runtime · Runs exported one-layer LSTM inference without PyTorch.
runtime_model.py - Runtime model archive · Bundled read-only model parameters.
gesture_model_runtime.npz - Action timing gate · Applies cooldowns and release-to-rearm before side effects.
action_timing.py - Action dispatcher · Live-reloads mappings and executes enabled gesture actions.
actions.py
Configuration
User-editable mappings and application selection.
- Settings editor · Edits gesture enablement and mappings.
config_gui.py - Application discovery · Discovers and caches Start Menu applications.
app_discovery.py - User configuration · Stored under %LOCALAPPDATA%\GestureAssistant.
Model Delivery
Development training exports the lightweight runtime model.
- Landmark collection · Records labeled 20×21×3 landmark sequences.
collect_data.py - PyTorch training · Trains the development LSTM checkpoint.
train_classifier.py - Runtime model export · Exports NumPy weights and validates inference parity.
export_runtime_model.py
Packaging
Windows executable and installer delivery.
- PyInstaller build · Bundles runtime dependencies and application assets.
build_app.ps1 - Installer build · Builds the per-user Windows installer.
build_installer.ps1 - Inno Setup installer
installer/GestureAssistant.iss - Windows 10/11 + webcam
Connections 17
- Tray process → Windows integration: uses
- Tray process → Shortcut setup: manages startup
- Tray process → Camera & recognition: starts / stops
- Camera & recognition → NumPy LSTM runtime: runs inference
- NumPy LSTM runtime → Runtime model archive: loads parameters
- Camera & recognition → Action timing gate: accepted gestures · Rejects none and low-confidence predictions first.
- Action timing gate → Action dispatcher: gated actions
- Settings editor → User configuration: writes
- Action dispatcher → User configuration: live reads
- Settings editor → Application discovery: selects applications
- Landmark collection → PyTorch training: training sequences
- PyTorch training → Runtime model export: PyTorch checkpoint
- Runtime model export → Runtime model archive: exports
- PyInstaller build → Runtime model archive: bundles
- PyInstaller build → Installer build: produces app payload
- Installer build → Inno Setup installer: uses definition
- Inno Setup installer → Windows 10/11 + webcam: installs on