This Python application utilizes a webcam to detect the presence of people and plays music when a person is detected. The music continues to play in a loop as long as a person is present in the frame. Once no person is detected, the music stops. The application also features functionality to dynamically handle file paths and manage virtual environments.
- Real-time person detection using OpenCV.
- Music playback controlled by Pygame.
- Dynamic handling of script paths with batch and shell scripts.
- Virtual environment support for isolated package management.
- Python 3.x
- OpenCV
- Pygame
- Ultralytics YOLOv8
- Clone this repository:
git clone https://github.com/idoalit/webcam-music-detector.git
- Navigate to the project directory:
cd webcam-music-detector
- Create and activate a virtual environment:
python -m venv venv venv\Scripts\activate
- Install the required packages:
pip install -r requirements.txt
-
Run the script:
python music.py
or use Yolo instead
python yolo.py
-
To stop the running script, use the provided
stop.bat
file.
start.bat
: Activates the virtual environment and runs the Python script.stop.bat
: Closes any running Python scripts.