Projects Python Projects

Create a Virtual Pen and Eraser with Python OpenCV

Written by genialcode

Learn Free how to create a virtual pen and eraser with python and OpenCV with source code and complete guide. This entire application is built fundamentally on contour detection. It can be thought of as something like closed color curves on compromises that have the same color or intensity, it’s like a blob. In this project we use color masking to get the binary mask of our target color pen, then we use the counter detection to find the location of this pen and the contour to find it.

When we work with it then it is a matter of literally connecting the dots, we just have to draw a line using the x, y dots of the previous position of the pen with new x, y dots and that’s it. , We have a virtual pen.

Virtual Pen and Eraser with Python 

There are 6 main points in the structure

  1. Find color range of target object and save it.
  2. Apply morphological operations.
  3. Detect and track the colored object.
  4. Find the object’s x, y  coordinates.
  5. Add a Wiper functionality.
  6. Add an Eraser Functionality.

Import required libraries

Download Complete Guide of Virtual Pen & Eraser OpenCV

Download Source Code Of Virtual Pen & Eraser OpenCV

About the author


Leave a Comment