A 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.
- Real-time AI Classification: Live desk work activity detection using YOLOv8
- Multi-Camera Support: Works with MacBook cameras and iPhone cameras
- Person & Equipment Detection: Identifies people, laptops, keyboards, mice, and phones
- Pose Analysis: Advanced body posture analysis for accurate work state detection
- Live Statistics: Real-time counts of working vs. idle people
- High Performance: Optimized frame processing with adjustable quality modes
- π’ Working: Person at desk with active working posture
- π‘ At Desk: Person at desk but not actively engaged
- π At Desk (Idle): Person at desk with minimal activity
- π΄ Away from Desk: Person not positioned at workspace
- Python 3.8+
- macOS (tested on macOS 13+)
- Camera access permissions
-
Clone the repository
git clone https://github.com/yourusername/cam-feed-ai-classifier.git cd cam-feed-ai-classifier -
Install dependencies
# Using pipenv (recommended) pipenv install # Or using pip pip install -r requirements.txt
-
Grant camera permissions
- System Preferences β Security & Privacy β Camera
- Enable access for Terminal/IDE
pipenv shell
python main.py- iPhone: Settings β General β AirPlay & Handoff β Continuity Camera β
- Mac: System Settings β General β AirPlay & Handoff β iPhone Widgets β
- Keep iPhone unlocked and nearby
Then run:
pipenv run python main.py| Key | Action |
|---|---|
q |
Quit application |
s |
Save current frame |
t |
Test camera connection |
f |
Toggle full processing mode |
c |
Show available cameras |
r |
Reset/restart detection |
cam-feed-ai-classifier/
βββ LICENSE # Project license
βββ Pipfile # Pipenv dependencies
βββ Pipfile.lock # Locked dependency versions
βββ main.py # Main application
βββ pyproject.toml # Project configuration
βββ .gitignore # Git ignore rules
βββ .pre-commit-config.yaml # Pre-commit hooks
βββ README.md # This file
The system automatically detects available cameras:
- Index 0: MacBook built-in camera (1280x720)
- Index 1: iPhone/external camera (1920x1080+)
- Index 2+: Additional cameras
Edit confidence thresholds in main.py:
# Object detection confidence
obj_results = self.yolo_model.predict(frame, conf=0.3)
# Working pose threshold
is_working = working_score > 0.5 # Adjust 0.1-0.9# Frame processing (every Nth frame)
skip_frames = 2 # Process every 3rd frame
# Camera resolution
self.cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920) # Higher = better quality
self.cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080) # Higher = slower processing- Object Detection (YOLOv8): Detects persons and work equipment
- Spatial Analysis: Determines desk positioning relationships
- Pose Estimation (YOLOv8-pose): Analyzes body keypoints
- Classification Logic: Combines spatial + pose data for final status
- Real-time Display: Live visualization with statistics
- Proximity Check: Person within range of work equipment
- Posture Analysis: Sitting position, shoulder alignment, head orientation
- Hand Position: Typing posture detection via wrist/elbow keypoints
- Engagement Score: Combined confidence metric (0.0-1.0)
The interface shows:
- Live camera feed with bounding boxes
- Person classifications with confidence scores
- Equipment detection highlights
- Real-time statistics (People | At Desk | Working)
- Processing mode and timestamp
- Camera resolution info
# Test camera availability
python -c "import cv2; print([cv2.VideoCapture(i).isOpened() for i in range(5)])"Common Solutions:
- Close other camera apps (Zoom, Teams, etc.)
- Restart Terminal/IDE after granting permissions
- Try different camera indices (0, 1, 2)
- For iPhone: ensure same Apple ID, WiFi/Bluetooth enabled
- Use MacBook camera for better performance
- Reduce resolution in camera settings
- Increase frame skipping (
skip_frames = 3) - Toggle full processing mode with
fkey
- Ensure good lighting conditions
- Position camera to capture full desk area
- Use iPhone camera for higher resolution
- Adjust confidence thresholds
- ultralytics: YOLOv8 models for detection and pose estimation
- opencv-python: Computer vision and camera handling
- numpy: Numerical computations for pose analysis
- yolov8n.pt: Lightweight object detection (~6MB)
- yolov8n-pose.pt: Human pose estimation (~6MB)
Models are automatically downloaded on first run.
- Class 0: Person
- Class 56: Chair
- Class 63: Laptop
- Class 64: Mouse
- Class 66: Keyboard
- Class 67: Cell phone
Typical Performance:
- MacBook Camera: ~15-20 FPS (720p)
- iPhone Camera: ~10-15 FPS (1080p)
- Detection Accuracy: ~85-90% in good lighting
System Requirements:
- RAM: 4GB+ recommended
- CPU: Modern Intel/Apple Silicon
- Storage: 200MB for models and dependencies
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please run pre-commit hooks before submitting:
pre-commit run --all-filesThis project is licensed under the MIT License - see the LICENSE file for details.
- Ultralytics for YOLOv8 models
- OpenCV for computer vision capabilities
- COCO dataset for training data
This tool processes camera feeds locally. Please respect privacy laws and obtain consent when monitoring individuals in workplace environments.
Made with β€οΈ at Datum Brain for productivity insights.