forked from sat5297/hacktober-coding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inv_cloak.py
45 lines (28 loc) · 888 Bytes
/
inv_cloak.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'''
This project is done using only openCV.
No Machine Learning or Deep Learning concepts/algos have been used.
'''
import cv2
import numpy as np
cam = cv2.VideoCapture(0) #captures the video.
i = 0
while i<50:
i+=1
_, background = cam.read()
replace = cv2.resize(background,(1000,1000))
while True:
_,frame = cam.read()
frame = cv2.resize(frame,(1000,1000))
hsv = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
lower_blue = np.array([64,74,0])
upper_blue = np.array([111,255,251])
mask = cv2.inRange(hsv,lower_blue,upper_blue)
mask_inv = cv2.bitwise_not(mask)
IL = cv2.bitwise_and(frame, frame, mask=mask_inv)
CL = cv2.bitwise_and(replace, replace, mask=mask)
final_img = cv2.add(IL,CL)
cv2.imshow('image', final_img)
if cv2.waitKey(50) & 0xFF == ord('q'):
break
cam.release()
cv2.destroyAllWindows()