All works

2024Computer vision tool

MediaControl

Control Spotify with your hand. Point your fingers one way to skip, the other way to go back, and raise your hand to play or pause.

  • Python
  • OpenCV
  • MediaPipe

Overview

MediaControl reads a webcam feed with OpenCV, tracks the 21 landmarks of one hand with MediaPipe, and turns simple hand poses into Spotify commands sent through AppleScript.

A two-second cooldown keeps one gesture from firing twice, and the live FPS and the last command are drawn on top of the video.

See it in action

The original demo from the repo: raising my hand plays or pauses, and pointing my fingers left or right skips forward or back.

Highlights

  • 21 hand landmarks

    Fingertips and the wrist decide which way the hand is turned.

  • 3 gestures

    Next track, previous track, and play or pause.

  • 2 s cooldown

    So one wave of the hand is one command.

From the source

TrackingModel.py
# Left
if (
    max(lmList[0][1], lmList[4][1], lmList[8][1], lmList[12][1], lmList[16][1], lmList[20][1]) == lmList[0][1]
):
    lastControl = time.time()
    subprocess.call(['osascript', '-e', 'tell application "Spotify" to next track'])
    status = "NEXT TRACK"

Ready to build something amazing?

I'd love to connect with you!