Skip to content

Rcidshacker/Air-canvas-new

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

26 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


๐Ÿ”ฎ What is Air Canvas?

Air Canvas is an innovative computer vision application that transforms your webcam into a touch-free digital drawing tablet.

By leveraging the power of MediaPipe for precision hand tracking and Depth-Anything V2 for intelligent depth perception, Air Canvas can distinguish between you hovering your hand over the canvas versus actually touching it โ€” just like a real pen on paper!

Whether you're sketching, prototyping, or just having fun, Air Canvas makes digital art accessible without any physical touch.

    โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
    โ•‘    ๐Ÿ–๏ธ YOUR HAND      โ•‘
    โ•‘         โ†“             โ•‘
    โ•‘    ๐Ÿ“ท WEBCAM         โ•‘
    โ•‘         โ†“             โ•‘
    โ•‘    ๐Ÿง  AI PROCESSING   โ•‘
    โ•‘         โ†“             โ•‘
    โ•‘    ๐ŸŽจ CANVAS         โ•‘
    โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โœจ Features

Feature Description
๐Ÿ–๏ธ AI Hand Tracking Ultra-responsive finger detection using MediaPipe with Kalman filtering for silky-smooth cursor movement
๐Ÿง  Depth Perception Depth-Anything V2 integration enables hover vs. draw distinction โ€” lift to pause, lower to draw!
โœ๏ธ Free Draw Smooth strokes with Catmull-Rom spline interpolation for natural, flowing lines
๐Ÿ“ Shape Tools Instant geometric primitives: Lines, Rectangles, and Circles
๐Ÿงฝ Eraser Multiple eraser sizes for precise corrections
๐ŸŽจ Dynamic Palette Real-time color and brush size selection via virtual UI
๐Ÿ”ค OCR Integration Convert handwritten air-drawings to digital text using Tesseract
๐Ÿ“ธ Screenshot Export Save your artwork instantly with a single keystroke
๐Ÿ”ง Live Config Reload Modify config.yaml and apply changes without restarting

๐Ÿ› ๏ธ Tech Stack

flowchart TD
    subgraph Input["๐Ÿ“น Input Layer"]
        A[Webcam Feed]
    end
    
    subgraph Processing["๐Ÿง  AI Processing"]
        B[MediaPipe Hands]
        C[Depth-Anything V2]
        D[Kalman Filter]
    end
    
    subgraph Logic["โšก Application Logic"]
        E[Gesture Detection]
        F[Drawing Engine]
        G[UI Manager]
    end
    
    subgraph Output["๐Ÿ–ฅ๏ธ Output Layer"]
        H[Canvas Window]
        I[Depth Visualization]
        J[Webcam Preview]
    end
    
    A --> B --> D --> E
    A --> C --> E
    E --> F --> H
    E --> G --> J
    C --> I
    
    style Input fill:#4f46e5,color:#fff
    style Processing fill:#7c3aed,color:#fff
    style Logic fill:#a855f7,color:#fff
    style Output fill:#c084fc,color:#fff
Loading

๐Ÿš€ Quick Start

Prerequisites

Important

Make sure you have the following installed before proceeding:

  • Python 3.8+ with pip
  • CUDA-capable GPU (recommended for depth estimation)
  • Webcam connected to your system

Step 1: Clone the Repository

git clone https://github.com/Rcidshacker/Air-canvas-new.git
cd Air-canvas-new

Step 2: Create Virtual Environment

๐ŸชŸ Windows
python -m venv .depthv2
.\.depthv2\Scripts\activate
๐Ÿง Linux / ๐ŸŽ macOS
python3 -m venv .depthv2
source .depthv2/bin/activate

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Install Tesseract OCR

๐Ÿ“ฆ Click to expand installation instructions
Platform Installation Command
Windows Download from UB-Mannheim/tesseract
Linux sudo apt-get install tesseract-ocr
macOS brew install tesseract

[!NOTE] Windows Users: Ensure the path in depthtrack.py (line 18) matches your Tesseract installation path. Default: C:\Program Files\Tesseract-OCR\tesseract.exe

Step 5: Download Model Weights

Caution

This step is mandatory! The depth model weights are too large to include in the repository.

  1. Visit the Depth-Anything V2 Repository
  2. Download depth_anything_v2_vits.pth
  3. Create a model_weights/ folder in the project root
  4. Place the .pth file inside:
๐Ÿ“ฆ Air-canvas-new/
 โ”— ๐Ÿ“‚ model_weights/
   โ”— ๐Ÿ“œ depth_anything_v2_vits.pth  โ† Place here!

Step 6: Run the Application! ๐ŸŽ‰

python depthtrack.py

๐ŸŽฎ Controls & Shortcuts

โœ‹ Hand Gestures

Gesture Visual Action
Point โ˜๏ธ Move cursor (hover mode)
Pinch ๐Ÿค Draw / Select (thumb + index finger close)
Release โœ‹ Stop drawing (fingers apart)

โŒจ๏ธ Keyboard Shortcuts

Key Icon Function
R ๐Ÿ—‘๏ธ Reset โ€” Clear the entire canvas
S ๐Ÿ“ธ Screenshot โ€” Save current canvas as PNG
O ๐Ÿ”ค OCR โ€” Read text from canvas
U ๐Ÿ”„ Update โ€” Reload config without restart
B / V โ˜€๏ธ Brightness โ€” Increase / Decrease
C / X ๐ŸŽš๏ธ Contrast โ€” Increase / Decrease
ESC โŒ Quit โ€” Exit application

โš™๏ธ Configuration

Customize every aspect of Air Canvas by editing config.yaml:

# ๐Ÿ–ผ๏ธ Display Settings
window_width: 1280
window_height: 800

# ๐Ÿง  AI Settings
use_depth: true           # Toggle depth estimation
depth_threshold: 0.6      # Sensitivity for "touch" detection
device: 'cuda'            # Use 'cpu' if no GPU available

# ๐ŸŽจ Drawing Tools
brush_sizes: [5, 10, 15]
eraser_sizes: [20, 40]
colors:
  - [255, 255, 255]       # White
  - [0, 0, 0]             # Black
  - [255, 0, 0]           # Red
  - [0, 255, 0]           # Green
  - [0, 0, 255]           # Blue
  - [255, 255, 0]         # Yellow

# ๐ŸŽฏ Gesture Sensitivity
multi_pinch_threshold: 60
multi_separation_threshold: 50

# ๐Ÿ“ Smoothing (Kalman Filter)
kalman_process_noise: 1e-3
kalman_measurement_noise: 0.1

Tip

Press U while running to reload config changes without restarting the app!


๐Ÿ“‚ Project Structure

๐Ÿ“ฆ Air-canvas-new
 โ”ฃ ๐Ÿ“‚ model_weights/          # โš ๏ธ Place depth model here
 โ”ƒ  โ”— ๐Ÿ“œ depth_anything_v2_vits.pth
 โ”ฃ ๐Ÿ“œ depthtrack.py           # ๐Ÿš€ Main application entry point
 โ”ฃ ๐Ÿ“œ config.yaml             # โš™๏ธ User configuration
 โ”ฃ ๐Ÿ“œ requirements.txt        # ๐Ÿ“ฆ Python dependencies
 โ”ฃ ๐Ÿ–ผ๏ธ cursor.png              # ๐ŸŽฏ UI Cursor asset
 โ”ฃ ๐Ÿ–ผ๏ธ draw.png                # โœ๏ธ Draw tool icon
 โ”ฃ ๐Ÿ–ผ๏ธ eraser.png              # ๐Ÿงฝ Eraser tool icon
 โ”ฃ ๐Ÿ–ผ๏ธ line.png                # ๐Ÿ“ Line tool icon
 โ”ฃ ๐Ÿ–ผ๏ธ rectangle.png           # โฌ› Rectangle tool icon
 โ”ฃ ๐Ÿ–ผ๏ธ circle.png              # โญ• Circle tool icon
 โ”— ๐Ÿ“œ README.md               # ๐Ÿ“– This file!

๐Ÿ“– Documentation

How It Works

sequenceDiagram
    participant User as ๐Ÿ‘ค User
    participant Cam as ๐Ÿ“ท Webcam
    participant MP as ๐Ÿคš MediaPipe
    participant DA as ๐Ÿง  Depth-Anything
    participant App as ๐ŸŽจ Air Canvas
    
    User->>Cam: Wave hand in air
    Cam->>MP: Video frame
    MP->>App: Hand landmarks (21 points)
    Cam->>DA: Same frame
    DA->>App: Depth map
    App->>App: Calculate pinch gesture
    App->>App: Check depth threshold
    alt Pinching + Close to camera
        App->>App: Draw on canvas
    else Not pinching OR far from camera
        App->>App: Move cursor only
    end
    App->>User: Display canvas + UI
Loading

Key Algorithms

Algorithm Purpose Benefit
Catmull-Rom Spline Smooth curve interpolation Natural, flowing brush strokes
Kalman Filter Position prediction & smoothing Reduces hand-tracking jitter
Multi-Distance Pinch Precise gesture detection Prevents accidental draws

๐Ÿค Contributing

Contributions make the open-source community an amazing place to learn, inspire, and create.
Any contributions you make are greatly appreciated!

  1. Fork the project
  2. Create your feature branch: git checkout -b feature/AmazingFeature
  3. Commit your changes: git commit -m 'Add some AmazingFeature'
  4. Push to the branch: git push origin feature/AmazingFeature
  5. Open a Pull Request

๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for more information.


๐Ÿ‘จโ€๐Ÿ’ป Author

Ruchit Das

Ruchit Das

Computer Vision Enthusiast โ€ข Creative Developer

LinkedIn GitHub



โญ Star this repository if you found it helpful! โญ

Made with โค๏ธ and lots of โ˜•

About

Unleash your inner artist without a single brush! ๐ŸŽจ Air Canvas lets you draw in thin air using just your hand gestures, turning your webcam into a magical canvas.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages