# A Pineapple Target Detection Method in a Field Environment Based on Improved YOLOv7
## 4 Conclusions  
The target detection algorithm based on the improved YOLOv7 proposed in this study was mainly to achieve the efficient detection of pineapple under complex field environments. This method used different mature pineapples collected in a variety of complex field environments as data sets. By adding an attention mechanism, modifying the original network module, and changing the postprocessing mode, the detection speed and accuracy of the model were improved. The \(P\), \(R\), \(F1\), \(mAP\), and average detection time of the training model in the test set were 94.17%, 89.83%, 91.95%, 95.82%, and 23.81 ms. Compared with the original YOLOv7 model, \(P\) increased by 2.9%, \(R\) increased by 3.41%, \(F1\) increased by 3.17%, \(mAP\) increased by 2.71%, and the average detection time increased by 2.98 ms. Compared with YOLOv4-tiny and YOLOv5s, the \(mAP\) increased by 9.27% and 4.18%, respectively. This shows that the improved strategy in this paper could significantly improve the detection accuracy of pineapple with different maturities in complex field environments without significantly affecting the detection rate. In a word, the improved model proposed in this paper met the requirements of the pineapple detection task in a complex field environment in terms of the detection accuracy and detection speed.  
The model proposed in this paper performed well on a personal computer with strong computing performance but cannot be directly deployed on edge devices with poor computing performance, and the detection performance needs to be improved in dense and highly occluded scenes. In the future, we will continue to study the problem of pineapple real-time detection in dense and highly occluded scenes, while reducing the  
Figure 13: Comparison of the detection performance of the four models in different field environments. (**a**) Detection precision of unripe pineapples; (**b**) Detection precision of semi-ripe pineapples; (**c**) Detection precision of ripe pineapples; (**d**) Average detection of pineapples.  
computational power requirements of the model to adapt to edge devices. We will study three-dimensional positioning technology for pineapple based on a depth camera and achieve efficient automatic picking of pineapple in a natural environment by using the appropriate mechanical arm. The classification of pineapple maturity while picking is expected to be another valuable direction. This will help simplify the subsequent pineapple grading process and reduce the grading cost.  
Conceptualization, Y.L.; Methodology, Y.L. and R.J.; Software, Y.L. and T.W.; Validation, Y.L. and H.H.; Formal analysis, Y.C. and H.H.; Investigation, T.W.; Resources, R.M.; Data curation, R.J.; Writing--original draft, Y.L.; Writing--review & editing, R.M.; Visualization, Y.L.; Supervision, Y.C.; Funding acquisition, R.M. All authors have read and agreed to the published version of the manuscript.  
This research was funded by Science and Technology Planning Project of Guangdong Province of China (grant number 2021B1212040009); and the APC was funded by Science and Technology Planning Project of Guangdong Province of China (grant number 2021B1212040009).  
Not applicable.  
The authors declare no conflict of interest.