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.
webcam
FPS: 30
NEXT TRACKPREVIOUS TRACKPLAY/PAUSE
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
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
# 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"