Create An Invisible Cloak With OpenCV and Python

04 May 2023 Balmiki Mandal 0 Python

Using OpenCV and Python to Recreate Harry Potter's Invisible Cloak!

Using OpenCV and Python to Recreate Harry Potter's Invisible Cloak!

For any fan of the Harry Potter franchise, it is not a secret that one of the most iconic magical objects is the magical invisible cloak! In this project, I will be using openCV and python to try and recreate this magical cloak.

OpenCV stands for Open Source Computer Vision library. It is a library of programming functions mainly aimed at real-time computer vision. Python is a high-level, interpreted, interactive, and object-oriented scripting language. This means that with the combination of these two languages there is a great power to create magical effects such as this invisibility cloak!

How does it work?

The basis of this project is background subtraction. This means that an image with the person wearing an invisible cloak is subtracted from an image taken without the cloak. Subtracting these two images will leave only the cloak in the image. This is how the magic happens!

What do you need?

  • A laptop or desktop with Python and OpenCV installed
  • A webcam or video camera
  • A red piece of cloth to represent the cloak. This is important as this color is used by the program to detect the differences between the cloak and the background.

Steps to Follow

  • Take two frames from the video, one with the subject wearing the cloak and the other without.
  • Capture the red colored cloth by defining the upper and lower range of red color in HSV color space.
  • Segment out the red colored cloth by creating a mask with segmented color.
  • Generate the final augmented output to create a magical effect.

Conclusion

This project is a demonstration of how OpenCV and Python can be used together to create a magical effect similar to Harry Potter's invisible cloak. Although this project does not completely make a person invisible, it does give an idea of how an image manipulation tool can help create illusions or magic with just a few lines of code.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.