*4.2. Analyses of Location Result*

According to the segmentation mask in the bounding box, the laser strike point was located as the midpoint of the skeleton of pest image area, which was extracted through an improved ZS thinning algorithm. This method solves the problem of pest contour extraction based on deep learning, which greatly improves the robustness and efficiency of the algorithm.

However, this method cannot accurately locate the laser strike point in some special cases. The main causes of errors are: (1) When the *P. rapae* is partially occluded by leaves or the inclination angle is large, the method of locating the laser strike point through the midpoint of the skeleton is inaccurate because only a part of the pest skeleton is extracted (Figure 18a). (2) If the *P. rapae* larvae curl up in a ring, the pest segmentation mask is a circle. The laser strike points finally obtained by the above location method is near the center of the circle and is not within the effective strike range (Figure 18b).

**Figure 18.** Incorrect location results in special cases. (**a**) The body of the *P. rapae* shaded by leaves. (**b**) The larvae curl up in a ring.

Fortunately, the above situation is not common. Fieldwork indicates that the *P. rapae* larvae are mostly found on the leaf surface in the morning, sunset, and night and are mainly located on the petioles, leaf veins, and undeveloped new leaves of the outer leaves. Especially at sunrise and at night, the *P. rapae* larvae can be clearly seen from the top of the plant when illuminated with light. The larvae curl up only when hit by external stimuli and usually become strip shaped. In general, the location method is suitable in most cases. However, the method still needs to be further improved to adapt to complex working conditions.

### *4.3. Analyses of the Multi-Constraint Stereo Matching Result*

Experiment 2 showed that the average location errors on the *X*-axis, the *Y*-axis, and the *Z*-axis of the laser strike point were 0.40, 0.30, and 0.51 mm, respectively, and the maximum errors were 0.98, 0.68, and 1.16 mm. The system has high location accuracy on the *X*-axis and the *Y*-axis. Considering the distance between the real and the located point, the average absolute error of the total location error in the world coordinate system was 0.77 mm. The maximum error was 1.45 mm.

With the fourth and fifth instar larvae of *P. rapae* as an example, their average widths reach 1.564 mm and 2.738 mm, respectively [28]. Considering that the laser strikes vertically downward and the irradiation area is 6.189 mm<sup>2</sup> (diameter 2.8 mm) [5], the effective stroke of the laser end effector is increased by a maximum of 1.45 mm for accommodating the location error of the laser strike point. The extra travel poses less technical risk to the design and motion control of the laser strike device. The results satisfy the localization requirements of lasers to strike *P. rapae* larvae accurately.

The reasons for the errors are as follows: As the depth increases, the proportion of the pest area in the whole image is smaller, which results in pest segmentation and location errors. There are errors in internal and external parameters, which lead to an increase in the system error. Moreover, manual measurement error of the displacement sensor can also result in errors.

Overall, the average time of the entire pest localization process, including field pest identification, contour segmentation, and 3D coordinate position, was 0.607 s. Because the matching area was reduced, the stereo matching algorithm proposed in the study takes only 24.2% of the total time, approximately 0.147 s, which shows that the matching algorithm can quickly and accurately locate the three-dimensional coordinates of pests in the field after obtaining the pest segmentation results.

#### *4.4. Discussion about Further Improvement Aspects*

The data for this experiment were mainly collected at a depth of 400–600 mm above the ground. In the follow-up research, the relationship between the spatial resolution of the image and the laser strike point location accuracy of the proposed system can be further analyzed to obtain the best spatial solution. In this experiment, all images were collected from directly above. However, this will result in a lack of image information for pests that may be occluded by leaves or have a larger body inclination. This is somewhat detrimental to understanding the overall situation of pest infestation. In future research, the data of pests located on leaves should be collected from multiple angles to generate well-established and accurate 3D location information of pests.
