AI-powered companion for Alzheimer's patients with computer vision, face recognition, and context-aware assistance.
- Multi-source camera input: Webcam, iPhone (RTSP), or video file
- Real-time face recognition: InsightFace embeddings with relationship tracking
- Object detection: YOLOv8 for environmental awareness
- Robust RTSP handling: Automatic reconnection with exponential backoff
- Performance monitoring: FPS, latency, and frame drop tracking
✅ All 5 Scenarios - Voice-Enabled System: Complete hands-free interaction!
- Try it:
python unified_vision_voice.py --source webcam --index 0 - Say "Cura, what am I looking at?" (environment description)
- Say "Cura, who is this?" (face recognition with relationship)
- Say "Cura, where am I?" (location/orientation with reassurance)
- Automatic stress detection triggers comfort (emotional support)
- Continuous listening detects routines from conversation
- See: VOICE_INTERACTION_GUIDE.md
-
✅ Context-aware narration (Scenario 1): "You're in your living room. There's a couch in front of you. You're safe."
-
✅ Face recognition with memory (Scenario 2): "This is Sarah, your granddaughter."
- Unknown person handling
- Relationship context
- Optional notes from caregiver
-
✅ Adaptive routines (Scenario 3): Learn and remind about daily activities with caregiver approval
-
✅ Location orientation (Scenario 4): "You're at home, in your living room. Everything is okay."
- Reassurance-focused responses
- No technical GPS details
- Familiar object grounding
-
✅ Emotional comfort (Scenario 5): Stress detection with family voice playback
- Detects repeated anxious phrases
- Plays family voice recordings for reassurance
- Auto-triggers during stress or manual with '5' key
# Run quick setup
./quickstart.sh
# Or manually:
pip install -r requirements.txt# Run comprehensive test suite
python run_tests.pyAll tests should pass with just the base requirements. Optional backends (OpenAI, Ollama, Coqui TTS) enhance functionality but aren't required.
# Test webcam
python test_camera.py --source webcam --index 0
# Test iPhone via RTSP
python test_camera.py --source rtsp --url "rtsp://192.168.1.100:8554/live"
# Test video file
python test_camera.py --source file --path demo.mp4 --loop# With webcam
python vision.py --source webcam --index 0
# With iPhone (requires RTSP app)
python vision.py --source rtsp --url "rtsp://YOUR_IPHONE_IP:8554/live"
# With video file
python vision.py --source file --path demo.mp4 --loop --speed 1.0See IPHONE_CAMERA_SETUP.md for detailed instructions on:
- Installing RTSP server apps
- Network configuration
- Troubleshooting connectivity
- Performance optimization
Quick setup:
- Install "RTSP Camera" app on iPhone
- Start server and note the RTSP URL
- Run:
python vision.py --source rtsp --url "rtsp://YOUR_IP:8554/live"
While the vision pipeline is running:
- Press 'e' to enroll a face
- Enter name (e.g., "Sarah")
- Enter relationship (e.g., "granddaughter")
- Hold still for 10 frames
- Face is saved to local database
The system will recognize this person in future encounters.
- 'e': Enroll new face
- 'q': Quit
- 's' (in test mode): Save screenshot
-
camera_source.py: Camera abstraction layer
WebcamSource: Local USB/built-in cameraRTSPSource: Network stream with reconnectionVideoFileSource: Pre-recorded video playback
-
vision.py: Main vision pipeline
- YOLOv8 object detection
- InsightFace face recognition
- Real-time processing loop
-
orchestrator.py: AI orchestration layer
- Event-driven architecture
- OpenAI GPT integration
- Intent routing
- Routine reminders
-
test_camera.py: Performance testing utility
- FPS monitoring
- Latency measurement
- Frame drop detection
Face data stored locally in face_db/:
meta.json: Names and relationshipsembeddings.npz: Face embedding vectors
- Multi-source camera input
- Face recognition
- Object detection
- RTSP reconnection logic
- Bridge vision.py → orchestrator.py
- WorldState schema
- Context-aware narration
- Caregiver approval workflow
- FastAPI server
- Postgres + pgvector
- Face encounter logging
- Routine management API
- Web dashboard (Next.js)
- Unknown face queue
- Routine approval interface
- Activity logs
- Whisper STT integration
- Family voice recording
- Stress detection
- Calming audio playback
Create a .env file:
# OpenAI (for orchestrator)
OPENAI_API_KEY=your_key_here
OPENAI_MODEL=gpt-4o-mini
# Maps (for navigation)
GOOGLE_MAPS_KEY=your_key_here
HOME_ADDRESS="123 Main St, City, State"
# Camera
DEFAULT_CAMERA_SOURCE=webcam
DEFAULT_CAMERA_INDEX=0Edit constants in vision.py:
FACE_SIM_THRESHOLD = 0.30 # Face recognition sensitivity
ENROLL_SAMPLES = 10 # Frames to average for enrollment- Use GPU if available (automatically detected)
- Reduce resolution: Use 1280x720 instead of 1080p
- Lower confidence threshold: Fewer detections = faster processing
- Skip frames: Process every 2nd or 3rd frame for face recognition
- Good lighting: Face recognition needs clear visibility
- Frontal faces: Works best at 0-30° angle
- Reasonable distance: 2-6 feet from camera
- Multiple enrollment samples: Use 15-20 frames instead of 10
- Check device index with:
ls /dev/video*(Linux) or System Preferences (macOS) - Try different
--indexvalues (0, 1, 2, etc.)
- Verify iPhone and computer on same Wi-Fi
- Check RTSP URL format:
rtsp://IP:PORT/path - Ensure RTSP app is running on iPhone
- Check firewall settings
- Use
test_camera.pyto diagnose - Reduce camera resolution
- Use wired connection instead of Wi-Fi
- Close other applications
- Ensure good lighting
- Check face is clearly visible
- Verify FACE_SIM_THRESHOLD is appropriate
- Re-enroll with more samples
- Model: InsightFace buffalo_l (ArcFace)
- Embedding size: 512 dimensions
- Similarity: Cosine similarity with L2 normalization
- Threshold: 0.30 (adjustable)
- Model: YOLOv8n (nano - fastest variant)
- Input size: 960x960
- Confidence: 0.35
- Classes: 80 COCO classes
- Max consecutive failures: 30 frames
- Initial backoff: 1 second
- Max backoff: 30 seconds
- Backoff multiplier: 2x
- All processing on-device by default
- No video uploaded to servers
- Face embeddings stored locally
- Caregiver approval required for face registration
- Human-in-the-loop for all identity registration
- Clear consent from patient and family
- Caregiver oversight of all system actions
- No autonomous decision-making about care
This is a hackathon project for Alzheimer's care assistance. Key principles:
- Privacy first: Process locally when possible
- Human oversight: Never autonomous care decisions
- Gentle UX: Reassuring, not alarming
- Clinically aligned: Follow memory care best practices
MIT License - see LICENSE file for details
- YOLOv8: Ultralytics
- InsightFace: Face recognition models
- OpenCV: Computer vision library
- Clinical guidance from Alzheimer's care professionals