**5. Conclusions**

In this paper, a fruit tree position information perception method based on a 2D LiDAR sensor was proposed and verified on an experimental platform. According to the actual detection effect, the positive detection rate of the algorithm could reach 96.69%, the false detection rate was as low as 3.31%, and the average processing time was 1.14 s, indicating that the algorithm can be used in fruit tree detection to obtain the position of fruit trees. Although the algorithm has a good perception effect, there are also shortcomings. In the process of the experiment, because of the limitations of the 2D LiDAR sensor itself, the fruit tree information obtained was limited. When the algorithm is used for verification, there will be false detection and missed detection. From the detection of fruit tree trunks to the detection of fruit tree crowns, the amount of point cloud data for fruit trees will increase, resulting in a decrease in the positive detection rate of the algorithm. However, overall, the algorithm can still meet the requirements for the detection of fruit trees. In the future, the positions of fruit trees obtained by this algorithm could play a role in orchard navigation.

**Author Contributions:** Conceptualization, Y.W. and C.G.; Data curation, Y.W., G.Z. and H.G.; Formal analysis, R.S. and W.L.; Investigation, C.G.; Methodology, Y.W.; Software, Y.W.; Validation, G.Z., R.S. and H.G.; Writing—original draft, Y.W.; Writing—review and editing, C.G. and G.Z. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the National Key Research and Development Program of China (No. 2016YFD0700600).

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **References**


**Bo Xu 1, Xiang Cui 1, Wei Ji 1,\*, Hao Yuan <sup>2</sup> and Juncheng Wang <sup>1</sup>**


**Abstract:** Apple grading is an essential part of the apple marketing process to achieve high profits. In this paper, an improved YOLOv5 apple grading method is proposed to address the problems of low grading accuracy and slow grading speed in the apple grading process and is experimentally verified by the designed automatic apple grading machine. Firstly, the Mish activation function is used instead of the original YOLOv5 activation function, which allows the apple feature information to flow in the deep network and improves the generalization ability of the model. Secondly, the distance intersection overUnion loss function (DIoU\_Loss) is used to speed up the border regression rate and improve the model convergence speed. In order to refine the model to focus on apple feature information, a channel attention module (Squeeze Excitation) was added to the YOLOv5 backbone network to enhance information propagation between features and improve the model's ability to extract fruit features. The experimental results show that the improved YOLOv5 algorithm achieves an average accuracy of 90.6% for apple grading under the test set, which is 14.8%, 11.1%, and 3.7% better than the SSD, YOLOv4, and YOLOv5s models, respectively, with a real-time grading frame rate of 59.63 FPS. Finally, the improved YOLOv5 apple grading algorithm is experimentally validated on the developed apple auto-grader. The improved YOLOv5 apple grading algorithm was experimentally validated on the developed apple auto grader. The experimental results showed that the grading accuracy of the automatic apple grader reached 93%, and the grading speed was four apples/sec, indicating that this method has a high grading speed and accuracy for apples, which is of practical significance for advancing the development of automatic apple grading.

**Keywords:** apple grader; YOLOv5; attention mechanism SE; DIoU\_Loss; mish
