Air drawing with hand gestures (MediaPipe + OpenCV)
835
Draw in the air with your hand, then view the drawing as a rotatable 3D object. Hand tracking uses the MediaPipe Hand Landmarker. Rendering and the UI use OpenCV.
This is a camera and GUI application. It needs a Linux host with a webcam and an X11 display. It cannot reach the camera or screen on Docker Desktop for macOS or Windows.
xhost +local:docker
docker run --rm \
--device /dev/video0:/dev/video0 \
-e DISPLAY=$DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--network host \
flugmaschine/hand-tracking-drawing:latest
Saved drawings go to /app/output inside the container. Mount a folder to keep them:
-v $(pwd)/output:/app/output
:(( for a secondKeys: S save, C clear, U undo, 1..6 color, [ / ] thickness,
SPACE 2D/3D, R reset view, K skeleton, D debug, H help, Q quit.
The 3D Drawing mode uses the YOLO depth model (models/yolo26s-depth.pt), which
returns a per pixel depth map in meters. Every drawn point takes its Z from the metric
depth under the fingertip, so moving the hand closer or further really draws into the
scene: the stroke is a 3D curve in space, not a flat picture placed on a board. The
first drawn point sets the zero plane, everything after that is relative to it.
Depth runs in a background thread, so tracking and drawing stay at camera speed.
Raw monocular depth flickers, so the pen does not follow it directly: the global scale drift of the map is cancelled against the static background, the fingertip depth goes through a one euro filter with a noise deadband and a speed limit, and the newest points of a stroke are low passed along the curve. A circle drawn without moving the hand comes out flat, while a deliberate push of 25 cm is kept in full.
By default strokes are colored by a depth gradient - warm near the camera, cool further
away. 1..6 switch to a solid color, G goes back to the gradient.
Gestures and keys are the same as in 2D, with two additions:
In 3D the fist rotates the drawing itself and two fists scale it, SPACE toggles
depth colors, R resets the view.
by Salimli Ayzek (Салимли Айзек): https://mathematiclove.github.io/my-cv
Content type
Image
Digest
sha256:5bba00556…
Size
3 GB
Last updated
2 months ago
docker pull flugmaschine/hand-tracking-drawing