forked from Illinois-IoT/main-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoor.py
49 lines (33 loc) · 1.03 KB
/
door.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
46
47
48
49
import threading
import sys
'''
preliminary project:
runs alarm until movement at door is seen
'''
from utils import *
def MostRecentMovement():
index = get_counter()
img1 = cv2.imread('../images/pic' + str(index - 1), cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread('../images/pic' + str(index), cv2.IMREAD_GRAYSCALE)
if(IdentifyMovement(img1, img2) != None):
#movement is found
sys.exit()
#first thread takes pictures at given time intervals until result from second thread is found
'''
thread1 = threading.Thread(target = capture_images, args = {delay=2.0, forever=True} )
thread2 = threading.Thread(target = MostRecentMovement)
thread3 = threading.Thread(target = play_alarm)
thread1.start()
thread2.start()
thread2.start()
thread1.join()
thread2.join()
thread3.join()
'''
img1 = cv2.imread('../images/pic2.jpg', cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread('../images/pic3.jpg', cv2.IMREAD_GRAYSCALE)
cv2.imshow("mm", img1)
cv2.waitKey()
#print(img1)
#print(img2)
print(identifyMovement_ssim(img1, img2))