Skip to content

๐ŸŽน Air-Piano: Play D Major chords with hand gestures using OpenCV, cvzone & MIDI โ€“ No physical keyboard needed! โœจ๐Ÿ–๏ธ๐ŸŽถ

Notifications You must be signed in to change notification settings

anjalirj27/PianoProject_CV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽน Piano: Play Chords with Hand Gestures

Air-Piano is a hands-free virtual MIDI instrument powered by your webcam and computer vision. By detecting finger gestures from both hands, it plays chords from the D Major scale in real-time โ€” no physical keyboard required!

A creative blend of music, machine vision, and MIDI technology โ€” all in Python.


โœจ In a Nutshell

This project uses OpenCV, cvzone (MediaPipe), and pygame.midi to:

  • Detect hand gestures via webcam
  • Map each raised finger to a chord
  • Play the chord for 2 seconds before releasing it

๐Ÿ“† Project Structure

PianoProject_CV/
โ”‚
โ”œโ”€โ”€ handgesturecvpiano.py        # Original basic version: finger-chord mapping and auto-stop
โ”œโ”€โ”€ handgesture.py               # Enhanced version with instrument switching + chord display
โ”œโ”€โ”€ chordmaping.txt              # Lists chord mappings for reference
โ”œโ”€โ”€ requirements.txt             # All required dependencies
โ””โ”€โ”€ README.md                    # ๐Ÿ“˜ Youโ€™re reading it!

๐Ÿ‘ Chord Mapping (D Major Scale)

Each hand controls different chords. Raising a finger = triggering a chord.

Hand Finger Chord Notes Played
Left Thumb D Major D, F#, A
Left Index E Minor E, G, B
Left Middle G Major G, B, D
Right Thumb G Major G, B, D
Right Index A Major A, C#, E
Right Middle B Minor B, D, F#
Right Pinky F# Minor F#, A, C#

Check full mapping in: chordmaping.txt


๐Ÿ› ๏ธ Setup Instructions

Step 1๏ธโƒฃ โ€“ Clone the Repository

git clone https://github.com/anjalirj27/PianoProject_CV.git
cd PianoProject_CV

Step 2๏ธโƒฃ โ€“ Install Dependencies

Ensure you are in a Python environment (e.g., tensorflowenv). Then install all required packages:

pip install -r requirements.txt

Dependencies List (from requirements.txt):

  • opencv-python
  • cvzone
  • pygame
  • mediapipe
  • numpy

Step 3๏ธโƒฃ โ€“ Run the Program

Option 1: Basic Version

To run the original hand-to-chord logic:

python handgesturecvpiano.py

Option 2: Enhanced Version ๐ŸŽฎ

To use advanced features like instrument switching and chord visual feedback:

python handgesture.py

๐ŸŒŸ Features

  • ๐ŸŽฅ Real-Time Hand Tracking using OpenCV + cvzone
  • ๐ŸŽน MIDI Chord Output using pygame.midi
  • ๐ŸŽถ D Scale Chords mapped to specific fingers (both hands)
  • โฑ๏ธ Auto Sustain: Chords sustain for 2 seconds and stop
  • ๐Ÿ–๏ธ Control the piano just by lifting fingers in front of a webcam!

About

๐ŸŽน Air-Piano: Play D Major chords with hand gestures using OpenCV, cvzone & MIDI โ€“ No physical keyboard needed! โœจ๐Ÿ–๏ธ๐ŸŽถ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages