Skip to content

HelloItsJustin/AI-Invisibility-Cloak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🧙 AI Invisibility Cloak (QR Controlled)

Turn yourself invisible in real time using computer vision and a red cloak. This project uses OpenCV and Python to detect a red cloth, remove it from the camera feed, and replace it with a captured background — creating a Harry Potter–style invisibility effect.

Instead of buttons or a GUI, the cloak is controlled using QR codes.

OpenCV Computer Vision Python QR Control

✨ Features

  • ⚡ Real-time invisibility effect (typically 30+ FPS)
  • 🎨 HSV-based color segmentation for reliable red-cloak detection
  • 📱 QR code control:
    • CLOAK_ON / INVISIBLE → Activate cloak
    • CLOAK_OFF / VISIBLE → Deactivate cloak
    • TOGGLE → Switch state
  • 🖼️ Static or dynamic background replacement
  • 📊 On-screen HUD with live FPS counter and cloak status
  • ⌨️ Keyboard fallbacks (C to toggle, ESC to quit)

⚙️ How It Works

1. Background Capture

At startup, the camera records several frames while you are not in front of it. These frames are combined into a clean background image.

2. Color-Based Cloak Detection

  • Each frame is flipped horizontally for a mirror-like view
  • Blurred slightly to reduce noise
  • Converted from BGR to HSV color space
  • Two red hue ranges (around 0° and 180°) create a cloak mask

3. Mask Refinement

Morphological operations are applied to:

  • Remove noise
  • Fill gaps
  • Smooth cloak edges

4. Compositing

Pixels detected as cloak are replaced with pixels from the stored background. All other pixels come from the live camera feed, producing the invisibility illusion.

5. QR Code Control

Each frame is scanned for QR codes. Decoded commands update the cloak state with a cooldown to prevent repeated triggers.

📦 Requirements

  • Python 3.8+
  • Webcam
  • Red cloth or fabric
  • Python packages:
pip install opencv-python numpy pyzbar

🚀 Installation & Usage

Clone the Repository

git clone https://github.com/<your-username>/qr-invisibility-cloak.git
cd qr-invisibility-cloak

Install Dependencies

pip install opencv-python numpy pyzbar

Generate QR Codes (Optional)

python QRCodeGen.py

Or use the pre-generated QR codes in the QR's Generated folder.

Run the Invisibility Cloak

python InvisibilityCloak.py
Setup Instructions:
  • Remove the red cloth from the camera view
  • Wait for background capture (~3 seconds)
  • Put on your red cloak
  • Show QR codes to control the effect

🎮 Controls

QR Codes

  • cloak_on.png → Activate cloak
  • cloak_off.png → Deactivate cloak
  • toggle.png → Toggle state

Keyboard

  • C → Toggle cloak
  • ESC → Exit program

📁 Project Structure

.
├── QR's Generated/
│   ├── cloak_off.png
│   ├── cloak_on.png
│   └── toggle.png
├── InvisibilityCloak.py
├── QRCodeGen.py
└── README.md

🎛️ Tuning the Effect

Adjust HSV values in InvisibilityCloak.py if detection is noisy:

lower_red1 = np.array([0, 100, 50])
upper_red1 = np.array([10, 255, 255])
lower_red2 = np.array([160, 100, 50])
upper_red2 = np.array([180, 255, 255])
  • Use uniform lighting
  • Avoid pink or orange fabrics
  • Tune morphological iterations
  • Maintain moderate camera distance

🧠 Technical Details

  • Color Detection: HSV segmentation
  • Image Processing: Morphological operations
  • QR Detection: pyzbar
  • Performance: 30+ FPS optimized pipeline
  • Background: Median-based capture

🚧 Possible Extensions

  • 🎮 Gesture-based control
  • 👥 Multi-person or multi-color cloaks
  • 🎥 OBS virtual camera support
  • 🖱️ GUI for live HSV tuning
  • 📦 Standalone app with PyInstaller
  • 🌍 Custom background images or videos

🤝 Contributing

Fork the project and submit pull requests for improvements.

Built with OpenCV & Python
QR-Controlled Interaction

Made by Justin Thomas

About

Turn invisible like Harry Potter ! QR-controlled AI cloak using computer vision. Wear red cloth, scan to disappear / reappear instantly. Built with OpenCV & Python. 30+ FPS performance with seamless edge detection. Great for video effects, hackathons, and creative projects. Includes customizable backgrounds !

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages