-
Notifications
You must be signed in to change notification settings - Fork 9
/
example_webcam.py
39 lines (28 loc) · 1013 Bytes
/
example_webcam.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
import config
import sys
import traceback
import time
from door_detect import Detector
from door_detect.cameras import Webcam
if __name__ == '__main__':
# set up camera object - if you have multiple cameras, changed this integer to reference their ID!
camera = Webcam(0)
try:
previousState = None
while True:
# get live webcam data in OpenCV format
inputImage = camera.getSnapshotCV()
# set up our detector object
detector = Detector(config.THRESHOLD, config.SHAPES, config.TEMPLATEDIR, config.HORIZ_ALIGN_THRESH, config.OUTPUTDIR, config.OUTPUT_DETECTION_IMAGE)
# get the current state of the door
currentState = detector.detectState(inputImage)
# output the state of the door
print("Current state: ", currentState[0])
#previousState = currentState
time.sleep(.2)
except Exception as e:
print("Fatal error.")
print(e)
print(traceback.format_exc())
camera.release()
sys.exit(1)