A tiny Python demo that lets you vanish on‑screen when you drape yourself in a plain white cloth. Built with OpenCV + NumPy, tested on macOS & Windows.
- Python 3.8+ – install from python.org or
brew install python. - A webcam (built‑in or USB).
- macOS users: Grant Terminal/VS Code camera permission under System Settings → Privacy & Security → Camera.
# 1. clone the repo
git clone https://github.com/<YOUR_USERNAME>/HarryPotterInvisibleCloak.git
cd HarryPotterInvisibleCloak
# 2. create a project‑local virtualenv
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# 3. install deps
pip install -r requirements.txt # or run: pip install opencv-python numpysource .venv/bin/activate # ensure venv is active
python invisibility_cloak_white.py- Hide from the camera for ~3 seconds while the script captures a clean background.
- Step into frame wearing a white cloth – you’ll appear invisible!
- Quit with q (while the OpenCV window is focused) or Ctrl + C in the terminal.
All magic knobs live at the top of invisibility_cloak_white.py:
| Var | Default | What it does |
|---|---|---|
WHITE_SAT_MAX |
30 |
Upper saturation threshold for “white”. |
WHITE_VAL_MIN |
200 |
Minimum brightness to consider a pixel white. |
WAIT_SEC_FOR_BG |
3 s |
Background‑capture duration. |
FRAME_WIDTH/HEIGHT |
640×480 |
Resize for FPS vs quality trade‑off. |
| Issue | Fix |
|---|---|
| OpenCV: not authorized to capture video | Go to macOS Settings → Privacy & Security → Camera and enable access. |
| Black/empty window | Another app is hogging the webcam → close it and restart script. |
| White objects in background also vanish | Use a colored backdrop or tweak WHITE_* thresholds. |
| Low FPS | Lower FRAME_WIDTH/HEIGHT or ensure plenty of light. |
PRs welcome! Clone, create a feature branch (git checkout -b feat/cool-idea), commit small chunks, open a PR.
MIT – free to remix, abracadabra responsibly.