Rice leaf angle extraction method and device based on rice side view image optimization, equipment and medium
By using an improved dung beetle algorithm and an improved YOLOv8-Pose model, the problems of insufficient adaptive gimbal attitude angle error and rice leaf angle detection accuracy of traditional PID controllers under time-varying disturbances were solved. This enabled high-precision automated detection of rice leaf angle and generation of fertilization suggestions, improving the efficiency and accuracy of field detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SOUTH CHINA AGRICULTURAL UNIVERSITY
- Filing Date
- 2026-02-12
- Publication Date
- 2026-05-29
AI Technical Summary
In existing technologies, traditional PID controllers suffer from cumulative integral term errors under time-varying disturbances, resulting in steady-state errors in the attitude angle of the adaptive gimbal. Furthermore, general target detection and attitude estimation models are inaccurate in key point positioning and computationally redundant when detecting rice leaf angles, making it difficult to achieve large-scale field detection.
An improved dung beetle algorithm is used to dynamically adjust PID control parameters. Combined with real-time data from attitude sensors, a closed-loop compensation control system is designed to optimize the adaptive gimbal attitude. The improved YOLOv8-Pose model is used to enhance the features of rice stems and leaves. The Wing Loss loss function is used to improve the accuracy of key point detection. Combined with the neighborhood-weighted loss function, the precise extraction of the rice leaf angle is achieved.
In complex field environments, it achieves dynamic balance adjustment of adaptive gimbal attitude angle and high-precision detection of rice leaf angle, supports automated and large-scale data collection in the field, generates precise fertilization suggestions, and improves detection efficiency and accuracy.
Smart Images

Figure CN122116136A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of agricultural detection, and in particular to a method for extracting the included angle of rice leaves based on optimized rice side view images, a corresponding device, electronic equipment, and a computer-readable storage medium. Background Technology
[0002] Rice is one of my country's most important food crops, and accurate monitoring of its growth is crucial for improving yield and quality. During rice growth, the leaf angle refers to the angle between the rice leaf and the stem. The size of this angle directly affects photosynthetic efficiency and the rice's growth pattern. A suitable leaf angle increases the area receiving sunlight, thereby enhancing photosynthesis and promoting yield. Nitrogen fertilizer can be used to regulate the rice leaf angle. Traditional methods for detecting rice leaf angles often rely on manual measurement, which is not only inefficient and inaccurate, but also heavily influenced by subjective factors and difficult to implement on a large scale in the field.
[0003] In recent years, with the development of robotics and attitude sensor technologies, information-based field monitoring devices and technologies have been gradually applied to crop monitoring. However, existing field monitoring devices still have shortcomings in monitoring accuracy. Traditional PID controllers suffer from cumulative integral term errors under time-varying disturbances, leading to steady-state errors in the attitude angle of adaptive gimbals. Especially in complex field environments, the stability, accuracy, and adaptability of adaptive gimbals need to be improved. Furthermore, existing image acquisition systems exhibit unstable imaging quality under complex lighting conditions, affecting the accuracy of subsequent image analysis.
[0004] In image analysis, although deep learning technology has been applied in agriculture, general object detection and pose estimation models are often designed for humans or conventional objects. When directly applied to rice leaf angle detection, they suffer from problems such as inaccurate key point localization and computational redundancy. Furthermore, existing methods lack a systematic solution that organically combines stable detection with intelligent analysis, making it difficult to achieve closed-loop management from image acquisition to fertilization decisions.
[0005] In summary, existing technologies have limitations. Traditional PID controllers suffer from cumulative integral errors under time-varying disturbances, leading to steady-state errors in the attitude angle of adaptive gimbals. Furthermore, general target detection and attitude estimation models are often designed for human bodies or conventional objects, and their direct application to rice leaf angle detection results in inaccurate key point positioning and computational redundancy. To address these issues, the applicant has made corresponding explorations. Summary of the Invention
[0006] The purpose of this application is to solve the above problems by providing a method, device, electronic device and computer-readable storage medium for extracting the included angle of rice leaves based on optimized rice side view images.
[0007] To achieve the various objectives of this application, the following technical solution is adopted: A method for extracting the included angle of rice leaves based on optimized rice side view images, proposed to meet one of the purposes of this application, includes: The adaptive gimbal is driven by an attitude sensor to collect angular velocity, angular acceleration and actual attitude angle in real time and transmit them to the control board. The control board calls an improved dung beetle algorithm to dynamically adjust the PID control parameters to generate a closed-loop compensation command to drive the servo actuator to adjust the attitude of the adaptive gimbal, so that the adaptive gimbal maintains the preset observation attitude to collect a side view image of the rice to be detected containing the target rice. Three key point output branches are retained in the backbone network of the first rice key point detection model, and the number of output channels is compressed to 6. Two cascaded RiceFeatureEnhancer modules are embedded in the middle region connecting the P3 and P4 layers of the PANet feature pyramid of the neck network. The Wing Loss loss function is used as the regression loss function to construct the second rice key point detection model. Each RiceFeatureEnhancer module adopts a parallel structure of one spatial attention branch and one channel attention branch. The side view image of the rice to be detected is input into the trained and converged second rice key point detection model to determine the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice. The first difference between the top point and the bottom point of the stem is calculated to determine the stem direction vector; the second difference between the leaf tip point and the top point of the stem is calculated to determine the leaf direction vector; and the leaf angle of the target rice is calculated based on the stem direction vector and the leaf direction vector. Based on the rice leaf angle, the rice leaf angle level of the target experimental plot is determined, and the target fertilization recommendation corresponding to the rice leaf angle level is determined, so as to complete the extraction of the rice leaf angle of the target rice.
[0008] Optionally, the step of dynamically adjusting PID control parameters by calling an improved dung beetle algorithm in the control board to generate closed-loop compensation commands to drive the servo actuator to adjust the adaptive gimbal attitude, so that the adaptive gimbal maintains a preset observation attitude, in order to acquire a side view image of the rice to be detected containing the target rice, includes: The preset improved dung beetle algorithm is invoked in the control board to minimize the attitude angle deviation and control response time of the adaptive gimbal as the optimization objective, so as to determine the optimal PID control parameters, wherein the PID control parameters include the proportional coefficient, integral coefficient and derivative coefficient of the PID controller. Based on the optimal PID control parameters, a closed-loop compensation command is generated. The control board transmits the closed-loop compensation command to the adapter board, which converts it into an executable signal for the servo actuator and outputs it to the servo actuator. The servo actuator outputs a PID correction torque according to the executable signal to drive the adaptive gimbal to adjust its attitude. When the attitude angle deviation between the actual attitude angle of the adaptive gimbal and the preset observed attitude angle meets the preset angle threshold, the attitude sensor secondary calibration mechanism is triggered. The PID control parameters are updated based on the real-time collected angular velocity, angular acceleration and actual attitude angle to perform dynamic balance adjustment. While the adaptive gimbal is stably maintaining a preset observation posture, the imaging device is controlled to acquire a side view image of the rice to be detected, which includes the target rice.
[0009] Optionally, the servo actuator outputs a PID correction torque based on the executable signal to drive the adaptive gimbal to adjust its attitude. When the attitude angle deviation between the actual attitude angle of the adaptive gimbal and the preset observed attitude angle meets a preset angle threshold, a secondary calibration mechanism for the attitude sensor is triggered. This mechanism updates the PID control parameters based on real-time acquired angular velocity, angular acceleration, and the actual attitude angle to perform dynamic balance adjustment. The steps include: Obtain the actual attitude angle, the preset observation attitude angle, and the allowable adjustment time of the adaptive platform, and calculate and determine the attitude angle deviation between the actual attitude angle and the preset observation attitude angle; When the attitude angle deviation meets the preset angle threshold, the attitude sensor secondary calibration mechanism is triggered to calculate the target angular acceleration of the servo actuator. The maximum allowable angular velocity of the adaptive gimbal is determined based on the product of the target angular acceleration and the allowable adjustment time. The improved dung beetle algorithm is called to update the PID control parameters with the goal of minimizing the attitude angle deviation and control response time. Based on the updated PID control parameters, a dynamic balance adjustment command is generated. After being converted into an executable signal for the servo actuator via an adapter board, the servo actuator is driven to output a PID correction torque to adjust the attitude of the adaptive gimbal until the attitude angle deviation is close to zero, so as to perform dynamic balance adjustment.
[0010] Optionally, the step of inputting the side view image of the rice to be detected into a trained and converged second rice key point detection model to determine the stem base point, stem top point, and leaf tip point of the target rice includes: Obtain a side view image of the rice to be detected that contains the target rice; The features of the rice side view image to be detected are enhanced by two cascaded RiceFeatureEnhance modules. In the spatial attention branch of each RiceFeatureEnhance module, the spatial weights of the stem and leaf regions of the target rice are learned by 7×7 convolution. In the channel attention branch, the channel response related to the rice structure is dynamically enhanced by the SE module to strengthen the features of rice stems and leaves. The enhanced rice stem and leaf features are processed by the subsequent network layers of the second rice key point detection model, and the stem bottom point, stem top point, and leaf tip point of the target rice are output.
[0011] Optionally, the step of calculating and determining the included angle of the rice leaves of the target rice based on the stem direction vector and the leaf direction vector includes: Obtain the stem direction vector and leaf direction vector of the target rice; Calculate and determine the first product between the stem direction vector and the leaf direction vector; Calculate and determine the first vector magnitude corresponding to the stem direction vector, calculate and determine the second vector magnitude corresponding to the leaf direction vector, and calculate and determine the second product between the first vector magnitude and the second vector magnitude; A first ratio between the first product and the second product is calculated, and the inverse cosine function value of the first ratio is used to determine the included angle of the rice leaves of the target rice.
[0012] Optionally, the step of determining the rice leaf angle level of the target experimental plot based on the rice leaf angle, and then determining the target fertilization recommendation corresponding to the rice leaf angle level, includes: Obtain the leaf angle of multiple target rice plants in the target test plot, and calculate the average value of the leaf angle of the multiple target rice plants in the target test plot as the representative value of the leaf angle of the target test plot; The representative value of the rice leaf angle is matched to the corresponding rice leaf angle grade, wherein the rice leaf angle grade includes Grade 1 upright, Grade 2 semi-upright, Grade 3 intermediate, Grade 4 semi-spreading, and Grade 5 spreading. Based on the matched rice leaf angle level, the preset correspondence between the rice leaf angle level and the target fertilization recommendation is retrieved to determine the target fertilization recommendation corresponding to the target experimental plot. The target fertilization recommendation includes relevant control content on nitrogen fertilizer application rate, potassium fertilizer and silicon fertilizer application requirements.
[0013] Optionally, the basic network architecture of the first rice key point detection model is the original YOLOv8-Pose model; the basic network architecture of the second rice key point detection model is the improved YOLOv8-Pose model. The rice leaf angle refers to the angle formed between the rice leaf and the rice stem, and its size directly reflects the degree of spreading and uprightness of the rice plant.
[0014] A rice leaf angle extraction device based on rice side view image optimization, provided for another purpose of this application, includes: The image acquisition module is configured to drive the adaptive gimbal to collect angular velocity, angular acceleration and actual attitude angle in real time through the attitude sensor and transmit them to the control board. In the control board, the improved dung beetle algorithm is called to dynamically adjust the PID control parameters to generate closed-loop compensation commands to drive the servo actuator to adjust the attitude of the adaptive gimbal, so that the adaptive gimbal maintains the preset observation attitude to acquire a side view image of the rice to be detected containing the target rice. The detection model construction module is set to retain 3 key point output branches in the backbone network of the first rice key point detection model and compress the number of output channels to 6. The middle region connecting the P3 and P4 layers of the PANet feature pyramid of the neck network is embedded into two cascaded RiceFeatureEnhancer modules. The Wing Loss loss function is used as the regression loss function to construct the second rice key point detection model. Each RiceFeatureEnhancer module adopts a parallel structure of one spatial attention branch and one channel attention branch. The rice key point detection module is configured to input the side view image of the rice to be detected into a trained and converged second rice key point detection model to determine the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice. The leaf angle calculation module is configured to calculate and determine the first difference between the top point of the stem and the bottom point of the stem to determine the stem direction vector, calculate and determine the second difference between the leaf tip point and the top point of the stem to determine the leaf direction vector, and calculate and determine the leaf angle of the target rice based on the stem direction vector and the leaf direction vector. The fertilization strategy determination module is set to determine the rice leaf angle level of the target experimental plot based on the rice leaf angle, so as to determine the target fertilization recommendation corresponding to the rice leaf angle level, thereby completing the extraction of the rice leaf angle of the target rice.
[0015] An electronic device provided for another purpose of this application includes a central processing unit and a memory, the central processing unit being configured to invoke and run a computer program stored in the memory to perform the steps of the rice leaf angle extraction method based on rice side view images optimized according to this application.
[0016] A computer-readable storage medium is provided for another purpose of this application, which stores, in the form of computer-readable instructions, a computer program implemented according to the method for extracting the included angle of rice leaves based on the rice side view image, which, when called by a computer, performs the steps included in the corresponding method.
[0017] Compared to existing technologies, this application addresses the problems of accumulated integral term error in traditional PID controllers under time-varying disturbances, leading to steady-state error in the adaptive gimbal attitude angle, and the issues of inaccurate key point localization and computational redundancy when general target detection and attitude estimation models are often designed for human bodies or conventional objects and directly applied to rice leaf angle detection. This application includes, but is not limited to, the following beneficial effects: Firstly, addressing the issues of "traditional PID controllers accumulating integral term errors under time-varying disturbances, adaptive gimbals exhibiting steady-state errors, and poor stability, accuracy, and adaptability in complex field environments," this application uses attitude sensors to collect gimbal angular velocity, angular acceleration, and attitude angle data in real time. It then dynamically optimizes PID control parameters using an improved dung beetle algorithm and designs a secondary calibration mechanism and closed-loop compensation control to achieve adaptive compensation and dynamic balance adjustment of gimbal attitude angle errors, controlling the attitude angle error within ±1°. Simultaneously, by calculating servo motor motion parameters and constraining the maximum angular velocity, it ensures smooth gimbal reset, effectively solving the gimbal offset problem caused by field bumps and mechanical vibrations, and improving the stability and accuracy of phenotypic data acquisition in complex farmland environments.
[0018] Secondly, since general object detection and pose estimation models are often designed for human bodies or conventional objects, their direct application to rice leaf angle detection suffers from problems such as inaccurate key point localization and computational redundancy. This application addresses these issues by improving the YOLOv8-Pose model, simplifying the original YOLOv8-Pose model to output three core rice key points, removing redundant branches, and reducing computational load. A dual-attention parallel RiceFeatureEnhancer module is embedded in the Neck layer to enhance rice stem and leaf features and suppress field background interference. The Wing Loss function combined with a domain-weighted loss function is used to significantly improve the robustness of localization at key locations such as the bottom of the stem, the top of the stem, and the tip of the leaf, thereby significantly improving the accuracy of rice key point detection.
[0019] Thirdly, the adaptive gimbal control system ensures that the imaging equipment is always in the optimal observation posture in complex fields, and collects high-quality rice side view images; then, the optimized deep learning model accurately extracts key points and calculates the leaf angle of the target rice; finally, based on the national standard's five-level classification of leaf angle, the system intelligently analyzes the leaf angle level of rice in the experimental area and generates targeted nitrogen fertilizer application suggestions, realizing integrated closed-loop management from field data collection to agricultural production decision-making.
[0020] Fourth, addressing the problem that "traditional rice leaf angle detection relies on manual measurement, resulting in low efficiency and accuracy, significant subjective influence, and difficulty in large-scale field detection," the system in this application is mounted on a mobile platform, possesses multi-terrain adaptability, and can achieve automated and large-scale data collection in the field. Simultaneously, image acquisition, processing, analysis, and decision generation are all integrated into the control board, enabling real-time processing at the edge, greatly shortening inference latency and significantly improving detection efficiency. Furthermore, the fully automated operation avoids subjective errors from manual measurement, providing a feasible technical solution for the precision management of large-scale farmland. Attached Figure Description
[0021] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a system architecture diagram of the rice leaf angle extraction system in the embodiments of this application; Figure 2 This is a hardware architecture diagram of the rice leaf angle extraction system in the embodiments of this application; Figure 3 This is a flowchart illustrating the method for extracting the included angle of rice leaves based on optimized rice side view images in this application embodiment; Figure 4 This is a flowchart of the improved dung beetle algorithm module in an embodiment of this application; Figure 5 This is an exemplary network architecture for the improved YOLOv8-Pose model in the embodiments of this application; Figure 6 This is an exemplary network architecture for the RiceFeatureEnhancer module in the embodiments of this application; Figure 7 This is a schematic diagram illustrating the annotation of key points on rice in an embodiment of this application; Figure 8 This is a schematic diagram of the principle of the rice leaf angle extraction device based on rice side view image optimization in the embodiments of this application; Figure 9 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation
[0022] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0023] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.
[0024] Those skilled in the art will understand that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0025] Those skilled in the art will understand that the terms "client," "terminal," and "terminal device" as used herein include both devices that receive wireless signals, devices that only possess wireless signal receiver capabilities without transmission capabilities, and devices with receiving and transmitting hardware, devices that have receiving and transmitting hardware capable of bidirectional communication over a bidirectional communication link. Such devices may include: cellular or other communication devices such as personal computers or tablets, having single-line displays, multi-line displays, or cellular or other communication devices without multi-line displays; PCS (Personal Communications Service) that can combine voice, data processing, fax, and / or data communication capabilities; PDAs (Personal Digital Assistants) that may include radio frequency receivers, pagers, internet / intranet access, web browsers, notebooks, calendars, and / or GPS (Global Positioning System) receivers; and conventional laptops and / or handheld computers or other devices that have and / or include radio frequency receivers. As used herein, "client," "terminal," and "terminal device" can be portable, transportable, installed in a means of transportation (air, sea, and / or land), or suitable and / or configured to operate locally and / or in a distributed manner, operating in any other location on Earth and / or in space. "Client," "terminal," and "terminal device" as used herein can also be a communication terminal, an internet access terminal, or a music / video playback terminal, such as a PDA, a MID (Mobile Internet Device), and / or a mobile phone with music / video playback capabilities, or a smart TV, set-top box, etc.
[0026] The hardware referred to by the names "server," "client," and "service node" in this application is essentially an electronic device with the equivalent capabilities of a personal computer. It is a hardware device with the necessary components revealed by the von Neumann architecture, such as a central processing unit (including an arithmetic logic unit and a control unit), memory, input devices, and output devices. The computer program is stored in its memory, and the central processing unit loads the program stored in the secondary storage into the main memory to run it, execute the instructions in the program, and interact with the input and output devices to complete specific functions.
[0027] It should be noted that the concept of "server" used in this application can also be extended to the case of server clusters. Based on the network deployment principles understood by those skilled in the art, the servers should be logically divided. Physically, these servers can be independent of each other but accessible through interfaces, or they can be integrated into a single physical computer or a computer cluster. Those skilled in the art should understand this flexibility and should not use it to constrain the implementation of the network deployment method in this application.
[0028] One or more of the technical features of this application, unless explicitly specified herein, can be deployed on a server and accessed by a client remotely calling the online service interface provided by the server, or can be directly deployed and run on a client for access.
[0029] Unless otherwise specified, the neural network models referenced or potentially referenced in this application may be deployed on a remote server and invoked remotely on the client, or deployed on a client with the capability to invoke directly. In some embodiments, when running on the client, the corresponding intelligence may be acquired through transfer learning in order to reduce the requirements on the client's hardware resources and avoid excessive consumption of the client's hardware resources.
[0030] Unless otherwise specified, all data involved in this application may be stored remotely on a server or on a local terminal device, as long as it is suitable for use by the technical solution of this application.
[0031] Those skilled in the art will understand that although the various methods in this application are described based on the same concept and thus present commonality among them, they can be performed independently unless otherwise specified. Similarly, the various embodiments disclosed in this application are all based on the same inventive concept; therefore, concepts expressed in the same way, as well as concepts that are appropriately changed for convenience but are expressed differently, should be understood equivalently.
[0032] Unless otherwise expressly stated, the various embodiments disclosed in this application can be combined in a cross-cutting manner to flexibly construct new embodiments, as long as such combination does not depart from the inventive spirit of this application and can meet the needs of the prior art or solve a certain deficiency in the prior art. Those skilled in the art should be aware of such modifications.
[0033] Please see Figure 1 as well as Figure 2The rice leaf angle extraction method based on optimized rice side view images of this application can be implemented based on a rice leaf angle extraction system 100, which includes a control board 110, an adapter board 120, a servo actuator 130, an adaptive gimbal 140, an imaging device 150, and an attitude sensor 160. The control board 110 is electrically connected to the adapter board 120 and is used to convert control signals into drive signals adapted to the servo actuator. The adapter board 120 is electrically connected to the servo actuator 130 to drive the servo actuator to rotate. The adaptive gimbal 140 is mechanically coupled to the servo actuator 130 via a rotation axis, and achieves pitch motion under the drive of the servo actuator 130. The imaging device 150 is integrated at the top of the adaptive gimbal 140 and electrically connected to the control board 110, used to acquire rice side view images. The attitude sensor 160 is integrated into the adaptive gimbal 140. The top and sides of the device are electrically connected to the control board 110, and are used to collect the angular velocity, angular acceleration and attitude angle deviation of the adaptive gimbal in real time, and feed the data back to the control board 110. The control board 110 generates a dynamic calibration command based on the received attitude sensor data, and converts it into a PWM control signal that can be resolved by the servo actuator through the adapter board 120. The adapter board 120 further transmits the calibration command to the digital servo actuator 130, driving the adaptive gimbal 140 to adjust its attitude in real time, forming a closed-loop control loop to ensure the dynamic stability of the adaptive gimbal under field disturbances.
[0034] It should be noted that when the adaptive gimbal 140 moves under the drive of the digital servo actuator 130, its actual attitude angle may be affected by mechanical vibration or external interference. It may deviate from the preset observation attitude angle However, the system considers the adaptive gimbal attitude angle to be still [value missing]. This causes the actual attitude angle to differ from the preset observed attitude angle. There is an error between them. If this deviation is not compensated for in real time through a closed-loop feedback mechanism, the attitude angle deviation will increase during continuous operation. The frequency of the disturbance will increase as it accumulates, leading to a shift in the imaging perspective and reducing the reliability of the data collected on crop phenotypic parameters.
[0035] In some embodiments, the attitude sensor 160 is integrated into the top and side of the adaptive gimbal 140 to detect the angular velocity, angular acceleration, and actual attitude angle data of the adaptive gimbal along the x and y axes in real time. When the adaptive gimbal is disturbed and experiences an attitude angle shift, the attitude sensor 160 detects the attitude angle deviation. A calibration trigger signal is generated. After receiving the signal, the control board 110 calls the improved dung beetle algorithm to recalculate the PID control parameters and generates a compensation command to drive the servo actuator 130 to perform closed-loop correction.
[0036] Specifically, the calibration trigger signal can carry the actual attitude angle of the attitude sensor. Or by setting the observation attitude angle Compared with actual attitude angle Deviation between Trigger the compensation mechanism. During calibration on the control board, a dynamic parameter reconstruction method is used: first, the target attitude angle is calculated. Compared with actual attitude angle The deviation amount is then determined according to the allowable adjustment time T using the formula. Solve for angular acceleration, and finally generate the equation containing ω ≤ ω max The constraint conditions drive the adaptive gimbal to reset smoothly. This mechanism achieves high-reliability transmission of attitude sensor data through the I²C protocol. Combined with the command conversion function of the adapter board 120, it shortens the attitude correction response time, controls the attitude angle error within ±1°, and improves the imaging stability in complex farmland environments.
[0037] It is understood that, in the above embodiments, the adaptive gimbal attitude angle data detected by the attitude sensor (including the current attitude angle) Angular velocity ω and angular acceleration All values are absolute measurements, requiring no coordinate system transformation or scaling. The control board performs closed-loop control calculations directly based on the raw data from the attitude sensors, reducing error accumulation in intermediate processing stages.
[0038] Please see Figure 3 In one embodiment of the method for extracting the included angle of rice leaves based on optimized rice side view images, this application includes: Step S10: Drive the adaptive gimbal to collect angular velocity, angular acceleration and actual attitude angle in real time through attitude sensor and transmit them to the control board. In the control board, call the improved dung beetle algorithm to dynamically adjust the PID control parameters to generate closed-loop compensation command to drive the servo actuator to adjust the attitude of the adaptive gimbal so that the adaptive gimbal maintains the preset observation attitude to collect a side view image of the rice to be detected containing the target rice. The rice leaf angle extraction system 100 can drive an adaptive gimbal to collect angular velocity, angular acceleration and actual attitude angle in real time through an attitude sensor and transmit them to the control board. The control board calls an improved dung beetle algorithm to dynamically adjust the PID control parameters to generate a closed-loop compensation command to drive the servo actuator to adjust the attitude of the adaptive gimbal so that the adaptive gimbal maintains the preset observation attitude in order to collect a side view image of the rice to be detected containing the target rice. In some embodiments, the step of dynamically adjusting PID control parameters by calling an improved dung beetle algorithm in the control board to generate closed-loop compensation commands to drive the servo actuator to adjust the adaptive gimbal attitude, so that the adaptive gimbal maintains a preset observation attitude, in order to acquire a side view image of the rice to be detected containing the target rice, includes: Step S101: In the control board, call the preset improved dung beetle algorithm to minimize the attitude angle deviation and control response time of the adaptive gimbal as the optimization objective, so as to determine the optimal PID control parameters, wherein the PID control parameters include the proportional coefficient, integral coefficient and derivative coefficient of the PID controller. Step S102: Generate a closed-loop compensation command based on the optimal PID control parameters. The control board transmits the closed-loop compensation command to the adapter board, which converts it into an executable signal for the servo actuator and outputs it to the servo actuator. Step S103: The servo actuator outputs PID correction torque according to the executable signal to drive the adaptive gimbal to adjust its attitude. When the attitude angle deviation between the actual attitude angle of the adaptive gimbal and the preset observed attitude angle meets the preset angle threshold, the attitude sensor secondary calibration mechanism is triggered. The PID control parameters are updated based on the real-time collected angular velocity, angular acceleration and actual attitude angle to perform dynamic balance adjustment. Step S104: When the adaptive gimbal is stably maintaining the preset observation posture, control the imaging device to acquire a side view image of the rice to be detected containing the target rice.
[0039] Specifically, please refer to Figure 4 The improved dung beetle algorithm module includes: a chaotic initialization module, a hybrid mutation strategy module, and an adaptive weight adjustment module. The chaotic initialization module uses Tent chaotic mapping to generate an initial population, improving the diversity and distribution uniformity of the population. The hybrid mutation strategy module combines Gaussian mutation and differential mutation to balance the algorithm's global exploration capability and local exploitation capability. The adaptive weight adjustment module dynamically adjusts the position update weights according to the number of iterations, realizing adaptive switching of the search strategy.
[0040] The improved dung beetle algorithm uses adaptive gimbal attitude angle deviation and control response time as optimization objectives, and dynamically adjusts the proportional coefficient of the PID controller. Integral coefficient and differential coefficients The objective function of the improved dung beetle algorithm is expressed as: , in, This represents the fitness function value of the improved dung beetle algorithm; The weighting coefficients representing attitude angle deviations; This represents the weighting coefficient that controls the response time. This represents the absolute value of the attitude angle deviation. This refers to the control response time of the adaptive gimbal.
[0041] In this embodiment, the imaging device, through optimized imaging and image processing algorithms, can provide stable imaging quality under complex field lighting conditions. High-quality image data is beneficial for deep learning models to extract structural features of rice. Simultaneously, image compression and optimization processing can improve image transmission and processing efficiency.
[0042] In practical applications, a mobile platform carrying the rice leaf angle acquisition device moves across the field. The control board controls the platform's movement according to a preset path or remote commands. When it reaches the designated detection position, the adaptive gimbal control system activates. The attitude sensor detects the adaptive gimbal's attitude in real time, and the control board optimizes the PID control parameters using an improved dung beetle algorithm, driving the servo actuator to adjust the adaptive gimbal's attitude to the preset observation angle. After the adaptive gimbal stabilizes, the imaging device acquires a side image of the rice, which is then transmitted to the control board for processing.
[0043] The control board runs an improved YOLOv8-Pose model (YOLOv8-Pose-RiceFE lightweight model) to infer the side view image of the rice plant under test, outputting the coordinates of three key points: the bottom of the stem, the top of the stem, and the leaf tip. It calculates the leaf angle of each rice plant through vector operations and calculates the average leaf angle within the experimental plot. Based on the leaf angle classification standard, it determines the leaf angle level of the plot and automatically generates corresponding fertilization suggestions. These suggestions can be transmitted wirelessly to farmers' mobile terminals or agricultural management systems to guide precision fertilization operations.
[0044] In a further embodiment, the servo actuator outputs a PID correction torque based on the executable signal to drive the adaptive gimbal to adjust its attitude. When the attitude angle deviation between the actual attitude angle of the adaptive gimbal and the preset observed attitude angle meets a preset angle threshold, a secondary calibration mechanism for the attitude sensor is triggered. The step of updating the PID control parameters based on the real-time collected angular velocity, angular acceleration, and actual attitude angle to perform dynamic balance adjustment includes: Step S1001: Obtain the actual attitude angle, preset observation attitude angle, and allowable adjustment time of the adaptive platform, and calculate and determine the attitude angle deviation between the actual attitude angle and the preset observation attitude angle; Step S1002: When the attitude angle deviation meets the preset angle threshold, the attitude sensor secondary calibration mechanism is triggered to calculate the target angular acceleration of the servo actuator. The maximum allowable angular velocity of the adaptive gimbal is determined based on the product of the target angular acceleration and the allowable adjustment time. The improved dung beetle algorithm is called to update the PID control parameters with the goal of minimizing the attitude angle deviation and control response time. Step S1003: Generate a dynamic balance adjustment command based on the updated PID control parameters, convert it into an executable signal for the servo actuator via the adapter board, drive the servo actuator to output PID correction torque, adjust the adaptive gimbal attitude until the attitude angle deviation is close to zero, so as to perform dynamic balance adjustment.
[0045] Specifically, the attitude sensor collects the angular velocity, angular acceleration, and actual attitude angle of the adaptive gimbal in real time. The attitude sensor collects data at a preset frequency to ensure real-time performance and accuracy. The angular velocity, angular acceleration, and actual attitude angle reflect the motion state and attitude changes of the adaptive gimbal in space. These data are transmitted to the control board, which uses an improved dung beetle algorithm to dynamically reconstruct the PID control parameters and generate closed-loop compensation commands. The improved dung beetle algorithm combines information from multiple data sources to adapt to different working conditions and load changes, determining the optimal PID control parameters. Based on the closed-loop compensation commands, a proportional-integral-derivative (PID) correction torque is output to the servo actuator via the adapter board, driving the adaptive gimbal to adjust its attitude. The adapter board converts the commands generated by the control board into executable signals for the servo actuator, ensuring the accuracy and stability of the executable signal transmission. The servo actuator adjusts the attitude angle of the adaptive gimbal based on the received PID correction torque to achieve stable acquisition of rice phenotypic data. When the adaptive gimbal recovers to the preset attitude angle threshold, the attitude sensor secondary calibration mechanism is triggered. Based on the real-time angular velocity, angular acceleration, and actual attitude angle, the control parameters are updated to complete the dynamic balance adjustment. The preset attitude angle is pre-set according to the specific application scenario and user needs to ensure that the adaptive gimbal can achieve the best data acquisition effect at this attitude angle. The attitude sensor secondary calibration mechanism is used to eliminate the cumulative errors that may be generated during long-term operation, ensuring the accuracy and reliability of the control system. The imaging device acquires side images of rice in a stable attitude and transmits the images to the control board for processing.
[0046] In some embodiments, the formula for calculating the target angular acceleration of the servo actuator is expressed as: , in, This indicates the target angular acceleration of the servo actuator; Indicates the allowed adjustment time for adaptive gimbal attitude adjustment; This indicates the preset observation attitude angle of the adaptive gimbal; This represents the actual attitude angle of the adaptive gimbal; The formula for calculating the attitude angle deviation between the actual attitude angle and the preset observed attitude angle is expressed as follows: , in, This indicates the attitude angle deviation of the adaptive gimbal; This indicates the preset observation attitude angle of the adaptive gimbal; This represents the actual attitude angle of the adaptive gimbal; The formula for calculating the maximum permissible angular velocity of the adaptive gimbal is as follows: , in, This indicates the target angular acceleration of the servo actuator; Indicates the allowed adjustment time for adaptive gimbal attitude adjustment; This indicates the maximum permissible angular velocity of the adaptive gimbal.
[0047] Step S20: In the backbone network of the first rice key point detection model, three key point output branches are retained and the number of output channels is compressed to six. The middle region connecting the P3 and P4 layers of the PANet feature pyramid of the neck network is embedded into two cascaded RiceFeatureEnhancer modules. The Wing Loss loss function is used as the regression loss function to construct the second rice key point detection model. Each RiceFeatureEnhancer module adopts a parallel structure of one spatial attention branch and one channel attention branch. The adaptive gimbal is driven by an attitude sensor that collects angular velocity, angular acceleration, and actual attitude angle in real time and transmits them to the control board. The control board uses an improved dung beetle algorithm to dynamically adjust PID control parameters, generating closed-loop compensation commands to drive the servo actuator to adjust the adaptive gimbal's attitude, ensuring it maintains a preset observation attitude. After acquiring a side view image of the rice field containing the target rice, the backbone network of the first rice keypoint detection model retains three keypoint output branches, compressing the number of output channels to six. Two cascaded RiceFeatureEnhancer modules are embedded in the middle region connecting the P3 and P4 layers of the PANet feature pyramid in the neck network. A Wing Loss loss function is used as the regression loss function to construct the second rice keypoint detection model. Each RiceFeatureEnhancer module employs a parallel structure of one spatial attention branch and one channel attention branch. The basic network architecture of the first rice keypoint detection model is the original YOLOv8-Pose model; the basic network architecture of the second rice keypoint detection model is an improved YOLOv8-Pose model. Specifically, please refer to Figures 5 to 7 The second rice key point detection model in this application is based on the original YOLOv8-Pose model and undergoes structural redesign. The head network layer, neck network layer and loss function are co-optimized to construct an improved YOLOv8-Pose model, which is named "YOLOv8-Pose-RiceFE Lightweight Model".
[0048] The model follows a three-stage architecture: Backbone-Neck-Head. The Backbone layer uses VanillaBlock units for multi-scale feature extraction, including four stages: VanillaBlock×2, VanillaBlock×4, VanillaBlock×6, and VanillaBlock×8. At the end, an SPPF module is set to achieve rapid fusion of receptive field features at multiple scales: 1×1, 3×3, 5×5, and 7×7. The Neck layer uses the PANet dual-path feature pyramid, and completes top-down semantic fusion and bottom-up detail supplementation through C2PAS, upsampling, and C3K2 modules. Two cascaded RiceFeatureEnhancer modules are embedded in the middle region connecting the P3 and P4 layers. The Head layer uses the FASFFHead structure to output bounding boxes (4D), categories (1D), and rice keypoints (6D) in parallel, realizing the integration of detection and pose estimation.
[0049] The RiceFeatureEnhancer module employs a two-stream attention coupling mechanism: the spatial attention branch performs dual-path aggregation of the feature map using average pooling (AvgPool) and max pooling (MaxPool), and then generates a spatial weight map via a 7×7 convolution. Highlighting the stem and leaf regions; channel attention branches generate channel weights through compression-excitation in a fully connected layer. This enhances feature channels related to rice morphology. Output features are processed via... By weighting elements one by one, the contrast between plant structure and soil background in complex field conditions is effectively improved, and the false detection rate in shaded environments is reduced. This module achieves background suppression and structure enhancement with 0.1M parameters, which increases the response intensity of the stem and leaf area by more than 40%.
[0050] Keypoint output structure optimization to meet the needs of rice leaf angle calculation: In the head network layer, the original 17 human keypoint branches were removed, retaining only 3 rice keypoint outputs, corresponding to the bottom of the stem. Top of stem and leaf tips The output tensor dimension is compressed to [B, 6, H, W], where B represents the number of rice side-view images processed in one operation; H represents the height of the rice side-view image; and W represents the width of the rice side-view image. This modification removes 14 redundant keypoint prediction branches, reduces the number of model parameters from 8.6M to 3.2M, reduces FLOPs to 8.5G, and optimizes the inference latency on the embedded GPU platform to 21.4ms, meeting the requirements for real-time field detection.
[0051] Furthermore, adopt The loss function is used as a regression loss function. A hybrid strategy combining loss function and domain weighting, where, The expression for the loss function is: , in, express Loss function; This indicates the error between the predicted coordinates and the actual coordinates of key points; express The error threshold of the loss function, It can take the value 10; express The smoothing coefficient of the loss function, It can take the value 2; It represents a continuity constant.
[0052] The loss function provides a smooth logarithmic penalty in the small error region to suppress noise interference; in the large error region, it maintains linear growth to accelerate gradient propagation. A domain-weighted strategy sets the total loss. Forced model priority optimization Point positioning accuracy; experiments show that this strategy improves... The point MAE is reduced by 1.8 pixels, and the leaf angle calculation error is reduced by 0.9°.
[0053] In some embodiments, the labeling specification establishes a three-level quality control system: Level 1 requirements The dots must be marked at the actual physical intersection of the stem and the ground, with a marking error ≤ 3 pixels; Level 2 requirement. The point is located at the highest visible node of the stem. The point is located at the tip of the leaf; the third level is cross-validated by two annotators to ensure consistency. The samples were returned for relabeling. This mechanism ensures geometric consistency of the training data, improving labeling accuracy from 82% to 96%.
[0054] In some embodiments, the model training employs a transfer learning strategy: the Backbone loads pre-trained weights from the COCO dataset, the Neck and Head layers are randomly initialized, the Backbone learning rate is frozen at 0.001 for the first 30 epochs, and the entire network is fine-tuned at a learning rate of 0.0001 for the next 120 epochs. The SGD optimizer momentum is 0.937, and weight decay is used. The cosine annealing strategy enabled the model to converge within 150 epochs, and the validation set mAP@0.5 reached 0.914.
[0055] Step S30: Input the side view image of the rice to be detected into the trained and converged second rice key point detection model to determine the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice. In the backbone network of the first rice keypoint detection model, three keypoint output branches are retained, and the number of output channels is compressed to six. Two cascaded RiceFeatureEnhancer modules are embedded in the middle region connecting the P3 and P4 layers of the PANet feature pyramid in the neck network. After constructing the second rice key point detection model, the side view image of the rice to be detected is input into the trained and converged second rice key point detection model to determine the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice. In some embodiments, the step of inputting the side view image of the rice to be detected into a trained and converged second rice key point detection model to determine the stem base point, stem top point, and leaf tip point of the target rice includes: Step S301: Obtain a side view image of the rice to be detected containing the target rice; Step S302: Enhance the features of the rice side view image to be detected through two cascaded RiceFeatureEnhance modules. In the spatial attention branch of each RiceFeatureEnhance module, the spatial weights of the stem and leaf regions of the target rice are learned through 7×7 convolution. In the channel attention branch, the channel response related to the rice structure is dynamically enhanced through the SE module to strengthen the features of the rice stem and leaves. Step S303: The enhanced rice stem features and rice leaf features are processed by the subsequent network layer of the second rice key point detection model, and the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice are output.
[0056] Step S40: Calculate and determine the first difference between the top point of the stem and the bottom point of the stem to determine the stem direction vector; calculate and determine the second difference between the leaf tip point and the top point of the stem to determine the leaf direction vector; calculate and determine the rice leaf angle of the target rice based on the stem direction vector and the leaf direction vector. The side view image of the rice to be detected is input into a trained and converged second rice key point detection model. After determining the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice, the first difference between the top point and the bottom point of the stem is calculated to determine the stem direction vector. The second difference between the tip point and the top point of the stem is calculated to determine the leaf direction vector. The leaf angle of the target rice is calculated based on the stem direction vector and the leaf direction vector. The leaf angle refers to the angle formed between the rice leaf and the rice stem, and its size directly reflects the degree of spreading and uprightness of the rice plant.
[0057] In some embodiments, the step of calculating and determining the rice leaf angle of the target rice based on the stem direction vector and the leaf direction vector includes: Step S401: Obtain the stem direction vector and leaf direction vector of the target rice. Step S402: Calculate and determine the first product between the stem direction vector and the leaf direction vector; Step S403: Calculate and determine the first vector magnitude corresponding to the stem direction vector, calculate and determine the second vector magnitude corresponding to the leaf direction vector, and calculate and determine the second product between the first vector magnitude and the second vector magnitude; Step S404: Calculate and determine the first ratio between the first product and the second product, and determine the rice leaf angle of the target rice based on the inverse cosine function value of the first ratio.
[0058] Specifically, the key point annotation for rice includes three key points: (The bottom point of the stem, located at the actual intersection of the stem and the ground) (The top point of the stem, located at the very top of the stem) and (Leaf tip, located at the end).
[0059] Calculate and determine the first difference between the top point and the bottom point of the stem to determine the stem direction vector, that is... , The stem direction vector is represented; the second difference between the leaf tip and the stem top is calculated to determine the leaf direction vector, i.e., the vector. , This represents the leaf direction vector. The leaf angle of the target rice variety is calculated and determined based on the stem direction vector and the leaf direction vector. The calculation formula is expressed as: ; in, This indicates the angle between the rice leaves of the target rice variety; This represents the two-dimensional pixel coordinates corresponding to the bottom point of the stem; This represents the two-dimensional pixel coordinates corresponding to the top point of the stem; · represents the two-dimensional pixel coordinates corresponding to the leaf tip; · represents the vector dot product operator. This represents the magnitude of the first vector corresponding to the stem direction vector; This represents the magnitude of the second vector corresponding to the blade direction vector.
[0060] Step S50: Determine the rice leaf angle level of the target test plot based on the rice leaf angle, and determine the target fertilization recommendation corresponding to the rice leaf angle level to complete the extraction of the rice leaf angle of the target rice.
[0061] The first difference between the top and bottom points of the stem is calculated to determine the stem direction vector. The second difference between the leaf tip and the top point of the stem is calculated to determine the leaf direction vector. After calculating the leaf angle of the target rice based on the stem direction vector and the leaf direction vector, the leaf angle level of the target experimental plot is determined based on the leaf angle, and the target fertilization recommendation corresponding to the leaf angle level is determined to complete the extraction of the leaf angle of the target rice.
[0062] In some embodiments, the step of determining the rice leaf angle level of the target experimental plot based on the rice leaf angle, and then determining the target fertilization recommendation corresponding to the rice leaf angle level, includes: Step S501: Obtain the leaf angle of multiple target rice plants in the target test plot, and calculate the average value of the leaf angle of the multiple target rice plants in the target test plot as the representative value of the leaf angle of the target test plot. Step S502: Match the representative value of the rice leaf angle to the corresponding rice leaf angle level, wherein the rice leaf angle level includes level 1 upright, level 2 semi-upright, level 3 intermediate, level 4 semi-spreading, and level 5 spreading. Step S503: Based on the matched rice leaf angle level, retrieve the preset correspondence between the rice leaf angle level and the target fertilization recommendation, and determine the target fertilization recommendation corresponding to the target experimental plot. The target fertilization recommendation includes relevant control content on nitrogen fertilizer application rate, potassium fertilizer and silicon fertilizer application requirements.
[0063] Within the target experimental plot, 5 to 10 rice samples can be randomly selected. The average value of the leaf angles of the target rice plants within the target experimental plot is calculated and used as the representative value of the leaf angles of the target experimental plot. The representative value of the leaf angles is then matched to the corresponding leaf angle grades, which include Grade 1 (erect), Grade 2 (semi-erect), Grade 3 (intermediate), Grade 4 (semi-spreading), and Grade 5 (spreading). As shown in Table 1, the leaf angle grades are determined according to the 5-grade classification standard for rice leaf angles, and target fertilization recommendations are generated.
[0064] Table 1. Comparison of Rice Leaf Angle Levels and Nitrogen Fertilizer Application Guidelines It should be noted that the technical solution of this application is not only applicable to rice, but can also be applied to phenotypic detection of other crops such as wheat and corn after appropriate adjustments. Furthermore, the YOLOv8-Pose-RiceFE model and dung beetle algorithm described can also be independently applied to other agricultural detection scenarios, demonstrating good versatility and scalability. Those skilled in the art should understand that the optimization algorithm described in this application is not limited to the improved dung beetle algorithm; particle swarm optimization, genetic algorithms, ant colony optimization, and other intelligent optimization algorithms can also be used to achieve dynamic optimization of PID parameters. The loss function described is not limited to... The loss function can also be other loss functions such as Smooth L1 Loss and Focal Loss to improve the accuracy of key point localization.
[0065] As can be seen from the above embodiments, compared with the prior art, this application addresses the problems of accumulated integral term error in traditional PID controllers under time-varying disturbances, which leads to steady-state error in the adaptive gimbal attitude angle, and the problems of inaccurate key point positioning and computational redundancy when general target detection and attitude estimation models are often designed for human bodies or conventional objects and are directly applied to rice leaf angle detection. This application has, but is not limited to, the following beneficial effects: Firstly, addressing the issues of "traditional PID controllers accumulating integral term errors under time-varying disturbances, adaptive gimbals exhibiting steady-state errors, and poor stability, accuracy, and adaptability in complex field environments," this application uses attitude sensors to collect gimbal angular velocity, angular acceleration, and attitude angle data in real time. It then dynamically optimizes PID control parameters using an improved dung beetle algorithm and designs a secondary calibration mechanism and closed-loop compensation control to achieve adaptive compensation and dynamic balance adjustment of gimbal attitude angle errors, controlling the attitude angle error within ±1°. Simultaneously, by calculating servo motor motion parameters and constraining the maximum angular velocity, it ensures smooth gimbal reset, effectively solving the gimbal offset problem caused by field bumps and mechanical vibrations, and improving the stability and accuracy of phenotypic data acquisition in complex farmland environments.
[0066] Secondly, since general object detection and pose estimation models are often designed for human bodies or conventional objects, their direct application to rice leaf angle detection suffers from problems such as inaccurate key point localization and computational redundancy. This application addresses these issues by improving the YOLOv8-Pose model, simplifying the original YOLOv8-Pose model to output three core rice key points, removing redundant branches, and reducing computational load. A dual-attention parallel RiceFeatureEnhancer module is embedded in the Neck layer to enhance rice stem and leaf features and suppress field background interference. The Wing Loss function combined with a domain-weighted loss function is used to significantly improve the robustness of localization at key locations such as the bottom of the stem, the top of the stem, and the tip of the leaf, thereby significantly improving the accuracy of rice key point detection.
[0067] Thirdly, the adaptive gimbal control system ensures that the imaging equipment is always in the optimal observation posture in complex fields, and collects high-quality rice side view images; then, the optimized deep learning model accurately extracts key points and calculates the leaf angle of the target rice; finally, based on the national standard's five-level classification of leaf angle, the system intelligently analyzes the leaf angle level of rice in the experimental area and generates targeted nitrogen fertilizer application suggestions, realizing integrated closed-loop management from field data collection to agricultural production decision-making.
[0068] Fourth, addressing the problem that "traditional rice leaf angle detection relies on manual measurement, resulting in low efficiency and accuracy, significant subjective influence, and difficulty in large-scale field detection," the system in this application is mounted on a mobile platform, possesses multi-terrain adaptability, and can achieve automated and large-scale data collection in the field. Simultaneously, image acquisition, processing, analysis, and decision generation are all integrated into the control board, enabling real-time processing at the edge, greatly shortening inference latency and significantly improving detection efficiency. Furthermore, the fully automated operation avoids subjective errors from manual measurement, providing a feasible technical solution for the precision management of large-scale farmland.
[0069] Please see Figure 8 This application provides a rice leaf angle extraction device based on optimized rice side view images, comprising an image acquisition module 1100, a detection model construction module 1200, a rice key point detection module 1300, a leaf angle calculation module 1400, and a fertilization strategy determination module 1500. The image acquisition module 1100 is configured to drive an adaptive gimbal to collect angular velocity, angular acceleration, and actual attitude angle in real time via an attitude sensor and transmit this data to a control board. The control board uses an improved dung beetle algorithm to dynamically adjust PID control parameters, generating closed-loop compensation commands to drive a servo actuator to adjust the adaptive gimbal's attitude, maintaining a preset observation attitude to acquire a side view image of the target rice plant. The detection model construction module 1200 is configured to retain three key point output branches in the backbone network of a first rice key point detection model, compressing the number of output channels to six. It embeds two cascaded RiceFeatureEnhancer modules into the middle region connecting the P3 and P4 levels of the PANet feature pyramid in the neck network, using a Wing... The loss function is used as a regression loss function to construct a second rice keypoint detection model. Each RiceFeatureEnhancer module adopts a parallel structure of one spatial attention branch and one channel attention branch. The rice keypoint detection module 1300 is configured to input the side view image of the rice to be detected into the trained and converged second rice keypoint detection model to determine the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice. The leaf angle calculation module 1400 is configured to calculate and determine the first difference between the top point of the stem and the bottom point of the stem to determine the stem direction vector, calculate and determine the second difference between the tip point of the leaf and the top point of the stem to determine the leaf direction vector, and calculate and determine the leaf angle of the target rice based on the stem direction vector and the leaf direction vector. The fertilization strategy determination module 1500 is configured to determine the leaf angle level of the target experimental plot based on the leaf angle of the rice, and determine the target fertilization suggestion corresponding to the leaf angle level to complete the extraction of the leaf angle of the target rice.
[0070] Based on any embodiment of this application, please refer to Figure 9 Another embodiment of this application also provides an electronic device, which can be implemented by a computer device, such as... Figure 9 The diagram shows the internal structure of a computer device. The computer device includes a processor, a computer-readable storage medium, a memory, and a network interface connected via a system bus. The computer-readable storage medium stores an operating system, a database, and computer-readable instructions. The database stores control information sequences. When executed by the processor, the computer-readable instructions enable the processor to implement a method for extracting the angle of rice leaves based on optimized rice side-view images. The processor provides computational and control capabilities, supporting the operation of the entire computer device. The memory stores computer-readable instructions, which, when executed by the processor, enable the processor to execute the rice leaf angle extraction method based on optimized rice side-view images of this application. The network interface of the computer device is used for communication with a terminal. Those skilled in the art will understand that… Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0071] In this embodiment, the processor is used to execute... Figure 8 The specific functions of each module are defined within the device, and the memory stores the program code and various data required to execute these modules or sub-modules. The network interface is used for data transmission between the user terminal and the server. In this embodiment, the memory stores the program code and data required to execute all modules in the rice leaf angle extraction device based on optimized rice side-view images. The server can call the server's program code and data to execute the functions of all modules.
[0072] This application also provides a storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the rice leaf angle extraction method based on rice side view image optimization as described in any embodiment of this application.
[0073] This application also provides a computer program product, including a computer program / instructions that, when executed by one or more processors, implement the steps of the rice leaf angle extraction method based on rice side view image optimization as described in any embodiment of this application.
[0074] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. This computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0075] The above description is only a partial embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for extracting the included angle of rice leaves based on optimized rice side view images, characterized in that, include: The adaptive gimbal is driven by an attitude sensor to collect angular velocity, angular acceleration and actual attitude angle in real time and transmit them to the control board. The control board calls an improved dung beetle algorithm to dynamically adjust the PID control parameters to generate a closed-loop compensation command to drive the servo actuator to adjust the attitude of the adaptive gimbal, so that the adaptive gimbal maintains the preset observation attitude to collect a side view image of the rice to be detected containing the target rice. Three key point output branches are retained in the backbone network of the first rice key point detection model, and the number of output channels is compressed to 6. Two cascaded RiceFeatureEnhancer modules are embedded in the middle region connecting the P3 and P4 layers of the PANet feature pyramid of the neck network. The Wing Loss loss function is used as the regression loss function to construct the second rice key point detection model. Each RiceFeatureEnhancer module adopts a parallel structure of one spatial attention branch and one channel attention branch. The side view image of the rice to be detected is input into the trained and converged second rice key point detection model to determine the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice. The first difference between the top point and the bottom point of the stem is calculated to determine the stem direction vector; the second difference between the leaf tip point and the top point of the stem is calculated to determine the leaf direction vector; and the leaf angle of the target rice is calculated based on the stem direction vector and the leaf direction vector. Based on the rice leaf angle, the rice leaf angle level of the target experimental plot is determined, and the target fertilization recommendation corresponding to the rice leaf angle level is determined, so as to complete the extraction of the rice leaf angle of the target rice.
2. The method for extracting the included angle of rice leaves based on optimized rice side view images according to claim 1, characterized in that, The steps of dynamically adjusting PID control parameters by calling an improved dung beetle algorithm in the control board to generate closed-loop compensation commands to drive the servo actuator to adjust the adaptive gimbal attitude, so that the adaptive gimbal maintains a preset observation attitude, in order to acquire a side view image of the rice to be detected containing the target rice, include: The preset improved dung beetle algorithm is invoked in the control board to minimize the attitude angle deviation and control response time of the adaptive gimbal as the optimization objective, so as to determine the optimal PID control parameters, wherein the PID control parameters include the proportional coefficient, integral coefficient and derivative coefficient of the PID controller. Based on the optimal PID control parameters, a closed-loop compensation command is generated. The control board transmits the closed-loop compensation command to the adapter board, which converts it into an executable signal for the servo actuator and outputs it to the servo actuator. The servo actuator outputs a PID correction torque according to the executable signal to drive the adaptive gimbal to adjust its attitude. When the attitude angle deviation between the actual attitude angle of the adaptive gimbal and the preset observed attitude angle meets the preset angle threshold, the attitude sensor secondary calibration mechanism is triggered. The PID control parameters are updated based on the real-time collected angular velocity, angular acceleration and actual attitude angle to perform dynamic balance adjustment. While the adaptive gimbal is stably maintaining a preset observation posture, the imaging device is controlled to acquire a side view image of the rice to be detected, which includes the target rice.
3. The method for extracting the included angle of rice leaves based on optimized rice side view images according to claim 2, characterized in that, The servo actuator outputs a PID correction torque based on the executable signal to drive the adaptive gimbal to adjust its attitude. When the attitude angle deviation between the actual attitude angle of the adaptive gimbal and the preset observed attitude angle meets a preset angle threshold, a secondary calibration mechanism for the attitude sensor is triggered. This mechanism updates the PID control parameters based on real-time acquired angular velocity, angular acceleration, and the actual attitude angle to perform dynamic balance adjustment. The steps include: Obtain the actual attitude angle, the preset observation attitude angle, and the allowable adjustment time of the adaptive platform, and calculate and determine the attitude angle deviation between the actual attitude angle and the preset observation attitude angle; When the attitude angle deviation meets the preset angle threshold, the attitude sensor secondary calibration mechanism is triggered to calculate the target angular acceleration of the servo actuator. The maximum allowable angular velocity of the adaptive gimbal is determined based on the product of the target angular acceleration and the allowable adjustment time. The improved dung beetle algorithm is called to update the PID control parameters with the goal of minimizing the attitude angle deviation and control response time. Based on the updated PID control parameters, a dynamic balance adjustment command is generated. After being converted into an executable signal for the servo actuator via an adapter board, the servo actuator is driven to output a PID correction torque to adjust the attitude of the adaptive gimbal until the attitude angle deviation is close to zero, so as to perform dynamic balance adjustment.
4. The method for extracting the included angle of rice leaves based on optimized rice side view images according to claim 1, characterized in that, The steps of inputting the side view image of the rice to be detected into a trained and converged second rice key point detection model to determine the stem base point, stem top point, and leaf tip point of the target rice include: Obtain a side view image of the rice to be detected that contains the target rice; The features of the rice side view image to be detected are enhanced by two cascaded RiceFeatureEnhance modules. In the spatial attention branch of each RiceFeatureEnhance module, the spatial weights of the stem and leaf regions of the target rice are learned by 7×7 convolution. In the channel attention branch, the channel response related to the rice structure is dynamically enhanced by the SE module to strengthen the features of rice stems and leaves. The enhanced rice stem and leaf features are processed by the subsequent network layers of the second rice key point detection model, and the stem bottom point, stem top point, and leaf tip point of the target rice are output.
5. The method for extracting the included angle of rice leaves based on optimized rice side view images according to claim 1, characterized in that, The step of calculating and determining the rice leaf angle of the target rice based on the stem direction vector and the leaf direction vector includes: Obtain the stem direction vector and leaf direction vector of the target rice; Calculate and determine the first product between the stem direction vector and the leaf direction vector; Calculate and determine the first vector magnitude corresponding to the stem direction vector, calculate and determine the second vector magnitude corresponding to the leaf direction vector, and calculate and determine the second product between the first vector magnitude and the second vector magnitude; A first ratio between the first product and the second product is calculated, and the inverse cosine function value of the first ratio is used to determine the included angle of the rice leaves of the target rice.
6. The method for extracting the included angle of rice leaves based on optimized rice side view images according to claim 1, characterized in that, The steps for determining the rice leaf angle level of the target experimental plot based on the rice leaf angle, and then determining the target fertilization recommendation corresponding to the rice leaf angle level, include: Obtain the leaf angle of multiple target rice plants in the target test plot, and calculate the average value of the leaf angle of the multiple target rice plants in the target test plot as the representative value of the leaf angle of the target test plot; The representative value of the rice leaf angle is matched to the corresponding rice leaf angle grade, wherein the rice leaf angle grade includes Grade 1 upright, Grade 2 semi-upright, Grade 3 intermediate, Grade 4 semi-spreading, and Grade 5 spreading. Based on the matched rice leaf angle level, the preset correspondence between the rice leaf angle level and the target fertilization recommendation is retrieved to determine the target fertilization recommendation corresponding to the target experimental plot. The target fertilization recommendation includes relevant control content on nitrogen fertilizer application rate, potassium fertilizer and silicon fertilizer application requirements.
7. The method for extracting the included angle of rice leaves based on rice side view images optimized according to any one of claims 1 to 6, characterized in that, The basic network architecture of the first rice key point detection model is the original YOLOv8-Pose model; the basic network architecture of the second rice key point detection model is the improved YOLOv8-Pose model. The rice leaf angle refers to the angle formed between the rice leaf and the rice stem, and its size directly reflects the degree of spreading and uprightness of the rice plant.
8. A device for extracting the included angle of rice leaves based on optimized rice side view images, characterized in that, include: The image acquisition module is configured to drive the adaptive gimbal to collect angular velocity, angular acceleration and actual attitude angle in real time through the attitude sensor and transmit them to the control board. In the control board, the improved dung beetle algorithm is called to dynamically adjust the PID control parameters to generate closed-loop compensation commands to drive the servo actuator to adjust the attitude of the adaptive gimbal, so that the adaptive gimbal maintains the preset observation attitude to acquire a side view image of the rice to be detected containing the target rice. The detection model construction module is set to retain 3 key point output branches in the backbone network of the first rice key point detection model and compress the number of output channels to 6. The middle region connecting the P3 and P4 layers of the PANet feature pyramid of the neck network is embedded into two cascaded RiceFeatureEnhancer modules. The Wing Loss loss function is used as the regression loss function to construct the second rice key point detection model. Each RiceFeatureEnhancer module adopts a parallel structure of one spatial attention branch and one channel attention branch. The rice key point detection module is configured to input the side view image of the rice to be detected into a trained and converged second rice key point detection model to determine the bottom point of the stem, the top point of the stem, and the tip point of the leaf of the target rice. The leaf angle calculation module is configured to calculate and determine the first difference between the top point of the stem and the bottom point of the stem to determine the stem direction vector, calculate and determine the second difference between the leaf tip point and the top point of the stem to determine the leaf direction vector, and calculate and determine the leaf angle of the target rice based on the stem direction vector and the leaf direction vector. The fertilization strategy determination module is set to determine the rice leaf angle level of the target experimental plot based on the rice leaf angle, so as to determine the target fertilization recommendation corresponding to the rice leaf angle level, thereby completing the extraction of the rice leaf angle of the target rice.
9. An electronic device comprising a central processing unit and a memory, characterized in that, The central processing unit is used to invoke and run a computer program stored in the memory to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores, in the form of computer-readable instructions, a computer program implemented according to any one of claims 1 to 7, which, when invoked by a computer, executes the steps included in the corresponding method.