This project implements a laser point tracking system using a webcam to control the mouse cursor on the screen. The system detects a red laser point in the webcam feed, maps it to screen coordinates using perspective transformation, and moves the mouse cursor accordingly.
- Hardware:
- A webcam connected to your computer.
- A red laser pointer for tracking.
- Software:
- Python 3.x
- pip (Python package manager)
- OpenCV dependencies (e.g.,
libopencv-devon Ubuntu)
The project requires the following Python packages:
opencv-python: For webcam capture and image processing.numpy: For numerical operations and array handling.pyautogui: For controlling the mouse cursor.
-
Clone or Download the Project: Ensure you have the
laser_tracker.pyscript in the same directory. -
Install System Dependencies (if needed): On Ubuntu/Debian, install OpenCV dependencies:
sudo apt-get install libopencv-dev
-
Run the Script: Run the script directly:
python3 laser_tracker.py
-
Select Four Points:
- A window will display the webcam feed.
- Double-click to select four points in the following order: top left, top right, bottom left, bottom right.
- These points define the region in the webcam feed to map to the screen.
-
Track the Laser Point:
- Point a red laser at the selected region.
- The script will detect the laser point and move the mouse cursor to the corresponding screen coordinates.
- A window (
Track Laser) will show the transformed video feed with the detected laser point marked.
-
Exit:
- Press the
Esckey to exit the program.
- Press the