πŸ€– LateAI
Home β€Ί Tutorials β€Ί AI Virtual Painter
🎨

AI Virtual Painter

Beginner Β· 2-3 hours
πŸ“Ά Beginner ⏱ 2-3 hours πŸ’° Free (software only) 🏷 CV Zone

πŸ“Œ Overview

Draw in mid-air in real time: raise your index finger and move it around the frame to draw a line, hold up different numbers of fingers to switch colour, and use a fist or similar gesture to clear the canvas.

On top of hand tracking it adds canvas state management (draw / don't draw / clear), which makes it the best beginner project for understanding a gesture state machine.

🧰 What you need

πŸ”§ Step by step

1

Hand-tracking basics

Use HandTrackingModule to get the 21 landmarks

Pick out the index, middle, and ring fingertip coordinates

2

Design the canvas

Create an all-black canvas with numpy and blend it over the camera frame

Keep the canvas the same size as the frame so coordinates line up

3

Decide the drawing state

Index finger only = draw mode, and record the fingertip trail

Index and middle finger together = don't draw (move mode)

4

Draw the line

Join the previous frame's fingertip to the current one with cv2.line

The trail stays continuous and feels natural

5

Switch colour

Hold up 3-4 fingers in the colour strip at the top to pick a colour

Make colour selection a 'point and hold on the swatch' interaction

6

Clear the canvas

Assign a gesture (a fist, for example) to reset the canvas

Refactor the code into a reusable drawing-board function

πŸ’‘ Tips

View original β†— ← Back to LateAI home