Ever wished to capture your imagination by just waving your finger in the air? In this post, we have an Air Canvas that can draw anything on it by simply moving our hands and observing the landmark on the hand knuckles. A virtual drawing tool (Computer vision project) that allows you to draw in the air using hand gestures, thanks to the powerful combination of OpenCV and MediaPipe.
๐ง Tools and Libraries Used:
-
Python3 , NumPy , opencv , mediapipe
-
OpenCV: This open-source library is essential for real-time computer vision tasks. It helped me capture and process video frames from the webcam seamlessly.
-
MediaPipe: Developed by Google, MediaPipe is a fantastic framework for building multimodal machine learning pipelines. In this project, I used MediaPipe for hand tracking, enabling accurate and real-time recognition of hand landmarks.
How It Works:
- Capture Video: Using OpenCV, the script captures live video feed from the webcam.
- Process Frames: Each frame is processed using MediaPipe to detect and track hand landmarks.
- Draw Landmarks: The detected hand landmarks are drawn on the video frames, creating a virtual canvas for drawing in the air.
Start reading the frames and convert the captured frames to HSV colour space.(Easy for colour detection)
Prepare the canvas frame and put the respective ink buttons on it.
Adjust the values of the mediapipe utilization to detect one hand only.
Detect the landmarks by passing the RGB frame to the mediapipe hand detector.
Detect the landmarks, find the forefinger coordinates and keep storing them in the array for successive frames.(Arrays for drawing points on canvas)
Finally, draw the points stored in an array on the frames and canvas.
![image](https://private-user-images.githubusercontent.com/114860158/339307062-77a756ac-54ad-49c2-b784-c46ee868a01d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQzOTI0MjEsIm5iZiI6MTcyNDM5MjEyMSwicGF0aCI6Ii8xMTQ4NjAxNTgvMzM5MzA3MDYyLTc3YTc1NmFjLTU0YWQtNDljMi1iNzg0LWM0NmVlODY4YTAxZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODIzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyM1QwNTQ4NDFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zYjY2OWQ4YjczN2QwMzNiMmFlN2M4NWNiZjdkZGViZTljMTNhN2E5MWU1ZDhmYjQ3MjBmMDFjYjkwNzBjZGRlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.k_3HO7MvsOrWA7lPPImBRXROAap55I8S6C2md3yh8Wg)