{"id":30407688,"url":"https://github.com/datumbrain/cam-feed-ai-classifier","last_synced_at":"2025-08-21T20:44:13.313Z","repository":{"id":306090422,"uuid":"1024979587","full_name":"datumbrain/cam-feed-ai-classifier","owner":"datumbrain","description":"Camera feed AI classifier tested with iPhone continuity camera. Using Yolo (v8).","archived":false,"fork":false,"pushed_at":"2025-07-23T14:42:52.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-23T16:30:52.570Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datumbrain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-23T14:33:42.000Z","updated_at":"2025-07-23T14:42:55.000Z","dependencies_parsed_at":"2025-07-23T16:30:55.050Z","dependency_job_id":"5237cf1b-1f51-417b-919a-8708c3f94d9c","html_url":"https://github.com/datumbrain/cam-feed-ai-classifier","commit_stats":null,"previous_names":["datumbrain/cam-feed-ai-classifier"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/datumbrain/cam-feed-ai-classifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datumbrain%2Fcam-feed-ai-classifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datumbrain%2Fcam-feed-ai-classifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datumbrain%2Fcam-feed-ai-classifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datumbrain%2Fcam-feed-ai-classifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datumbrain","download_url":"https://codeload.github.com/datumbrain/cam-feed-ai-classifier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datumbrain%2Fcam-feed-ai-classifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271538667,"owners_count":24777479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-21T20:44:10.778Z","updated_at":"2025-08-21T20:44:13.278Z","avatar_url":"https://github.com/datumbrain.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cam-feed-ai-classifier\n\nA real-time AI-powered camera feed classifier that uses YOLOv8 to detect and classify whether people are actively working at their desks. Supports both MacBook built-in cameras and iPhone cameras via Continuity Camera.\n\n![Python](https://img.shields.io/badge/python-v3.10+-blue.svg)\n![OpenCV](https://img.shields.io/badge/opencv-4.8+-green.svg)\n![YOLOv8](https://img.shields.io/badge/YOLOv8-ultralytics-orange.svg)\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n\n## 🚀 Features\n\n- **Real-time AI Classification**: Live desk work activity detection using YOLOv8\n- **Multi-Camera Support**: Works with MacBook cameras and iPhone cameras\n- **Person \u0026 Equipment Detection**: Identifies people, laptops, keyboards, mice, and phones\n- **Pose Analysis**: Advanced body posture analysis for accurate work state detection\n- **Live Statistics**: Real-time counts of working vs. idle people\n- **High Performance**: Optimized frame processing with adjustable quality modes\n\n## 📊 Classifications\n\n- 🟢 **Working**: Person at desk with active working posture\n- 🟡 **At Desk**: Person at desk but not actively engaged\n- 🟠 **At Desk (Idle)**: Person at desk with minimal activity\n- 🔴 **Away from Desk**: Person not positioned at workspace\n\n## 🛠️ Installation\n\n### Prerequisites\n\n- Python 3.8+\n- macOS (tested on macOS 13+)\n- Camera access permissions\n\n### Setup\n\n1. **Clone the repository**\n\n   ```bash\n   git clone https://github.com/yourusername/cam-feed-ai-classifier.git\n   cd cam-feed-ai-classifier\n   ```\n\n2. **Install dependencies**\n\n   ```bash\n   # Using pipenv (recommended)\n   pipenv install\n\n   # Or using pip\n   pip install -r requirements.txt\n   ```\n\n3. **Grant camera permissions**\n   - **System Preferences** → **Security \u0026 Privacy** → **Camera**\n   - Enable access for Terminal/IDE\n\n## 🎯 Quick Start\n\n### MacBook Camera\n\n```bash\npipenv shell\npython main.py\n```\n\n### iPhone Camera Setup\n\n#### **Method 1: Continuity Camera (macOS 13+)**\n\n1. iPhone: Settings → General → AirPlay \u0026 Handoff → Continuity Camera ✓\n2. Mac: System Settings → General → AirPlay \u0026 Handoff → iPhone Widgets ✓\n3. Keep iPhone unlocked and nearby\n\n#### **Method 2: Third-party Apps**\n\n- Install [Camo](https://reincubate.com/camo/) or [EpocCam](https://www.elgato.com/epoccam)\n- Connect via USB or WiFi\n\nThen run:\n\n```bash\npipenv run python main.py\n```\n\n## ⌨️ Controls\n\n| Key | Action                      |\n| --- | --------------------------- |\n| `q` | Quit application            |\n| `s` | Save current frame          |\n| `t` | Test camera connection      |\n| `f` | Toggle full processing mode |\n| `c` | Show available cameras      |\n| `r` | Reset/restart detection     |\n\n## 📁 Project Structure\n\n```raw\ncam-feed-ai-classifier/\n├── LICENSE                   # Project license\n├── Pipfile                   # Pipenv dependencies\n├── Pipfile.lock              # Locked dependency versions\n├── main.py                   # Main application\n├── pyproject.toml            # Project configuration\n├── .gitignore                # Git ignore rules\n├── .pre-commit-config.yaml   # Pre-commit hooks\n└── README.md                 # This file\n```\n\n## 🔧 Configuration\n\n### Camera Detection\n\nThe system automatically detects available cameras:\n\n- **Index 0**: MacBook built-in camera (1280x720)\n- **Index 1**: iPhone/external camera (1920x1080+)\n- **Index 2+**: Additional cameras\n\n### Adjusting Sensitivity\n\nEdit confidence thresholds in `main.py`:\n\n```python\n# Object detection confidence\nobj_results = self.yolo_model.predict(frame, conf=0.3)\n\n# Working pose threshold\nis_working = working_score \u003e 0.5  # Adjust 0.1-0.9\n```\n\n### Performance Tuning\n\n```python\n# Frame processing (every Nth frame)\nskip_frames = 2  # Process every 3rd frame\n\n# Camera resolution\nself.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)   # Higher = better quality\nself.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)  # Higher = slower processing\n```\n\n## 🧠 How It Works\n\n### AI Pipeline\n\n1. **Object Detection** (YOLOv8): Detects persons and work equipment\n2. **Spatial Analysis**: Determines desk positioning relationships\n3. **Pose Estimation** (YOLOv8-pose): Analyzes body keypoints\n4. **Classification Logic**: Combines spatial + pose data for final status\n5. **Real-time Display**: Live visualization with statistics\n\n### Detection Logic\n\n- **Proximity Check**: Person within range of work equipment\n- **Posture Analysis**: Sitting position, shoulder alignment, head orientation\n- **Hand Position**: Typing posture detection via wrist/elbow keypoints\n- **Engagement Score**: Combined confidence metric (0.0-1.0)\n\n## 🎛️ Output Display\n\nThe interface shows:\n\n- Live camera feed with bounding boxes\n- Person classifications with confidence scores\n- Equipment detection highlights\n- Real-time statistics (People | At Desk | Working)\n- Processing mode and timestamp\n- Camera resolution info\n\n## 🐛 Troubleshooting\n\n### Camera Issues\n\n```bash\n# Test camera availability\npython -c \"import cv2; print([cv2.VideoCapture(i).isOpened() for i in range(5)])\"\n```\n\n**Common Solutions:**\n\n- Close other camera apps (Zoom, Teams, etc.)\n- Restart Terminal/IDE after granting permissions\n- Try different camera indices (0, 1, 2)\n- For iPhone: ensure same Apple ID, WiFi/Bluetooth enabled\n\n### Performance Issues\n\n- Use MacBook camera for better performance\n- Reduce resolution in camera settings\n- Increase frame skipping (`skip_frames = 3`)\n- Toggle full processing mode with `f` key\n\n### Detection Quality\n\n- Ensure good lighting conditions\n- Position camera to capture full desk area\n- Use iPhone camera for higher resolution\n- Adjust confidence thresholds\n\n## 🔬 Technical Details\n\n### Dependencies\n\n- **ultralytics**: YOLOv8 models for detection and pose estimation\n- **opencv-python**: Computer vision and camera handling\n- **numpy**: Numerical computations for pose analysis\n\n### Models\n\n- **yolov8n.pt**: Lightweight object detection (~6MB)\n- **yolov8n-pose.pt**: Human pose estimation (~6MB)\n\nModels are automatically downloaded on first run.\n\n### COCO Classes Used\n\n- Class 0: Person\n- Class 56: Chair\n- Class 63: Laptop\n- Class 64: Mouse\n- Class 66: Keyboard\n- Class 67: Cell phone\n\n## 📊 Performance\n\n**Typical Performance:**\n\n- MacBook Camera: ~15-20 FPS (720p)\n- iPhone Camera: ~10-15 FPS (1080p)\n- Detection Accuracy: ~85-90% in good lighting\n\n**System Requirements:**\n\n- RAM: 4GB+ recommended\n- CPU: Modern Intel/Apple Silicon\n- Storage: 200MB for models and dependencies\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit changes (`git commit -m 'Add amazing feature'`)\n4. Push to branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\nPlease run pre-commit hooks before submitting:\n\n```bash\npre-commit run --all-files\n```\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- [Ultralytics](https://ultralytics.com/) for YOLOv8 models\n- [OpenCV](https://opencv.org/) for computer vision capabilities\n- COCO dataset for training data\n\n## ⚠️ Privacy Notice\n\nThis tool processes camera feeds locally. Please respect privacy laws and obtain consent when monitoring individuals in workplace environments.\n\n---\n\nMade with ❤️ at Datum Brain for productivity insights.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatumbrain%2Fcam-feed-ai-classifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatumbrain%2Fcam-feed-ai-classifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatumbrain%2Fcam-feed-ai-classifier/lists"}