Crop ridge row range determination method, program product, electronic equipment and medium
Through image segmentation and confidence evaluation, and combining multiple indicators to calculate the crop monopoly range, the problem of low crop recognition accuracy in complex environments is solved, and high precision and automation support for agricultural mechanized operations are achieved.
Patent Information
- Application Number
- CN202510332782.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-07-18
AI Technical Summary
The prior art is difficult to accurately identify the crop range in complex environments such as insufficient light, shadows or strong light reflections, resulting in low accuracy of agricultural mechanized operations.
Through image segmentation and confidence evaluation, the confidence data of crop ridge range is calculated based on the continuous degree of pixel points, the degree of change of adjacent frames and the degree of pixel dispersion, and the driving path of agricultural machinery or drones is dynamically adjusted.
It improves the accuracy of crop range determination, reduces manual dependence, reduces labor costs, and optimizes the accuracy and robustness of agricultural automation operations.
Smart Images

Figure CN120339823A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of crop range identification. Specifically, it relates to a method for determining the ridge row range of a crop, a program product, an electronic device, and a medium. Background Art
[0002] Accurately determining the range of crops can provide precise navigation and decision-making support for agricultural mechanized operations, meet the requirements of precise operations, and thus improve agricultural production efficiency. The prior art classifies the crop range based on a multispectral camera. According to the principle that different objects such as crops, land, and weeds have different spectra, it is possible to identify crops, land, weeds, etc., and then calculate the crop range. However, this method has a low accuracy in identifying the crop range. Summary of the Invention
[0003] The purpose of the embodiments of the present application is to provide a method for determining the ridge row range of a crop, a program product, an electronic device, and a medium, which is used to improve the accuracy of identifying the crop range.
[0004] In a first aspect, the embodiments of the present application provide a method for determining the ridge row range of a crop, including: obtaining an image to be detected; the image to be detected includes at least one ridge of crops; segmenting the image to be detected according to the at least one ridge of crops to obtain a segmented region image; the segmented region image represents the region of a ridge of crops in the image to be detected; calculating the confidence of the segmented region image to obtain the confidence data of the segmented region image; the confidence data represents the degree of consistency that the segmented region image is the crop range; determining the ridge row range of the crop based on the confidence data.
[0005] In the above implementation process, through image segmentation and confidence evaluation, the ridge row range of the crop can be accurately determined, providing reliable support for agricultural automated operations. By determining the ridge row range of the crop, agricultural machinery or drones can accurately travel along the crop rows, reducing deviation and collision. Automatically determining the crop range reduces the dependence on manual labor, especially in large-scale farms, significantly reducing labor costs. Through confidence evaluation, the accuracy of crop range determination is improved, thus realizing dynamic adjustment of operation strategies in complex environments (such as light changes, shadows, etc.).
[0006] Optionally, in the embodiments of the present application, confidence calculation includes calculating based on the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels; performing confidence calculation on the segmented region image to obtain confidence data of the segmented region image, including: performing confidence calculation on the segmented region image to obtain the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels in the segmented region image; performing calculation processing on the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels to obtain the confidence data of the segmented region image; the calculation processing includes weighted summation, average method, minimum / maximum value method, exponential weighting method, or machine learning method.
[0007] In the above implementation process, by comprehensively considering the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels, the accuracy of the segmented region image can be more comprehensively evaluated, misjudgment caused by the limitation of a single index can be reduced, and the robustness of the model can be improved. By performing various calculation processes to obtain the confidence data of the segmented region image, different agricultural scenarios and crop types can be adapted, and the accuracy of crop range determination can be improved.
[0008] Optionally, in the embodiments of the present application, performing confidence calculation on the segmented region image to obtain the continuity degree of pixel points in the segmented region image includes: determining the non-adherent crop regions within a preset range in the segmented region image; counting the number of pixels in the non-adherent crop regions to obtain the number of effective pixel points; obtaining the continuity degree of pixel points according to the ratio of the number of effective pixel points to the total number of pixel points in the segmented region image.
[0009] In the above implementation process, by counting the number of effective pixel points in the non-adherent crop regions of the segmented region image and calculating the ratio of the number of effective pixel points to the total number of pixel points, the continuity degree of pixel points is quantified. This method can not only accurately evaluate the quality of the segmentation result, but also provide a reliable basis for subsequent agricultural automation operations, improving the decision-making reliability and real-time performance of the system.
[0010] Optionally, in the embodiments of the present application, the image to be detected is a video frame in the video to be detected; performing confidence calculation on the segmented region image to obtain the change degree between adjacent frames of the segmented region image includes: obtaining adjacent frames in the video corresponding to the image to be detected from the video to be detected; the adjacent frames include multiple segmented regions segmented according to the crops in the adjacent frames; determining the target segmented region from the multiple segmented regions in the adjacent frames according to the identification information of the segmented region image or the position of the segmented region image in the image to be detected; determining the number of repeated pixel points between the segmented region image and the target segmented region, and the total number of pixel points of the segmented region image and the target segmented region; obtaining the change degree between adjacent frames of the segmented region image according to the ratio of the number of repeated pixel points to the total number of pixel points.
[0011] In the above implementation process, by calculating the degree of change between adjacent frames, the stability of the segmentation result in the time series can be quantified, which helps to evaluate the accuracy of the segmented region image. If the degree of change between adjacent frames is low, it indicates that the segmentation result is unstable, and the system can dynamically adjust the parameters of the segmentation algorithm or trigger manual intervention. The degree of change between adjacent frames provides important time dimension information for confidence calculation, making the confidence evaluation more comprehensive and reliable. Moreover, by comparing the segmentation results of adjacent frames, the existing segmentation information can be directly utilized, reducing redundant calculations.
[0012] Optionally, in the embodiments of the present application, the pixel dispersion degree includes the edge dispersion degree and / or the center dispersion degree; calculating the confidence of the segmented region image to obtain the pixel dispersion degree of the segmented region image includes: generating a first fitting line according to the edge pixel points of the segmented region image; obtaining the edge dispersion degree of the segmented region image according to the distance from the edge pixel points of the segmented region image to the first fitting line; and / or, generating a second fitting line according to the center pixel points of the segmented region image; obtaining the center dispersion degree of the segmented region image according to the distance from the center pixel points of the segmented region image to the second fitting line.
[0013] In the above implementation process, by evaluating the dispersion degrees of the edge pixel points and the center pixel points, the smoothness of the segmented region is quantified. A smooth edge usually indicates a more accurate segmentation result. Combining the edge dispersion degree and the center dispersion degree can evaluate the quality of the segmentation result from multiple dimensions, making the confidence calculation more comprehensive.
[0014] Optionally, in the embodiments of the present application, segmenting the image to be detected according to at least one ridge of crops to obtain a segmented region image includes: inputting the image to be detected into a pre-trained segmentation model to obtain the segmented region image; the training process of the segmentation model includes: performing class labeling on the pixel points in the collected crop images to obtain an annotated image; preprocessing the annotated image to obtain a preprocessed annotated image; and training a preset model using the preprocessed annotated image to obtain the segmentation model.
[0015] In the above implementation process, by performing class labeling on the pixel points in the image, a high-quality annotated image is generated, providing an accurate supervision signal for model training. By preprocessing and data augmentation of the annotated image, the generalization ability of the model is improved, enabling it to be more accurate under different environmental conditions. Selecting a lightweight model suitable for edge devices can operate efficiently in resource-constrained environments.
[0016] Optionally, in the embodiments of the present application, the image to be detected includes a video frame in an image or video captured by an agricultural vehicle or a drone during operation; after obtaining the confidence data of the segmented region image, the method further includes: adjusting the driving direction of the agricultural vehicle or the drone according to the confidence data; and / or sending the confidence data to the client.
[0017] In the above implementation process, through image segmentation and confidence evaluation, the ridge range of crops can be accurately determined, and the driving direction of the agricultural vehicle or the drone can be dynamically adjusted according to the confidence data. At the same time, the confidence data is sent to the client to provide real-time feedback and monitoring functions for the operator. This method not only improves the accuracy and automation level of agricultural operations, but also optimizes resource utilization, enhances the robustness and intelligence level of the system.
[0018] In a second aspect, the embodiments of the present application further provide a device for determining the ridge range of crops, including: an image acquisition module for acquiring an image to be detected; the image to be detected includes at least one ridge of crops; a segmentation module for segmenting the image to be detected according to at least one ridge of crops to obtain a segmented region image; the segmented region image represents the region of one ridge of crops in the image to be detected; a confidence calculation module for calculating the confidence of the segmented region image to obtain the confidence data of the segmented region image; the confidence data represents the degree of consistency that the segmented region image is the crop range; a range determination module for determining the ridge range of crops based on the confidence data.
[0019] In a third aspect, the embodiments of the present application further provide a computer program product, including computer program instructions, and when the computer program instructions are run by a processor, they execute the method provided in the first aspect or any one implementation manner of the first aspect.
[0020] In a fourth aspect, the embodiments of the present application further provide an electronic device, including: a processor and a memory, the memory stores computer program instructions, and when the computer program instructions are run by the processor, they execute the method provided in the first aspect or any one implementation manner of the first aspect.
[0021] In a fifth aspect, the embodiments of the present application further provide a computer-readable storage medium, on which computer program instructions are stored, and when the computer program instructions are run by a processor, they execute the method provided in the first aspect or any one implementation manner of the first aspect.
[0022] By using a method, program product, electronic device, and storage medium for determining the ridge row range of a crop provided in this application, through image segmentation and confidence evaluation, the ridge row range of the crop can be accurately determined, providing reliable support for agricultural automation operations. By determining the ridge row range of the crop, agricultural machinery or drones can accurately travel along the crop rows, reducing deviation and collision. Automatically determining the crop range reduces the dependence on manual labor, especially in large-scale farms, significantly reducing labor costs. Through confidence evaluation, the accuracy of crop range determination is improved, enabling dynamic adjustment of operation strategies in complex environments (such as light changes, shadows, etc.). BRIEF DESCRIPTION OF THE DRAWINGS
[0023] To more clearly illustrate the technical solutions of the embodiments of this application, the following briefly introduces the drawings required for use in the embodiments of this application. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other relevant drawings can also be obtained based on these drawings.
[0024] Figure 1 It is a schematic flowchart of a method for determining the ridge row range of a crop provided in an embodiment of this application;
[0025] Figure 2 It is a schematic structural diagram of a device for determining the ridge row range of a crop provided in an embodiment of this application;
[0026] Figure 3 It is a schematic structural diagram of an electronic device provided in an embodiment of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0027] The following will describe in detail the embodiments of the technical solutions of this application with reference to the drawings. The following embodiments are only used to more clearly illustrate the technical solutions of this application and are therefore only examples and should not be used to limit the protection scope of this application.
[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0029] In the description of the embodiments of this application, technical terms such as "first" and "second" are only used to distinguish different objects and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity, specific order, or primary-secondary relationship of the indicated technical features. In the description of the embodiments of this application, "a plurality" means two or more, unless otherwise specifically defined.
[0030] By precisely controlling the driving path and operation range of agricultural machinery, precise seeding, fertilization, irrigation, and harvesting can be achieved, that is, precise operation. Ridge finding and determining the crop range provide the basic data for these operations. In hilly or irregular terrains, the crop ridges may be irregular. By finding the ridges and determining the range, the operation path can be dynamically adjusted to adapt to complex terrain conditions.
[0031] The prior art classifies the crop range based on a multispectral camera. According to the principle that different objects such as crops, land, and weeds have different spectra, the crops, land, and weeds can be identified, and then the crop range can be calculated. However, in complex environments such as insufficient light, shadows, or strong light reflection, the crop range may not be accurately identified, indicating that this method has a low accuracy in identifying the crop range.
[0032] The embodiment of the present application provides a method for determining the ridge range of crops. Through image segmentation and confidence evaluation, the ridge range of crops can be accurately determined, providing reliable support for agricultural automation operations. By determining the ridge range of crops, agricultural machinery or drones can accurately drive along the crop rows, reducing deviation and collision. Automatically determining the crop range reduces the dependence on manual labor, especially in large-scale farms, significantly reducing the labor cost. Through confidence evaluation, the accuracy of crop range determination is improved, thus enabling dynamic adjustment of operation strategies in complex environments (such as light changes, shadows, etc.).
[0033] Please refer to Figure 1 The schematic flowchart of a method for determining the ridge range of crops provided by the embodiment of the present application is shown. The method for determining the ridge range of crops provided by the embodiment of the present application can be applied to an electronic device. The electronic device can include physical devices such as a server, a PC, a tablet computer, or a smart phone, or can also be a virtual device such as a virtual machine or a container. The electronic device can be a single device, or a combination of multiple devices or a cluster of a large number of devices. The method for determining the ridge range of crops can include:
[0034] Step S110: Obtain an image to be detected; the image to be detected includes at least one ridge of crops.
[0035] Step S120: Segment the image to be detected according to at least one ridge of crops to obtain a segmented region image; the segmented region image represents the region of a ridge of crops in the image to be detected.
[0036] Step S130: Calculate the confidence of the segmented region image to obtain the confidence data of the segmented region image; the confidence data indicates the degree of consistency of the segmented region image as the crop range.
[0037] Step S140: Determine the ridge range of crops based on the confidence data.
[0038] In step S110, cameras installed on agricultural vehicles or drones can be used to capture images in real time. These cameras can be RGB cameras, multispectral cameras, or thermal imaging cameras, and the specific selection can depend on the application scenario and requirements.
[0039] If the image to be detected is from a video stream, a single frame image needs to be extracted from the video for processing. Frames can be extracted by setting a fixed time interval (such as extracting one frame per second) or based on preset events (such as entering a new operation area, or a change in the shooting angle, etc.) as the image to be detected.
[0040] In an agricultural scenario, "ridge" and "row" are terms used to describe the crop planting layout. A ridge refers to a long strip of earthen ridge artificially created in a farmland for growing crops, used to distinguish different planting areas. Crops can include agricultural crops, gardens, flowers, traditional Chinese medicinal materials, and so on. The image to be detected includes at least one ridge of crops, and one ridge of crops includes one row or multiple rows of crops.
[0041] As an implementation, after obtaining the image to be detected, the image can also be preprocessed. For example, the image can be corrected, including removing distortion, adjusting brightness and contrast, to improve the image quality; and normalization: normalizing the pixel values of the image to a fixed range (such as [0,1]) for subsequent processing.
[0042] In step S120, a deep learning model (such as U-Net, DeepLab, etc.) is used for image segmentation. These models can classify each pixel in the image into different categories (such as crops, land, weeds, etc.). The segmentation model is trained using labeled image data. The labeled data needs to clearly mark areas such as crops and land. A suitable loss function (such as cross-entropy loss or Dice loss) and optimizer (such as Adam) are selected. The preprocessed image is input into the trained segmentation model, and the segmentation result is output. The segmentation result can be a mask, where the value of each pixel represents its category. The area representing the crops is extracted from the segmentation mask. Methods such as connected component analysis or contour detection can be used to extract independent crop row areas.
[0043] In step S130, considering that in actual operations, the height of the confidence data is intuitively reflected in the following phenomena: few or no breaks in the crop rows, few or no adhesions in the crop rows, as many effective pixels as possible in the segmentation result of the crop rows, not particularly drastic changes in the front and back of the crop rows, as slow and continuous as possible, and the segmentation result of the crop rows being smooth enough, etc. It can be seen that aspects such as the continuity degree of pixel points, the change degree between adjacent frames, and the dispersion degree of pixels affect the value of the confidence. That is, the confidence calculation includes calculations based on the continuity degree of pixel points, the change degree between adjacent frames, and the dispersion degree of pixels. Among them, the continuity degree of pixel points is used to measure the continuity of the edge points or center points of the crop rows. The change degree between adjacent frames is used to measure the stability of the segmentation results in consecutive frames. The dispersion degree of pixels is used to measure the distance distribution between the edge points or center points and the corresponding fitted lines.
[0044] The continuity degree of pixel points, the change degree between adjacent frames, and the dispersion degree of pixels can be calculated and processed, such as by weighted summation, average method, minimum / maximum value method, exponential weighting method, or machine learning method, etc., to obtain the confidence data of the segmented region image. The confidence data can be classified as high, medium, or low, etc., or it can also be a numerical value. The larger the numerical value, the higher the confidence data.
[0045] For each segmented region image, the corresponding confidence data can be calculated. The confidence data indicates the degree of consistency of the segmented region image as the crop range. The confidence data helps to determine whether the segmented region accurately represents the ridge range of the crop. For example, a segmentation result with high confidence can be directly used to determine the ridge range, while a result with low confidence may require further processing or verification.
[0046] In step S140, based on the confidence data, the ridge range of the crop is determined. For example, high confidence indicates that the segmented region image very accurately represents the ridge range of the crop. It can be further explained that the edge of the segmented region image is smooth, continuous, and highly consistent with the actual crop region. It is suitable for direct use in agricultural operations, such as agricultural machinery navigation, crop monitoring, etc.
[0047] Medium confidence indicates that the segmented region image has a certain degree of accuracy, but there may be some errors (such as uneven edges, missing or redundant parts in some regions). For medium confidence, other information (such as historical data, multi-frame images) can be combined for further verification or adjustment.
[0048] Low confidence indicates that the segmented region image may not accurately represent the ridge range of the crop, and there is a high possibility that there are large errors in the segmented region image, such as blurred edges, breaks, adhesions, or large deviations from the actual crop region. For the segmented region image with low confidence, further processing is required, such as manual intervention and active investigation.
[0049] In an optional embodiment, confidence data can be used to dynamically adjust operation parameters, such as the traveling speed and steering angle of agricultural machinery, to ensure the accuracy and safety of operations.
[0050] In the above implementation process, through image segmentation and confidence evaluation, the ridge range of crops can be accurately determined, providing reliable support for agricultural automation operations. By determining the ridge range of crops, agricultural machinery or drones can travel precisely along the crop rows, reducing deviation and collision. Automatically determining the crop range reduces the dependence on manual labor, especially in large-scale farms, significantly reducing labor costs. Through confidence evaluation, the accuracy of crop range determination is improved, thus enabling dynamic adjustment of operation strategies in complex environments (such as light changes, shadows, etc.).
[0051] Optionally, in the embodiments of the present application, confidence calculation includes calculating based on the continuity of pixel points, the change degree between adjacent frames, and the dispersion degree of pixels; calculating the confidence of the segmented region image to obtain the confidence data of the segmented region image, including:
[0052] Calculating the continuity of pixel points, the change degree between adjacent frames, and the dispersion degree of pixels of the segmented region image.
[0053] The continuity of pixel points measures the coherence of pixel points within the segmented region, that is, whether the edge of the segmented region is smooth, whether there are breaks or burrs. The calculation method is, for example: using an edge detection algorithm (such as the Canny algorithm) to extract the edge of the segmented region; then performing connected component analysis: calculating the number and proportion of connected pixels within the segmented region through connected component analysis; calculating the proportion of connected pixels, the higher the proportion, the higher the continuity.
[0054] The change degree between adjacent frames measures the stability of the segmented region between consecutive frames. The calculation method is, for example: calculating the intersection over union (IoU) between the current frame and the segmentation result of the previous frame; the higher the IoU value, the smaller the change degree, and the more stable the segmentation result.
[0055] The dispersion degree of pixels measures the deviation degree of the edge points of the segmented region from the ideal fitting curve (or straight line). The calculation method is, for example: fitting a curve, fitting a straight line or curve to the edge points of the segmented region; calculating the error, calculating the perpendicular distance from each edge point to the fitting curve; evaluating the dispersion degree, calculating the standard deviation of these distances, the smaller the standard deviation, the lower the dispersion degree.
[0056] Calculate and process the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels to obtain the confidence data of the segmented region image; the calculation and processing include weighted summation, average method, minimum / maximum value method, exponential weighting method, or machine learning method.
[0057] For weighted summation, for example: Confidence = ω1 × continuity degree of pixel points + ω2 × change degree between adjacent frames + ω3 × discreteness degree of pixels. Among them, ω1 is the weight of the continuity degree of pixel points, ω2 is the weight of the change degree between adjacent frames, and ω3 is the weight of the discreteness degree of pixels. The sum of ω1, ω2, and ω3 can be 1, and the values can be set according to actual needs. The values of ω1, ω2, and ω3 can be the same or different.
[0058] Minimum value method: Confidence = min(continuity degree of pixel points, change degree between adjacent frames, discreteness degree of pixels).
[0059] Maximum value method: Confidence = max(continuity degree of pixel points, change degree between adjacent frames, discreteness degree of pixels).
[0060] Exponential weighting method: Confidence = α × e β×像素点连续程度 + γ × e δ×相邻帧变化程度 + ∈ × eζ×像素离散程度 . Among them, α, γ, and ∈ are the weights of the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels respectively, and β, δ, and ζ represent the exponential coefficients of the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels respectively.
[0061] Machine learning method: Collect feature data related to the segmented region image, including the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels, and collect the confidence data corresponding to the input features. These data can be manually labeled or generated by other methods (such as expert systems). Preprocessing such as normalization or data partitioning can be performed on the input data. Select machine learning models, including random forest, support vector machine, neural network, or linear regression models. Use the training set data to train the selected machine learning model. Adjust the hyperparameters of the model through methods such as cross-validation to obtain the best performance, and the performance of the model can also be evaluated on the validation set to select the model with the optimal performance. For random forest and support vector machine, the hyperparameters can also be adjusted.
[0062] In practical applications, use the continuity degree of pixel points, the change degree between adjacent frames, and the discreteness degree of pixels of the new segmented region image as input features, input them into the trained model, and the model outputs the corresponding confidence data.
[0063] In the implementation process of the above embodiments: By comprehensively considering the continuity of pixel points, the change degree between adjacent frames, and the pixel dispersion degree, the accuracy of the segmented region image can be evaluated more comprehensively, reducing misjudgments caused by the limitations of a single indicator and improving the robustness of the model. Through various computational processes, confidence data of the segmented region image is obtained, which can adapt to different agricultural scenarios and crop types, improving the accuracy of crop range determination.
[0064] Optionally, in the embodiments of the present application, calculating the confidence of the segmented region image to obtain the continuity of pixel points in the segmented region image includes:
[0065] Determine the unconnected crop regions within a preset range in the segmented region image; count the number of pixels in the unconnected crop regions to obtain the number of effective pixel points. The segmented region image is extracted from the image to be detected through an image segmentation algorithm (such as a deep learning model) and represents the region of a ridge of crops.
[0066] Image processing techniques (such as connected component analysis) can be used to identify the unconnected crop regions within the segmented region. The unconnected crop regions refer to the regions in the segmented region image that are not connected to other segmented region images. For example, if any part of a segmented region image is not connected to any other segmented region image, the entire segmented region image is determined as an unconnected crop region; if a certain part of segmented region image A (such as the pixels in the middle region) is connected to any other segmented region image B, then the region of segmented region image A excluding the connected part (the pixels in the middle region) is used as the unconnected crop region.
[0067] For each unconnected crop region, count the number of pixels therein. These pixel counts represent the number of effective pixel points, that is, the pixel points that actually belong to the crops within the segmented region. Accumulate the number of pixels in all unconnected crop regions to obtain the total number of effective pixel points.
[0068] Obtain the continuity of pixel points according to the ratio of the number of effective pixel points to the total number of pixel points in the segmented region image. Use the ratio of the number of effective pixel points to the total number of pixel points as the continuity of pixel points. The higher the ratio, the more continuous the pixel points in the segmented region and the higher the quality of the segmentation result.
[0069] In the implementation process of the above embodiments: By counting the number of effective pixel points in the unconnected crop regions of the segmented region image and calculating its ratio to the total number of pixel points, the continuity of pixel points is quantified. This method can not only accurately evaluate the quality of the segmentation result but also provide a reliable basis for subsequent agricultural automation operations, improving the decision-making reliability and real-time performance of the system.
[0070] Optionally, in the embodiments of the present application, the image to be detected is a video frame in a video to be detected; calculating the confidence of the segmented region image to obtain the degree of change between adjacent frames of the segmented region image, including:
[0071] Obtain adjacent frames in the video corresponding to the image to be detected from the video to be detected; the adjacent frames include a plurality of segmented regions segmented according to the crops in the adjacent frames. As an implementation manner, the current frame in the video to be detected can be used as the image to be detected, and the previous frame or the next frame of the current frame can be used as the adjacent frame in the video corresponding to the image to be detected. Among them, if the previous frame is used as the adjacent frame, the image to be detected is the second frame and subsequent video frames, because the first frame has no previous frame in the video frames to be detected.
[0072] For example, if the current frame is the t-th frame, the (t - 1)-th frame or the (t + 1)-th frame can be extracted as the adjacent frame. These adjacent frames have been processed by a segmentation algorithm, and each adjacent frame has obtained a plurality of segmented regions. The segmentation method can be the same as the segmentation method of the image to be detected.
[0073] Determine the target segmented region from the plurality of segmented regions of the adjacent frame according to the identification information of the segmented region image or the position of the segmented region image in the image to be detected.
[0074] Exemplarily, after the image to be detected is segmented, it includes three segmented region images, and the identification information from left to right is A1, B1, and C1 respectively; after the adjacent frame is segmented, it includes three segmented regions, and the identification information in the order from left to right is A0, B0, and C0 respectively. Among them, the segmented region image A1 corresponds to the segmented region A0 as the same ridge of crops; the segmented region image B1 corresponds to the segmented region B0 as the same ridge of crops; the segmented region image C1 corresponds to the segmented region C0 as the same ridge of crops.
[0075] Taking the segmented region image as A1 as an example, according to the identification information, it can be determined that the segmented region A0 is the target segmented region, and subsequent calculations will be based on the segmented region image A1 and the segmented region A0.
[0076] After the image to be detected is segmented, it includes three segmented region images. The positions can be determined respectively according to the coordinates of these three segmented region images in the image to be detected, and the segmented region in the plurality of segmented regions of the adjacent frame with the position closest to the segmented region image is used as the target segmented region. For example, if the current segmented region image represents a ridge of crops in the upper left corner and the leftmost position in the 100th frame. Through the position information, the crop region at the same position in the 99th frame is found as the target segmented region.
[0077] Determine the number of duplicate pixel points in the segmented region image and the target segmented region, and the total number of pixel points in the segmented region image and the target segmented region.
[0078] Perform a pixel - level comparison between the current segmented region image and the target segmented region to determine the number of overlapping pixel points. Overlapping pixel points refer to pixel points that are 1 (or are in the crop region) in both the current segmented region and the target segmented region. Calculate the total number of pixel points in the current segmented region image and the target segmented region. This can be obtained by adding the number of pixel points in the two regions.
[0079] Obtain the degree of change between adjacent frames of the segmented region image based on the ratio of the number of overlapping pixel points to the total number of pixel points.
[0080] Use the ratio of the number of overlapping pixel points to the total number of pixel points to measure the degree of change between adjacent frames. The higher the ratio, the more stable the segmentation result is between adjacent frames, and the smaller the degree of change.
[0081] In the implementation process of the above - mentioned embodiment: By calculating the degree of change between adjacent frames, the stability of the segmentation result in the time series can be quantified, which helps to evaluate the accuracy of the segmented region image. If the degree of change between adjacent frames is low, it indicates that the segmentation result is unstable, and the system can dynamically adjust the parameters of the segmentation algorithm or trigger manual intervention. The degree of change between adjacent frames provides important time - dimension information for confidence calculation, making the confidence evaluation more comprehensive and reliable. And by comparing the segmentation results of adjacent frames, the existing segmentation information can be directly utilized, reducing repeated calculations.
[0082] Optionally, in the embodiments of the present application, the pixel dispersion degree includes edge dispersion degree and / or central dispersion degree; the edge dispersion degree measures the deviation degree of the edge pixel points of the segmented region relative to the ideal edge (such as a fitted straight line or curve), reflecting the smoothness or regularity of the edge of the segmented region. The central dispersion degree measures the deviation degree of the central pixel points of the segmented region relative to the ideal central line (such as a fitted straight line or curve), reflecting the regularity or consistency of the central part of the segmented region.
[0083] Perform confidence calculation on the segmented region image to obtain the pixel dispersion degree of the segmented region image, including:
[0084] Generate a first fitted line based on the edge pixel points of the segmented region image. For example, use an edge detection algorithm (such as Canny edge detection, Sobel operator, etc.) to extract edge pixel points from the segmented region image. The edge pixel points represent the contour of the segmented region. A fitting algorithm (such as the least - squares method, RANSAC, etc.) can be used to fit the edge pixel points to generate a fitted line representing the edge contour. The fitted line can be a straight line or a curve, depending on the shape of the segmented region.
[0085] According to the distances from the edge pixels of the segmented region image to the first fitted line, obtain the edge dispersion degree of the segmented region image. For each edge pixel (xi, yi), calculate its distance di to the fitted line, which can be calculated using the distance formula. For example, if the fitted line is a straight line y = ax + b, the distance formula is:
[0086]
[0087] Calculate the mean μ and standard deviation σ of all the distances. The edge dispersion degree can be measured by the standard deviation σ. The smaller the standard deviation, the closer the edge pixels are to the fitted line, and the smoother the edge of the segmented region.
[0088] And / or, generate a second fitted line according to the central pixels of the segmented region image; obtain the central dispersion degree of the segmented region image according to the distances from the central pixels of the segmented region image to the second fitted line.
[0089] For example, extract the central pixels of the segmented region image. These points can be the geometric center of the segmented region or the central region defined by a certain rule. The central pixels can be determined by calculating the centroid of the segmented region. Use a fitting algorithm (such as the least squares method) to fit the central pixels to generate a fitted line representing the central region. For each central pixel (xi, yi), calculate its distance di to the fitted line, which can be calculated using the distance formula. Then, the mean μ and standard deviation σ of all the distances can be calculated. The central dispersion degree can be measured by the standard deviation σ. The smaller the standard deviation, the closer the central pixels are to the fitted line, and the more regular the center of the segmented region.
[0090] In the implementation process of the above embodiments: by evaluating the dispersion degrees of the edge pixels and the central pixels, quantify the smoothness of the segmented region. A smooth edge usually indicates a more accurate segmentation result. Combining the edge dispersion degree and the central dispersion degree can evaluate the quality of the segmentation result from multiple dimensions, making the confidence calculation more comprehensive.
[0091] Optionally, in the embodiments of the present application, segment the to-be-detected image according to at least one ridge of crops to obtain a segmented region image, including: input the to-be-detected image into a pre-trained segmentation model to obtain the segmented region image.
[0092] As an implementation manner, before inputting the to-be-detected image into the segmentation model, it can be preprocessed to improve the quality of the image and make it meet the requirements of the model. The preprocessing can include: size adjustment: adjust the image to the size required for model input. Normalization: normalize the pixel values to a specific range (such as [0, 1] or [-1, 1]). Denoising: remove the noise in the image to improve the image quality.
[0093] Input the pre - processed image to be detected into a pre - trained segmentation model. The segmentation model will output a segmentation result, usually a mask of the same size as the input image, where the value of each pixel represents its category (such as crops, background, etc.). Extract the segmented region image according to the segmentation mask. The segmented region image represents one or more ridges of crops in the image to be detected. Independent segmented regions can be extracted from the segmentation mask by methods such as threshold processing or connected component analysis.
[0094] Exemplarily, the size of the image to be detected is 512×512 pixels. After pre - processing, it is input into the segmentation model. The segmentation model outputs a mask of the same size, where the pixel values are 0 (background) and 1 (crops). The segmented region image is extracted through threshold processing, representing one or more ridges of crops.
[0095] The training process of the segmentation model includes:
[0096] Collect image data containing crops. These images can be from farmlands, drone shots, or other sources. Perform category labeling on the pixel points in the collected crop images to obtain an annotated image. For example, for each pixel point in the image, category labeling can be performed using annotation tools (such as LabelMe, CVAT, etc.). The labeled categories can include: Crops: Pixel points representing crop regions. Background: Pixel points representing non - crop regions. Other categories: Such as weeds, roads, etc., depending on the application scenario. After annotation, an annotated image is generated, where the value of each pixel represents its category. The annotated image can be a mask of the same size as the original image, with pixel values being category labels.
[0097] Pre - process the annotated image to obtain a pre - processed annotated image; use the pre - processed annotated image to train a preset model to obtain a segmentation model. The annotated image can be adjusted to the same size as the input size of the preset model. For example, if the model input size is 256×256, the annotated image needs to be adjusted to this size. The pixel values of the annotated image can be normalized to a specific range (such as [0,1]) to improve the efficiency and stability of model training. To improve the generalization ability of the model, data augmentation operations such as rotation, flipping, and cropping can be performed on the annotated image.
[0098] Select a deep learning model suitable for image segmentation tasks, such as U-Net, DeepLab, PSPNet, etc. Divide the preprocessed labeled images into a training set, a validation set, and a test set. Use the training set data to train the preset model and optimize the model's parameters. Select appropriate loss functions (such as cross-entropy loss, Dice loss) and optimizers (such as Adam, SGD). During training, use the validation set data for hyperparameter tuning to obtain the best performance. Use the test set data to evaluate the model's performance. Commonly used performance metrics include accuracy, intersection over union, or Dice coefficient. After training is completed, save the model's parameters for subsequent use.
[0099] In the implementation process of the above embodiment: By classifying the pixel points in the image, high-quality labeled images are generated, providing accurate supervision signals for model training. Through preprocessing and data augmentation of the labeled images, the generalization ability of the model is improved, enabling it to be more accurate under different environmental conditions. Select a lightweight model suitable for edge devices (such as U-Net), which can operate efficiently in resource-constrained environments.
[0100] Optionally, in the embodiment of the present application, the image to be detected includes video frames in images or videos captured by an agricultural vehicle or a drone during operation; after obtaining the confidence data of the segmented region image, the method further includes: adjusting the driving direction of the agricultural vehicle or the drone according to the confidence data; and / or sending the confidence data to the client.
[0101] The segmentation results can be divided into three levels: high, medium, and low according to the confidence value. For example, high confidence: confidence ≥ 0.8; medium confidence: 0.5 ≤ confidence < 0.8; low confidence: confidence < 0.5. For high confidence, the driving direction can be directly adjusted according to the segmentation results to make the agricultural vehicle or the drone travel along the center line of the crop row. For medium confidence, cautious adjustment can be made in combination with historical data or preset rules, and the driving speed can be appropriately reduced. For low confidence, the automatic driving can be paused, switched to manual mode, or wait for manual intervention.
[0102] Exemplarily, assume that the confidence of the current frame is 0.85, which belongs to high confidence. Calculate the deviation angle of the center line of the crop row based on the segmented region image and adjust the driving direction of the agricultural vehicle to make it travel along the center line. Of course, it can also be based on other
[0103] Send confidence data to the client: Format the confidence data into a format suitable for transmission, such as JSON or binary format. Send the confidence data to the client, which can be the monitoring device of the operator, the server, or other management systems. The client receives the confidence data and displays it on the operation interface. The operator can monitor the operation process based on the confidence data and perform manual intervention if necessary.
[0104] In the implementation process of the above embodiments: Through image segmentation and confidence evaluation, the ridge range of crops can be accurately determined, and the driving direction of the agricultural vehicle or drone can be dynamically adjusted according to the confidence data. At the same time, the confidence data is sent to the client to provide real-time feedback and monitoring functions for the operator. This method not only improves the accuracy and automation level of agricultural operations, but also optimizes resource utilization, enhances the robustness and intelligence level of the system.
[0105] Please refer to Figure 2 the structural schematic diagram of the crop ridge range determination device provided by the embodiments of the present application shown; The embodiments of the present application provide a crop ridge range determination device 200, including:
[0106] An image acquisition module 210, configured to acquire an image to be detected; The image to be detected includes at least one ridge of crops;
[0107] A segmentation module 220, configured to segment the image to be detected according to at least one ridge of crops to obtain a segmented region image; The segmented region image represents the region of one ridge of crops in the image to be detected;
[0108] A confidence calculation module 230, configured to calculate the confidence of the segmented region image to obtain the confidence data of the segmented region image; The confidence data represents the degree of consistency of the segmented region image as the crop range;
[0109] A range determination module 240, configured to determine the ridge range of crops based on the confidence data.
[0110] Optionally, in the embodiments of the present application, for the crop ridge range determination device 200, the confidence calculation includes calculation based on the continuity degree of pixel points, the change degree of adjacent frames, and the discreteness degree of pixels; The confidence calculation module 230 is configured to calculate the continuity degree of pixel points, the change degree of adjacent frames, and the discreteness degree of pixels of the segmented region image; Calculate and process the continuity degree of pixel points, the change degree of adjacent frames, and the discreteness degree of pixels to obtain the confidence data of the segmented region image; The calculation process includes weighted summation, average method, minimum / maximum value method, exponential weighting method, or machine learning method.
[0111] Optionally, in the embodiments of the present application, for the crop row range determination device 200, the confidence calculation module 230 is configured to determine the non - adhered crop areas within a preset range in the segmented area image; count the number of pixels in the non - adhered crop areas to obtain the number of effective pixel points; and obtain the pixel continuity degree according to the ratio of the number of effective pixel points to the total number of pixel points in the segmented area image.
[0112] Optionally, in the embodiments of the present application, for the crop row range determination device 200, the image to be detected is a video frame in a video to be detected; the confidence calculation module 230 is configured to obtain adjacent frames in the video corresponding to the image to be detected from the video to be detected; the adjacent frames include multiple segmented areas segmented according to the crops in the adjacent frames; determine the target segmented area from the multiple segmented areas of the adjacent frames according to the identification information of the segmented area image or the position of the segmented area image in the image to be detected; determine the number of repeated pixel points between the segmented area image and the target segmented area, and the total number of pixel points of the segmented area image and the target segmented area; and obtain the change degree of adjacent frames of the segmented area image according to the ratio of the number of repeated pixel points to the total number of pixel points.
[0113] Optionally, in the embodiments of the present application, for the crop row range determination device 200, the pixel dispersion degree includes edge dispersion degree and / or central dispersion degree; the confidence calculation module 230 is configured to calculate the confidence of the segmented area image to obtain the pixel dispersion degree of the segmented area image, including: generating a first fitting line according to the edge pixel points of the segmented area image; obtaining the edge dispersion degree of the segmented area image according to the distance from the edge pixel points of the segmented area image to the first fitting line; and / or, generating a second fitting line according to the central pixel points of the segmented area image; obtaining the central dispersion degree of the segmented area image according to the distance from the central pixel points of the segmented area image to the second fitting line.
[0114] Optionally, in the embodiments of the present application, for the crop row range determination device 200, the segmentation module 220 is configured to input the image to be detected into a pre - trained segmentation model to obtain a segmented area image; the training process of the segmentation model includes: performing class labeling on the pixel points in the collected crop images to obtain an annotated image; pre - processing the annotated image to obtain a pre - processed annotated image; and training a preset model using the pre - processed annotated image to obtain a segmentation model.
[0115] Optionally, in the embodiments of the present application, for the crop row range determination device 200, the image to be detected includes video frames in images or videos captured by an agricultural vehicle or a drone during operation; it further includes a confidence application module, which is configured to adjust the driving direction of the agricultural vehicle or the drone according to the confidence data; and / or send the confidence data to the client.
[0116] It should be understood that the device corresponds to the above-mentioned crop row range determination method embodiment and can execute the various steps involved in the above-mentioned method embodiment. The specific functions of the device can be found in the above description. To avoid repetition, the detailed description is appropriately omitted here. The device includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the operating system (OS) of the device.
[0117] See also Figure 3 The electronic device 300 provided in the embodiment of the present application includes: a processor 310 and a memory 320, wherein the memory 320 stores machine-readable instructions executable by the processor 310, and when the machine-readable instructions are executed by the processor 310, the above method is executed.
[0118] Figure 3 Each component shown in can be implemented by hardware, software or a combination thereof. The electronic device 300 may be a physical device, such as a server, a PC, etc., or a virtual device, such as a virtual machine, a virtualized container, etc. Moreover, the electronic device 300 is not limited to a single device, but may also be a combination of multiple devices or a cluster consisting of a large number of devices.
[0119] An embodiment of the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above method is executed.
[0120] Among them, the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, disk or optical disk.
[0121] The embodiment of the present application also provides a computer program product, including computer program instructions, which execute the above method when executed by a processor.
[0122] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0123] In addition, in each embodiment of the embodiments of the present application, the various functional modules can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.
[0124] The above description is only an alternative implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the embodiments of the present application can easily think of changes or substitutions, which should all be covered within the protection scope of the embodiments of the present application.
Claims
1. A method for determining the ridge row range of a crop, characterized in that, Including: Obtain an image to be detected; the image to be detected includes at least one ridge of crops; Segment the image to be detected according to the at least one ridge of crops to obtain a segmented region image; the segmented region image represents the region of one ridge of the crops in the image to be detected; Calculate the confidence of the segmented region image to obtain the confidence data of the segmented region image; the confidence data represents the degree of consistency of the segmented region image as the crop range; Determine the ridge range of the crops based on the confidence data.
2. The method according to claim 1, wherein The confidence calculation includes calculation based on the continuity of pixel points, the change degree of adjacent frames, and the discreteness of pixels; calculating the confidence of the segmented region image to obtain the confidence data of the segmented region image includes: Calculate the continuity of pixel points, the change degree of adjacent frames, and the discreteness of pixels of the segmented region image; Perform calculation processing on the continuity of pixel points, the change degree of adjacent frames, and the discreteness of pixels to obtain the confidence data of the segmented region image; the calculation processing includes weighted summation, average method, minimum / maximum value method, exponential weighting method, or machine learning method.
3. The method according to claim 2, characterized in that, Calculating the continuity of pixel points of the segmented region image includes: Determine the unconnected crop regions within a preset range in the segmented region image; count the number of pixels in the unconnected crop regions to obtain the number of effective pixel points; Obtain the continuity of pixel points according to the ratio of the number of effective pixel points to the total number of pixel points in the segmented region image.
4. The method according to claim 2, wherein The image to be detected is a video frame in a video to be detected; calculating the change degree of adjacent frames of the segmented region image includes: Obtain adjacent frames in the video corresponding to the image to be detected from the video to be detected; the adjacent frames include multiple segmented regions segmented according to the crops in the adjacent frames; Determine the target segmented region from the multiple segmented regions of the adjacent frames according to the identification information of the segmented region image or the position of the segmented region image in the image to be detected; Determine the number of repeated pixel points between the segmented region image and the target segmented region, and the total number of pixel points of the segmented region image and the target segmented region; Obtain the change degree of adjacent frames of the segmented region image according to the ratio of the number of repeated pixel points to the total number of pixel points.
5. The method according to claim 2, wherein The pixel discreteness includes edge discreteness and / or center discreteness; Calculating the pixel discreteness of the segmented region image includes: Generate a first fitting line according to the edge pixel points of the segmented region image; obtain the edge discreteness of the segmented region image according to the distance from the edge pixel points of the segmented region image to the first fitting line; And / or, generating a second fitted line according to the central pixel point of the segmented region image; obtaining the central dispersion degree of the segmented region image according to the distance from the central pixel point of the segmented region image to the second fitted line.
6. The method according to claim 1, characterized in that, Segmenting the to-be-detected image according to the at least one ridge of crops to obtain a segmented region image, including: Inputting the to-be-detected image into a pre-trained segmentation model to obtain the segmented region image; the training process of the segmentation model includes: performing class labeling on pixel points in the collected crop images to obtain an annotated image; preprocessing the annotated image to obtain a preprocessed annotated image; using the preprocessed annotated image to train a preset model to obtain the segmentation model.
7. The method according to claim 2, wherein The to-be-detected image includes video frames in images or videos captured by an agricultural vehicle or a drone during operation; after obtaining the confidence data of the segmented region image, the method further includes: Adjusting the driving direction of the agricultural vehicle or the drone according to the confidence data; and / or sending the confidence data to a client.
8. A computer program product, characterized in that, Including computer program instructions, which are executed by a processor when running to perform the method according to any one of claims 1 to 7.
9. An electronic device, characterized in that, Including: A processor and a memory, the memory stores computer program instructions, and the computer program instructions are executed by the processor when running to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Computer program instructions are stored on the computer-readable storage medium, and the computer program instructions are executed by a processor when running to perform the method according to any one of claims 1 to 7.