AirCanvas is a virtual drawing application that uses computer vision and hand gesture recognition to enable touch-free drawing. Users can select colors and draw on a canvas using only their hands, captured through a webcam.
- Imports OpenCV (cv2): For capturing webcam feed and processing frames. NumPy (np): For handling numerical operations. Mediapipe: For hand tracking and gesture detection. Deque (from collections): For managing color-specific points in the drawing queue.
- Initialization Separate deques for different color points. Color and index initialization for easy switching between colors. Configured canvas (paintWindow) with color selection buttons for clear, blue, green, red, and yellow.
- Mediapipe Setup Uses Mediapipe’s hand tracking for detecting hand landmarks and interpreting gestures.
- Webcam Feed Captures frames from the webcam, flips them for a mirrored view, and processes them in real-time.
- Main Drawing Loop Processes each frame to detect hand landmarks. Uses finger positions to interpret gestures for: Color Selection: Switch colors based on finger position over the color buttons. Clear Canvas: Erase the canvas by selecting the "CLEAR" button. Drawing: Tracks finger movement to draw lines on the canvas.
- Display Output Displays the live drawing and color selection interface in separate OpenCV windows.
- Termination Press the q key to exit, releasing the webcam and closing all windows.
- Run the Script: Ensure you have the required libraries and launch the script.
- Interact with the Interface: Use hand gestures to draw, change colors, or clear the canvas.
- Exit: Press q to close the application.