Project Level: Real-World
This project is designed for learners who know Python fundamentals and are learning to build real-world programs.
Project Description
Ever wanted to play an air guitar for real? This project uses hand tracking to detect strumming and play guitar sounds based on your movement. The program is built 100% in Python using the OpenCV and the Mediapipe libraries for image and hand movement detection. The program starts the computer webcam and waits for hand movements. Here is a demo of the program:
How It Works
Move your right hand → Strum the virtual guitar 🎵
Move your left hand up/down → Change chords 🎼
Different chords & strumming speed affect the sound! 🎶
Press ‘q’ to quit ❌
You need some chord sounds and place them in a folder. We are using the following chords. You can download the chord sound files in this link:
Am Chord:
C Chord:
D Chord:
G Chord:
Prerequisites
Required Libraries: numpy, OpenCV, mediapipe, PyGame
pip install opencv-python mediapipe pygame numpy
Required Files: Download the chord sound files.
IDE: Use any IDE.
Danger Zone
The solution code is hidden behind the button below. Click to reveal it.
Happy Coding!
Daily Python Projects Team