Skip to content

thejasvims007/mouse_cursor_control_using_eye

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฎ Eye Controlled Cursor Using Python

Control YouTube with your face and voice! An enhanced version of FaceMouse that integrates facial gesture control with YouTube playback control and voice commands.

OpenCV Selenium

โœจ Features

๐ŸŽฏ Facial Gesture Control

  • Head Movement: Control mouse cursor by moving your head
  • Eye Blinks: Different blink patterns control different actions
  • Real-time Processing: Smooth, responsive facial tracking

๐ŸŽฌ YouTube Control

  • Play/Pause: Toggle video playback
  • Volume Control: Increase/decrease volume
  • Video Navigation: Next/previous video, seek forward/backward
  • Video Controls: Like, subscribe, fullscreen toggle
  • Settings Access: Open YouTube settings menu

๐ŸŽค Voice Commands

  • Playback: "play", "pause", "stop"
  • Audio: "mute", "unmute", "volume up", "volume down"
  • Navigation: "next", "previous", "forward", "backward"
  • Interface: "fullscreen", "settings", "like", "subscribe"

๐Ÿ”„ Dual Mode System

  • Mouse Mode: Traditional mouse control with facial gestures
  • YouTube Mode: YouTube-specific controls with voice commands

๐Ÿ“‹ System Requirements

Hardware Requirements

  • Webcam: Any standard webcam (built-in or external)
  • Microphone: For voice commands
  • Internet Connection: For YouTube access and model download
  • Minimum RAM: 4GB (8GB recommended)
  • Processor: Intel i3 or equivalent (i5+ recommended)

Software Requirements

  • Operating System: Windows 10/11, macOS, or Linux
  • Python: 3.8 or higher
  • Chrome Browser: Latest version (for YouTube control)
  • Visual C++ Redistributable: For Windows users

๐Ÿš€ Quick Start (3-Command Setup)

Command 1: Install Python Dependencies

pip install -r requirements.txt

Command 2: Download Facial Recognition Model

# Download the facial landmark model
curl -O http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2

# Decompress the model
python -c "import bz2; data = bz2.decompress(open('shape_predictor_68_face_landmarks.dat.bz2', 'rb').read()); open('shape_predictor_68_face_landmarks.dat', 'wb').write(data); print('โœ… Model downloaded and decompressed successfully!')"

Command 3: Run FaceMouse YouTube Controller

python face_mouse_youtube.py

๐Ÿ“ Project Files

FaceMouse-YouTube/
โ”œโ”€โ”€ face_mouse_youtube.py      # Main application (enhanced with YouTube control)
โ”œโ”€โ”€ youtube_controller.py      # YouTube control module
โ”œโ”€โ”€ test_youtube_controller.py # Test script for YouTube functionality
โ”œโ”€โ”€ requirements.txt           # Python dependencies
โ”œโ”€โ”€ README.md                  # This file
โ”œโ”€โ”€ shape_predictor_68_face_landmarks.dat  # Facial landmark model (99MB)
โ””โ”€โ”€ shape_predictor_68_face_landmarks.dat.bz2  # Compressed model file

๐ŸŽฎ Usage Guide

Starting the Application

python face_mouse_youtube.py

Keyboard Controls

  • h - Show help menu
  • y - Toggle YouTube mode ON/OFF
  • q - Quit application

Mouse Mode Gestures (Default Mode)

  • 1 Blink โ†’ Left Click
  • 2 Blinks โ†’ Double Click
  • 3 Blinks โ†’ Mouse Down (Drag)
  • 4+ Blinks โ†’ Right Click

YouTube Mode Gestures (Press 'y' to activate)

  • 1 Blink โ†’ Play/Pause video
  • 2 Blinks โ†’ Next video
  • 3 Blinks โ†’ Mute/Unmute
  • 4 Blinks โ†’ Fullscreen toggle
  • 5 Blinks โ†’ Like video
  • 6 Blinks โ†’ Volume up
  • 7 Blinks โ†’ Volume down
  • 8+ Blinks โ†’ Subscribe

Voice Commands (YouTube Mode)

  • "play" - Start/resume playback
  • "pause" - Pause playback
  • "mute" - Mute audio
  • "unmute" - Unmute audio
  • "volume up" - Increase volume
  • "volume down" - Decrease volume
  • "next" - Next video
  • "previous" - Previous video
  • "fullscreen" - Toggle fullscreen
  • "like" - Like current video
  • "subscribe" - Subscribe to channel
  • "settings" - Open settings menu

๐Ÿ”ง Detailed Setup Instructions

Step 1: Install Python

  1. Download Python 3.8+ from python.org
  2. During installation, check "Add Python to PATH"
  3. Verify installation: python --version

Step 2: Install Dependencies

# Upgrade pip first
python -m pip install --upgrade pip

# Install all required packages
pip install -r requirements.txt

Step 3: Download Facial Recognition Model

# Download compressed model (64MB)
curl -O http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2

# Decompress model (creates 99MB .dat file)
python -c "import bz2; data = bz2.decompress(open('shape_predictor_68_face_landmarks.dat.bz2', 'rb').read()); open('shape_predictor_68_face_landmarks.dat', 'wb').write(data); print('โœ… Model decompressed successfully!')"

Step 4: Verify Installation

# Test core dependencies
python -c "import cv2, dlib, mouse, numpy as np, scipy; print('โœ… Core dependencies working!')"

# Test YouTube controller
python -c "from youtube_controller import YouTubeController; print('โœ… YouTube controller ready!')"

# Test audio system
python -c "import pygame; pygame.mixer.init(); print('โœ… Audio system working!')"

Step 5: Run Application

python face_mouse_youtube.py

๐Ÿ› Troubleshooting

Common Issues & Solutions

1. Camera Not Working

# Check available cameras
python -c "import cv2; print([i for i in range(5) if cv2.VideoCapture(i).isOpened()])"

# Try different camera index in code (change cv2.VideoCapture(0) to cv2.VideoCapture(1))

2. Chrome Driver Issues

# Install Chrome driver manually
python -c "from webdriver_manager.chrome import ChromeDriverManager; print(ChromeDriverManager().install())"

# Or update Chrome to latest version

3. Audio/Microphone Issues

# Test microphone
python -c "import speech_recognition as sr; sr.Microphone().list_microphone_names()"

# Install PyAudio dependencies for Windows
pip install pipwin
pipwin install pyaudio

4. Permission Errors

# Run as administrator (Windows)
# Or check antivirus settings

5. Import Errors

# Reinstall specific package
pip uninstall package_name
pip install package_name

# Clear pip cache
pip cache purge

Error Messages & Solutions

Error Solution
No module named 'dlib' pip install dlib
No module named 'selenium' pip install selenium
Chrome driver not found pip install webdriver-manager
Microphone not working pip install pyaudio
OpenCV camera error Check camera permissions/connections
Model file not found Download and decompress the facial model

โš™๏ธ Configuration

Adjust Sensitivity

Edit these values in face_mouse_youtube.py:

sclFact = 6          # Cursor movement sensitivity (default: 6)
EYE_AR_THRESH = 0.20 # Blink detection threshold (default: 0.20)

Camera Settings

vs = cv2.VideoCapture(0)  # Change 0 to 1, 2, etc. for different cameras

Chrome Options

Edit youtube_controller.py for browser preferences:

chrome_options.add_argument("--start-maximized")  # Window size
chrome_options.add_argument("--disable-gpu")      # Performance

๐Ÿ“Š Performance Tips

For Better Performance

  1. Good Lighting: Ensure well-lit environment
  2. Stable Position: Sit at consistent distance from camera
  3. Reduce Background Movement: Minimize distractions behind you
  4. Close Other Applications: Free up system resources
  5. Use External Webcam: Better quality than built-in cameras

System Optimization

# Update graphics drivers
# Close unnecessary background applications
# Use SSD storage for better I/O performance

๐Ÿ”ฎ Advanced Features

Custom Gestures

Modify gesture mappings in youtube_controller.py:

self.gesture_commands = {
    1: 'play_pause',      # 1 blink = play/pause
    2: 'next',            # 2 blinks = next video
    # Add your custom gestures here
}

Voice Command Languages

# Add language support in youtube_controller.py
recognizer.recognize_google(audio, language='en-US')  # English
recognizer.recognize_google(audio, language='es-ES')  # Spanish

๐Ÿ“ž Support & Help

Getting Help

  1. Check the troubleshooting section above
  2. Verify all dependencies are installed
  3. Test individual components before full integration
  4. Check console output for specific error messages

Common Questions

  • Q: Can I use it without a camera?
    • A: The facial gestures require a camera, but voice commands work without camera
  • Q: Does it work on Mac/Linux?
    • A: Yes, with appropriate dependencies installed
  • Q: Can I customize the gestures?
    • A: Yes, modify the gesture mappings in the code

๐Ÿ“„ License

This project is based on the original FaceMouse project. Please refer to the original license terms.

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

๐ŸŽฎ Enjoy hands-free YouTube control with FaceMouse!

Made with โค๏ธ for the computer vision and automation community


๐Ÿ“ Quick Reference

3-Command Setup:

pip install -r requirements.txt
curl -O http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
python -c "import bz2; data = bz2.decompress(open('shape_predictor_68_face_landmarks.dat.bz2', 'rb').read()); open('shape_predictor_68_face_landmarks.dat', 'wb').write(data); print('โœ… Setup complete!')"

Run Application:

python face_mouse_youtube.py

Controls:

  • Press 'y' โ†’ YouTube mode
  • Press 'h' โ†’ Help
  • Press 'q' โ†’ Quit

About

a nice project of mouse control using python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages