Design and Research on a Reed Field Obstacle Detection and Safety Warning System Based on Improved YOLOv8n
Abstract
:1. Introduction
2. Dataset
2.1. Data Collection
2.2. Data Preprocessing
3. Methods for Field Obstacle Detection and Warning Systems
3.1. Framework for Obstacle Detection and Safety Warning System
- (1)
- Utilizing a stereo vision camera to capture RGB images and depth information of the environment in front of the agricultural machinery. The RGB images are used for obstacle detection, while the depth information is employed to calculate the spatial position of obstacles. The CGL-YOLOv8n object detection algorithm is applied to process the RGB images, accurately identifying obstacle categories and extracting their pixel coordinates.
- (2)
- Integrating the depth information provided by the stereo camera, the obstacle’s pixel coordinates are transformed into three-dimensional coordinates in the camera coordinate system. Through coordinate transformation, the absolute position of the obstacle in the world coordinate system is obtained, enabling precise localization of obstacles.
- (3)
- After acquiring the world coordinates of the obstacles, the system further calculates the TTC between the obstacle and the unmanned agricultural machinery. TTC is computed based on the relative velocity and distance between the obstacle and the machinery, serving as a critical indicator for collision risk assessment.
3.2. Improved YOLOv8n Lightweight Network for Field Obstacle Detection
- The CG Block is used as the main gradient flow branch to replace all BottleNeck Blocks in the C2f module. This enhances the model’s ability to extract feature information in complex field environments, improving its capacity to detect small or hard-to-detect objects;
- The Context-Guide Fusion Module is introduced into the Feature Pyramid Network (FPN), which strengthens important features during the feature fusion process while suppressing irrelevant features. This effectively addresses potential issues with detection accuracy caused by factors such as lighting and weather conditions;
- The original detection head is replaced with a lightweight Shared Convolutional Separated BN Detection Head to resolve discrepancies in statistical features across different levels. This significantly reduces the number of parameters, resulting in a more lightweight model.
3.2.1. YOLOv8 Object Detection Algorithm
3.2.2. C2f—Context-Guided
3.2.3. ContextGuideFPN
3.2.4. SharedSepHead
3.3. Formatting of Mathematical Components
3.4. Safety Warning Strategy
4. Experimental Results and Analysis
4.1. Experimental Environment
4.2. Evaluation Metrics
4.3. Model Training and Detection Results
4.4. Ablation Experiment
4.5. Comparison Experiment
4.6. Accuracy Test of the Safety Warning System
5. Conclusions
- (1)
- On the test set, the improved model demonstrates excellent discrimination and recognition performance for five types of obstacles. Compared to the YOLOv8n model, the improved model achieves a mean Average Precision (mAP) of 92.3%, with a reduction in the number of parameters and computational complexity by 31.9% and 33.4%, respectively. The model size is only 4.2 MB, reduced by 30%, and the inference speed for a single image is 59.1 frames per second. Although there is a slight decrease compared to the baseline model, the improved model still meets the real-time detection performance requirements. When compared to Faster R-CNN, Cascade R-CNN, RetinaNet, and the YOLO series models (YOLOv5n, YOLOv6n, YOLOv7, YOLOv8n, YOLOv9t, YOLOv10n), the main advantages of our model lie in its ability to maintain the best balance between parameters, computational load, detection speed, and accuracy. While maintaining high detection precision, the model is more lightweight, consumes less memory, and offers better real-time performance. This makes it more suitable for deployment on edge devices with limited computational power and memory, thus reducing costs and improving efficiency. Additionally, the model lowers the usage threshold for unmanned agricultural machinery, facilitating the advancement of agricultural automation.
- (2)
- In the field dynamic experiments, the overall detection success rate for obstacle target detection reached 94.5%, with positioning accuracy showing a relative error of less than 3% within a 5 m range and less than 5% within a 10 m range, fully meeting the requirements for real-time detection and distance measurement. Based on ensuring the accuracy of obstacle recognition and positioning, further safety warning experiments were conducted. By comparing the number of manual warnings with the system’s warnings, the final overall warning accuracy reached 86%, confirming the reliability of the safety warning system. This study also provides a reference for obstacle detection and safety warning in other scenarios.
- (3)
- Future research will focus on further optimizing obstacle detection and early warning systems under various complex weather and lighting conditions, enhancing the robustness and adaptability of models in extreme environments. Additionally, plans include integrating unmanned agricultural machinery control systems to develop a unified autonomous farming platform, promoting the integration of detection, early warning, and decision control applications. Furthermore, the proposed lightweight detection models and safety warning methods can be directly deployed on agricultural machinery terminals with limited computational power, not only improving the intelligence level of agricultural operations but also helping to reduce equipment costs and usage difficulty, with promising prospects for widespread application.
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Yin, Q.; Li, Y.M.; Ji, B.B.; Chen, L.P. Design and Experiment of Clamping and Conveying Device for Self Propelled Reed Harvester. J. Agric. Mech. Res. 2023, 45, 113–118. [Google Scholar]
- Li, S.; Xu, H.; Ji, Y.; Cao, R.; Zhang, M.; Li, H. Development of a following agricultural machinery automatic navigation system. Comput. Electron. Agric. 2019, 158, 335–344. [Google Scholar] [CrossRef]
- Shang, Y.H.; Zhang, G.Q.; Meng, Z.J.; Wang, H.; Su, C.H.; Song, Z.H. Field Obstacle Detection Method of 3D LiDAR Point Cloud Based on Euclidean Clustering. Nongye Jixie Xuebao/Trans. Chin. Soc. Agric. Mach. 2022, 53, 23–32. [Google Scholar]
- Hu, L.; Wang, Z.M.; Wang, P.; He, J.; Jiao, J.K.; Wang, C.Y.; Li, M.J. Agricultural robot positioning system based on laser sensing. Trans. Chin. Soc. Agric. Eng. 2023, 39, 1–7. [Google Scholar]
- Xie, P.; Wang, H.C.; Huang, Y.X.; Gao, Q.; Bai, Z.H.; Zhang, L.N.; Ye, Y.X. LiDAR-Based Negative Obstacle Detection for Unmanned Ground Vehicles in Orchards. Sensors 2024, 24, 7929. [Google Scholar] [CrossRef]
- Xue, J.L.; Cheng, F.; Wang, B.Q.; Li, Y.Q.; Ma, Z.B.; Chu, Y.Y. Method for Millimeter Wave Radar Farm Obstacle Detection Based on Invalid Target Filtering. Trans. CSAM 2023, 54, 233–240. [Google Scholar]
- Lai, H.R.; Zhang, Y.W.; Zhang, B.; Yin, Y.X.; Liu, Y.H.; Dong, Y.H. Design and experiment of the visual navigation system for a maize weeding robot. Trans. Chin. Soc Agric. Eng. 2023, 39, 18–27. [Google Scholar]
- Liu, H.; Zheng, X.P.; Shen, Y.; Wang, S.Y.; Shen, Z.F.; Kai, J.R. Method for the target detection of seedlings and obstacles in nurseries using improved YOLOv5s. Trans. Chin. Soc. Agric. Eng. 2024, 40, 136–144. [Google Scholar]
- Lan, Y.B.; Yan, Y.; Wang, B.J.; Song, C.C.; Wang, G.B. Current status and future development of the key technologies for intelligent pesticide spraying robots. Trans. Chin. Soc. Agric. Eng. 2022, 38, 30–40. [Google Scholar]
- He, Y.; Jiang, H.; Fang, H.; Wang, Y.; Liu, Y.F. Research progress of intelligent obstacle detection methods of vehicles and their application on agriculture. Trans. Chin. Soc. Agric. Eng. 2018, 34, 21–32. [Google Scholar]
- Sun, Y.P.; Sun, J.; Yuan, B.K.; Fang, Z.; Qin, Y.; Zhao, D.A. Ligntweight crab pond obstacle detection and location method based on improved YOLOv5s. Trans. Chin. Soc. Agric. Eng. 2023, 39, 152–163. [Google Scholar]
- Xu, Y.; Xiong, J.J.; Li, L.; Peng, Y.J.; He, J.J. Detecting pepper cluster using improved YOLOv5s. Trans. Chin. Soc. Agric. Eng. 2023, 39, 283–290. [Google Scholar]
- Navneet, D.; Bill, T. Histograms of Oriented Gradients for Human Detection. In Proceedings of the 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR’05), San Diego, CA, USA, 20–25 June 2005; pp. 886–893. [Google Scholar]
- David, G.L. Distinctive Image Features from Scale-Invariant Keypoints. Int. J. Comput. Vis. 2004, 60, 91–110. [Google Scholar]
- Vapnik, V.N. The Nature of Statistical Learning Theory; Springer: Berlin/Heidelberg, Germany, 1995. [Google Scholar]
- Freund, Y.; Schapire, R.E. A Decision-Theoretic Generalization of On-Line Learning and an Application to Boosting. J. Comput. Syst. Sci. 1997, 55, 119–139. [Google Scholar] [CrossRef]
- Viola, P.; Jones, M. Robust real-time face detection. J. Comput. Vis. 2004, 57, 137–154. [Google Scholar] [CrossRef]
- Viola, P.; Jones, M. Rapid object detection using a boosted cascade of simple features. In Proceedings of the 2001 IEEE Computer Society Conference on Computer Vision and Pattern Recognition, Kauai, HI, USA, 8–14 December 2001; pp. 1584–1598. [Google Scholar]
- Girshick, R.; Donahue, J.; Darrell, T.; Malik, J. Rich feature hierarchies for accurate object detection and semantic segmentation. In Proceedings of the 2014 IEEE Conference on Computer Vision and Pattern Recognition, Columbus, OH, USA, 23–28 June 2014; pp. 580–587. [Google Scholar]
- Girshick, R. Fast R-CNN. In Proceedings of the 2015 IEEE International Conference on Computer Vision (ICCV), Santiago, Chile, 7–13 December 2015; pp. 1440–1448. [Google Scholar]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards real-time object detection with region proposal networks. IEEE Trans. Pattern Anal. Mach. Intell. 2017, 39, 1137–1149. [Google Scholar] [CrossRef]
- Cai, Z.; Vasconcelos, N. Cascade R-CNN: High quality object detection and instance segmentation. IEEE Trans. Pattern Anal. Mach. Intell. 2019, 43, 1483–1498. [Google Scholar] [CrossRef]
- Liu, W.; Anguelov, D.; Erhan, D.; Szegedy, D.; Reed, S.; Fu, C.Y.; Berg, A.C. SSD: Singleshot Multibox Detector; Springer: Berlin/Heidelberg, Germany, 2016; pp. 21–37. [Google Scholar]
- Redmon, J.; Farhadi, A. YOLOv3: An Incremental Improvement. arXiv 2018, arXiv:1804.02767. [Google Scholar]
- Bochkovskiy, A.; Wang, C.Y.; Liao, H.Y.M. YOLOv4: Optimal Speed and Accuracy of Object Detection. arXiv 2020, arXiv:2004.10934. [Google Scholar]
- Glenn, J. YOLOv5 Release v6.1. 2022. Available online: https://github.com/ultralytics/yolov5/releases/tag/v6.1 (accessed on 16 March 2025).
- Li, C.Y.; Li, L.L.; Jiang, H.L.; Weng, K.H.; Geng, Y.F.; Li, L.; Ke, Z.D.; Li, Q.Y.; Cheng, M.; Nie, W.Q.; et al. YOLOv6: A Single-Stage Object Detection Framework for Industrial Applications. arXiv 2022, arXiv:2209.02976. [Google Scholar]
- Wang, C.Y.; Bochkovskiy, A.; Liao, H.Y.M. YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors. In Proceedings of the 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Vancouver, BC, Canada, 17–24 June 2023; pp. 7464–7475. [Google Scholar]
- Glenn, J. Ultralytics YOLOv8. 2022. Available online: https://github.com/ultralytics/ultralytics (accessed on 27 April 2025).
- Wang, C.Y.; Yeh, I.H.; Liao, H.Y.M. YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information. arXiv 2024, arXiv:2402.13616. [Google Scholar]
- Wang, A.; Chen, H.; Liu, L.H.; Chen, K.; Lin, Z.J.; Han, J.G.; Ding, G.G. YOLOv10: Real-Time End-to-End Object Detection. arXiv 2024, arXiv:2405.14458. [Google Scholar]
- Zou, Z.; Chen, K.; Shi, Z.; Guo, Y.H.; Ye, J.P. Object detection in 20 years: A survey. Proc. IEEE 2023, 111, 257–276. [Google Scholar] [CrossRef]
- Diwan, T.; Anirudh, G.; Tembhurne, J.V. Object detection using YOLO: Challenges, architectural successors, datasets and applications. Multimed. Tools Appl. 2023, 82, 9243–9275. [Google Scholar] [CrossRef]
- Liu, H.; Zhang, L.S.; Shen, Y.; Zhang, J.; Wu, B. Real-time Pedestrian Detection in Orchard Based on Improved SSD. Nongye Jixie Xuebao/Trans. Chin. Soc. Agric. Mach. 2019, 50, 29–35, 101. [Google Scholar]
- Wei, J.S.; Pan, S.G.; Tian, G.Z.; Gao, W.; Sun, Y.C. Design and experiments of the binocular visual obstacle perception system for agricultural vehicles. Trans. Chin. Soc. Agric. Eng. 2021, 37, 55–63. [Google Scholar]
- Cai, S.P.; Sun, Z.M.; Liu, H.; Wu, H.X.; Zhuang, Z.Z. Real-time detection methodology for obstacles in orchards using improved YOLOv4. Trans. Chin. Soc. Agric. Eng. (Trans. CSAE) 2021, 37, 36–43. [Google Scholar]
- Wang, X.Y.; Yi, Z.Y. Research on obstacle detection method of mowing robot working environment based on improved YOLOv5. J. Chin. Agric. Mech. 2023, 44, 171–176. [Google Scholar] [CrossRef]
- Liu, Y.; Wang, H.R.; Liu, Y.H.; Luo, Y.Y.; Li, H.Y.; Chen, H.F.; Liao, K.; Li, L.J. A trunk detection method for camellia oleifera fruit harvesting robot based on improved YOLOv7. Forests 2023, 14, 1453. [Google Scholar] [CrossRef]
- Brown, J.; Paudel, A.; Biehler, D.; Thompson, A.; Karkee, M.; Grimm, C.; Davidson, J.R. Tree detection and in-row localization for autonomous precision orchard management. Comput. Electron. Agric. 2024, 227, 109454. [Google Scholar] [CrossRef]
- Zhang, Y.; Tian, K.; Huang, J.; Wang, Z.L.; Zhang, B.; Xie, Q. Field obstacle detection and location method based on binocular vision. Agricluture 2024, 14, 1493. [Google Scholar] [CrossRef]
- Mish, M.D. A Self Regularized Non-Monotonic Neural Activation Function. arXiv 2019, arXiv:1908.08681. [Google Scholar]
- Lin, T.Y.; Dollár, P.; Girshick, R.; He, K.M.; Hariharan, B.; Belongie, S. Feature pyramid networks for object detection. In Proceedings of the 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Honolulu, HI, USA, 21–26 July 2017; pp. 936–944. [Google Scholar]
- Liu, S.; Qi, L.; Qin, H.F.; Shi, J.P.; Jia, J.Y. Path aggregation network for instance segmentation. In Proceedings of the 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018; pp. 8759–8768. [Google Scholar]
- He, K.M.; Zhang, X.Y.; Ren, S.Q.; Sun, J. Deep residual learning for image recognition. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 770–778. [Google Scholar]
- Wu, T.Y.; Tang, S.; Zhang, R.; Zhang, Y.D. CGNet: A Light-weight Context Guided Network for Semantic Segmentation. IEEE Trans. Image Process. 2021, 30, 1169–1179. [Google Scholar] [CrossRef] [PubMed]
- Tang, L.F.; Zhang, H.; Xu, H.; Ma, J.Y. Rethinking the necessity of image fusion in high-level vision tasks: A practical infrared and visible image fusion network based on progressive semantic injection and scene fidelity. Inf. Fusion 2023, 99, 101870. [Google Scholar] [CrossRef]
- Hu, J.; Shen, L.; Sun, G. Squeeze-and-excitation networks. In Proceedings of the 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018; pp. 7132–7141. [Google Scholar]
- Ghiasi, G.; Lin, T.Y.; Pan, R.M.; Le, Q.V. NAS-FPN: Learning Scalable Feature Pyramid Architecture for Object Detection. In Proceedings of the 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Salt Lake City, UT, USA, 15–20 June 2019; pp. 7029–7038. [Google Scholar]
- Duan, J.L.; Wang, Z.R.; Zou, X.J.; Yuan, H.T.; Huang, G.S.; Yang, Z. Recognition of bananas to locate bottom fruit axis using improved YOLOv5. Trans. Chin. Soc Agric. Eng. 2022, 38, 122–130. [Google Scholar]
Class | Image | Instance | |||||
---|---|---|---|---|---|---|---|
Person | Pylon | Agri-Machinery | Pole | Stone | All | ||
Original | 2589 | 1334 | 783 | 662 | 938 | 1224 | 4941 |
Final | 4459 | 1982 | 1532 | 1590 | 1736 | 1670 | 8510 |
Type | Parameter |
---|---|
OS | Windows 11 |
GPU | NVIDIA RTX A4000 GPU |
CPU | Intel(R) Xeon(R) Gold 5218R CPU @ 2.10 GHz |
RAM/VRAM | 128 GB/16 GB |
Interpreted language version | Python 3.8.16 |
Framework and gas pedal versions | PyTorch 1.12.1, CUDA 11.3, CUDNN 8.2.1 |
Hyperparameter | Value |
---|---|
Epochs | 300 |
Batch size | 32 |
Workers | 4 |
Optimizer | SGD |
Patience | 50 |
Close mosaic | 10 |
C2f-CG | CGFPN | SharedSepHead | P/% | R/% | mAP@0.5/% | FLOPs/G | Params/M | FPS |
---|---|---|---|---|---|---|---|---|
91.3 | 84.6 | 91.6 | 8.1 | 3.01 | 60.9 | |||
√ | 90.6 | 86.8 | 92.1 | 5.8 | 2.10 | 55.2 | ||
√ | 91.5 | 87.2 | 91.7 | 8.3 | 3.16 | 59.5 | ||
√ | 91.8 | 85.6 | 91.8 | 6.5 | 2.36 | 68.5 | ||
√ | √ | 91.3 | 85.3 | 92.1 | 7.0 | 2.69 | 57.6 | |
√ | √ | √ | 92.8 | 85.0 | 92.3 | 5.4 | 2.05 | 59.1 |
Model | mAP | FLOPs | Model Size | FPS | |
---|---|---|---|---|---|
Others | Faster R-CNN | 89.7 | 201.0 G | 166.8 MB | 14.5 |
Cascade R-CNN | 90.5 | 228.0 G | 276.8 MB | 12.0 | |
RetinaNet | 90.1 | 211.9 G | 145.6 MB | 16.2 | |
YOLOv5n | 90.7 | 7.1 G | 5.0 MB | 58.1 | |
YOLOv6n | 91.0 | 11.8 G | 8.3 MB | 69.5 | |
YOLOv7 | 90.9 | 105.2 G | 71.4 MB | 28.3 | |
YOLOv8n | 91.6 | 8.1 G | 6.0 MB | 60.9 | |
YOLOv9t | 91.8 | 7.6 G | 4.4 MB | 26.4 | |
YOLOV10n | 91.5 | 6.5 G | 5.5 MB | 53.7 | |
Ours | CGL-YOLOv8n | 92.3 | 5.4 G | 2.05 MB | 59.1 |
Obstacle Type | Vehicle Speed | Manual Warning Count | System Warning Count | Per-Class Warning Accuracy | Overall Warning Accuracy | ||
---|---|---|---|---|---|---|---|
No/Level 1/Level 2 | No | Level 1 | Level 2 | ||||
Person | 3 km/h | 10 | 8 | 9 | 10 | 90% | 86% |
Pylon | 3 km/h | 10 | 7 | 8 | 8 | 77% | |
Agri-machinery | 3 km/h | 10 | 9 | 9 | 10 | 94% | |
Pole | 3 km/h | 10 | 9 | 10 | 9 | 94% | |
Stone | 3 km/h | 10 | 7 | 8 | 8 | 77% |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Zhang, Y.; Mu, Z.; Tian, K.; Zhang, B.; Huang, J. Design and Research on a Reed Field Obstacle Detection and Safety Warning System Based on Improved YOLOv8n. Agronomy 2025, 15, 1158. https://doi.org/10.3390/agronomy15051158
Zhang Y, Mu Z, Tian K, Zhang B, Huang J. Design and Research on a Reed Field Obstacle Detection and Safety Warning System Based on Improved YOLOv8n. Agronomy. 2025; 15(5):1158. https://doi.org/10.3390/agronomy15051158
Chicago/Turabian StyleZhang, Yuanyuan, Zhongqiu Mu, Kunpeng Tian, Bing Zhang, and Jicheng Huang. 2025. "Design and Research on a Reed Field Obstacle Detection and Safety Warning System Based on Improved YOLOv8n" Agronomy 15, no. 5: 1158. https://doi.org/10.3390/agronomy15051158
APA StyleZhang, Y., Mu, Z., Tian, K., Zhang, B., & Huang, J. (2025). Design and Research on a Reed Field Obstacle Detection and Safety Warning System Based on Improved YOLOv8n. Agronomy, 15(5), 1158. https://doi.org/10.3390/agronomy15051158