Itβs the cloak which Harry Potter uses to become invisible. Of course, we all know that an invisibility cloak is not real β itβs all graphics trickery.
Well, it turns out that you can create this magical experience using an image processing technique called color detection and segmentation. And the good news is, you donβt need to be part of Hogwarts for that! All you need is a red colored cloth.
- python 3
- opencv library
- numpy library
- Red cloth (which will serve as a cloak)
- Installation of Open CV and numpy
pip install opencv-python
The basic idea is given below:
- Capture and store the background frame.
- Detect the red colored cloth using color detection algorithm.
- Segment out the red colored cloth by generating a mask.
- Generate the final augmented output to create the magical effect.
-
background.py It is used for extracting the static background frame. We will replace the current frame pixels corresponding to the cloth with the background pixels to generate the effect of an invisibility cloak. For this we need to store the frame of a static background.
-
invisible_cloak.py Invisible_cloak file records the main window and works with the image saved by
background.py
for making the invisible cloak.