# A Pineapple Target Detection Method in a Field Environment Based on Improved YOLOv7
## 1 Introduction  
China has a long history of pineapple cultivation and is also one of the top 10 pineapple growers [1]. In China, pineapples are mainly picked by hand. At present, the continuous loss of the rural labor force has seriously restricted the development of the pineapple industry [2]. Using picking robots to mechanize picking instead of manual picking can effectively alleviate the problem caused by the loss of rural labor force. Target detection is the key step in mechanized picking [3]. Therefore, in order to realize the efficient automatic picking of pineapple, reduce the burden of workers, and ensure the timely picking of pineapple, it is an effective means to study and improve the target detection technology of pineapples. This has important practical value for developing a computer vision system that can detect pineapples in real time in a complex field environment. In the field of agriculture, the target detection method based on an image algorithm and the target detection method based on deep learning are two kinds of mainstream target detection methods, both of which have made progress. Fruit detection methods based on traditional image algorithms usually rely on manual experience, such as manually setting image features, such as the shape, color, and texture, and then extracting the features of the candidate regions based on sliding windows and completing the target detection according to the feature classifiers. [PERSON] and [PERSON] [4] used texture analysis to detect pineapples and bitter melons, achieving an 85% accuracy for pineapples and a 100% accuracy for bitter melons. [PERSON] et al. [5] used local binary patterns (LBP) to detect and count green citrus, achieving an accuracy of 85.6% in the validation set. [PERSON] et al. [6] used the improved linear discriminant analysis (LDA) method to identify green litch in a natural environment. [PERSON] et al. [1] used the Otsu method to perform the threshold segmentation of pineapples in an image and successfully completed the image segmentation of pineapples. [PERSON] and [PERSON] [7] used a computer image algorithm based on error conversion to detect green citrus. In order to overcome the overlapping and occlusion problems of green apples, [PERSON] et al. [8] proposed a recognition method combining the GrabCut model and Ncut algorithm. [PERSON] et al. [9] used the simple linear iterative clustering (SLIC) method to implement the detection and localization of apples. [PERSON] and [PERSON] [10] proposed a threshold algorithm combined with an RGB-D sensor to detect red sweet pepper for highly variable illumination conditions and achieved a detection rate of 90.9%. There are two kinds of target detection algorithms based on deep learning. The two-stage detection method first uses a region proposal to screen the candidate regions to obtain the region of interest (ROI) and then performs object location and border regression prediction on the selected region. The common two-stage detection methods are Fast R-CNN [11], Faster R-CNN [12], and Mask R-CNN [13]. The one-stage detection method directly divides the whole image into multiple small grids, and feature extraction and classification regression are completed in a very small grid space, judgment and recognition based on the prior frame, and offset information in one step. YOLO [14; 15; 16] and SSD [17] are a common one-stage detection method. Deep learning can be widely used, mainly due to its high detection accuracy and high detection rate. Researchers have gradually applied deep learning methods to the agricultural field. In general, researchers will improve the applicability of a deep learning model in the agricultural field through certain methods to obtain a better detection performance or detection rate, including modifying the network structure of the deep learning model [18; 19; 20; 21; 22], adding functional modules to the deep learning model [23; 24], and optimizing the post-processing method of the deep learning model [25].