A comprehensive AI-powered baby monitoring system with advanced sleeping position detection, face recognition, and safety alerts.
- Real-time Position Tracking: Detects back, side, and prone sleeping positions
- MediaPipe Integration: Uses advanced pose estimation for accurate detection
- Safety Alerts: Immediate notifications for unsafe prone positions
- Confidence Scoring: Reliability metrics for each detection
- Visual Overlays: Bounding boxes and pose landmarks on video feed
- Enhanced Face Detection: Supports side faces and partial visibility
- Eye State Monitoring: Detects open/closed eyes for sleep analysis
- Face Orientation: Determines viewing angle and profile type
- Robust Tracking: Handles face loss and recovery gracefully
- Multi-factor Detection: Combines motion, sound, face, and eye data
- Smart State Logic: Accurate sleeping/awake/unknown classifications
- Context Awareness: Considers all available information for decisions
- Cry Detection: AI-powered baby cry identification
- Sound Level Tracking: Real-time audio level visualization
- Background Processing: Continuous audio analysis
- Live Video Feed: Real-time video with position overlays
- Status Monitoring: Current position, confidence, and sleep state
- Interactive Controls: Pause, resume, and configuration options
- Responsive Design: Works on desktop and mobile devices
- Prone Position Alerts: Warnings for stomach-down sleeping
- Face Loss Monitoring: Alerts when baby is not visible
- Automatic Recording: Captures video during safety events
- Configurable Thresholds: Customizable alert sensitivity
- Python 3.8 or higher
- Webcam or camera device
- Microphone (optional, for audio monitoring)
-
Clone the repository
git clone <repository-url> cd ProjectBBY
-
Install dependencies
pip install -r requirements.txt
-
Configure settings (optional)
# Edit config/settings.json to customize detection thresholds -
Run the system
python src/main.py
-
Access dashboard
- Open browser to
http://localhost:5001 - View live feed and monitoring data
- Open browser to
- Camera: USB webcam or built-in camera
- CPU: Intel i5 or equivalent (for real-time processing)
- RAM: 4GB minimum, 8GB recommended
- Storage: 1GB free space (for recordings)
- OS: Windows 10/11, macOS 10.14+, or Linux
- Python: 3.8, 3.9, 3.10, or 3.11
- Browser: Chrome, Firefox, Safari, or Edge
{
"detection": {
"position": {
"enabled": true,
"confidence_threshold": 0.6,
"alert_prone_time": 300
},
"face": {
"min_detection_confidence": 0.5,
"ear_threshold": 0.2,
"face_loss_timeout": 10
},
"sleep": {
"motion_threshold": 5,
"sound_threshold": 0.02,
"consecutive_frames": 90
}
}
}- Position Detection: Enable/disable and set confidence thresholds
- Alert Timing: How long to wait before triggering prone position alerts
- Face Detection: Sensitivity and tracking parameters
- Sleep Detection: Motion and sound thresholds for sleep determination
- Baby lying on back, face visible and upward
- Shoulders and hips symmetric
- Safety: Recommended sleeping position
- Color Code: Green
- Baby lying on side, one shoulder/hip higher
- May show profile view of face
- Safety: Generally safe but monitor
- Color Code: Orange
- Baby lying on stomach, face may not be visible
- Body oriented horizontally
- Safety: Immediate attention needed
- Color Code: Red
- Insufficient data for reliable detection
- Baby not clearly visible or pose unclear
- Safety: Manual verification recommended
- Color Code: Gray
python quick_test.pyVerifies all modules are working correctly.
python test_integration.pyComprehensive testing of all system components.
python demo_position_detection.pyLive demonstration of position detection features.
ProjectBBY/
βββ src/ # Source code
β βββ main.py # Main application
β βββ position_detector.py # Position detection (NEW)
β βββ face_detector.py # Face & eye detection
β βββ sleep_detector.py # Sleep state analysis
β βββ motion_detector.py # Motion detection
β βββ cry_detector.py # Audio cry detection
β βββ alert_manager.py # Alert system
β βββ recorder.py # Video recording
β βββ gui/
β βββ dashboard.py # Web dashboard
βββ templates/ # Web templates
β βββ index.html # Dashboard interface
βββ static/ # Web assets
β βββ style.css # Dashboard styling
β βββ script.js # Dashboard JavaScript
βββ config/ # Configuration
β βββ settings.json # System settings
βββ media/ # Recordings storage
βββ logs/ # System logs
βββ tests/ # Test files
- Check camera permissions
- Verify camera device ID in settings
- Try different USB port or camera
- Reduce video resolution in settings
- Lower detection confidence thresholds
- Close other resource-intensive applications
- Ensure good lighting conditions
- Check camera angle and distance
- Adjust confidence thresholds in config
- Check if port 5001 is available
- Verify firewall settings
- Try different browser
Enable detailed logging by setting log level to DEBUG in config/settings.json:
{
"logging": {
"level": "DEBUG"
}
}- This system is a monitoring aid, NOT a medical device
- Always follow safe sleep guidelines from pediatric experts
- Do not rely solely on automated alerts for baby safety
- Regularly check on your baby regardless of system status
- Consult healthcare professionals for sleep safety advice
- Create feature branch
- Implement changes with tests
- Update documentation
- Submit pull request
- Follow PEP 8 guidelines
- Add docstrings to all functions
- Include type hints where applicable
- Write unit tests for new features
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.
For support, questions, or feature requests:
- Create an issue on GitHub
- Check the troubleshooting section
- Review the documentation
- β Added sleeping position detection
- β Enhanced face detection with side face support
- β Improved sleep state logic
- β Updated dashboard with position display
- β Added safety alerts and visual overlays
- Basic video monitoring
- Face and eye detection
- Motion detection
- Audio cry detection
- Web dashboard
Made with β€οΈ for baby safety and parental peace of mind