*3.2. Result of Probe Positioning Test*

The probe positioning test result, as shown in Figure 15, reveals that of the five Goodfarmer Philippine pineapples after manual peeling (460 pineapple eyes in total, 444 pineapple eyes were successfully recognized), the deviation between the actual center of the pineapple eye and the probe puncture position was 1.01 mm, and the maximum was 2.17 mm, with a root mean square value of 1.09 mm.

**Figure 15.** Probe positioning test.

#### *3.3. Discussion*

The YOLOv5 model has high detection accuracy on the self-built pineapple eye dataset. In the sample images of the whole test set, the accuracy, recall, and *AP* of the model are higher than 96%, indicating that the YOLOv5 recognition algorithm is feasible. The reason why a few pineapple eyes could not be successfully identified is that the pineapple eyes on both sides of the image are prone to distortion. This situation increases the recognition difficulty, resulting in some pineapple eye recognition errors. Therefore, further research on the optimization methods of models and parameters is needed to improve detection accuracy.

The localization experiment demonstrates that collecting images of the entire pineapple circumference at even intervals and employing multiangle image matching with high positioning precision may effectively accomplish three-dimensional localization of the pineapple eye. Simultaneously, pineapple eye coordinates have been converted into a form that can be directly applied by the actuator, which provides a good foundation for the further development of pineapple eye-removal equipment for practical operations.

#### **4. Conclusions**

A pineapple eye recognition algorithm was presented based on deep learning. YOLOv5 was used as the target detection network for pineapple eye recognition. The 600 pineapple eye images enhanced by the dataset are divided into a training set, validation set, and test set with an 8:1:1 ratio. The values in the final model validation of precision, recall, and mAP (mean average precision) were 97.8%, 97.5%, and 99.2%, respectively. The YOLOv5l network was compared with YOLOv5s, YOLOv5m, and YOLOv5x on 60 images in the test set. The YOLOv5 (l, s, m, and x) values of mAP were 98%, 97.6%, 97.8%, and 98%, showing the effectiveness of the proposed model. Additionally, the average times required to detect one pineapple eye image were 0.015 s, 0.012 s, 0.019 s, and 0.024 s. The detection results of YOLOv5l and Mask R-CNN were further compared, and the results showed that YOLOv5l was significantly higher than that of Mask R-CNN in both the mAP and detection speed.

A pineapple eye location algorithm based on monocular multiangle image stereo matching was proposed. Two images with different angles of 90◦ were selected as a group for stereo-matching analysis to obtain the three-dimensional position information of all pineapple eyes, establish a camera three-dimensional coordinate system with the camera optical center as the origin, and obtain the three-dimensional space coordinates (*X*,*Y*, *Z*) of the all pineapple eye through the geometric vector method. To facilitate subsequent experiments and the operation of removing pineapple eyes in practical engineering applications, in this paper, the three-dimensional space coordinate (*X*,*Y*, *Z*) of the pineapple eye was transformed into the space coordinate (*L*, *θ*) with the probe (or eye-removal tool) position *L* and the rotation angle *θ* of the pineapple as the reference. The probe test results showed that the average deviation between the actual center of the pineapple eye and the puncture position of the probe was

1.01 mm, the maximum was 2.17 mm, the root mean square value was 1.09 mm, and the positioning accuracy met the needs of the automated eye-removal operations.

The pineapple eye recognition and positioning algorithm proposed in this paper provides an important theoretical basis for the development of automatic pineapple-eyeremoval equipment. The practical application performance of the algorithm needs to be verified and improved in the actual eye-removal operation. At the same time, only one variety of pineapple was tested, and the peeling operation was performed manually. The applicability of the algorithm to different varieties of pineapples and machine-peeled pineapples also needs to be further verified.

**Author Contributions:** Conceptualization, A.L., Y.X. and Y.L.; methodology, A.L., Y.X. and Y.L.; software, Y.L.; validation, A.L., Y.L., Z.H. and X.D.; formal analysis, A.L.; investigation, A.L., Z.H., X.L. and Z.T.; resources, Y.X. and Y.L.; data curation, A.L.; writing—original draft preparation, A.L.; writing—review and editing, Y.X. and Y.L.; visualization, A.L.; supervision, X.L.; project administration, A.L.; funding acquisition, Y.X. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the Natural Science Foundation of Hunan Province of China, grant number 2021JJ30363.

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

**Data Availability Statement:** All data are presented in this article in the form of figures and tables.

**Acknowledgments:** We gratefully acknowledge Mingliag Wu, Ying Xiong and anonymous referees for thoughtful review of this research as well as the assistance of Yanfei Li with statistical analyses.

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