An Android application that detects hand rotation movements (clockwise/counter-clockwise) via the phone's camera to control system volume. This allows for touch-free operation, specifically designed for safe use while driving.
β Real-time Hand Rotation Recognition
- Powered by MediaPipe for high-precision hand tracking.
- Detects clockwise and counter-clockwise rotation.
- Noise filtering and false-positive prevention logic.
β Volume Control
- Seamlessly increases/decreases system audio levels.
- Stable and responsive feedback.
- Built-in 500ms cooldown to prevent excessive triggers.
β Background Operation
- Runs as a Foreground Service with a persistent Notification.
- Dynamic notification updates.
- Pause/Resume functionality from the UI or notification.
β Driving Detection
- Real-time GPS monitoring.
- Automatically activates monitoring when speed exceeds 5 km/h.
- Pauses monitoring when stationary to save resources.
β User Interface
- Simple and intuitive UI.
- Comprehensive permission management guide.
- Master On/Off toggle and Pause/Resume controls.
βββββββββββββββββββββββββββββββββββββββββββ
β MainActivity (UI) β
βββββββββββββββββββββββββββββββββββββββββββ€
β β
β βββββββββββββββββββββββββββββββββββ β
β β HandGestureService β β
β β (Foreground Service) β β
β βββββββββββββββββββββββββββββββββββ€ β
β β β’ CameraX (Image Analysis) β β
β β β’ HandDetector (MediaPipe) β β
β β β’ RotationDetector β β
β β β’ VolumeController β β
β β β’ DrivingModeDetector (GPS) β β
β βββββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββ
- HandDetector.kt: Handles hand landmark detection using MediaPipe.
- RotationDetector.kt: Calculates rotation direction using geometric angle analysis.
- VolumeController.kt: Interfaces with Android's AudioManager.
- DrivingModeDetector.kt: Monitors speed and movement via GPS.
- MainActivity.kt: The main entry point and user interface.
- HandGestureService.kt: Manages background lifecycle and camera analysis.
- activity_main.xml: Application layout definition.
- AndroidManifest.xml: App declarations, services, and permissions.
- build.gradle: Dependencies and build configurations.
- strings.xml: Localization and UI text.
compileSdk 34
minSdk 26
targetSdk 34// CameraX - for camera access
implementation "androidx.camera:camera-core:1.3.0"
implementation "androidx.camera:camera-lifecycle:1.3.0"
// MediaPipe - for hand detection
implementation "com.google.mediapipe:solution-core:latest_version"
implementation "com.google.mediapipe:tasks-vision:latest_version"
// Android & Lifecycle
implementation "androidx.lifecycle:lifecycle-service:2.6.1"
implementation "androidx.appcompat:appcompat:1.6.1"| Permission | Purpose |
|---|---|
CAMERA |
Accessing the front camera for gesture recognition. |
ACCESS_FINE_LOCATION |
Accurate speed detection for Driving Mode. |
ACCESS_COARSE_LOCATION |
Fallback for network-based location. |
FOREGROUND_SERVICE |
Keeping the app active in the background. |
ACCESS_NOTIFICATION_POLICY |
System-level volume adjustment permissions. |
git clone https://github.com/PROL3/VoluMotion
cd VoluMotion- π· Camera
- π Location
- π Notifications
- Open the app and toggle the Master Switch to ON.
- Position your hand in front of the front camera.
- Rotate Right (CW): Volume Up β
- Rotate Left (CCW): Volume Down β
Camera Stream β MediaPipe β 21 Hand Landmarks
Landmarks β Calculate relative angles of fingers around the palm center.
Compare Previous Angles vs. Current Angles β Determine Direction & Speed.
- Motion Buffer: Analyzes a 10-frame window.
- Confidence: Requires a minimum threshold of 0.6.
- Cooldown: 500ms delay between actions to ensure stability.
private val bufferSize = 10 // Window size for average calculation
private const val threshold = 2f // Minimum degrees to trigger rotationprivate val rotationCooldown = 500L // Delay in milliseconds between volume stepslocationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
1000, // 1 second interval
10f, // 10 meters distance interval
locationListener
)- CPU Efficiency: Single
ImageAnalysispipeline with GPU acceleration via MediaPipe. - Battery Conservation: Uses a
LOWimportance Foreground Service and smart GPS polling intervals. - Memory Management: Optimized Bitmap recycling and limited landmark buffers.
- CameraX Strategy: Uses
KEEP_ONLY_LATESTbackpressure strategy to prevent lag.
| Issue | Solution |
|---|---|
| Hand not detected | Ensure adequate lighting and distance (30-50 cm from camera). |
| Too many false positives | Increase bufferSize (e.g., to 20) or increase the threshold. |
| Service stops in background | Check battery optimization settings and ensure FOREGROUND_SERVICE permission is granted. |
| High battery drain | Ensure GPS is set to "While using app" or increase minTime in GPS updates. |
Monitor the app's behavior via Logcat:
adb logcat | grep -E "HandDetector|RotationDetector|VolumeController|DrivingMode"- Add support for additional gestures (Swipe, Pinch).
- Implement haptic/vibration feedback.
- Multilingual support (Hebrew, Spanish, etc.).
- Simultaneous left and right-hand support.
- ML-based custom gesture training.
- Customizable keybindings (e.g., Skip Track).
This project integrates Google's MediaPipe solutions. Please refer to the MediaPipe license for core vision task usage.
Created with β€οΈ for touchless volume control while driving.
