Hello there ๐! I am Sakshi Gupta a backend developer and Machine Learning Enthusiast. After attending a super fun boot-camp about Data Science and Machine Learning I learned how to work around with python libraries like OpenCv and Numpy.
The basic idea of this project is to build a invisibility cloak which will:
- ๐ธ Capture the background image and save it.
- ๐โโ๏ธ Read input video frame by frame and Replace all the pixels of the cloth (here I have used a red colored cloth) with those of the background image.
The complete project is created using one language i.e Python. There are two python libraries used:
- OpenCV : It is a huge open-source library for the computer vision, machine learning, and image processing and it plays a major role in real-time operation which is very important in today's systems. By using it, one can process images and videos to identify objects, faces, or even handwriting of a human.
- Numpy: It is an open-source numerical Python library. NumPy contains a multi-dimensional array and matrix data structures. It can be utilised to perform a number of mathematical operations on arrays such as trigonometric, statistical, and algebraic routines.
Install the latest version of Python3
pip install opencv-python #installs opencv
pip install numpy #installs numpy
- background.py
- Capture the background image.
- Save it.
- invisibility_cloak.py
- Read input video frame by frame.
- Convert the frame from bgr to hsv (best for color detection).
- Set the bgr value of red color in a numpy array.
- Convert it into hsv.
- Determine the threshold values for detecting red color (basically used to determine the shades of red).
- Create masks to detect the red color only.
- Refine the masks by using morphology techniques
- Create anti-mask to determine all the colors except red.
- Combine the background and the current frame.
- Let the magic begin!
- Fork this repository.
- Download soource code.
- Open command prompt.
- Switch to the directory where the project is stored.
- Run the background.py file using
python background.py
- Run the invisibility_cloak file using
python invisibility_cloak.py