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 a12ea83

Browse files
Invisibility_Cloak is added
1 parent b6adc71 commit a12ea83

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-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()

0 commit comments

Comments
(0)

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