You are browsing as a guest. Sign up (or log in) to start making projects!

Air draw

  • 2 Devlogs
  • 6 Total hours

Air Draw is a python script that tracks your hand through your webcam and lets you paint on screen by moving your index finger around. It uses MediaPipe under the hood to figure out where your hand and fingers are, and OpenCV to show the camera feed and draw the lines.

Ship #1 Pending review

Air Draw is a python script that tracks your hand through your webcam and lets you paint on screen by moving your index finger around. It uses MediaPipe under the hood to figure out where your hand and fingers are, and OpenCV to show the camera feed and draw the lines.

Quick Controls:
-Index finger up: Move Brush
-Pinch (Index + Thumb): Lift Brush (Pause Drawing)
-Index + Middle fingers up: Select Color / Clear
-Press ‘q’ to quit

Sometimes when you switch from drawing mode to selection mode quickly the brush leaves a small stray line before resetting. Havent fixed this yet.

  • 1 devlog
  • 6h
Try project → See source code →
Open comments for this post

5h 54m 14s logged

Air Draw
Wanted to try making an air drawing thing from scratch. Most tutorials use the old mediapipe Hands API which is getting deprecated so I used the newer Tasks API instead.
Canvas layer
Keeping a separate image layer for the drawing and merging it with the camera feed each frame was the annoying part. Empty parts of the canvas had to be made transparent using a threshold mask and bitwise operations. cv2.threshold + cv2.bitwise_and + cv2.bitwise_or is the combo that works.
Gesture detection
First tried checking if fingertip y coordinate was above the knuckle y coordinate. Broke whenever the hand tilted sideways. Switched to distance based: if fingertip is farther from the wrist than the middle knuckle, finger is extended. Works regardless of hand angle.
Smoothing
Two layers of smoothing. One on the landmark positions themselves and one on the actual drawing point
Pinch to lift
Fixed pixel distance threshold for pinch detection broke whenever the hand moved closer or farther from the camera. Made the threshold relative to palm size instead (35% of wrist to middle knuckle distance). Much more consistent.

Controls (nutshell):

  • Index finger up: Move Brush
  • Pinch (Index + Thumb): Lift Brush (Pause Drawing)
  • Index + Middle fingers up: Select Color / Clear
  • Press ‘q’ to quit
1
0
28

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…