Real-time health monitoring and anomaly detection using wearable sensors and computer vision.
Samsung Galaxy Watch
│ (Health Connect / BLE)
▼
Android (Kotlin) ←──────────────────────────────────┐
SamsungHealthPlugin.kt │
WatchDataManager.kt │ Platform Channel
│ │
▼ │
Flutter App ──── WebSocket ────► FastAPI CV Backend │
Dashboard YOLOv8 + ByteTrack │
Camera feed overlay MediaPipe Pose │
Incident Report Anomaly Classifier │
GenAI Report (GPT) │
├── flutter_app/ # Flutter frontend (Riverpod, fl_chart)
│ ├── lib/
│ │ ├── main.dart
│ │ ├── screens/
│ │ │ ├── dashboard_screen.dart
│ │ │ ├── camera_screen.dart
│ │ │ └── report_screen.dart
│ │ ├── services/
│ │ │ ├── sensor_service.dart
│ │ │ ├── cv_service.dart
│ │ │ └── report_service.dart
│ │ ├── models/
│ │ │ ├── biometric_data.dart
│ │ │ └── incident_report.dart
│ │ └── widgets/
│ │ └── vital_card.dart
│ └── android/app/src/main/kotlin/com/yourapp/
│ ├── MainActivity.kt
│ ├── SamsungHealthPlugin.kt
│ └── WatchDataManager.kt
│
├── cv_backend/ # FastAPI computer vision server
│ ├── main.py
│ ├── routers/
│ │ ├── stream.py # WebSocket /ws/stream + POST /analyze/frame
│ │ └── report.py # POST /report/generate (GenAI)
│ ├── core/
│ │ ├── detector.py # YOLOv8 person detection
│ │ ├── tracker.py # ByteTrack multi-person tracking
│ │ ├── pose.py # MediaPipe pose estimation
│ │ └── anomaly.py # Fall / collapse / erratic motion rules
│ ├── schemas/
│ │ ├── sensor_payload.py
│ │ └── incident_report.py
│ ├── requirements.txt
│ └── Dockerfile
│
└── notebooks/ # Google Colab prototyping
├── cv_pipeline_prototype.ipynb
└── genai_report_prototype.ipynb
cd cv_backend
cp .env.example .env
# Edit .env — add your OPENAI_API_KEY
pip install -r requirements.txt
# Install ByteTrack from source
git clone https://github.com/ifzhang/ByteTrack
pip install -e ByteTrack/
# From cv_backend directory (so main:app resolves):
uvicorn main:app --reload --host 0.0.0.0 --port 8000--host 0.0.0.0— makes the service reachable from other devices on your network (e.g. phone, another PC). Uselocalhostor omit for local-only.--port 8000— change if 8000 is in use.
Then open the dashboard: http://localhost:8000/pose/view (or http://<this-machine-ip>:8000/pose/view from another device).
Test the health endpoint:
curl http://localhost:8000/healthcd flutter_app
flutter pub get
flutter runBefore running, update the backend URL in:
lib/services/cv_service.dart→_wsBaseUrllib/services/report_service.dart→_baseUrl
- Install the Health Connect app on the Android phone.
- Open Health Connect → grant permissions for Heart Rate, SpO2, Steps, Skin Temperature.
- Ensure your Galaxy Watch is paired and syncing to Health Connect.
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key for incident report generation |
INFERENCE_STRIDE |
Process every Nth frame (default: 2) |
SMTP_HOST |
SMTP server for sending report emails (e.g. smtp.gmail.com) |
SMTP_PORT |
SMTP port (default: 587) |
SMTP_USER |
SMTP login / sender account |
SMTP_PASSWORD |
SMTP password (use app password for Gmail) |
FROM_EMAIL |
Sender address (defaults to SMTP_USER) |
- Model weights (
*.pt) are auto-downloaded by Ultralytics and cached incv_backend/models/(gitignored). - All API keys must be set via environment variables — never hardcoded.
- The platform channel prefix
com.yourapp/must stay consistent across Kotlin and Dart.