Skip to content
sewonmPublic

About

UGAHacks 2026

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alzheimer's Assistant - Vision Pipeline

AI-powered companion for Alzheimer's patients with computer vision, face recognition, and context-aware assistance.

Features

Current Implementation

  • 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

Implemented Scenarios

✅ 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
  1. ✅ Context-aware narration (Scenario 1): "You're in your living room. There's a couch in front of you. You're safe."

  2. ✅ Face recognition with memory (Scenario 2): "This is Sarah, your granddaughter."

    • Unknown person handling
    • Relationship context
    • Optional notes from caregiver
  3. ✅ Adaptive routines (Scenario 3): Learn and remind about daily activities with caregiver approval

  4. ✅ 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
  5. ✅ 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

Quick Start

Installation

# Run quick setup
./quickstart.sh

# Or manually:
pip install -r requirements.txt

Run Tests

# Run comprehensive test suite
python run_tests.py

All tests should pass with just the base requirements. Optional backends (OpenAI, Ollama, Coqui TTS) enhance functionality but aren't required.

Test Camera Connection

# 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

Run Vision Pipeline

# 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.0

iPhone Camera Setup

See IPHONE_CAMERA_SETUP.md for detailed instructions on:

  • Installing RTSP server apps
  • Network configuration
  • Troubleshooting connectivity
  • Performance optimization

Quick setup:

  1. Install "RTSP Camera" app on iPhone
  2. Start server and note the RTSP URL
  3. Run: python vision.py --source rtsp --url "rtsp://YOUR_IP:8554/live"

Usage

Face Enrollment

While the vision pipeline is running:

  1. Press 'e' to enroll a face
  2. Enter name (e.g., "Sarah")
  3. Enter relationship (e.g., "granddaughter")
  4. Hold still for 10 frames
  5. Face is saved to local database

The system will recognize this person in future encounters.

Controls

  • 'e': Enroll new face
  • 'q': Quit
  • 's' (in test mode): Save screenshot

Architecture

Files

  • camera_source.py: Camera abstraction layer

    • WebcamSource: Local USB/built-in camera
    • RTSPSource: Network stream with reconnection
    • VideoFileSource: 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

Database

Face data stored locally in face_db/:

  • meta.json: Names and relationships
  • embeddings.npz: Face embedding vectors

Development Roadmap

Phase 1: Core Vision ✅

  • Multi-source camera input
  • Face recognition
  • Object detection
  • RTSP reconnection logic

Phase 2: Integration (In Progress)

  • Bridge vision.py → orchestrator.py
  • WorldState schema
  • Context-aware narration
  • Caregiver approval workflow

Phase 3: Backend

  • FastAPI server
  • Postgres + pgvector
  • Face encounter logging
  • Routine management API

Phase 4: Caregiver UI

  • Web dashboard (Next.js)
  • Unknown face queue
  • Routine approval interface
  • Activity logs

Phase 5: Voice & Comfort

  • Whisper STT integration
  • Family voice recording
  • Stress detection
  • Calming audio playback

Configuration

Environment Variables

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=0

Camera Parameters

Edit constants in vision.py:

FACE_SIM_THRESHOLD = 0.30  # Face recognition sensitivity
ENROLL_SAMPLES = 10        # Frames to average for enrollment

Performance Tips

For Real-time Performance

  1. Use GPU if available (automatically detected)
  2. Reduce resolution: Use 1280x720 instead of 1080p
  3. Lower confidence threshold: Fewer detections = faster processing
  4. Skip frames: Process every 2nd or 3rd frame for face recognition

For Better Accuracy

  1. Good lighting: Face recognition needs clear visibility
  2. Frontal faces: Works best at 0-30° angle
  3. Reasonable distance: 2-6 feet from camera
  4. Multiple enrollment samples: Use 15-20 frames instead of 10

Troubleshooting

"Could not open camera"

  • Check device index with: ls /dev/video* (Linux) or System Preferences (macOS)
  • Try different --index values (0, 1, 2, etc.)

"Failed to connect to RTSP stream"

  • 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

Low FPS / High Latency

  • Use test_camera.py to diagnose
  • Reduce camera resolution
  • Use wired connection instead of Wi-Fi
  • Close other applications

Face Recognition Not Working

  • Ensure good lighting
  • Check face is clearly visible
  • Verify FACE_SIM_THRESHOLD is appropriate
  • Re-enroll with more samples

Technical Details

Face Recognition

  • Model: InsightFace buffalo_l (ArcFace)
  • Embedding size: 512 dimensions
  • Similarity: Cosine similarity with L2 normalization
  • Threshold: 0.30 (adjustable)

Object Detection

  • Model: YOLOv8n (nano - fastest variant)
  • Input size: 960x960
  • Confidence: 0.35
  • Classes: 80 COCO classes

RTSP Reconnection

  • Max consecutive failures: 30 frames
  • Initial backoff: 1 second
  • Max backoff: 30 seconds
  • Backoff multiplier: 2x

Privacy & Ethics

Data Handling

  • All processing on-device by default
  • No video uploaded to servers
  • Face embeddings stored locally
  • Caregiver approval required for face registration

Ethical Considerations

  • 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

Contributing

This is a hackathon project for Alzheimer's care assistance. Key principles:

  1. Privacy first: Process locally when possible
  2. Human oversight: Never autonomous care decisions
  3. Gentle UX: Reassuring, not alarming
  4. Clinically aligned: Follow memory care best practices

License

MIT License - see LICENSE file for details

Acknowledgments

  • YOLOv8: Ultralytics
  • InsightFace: Face recognition models
  • OpenCV: Computer vision library
  • Clinical guidance from Alzheimer's care professionals

About

UGAHacks 2026

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages