## 5 Discussion  
This work proposed the training and testing of two DL models for tomato detection and compared them with a developed HSV colour space model regarding the classification of those fruits according to their colour/ripeness through images of two datasets collected for this effect. Overall, both models were generic enough to detect tomato successfully. The results were similar between the validation set and the test set, with the YOLOv4 model obtaining promising results, being the best performing model. Interestingly, the use of filtered results  
Figure 12: Classification results comparison between the two DL models and the HSV colour space model with the groundtruth annotations. Green, Yellow, Orange and Red bounding boxes represents Green, Turning, Light Red and Red tomatoes predictions, respectively. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**DL Models** & **Fruit Ripeness** & **Precision** & **Recall** & **Macro F1-Score** &
\begin{tabular}{c} **Balanced** \\ **Accuracy** \\ \end{tabular} \\ \hline \multirow{3}{*}{SSD MobileNet v2} & Green & 77.27\% & 70.09\% & \multirow{3}{*}{65.93\%} & \multirow{3}{*}{62.70\%} \\  & Turning & 59.38\% & 55.88\% & & \\  & Light Red & 60.61\% & 40.82\% & & \\  & Red & 80.77\% & 84.00\% & & \\ \hline \multirow{3}{*}{YOLOv4} & Green & 85.38\% & 84.66\% & \multirow{3}{*}{74.16\%} & \multirow{3}{*}{68.87\%} \\  & Turning & 70.77\% & 67.65\% & & \\ \cline{1-1}  & Light Red & 76.32\% & 59.18\% & & \\ \cline{1-1}  & Red & 88.89\% & 64.00\% & & \\ \hline \multirow{3}{*}{HSV Colour Space} & Green & 98.24\% & 98.31\% & \multirow{3}{*}{70.93\%} & \multirow{3}{*}{68.10\%} \\  & Turning & 50.00\% & 63.24\% & & \\ \cline{1-1}  & Light Red & 58.33\% & 42.86\% & & \\ \cline{1-1}  & Red & 89.47\% & 68.00\% & & \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Classification results of the over the evaluation metrics, considering each model’s best-computed confidence threshold. by a threshold was only significant to the YOLOv4 model. The SSD MobileNet v2 model obtained identical results regardless of the confidence threshold, which means that it can be used without any filtering process without compromising the results. The models were able to detect tomatoes at different ripeness stages, even in complex scenarios, considering occlusions, overlaps and variations in illumination conditions. As they are one-stage detectors, the SSD MobileNetv2 and YOLOv4 models, although faster at detecting, could lack accuracy. This is not overly verified, showing good inference times that, together with the results of Precision and Recall, allow these models to be applied in systems equipped with computer vision to perform tasks in real time. Comparing these results with different authors is essential to understand the relevance of the results obtained and potential aspects that could be improved. Both models outperformed with distinction those presented by [PERSON] et al. (2018), [PERSON] et al. (2019), [PERSON] et al. (2019) and [PERSON] et al. (2020), which obtained quite high Precision rates but ended up failing in their ability to detect all relevant objects, causing the overall F1-Score to vary only between 60 and 66%. The models evaluated in this paper only lagged behind some heavily modified models. [PERSON] et al. (2019), [PERSON] et al. (2020), [PERSON] (2019) and [PERSON] et al. (2020) improved the YOLOv3 and YOLOv3 Tiny models leading to an F1-Score consistently higher than 90%. However, most of these models were trained with a single class, regardless of the fruit ripeness stage, and in some cases the datasets were largely or entirely composed of red tomatoes which, due to the higher colour contrast between the fruit and the background, are easier to detect. To the best of our knowledge, there is no literature reporting the application of DL models in the detection of tomato in a greenhouse context with more than three classes.