Draw on screen by moving your index finger in front of a webcam.
Built and tested by Shahan Fathima K · Industrial Robotics Institute
Python 3.11.9, OpenCV, MediaPipe, NumPy, PyCharm IDE
AI Air Drawing is a computer vision application that lets users draw in the air using hand gestures instead of a mouse or touchscreen. AI-based hand tracking detects the finger position from a webcam and converts its movement into a digital drawing on screen. It is built in Python with OpenCV, MediaPipe and NumPy.
| Component | Qty |
|---|---|
| Laptop / Computer | 1 |
| Webcam | 1 |
Complete, tested Python code for this project. Copy it into Python 3.11.9 and upload it and run it.
import cv2
import mediapipe as mp
import numpy as np
cap = cv2.VideoCapture(0)
mpHands = mp.solutions.hands
hands = mpHands.Hands(max_num_hands=1)
mpDraw = mp.solutions.drawing_utils
canvas = None
prev_x, prev_y = 0, 0
while True:
ret, frame = cap.read()
frame = cv2.flip(frame, 1)
if canvas is None:
canvas = np.zeros_like(frame)
rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
result = hands.process(rgb)
if result.multi_hand_landmarks:
for handLms in result.multi_hand_landmarks:
mpDraw.draw_landmarks(frame, handLms, mpHands.HAND_CONNECTIONS)
landmarks = [(int(lm.x*640), int(lm.y*480)) for lm in handLms.landmark]
x, y = landmarks[8]
if prev_x == 0 and prev_y == 0:
prev_x, prev_y = x, y
cv2.line(canvas, (prev_x, prev_y), (x, y), (0,255,0), 5)
prev_x, prev_y = x, y
else:
prev_x, prev_y = 0, 0
frame = cv2.add(frame, canvas)
cv2.imshow("Air Drawing", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
AI Air Drawing is a computer vision application that lets users draw in the air using hand gestures instead of a mouse or touchscreen. AI-based hand tracking detects the finger position from a webcam and converts its movement into a digital drawing on screen.
You need: Laptop / Computer (1), Webcam (1). Software: Python 3.11.9, OpenCV, MediaPipe, NumPy, PyCharm IDE.
Yes. It is rated beginner and takes about 1–2 hours to build, using the Laptop / PC with webcam. The guide on this page explains every connection and step.
The complete, tested Python code is free on this page. Copy it into Python 3.11.9 and upload it and run it.
No kit is needed. This project runs on a laptop or PC with webcam. For help with the setup, message IRI on WhatsApp at +91 86060 82634.