#include <Servo.
h>
Servo leftMotor;
Servo rightMotor;
int buzzer = 7;
int led = 6;
void setup() {
[Link](9600);
[Link](9);
[Link](10);
pinMode(buzzer, OUTPUT);
pinMode(led, OUTPUT);
}
void loop() {
if ([Link]() > 0) {
char command = [Link]();
if (command == 'M') { // Move forward
[Link](180);
[Link](0);
delay(3000);
[Link](90);
[Link](90);
} else if (command == 'S') { // Stop
[Link](90);
[Link](90);
} else if (command == 'B') { // Activate Buzzer & LED
digitalWrite(buzzer, HIGH);
digitalWrite(led, HIGH);
delay(2000);
digitalWrite(buzzer, LOW);
digitalWrite(led, LOW);
}
}
}
import cv2
import mediapipe as mp
import numpy as np
import requests
import serial
import speech_recognition as sr
import tensorflow as tf
from [Link] import load_model
# Load ML model for improved fall detection
fall_model = load_model("fall_detection_model.h5")
# Initialize Pose Detection
mp_pose = [Link]
pose = mp_pose.Pose()
# ESP32-CAM Stream URL
ESP32_URL = "[Link]
# Initialize Serial Communication (for Arduino)
arduino = [Link]('/dev/ttyUSB0', 9600, timeout=1)
# Initialize Speech Recognition
recognizer = [Link]()
# Function to detect fall using ML model
def is_fall_detected(landmarks):
keypoints = [Link]([[lm.x, lm.y] for lm in landmarks]).flatten()
prediction = fall_model.predict(np.expand_dims(keypoints, axis=0))
return prediction[0] > 0.7 # Threshold for fall detection
# Function to process voice commands
def process_voice_command():
with [Link]() as source:
print("Listening for command...")
audio = [Link](source)
try:
command = recognizer.recognize_google(audio).lower()
print("Command:", command)
if "come here" in command:
[Link](b'M') # Move to person
elif "stop" in command:
[Link](b'S') # Stop robot
except:
print("Could not understand command.")
# Open Video Stream
cap = [Link](ESP32_URL)
while [Link]():
ret, frame = [Link]()
if not ret:
break
rgb_frame = [Link](frame, cv2.COLOR_BGR2RGB)
results = [Link](rgb_frame)
if results.pose_landmarks:
landmarks = results.pose_landmarks.landmark
# ML-based Fall Detection
if is_fall_detected(landmarks):
[Link](frame, "FALL DETECTED!", (50, 50),
cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)
# Send alert
[Link]("[Link] data={"status": "Fall
detected!"})
# Notify Arduino
[Link](b'M') # Move towards person
[Link](b'B') # Activate buzzer
# Show output
[Link]("Fall Detection", frame)
# Listen for voice commands
process_voice_command()
if [Link](10) & 0xFF == ord('q'):
break
[Link]()
[Link]()
#include <WiFi.h>
#include <esp32cam.h>
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";
void startCameraServer();
void setup() {
[Link](115200);
[Link](ssid, password);
while ([Link]() != WL_CONNECTED) {
delay(1000);
[Link]("Connecting to WiFi...");
}
[Link]("Connected to WiFi!");
startCameraServer();
}
void loop() {
delay(1000);
}