*3.2. Discussion*

3.2.1. Reliability Verification Experiment

In order to verify the validity of the data and model, a program was written to rotate the image samples 90◦ counterclockwise before extracting the contours and then extract the contour to identify its orientation, as shown in Figure 20. Since the original orientation categories up, left, bottom, and right correspond to labels 0, 1, 2, and 3 respectively, the category labels output by the model after the rotation should be 1, 2, 3, and 0. In the test, all the tested models can achieve almost the same recognition rate as before the sample rotation, as shown in Table 6.

**Figure 20.** Sample rotation test of the model.

**Table 6.** Orientation recognition rate of the model to the rotated sample.


#### 3.2.2. Comparison with Statistical Learning

The difficulty in applying statistical learning methods to image recognition is how to extract image features. The method of sampling fixed coordinate points at equal intervals of contour lines introduced in Section Uniform Input Size greatly reduces the feature dimension of the image, which can be regarded as a kind of feature extraction method. Based on this, several statistical learning algorithms such as KNN, SVM, and lightGBM [33] were fitted and tested using a dataset of 50 contour sampling points, but none of them matched the classification performance of the neural network algorithm.

In the test of the KNN algorithm, the NCA [34] algorithm is used to reduce the dimension of the data samples of 50 sampling points to generate a vector of a specific dimension and use it as the input of the KNN algorithm. In the parameter adjustment test, when the dimension of the model input vector, that is, the NCA output vector, was reduced to 25, and the number of adjacent elements of the KNN model is 16, the recognition rate of the validation set of the KNN model reaches a peak at 93.70%.

In the test of the SVM algorithm, the performance of the RBF kernel function was significantly higher than that of linear and poly kernel functions. The randomized search CV method was used to select C and gamma parameters. When C is 98.21 and gamma is 0.0044, the accuracy of the validation set of the SVM model reaches 94.06% of the optimal figure in the experiment.

In the test of the lightGBM algorithm, PCA algorithm was used to reduce the dimension of data samples at 50 sampling points. When the dimension of data samples was reduced to 25, num\_leaves and max\_depth parameter of the lightGBM algorithm were 127 and 8, respectively, and the recognition rate of the validation set of the lightGBM model could reach an optimal 96.56% in the experiment.

If PCA is not used, the lightGBM model can only achieve a recognition rate of less than 92% of the validation set, which indicates that the processing of the PCA algorithm not only reduces the dimension of the sample vector but also improves the ability of the data to represent the original sample. After follow-up tests, the improvement of model accuracy by PCA preprocessing is limited to gbdt-based algorithms such as XGBoost [35] and lightGBM and cannot greatly improve the recognition rate of validation sets of KNN, SVM, and fully connected neural networks. Using PCA to convert the coordinate data of 50 sampling points into a 25-dimensional vector can reduce the complexity of the model. For the fully connected model in Table 4, after modifying the model input to a 25-dimensional vector, the number of parameters was reduced to 183.6 K. The amount of computation was reduced to 0.36 M, but the recognition rate on the validation set dropped to 97.97%.

As a comparison, the accuracy and running speeds of KNN, SVM, lightGBM, and the fully connected model on the embedded platform are shown in Table 7. Obviously, the speed of the fully connected model is better than that of the statistical learning model.

**Table 7.** Performance comparison of statistical learning models and fully connected model.


3.2.3. Comparison with Methods in Other Literature

Table 8 lists the garlic orientation recognition methods and their recognition rates described in the literature in recent years. It can be seen that the recognition rate of the method proposed in this paper is higher than other methods. Since all these studies use private datasets, this horizontal comparison is only for reference. However, because the samples contained in the dataset constructed in this paper uniquely retain the common morphological abnormalities and motion blur phenomena in the real scene, the reliability of the recognition rate achieved by the model in this study is at least not lower than that of other studies.

**Table 8.** Comparison of recognition rate of methods in related literatures.


Note: \* Ref. [12] only published that the success rate of garlic seeds righting is 90.56. It can be inferred that the recognition rate must be greater than this value.

The generally high recognition rates of the models proposed in this paper indicate that the dataset enhancement method and the contour-image-based garlic-clove-bud orientation recognition models adopted in this paper are effective. The form of binarized contour image unifies the pixel value distribution of contour points, so that the information of image samples can be completely expressed by the coordinate set of contour points. The feature extraction method of contour point equidistant sampling further reduces the dimension of the input data, so that the extremely lightweight fully connected neural network can also complete the orientation classification task of garlic seeds with high accuracy and speed.

### 3.2.4. Application Prospect

The operating speed of the garlic planter can be calculated by Equation (4), where η represents the sowing efficiency (hm2/h), *w* represents the plant spacing (m), *h* represents the row spacing (m) and *v* represents the sowing speed (pieces/second).

$$
\eta = 0.36 \cdot \upsilon \cdot w \cdot h \tag{4}
$$

The garlic sowing efficiency of the existing garlic seed adjustment method is in the range of 0.05–0.2 hm2/h [36,37]. According to the planting standards of 0.2 m row spacing and 0.12 m plant spacing, the four orientation recognition models in Table 5 can reach sowing speeds of 0.16, 0.51, 0.84, and 1.30 hm2/h, respectively. The above speed is the ideal single-row seeding speed. It can also be used in multi-row seeders in the form of controlling multiple rows through a single board. It only needs a single embedded board with the same performance as the OrangePi 3 LTS. If there are performance bottlenecks in the other devices that make up the garlic planter, the hardware configuration can be further reduced, thereby reducing the manufacturing cost of the planter.
