Ever wanted to draw your imagination by just waving your finger in the air. In this post, we will learn to build an Air Canvas which can draw anything on it by just capturing the motion of a colored marker with a camera. Here a colored object at the tip of the finger is used as the marker.
We will be using the computer vision techniques of OpenCV to build this project. The preferred language is Python due to its exhaustive libraries and easy to use syntax but understanding the basics it can be implemented in any OpenCV supported language.
Here Color Detection and tracking are used in order to achieve the objective. The color marker is detected and a mask is produced. It includes the further steps of morphological operations on the mask produced which are Erosion and Dilation. Erosion reduces the impurities present in the mask and dilation further restores the eroded main mask.
- Start reading the frames and convert the captured frames to HSV color space (Easy for color detection).
- Prepare the canvas frame and put the respective ink buttons on it.
- Adjust the track bar values for finding the mask of the colored marker.
- Preprocess the mask with morphological operations (Eroding and dilation).
- Detect the contours, find the center coordinates of largest contour 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.
Below is the implementation.
- Python Tkinter | Create different shapes using Canvas class
- Python Tkinter | Create different type of lines using Canvas class
- Python | Canvas in kivy
- Python | Canvas in Kivy using .kv file
- Python | Line (Canvas) in kivy
- Python Tkinter - Canvas Widget
- Python - How to save canvas in pyqt5?
- Circular (Oval like) button using canvas in kivy (using .kv file)
- Python Tkinter | Moving objects using Canvas.move() method
- How to Create an App in Django ?
- Python - Create a box in GTK+ 3
- Create Table Using Tkinter
- Create a directory in Python
- How to create a Dictionary in Python
- Create a stopwatch using python
- Tableau - Create Visualization
- How to create a new thread in Python
- Create Certificates using Python-PIL
- Create XML Documents using Python
- wxPython - Create() function in wx.Button
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.