Artificial intelligenceAn Object-Recognising Camera with Raspberry Pi 5
A camera watches the room and a neural network recognises 80 kinds of object in real time, among them people, cats and cups.
- Difficulty
- Advanced
- Time
- 3 h
- Age
- 14+
- Parts
- 4, 4 on the site
Written by the RoboHub team. A question? Write to us.
Variations
Choose a variation and the parts list updates.
Instructions
The system
Write Raspberry Pi OS (64-bit) to the microSD card with Raspberry Pi Imager.
The camera
The Pi 5 has a smaller 22-pin camera connector, while the Camera Module 3 comes with a 15-pin ribbon, so you need a separate 22-to-15-pin camera cable (sold as a Pi 5 camera cable). A USB webcam works too and needs no ribbon.
The model
Install the ultralytics Python library and run a YOLO model on the camera stream.
Pythonfrom ultralytics import YOLO model = YOLO("yolov8n.pt") # the small model, fast enough on a Pi for result in model.predict(source=0, stream=True, show=True): passThe result
Every recognised object appears on screen in a box with its name.