# 树莓派 YOLO 检测 **Repository Path**: hardychenlong/raspberry-pie4b-yolo-detection ## Basic Information - **Project Name**: 树莓派 YOLO 检测 - **Description**: 树莓派 YOLO 循环检测检测 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 15 - **Forks**: 4 - **Created**: 2020-11-27 - **Last Updated**: 2025-11-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 项目概述 Abstract 在树莓派4B等**嵌入式设备**进行 [Yolo-Fastest](https://github.com/dog-qiuqiu/Yolo-Fastest) **推理部署** [gitee](https://gitee.com/hardychenlong/raspberry-pie4b-yolo-detection) # 系统需求 environment 环境:树莓派4B 内存4G版 存储tf卡32GB,系统 Ubuntu MATE 20LTS,opencv4.4.0,python3.8 # 安装说明 Installation ## 树莓派4B环境 OpenCV 安装 [Ubuntu 树莓派安装 OpenCV4 参考blog 请注意时效性!!!](https://blog.csdn.net/qq_44880154/article/details/108849953) ```bash git clone https://gitee.com/hardychenlong/raspberry-pie4b-yolo-detection.git ``` # 使用说明 Usage ```py # 单张图片测试 python main_yolov3.py --image=person.jpg ``` ```py # url = "http://192.168.137.136:8085/?action=stream" url = "http://192.168.137.136:8080/?action=stream" # 打开网络摄像头 cap = cv.VideoCapture(url) # cap = cv.VideoCapture(0) # 电脑默认摄像头 # cap = cv.VideoCapture('dance.mp4') ``` - 修改 camera.py 程序中的摄像头读取方式,可以是摄像头或者视频或者是网络视频流。 ![image-20201127212511713](https://gitee.com/hardychenlong/giteeblogimg/raw/master/20201127212518.png) ![](Asava_pic/object.jpg) # 数据集 Dataset 如果想使用自己的数据集训练模型,可以参考作者仓库中关于 train 的部分,使用darknet 框架训练 - https://github.com/dog-qiuqiu/Yolo-Fastest#how-to-train - https://github.com/dog-qiuqiu/Yolo-FastestV2#how-to-train # 模型下载 Model Download 由于模型体积较小,本仓库直接包含了的模型可以直接使用,也可以选择到作者仓库下载最新的模型进行替换。 - https://github.com/dog-qiuqiu/Yolo-Fastest # 示例 `main_yolov3.py` ```py # Initialize the parameters confThreshold = 0.25 # Confidence threshold nmsThreshold = 0.4 # Non-maximum suppression threshold inpWidth = 320 # Width of network's input image inpHeight = 320 # Height of network's input image ``` - 设置输入图片大小 320 * 320 - 置信度0.25 - 极大值抑制指标0.4 ```py # Load names of classes classesFile = "voc.names" ``` - 模型使用 [VOC2007](http://host.robots.ox.ac.uk/pascal/VOC/) / coco2017 数据集预训练,识别类别参考 `voc.names` / `coco.names` - 可以选择加载 voc 或 coco 的标签 labels - 注意需要模型和 labels 保持一致,如 选择了voc的模型,就需要加载 voc.names ```py # Give the configuration and weight files for the model and load the network using them. modelConfiguration = "Yolo-Fastest-voc/yolo-fastest-xl.cfg" modelWeights = "Yolo-Fastest-voc/yolo-fastest-xl.weights" ``` - 配置网络结构和加载权重,可以选择 voc 或 coco 的预训练网络和权重,识别类型数量分别是20、80 , 网络结构 cfg 文件可查看 `Yolo-Fastest-coco/yolo-fastest-xl.cfg` / `Yolo-Fastest-voc/yolo-fastest-xl.cfg` ```py net = cv.dnn.readNetFromDarknet(modelConfiguration, modelWeights) net.setPreferableBackend(cv.dnn.DNN_BACKEND_OPENCV) net.setPreferableTarget(cv.dnn.DNN_TARGET_CPU) ``` - 使用OpenCV dnn模块加载 darknet 网络,并使用CPU进行推理 > OpenCV的dnn模块是一个深度神经网络模块,可用于对图像、视频进行分类、识别、检测等任务。它支持各种常见的神经网络框架,如Caffe、TensorFlow、Torch等,并提供了一组简单易用的API,方便用户在OpenCV中使用深度学习模型。 # Issue template ```md ## Description [Insert a brief description of the issue here.] ## Steps to Reproduce 1. [Step 1] 2. [Step 2] 3. [Step 3, etc.] ## Expected Behavior [Describe what you expected to happen.] ## Actual Behavior [Describe what actually happened.] ## Screenshots (if applicable) [Add any relevant screenshots here.] ## Additional Context [Add any additional information that might be helpful here.] ``` # 许可证信息 license MIT License Copyright (c) [2020] [hardychenlong] # 参考文献/资料 Refs - Redmon J, Divvala S, Girshick R, et al. You only look once: Unified, real-time object detection[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2016: 779-788. - Redmon J, Farhadi A. YOLO9000: better, faster, stronger[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 7263-7271. - Redmon J, Farhadi A. Yolov3: An incremental improvement[J]. arXiv preprint arXiv:1804.02767, 2018. - https://github.com/dog-qiuqiu/Yolo-Fastest - https://blog.csdn.net/nihate/article/details/108670542 - https://blog.csdn.net/qq_44880154/article/details/128554830?spm=1001.2014.3001.5501