-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript_working.py
115 lines (93 loc) · 3.21 KB
/
script_working.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import dbus
import numpy as np
import cv2
import time
import sys
print("ppp")
cap = cv2.VideoCapture(0)
fist_cascade = cv2.CascadeClassifier('fist.xml')
palm_cascade = cv2.CascadeClassifier('palm_v4.xml')
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
'org.ofono.Manager')
modems = manager.GetModems()
for path, properties in modems:
#print "[ %s ]" % (path)
#print("Currently in check_call_first.py")
if "org.ofono.VoiceCallManager" not in properties["Interfaces"]:
continue
mgr = dbus.Interface(bus.get_object('org.ofono', path),
'org.ofono.VoiceCallManager')
calls = mgr.GetCalls()
for path, properties in calls:
state = properties["State"]
#print "[ %s ] %s" % (path, state)
call = dbus.Interface(bus.get_object('org.ofono', path),
'org.ofono.VoiceCall')
def hang_up():
modem = modems[0][0]
print("Currently in hangup_all_calls.py")
if (len(sys.argv) == 2):
modem = sys.argv[1]
mgr = dbus.Interface(bus.get_object('org.ofono', modem),
'org.ofono.VoiceCallManager')
mgr.HangupAll()
def check():
for paths, properties in calls:
state = properties["State"]
if state == "incoming":
return 1
else:
return 0
def recieve_call():
for path, properties in calls:
state = properties["State"]
#print "[ %s ] %s" % (path, state)
#print("Currently in answer_calls.py")
if state != "incoming":
#print("No Incoming calls!")
continue
call.Answer()
def check_for_signal():
while (True):
if(check()==0):
return 0
ret, img=cap.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#print("Currently in incoming_call.py")
fists = fist_cascade.detectMultiScale(gray, 1.3, 5)
palms = palm_cascade.detectMultiScale(gray, 1.3, 5)
cv2.imshow('img', img)
# Accept
for (x,y,w,h) in fists:
#cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2)
#cv2.imshow('img',img)
#cap.release()
cv2.destroyAllWindows()
return 1
# Decline:
for (x,y,w,h) in palms:
#cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),2)
#cv2.imshow('img',img)
#cap.release()
cv2.destroyAllWindows()
return 0
cv2.waitKey(150)
if __name__ == "__main__":
print("Check if there is an incoming call:")
print("sss")
print("Is it in loop?")
tyu = check()
if(tyu):
print("Now there is a call, so we need to ask what to do:")
if(check_for_signal()):
print("the user has given fist:")
recieve_call()
print("Now that we have recived a call, we need to know if the call is still active:")
while(check()):
if(check_for_signal()==0):
print("the call is still active, user seeks termination signal:")
hang_up()
else:
print("the user wants to terminate the call:")
hang_up()