wincam   A
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 0
1
'''reads the camera'''
2
#image gets written in parent (startup directory!)
3
4
import cv2
5
6
CAM = cv2.VideoCapture(0)
7
8
cv2.namedWindow("test")
9
10
COUNTER = 0
11
12
while True:
13
    RET, FRAME = CAM.read()
14
    cv2.imshow("test", FRAME)
15
    if not RET:
16
        break
17
    k = cv2.waitKey(1)
18
19
    if k%256 == 27:
20
        # ESC pressed
21
        print("Escape hit, closing...")
22
        break
23
    elif k%256 == 32:
24
        # SPACE pressed
25
        IMAGENAME = "fullcycle_{}.png".format(COUNTER)
26
        cv2.imwrite(IMAGENAME, FRAME)
27
        print("{} written!".format(IMAGENAME))
28
        COUNTER += 1
29
30
CAM.release()
31
32
cv2.destroyAllWindows()
33