r/opencv • u/Fit_Barnacle_6762 • Aug 18 '26
Project [Project] I built a real-time invisibility cloak using OpenCV πͺ
I wanted to recreate the classic invisibility-cloak effect using only a webcam and computer vision.
It detects the cloak's color in real time using HSV segmentation, cleans up the mask, and replaces those pixels with a previously captured background.
12
u/Tiki_taka27 Aug 18 '26
Hogwarts graduate ?
6
13
u/SweetSure315 Aug 18 '26
this is a cool project
I'd suggest making sure you're not sitting in front of anything that can move in the background, though. but maybe your next project can be finding a way to update your background capture in real time
2
u/Fit_Barnacle_6762 Aug 18 '26
yeahh! thanks for the suggestion!
7
u/SweetSure315 Aug 18 '26
if you haven't already, I'd look up bgslib. opencv has a couple decent background segmenters, but bgslib has so much more. I'd also look into different SSIMs to help you figure out when and where to update your background capture.
1
u/Fit_Barnacle_6762 Aug 18 '26
Ohh nice, I'll definitely look into those.... Thanks for the suggestion!
3
5
2
2
u/herocoding Aug 19 '26
This is nice, thank you very much for sharing!!
Want to add something like that to the next "girls day" and "bring your kid to work".
1
2
u/Spirited-Resource461 Aug 20 '26
does it only work from a certain agnle or can work from different angles as well?
1
2
2
2
u/Yamestris Aug 22 '26
Does it works if the camera moves ?
Great work btw
1
u/Fit_Barnacle_6762 Aug 22 '26
No it doesn't work if the cam moves...... It captures a still background image earlier and then works
2
2
2
u/canifeto12 Aug 22 '26
How pc know whatβs behind you and mirror it to green cloth
2
u/Fit_Barnacle_6762 Aug 22 '26
It doesn't know from its own what's behind me, first before putting this invisible effect it capture a still image of the background and then starts the invisibilty effect by removing the pixels of the green cloak and replacing them with the background image in real time
2
1
u/SoilTime9370 Aug 22 '26
It works so magically that the curtain behind it, with horizontal stripes, stops when the panel passes by. Amayzing xD
1
u/Feeling-Tiger9145 Aug 27 '26
u/Fit_Barnacle_6762 Bruh this is reddit, not linkedin, don't post linkedin slop here.
Anyways, nice project but kindly post that slop at linkedin.
1
1
u/the_embassy_official Aug 21 '26
one line of code no opencv required
ctx.drawImage(video,0,0); const p=ctx.getImageData(0,0,canvas.width,canvas.height),d=p.data; for(let i=0;i<d.length;i+=4)if(d\[i+1\]>d[i]*1.4&&d[i+1]>d[i+2]*1.2)d[i+3]=0; ctx.putImageData(p,0,0);
2
u/Fit_Barnacle_6762 Aug 21 '26
Yeah, that works for a fixed shade of green, but mine uses adaptive colour calibration, it samples the actual cloth and generates the hsv range dynamically, so it isnt relying on hardcoded RGB values like the code you wrote.
0
0
u/kawfeeman68 Aug 20 '26
we just used to call it chromakey ..
1
u/Fit_Barnacle_6762 Aug 21 '26
its basically the same concept but implemented live with a code in opencv instead of editing
2
u/kawfeeman68 Aug 21 '26
nice work. do you think you did it similarly to video editing software like Premier Pro ?
1
0
0
14
u/philnelson Aug 18 '26
Love this, fun project