Invisible Cloak using Open CV and Python

Published on . Written by

Invisible Cloak using OpenCV-Python
We all have seen the famous “Harry Potter Invisible cloak” in the harry potter movie and if you are a fan of Harry Potter movies simply like me, then you must know that Harry Potter uses an invisible cloak to become invisible.

Read more..
Here we will make our own “Invisibility Cloak” using OpenCV-python and some basic computer vision techniques.  We likewise going to utilize some fundamental thought of color detection and segmentation to create some magical experience just like Harry Potter does in his movies.


Skyfi Labs Projects
Project Description

Colour detection and segmentation- It is an Image Processing method and by making segments of a single predefined color from the video and replacing it with a pre-existing same background, we can create the invisible cloak.

You must have a cloth of the similar shading and there ought to be no other shading noticeable in that material. Here we are taking the red cloth and if you want you can take some other color cloth-like green, blue color cloth, etc. But there will be some changes in timing and code as well.

HSV color space value- “Why we choose a red color or Can we another color as well?”

Truly, we can utilize any color cloth in making this cloak. We simply need to refresh the HSV estimation of the shading in our code.

HSV color space value tell us the colors using three values -

1. H is Hue, Hue describe the color information, range from 0 to 360 degrees.

  • Yellow ranges somewhere in the range of 61 and 120.
  • Red ranges somewhere in the range of 0 and 60 and 0 are red.
  • Green ranges between 121–180.
  • Cyan ranges between 181–240.
  • Blue ranges between 241–300.
  • Magenta ranges between 301–360.
2. S is Saturation, it describes the dim shading in a specific shading running from 0 to 100% and the purity of color.

3. V is Value, it describes the brightness of the color, from 0–100 %, where 0 is totally dark, and 100 is the brightest and uncovers the most shading.

OpenCV-python- We are going to code our project in OpenCV-python, and OpenCV-Python is a library of Python used to determine the computer vision problems. OpenCV-Python utilizes Numpy, which is an exceptionally streamlined and reliable library for numerical activities with a MATLAB-style language structure.

Project Implementation

There are some fundamental to make invisibility cloak and the steps are:

  1. Capture and store the background frame, by doing this we can change the present casing pixels identical to the cloth with the background pixels to create the impact like an invisibility cloak.
  1. Presently in this step, we have to distinguish the red colored cloth using color detection and segmentation technique and by doing this we convert the color space of our image from RGB to HSV.
  1. The next stage is to segment out the identified red colored cloth by generating a mask.
  1. The Last step is to produce the final augmented output to create a magical effect and now we can see the otherworldly i.e. magical impact on the webcam.
Software Requirements

Programming language - OpenCV - Python

Operating System - windows, ubuntu.

Kit required to develop Invisible Cloak using Open CV and Python:
Technologies you will learn by working on Invisible Cloak using Open CV and Python:


Any Questions?


Subscribe for more project ideas