# Development of Continuum Robot Arm and Gripper for Harvesting Cherry Tomatoes
## 3 Tomato Recognition System
the ratio between the true-positive results (TP) and all positively classified objects (TP and FP) that represents the ability to distinguish a given class from all other classes. As shown in Figure 9, the value of the precision metric rapidly increases as the iteration progresses, which proves that the high accuracy of recognition was achieved in the early stage. The _recall metric_ is also determined using TP results, but instead of false-positive decisions (FP), it takes into account the number of objects classified as negative, but positive (FN). This metric evaluates the ability to detect a certain class and shows how many positive examples are lost because of classification. The higher the value of the recall metric, the lower the value of the loss of correct predictions. In other words, the recall metric is associated with the confidence of a trained neural network. In a neural network, the neuron weight is associated with accuracy, the higher the weight the more accurate the trained module. Figure 10 shows that the initial recall value is less than 0.5, which indicates staying at a poor level for the quality of the algorithm, but it rapidly increases to almost one. Figure 10: An example of a growing recall metric in the iteration process. Figure 9: An example of growing precision metric in the iteration process. In YOLO, one of the significant metrics is the _confidence metric_, which provides information about the reliability of the classifier's predictions. In the case of increasing the confidence threshold (the mean of precision), the value of the precision metric increases, and the recall will decrease. Figure 11 shows that the reliability threshold was 0.966 (the mean of 0, 1 and 2 class values), which means that almost all the classes achieve ideal accuracy. The results of this trial of assessment confirm that the YOLOv5 algorithm has high accuracy, enough to recognize ripe tomatoes. We experimented in terms of confidence metrics. We prepared real cherry tomatoes obtained from the grocery store and fake cherry tomatoes printed out with dimensions and shapes similar to real ones. Then, we set up the fake tomatoes for recognition; the neural network recognized them as real cherry tomatoes, but with 70-75 percent precision. Furthermore, we put a real tomato neighboring the fake ones, in which the neural network instantly changed the decision and recognized the real tomato with 96 percent precision (Figure 12). Figure 11: Assessment of precision all classes for YOLO v5 model. Figure 12: Experiment test with real and fake tomatoes recognition. Figure 13 shows real experimental results of tomato recognition by classifying them into three classes; \"0\" as red (ripened), \"1\" as green (no ripened), and \"2\" as a yellow tomato (expecting to be ripened one soon). The experiment was conducted in the agricultural greenhouse near Almaty city, Kazakhstan. For the dataset, we collected more than 1500 photos of the tomato plant as reference data to train the neural network. In this experiment, we used a borescope camera with a 3-megapixel resolution for dataset collection. The main difference between YOLO and other Convolutional Neural Network (CNN) algorithms used for object detection is that it recognizes objects very quickly in real-time. The principle of operation of YOLO involves the input of the entire image at once, which passes through the convolutional neural network only once. The main technical difference of YOLOv5 is that it was implemented on the PyTorch framework. This framework does not require a special API to work with the Python programming language. PyTorch also uses a dynamic graph model to make it easier for machine learning experts to write code. When detecting objects, YOLOv5 shows relatively good results in recognizing smaller objects compared to Faster RCNN [35]. Additionally, the Mask R-CNN model was trained on the same dataset.