Skip to content

Commit

Permalink
feat: messaging systems
Browse files Browse the repository at this point in the history
Signed-off-by: freedisch <[email protected]>
  • Loading branch information
Freedisch committed Jan 27, 2024
1 parent 7e15372 commit 0b4f3fd
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
48 changes: 37 additions & 11 deletions aimodel/isFalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
cap1 = cv2.VideoCapture(0)


MIN_HEIGHT = 0.5 # adjust this value to change the threshold for detecting fall
MIN_HEIGHT = 0.5

bulk_sms = f""

def is_falling(pose_landmarks):
# Check if the height of the hip is lower than the threshold
hip_height = pose_landmarks.landmark[8].y
if hip_height < MIN_HEIGHT:
return True
Expand Down Expand Up @@ -59,13 +59,20 @@ def detect_fall(cap):
print("Fall detected")

if not fall_detected:
# Set the fall_detected flag to True and record the current time
fall_detected = True
start_time = time.time()
# Check if 60 seconds have passed since fall detection
if time.time() - start_time >= 60:
fall_detected = False
#safe_call() # Reset the flag if no fall is detected
data = db_contact()
json_data = json.dumps(data.data)
data = json.loads(json_data)
for i in data:
phone = i['phone_number']
name = i['name']
print("Test", phone)
print("Test", name)
safe_call(phone, name)
safe_message(phone, name)


cTime = time.time()
Expand Down Expand Up @@ -103,14 +110,30 @@ def safe_call(num, name):

message = client.calls.create(
url=os.getenv("URL_NUMBER"),
to=trum,
from_=os.getenv("CALLING_NUMBER"),
to="+250791349797",
from_=os.getenv("CALLING_NUMBER_SMS"),
timeout=100
#body='Tests'
)

print(message)

def safe_message(num, name):
account_sid = os.getenv("SID_NUMBER")
auth_token = os.getenv("TOKEN_NUMBER")
trum = str(num)
client = Client_twilio(account_sid, auth_token)

message = client.messages.create(
#url=os.getenv("URL_NUMBER"),
to=trum,
from_=os.getenv("CALLING_NUMBER_SMS"),
#timeout=100,
body=f"This is SafetyCall. We are reaching out to notify you that {name} is currently experiencing a seizure and are currently on the ground. We are taking immediate action to send you their current location for prompt assistance. Your swift attention is crucial. Kindly ensure you act promptly and take appropriate measures to assist your friend. If you have any questions or require further information, please do not hesitate to contact us. Thank you for your cooperation."
)
print(message)


def db_contact():
response = supabase.table('contacts').select("*").execute()
print(response)
Expand Down Expand Up @@ -171,10 +194,13 @@ def call():
tree.write("output.xml")
reverst_data()
data = json.loads(json_data)
phone = data[2]['phone_number']
name = data[2]['name']
print("Test", phone)
safe_call(phone, name)
for i in data:
phone = i['phone_number']
name = i['name']
print("Test", phone)
print("Test", name)
#safe_call(phone, name)
#safe_message(phone, name)
return Response(json_data)

if __name__ == '__main__':
Expand Down
8 changes: 3 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: safetycare
name: safetycall
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
Expand All @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: '>=3.1.3 <4.0.0'
sdk: ">=3.1.3 <4.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand All @@ -31,7 +31,6 @@ dependencies:
flutter:
sdk: flutter


# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
Expand All @@ -52,7 +51,6 @@ dev_dependencies:

# The following section is specific to Flutter packages.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
Expand Down

0 comments on commit 0b4f3fd

Please sign in to comment.