YOLOv8-based corn field seedling counting method and system
By adding the BiFormer attention mechanism and SPD-Conv module to the YOLOv8 model, combined with image stitching technology, the problem of low accuracy of corn seedling identification in irregular terrain is solved, and accurate detection and positioning of corn seedlings in large areas is achieved. , improving the efficiency of agricultural production and the level of precision agriculture.
Patent Information
- Application Number
- CN202410846597.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-08
AI Technical Summary
The existing corn seedling identification technology based on machine vision has low recognition and detection accuracy when splicing large-scale images, especially in irregular terrain, it is difficult to achieve accurate detection of corn seedlings.
The corn field seedling counting method based on YOLOv8 is used to collect images through drones and use Agisoft PhotoScan Professional for image stitching. OpenCV is used to segment and number the images. The improved YOLOv8 model is used for detection, and the BiFormer attention mechanism and SPD-Conv module are added. , perform batch detection and correct the detection results through IoU.
It improves the recognition accuracy and detection speed of corn seedlings in irregular terrain, is suitable for large-area drone image recognition, enhances the ability to identify the characteristics of corn seedlings, and is suitable for high-throughput detection and counting.
Smart Images

Figure CN118747744A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of artificial intelligence machine vision counting, and in particular relates to a method and system for counting corn seedlings in a field based on YOLOv8. Background Art
[0002] Corn seedling counting is a commonly used technology in agricultural production and has a wide range of application backgrounds. First of all, it plays an important role in planting management. By accurately counting the number of corn seedlings, the planting density can be adjusted to ensure that each plant obtains sufficient nutrition and growth space, thereby increasing the growth rate and yield of crops. Secondly, corn seedling counting can also be used to detect the extent of pests and diseases and take corresponding prevention and control measures in a timely manner. In addition, it also plays an important role in research and analysis, and is used to explore the growth laws of corn and suitable planting conditions, and provide a scientific basis for optimizing and improving corn planting. In summary, corn seedling counting is of great significance for scientific and rational corn planting and management, and provides key support for agricultural production.
[0003] In recent years, with the rapid development of computer vision and machine learning technologies, significant progress has been made in the research of machine vision in corn seedling recognition. Researchers are committed to developing algorithms based on deep learning models, among which convolutional neural network (CNN) is a commonly used model. By training a large number of corn seedling image datasets, these models can accurately identify corn seedlings of different varieties, growth stages, and disease states. In order to improve the accuracy and robustness of recognition, researchers also try to fuse multiple sensor data, such as infrared images and thermal infrared images. This can obtain more comprehensive and multi-angle features of corn seedlings, thereby improving the reliability of recognition.
[0004] In addition to static identification of corn seedlings, the researchers also focused on real-time detection and tracking. By combining object detection and tracking techniques, they developed algorithms that can track moving seedlings in real time. These algorithms can quickly and accurately detect and track corn seedlings in the field, providing real-time decision support for corn planting.
[0005] Image stitching is also widely used in the agricultural field. By quickly tracking crops in the field and stitching images of multiple crop growing areas, comprehensive observation and analysis of crop growth over a large area can be achieved. This technology can monitor crop growth status, detect diseases, estimate crop density, and identify crop varieties. Through image stitching, agricultural managers can better understand the health of crops, optimize agricultural production activities, and improve crop yields and quality.
[0006] However, the current corn seedling recognition technology based on machine vision is only suitable for small-target corn planting situations. When a large range of images of corn seedlings are spliced together to form a complete image through machine vision recognition, there is a problem of low recognition and detection accuracy.
[0007] The present invention proposes a corn seedling counting method and system based on YOLOv8. Based on image stitching technology, the method aims to integrate the image information of corn seedlings taken under irregular terrain into a complete picture, so as to realize accurate detection of corn seedlings under irregular terrain. YOLOv8 is used as the framework basis for improvement to achieve better recognition ability for corn seedling characteristics. Summary of the invention
[0008] The purpose of the present invention is to provide a corn field seedling counting method and system based on YOLOv8, so as to solve the problem that the corn seedling recognition technology based on machine vision in the prior art proposed in the above background technology has low accuracy for high-throughput detection and counting.
[0009] To achieve the above object, the present invention adopts the following technical solutions:
[0010] The first aspect of the present invention proposes a method for counting corn seedlings in a field based on YOLOv8, comprising the following steps:
[0011] S1, collect drone corn seedling images under different shooting environments and build a dataset;
[0012] S2. Improve and build a UAV corn seedling counting model based on YOLOv8, and train and optimize the parameters of the UAV corn seedling counting model based on the data set;
[0013] S3, planning the route of the drone for the corn field to be inspected, obtaining block images of the corn field, and ensuring that the block images at adjacent positions in the corn field have overlapping areas;
[0014] S4, using Agisoft PhotoScan Professional software to stitch the acquired block images of the corn field to obtain a complete image of the corn field;
[0015] S5. Using OpenCV, the complete image of the corn field is divided into a number of segmented images of equal size, wherein the segmented images at adjacent positions have overlapping areas; and the segmented images are numbered, where the numbers are the row and column numbers of the relative positions of the segmented images in the complete image;
[0016] S6. Use the drone corn seedling counting model to perform batch detection on a number of segmented images to obtain segmented image detection results;
[0017] S7, based on the segmented image detection results and the relative position of the segmented image to the complete image, mapping the segmented image detection results to the complete image one by one to generate a complete image detection result of the corn field;
[0018] S8. Calculate the IoU of the detection results at the overlapping positions in the overlapping area one by one, determine whether it is a repeated detection of the overlapping area, and correct the detection result of the complete image of the corn field.
[0019] Preferably, the drone corn seedling counting model is constructed in S2, specifically as follows:
[0020] Based on the YOLOv8 model, the BiFormer attention mechanism is added before each upsample module and each C2f module, and the C2f module is renamed as C2f-BiF module. The C2f-BiF module captures global and local feature information simultaneously through a two-layer routing attention mechanism.
[0021] And add an SPD-Conv module before each C2f-BiF module in the backbone part and after each Conv in the Neck part. The SPD-Conv module consists of a space-to-depth layer and a convolution-free stride layer.
[0022] Preferably, in S2, the parameters of the drone corn seedling counting model are trained and optimized as follows:
[0023] S201, divide the data set into a training set and a validation set according to a ratio of 9:1;
[0024] S202, using the pre-trained network weights as initial weights, and using the transfer learning method to train the UAV corn seedling counting model using the training set;
[0025] The pre-trained weights were iterated for 150 epochs. The backbone network was frozen in the first 50 epochs of training, with the learning rate set to 1e-4 and the decay rate set to 0.96. After 50 epochs, the backbone network was unfrozen, with the learning rate set to 1e-5 and the decay rate set to 0.96.
[0026] S203. Use the validation set to verify the trained drone corn seedling counting model.
[0027] Preferably, the overlapping areas of the block images at adjacent positions or the segmented images at adjacent positions are both 20%.
[0028] Preferably, the segmented image detection result obtained in S6 is as follows:
[0029] The batch detection function in the drone corn seedling counting model is used to detect all segmented images, and the segmented image detection results are saved in text. The text records the center point coordinates of the detection frame of the corn seedlings in the segmented image, the length, width and confidence of the detection frame.
[0030] Preferably, the complete image detection result of the corn field is generated in S7, specifically as follows:
[0031] According to the segmented image detection results and the corresponding segmented image number, the corresponding detection frame position on the complete image is calculated. The calculation formula is as follows:
[0032] C x =c x +i*l-0.2*i(i=0,1,...)
[0033] C y =c y +j*w-0.2*j(j=0,1,...)
[0034] Among them, C x , C y is the center coordinate of the detection box on the complete image, c x 、c y is the center coordinate of the detection box on the segmented image, i and j are the row and column numbers of the corresponding segmented image, and l and w are the length and width of the segmented image.
[0035] Preferably, the complete image detection result of the corn field is corrected in S8, specifically as follows:
[0036] S801, obtain information of the detection frames in the overlapping area, and calculate the IoU between the detection frames with the same center coordinates one by one; the IoU calculation formula is as follows:
[0037]
[0038] Among them, A and B represent the detection frames of adjacent separated images in the overlapping area;
[0039] S802, setting the IoU threshold to 0.5; when the IoU of two detection frames is greater than 0.5, it is determined that a single corn seedling is detected by multiple detection frames, and the total number of complete image detection results of the corn field is deleted accordingly; otherwise, the total number of complete image detection results of the corn field is kept unchanged.
[0040] The second aspect of the present invention proposes a corn field seedling counting system based on YOLOv8, comprising:
[0041] Image acquisition equipment, including a drone equipped with a camera for acquiring images of corn seedlings;
[0042] The UAV route planning module is used to set the UAV route according to the latitude, longitude and area of the corn field to be inspected;
[0043] Image stitching module, using Agisoft PhotoScan Professional to stitch the divided images into a complete image;
[0044] Image segmentation module, using OpenCV to divide the complete image into several segmented images of equal size as required;
[0045] The corn seedling recognition and counting model is improved on the basis of YOLOv8 and is used to count corn seedlings in the segmented image;
[0046] A detection result mapping module is used to map the detection results of the segmented image to the complete image one by one to obtain the detection results of the complete image;
[0047] The detection result correction module is used to calculate the IoU of two detection boxes and correct the detection results of the complete image.
[0048] A third aspect of the present invention provides a computer device, including a memory and a processor;
[0049] The memory stores an executable program that runs on the processor;
[0050] The processor implements the above-mentioned corn field seedling counting method based on YOLOv8 when running the executable program.
[0051] Compared with the prior art, the present invention has the following beneficial effects:
[0052] (1) The corn field seedling counting method based on YOLOv8 in the present invention selects YOLOv8 as the framework basis, and adds the BiFormer attention mechanism and SPD-Conv module thereto, which effectively improves the accuracy and generalization ability of drone corn seedling detection. Adding a suitable number of BiFormer attention mechanisms and SPD-Conv modules at appropriate positions in YOLOv8 has better recognition ability for corn seedling features, and the deep learning network structure suitable for high-throughput detection and counting can improve the accuracy of counting. The present invention has a faster detection speed while ensuring the accuracy, and is very suitable for the recognition and detection of large-scale drone images of corn seedlings. The recognition and detection of small targets in drone images has a higher accuracy than other methods. Compared with the prior art, it can effectively improve the recognition accuracy of drone corn seedlings.
[0053] (2) The present invention is based on image stitching technology, and aims to integrate the image information of corn seedlings taken under irregular terrain into a complete picture, so as to realize accurate detection of corn seedlings under irregular terrain. By collecting and stitching multiple images of corn seedlings taken at different angles and positions, these partial images are seamlessly stitched together using image registration and fusion algorithms to form a panoramic image. This method can effectively overcome the limitations of irregular terrain on image acquisition, so that complete corn seedling information can be obtained even in complex terrain environments. At the same time, by processing and analyzing the stitched images, accurate detection and positioning of corn seedlings can be achieved, providing important data support for agricultural production and management. The application of this technology will help improve agricultural production efficiency and the level of development of precision agriculture. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 It is a schematic diagram of the process of the corn field seedling counting method based on YOLOv8 in the present invention;
[0055] Figure 2 It is a system block diagram of the corn seedling recognition and counting model in the present invention;
[0056] Figure 3 It is a structural block diagram of the BiFormer attention mechanism in the present invention;
[0057] Figure 4 The device for collecting corn seedling images and the collected corn seedling images in Example 1 of the present invention, (a) is a corn seedling image, and (b) is a device for collecting corn seedling images;
[0058] Figure 5 This is a schematic diagram of the UAV route planning in Example 1 of the present invention;
[0059] Figure 6 Schematic diagram of the complete image detection result in Example 1 of the present invention. DETAILED DESCRIPTION
[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] Embodiment 1:
[0062] See also Figure 1 , a corn field seedling counting method based on YOLOv8, comprising the following steps:
[0063] S1. Collect drone images of corn seedlings in different shooting environments, annotate them, and create a dataset.
[0064] Image acquisition: First, determine the flight area and flight altitude to ensure that the corn field image can be fully and clearly captured. Secondly, configure the camera equipment on the drone, including setting shooting parameters, adjusting focal length and angle, etc., to ensure image quality and coverage. Then, carry out the actual flight mission, let the drone fly on the predetermined path, and start the camera for continuous shooting, collecting 1,000 pictures. Then select another batch of corn seedling images in different environments, and take another 100 pictures. Figure 4 shown.
[0065] Dataset creation: Use Labelimg software to manually annotate each image, and divide the 1,000 images into a training set and a validation set at a ratio of 9:1. Use another 100 images as a test set to create a test set under different lighting and weather conditions.
[0066] S2. Improve the YOLOv8 model to build a drone corn seedling counting model.
[0067] The network structure of YOLOv8 is mainly composed of three parts: Backbone, Neck, and Head;
[0068] The Backbone part is responsible for feature extraction. It uses a series of convolution and deconvolution layers, combined with residual connections and bottleneck structures to reduce the size of the network and improve performance. This part uses the C2f module as the basic building block. Specifically, the C2f module reduces redundant parameters and improves computational efficiency through a more efficient structural design.
[0069] The Neck part is responsible for multi-scale feature fusion, which integrates feature maps from different stages of Backbone to enhance feature expression capabilities. Specifically, the Neck part of YOLOv8 includes the following components:
[0070] SPPF module (Spatial Pyramid Pooling Fast): For pooling operations of different scales, feature maps of different scales are spliced together to improve the detection ability of objects of different sizes.
[0071] PAA module (Probabilistic Anchor Assignment): intelligently assigns anchor boxes to optimize the selection of positive and negative samples, thereby improving the training effect of the model.
[0072] PAN module (Path Aggregation Network): It includes two PAN modules, which are used for path aggregation of features at different levels, and enhance the expressiveness of feature maps through bottom-up and top-down paths.
[0073] The Head part is responsible for the final target detection and classification tasks, including a detection head and a classification head:
[0074] Detection head: Contains a series of convolutional layers and deconvolutional layers to generate detection results.
[0075] Classification head: Global Average Pooling is used to classify each feature map, and the probability distribution of each category is output by reducing the dimension of the feature map.
[0076] Please refer to the network model constructed in this embodiment. Figure 2 To address the problem of poor accuracy in detecting small targets in drones, the present invention adds a BiFormer attention mechanism before each upsample module and each C2f module of YOLOv8, and changes the module name to C2f-BiF; and adds an SPD-Conv module before each C2f-BiF module in the backbone part and after each Conv in the Neck part.
[0077] The core idea of BiFormer is to introduce a two-layer routing attention mechanism, which can capture global and local feature information at the same time, thereby improving the performance of the model in visual tasks and is suitable for processing large-scale targets, small-scale targets, dense targets and occluded targets. Specifically for the YOLOv8 model, BiFormer captures global and local feature information at the same time through a two-layer routing attention mechanism, improving the performance of the model in visual tasks. The introduction of the BiFormer attention mechanism can effectively improve the model's ability to detect targets of different scales, densities and occluded targets. The structure of the BiFormer attention mechanism is as follows: Figure 3 shown.
[0078] SPD-Conv is designed to replace the stride convolution and pooling layers in the traditional CNN architecture to improve the performance when processing low-resolution images and small objects. SPD-Conv consists of a space-to-depth (SPD) layer and a convolution-free stride (Conv) layer, which can greatly improve the recognition accuracy of small objects.
[0079] Specifically, in this embodiment, the network weights pre-trained in step S1 are used as initial weights, and the training set is used for training using the transfer learning method;
[0080] The pre-trained weights were iterated for 150 epochs. The backbone network was frozen in the first 50 epochs of training, with the learning rate set to 1e-4 and the decay rate set to 0.96. After 50 epochs, the backbone network was unfrozen, with the learning rate set to 1e-5 and the decay rate set to 0.96.
[0081] The validation set is used to verify the trained improved YOLOv8 network model.
[0082] S3. Plan the route of the UAV according to the actual terrain of the corn field to be inspected.
[0083] Specifically, in this embodiment, according to the actual terrain, the drone is set to fly along the specified route and collect images, ensuring that the adjacent images collected have a 20% overlap, and obtaining the block images of the corn field; the example route is as follows: Figure 5 .
[0084] S4. Stitching the collected corn field block images to obtain a complete image of the corn field.
[0085] This embodiment uses Agisoft PhotoScan Professional software to stitch images. The specific steps are as follows:
[0086] After importing the photos through `Workflow>Add Photos`, select `Workflow>Align Photos` to align the images and adjust the parameters to start the alignment process. Then, generate a dense point cloud through `Workflow>Build Dense Cloud`, selecting appropriate quality and depth filters. Optionally, generate a mesh and texture, using `Workflow>BuildMesh` and `Workflow>Build Texture` respectively. Finally, export the orthophoto using `File>Export`. Make sure the camera is calibrated correctly and set the coordinate system as needed to improve accuracy. Pay attention to check the quality of the results during processing, adjust and optimize step by step, and ensure that the computer has enough resources to handle large datasets.
[0087] S5. Divide the complete image of the corn field into a number of rows and columns of images of equal size as required and number them.
[0088] Since the drone may not be able to fly completely accurately on the route due to environmental factors during the shooting process, the precise relative position relationship of the captured block images cannot be obtained. Therefore, OpenCV is first used to divide the complete image into several rows and columns of equal size according to the requirements, and then the detection is considered to obtain the segmented image detection results. The segmented images at adjacent positions have a 20% overlapping area, and the relative positions of the segmented images in the complete image are numbered by row and column numbers.
[0089] S6. Use the improved UAV corn seedling counting model to detect the segmented image of the corn field to be counted and retain the result coordinates.
[0090] Specifically, in this embodiment, the batch detection function of YOLOv8 is used to detect all segmented images, and the detection results are saved. The result text saves the center coordinates of the detection box, the length, width and confidence of the detection box.
[0091] S7. Generate detection results of the complete image of the corn field.
[0092] According to the previous result coordinates and the relative position relationship between the segmented image and the complete image, the detection result is mapped to the complete image to generate the complete target detection box coordinate result text for the spliced large image.
[0093] According to the saved segmented image detection results and the row and column numbers of the corresponding segmented images, the corresponding detection frame position on the spliced image is calculated according to the following formula;
[0094] C x =c x +i*l-0.2*i(i=0,1,...)
[0095] C y =c y +j*w-0.2*j(j=0,1,...)
[0096] Among them, C x , C y is the center coordinate of the detection box on the final large image, c x 、c y is the center coordinate of the detection box on the segmented image, and i and j are the row and column numbers of the corresponding segmented image.
[0097] This processing method can effectively detect targets in large-area and irregular-shaped corn field seedling images while retaining the spatial relationship of the targets in the original images.
[0098] S8. Calculate the IoU of the coordinates of the overlapping areas of adjacent segments in the target mapped back to the original image one by one. If IoU>0.5, it is considered to be a repeated detection of the overlapping part, and the total number of detections is reduced by one, and the coordinates of the detection box with a smaller area are deleted. For example, please refer to Figure 6 .
[0099] In order to avoid repeated counting, the IoU (Intersection over Union) method is usually used to eliminate repeated detection when counting the number of corn seedlings. The specific operation is to obtain the coordinate information of all detected bounding boxes, then calculate the IoU between them one by one, and set the IoU threshold to 0.5. Iou represents the degree of overlap between two boxes. When the IoU of two bounding boxes is greater than 0.5, it is considered that a single seedling is detected by multiple bounding boxes. This repeated detection will be deleted from the total number, thereby ensuring the accuracy of the final counting result. This method can effectively eliminate the number of repeated calculations and improve the accuracy of corn seedling counting.
[0100] The IoU calculation formula is as follows:
[0101]
[0102] The numerator in the formula represents the area of the intersection of the predicted box and the true box, and the denominator represents the area occupied by the predicted box plus the true box. A and B respectively represent the detection boxes of adjacent blocks in the overlapping area.
[0103] The corn field seedling counting system based on YOLOv8 obtained in this embodiment specifically includes: an image acquisition device, a drone route planning module, a corn seedling recognition and counting model, an image stitching module, an image segmentation module and a detection result image export module.
[0104] In this embodiment, the image acquisition device uses a camera device carried by a drone to acquire images. The longitude, latitude and altitude of the corn seedling field to be inspected are set through the drone route planning module, and the drone performs the image acquisition task.
[0105] In this embodiment, the image stitching module imports the drone image to generate the orthophoto of the corn field. In the image segmentation module, OpenCV is used to divide the complete image into several segmented images of equal size according to the requirements.
[0106] In this embodiment, the corn seedling recognition and counting model chooses to use YOLOv8 as the framework basis, and adds the BiFormer attention mechanism and SPD-Conv module to it; by batch importing the spliced orthophoto segmented images, recognition and counting are performed, and the coordinate information of the target box is generated.
[0107] In this embodiment, the detection result image export module includes a detection result mapping module and a detection result correction module. The detection result mapping module marks the corn seedlings on the orthophoto according to the coordinate information, and deletes the repeated calculations in the detection results of the orthophoto of the corn field through the detection result correction module, and exports it into an image.
[0108] Experimental verification:
[0109] In order to verify the accuracy of the invention in the identification of corn seedlings by drone, the obtained weight file was used to test the corn seedling images of drones in the test set. At the same time, in order to evaluate the superiority and effectiveness of the detection algorithm proposed by the invention over the current popular target detection model, the invention selected YOLOv5s, YOLOv7, YOLOv8s and YOLOv8n algorithms and conducted experimental comparisons under the same configuration and data set conditions.
[0110] In order to further verify the effectiveness of the improved module, this paper takes the original model YOLOv8n as the baseline, selects the BiFormer attention mechanism module and the SPD-Conv module, and conducts ablation experiments through different combinations of multiple improved modules. The experimental results are shown in Table 1.
[0111] Table 1 Comparison results of the improved models of the present invention and other improved methods of YOLOv8n
[0112]
[0113] The results show that when the dataset complexity is high, the improved network has significant improvements in various detection indicators compared with other methods, demonstrating its superiority in UAV corn seedling detection performance.
[0114] The application of machine vision in the agricultural field is not limited to corn seedling recognition. Similar technology can also be applied to seedling recognition of other crops, such as wheat, soybeans, etc. The present invention can also be applied to seedling recognition of other crops.
[0115] The above description is only used to help understand the method of the present invention and its core essence, but the protection scope of the present invention is not limited thereto. For those skilled in the art in the art, equivalent replacement or change according to the technical solution and inventive concept of the present invention within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A corn field seedling counting method based on YOLOv8, characterized in that: The following steps are involved: S1, collect drone corn seedling images under different shooting environments and build a dataset; S2. Improve and build a UAV corn seedling counting model based on YOLOv8, and train and optimize the parameters of the UAV corn seedling counting model based on the data set; S3, planning the route of the drone for the corn field to be inspected, obtaining block images of the corn field, and ensuring that the block images at adjacent positions in the corn field have overlapping areas; S4, stitching the acquired block images of the corn field to obtain a complete image of the corn field; S5, dividing the complete image of the corn field into a number of segmented images of equal size, wherein the segmented images at adjacent positions have overlapping areas; and numbering the segmented images, wherein the numbers are row and column numbers of the relative positions of the segmented images in the complete image; S6. Use the drone corn seedling counting model to perform batch detection on a number of segmented images to obtain segmented image detection results; S7, based on the segmented image detection results and the relative position of the segmented image to the complete image, mapping the segmented image detection results to the complete image one by one to generate a complete image detection result of the corn field; S8. Calculate the IoU of the detection results at the overlapping positions in the overlapping area one by one, determine whether it is a repeated detection of the overlapping area, and correct the detection result of the complete image of the corn field.
2. The corn field seedling counting method based on YOLOv8 according to claim 1, characterized in that: The UAV corn seedling counting model is constructed in S2, as follows: Based on the YOLOv8 model, the BiFormer attention mechanism is added before each upsample module and each C2f module, and the C2f module is renamed as C2f-BiF module. The C2f-BiF module captures global and local feature information simultaneously through a two-layer routing attention mechanism. And add an SPD-Conv module before each C2f-BiF module in the backbone part and after each Conv in the Neck part. The SPD-Conv module consists of a space-to-depth layer and a convolution-free stride layer.
3. The corn field seedling counting method based on YOLOv8 according to claim 2, characterized in that: In S2, the parameters of the drone corn seedling counting model are trained and optimized as follows: S201, divide the data set into a training set and a validation set according to a ratio of 9:1; S202, using the pre-trained network weights as initial weights, and using the transfer learning method to train the UAV corn seedling counting model using the training set; The pre-trained weights were iterated for 150 epochs. The backbone network was frozen in the first 50 epochs of training, with the learning rate set to 1e-4 and the decay rate set to 0.
96. After 50 epochs, the backbone network was unfrozen, with the learning rate set to 1e-5 and the decay rate set to 0.
96. S203. Use the validation set to verify the trained drone corn seedling counting model.
4. The corn field seedling counting method based on YOLOv8 according to claim 1, characterized in that: In the S4, a complete image of the corn field is obtained, specifically by using Agisoft PhotoScan Professional software to perform image stitching.
5. The corn field seedling counting method based on YOLOv8 according to claim 1, characterized in that: The overlapping areas of the block images at adjacent positions or the segmented images at adjacent positions are both 20%.
6. The corn field seedling counting method based on YOLOv8 according to claim 5, characterized in that: The segmented image detection result is obtained in S6, which is as follows: The batch detection function in the drone corn seedling counting model is used to detect all segmented images, and the segmented image detection results are saved in text. The text records the center point coordinates of the detection frame of the corn seedlings in the segmented image, the length, width and confidence of the detection frame.
7. The corn field seedling counting method based on YOLOv8 according to claim 6, characterized in that: The complete image detection result of the corn field is generated in S7, which is as follows: According to the segmented image detection results and the corresponding segmented image number, the corresponding detection frame position on the complete image is calculated. The calculation formula is as follows: C x =c x +i*l-0.2*i(i=0,1,...) C y =c y +j*w-0.2*j(j=0,1,...) Among them, C x , C y is the center coordinate of the detection box on the complete image, c x 、c y is the center coordinate of the detection box on the segmented image, i and j are the row and column numbers of the corresponding segmented image, and l and w are the length and width of the segmented image.
8. The corn field seedling counting method based on YOLOv8 according to claim 7, characterized in that: In the S8, the complete image detection result of the corn field is corrected as follows: S801, obtain information of the detection frames in the overlapping area, and calculate the IoU between the detection frames with the same center coordinates one by one; the IoU calculation formula is as follows: Among them, A and B represent the detection frames of adjacent separated images in the overlapping area; S802, setting the IoU threshold to 0.5; when the IoU of two detection frames is greater than 0.5, it is determined that a single corn seedling is detected by multiple detection frames, and the total number of complete image detection results of the corn field is deleted accordingly; otherwise, the total number of complete image detection results of the corn field is kept unchanged.
9. A corn field seedling counting system based on YOLOv8 obtained according to any one of the methods described in claims 1-8, characterized in that: include: Image acquisition equipment, including drones with cameras on board; Used for corn seedling image acquisition; The UAV route planning module is used to set the UAV route according to the latitude, longitude and area of the corn field to be inspected; Image stitching module, using Agisoft PhotoScan Professional to stitch the divided images into a complete image; Image segmentation module, using OpenCV to divide the complete image into several segmented images of equal size as required; The corn seedling recognition and counting model is improved on the basis of YOLOv8 and is used to recognize and count corn seedlings in segmented images; A detection result mapping module is used to map the detection results of the segmented image to the complete image one by one to obtain the detection results of the complete image; The detection result correction module is used to calculate the IoU of two detection boxes and correct the detection results of the complete image.
10. A computer device, characterized in that: Including memory and processor; The memory stores an executable program that runs on the processor; When the processor runs the executable program, the corn field seedling counting method based on YOLOv8 according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Method for detecting and counting corn seedlings and weeds based on remote sensing image of unmanned aerial vehicle
CN114926752A
Deep learning-based near-seabed benthos quantitative detection method and system
CN116664545A
Method for monitoring number of corn seedlings, computer equipment and computer program product
CN117893973A
Cited By
Indoor soft installation cost estimation method and device based on image detection and medium
CN121617123A
