*2.6. Probe Positioning Test*

In this paper, a probe test method is proposed for evaluating the positioning accuracy of the positioning system. The probe mounted on the linear slide, as illustrated in Figure 10, may be accurately moved and positioned in the direction of the pineapple axis. At the same time, the servo drive motor rotates the pineapple at a precise angle. Therefore, according to the coordinates (*L, θ*) of any pineapple eye, the probe can be moved to the position of the pineapple eye and inserted into the pineapple eye through the extension action of the probe cylinder. The deviation *er* (error) between the actual center of the pineapple eye and the probe penetration position can be calculated to evaluate the positioning accuracy of the pineapple eye:

$$er = \sqrt{\left(W\_2/2 - W\_1 - 0.99\right)^2 + \left(H\_2/2 - H\_1 - 0.99\right)^2} \tag{9}$$

**Figure 10.** Measurement principle of the probe position error. 1. pineapple eye, 2. probe, and 3. pineapple eye center point.

In Equation (9), *er* is the error, and *W*<sup>1</sup> is the distance between the left edge of the pineapple eye and the right edge of the probe, in mm. *W*<sup>2</sup> is the maximum length of the pineapple eye in the horizontal direction, in mm. *H*<sup>1</sup> is the distance between the upper edge of the pineapple eye and the lower edge of the probe, in mm. *H*<sup>2</sup> is the maximum length of the pineapple eye in the vertical direction, in mm. The probe radius is 0.99 mm.

Using five Goodfarmer Philippine pineapples, the diameter of the pineapple eye was 9–12 mm (manual measurement) after manual peeling. The positioning test is carried out on the built-in test platform. When the probe reaches each pineapple eye position, a Vernier caliper is used to successively measure the distances *W*1, *W*<sup>2</sup> , *H*1, and *H*2, as shown in Figure 11.

**Figure 11.** Measuring the pineapple eye error with a Vernier caliper. (**a**) *W*<sup>1</sup> measurement; (**b**) *H*<sup>1</sup> measurement; (**c**) *W*<sup>2</sup> measurement; (**d**) *H*<sup>2</sup> measurement.

#### **3. Results and Discussion**

### *3.1. YOLOv5 Model Performance Evaluation*

To evaluate the detection effect of the pineapple eye recognition model, the model recognition accuracy and detection efficiency are mainly measured from four parameters: recall (*R*), precision (*P*), average accuracy (*AP*), and detection time of a single pineapple eye.

$$\begin{cases} \begin{aligned} P &= \frac{TP}{TP + FP} \\ R &= \frac{TP}{TP + FN} \\ &AP = \int\_0^1 PdR \end{aligned} \end{cases} \tag{10}$$

The *AP* value in Formula (10) is the area between the *P–R* curve and the coordinate axis, *TP* represents the number of positive samples (pineapple eyes) correctly predicted as positive samples, *TN* denotes the number of negative samples correctly predicted as negative samples, *FP* indicates the number of negative samples predicted as positive samples, and *FN* suggests the number of positive samples predicted as negative samples.

The curve of network model training is shown in Figure 12. Figure 12a shows the loss function curve of training, with a minimum value of 0.01689. Figure 12b shows the accuracy *P* (precision) curve, and the maximum accuracy is 97.8%. Figure 12c shows the recall rate *R* (recall) curve, and the maximum recall rate is 97.5%. Figure 12d shows the mean average precision curve when the IOU threshold is set to 0.5.

**Figure 12.** Model training results. (**a**) Value of loss varies with the number of iterations; (**b**) P vary with the number of iterations; (**c**) R vary with the number of iterations; (**d**) mAP@0.5 vary with the number of iterations.

The *P–R* curve is a graph that depicts the relationship between precision and recall. The abscissa represents *R*, while the ordinate represents *P*. The region contained in the *P–R* curve and the coordinate axis is *AP*. The larger the area between the curve and the coordinate axis is, the better the model recognition effect. Figure 13 shows the *P–R* curve with a threshold of 0.5 generated in the training process. Since there is only one recognition target in this paper, the *AP* is equal to the mAP (mean Average Precision). The mAP is 99.2%.

**Figure 13.** *P–R* curve.

To further verify the YOLOv5l model performance for pineapple eyes, the YOLOv5l network was compared with YOLOv5s, YOLOv5m, and YOLOv5x on 60 images in the test set; the target distribution of the test set was actually 1806 pineapple eyes. Then, the test set images were input into the above models, respectively. The target recognition results of the pineapple eyes in the image samples of the test set by the model are shown in Table 1. The YOLOv5 (l, s, m, and x) values of mAP at a confidence of 0.5 were 98%, 97.6%, 97.8%, and 98%, respectively, 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, respectively. Figure 14 shows the YOLOv5l detection effect diagram with a confidence level greater than 0.5.


**Table 1.** Identification results for the pineapple eyes in test set.

**Figure 14.** YOLOv5l detection effect diagram.

Average time is the time to detect one pineapple eye image.

In order to further analyze the accuracy of the YOLOv5l model in pineapple eye image detection, the training results of YOLOv5l and the target detection model Mask R-CNN were compared with a threshold of 0.5, as shown in Table 2. As can be seen from Table 2, the mAP and detection speed of YOLOv5l are significantly higher than Mask R-CNN.

**Table 2.** Comparison models of YOLOv5l and Mask R-CNN.

