Development Board for Object Recognition on Raspberry Pi Zero2W
by ysonic in Circuits > Raspberry Pi
20 Views, 0 Favorites, 0 Comments
Development Board for Object Recognition on Raspberry Pi Zero2W
This document describes a project design for object recognition using the Raspberry Pi Zero 2W development board, including preparation, environment setup, ONNX model, flowcharts, project code, and demonstration.
ONNX
Open Neural Network Exchange (ONNX) is an open ecosystem that supports AI developers in choosing the right tools as their projects grow.。
- ONNX provides an open-source format for AI models, including deep learning and traditional ML.
- It defines a scalable computation graph model, along with built-in operators and standard-defined data types.
YOLO
YOLO (You Only Look Once) is a popular object detection algorithm, renowned for its speed and accuracy. The core idea of the YOLO algorithm is to transform the object detection problem into a regression problem, predicting bounding boxes and class probabilities directly from the input image using a single convolutional neural network (CNN).
YOLO's main advantages are its speed, enabling real-time processing of video streams. It also possesses strong versatility, allowing for transfer to new domains.
YOLOv5n
YOLOv5n represents an advancement in object detection methods. Based on the YOLOv5 model architecture developed by Ultralytics, it refines and optimizes the model architecture to achieve a higher accuracy-speed tradeoff in object detection tasks.
YOLOv5 provides an efficient solution for those seeking robust solutions in research and practical applications.
Thanks to GeKenflex for providing the funds to support.
Supplies
- Raspberry Pi Zero 2 W
- Display
- CSI-2 Camera Connector
- 2.4GHz IEEE 802.11b/g/n Wi-Fi, Bluetooth 4.2, BLE, Automotive Antenna
- 1 x USB 2.0 Port with OTG
- 40-pin HAT-compatible I/O header
- microSD Card Slot
- Mini HDMI Port
- Video: HDMI Interface, Composite Video
Hardware Connections & Library Installation
For system installation and environment setup details, please refer to: [Raspberry Pi Zero2W]
Hardware Connections
- If using SSH remote login, only a power supply is required.
- If using local login, an HDMI video streaming cable, a USB keyboard cable, etc., are required.
Library Installation
- Execute the command `sudo apt install python3-opencv` to install OpenCV.
- Install the `onnxruntime` library required for parsing ONNX models. Execute the command in the terminal.
If you encounter any problems, you can download and install the corresponding *.whl file according to your Linux system version and Python version.
Use `uname -a` to query Linux system information, and the `python --version` command to query the Python version.
Model Download
Download the model file to your local machine (./model folder);
Flowchart & Project Code
Flowchart
Local board-side inference for object recognition is implemented using the lightweight onNX model of YOLOv5n, and the recognition results are displayed in a pop-up window.
Project Code
Create a new file using the command `touch or_onnx.py`, and add the following code using the nano text editor.
Demonstration
Demonstration
Executing `python or_onnx.py ./img/road.jpg` in the terminal displays the object recognition results in a pop-up window;
At the same time, the terminal prints information.
More Scenarios
More scenarios