This project implements an "invisibility cloak" effect using OpenCV in Python. The concept is inspired by the fictional invisibility cloak from the Harry Potter series.
The project works by capturing the background without any subject present, and then replacing the pixels corresponding to the subject with the background pixels in real-time, creating the illusion of invisibility.
To run this project, you need the following:
- Python 3.x
- OpenCV
- Numpy
- Clone the repository to your local machine:
git clone https://github.com/taniishkaaa/invisibility-cloak.git
- Change into the project directory:
cd invisibility-cloak
- Install the required dependencies:
pip install -r requirements.txt
-
Run the main invisibility cloak script:
-
Make sure you have a solid-colored cloth (preferably red) that you can use as the invisibility cloak.
-
Run the
invisibility-cloak.py
script:python invisibility-cloak.py
-
-
Once the script is running, it will open a window displaying the video feed from your camera.
- Allow the camera to capture the background without any subject in the frame for 3 seconds(max).
- Hold the cloth in front of you, covering yourself or any object you want to make invisible.
- You should observe that the cloth-covered region will be replaced by the background, creating the illusion of invisibility.
-
To exit the program, press
q
orCtrl+C
.
You can customize the project to fit your requirements:
- Color Detection: By default, the project uses red color detection to identify the invisibility cloak. You can modify the
lower
andupper
values in theinvisibility-cloak.py
script to detect different colors. - Video Source: The project uses the default camera as the video source. If you want to use a different video source, modify the
cap
variable in theinvisibility-cloak.py
script.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License.
This project is based on the wonderful tutorials and inspiration from the online community. Special thanks to the OpenCV community and the authors of the related tutorials and projects.