A real-time invisibility cloak effect using computer vision with OpenCV and Python. Step into the world of Harry Potter and experience magic through the power of programming!
- ๐ญ Real-time Invisibility Effect - Become invisible in real-time using your webcam
- ๐จ Multiple Color Presets - Support for red, blue, green, and yellow cloaks
- ๐ง Live HSV Tuning - Real-time color calibration with interactive sliders
- ๐ฅ Video Recording - Record your magical moments with timestamps
- ๐ Performance Monitoring - Built-in FPS counter and system status
- ๐ฎ Interactive Controls - Easy-to-use keyboard shortcuts
- ๐ฅ๏ธ Cross-Platform - Works on Windows, macOS, and Linux
- ๐ฑ Smart Background Capture - Intelligent background averaging for stability
- ๐ User-Friendly Interface - Clear instructions and visual feedback
The invisibility cloak uses computer vision techniques to create a real-time masking effect:
- Background Capture: Records a clean background image by averaging multiple frames
- Color Detection: Uses HSV color space to detect the cloak color with high precision
- Mask Creation: Creates a binary mask identifying cloak areas using morphological operations
- Image Compositing: Seamlessly replaces cloak pixels with the pre-recorded background
- Real-time Processing: Applies the effect in real-time at 30+ FPS
Original Frame + Background โ HSV Conversion โ Color Masking โ Morphological Ops โ Final Composite
- Python 3.6 or higher
- Webcam (built-in or external)
- Good lighting conditions
- Clone the repository
git clone https://github.com/ALLEXCEED360/Invicibility_Cloak.git
cd Invisibility_Cloak- Install dependencies
pip install -r requirements.txt- Run the application
python invisibility_cloak.py- Start the magic!
- Press 'B' to capture background (step out of frame first!)
- Put on a red cloth/shirt
- Watch yourself become invisible! โจ
| Key | Action | Description |
|---|---|---|
| B | ๐ธ Capture Background | Step out of frame and press to record background |
| R | ๐ฅ Record Video | Start/stop recording (saves as MP4 with timestamp) |
| C | ๐จ Cycle Colors | Switch between red โ blue โ green โ yellow |
| T | ๐ง HSV Tuner | Open color calibration window with sliders |
| S | ๐พ Save Settings | Save current HSV settings to file |
| SPACE | ๐ Reset Background | Clear current background |
| Q/ESC | ๐ช Quit | Exit the application |
- Position your camera at eye level
- Ensure good, even lighting (avoid harsh shadows)
- Choose a complex background (not a plain wall)
# The app will guide you through this process
1. Run: python invisibility_cloak.py
2. Step completely out of camera view
3. Press 'B' key
4. Wait for 3-2-1 countdown
5. Background captured! โ
- Use solid-colored cloth (red works best)
- Avoid wrinkled or folded materials
- Cover the body parts you want to make invisible
- Press 'T' to open HSV tuner
- Adjust sliders until your cloak appears white in the mask
- Press 'S' to save your custom settings
The application comes with optimized presets for different cloak colors:
| Color | HSV Range | Best Use Case |
|---|---|---|
| Red ๐ด | H: 0-10, 170-180 | Default, works in most lighting |
| Blue ๐ต | H: 100-130 | Good for outdoor scenes |
| Green ๐ข | H: 40-80 | Avoid green backgrounds |
| Yellow ๐ก | H: 20-30 | Bright lighting conditions |
# Basic usage
python invisibility_cloak.py
# Use different camera
python invisibility_cloak.py --cam 1
# Start with blue preset
python invisibility_cloak.py --color blue
# Custom resolution (for performance tuning)
python invisibility_cloak.py --width 640 --height 480
# All options combined
python invisibility_cloak.py --cam 1 --color green --width 1920 --height 1080Create your own color presets by modifying the HSV ranges:
# Add to COLOR_PRESETS in the code
"purple": {
"ranges": [
(np.array([120, 50, 50]), np.array([150, 255, 255]))
],
"description": "Purple cloth/clothing"
}For older computers or lower-end hardware:
# Reduce resolution
python invisibility_cloak.py --width 640 --height 480
# Or even lower
python invisibility_cloak.py --width 320 --height 240invisibility-cloak/
โโโ ๐ invisibility_cloak.py # Main application
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐ README.md # This file
โโโ ๐ camera_test.py #Test your webcam
โโโ ๐ run_demo.py #Run Project using optimal settings
โโโ ๐ .gitignore # Git ignore rules
โโโ ๐ LICENSE # MIT license
โโโ ๐ Demo Gif/ # Demo materials
โ โโโ ๐ฌ im-invisible-invisible.gif
# Try different camera indices
python invisibility_cloak.py --cam 1
python invisibility_cloak.py --cam 2
# Check available cameras
python test_setup.py# Use lower resolution
python invisibility_cloak.py --width 640 --height 480
# Close other applications using the camera
# Ensure good lighting to reduce processing load- Lighting: Ensure even lighting without harsh shadows
- Color: Use solid, vibrant colors (avoid patterns)
- Tuning: Press 'T' to open HSV tuner and adjust
- Material: Avoid shiny or reflective materials
# Reinstall dependencies
pip uninstall opencv-python opencv-contrib-python
pip install opencv-python
# For conda users
conda install opencv numpy- Ensure you have write permissions in the directory
- Check available disk space
- Try different video codecs if issues persist
Minimum:
- Python 3.6+
- 2GB RAM
- Basic webcam (480p)
- 1 GHz processor
Recommended:
- Python 3.8+
- 4GB+ RAM
- HD webcam (720p+)
- Multi-core processor
- Good lighting setup
This project demonstrates several important computer vision concepts:
- Color Space Conversion (BGR โ HSV)
- Image Masking and Bitwise Operations
- Morphological Operations (Opening, Dilation)
- Real-time Video Processing
- Background Subtraction Techniques
- Contour Detection and Filtering
Perfect for:
- ๐ Computer Vision students
- ๐ฉโ๐ป OpenCV beginners
- ๐ญ Interactive art projects
- ๐ Halloween enthusiasts
- ๐น Content creators
We welcome contributions! Here's how you can help:
- Use the issue tracker to report bugs
- Include Python version, OS, and camera details
- Provide steps to reproduce the issue
- Suggest new features or improvements
- Explain the use case and expected behavior
- Check existing issues to avoid duplicates
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes with proper documentation
- Test thoroughly across different environments
- Submit a pull request with clear description
- ๐ Additional visual effects (color changing, transparency)
- ๐ฑ Mobile app version (Android/iOS)
- ๐ Web-based version using WebRTC
- ๐ค Machine learning-based color detection
- ๐ฅ Multiple person support
- ๐๏ธ Hand gesture controls
- ๐ต Audio-reactive effects
This project is licensed under the MIT License - see the LICENSE file for details.
- ๐ OpenCV Community - For the amazing computer vision library
- ๐ Python Foundation - For the versatile programming language
- โก NumPy Developers - For efficient numerical computing
- ๐ช J.K. Rowling - For inspiring the magic of invisibility cloaks
- ๐ Computer Vision Researchers - For foundational algorithms
- ๐ Open Source Community - For making this possible
Share your creations! Tag us on social media:
- ๐งโ๐ผ LinkedIn @Fardeen Alam
- ๐ธ Instagram: @fardeen_alam11
Use hashtags: #InvisibilityCloak #OpenCV #Python #ComputerVision #HarryPotter
Made with โค๏ธ and a touch of magic โจ
