-
Notifications
You must be signed in to change notification settings - Fork 0
/
SOFTWARE.py
32 lines (27 loc) · 871 Bytes
/
SOFTWARE.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
import numpy as np
import cv2
import time
cap = cv2.VideoCapture(0)
fgbg = cv2.createBackgroundSubtractorMOG2()
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('Smart_Recorder.avi',fourcc,20.0,(640,480))
while True :
got_pixels = 0
_, frame = cap.read()
fgmask = fgbg.apply(frame)
cv2.imshow('frame',frame)
cv2.imshow('mask',fgmask)
analytic = np.asarray(fgmask)
for i in analytic :
for j in i :
if j > 100:
got_pixels += 1
if (got_pixels/307200) > 0.03 :
out.write(frame)
time.sleep(0.001)
if cv2.waitKey(1) & 0xff == ord('q') :
print("pressed quit")
break
cap.release()
out.release()
cv2.destroyAllWindows()