A method for automatically extracting crop row direction and plant spacing information

By using the deep learning model YOLOv7 and vector point rotation optimization technology, the problem of inconsistent crop row directions in multiple fields in UAV imagery was solved, enabling fast and accurate extraction of crop row direction and plant spacing information.

CN117893785BActive Publication Date: 2026-07-10GUANGXI ZHUANG AUTONOMOUS REGION ACAD OF AGRI SCI

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGXI ZHUANG AUTONOMOUS REGION ACAD OF AGRI SCI
Filing Date
2023-09-18
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

The drone images contain multiple fields, and the crop row directions in each field are inconsistent, making it difficult to quickly and accurately extract information on crop row direction and plant spacing.

Method used

The crop is identified and converted into a vector point format based on the YOLOv7 deep learning model. Through spatial overlay analysis and rotation optimization, the optimal angle is found by using the variance of the number (or density) of vector points. The crop vector points are rotated to a vertical state. Combined with K-means clustering and least squares fitting, the crop row and plant spacing information is extracted.

Benefits of technology

It improves the accuracy of extracting crop row direction and plant spacing information, solves the error problem under inconsistent directions in multiple fields, and achieves fast and accurate information acquisition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117893785B_ABST
    Figure CN117893785B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of crop recognition, and particularly relates to a method for automatically extracting crop row direction and plant row spacing information, comprising the following steps: recognizing crops in images collected by a UAV platform; sequentially processing crop vector points of each field in order, and finding an optimal angle of rotation of the crop vector points of a current field; rotating the crop vector points of the current field according to the optimal angle, so that the crop rows are in a vertical state; determining the size of the crop row spacing in the current field; determining the size of the crop plant spacing in the current field; mapping the crop row position information to an original image coordinate system to obtain the actual distribution of the crop rows; repeating the above steps for each field in order, and finally obtaining the crop row direction and plant row spacing information in the entire image. The application can solve the problem that the crop row directions in multiple fields contained in UAV images are inconsistent, and it is difficult to quickly and accurately extract the crop row direction and plant row spacing information, and has a good market application prospect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of crop identification technology, specifically relating to a method for automatically extracting crop row direction and plant spacing information. Background Technology

[0002] China is a major agricultural producer, and agricultural development not only affects the living standards of its people but also the overall level of its economy. Agriculture is an indispensable part of my country's progress. In recent years, with the continuous application of advanced technologies such as big data, the Internet of Things, and artificial intelligence in agriculture, traditional agricultural production is transforming towards precision, intelligence, and collaboration in modern agriculture. Crop row recognition and row spacing information extraction are key technologies for achieving precision in modern agriculture. Accurately obtaining information such as crop row direction in complex farmland environments helps farmers accurately locate tasks such as tilling, weeding, fertilizing, and spraying pesticides, thereby improving agricultural production efficiency.

[0003] In existing research, crop image enhancement and segmentation are key aspects of crop row location detection. However, UAV imagery contains multiple fields with inconsistent crop row directions, making it difficult to quickly and accurately extract crop row direction and spacing information. Therefore, this invention proposes an automatic method for extracting crop row direction and spacing information.

[0004] The information disclosed in this background section is intended only to enhance the understanding of the overall background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention

[0005] The purpose of this invention is to provide an automatic extraction method for crop row direction and plant spacing information, in order to solve the problem that it is difficult to quickly and accurately extract crop row direction and plant spacing information when there are multiple fields in UAV images and the crop row direction of each field is inconsistent.

[0006] Furthermore, the method proposed in this invention is based on the fact that when the field is rotated to a suitable angle so that the crop rows are perpendicular to the X-axis, the crop distribution density in the crop row area is the highest, while the density in the non-crop row area is the lowest. At this point, the variance of the quantity (or density) of all crops (including both crop rows and non-crop rows) on the X-axis is the largest. Therefore, this invention uses the variance of the quantity (or density) of crop vector points distributed on the X-axis as an indicator to find the optimal angle for rotating the crop vector points of the current field.

[0007] To achieve the above objectives, the present invention provides the following technical solution:

[0008] A method for automatically extracting crop row direction and plant spacing information includes the following steps:

[0009] S1. Based on the deep learning model YOLOv7, crops in UAV images are identified, crop identification boxes are converted into vector point format with location information, plot boundary vectors and crop vector points are spatially overlaid and analyzed, and crop vector points are numbered according to their respective plots.

[0010] S2. Process the crop vector points of each field in sequence, find the optimal angle for rotating the crop vector point of the current field, and rotate the vector point to a vertical state.

[0011] By iterating twice with different rotation angles, the optimal rotation angle is gradually approached. First, the crop vector points of the current field are rotated in the range of -5° to 185° with a larger step size of 5° to obtain the range of the optimal angle. After each rotation, the variance of the number (or density) of vector points distributed on the X-axis is calculated, as shown in formula (1). When the rotation reaches angle α, if the condition of formula (2) is met, it indicates that the range of the optimal angle [α-5°, α+5°] has been obtained.

[0012] The formula for calculating variance is as follows:

[0013]

[0014] In the formula, S 2 The variance of the data is represented by X; M represents the mean of the data set; n represents the number of data points; X1, X2, X3...X n Indicates a specific numerical value;

[0015] X α-5 <X α ≥X α+5 (2)

[0016] Among them, X α =X max -X min

[0017] In the formula, X α X is the maximum variance of the number (or density) of crop vector points in the field when rotated to angle α. max With the minimum value X min The difference between them; X α-5 and X α+5 These are the differences between the maximum and minimum values ​​of the variance of the number (or density) of crop vector points at 5° to the left and right when rotated to angle α.

[0018] Then, within the obtained optimal angle range, rotate the crop vector point of the current field in steps of 0.5° to find a more refined optimal angle; when rotated to angle α, if the condition of formula (3) is met, the optimal angle α of rotation can be obtained.

[0019] X α-0.5 < X α ≥ X α+0.5 (3)

[0020] In the formula, X α X is the difference between the maximum and minimum variances of the crop vector points when rotated to angle α; α-0.5 and X α+0.5 These are the differences between the maximum and minimum variances of the crop vector points at 0.5° to the left and right when rotated to angle α, respectively.

[0021] S3. Rotate the crop vector points of the current field according to the optimal angle found in step S2 so that the crop rows are in a vertical state, so as to better extract crop row information.

[0022] S4. Determine the row spacing of crops in the current field;

[0023] By setting a filter, vector points in the current field with a number less than a certain threshold range are filtered out. While maintaining the characteristics of the crop row centerline, the scattered crops between rows are effectively removed, and the interference of noise outside the rows on the fitting of the crop row centerline is eliminated.

[0024] Set a sliding window with a width of 1m and a step size of 0.3m. Determine the position of the crop row by calculating the number (or density) of crop vector points within the window range. Move the sliding window from left to right along the X-axis. When the number (or density) of vector points at a certain position is greater than the number (or density) of vector points in the left window and greater than or equal to the number (or density) of vector points in the right window, it is considered that there is a crop row at that position. The discrimination formula is shown in formula (4). Record the number of crop rows and the X-axis coordinate values ​​corresponding to each crop row (approximate position, relatively coarse, needs further fitting and refinement).

[0025] M X-1 < M X ≥ M X+1 (4)

[0026] In the formula, M X M represents the number (or density) of crop vector points in the window when the sliding window is moved to the X position; X-1 and M X+1 The number (or density) of crop vector points when the sliding window moves to positions X-0.3m and X+0.3m;

[0027] Assign the corresponding X-axis coordinate value to the crop vector points, use the determined number of rows as the number of categories for K-means clustering, cluster the crop vector points of the current field, and complete the segmentation of crop rows;

[0028] The least squares method is used to fit straight lines to each row of the segmented crop vector points to obtain the accurate straight line coordinates of the crop rows on the image. The distance between crop rows is calculated based on the fitted straight line coordinates to obtain the crop row spacing in the image.

[0029] S5. Determine the spacing between crop plants in the current field.

[0030] Approximately 80% of the crop vector points in the current field are randomly sampled. The distance between each vector point and its nearest neighbor is calculated, and 10% of the maximum and minimum values ​​are removed to reduce the error caused by extreme values.

[0031] The average of the 60% of the retained distance values ​​is used to obtain the plant spacing of crops in the image;

[0032] S6. Because a rotation transformation has been performed, the fitting result needs to be inversely transformed. The points on the crop row obtained by least squares straight line fitting are rotated back to their original positions according to formula (5) to obtain the true distribution information of the crop row in the current field.

[0033] The formula for reverse rotation is as follows:

[0034] X=X′×cosθ-Y′×cosθ (5)

[0035] Y = X′ × sinθ + Y′ × cosθ

[0036] Where X and Y represent the coordinates of each point on the crop row in the actual situation after the reverse rotation; X′ and Y′ represent the coordinates of each point on the crop row in the vertical state before the reverse rotation; θ is the angle of reverse rotation;

[0037] S7. Repeat steps S2 to S6 for each crop field in the UAV image according to the numbering order to finally obtain the row direction and plant spacing information of the crops in the whole image.

[0038] Compared with the prior art, the present invention has the following beneficial effects:

[0039] (1) The automatic extraction method of crop row direction and plant spacing information of the present invention spatially superimposes the vector boundary of the plot with the vector point of the sugarcane seedling, numbers the vector point of the sugarcane seedling according to the plot to which it belongs, and the subsequent processing is based on the crop vector point. This solves the error caused by the image containing multiple plots with different row directions and the identified crops exceeding the plot range, and improves the accuracy.

[0040] (2) The automatic extraction method of crop row direction and plant spacing information of the present invention can rotate the vector point of the sugarcane seedling in the current field to a vertical state according to the optimal angle found, so as to facilitate the subsequent extraction of crop row direction and plant spacing information more quickly and accurately; there is a clear interval between crop rows after rotation and transformation, and the rotation of the vector point provides convenience for the subsequent acquisition of crop row direction and plant spacing information. Attached Figure Description

[0041] Figure 1 This is a flowchart of a method according to an embodiment of the present invention;

[0042] Figure 2 This is a schematic diagram of crop distribution represented in vector point format in an embodiment of the present invention;

[0043] Figure 3 This is a graph showing the change of the number (density) of crop vector points along the X-axis with rotation angle in an embodiment of the present invention;

[0044] Figure 4 This is a graph showing the variation of the crop vector point variance with rotation angle according to an embodiment of the present invention;

[0045] Figure 5 This is a comparison image of the crop vector points before and after rotation according to an embodiment of the present invention;

[0046] Figure 6 This is a schematic diagram illustrating the acquisition of crop row positions and quantities via a moving window in an embodiment of the present invention;

[0047] Figure 7 This is a schematic diagram of the crop row obtained by reverse rotation in an embodiment of the present invention. Detailed Implementation

[0048] The technical solution of this invention patent will be clearly and completely described below. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this invention.

[0049] See attached document Figure 1This invention was applied to conduct an automatic extraction experiment of crop row direction and plant spacing information in sugarcane fields in Dubang Village, Quli Town, Fusui County, Chongzuo City, Guangxi Province. First, a deep learning model was used to identify crops, converting their locations into vector points, and then dividing the crop vector points into blocks according to the field's vector boundaries. Second, the crop vector points of each field were processed sequentially, and the optimal rotation angle for the current field's crop vector points was obtained through two iterations with different rotation angles. Then, crop rows were divided based on K-means clustering, and the least squares method was used to fit the divided crop rows, calculating the crop row spacing in the current field based on the fitted linear coordinates. Next, approximately 80% of the crop vector points in the current field were randomly sampled to calculate the plant spacing in the current field. Finally, the fitted crop row position information was mapped to the original image coordinate system according to a correlation formula to obtain the actual distribution of crop rows. The above steps were repeated for each crop field in the UAV image in numerical order to obtain the crop row direction and plant spacing information for the entire image.

[0050] This invention uses the YOLOv7 deep learning model to identify sugarcane seedlings in UAV field images of the experimental area, and converts the identification boxes of the sugarcane seedlings into vector points, as shown in the attached figure. Figure 2 Furthermore, by spatially overlaying the vector boundaries of the plots with the vector points of the sugarcane seedlings, and numbering the sugarcane seedling vector points according to their respective plots, subsequent processing is all based on the crop vector points. This solves the errors caused by the image containing multiple plots with different row directions and the identified crops exceeding the plot boundaries, thus improving the accuracy of the method.

[0051] To better extract crop row information, this invention rotates the sugarcane seedling vector points in the current field to a vertical position by finding the optimal angle, and uses the variance of the number (or density) of vector points as an indicator to determine the optimal angle. This is mainly achieved through two iterations at different rotation angles, gradually approaching the optimal angle. First, the sugarcane seedling vector points in the experimental area are rotated in a range of -5° to 185° with a relatively long step size of 5°, and the range where the optimal angle lies is determined by maximizing the difference between the maximum and minimum values ​​of the vector point variance. Then, a smaller step size of 0.5° is used to rotate within the range where the optimal angle lies to find a more refined optimal angle. (See attached...) Figure 3 It can be observed that the variance of the sugarcane seedling vector points changes with the rotation angle. When the sugarcane seedling vector points in the current field are rotated to the optimal angle, i.e., when the crop rows are vertical, the number (density) of sugarcane seedling vector points on the crop rows reaches its maximum value, while the number (density) of vector points on non-crop rows reaches its minimum value. Figure 3 (c) Corresponding.

[0052] The optimal rotation angle is found when the difference between the maximum and minimum variances of the sugarcane seedling vector points at a certain angle is greater than both the difference to the left and the difference to the right. (See attached...) Figure 4 As can be seen, the angle corresponding to the point with the highest variance in the box is the optimal rotation angle. The optimal rotation angle for the sugarcane seedling vector point in the current field is 41°, where the difference between the maximum and minimum variance values ​​is the largest among all angles. Based on the found optimal angle, the sugarcane seedling vector point in the current field can be rotated to a vertical position, facilitating faster and more accurate extraction of information such as crop row direction and plant spacing.

[0053] Determine the optimal angle for rotating the sugarcane seedling vector points in the experimental area, and rotate the sugarcane seedling vector points in the current field to a vertical position according to the optimal angle. (Refer to Appendix) Figure 5 By comparison, it can be found that the crop rows after rotation are arranged along the X-axis of the image, and there is a clear interval between the rows. The rotation of the vector points provides convenience for subsequent acquisition of crop row direction and plant spacing information.

[0054] Obtain the approximate location and number of crop rows by moving the window. Set a sliding window 1m wide with a step size of 0.3m to calculate the number (density) of sugarcane seedling vector points in the current window. Refer to the appendix. Figure 6 The window moves from left to right along the X-axis. When the number (density) of vector points at a certain position is greater than the number (density) of vector points to the left and right, it is considered that a crop row exists at that position. The number of crop rows is used as the number of clusters for K-means clustering, and clustering is performed by assigning X-axis coordinate values ​​to the crop vector points, thus completing the division of all crop rows in the field.

[0055] The least squares method was used to fit the divided crop rows to obtain the linear coordinates of the crop rows on the image. (See attached figure.) Figure 7 The distance between crop rows can be calculated from the fitted linear coordinates, thus obtaining the crop row spacing; while the crop plant spacing can be obtained by statistically analyzing the distance between each vector point and its nearest neighbor. The crop row position information obtained from least-squares linear fitting is then rotated inversely according to the relevant formula to finally obtain the true distribution information of the crop rows.

[0056] The automatic extraction method for crop row direction and spacing information of the present invention processes the crop vector points of each field according to the division of the field, and can obtain the crop row direction and spacing information of each field in the whole UAV image. It can quickly and accurately extract the crop row features in the image, realize the efficient detection of crop row direction and spacing information, which is very practical and has good market application prospects.

[0057] The foregoing description of specific exemplary embodiments of the invention is for illustrative and explanatory purposes. These descriptions are not intended to limit the invention to the precise forms disclosed, and it will be apparent that many changes and variations can be made in accordance with the foregoing teachings. The exemplary embodiments were chosen and described in order to explain the specific principles of the invention and its practical application, thereby enabling those skilled in the art to implement and utilize various different exemplary embodiments of the invention, as well as various different choices and variations. The scope of the invention is intended to be defined by the claims and their equivalents.

Claims

1. A method for automatically extracting crop row direction and plant spacing information, characterized in that, Includes the following steps: S1. Identify crops in images collected by the drone platform; S2. Process the crop vector points of each field in sequence and find the optimal angle for rotating the crop vector points of the current field. S3. Rotate the crop vector points of the current field according to the optimal angle found in step S2 so that the crop rows are in a vertical state. S4. Determine the row spacing of crops in the current field; S5. Determine the spacing between crop plants in the current field. S6. Map the crop row location information to the original image coordinate system to obtain the actual distribution of the crop rows; S7. Repeat steps S2 to S6 above for each crop field in the UAV image according to the number order, and finally obtain the row direction and plant spacing information of the crops in the whole image. In step S1, crops in UAV images are identified based on the deep learning model YOLOv7. The crop identification boxes are converted into vector point format with location information. The plot boundary vectors and crop vector points are spatially overlaid and analyzed. The crop vector points are numbered according to the plots they belong to.

2. The method for automatically extracting crop row direction and plant spacing information according to claim 1, characterized in that, Step S2 first rotates the crop vector point of the current field in the range of -5° to 185° with a step size of 5° to obtain the range of the optimal angle; then, within the range of the obtained optimal angle, rotates the crop vector point of the current field in the range of 0.5° to obtain the final optimal angle.

3. The method for automatically extracting crop row direction and plant spacing information according to claim 1, characterized in that, Step S4 divides the crop rows based on K-means clustering, fits the divided crop rows using the least squares method, and calculates the crop row spacing in the current field based on the fitted straight line coordinates.

4. The method for automatically extracting crop row direction and plant spacing information according to claim 1, characterized in that, Step S5 involves randomly sampling 80% of the crop vector points in the current field, calculating the distance between each vector point and its nearest neighbor, and removing 10% of the maximum and minimum values ​​to reduce the error caused by extreme values. The average of the remaining 60% of the distance values ​​is then used to obtain the plant spacing of the crops in the image.