DEV Community

Sumit Mishra
Sumit Mishra

Posted on Edited on AI-assisted

Air Pen: Drawing in the Air with MediaPipe Hand Tracking

Air Pen turns a webcam into a simple drawing surface. It tracks a hand in real time and renders a line that follows the tip of the index finger, so you can sketch in the air without a physical pen or touchscreen.

The project uses MediaPipe Hand Landmarker to detect 21 hand landmarks and OpenCV to show the camera feed with the drawing overlaid. The index-finger tip supplies the pen position. A finger pose controls whether the system is drawing: folding the middle finger starts the stroke, and lifting it stops the stroke. Press C to clear the canvas and Q to quit.

A tiny gesture interface

The interesting part is the mapping between a hand pose and an action. The tracker has to distinguish intentional movement from a change in drawing state, then keep the visual feedback immediate enough that the gesture feels connected to the mark on screen.

To try it, the repository documents a Python environment, a webcam, and the MediaPipe Hand Landmarker model file. Run the app with python air_pen.py after installing its dependencies. See the Air Pen source on GitHub.

This is a small computer-vision experiment, but it is a useful starting point for exploring hands-free input and gesture-driven interfaces.

Top comments (0)