-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathexample.py
45 lines (33 loc) · 1.19 KB
/
example.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
44
45
import config
import sys
import traceback
import time
from door_detect import Detector
from door_detect.cameras import Foscam
if __name__ == '__main__':
try:
# used for local testing
#inputImage = cv2.imread('door_down.jpg')
previousState = None
while True:
# set up camera object
camera = Foscam(config.CAMADDRESS, config.USERNAME, config.PASSWORD)
# 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)
# experimental
#if(previousState != None):
# statesDiff = detector.diffStates(currentState, previousState)
# print statesDiff
# 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())
sys.exit(1)