Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 921e6d8

Browse files
Merge pull request avinashkranjan#529 from satyampgt4/master
Invisibility_Cloak is added
2 parents 5770490 + 0ede0fb commit 921e6d8

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import cv2
2+
import numpy as np
3+
import time
4+
5+
print("!! Invisibility is no more a Dream !!")
6+
7+
cap = cv2.VideoCapture(0)
8+
time.sleep(3)
9+
background=0
10+
for i in range(20):
11+
ret,background = cap.read()
12+
13+
background = np.flip(background,axis=1)
14+
15+
while(cap.isOpened()):
16+
ret, img = cap.read()
17+
18+
img = np.flip(img,axis=1)
19+
20+
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
21+
value = (35, 35)
22+
blurred = cv2.GaussianBlur(hsv, value,0)
23+
24+
low_red1 = np.array([0,120,70])
25+
low_red2 = np.array([170,120,70])
26+
27+
up_red1 = np.array([10,255,255])
28+
up_red2 = np.array([180,255,255])
29+
30+
cloak = cv2.inRange(hsv,low_red1,up_red1) + cv2.inRange(hsv,low_red2,up_red2)
31+
cloak = cv2.morphologyEx(cloak, cv2.MORPH_OPEN, np.ones((5,5),np.uint8))
32+
33+
img[np.where(cloak==255)] = background[np.where(cloak==255)]
34+
cv2.imshow('Display',img)
35+
k = cv2.waitKey(10)
36+
if k == 27:
37+
break;
38+
39+
cap.release()
40+
cv2.destroyAllWindows()

‎Invisibility_Cloak/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<h1 align="center">Invisibility Cloak</h1>
2+
An invisibility cloak is a magical garment which renders whomever or whatever it covers invisible
3+
<br>
4+
In this project we create an invisibility cloak using python
5+
6+
---------------------------------------------------------------------
7+
8+
## Modules Used
9+
- time
10+
- OpenCv
11+
- numpy
12+
13+
## How it works
14+
15+
- Capture and store static the background frame
16+
- Capture current frames and convert image into HSV colour space
17+
- Detect the defined color (red in our case) using color detection.
18+
- Segment out the color by generating cloak
19+
- Generate the final output by replacing cloak with background to create a resulting frame.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /