Skip to content

hpishwe/magic-cloak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Magic Cloak

Invisibility Cloak with OpenCV

This project implements a Harry Potter-style Invisibility Cloak using Python and OpenCV. It uses real-time video processing to detect a specific color (e.g., black) in a video feed and replaces it with a previously captured background, creating the illusion of invisibility.

Features

  • Real-time cloak detection using color segmentation.
  • Supports user-defined cloak colors (e.g., black, red, blue).
  • Works with any webcam or connected camera.
  • Implements background subtraction and image masking.

How It Works

  1. The program captures a static background image without the user in the frame.
  2. It detects the user’s cloak using the HSV color space and creates a mask for that specific color.
  3. The cloak area is replaced with the captured background using image masking techniques, making the cloak appear invisible.

Installation

1. Prerequisites

Ensure you have the following installed:

  • Python 3.7 or higher
  • pip (Python package manager)
  • OpenCV library

2. Clone the Repository

git clone https://github.com/hpishwe/magic-cloak.git
cd magic-cloak

3. Install Dependencies

pip install -r requirements.txt

Usage

Step 1: Capture the Background

python cloak_detection.py

Follow the instructions:

  1. Stand out of the frame for a few seconds to let the program capture the background.
  2. Once the background is captured, step into the frame wearing your cloak (black color in this version).

Step 2: Make the Cloak Invisible

The script will detect the black cloak and replace it with the background, making it appear invisible in real-time.

Dependencies

The project uses the following Python libraries:

  • OpenCV: For image processing and video handling.
  • NumPy: For array operations and mask creation.

These dependencies are included in the requirements.txt file.

Troubleshooting

  • Edges of the cloak are visible: Adjust the HSV range to ensure complete color coverage.
  • Cloak detection is inconsistent: Improve lighting and avoid shadows or wrinkles on the cloth.
  • Script not working: Ensure you’ve installed all dependencies and your webcam is functional.

Future Improvements

  • Allow dynamic color selection for the cloak.
  • Use deep learning models for more robust and precise segmentation.
  • Add support for multiple cloaks in the same frame.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages