A plug-and-play object recognition system using your MacBook M2 Pro's built-in camera. This project uses OpenCV for camera access and YOLOv8 (You Only Look Once) for real-time object detection.
- 🎥 Real-time object detection using your MacBook's camera
- 🚀 Fast and efficient YOLOv8 model (optimized for Apple Silicon)
- 📊 Displays bounding boxes, labels, and confidence scores
- 💾 Save frames with detected objects
- ⌨️ Interactive controls
cd visionProject
pip install -r requirements.txtNote: On first run, YOLOv8 will automatically download the model weights (~6MB for nano model).
python object_recognition.py- 'q' - Quit the application
- 's' - Save current frame as an image
- 'r' - Toggle object detection on/off
- Camera Access: Uses OpenCV to access your MacBook's built-in camera
- Object Detection: YOLOv8 model processes each frame to detect objects
- Visualization: Draws bounding boxes and labels around detected objects
- Real-time Processing: Optimized for smooth real-time performance on M2 Pro
The default uses YOLOv8n (nano) for fastest performance. You can change the model size in object_recognition.py:
recognizer = ObjectRecognizer(model_size='n') # Options: 'n', 's', 'm', 'l', 'x'- 'n' (nano) - Fastest, ~6MB, good for real-time
- 's' (small) - Balanced, ~22MB
- 'm' (medium) - Better accuracy, ~52MB
- 'l' (large) - High accuracy, ~87MB
- 'x' (xlarge) - Best accuracy, ~136MB
- Python 3.8+
- macOS (tested on MacBook M2 Pro)
- Camera permissions (granted automatically on first run)
- Make sure no other application is using the camera
- Grant camera permissions in System Settings > Privacy & Security > Camera
- Use the nano model ('n') for fastest performance
- Close other applications using the camera
- Reduce camera resolution in the code if needed
- Ensure you have an internet connection for the first run
- The model will be cached after first download
YOLOv8 can detect 80 different object classes including:
- People, animals (cats, dogs, birds, etc.)
- Vehicles (cars, trucks, buses, motorcycles, etc.)
- Electronics (cell phones, laptops, keyboards, etc.)
- Furniture (chairs, couches, tables, etc.)
- Sports equipment (sports balls, skateboards, etc.)
- And many more!
The application will display:
- Live video feed from your camera
- Bounding boxes around detected objects
- Object labels and confidence scores
- Frame counter and status information
This project is open source and available for personal and educational use.