Fruit tree point cloud distance measurement method and system based on TreeSegNet

By using the TreeSegNet lightweight point cloud segmentation network to perform fine segmentation of fruit tree point clouds, the problem of difficulty in obtaining the distance between the spray nozzle and the fruit tree in real time during orchard plant protection operations is solved, enabling precise spray control and reducing pesticide usage and environmental risks.

CN121904585APending Publication Date: 2026-04-21SHANGHAI INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI INST OF TECH
Filing Date
2025-12-31
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing technologies struggle to achieve real-time and accurate distance sensing between the tree canopy and the spray nozzles in orchard plant protection operations, resulting in uneven spray volume, pesticide waste, and environmental pollution risks. Furthermore, existing solutions have limitations in terms of accuracy, cost, or integration difficulty.

Method used

A lightweight point cloud segmentation network based on TreeSegNet is adopted. The 3D point cloud and color information of fruit trees are collected by a depth camera and fine segmentation is performed. Combined with local feature extraction and channel attention mechanism, multi-channel and partitioned distance information is output, which is suitable for embedded sprayer platform.

Benefits of technology

It achieves precise distance measurement of the fruit tree canopy, reduces background interference, reduces pesticide usage and ground pesticide deposition, improves the real-time performance and reliability of spray control, adapts to complex orchard environments, and reduces hardware costs and maintenance difficulty.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121904585A_ABST
    Figure CN121904585A_ABST
Patent Text Reader

Abstract

The invention provides a TreeSegNet-based fruit tree point cloud distance measurement method and system, and relates to the technical field of agricultural engineering and computer vision, and the method comprises the steps: synchronously collecting a depth image and a color image containing a target fruit tree through a depth camera, and fusing the depth image and the color image to generate a scene point cloud with color information; the method comprises the steps that scene point clouds are preprocessed and then input into a lightweight point cloud segmentation network TreeSegNet for point-by-point semantic segmentation, the point clouds are divided into fruit tree point clouds and background point clouds, and the TreeSegNet network sequentially comprises an encoder used for feature mapping, a local feature extraction module based on edge convolution, a channel attention module and a classifier; and extracting the point cloud of the target fruit tree according to the segmentation result, and calculating the distance between the spraying equipment and the fruit tree in the distance measurement area corresponding to the nozzle arrangement. According to the method, accurate segmentation and real-time distance measurement of the fruit tree target can be realized in a complex orchard environment, reliable input is provided for variable spraying control, and the method has the advantages of high precision, strong real-time performance and easy integration and deployment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of agricultural engineering and computer vision technology, specifically to a method and system for fruit tree point cloud segmentation and distance estimation based on a lightweight point cloud segmentation network, and more particularly to a method and system for fruit tree point cloud ranging based on TreeSegNet. Background Technology

[0002] Orchard plant protection operations currently rely primarily on wind-assisted sprayers for chemical control. The vast majority of these devices operate on a constant spray rate mode, meaning that uniform spraying parameters are set based on experience without real-time adjustments based on individual tree height, canopy volume, and density. This leads to uneven pesticide distribution within the canopy, with significant pesticide drift and deposition between rows and on the ground, increasing pesticide waste and environmental pollution risks. Therefore, implementing on-demand variable-rate pesticide application based on orchard canopy characteristics has become an urgent need for the development of precision agriculture.

[0003] The key to achieving variable displacement spraying lies in the real-time and accurate sensing of the distance between the nozzle and the canopy of the target fruit tree. Currently, sensor-based variable displacement spraying technology mainly includes the following types of solutions:

[0004] The first type of solution uses ultrasonic sensors to detect the canopy of fruit trees. This type of system estimates the width or volume of the canopy through echo signals, and then adjusts the spray volume accordingly. While its structure is relatively simple and low-cost, the ultrasonic beam has a large divergence angle and limited spatial resolution. When the canopy structure is complex, the branches and leaves are sparse, or there are gaps, the ranging results deviate significantly from the actual outline. It is easy to misidentify non-target structures such as support poles as the canopy, and it is significantly affected by environmental factors such as wind speed and temperature. Therefore, the ranging accuracy is difficult to meet the requirements of precision plant protection.

[0005] The second approach uses lidar sensors to acquire the canopy outline of fruit trees. Spray volume control is achieved by reconstructing the canopy volume or leaf area index. Lidar has advantages such as long range and high resolution, but such systems are expensive, bulky, power-consuming, and have complex calibration and data processing procedures, making large-scale deployment on small and medium-sized orchard sprayers difficult. Furthermore, existing solutions often focus on estimating the canopy volume of the entire tree or row, lacking sufficient ability to perceive the precise distance between the nozzle and specific areas of the canopy.

[0006] The third type of approach attempts to utilize computer vision and RGB-D (color-depth) imaging technology. For example, it uses a depth camera to simultaneously acquire color and depth information, and then separates the foreground of the fruit tree using image segmentation or depth field extraction algorithms to estimate the distance. However, in real-world orchard scenarios with large variations in outdoor lighting, overlapping branches and leaves, and complex backgrounds, the ranging error of this method remains relatively large. Especially when branches and leaves are adhered to or occluded by the background such as the ground or support poles, directly calculating the average distance from the original depth map or the overall point cloud will include a large amount of background point cloud data in the calculation, leading to systematic biases in the ranging results.

[0007] With the development of 3D perception and deep learning technologies, methods for fruit tree canopy segmentation based on 3D point clouds have emerged. Some studies utilize traditional 3D processing algorithms (such as voxel generation and region growing) to separate the canopy from the point cloud and then calculate tree parameters. In recent years, deep learning networks such as PointNet, PointNet++, and DGCNN have been introduced into fruit tree point cloud semantic segmentation tasks, validating their potential. However, these networks are mostly complex encoder-decoder structures with large parameter counts and high computational overhead. They typically require GPUs or high-performance industrial control computers for offline inference, making them difficult to deploy directly in embedded control terminals on spray aircraft, which are subject to strict space and power consumption constraints. Furthermore, some networks only use geometric coordinates as input, resulting in limited ability to distinguish background objects with similar colors and geometric structures (such as white support poles) in the orchard. In complex backgrounds, misclassification is prone to occur, affecting the accuracy of subsequent distance measurements.

[0008] In summary, existing technologies face prominent contradictions in achieving real-time and accurate distance measurement for orchard plant protection: traditional sensing methods such as ultrasound and lidar have limitations in terms of accuracy, cost, or integration difficulty; RGB-D image-based solutions lack fine segmentation of point clouds, resulting in large errors in complex scenarios; while advanced 3D point cloud deep learning segmentation methods are difficult to meet the real-time and lightweight requirements of embedded platforms.

[0009] Therefore, there is an urgent need for a fruit tree point cloud segmentation and distance estimation scheme that can balance segmentation accuracy, model lightweighting, and embedded real-time inference capabilities, in order to solve the common technical problems of inaccurate measurement, slow calculation, and difficulty in integration, and to provide reliable distance information input for precise variable spraying. Summary of the Invention

[0010] To address the shortcomings of existing technologies, this invention provides a method and system for measuring the distance of fruit tree point clouds based on TreeSegNet.

[0011] According to the present invention, a method and system for ranging fruit tree point clouds based on TreeSegNet are provided, the scheme of which is as follows:

[0012] Firstly, a tree point cloud ranging method based on TreeSegNet is provided, the method comprising:

[0013] Step S1: Data acquisition and synchronization. Using a depth camera installed on the plant protection sprayer, simultaneously acquire depth images and registered color images of the target fruit trees.

[0014] Step S2: Point cloud construction and feature fusion. Based on camera intrinsic parameters, the depth image is converted into three-dimensional point cloud data containing spatial coordinates. The RGB color information of corresponding pixels in the color image is associated with the three-dimensional point cloud data point by point to form orchard scene point cloud data with six-dimensional features.

[0015] Step S3: Point cloud preprocessing, spatial cropping and downsampling are performed on the point cloud data of the orchard scene to obtain standardized point cloud data;

[0016] Step S4: TreeSegNet semantic segmentation. The standardized point cloud data is input into the lightweight point cloud segmentation network TreeSegNet. TreeSegNet adopts a hierarchical structure of encoder, local feature extraction, channel attention and classification to perform point-by-point semantic classification on each point and output point cloud data labeled with fruit tree and background categories.

[0017] Step S5: Extract point cloud of target fruit trees. Filter point clouds of fruit tree categories according to the category labels to form a subset of target fruit tree point clouds.

[0018] Step S6: Regional distance measurement calculation. Based on the installation geometry of the depth camera and the sprayer, multiple distance measurement areas corresponding one-to-one with the nozzle arrangement are preset. The target fruit tree point cloud subset is divided into each distance measurement area, and the spatial distance between the target fruit tree point cloud and the sprayer in each distance measurement area is calculated.

[0019] Step S7: Validity determination and anomaly handling. Determine whether the number of target fruit tree point clouds in each ranging area exceeds the preset threshold. If it does not exceed the threshold, output a null value or the default distance.

[0020] Step S8: Output distance results. Output the distance results of each measuring area that has passed the validity determination to the spray controller or host computer.

[0021] Preferably, the point cloud preprocessing in step S3 further includes at least one of coordinate normalization, noise point removal, and ground stripping;

[0022] The downsampling is either voxel grid downsampling or random downsampling, which unifies the number of point clouds to a preset range.

[0023] Preferably, in step S4, the encoder of TreeSegNet performs two-layer linear transformation on the six-dimensional features, and after each layer of linear transformation, batch normalization and ReLU activation function processing are performed sequentially to obtain a compact high-dimensional feature representation.

[0024] In step S4, the local feature extraction adopts the EdgeConv structure, selects the k nearest neighbors of each point by Euclidean distance, calculates the feature difference between the current point and the neighboring points and performs feature concatenation, and aggregates the local geometric features by max pooling after nonlinear transformation by multilayer perceptron.

[0025] Preferably, in step S4, the channel attention uses the SE module, which obtains the channel description vector through global average pooling, calculates the channel weights through two fully connected transformations and the Sigmoid activation function, and performs channel-level adaptive recalibration on the encoder output features.

[0026] Preferably, the spatial distance in step S6 is calculated as average distance, median distance, or a weighted fusion of the truncated mean and median; in the weighted fusion, the weight λ∈[0,1] of the truncated mean is calculated by removing 10% of the extreme values ​​at both ends.

[0027] Preferably, the method further includes a multi-frame spatiotemporal fusion step: obtaining the linear velocity, heading angle and its rate of change of the sprayer through an encoder and an inertial measurement unit, unifying the point clouds of multiple frames within the time window into a global fusion coordinate system, performing spatiotemporal fusion on the target fruit tree point clouds segmented by TreeSegNet in each frame, and calculating the fusion distance using a time-quality weighted mechanism.

[0028] Preferably, in the time-quality weighting mechanism, the weight is the product of the time decay factor and the quality factor; the time decay factor adopts an exponential decay function, and the quality factor is calculated based on the number of valid points in the region and the class confidence score output by TreeSegNet.

[0029] Preferably, the exception handling in step S7 further includes:

[0030] Distance abrupt change determination: When the rate of change of distance between adjacent frames exceeds the theoretical upper limit derived from the maximum driving speed of the sprayer, the result of the previous frame or local median filtering is used for correction.

[0031] Secondly, a tree point cloud ranging system based on TreeSegNet is provided, the system comprising:

[0032] The depth sensing module includes a depth camera and a support structure. The support structure fixes the depth camera to the plant protection sprayer and faces the spray direction, for simultaneously acquiring depth images and color images of the orchard operation area.

[0033] The data processing module includes an embedded processing unit and a memory. The memory stores a computer program. The embedded processing unit is used to convert a depth image into three-dimensional point cloud data and fuse it with RGB color information, and to preprocess the fused point cloud data.

[0034] The point cloud segmentation module runs within the data processing module. It calls the stored TreeSegNet model parameters to perform semantic segmentation on the preprocessed point cloud and outputs point cloud data labeled with fruit tree and background categories.

[0035] The distance calculation module runs within the data processing module. It presets a distance measurement area corresponding to the nozzle arrangement, extracts the point cloud of fruit trees in each distance measurement area and calculates the spatial distance, and determines the validity of the distance results.

[0036] The communication interface module is used to send the distance result output by the distance calculation module to the spray controller or the host computer.

[0037] Thirdly, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the tree point cloud ranging method based on TreeSegNet.

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

[0039] 1. This invention uses TreeSegNet to perform point-by-point semantic segmentation on orchard scene point clouds, accurately selecting fruit tree category point clouds and removing background point clouds such as ground, supporting structures, and cultivation containers, thus avoiding interference from non-target areas in distance measurement from the source; at the same time, it integrates three-dimensional geometric coordinates and RGB color features, combined with local feature extraction and channel attention mechanisms, to effectively distinguish objects with similar geometric shapes but significant color differences, solving the systematic bias problem of distance measurement in complex orchard scenes, and making the distance measurement results more consistent with the actual position of the fruit tree canopy;

[0040] 2. TreeSegNet adopts a lightweight design, which significantly reduces the number of model parameters and computational complexity by simplifying the encoder structure and optimizing the feature dimension and network depth. It can be deployed on small embedded computing platforms such as Raspberry Pi CM5. During the sprayer's movement, it can continuously process point cloud data and output ranging results, avoiding the lag of traditional complex network offline modeling and post-analysis, and providing dynamic response support for real-time adjustment of nozzle spray volume.

[0041] 3. This invention divides the distance measurement area based on the arrangement of the nozzles and outputs multi-channel, zoned distance information, so that the spray control system can adjust the start and stop and spray volume of the corresponding nozzles according to the canopy distribution at different heights and lateral positions. When there is insufficient effective tree point cloud in a certain area, the system automatically identifies and shuts down the corresponding nozzles or reduces the spray volume, reducing dry spraying and ineffective spraying, significantly reducing pesticide use and ground pesticide deposition, and promoting the development of plant protection operations towards green and efficient directions.

[0042] 4. This invention uses a single depth camera as the core sensing device, eliminating the need for additional multi-layer ultrasonic sensors or high-cost lidar, thus reducing hardware investment and installation and calibration workload; point cloud processing, semantic segmentation, and ranging calculation are all integrated into the embedded processing module, eliminating the need for a separate industrial control computer, simplifying the overall structure of the spraying equipment, improving system reliability and maintainability, and allowing for performance optimization through software upgrades and iterations, thereby reducing long-term operating costs.

[0043] 5. TreeSegNet maintains stable performance in orchard environments with large changes in lighting, overlapping branches and leaves, and irregular tree shapes through local topological relationship encoding, channel attention feature enhancement, and anomaly handling mechanisms. Combined with multi-frame spatiotemporal fusion and motion compensation strategies (suitable for complex terrain scenarios), it can effectively suppress distance abrupt changes caused by rack jitter and short-term occlusion, adapting to various operating scenarios such as hilly areas and dense orchards, thus broadening its application scope.

[0044] Other beneficial effects of the present invention will be explained in detail through the introduction of specific technical features and technical solutions in specific embodiments. Those skilled in the art should be able to understand the beneficial technical effects brought about by these technical features and technical solutions through the introduction of these technical features and technical solutions. Attached Figure Description

[0045] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0046] Figure 1 This is a flowchart illustrating the execution of the point cloud ranging algorithm that integrates semantic segmentation in this invention.

[0047] Figure 2 This is a rendering of the original dense point cloud generated by the depth image conversion method of this invention.

[0048] Figure 3 This is a schematic diagram of the sparse point cloud after voxel grid downsampling according to the present invention;

[0049] Figure 4 This is a schematic diagram of point cloud semantic segmentation of citrus tree-cultivation facility-background according to the present invention;

[0050] Figure 5This is a schematic diagram of the lightweight network structure based on EdgeConv and channel attention in this invention;

[0051] Figure 6 This is a comparison chart of the parameter quantities of different models of the present invention;

[0052] Figure 7 This is a performance comparison diagram between the TreeSegNet model of this invention and existing mainstream models;

[0053] Figure 8 This is a comparison of the ablation experiment results of the TreeSegNet model of this invention;

[0054] Figure 9 This is a comparative chart showing the number of parameters and training loss values ​​for various model variants of this invention.

[0055] Figure 10 A manually labeled point cloud diagram of citrus trees, cultivation facilities, and background;

[0056] Figure 11 A schematic diagram of the semantic segmentation results of the point cloud of citrus trees using the TreeSegNet_Full model;

[0057] Figure 12 A schematic diagram of the semantic segmentation results of the point cloud of citrus trees using the TreeSegNet_NoEdgeConv model;

[0058] Figure 13 A schematic diagram of the semantic segmentation results of citrus tree point cloud using the TreeSegNet_NoSE_NoEdgeConv model;

[0059] Figure 14 A schematic diagram of the semantic segmentation results of citrus tree point cloud using the TreeSegNet_NoEncoder_NoSE_NoEdgeConv model;

[0060] Figure 15 The image shows the results of a stationary distance measurement experiment at different distances (1.6 meters).

[0061] Figure 16 The image shows the results of a stationary distance measurement experiment at different distances (2.0 meters).

[0062] Figure 17 The image shows the results of a stationary distance measurement experiment at different distances (2.6 meters).

[0063] Figure 18 The image shows the results of a stationary distance measurement experiment at different distances (3.0 meters).

[0064] Figure 19 A comparison chart of the distance predicted by the TreeSegNet model and the actual distance measured with a measuring tape.

[0065] Figure 20 A comparison of the original and smoothed average tree spacing over time as the sprayer moves away from the fruit trees;

[0066] Figure 21 This is a comparison chart showing the original and smoothed average tree distance changes over time as the sprayer approaches the fruit trees. Detailed Implementation

[0067] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the scope of protection of the present invention.

[0068] This invention provides a tree point cloud ranging method based on TreeSegNet, solving the problem of difficulty in obtaining the real-time and accurate distance between the nozzle and the target fruit tree in existing orchard plant protection spraying operations, leading to a mismatch between the spray volume and the tree canopy. By utilizing a depth camera to collect 3D point cloud and color information of the fruit tree, a lightweight point cloud segmentation network suitable for orchard scenarios is constructed to perform fine segmentation of the fruit tree and background. Based on this, the point cloud of the target fruit tree area related to spraying is extracted, and the spatial distance between the sprayer and the fruit tree is calculated, providing real-time and reliable distance input for variable spray control. This invention balances segmentation accuracy and computational efficiency and can be deployed on an embedded control terminal on a plant protection sprayer to achieve online ranging during orchard plant protection operations. The method includes at least the following steps:

[0069] First, during orchard plant protection operations, a depth camera mounted on a sprayer simultaneously acquires depth images of the target fruit trees and corresponding color images. Based on camera intrinsic parameters, the depth images are converted into 3D point cloud data containing spatial coordinates. The RGB color information of corresponding pixels in the color images is then correlated point by point with the point cloud, forming orchard scene point cloud data with (x, y, z, r, g, b) as basic features. Next, the acquired raw point cloud is preprocessed, including spatial cropping based on the camera's effective range and the spraying operation area to remove invalid points that are too close or too far away. Voxel downsampling or random downsampling is used to unify the number of points to a preset range to reduce the computational load of subsequent networks. If necessary, coordinate normalization and noise point removal can be performed on the point cloud to improve data stability.

[0070] Subsequently, the preprocessed point cloud is input into the lightweight point cloud segmentation network TreeSegNet. The TreeSegNet network employs a hierarchical structure of encoder-local feature extraction-channel attention-classification: the encoder performs point-by-point linear mapping and nonlinear transformation on the six-dimensional features of each point to obtain a compact high-dimensional feature representation; the local feature extraction part constructs the connection relationship between a point and its neighbors based on neighborhood search, and uses an edge convolution structure to encode local geometric relationships to extract local features reflecting the tree branch and leaf structure; the channel attention part recalibrates the channel dimension weights of the encoder output features, enhancing important features related to the fruit tree and suppressing redundant background information; the classification part classifies each point point-by-point according to the aforementioned features, outputting a category label indicating that each point in the point cloud belongs to at least two classes: "fruit tree" and "background". Through point-by-point semantic segmentation by this network, the point cloud is divided into two parts: the fruit tree point cloud and the background point cloud.

[0071] After obtaining the semantic segmentation results, based on the needs of plant protection spraying operations, point clouds of target fruit tree areas related to spraying are extracted from the segmentation results, and the distance between the sprayer and the fruit trees is calculated. Specifically, at least one ranging region corresponding to the nozzle arrangement can be set according to the depth camera coordinate system or the sprayer coordinate system. Point clouds marked as fruit tree categories and located within this ranging region are taken as the set of effective target point clouds. Within each ranging region, the average distance or median distance is calculated based on the spatial coordinates of the target point clouds to obtain the ranging result between the sprayer and the canopy of the fruit trees in that region. When the number of effective target point clouds in a certain ranging region is lower than a preset threshold, it can be determined that there are no effective tree targets in that region, and a null value or default distance is output for subsequent spray control logic judgment. Through the above steps, the real-time distance sequence between the sprayer and the fruit trees can be obtained on single frame or continuous frame data.

[0072] The present invention further provides a tree point cloud ranging system based on TreeSegNet, which includes: a depth perception module, a data processing module, a point cloud segmentation module, a distance calculation module, and a communication interface module. The depth sensing module includes a depth camera and a support structure for mounting the depth camera, fixed on the plant protection sprayer and facing the spray direction, for acquiring depth and color images of the orchard operation area; the data processing module includes an embedded processing unit and a memory, storing a computer program for implementing the ranging method of this invention, and for performing point cloud conversion and preprocessing on the depth and color images; the point cloud segmentation module runs on the data processing module, calling the stored TreeSegNet model parameters to perform lightweight semantic segmentation on the preprocessed point cloud, outputting point cloud data labeled with fruit tree category and background category; the distance calculation module also runs on the data processing module, extracting the target point cloud set from the point cloud labeled with fruit tree category according to the installation geometry of the sprayer and the depth camera and the preset ranging area definition, and calculating the distance of fruit trees in each ranging area; the communication interface module is used to send the ranging results output by the distance calculation module to the spray controller or host computer for driving the nozzle spray volume adjustment or recording operation information.

[0073] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described TreeSegNet-based fruit tree point cloud ranging method. By introducing a lightweight point cloud segmentation network and corresponding ranging method and system into orchard plant protection operations, this invention enables rapid segmentation of fruit trees and background point clouds and real-time measurement of the distance between the sprayer and the fruit trees on an embedded platform, providing a directly integrable distance sensing foundation for precision plant protection operations such as variable displacement spraying.

[0074] The overall process of this invention can be represented as follows: S1 Data acquisition and synchronization → S2 Point cloud construction and feature fusion → S3 Point cloud preprocessing → S4 TreeSegNet semantic segmentation → S5 Target fruit tree point cloud extraction → S6 Regionalized distance measurement calculation → S7 Validity determination and anomaly handling → S8 Distance result output and interface transmission.

[0075] Following the start node, the first step is data acquisition and synchronization (S1). In this step, the depth camera mounted on the agricultural sprayer acquires depth images and corresponding color images of the fruit trees at a preset frame rate during spraying operations, and performs timestamp alignment and frame synchronization in the embedded processing terminal. If necessary, this step also includes loading the camera's intrinsic and extrinsic parameters, as well as the installation pose parameters between the depth camera and the sprayer frame, providing a foundation for subsequent point cloud construction and coordinate transformation.

[0076] Next, we proceed to step S2: point cloud construction and feature fusion. In this step, based on the depth image and camera intrinsics, the depth value of each pixel is converted into a 3D coordinate point in the camera coordinate system, generating 3D point cloud data containing (x, y, z). Simultaneously, according to the registration relationship between the color image and the depth image, the R, G, and B color components of corresponding pixels in the color image are mapped one-to-one with the point cloud, forming an orchard scene point cloud with (x, y, z, r, g, b) as features, providing geometric and color fusion input for subsequent network segmentation.

[0077] Next is step S3, point cloud preprocessing. In this step, the system spatially crops the original point cloud according to the sprayer's working direction and effective spray range, removing invalid points that are too close or too far away. Simultaneously, voxel grid downsampling or random downsampling is used to control the number of points within a preset range to reduce the network's computational load. If necessary, coordinate normalization, abnormal noise point removal, and simple ground stripping can also be performed to obtain standardized point cloud data that meets the input requirements of TreeSegNet, laying the foundation for stable network inference.

[0078] The process then proceeds to step S4, TreeSegNet semantic segmentation. In this step, the preprocessed point cloud is input into the lightweight point cloud segmentation network TreeSegNet. The network first performs point-by-point feature mapping on the six-dimensional features of each point through the encoder, obtaining a compact high-dimensional representation; then, the local feature extraction module constructs the topological relationship between the point and its neighbors and performs edge convolution operations to extract local geometric features reflecting the tree canopy and leaf structure; further, a channel attention mechanism is used to weight different feature channels, highlighting features related to fruit trees and suppressing redundant background information; finally, the classification head determines the category of each point and outputs a semantic label for each point, including at least the categories of "fruit tree" and "background".

[0079] After semantic segmentation, step S5, target fruit tree point cloud extraction, is performed. This step filters out all points labeled as "fruit tree" from the overall point cloud based on the point-by-point category labels output by TreeSegNet, forming a subset of the target fruit tree point cloud. Simultaneously, point clouds labeled as "ground, supporting structures, cultivation containers, adjacent rows of fruit trees, or other background" are removed, ensuring that subsequent distance calculations are based solely on the fruit tree canopy point cloud directly related to plant protection spraying. If necessary, a simple clustering or region filtering process can be performed on the target fruit tree point cloud to eliminate scattered noise points.

[0080] The process then proceeds to step S6, regionalized ranging calculation. In this step, based on the calibration relationship between the depth camera coordinate system and the sprayer frame coordinate system, and the spatial arrangement of each nozzle on the sprayer, multiple ranging regions corresponding to the nozzles are predefined in the point cloud space. The target fruit tree point cloud is projected onto the corresponding coordinate system, and the points are divided into different ranging regions according to their spatial positions. For each ranging region, the average distance, median distance, or weighted distance of the target fruit tree point cloud in the direction of travel is calculated to obtain the distance measurement value of the fruit tree to the nozzle corresponding to that region, thus forming a multi-channel, one-to-one distance result set corresponding to each nozzle.

[0081] Next, step S7, validity determination and anomaly handling, is executed. In this step, the system checks the validity of the distance results for each ranging area, such as determining whether the number of target fruit tree point clouds in each area exceeds a preset threshold and whether the distance falls within a reasonable range. When the number of valid points in a certain area is insufficient or the distance abruptly exceeds the set threshold, the area can be marked as having no effective tree targets or suspected anomalies, and a null value or default distance can be output for subsequent control logic to shut down the nozzles or maintain a safe spray volume. For continuous frame data, sliding window filtering or median filtering can also be used to smooth the distance sequence to suppress accidental noise and instantaneous jitter.

[0082] Finally, in step S8, the distance results are output and transmitted via the interface. In this step, the distances to the fruit trees in each measurement area, after validity assessment and filtering, are organized into structured output data and sent to the spray control unit or host computer via the communication interface module. The spray control unit can adjust the start / stop status of the corresponding nozzles, the spray volume, or the PWM duty cycle based on the real-time distance values ​​of each area and a preset spray volume control model, achieving variable spraying that matches the canopy spatial structure. After this step is completed, the process returns to step S1 to continue processing the next frame of data, achieving continuous online distance measurement during the spraying operation until the operation ends and the process reaches the "end" node.

[0083] This invention introduces lightweight point cloud semantic segmentation and ranging technology based on TreeSegNet into orchard plant protection scenarios, achieving high-precision acquisition of the distance between the spray nozzle and the fruit tree canopy. Compared to the traditional method of directly using depth maps or averaging the distance from an undifferentiated overall point cloud, this significantly reduces systematic errors caused by background interference. Before distance calculation, this invention first uses TreeSegNet to classify each point in the point cloud point by point, only considering points identified as fruit trees as valid ranging targets. A large number of background point clouds, including the ground, cultivation containers, support poles, gaps between rows, and adjacent rows of fruit trees, are removed from the calculation, thus making the obtained distance result closer to the actual canopy location of the spray target. Even in complex citrus orchard environments with uneven foliage distribution, irregular tree shapes, and large gaps between rows, this invention can still maintain relatively stable distance measurement accuracy, providing reliable basic data support for precision plant protection.

[0084] This invention incorporates both spatial geometric coordinates and color information into point cloud feature construction. The 3D coordinates and RGB color of each point are combined to form a joint feature vector, which is then input into TreeSegNet. This overcomes the problem of insufficient ability to distinguish between target and non-target structures in orchard scenarios when relying solely on geometric information. By combining color features with local spatial structure features, the network can effectively distinguish objects with similar geometric shapes but significant color differences, such as white pillars, reflective supports, and green citrus canopies, fundamentally reducing the probability of ranging anomalies caused by misclassifying support structures as canopies. Simultaneously, the local feature extraction module in TreeSegNet fully encodes the local topological relationships and branch-leaf hierarchy between points and their neighbors. Furthermore, a channel attention mechanism is used to enhance features related to fruit trees and suppress background noise features. Therefore, it maintains good robustness and generalization ability even in real-world plant protection environments with large variations in outdoor lighting, complex backgrounds, and numerous noise points.

[0085] To address the limited computing power and power consumption of embedded terminals in plant protection spraying equipment, this invention employs a systematic lightweighting approach in its network structure design. By simplifying the multilayer perceptron structure, rationally controlling feature dimensions and network depth, and reducing redundant computations, the number of model parameters and computational complexity are significantly reduced. Compared to complex point cloud networks requiring high-performance GPUs or industrial PCs, the TreeSegNet of this invention can be deployed on small embedded computing platforms such as the Raspberry Pi CM5, enabling continuous point cloud segmentation and distance measurement output during the sprayer's movement, meeting the real-time requirements of orchard plant protection operations. Thus, this invention avoids the lag of offline modeling and post-event analysis in some existing research, allowing distance information to participate in spray control decisions in real time, thereby improving the dynamic response capability of the entire plant protection system.

[0086] Regarding the distance output format, this invention, considering the actual arrangement of nozzles on the sprayer, divides the coordinate system of the depth camera or sprayer into multiple distance measurement regions corresponding one-to-one with the nozzle positions. After completing point cloud semantic segmentation, it calculates the distance of fruit tree point clouds within each distance measurement region. Compared to the traditional solution that only provides a single distance between the sprayer and the entire tree or row of fruit trees, this invention can output multi-channel, zoned distance information. This allows the spray control system to adjust the start / stop and spray volume of the corresponding nozzles according to the canopy distribution at different heights and lateral positions, thus making the spatial distribution of the pesticide solution more closely match the actual canopy outline. For areas with missing trees, empty rows, or sparse canopies, when the number of effective tree point clouds in a certain distance measurement region is below a threshold, the system can automatically identify it as an area without effective targets and control the corresponding nozzles to close or reduce the spray volume to the minimum, effectively reducing dry spraying and ineffective spraying.

[0087] At the system implementation level, this invention uses a single depth camera as the core sensor for acquiring 3D environmental information, eliminating the need for additional multi-layer ultrasonic sensors or high-cost lidar on the orchard sprayer, thus significantly reducing hardware costs and installation and calibration difficulties. Point cloud generation, preprocessing, semantic segmentation, and distance calculation are all completed on an embedded processing module integrated with the spray control unit, without the need for an additional independent industrial control computer or host computer system. This makes the overall structure of the plant protection spraying equipment simpler, the wiring more centralized, and the system reliability and maintainability significantly improved. Furthermore, the core algorithm and network model of this invention can be iteratively optimized through software upgrades, continuously improving recognition and ranging performance without replacing hardware, thus reducing long-term use and maintenance costs.

[0088] This invention employs a novel technical architecture—a combination of depth camera 3D perception, point cloud preprocessing, TreeSegNet lightweight semantic segmentation, and regionalized ranging related to nozzle placement—to tightly couple sensing hardware, network structure design, and ranging output format, forming a collaborative technical solution not disclosed in existing technologies. The fusion of geometric and color features, along with the combined use of local structure encoding and attention mechanisms, not only improves the accuracy of fruit tree point cloud segmentation but also directly enhances the reliability of the final distance measurement. Furthermore, the regionalized distance output naturally integrates with the variable spray control logic. This invention not only solves the core technical problem of "difficulty in accurately and in real-time obtaining the distance between the nozzle and the fruit tree" but also provides a unified and scalable distance perception foundation for subsequent implementation of on-demand spray volume adjustment, reduced pesticide use, and reduced environmental risks, demonstrating significant technological advancement and engineering application value.

[0089] The invention will now be described in more detail through examples.

[0090] Example 1:

[0091] This embodiment uses citrus orchard spraying as a typical application scenario. Addressing issues such as uneven spacing between citrus trees or other row-planted crops, tree tilt, and continuously changing relative distances between the sprayer and crops during operation, it presents a citrus tree distance estimation method based on the lightweight point cloud segmentation network TreeSegNet. By sensing the spatial distance between the sprayer and the citrus tree canopy in real time and feeding this information back to the spray control system, dynamic adjustment of the spray dosage is achieved, thereby reducing the problem of uneven spraying caused by crop position deviations or distance fluctuations. To address the issues of large depth measurement errors and susceptibility to background interference in citrus tree environments, this embodiment performs precise semantic segmentation of the citrus tree area point cloud, estimating distance solely based on the target citrus tree point cloud, thus improving the accuracy of calculating the average distance between the sprayer and crops.

[0092] In actual citrus tree or crop planting environments, crop arrangement may be uneven, growth direction may deviate, and the relative distance between the sprayer and crops may change during operation. Therefore, to ensure the uniformity and accuracy of spraying operations, the system needs to have the ability to identify the distance between the crops and the sprayer in real time. Based on this distance information, the spray control system can dynamically adjust the spray volume, thereby reducing the inconsistency in spraying effects caused by deviations in crop position or distance between the crops and the sprayer. Addressing the issue of inaccurate depth measurement by depth cameras in citrus tree environments, this invention introduces a lightweight point cloud segmentation network model to accurately segment the point cloud of the citrus tree area, enabling the extraction of depth from the target citrus region, thus allowing for the accurate calculation of the average distance between the sprayer and the crops.

[0093] As attached Figure 1As shown, the tree point cloud ranging algorithm based on TreeSegNet of this invention includes the following sequentially connected steps: data acquisition and synchronization (S1), point cloud construction and feature fusion (S2), point cloud preprocessing (S3), TreeSegNet semantic segmentation (S4), target tree point cloud extraction (S5), regionalized ranging calculation (S6), validity determination and anomaly handling (S7), and distance result output and interface transmission (S8). Specifically, S1 to S3 perform preprocessing such as simultaneous acquisition of depth and color images, generation and cropping of 3D point clouds, and downsampling, providing standardized input for network inference; S4 to S5 use the lightweight point cloud segmentation network TreeSegNet to perform point-by-point semantic segmentation of the fruit tree and background, and extract point cloud data containing only the canopy of the target fruit tree; S6 to S7 calculate the distance between the sprayer and the fruit tree based on the target point in the spatial area corresponding to the nozzle layout, and judge and filter abnormal situations such as insufficient number of points or sudden changes in distance; S8 outputs the final effective distance result in the form of structured data to the spray control unit or host computer to drive the nozzle start and stop and adjust the spray volume, thereby realizing real-time perception and online feedback of the distance between the nozzle and the fruit tree.

[0094] This invention employs a depth camera to acquire depth and RGB images of citrus trees in an environment. The camera is set to a resolution of 640×480 pixels and a frame rate of 30 FPS, capable of simultaneously outputting depth maps and color images. The effective measurement range of the depth images is 0.2m to 3m, covering the distance changes (0.5 to 3 meters) between the citrus trees and the sprayer during spraying operations, resulting in a total of 200 depth images and their RGB images. The acquired depth maps and RGB images are then converted into 3D point clouds and stored in TXT files for subsequent semantic segmentation and distance calculation analysis.

[0095] To reduce the complexity of point cloud computing and improve processing efficiency, this invention uses the Python Open3d library to process the original point cloud (attached). Figure 2 As shown, voxel grid downsampling was used to downsample the original image from 110,291 points to 2,048 points (see attached image). Figure 3 (As shown). Specifically, the point cloud space is divided into cubic voxels with fixed side lengths, and the center point of each voxel represents all points within that voxel, thus generating a sparse point cloud. During downsampling, nearest neighbor matching preserves the point category information for subsequent semantic segmentation and distance calculation.

[0096] To achieve effective differentiation between the target crop and the background environment in the subsequent spray control model, this invention utilizes CloudCompare software to manually annotate the raw point cloud data acquired by the depth camera, as shown in the attached figure. Figure 4As shown. The labeled objects include: point clouds of citrus trees, point clouds of planting containers, and point clouds of the background and external environment. Because citrus trees often adhere or overlap with the ground or the edges of planting containers during their natural growth, the point cloud boundaries are often blurred, making it difficult to accurately distinguish the tree from the background. Therefore, in the labeling process, this invention prioritizes labeling the canopy and the upper-middle area. Furthermore, in the actual environment, the white support pole between two trees has an influence that is considered part of the external environment and needs to be removed. After labeling, the resulting point cloud data will be used as training samples for subsequent point cloud segmentation and feature extraction models to verify the model's target recognition and segmentation capabilities in complex scenes.

[0097] To achieve rapid identification and distance estimation between citrus trees and their background environment, this invention designs and implements a lightweight point cloud segmentation network, TreeSegNet. Combining point cloud data acquired by a depth camera, it achieves real-time target segmentation and distance calculation. This network can perform efficient semantic segmentation inference with low computational resources, meeting the real-time requirements of citrus tree scenes. The model uses PointNet with a multilayer perceptron to extract independent features from the coordinates of each point and obtains global features through global pooling. TreeSegNet makes targeted improvements based on PointNet. On one hand, PointNet only uses the 3D coordinates (x, y, z) of the point cloud as input features, while this invention further introduces color information (r, g, b), enabling the model to more accurately distinguish citrus trees from the background by fusing geometric and visual features, thus improving the robustness of point cloud segmentation. On the other hand, TreeSegNet borrows from the EdgeConv layer to extract local features, establishing connections between points by selecting the nearest neighbors of each point, and learning the structural information of local regions, thereby improving the model's ability to recognize local details. In addition, TreeSegNet has optimized the encoding structure to be lightweight, compressing the original multi-layer multi-perceptron structure into a two-layer linear transformation, which effectively reduces the number of network parameters and computational complexity.

[0098] This invention designs a lightweight point cloud segmentation network, TreeSegNet, as shown in the attached figure. Figure 5As shown, the four-stage architecture of encoding, local feature extraction, channel attention, and classification enables feature extraction and category determination of point clouds with low computational overhead. The network input is a point cloud acquired by a depth camera, where each point contains a six-dimensional feature vector (x, y, z, r, g, b). The three-dimensional coordinates provide geometric information, and the RGB colors provide visual information, enabling the network to more accurately distinguish citrus trees from the background by fusing geometric and visual features. In the feature extraction part, the Encoder layer uses multiple fully connected layers to process the features of the input points. The features of each input point are extracted using two linear transformations, the ReLU activation function, and batch normalization. Subsequently, the channel attention stage (SE module) uses global pooling to extract the global context and calculates channel weights to adaptively recalibrate the features, thereby highlighting important features related to citrus trees. Finally, the classification stage uses two fully connected layers and a Dropout layer to predict the category of each point, outputting citrus tree and background labels. The overall structure significantly reduces computational complexity and the number of parameters while ensuring segmentation accuracy.

[0099] The encoder is the core module of TreeSegNet, used to extract geometric and color features point by point. Traditional PointNet uses a multilayer perceptron (MLP) for feature mapping at each point, resulting in a large number of network layers and parameters, making real-time inference difficult on embedded devices. To adapt to real-time agricultural applications, this invention features a lightweight encoder structure, compressing the original multilayer MLP into a two-layer linear transformation, and appending Batch Normalization (BN) and ReLU activation functions to each layer to reduce computational complexity while maintaining non-linear representation capabilities.

[0100] Assume the input point cloud is P∈R N×6 Where N is the number of points, and each point contains six-dimensional features (x, y, z, r, g, b). The encoder's transformation can be represented as:

[0101] F1 = ReLU(BN(PW1+b1)), W1∈R 6×64 ,b1∈R 64

[0102] F2=ReLU(BN(PW2+b1)),W2∈R 64×H b2∈R H

[0103] Where F1 and F2 are the feature vectors after two layers of linear transformation; H is the hidden dimension (in this invention, H = 128); BN represents batch normalization; and ReLU is the nonlinear activation function.

[0104] This structure can effectively compress the number of model parameters, reduce computational overhead, and at the same time maintain the ability to fully express the features of each point.

[0105] The EdgeConv layer is designed based on graph convolutional neural networks, extracting local features by calculating the relative geometric relationships between each point and its neighbors. Specifically, the EdgeConv layer first calculates the Euclidean distance between each point in the point cloud and other points, and then selects the k nearest neighbors for each point. In this way, local features can be effectively extracted and can reflect the spatial structure of the point cloud data.

[0106] Assume the input point cloud is P∈R N×6 Where N is the number of points, and each point contains six-dimensional features (x, y, z, r, g, b). To extract local features, the EdgeConv layer's computation process includes the following steps:

[0107] Neighborhood selection and difference calculation. For each point p... i By calculating the Euclidean distance matrix d ij To measure the spatial relationship between points, select the k nearest points {p1, p2, ..., p...} k} as point p i The neighborhood of point p. Then, calculate the neighborhood of point p. i Its neighboring point p j Differences between them:

[0108] Δp ij =p j -p i

[0109] Where, p j p represents the characteristics of the neighborhood points. i The feature of the current point is the difference Δp. ij It represents the geometric difference between neighboring points and the current point.

[0110] Feature concatenation and transformation. The calculated difference features Δp are then processed. ij With the current point p i By concatenating features, a richer feature representation can be formed:

[0111]

[0112] This splicing operation enhances the point p. i The features, after being stitched together by the ability to perceive the neighborhood structure, are nonlinearly transformed by a multilayer perceptron (MLP) to learn higher-level local features.

[0113] Local feature aggregation. For each point p... iAfter all the features of points in its neighborhood are processed by MLP, max pooling is used to aggregate the features of k points in the neighborhood to obtain point p. i The final local feature representation:

[0114]

[0115] f i Point p i Local features; It is the result of splicing the difference features between the current point and its neighboring points and the original features.

[0116] MLP stands for Multilayer Perceptron, used for non-linear mapping of concatenated features; the max pooling operation aggregates the outputs of the MLP from all points in the neighborhood to obtain the value of point p. i The final local feature representation. This process preserves the most salient features within the neighborhood, thus ensuring that the importance of each point in its local structure is reflected.

[0117] The output of the EdgeConv layer is the local features for each point, which are then combined with global features to provide more comprehensive and accurate point cloud classification or segmentation results.

[0118] To enhance the network's ability to focus on citrus tree-related features, TreeSegNet introduces a feature channel attention mechanism (Squeeze-and-Excitation, SE module) after the encoder output. This module enhances key features and suppresses redundant information by performing channel-level adaptive recalibration on the features of each point, thereby improving segmentation accuracy.

[0119] Let the encoder output be F∈R N×H Where N is the number of points and H is the hidden dimension. The SE module first obtains the channel description vector through global average pooling (Squeeze):

[0120]

[0121] The channel weights w∈R are then calculated through two layers of fully connected excitation. H :

[0122] w = σ(W2ReLU(W1s+b1)+b2)

[0123] in, b2∈R Hσ(·) is the Sigmoid activation function used to normalize the channel weights. Finally, feature recalibration is achieved by applying the weights w to each channel of the original feature F.

[0124] F′=F⊙w

[0125] Here, ⊙ represents the element-wise multiplication operation by channel, and F′ is the weighted feature vector. This mechanism enables the network to dynamically focus on key features related to citrus trees, thereby improving the robustness and accuracy of segmentation in different scenarios.

[0126] After processing by the encoder and channel attention module, the feature vector of each point has fused geometric information, color information, and global context. To achieve semantic segmentation of the citrus tree and the background, TreeSegNet uses a classification layer to predict the category of each point. The classification layer of the network consists of two fully connected (linear) layers. The first layer maps the feature dimension from the hidden dimension H to 64 dimensions and increases the non-linear representation capability through the ReLU activation function; then a dropout layer (dropout rate of 0.1) is added to suppress overfitting, and the last layer linearly maps to the number of categories C=2 (background and citrus tree), outputting the predicted score of each point belonging to each category.

[0127] Let the weighted eigenvectors be F′∈R N×H The mapping of the classification layer can be represented as:

[0128] Y=Linear2(Dropout(ReLU(Linear1(F′)))),Y∈R N×C

[0129] Then, the category decision is made by taking the maximum predicted score for each point:

[0130]

[0131] Among them, y i This represents the predicted category label for the i-th point. The final point cloud segmentation result can be directly used to generate a color mask or calculate the average distance between citrus trees, providing a real-time distance reference for the variable spraying system.

[0132] To verify the effectiveness and superiority of the TreeSegNet model proposed in this invention in point cloud segmentation tasks, this section compares the performance of several classic point cloud segmentation models, including PointNet, PointNet++, and DGCNN. Experiments were conducted under the same dataset and parameter settings: 80 training epochs, batch size = 4, learning rate = 0.001, Adam optimizer, and 2048 downsampled points. A comprehensive evaluation was performed based on segmentation accuracy, loss value, and model parameter count. To ensure the fairness of the comparison, see attached... Figure 6 As shown, models with similar parameter counts were selected, thus simplifying the network structures of PointNet, PointNet++, and DGCNN to achieve a similar parameter scale to TreeSegNet.

[0133] As attached Figure 7 Appendix Figure 8 and attached Figure 9 As shown, the comparison results of different point cloud segmentation models are presented, including parameter count, accuracy, and loss value. Among all models, the TreeSegNet model proposed in this invention performs best in both accuracy and loss value, achieving an accuracy of 90.17%, a significant improvement compared to other models. For example, the accuracies of PointNet and PointNet++ models are 84.58% and 84.41%, respectively, while the accuracy of DGCNN is 88.59%. Although TreeSegNet has 35,971 parameters, slightly more than PointNet and PointNet++, its significant performance improvement demonstrates that more parameters can effectively improve the segmentation accuracy of the model. Furthermore, TreeSegNet's loss value of 0.2625, compared to DGCNN's 0.2888 and PointNet++'s 0.4186, shows better fitting ability. The lower loss value indicates that TreeSegNet can better fit the data during training, thus providing higher accuracy. Overall, TreeSegNet outperforms existing point cloud segmentation models in both segmentation accuracy and loss value, demonstrating its superiority in point cloud segmentation tasks.

[0134] To verify the effectiveness of each module in the model of this invention, an ablation experiment was conducted to sequentially remove the EdgeConv local feature extraction module, the Squeeze-and-Excitation (SE) feature channel attention module, and the Encoder module, and to analyze the impact of these modules on model performance. The experiment was conducted under the same dataset and parameter settings, with 80 training epochs, a batch size of 4, a learning rate of 0.001, an Adam optimizer, and 2048 downsampling points.

[0135] As attached Figure 10 As shown, there is a white support pole between two citrus trees. When manually labeling the point cloud, this part was labeled as the red point cloud of the external environment. Because part of the support pole is obscured by the branches of the citrus trees, some areas in the point cloud were mislabeled.

[0136] In the complete TreeSegNet model, as shown in the attached figure Figure 11 As shown, the point cloud segmentation effect is good, with only a small error at the junction of the support rod and the tree branch.

[0137] However, removing the EdgeConv module reduced the number of parameters by approximately 10,000, but the model's accuracy decreased by 4.09%, while the loss increased by 0.1165. (See attached image.) Figure 12 As shown, the model's ability to identify the point cloud of the white support poles decreased, with some support pole point clouds being misidentified as citrus tree point clouds. Without the EdgeConv module, the model cannot directly learn local geometry through neighborhood information, resulting in an inaccurate understanding of the point cloud spatial structure and thus affecting the segmentation results.

[0138] Removing the SE module weakens the model's regularization ability, potentially leading to overfitting, especially with limited training data or high data noise. Although the Dropout layer provides some regularization, the model still exhibits strong responses to irrelevant features in high-dimensional space without the SE module. (See attached image) Figure 13 As shown, the model's ability to classify the point cloud of the white support rod further declined, with the accuracy rate decreasing significantly by 2.83%, resulting in a worse classification effect.

[0139] The encoder layer is a crucial module in the model responsible for extracting global features. It transforms the input data through multiple fully connected (FC) layers, mapping point cloud features (including spatial coordinates and color information) to a higher-dimensional feature space, thereby helping the model extract discriminative global information. Removing the encoder layer significantly reduces the model's ability to extract global information, resulting in a substantial impact on overall performance. (See attached image) Figure 14 As shown, removing the Encoder layer further reduced the accuracy by 3.59%, and the model's classification results declined further.

[0140] In summary, the importance of each module in the model is evident. The EdgeConv module is crucial for local feature extraction, the SE module plays a significant role in regularization and feature channel adjustment, while the Encoder layer is the core module for global feature extraction. Removing any of these modules will lead to a significant decrease in model performance.

[0141] The experiment was conducted in a greenhouse at the Nongtangqiao Citrus Orchard in Jinshan District, Shanghai. A depth camera was mounted on a sprayer, approximately 1 meter above the ground. The camera resolution was set to 640×480, the frequency to 30Hz, and the distance to the camera ranged from 0.5 meters to 3 meters. Depth video and RGB video were used to generate point cloud data, which was then voxel-sampling followed by point cloud segmentation using a TreeSegNet model. To comprehensively evaluate the distance measurement performance of the depth camera in a real-world spraying environment, two typical test conditions were designed: static distance measurements and dynamic non-orthogonal continuous distance measurement experiments. The experiments were conducted by manually controlling the sprayer, using the depth camera to collect depth information and record the corresponding distance measurement results.

[0142] With the sprayer stationary, point it directly at the center of the single citrus tree, as shown in the attached diagram. Figure 15 Appendix Figure 16 Appendix Figure 17 and attached Figure 18 As shown, the distance between the camera and the target tree was adjusted sequentially (1.6 meters, 2.0 meters, 2.6 meters, 3.0 meters), and measurements were taken from different angles. The distance between the camera and the tree was measured using the TreeSegNet model, and the ground truth values ​​were recorded using a measuring tape for comparison.

[0143] The sprayer was controlled to slowly approach the tree from a distance of about 2.7 meters (approximately 1.8 meters) at a constant speed, continuously collecting depth data during its movement to obtain a distance change curve from far to near. A measuring tape was also used to measure the distance of several citrus trees along the sprayer's path for comparison.

[0144] The ranging results of the TreeSegNet model in a stationary state are shown in the attached figure. Figure 19 As shown, the recognition results are displayed at different distances. The horizontal axis represents the distance between the sprinkler head and the fruit tree predicted by the TreeSegNet model of this invention (unit: meters), and the vertical axis represents the actual distance measured with a measuring tape (unit: meters), covering a working range of approximately 0.5 to 3.0 meters. Pixel-level reading and linear regression analysis of the data in the figure yielded a fitted line between the predicted and actual values ​​of approximately: y = 0.983x + 0.045 (y is the measured value, x is the model predicted value). The slope is close to 1, and the intercept is close to 0, indicating that there is a basic one-to-one correspondence between the model output and the actual distance. Further calculations show that the Pearson correlation coefficient between the two is approximately 0.996, and the corresponding coefficient of determination R0 is... 2The mean square error (MSE) of approximately 0.99 indicates a very high consistency and linear correlation between the predicted and measured values ​​across the entire measurement range. Regarding error statistics, comparing the predicted and measured values ​​for each measurement point in the graph yields an average absolute error of approximately 0.05 m and a root mean square error of approximately 0.07 m. The error distribution shows that approximately 50% of the sample errors are less than 0.04 m, 90% are less than approximately 0.12 m, and the maximum error is controlled within approximately 0.20 m. These results demonstrate that the TreeSegNet-based point cloud ranging method proposed in this invention can stably and accurately estimate the true distance between the sprinkler head and the fruit tree within a working range of 0.5–3.0 m. The ranging results are consistent with the measured height using a measuring tape, providing a reliable distance input for variable spray control.

[0145] Before the experiment, the distances between three citrus trees along the diagonal path of the sprayer and the D456 camera were measured: 2 meters, 2.4 meters, and 2.7 meters. (Attached) Figure 20 This diagram shows the changes in distance between the sprayer and citrus trees recorded under continuous oblique travel conditions, with the tree positions marked on the graph. The graph clearly shows a gradual decrease in distance at 2 meters, 2.4 meters, and 2.7 meters, consistent with the requirements for real-time distance measurement by the camera. (Attached) Figure 21 This shows the distance change during the sprayer's reverse movement. The curves show similar patterns at the 2.7m, 2.4m, and 2m positions. The distance increases and then decreases as the sprayer moves towards and away from the citrus trees. This phenomenon verifies the accuracy of the distance measurement procedure.

[0146] Example 2:

[0147] An integrated application of a multi-nozzle regionalized variable spray distance estimation system based on TreeSegNet. This embodiment, building upon Embodiment 1, presents a specific application method for integrating a TreeSegNet-based fruit tree point cloud ranging method with a multi-nozzle variable spray control system. It focuses on the multi-range measurement region division, spatial coordinate calibration, distance calculation formula, and coupling process with the spray volume control model. This method is applicable to wind-driven or air-assisted sprayers used in typical citrus orchard row-to-row operations. In this embodiment, three sets of nozzles (numbered No.1, No.2, and No.3) are vertically distributed on one side of the spray bar of the sprayer, with a vertical spacing of approximately 0.35m between the nozzles. A depth camera is fixedly installed in front of the spray bar to acquire the 3D point cloud and color information of the citrus canopy on one side of the tree row. The sprayer's travel speed is set to 0.6m / s, applicable to tree heights of approximately 1.5–3.0m and row spacing of approximately 3.5m, covering most facility-grown citrus orchards and open-field dwarfing cultivation scenarios.

[0148] Regarding hardware installation and coordinate system setup, in this embodiment, the depth camera is installed at a position 1.2m above the ground at the front end of the spray boom, such as... Figure 1 As shown, the camera's optical axis is arranged horizontally along the direction of the sprayer's movement, and the horizontal distance between the center line of the camera's optical axis and the plane of the spray boom is approximately 0.5m. A frame coordinate system O is established with the center of the sprayer frame in mind. s -X s Y s Z s , where X s Along the direction of travel, Y s The axis is vertically upward, Z s The axis points to the left row of citrus trees; the camera coordinate system O is established with the optical center of the depth camera as the reference point. c -X c Y c Z c Z c The axis represents the line of sight in front of the camera. By using a calibration plate and the least squares method to solve for the extrinsic parameters, the rigid transformation matrix from the camera coordinate system to the gantry coordinate system can be obtained. Translation vector For any cloud point p in the depth camera coordinate system c =[x c ,y c ,z c ] T Its coordinates p in the frame coordinate system s =[x s ,y s ,z s ] T It can be represented as:

[0149] p s =Rp c +t

[0150] Using this transformation relationship, the point cloud segmentation results output by TreeSegNet can be uniformly mapped to the coordinate system of the sprayer itself, achieving spatial alignment with the nozzle placement position.

[0151] In the data acquisition and preprocessing stage, this embodiment also utilizes a depth camera to simultaneously acquire depth images and RGB color images at 640×480 pixels and a frame rate of 30 FPS, with the effective depth range set to 0.5–3.0 m. Using the camera's intrinsic parameters, the depth value d(u,v) of each pixel (u,v) is converted into three-dimensional coordinates (x, y). c ,y c ,z c This is then fused with the corresponding RGB components (r, g, b) to form a six-dimensional feature point (x). c ,y c ,z c(r, g, b). Then, based on the aforementioned rigid body transformation, the point cloud is transformed to the gantry coordinate system to obtain a unified scene point cloud. To meet the input requirements of TreeSegNet, this embodiment adopts a voxel grid downsampling strategy to compress the original hundreds of thousands of points to about 2048 points. After removing invalid points with a distance of less than 0.4m or greater than 3.2m, the remaining point cloud is normalized and abnormal noise is removed to ensure that the input data has good numerical stability under different operating scenarios.

[0152] like Figure 2 As shown, in this embodiment, the preprocessed point cloud is input into the TreeSegNet lightweight point cloud segmentation network for point-by-point semantic classification. The network structure is basically the same as in Embodiment 1, adopting a four-stage structure of encoder-local feature extraction-channel attention-classification. Let the input point cloud features be... The encoder maps the feature space to a high-dimensional feature space through two layers of linear transformation combined with ReLU and BN, resulting in H1, i.e.:

[0153] H1 = ReLU(BN2(XW2+b2))

[0154] Where W2 and b2 are learnable parameters. Subsequently, the EdgeConv local feature extraction module constructs a local graph structure based on K-nearest neighbors, and extracts features for each point h. i and its neighborhood Perform edge convolution operations:

[0155]

[0156] Where φ(·) represents a multilayer perceptron, [·,·] represents feature concatenation, and max· is channel-wise max pooling used to aggregate the most salient local features. The channel attention module globally weights the output features by channel to obtain weighted features. Finally, a two-layer fully connected classification head outputs the probability distribution of each point belonging to "fruit tree" or "background," and cross-entropy loss is used for training. After TreeSegNet inference, the target fruit tree point cloud set is obtained.

[0157] To ensure tight coupling with the real-time variable spray control logic of the nozzles, this embodiment divides the target fruit tree point cloud into multiple regions in the frame coordinate system, so that each region corresponds one-to-one with a specific nozzle or nozzle group on the spray boom. For example... Figure 1 As shown, the sprayer travels in the X direction. s The axis is the distance direction, with Y as the reference point. s The axis is in the height direction, with Z as the axis. s The axis is in the horizontal direction. This embodiment only considers a single row of tree canopies on the left side of the sprayer, therefore, in Z... sOn-axis defined region Z min ≤z s ≤Z max Z min Take 0.6m, Z max A distance of 1.5m is used to cover the typical range of the spray boom from the tree trunk. Vertically, the range is divided into three sub-zones based on the nozzle center heights H1, H2, and H3, and the spray angle:

[0158] Ω1={p s =(x s ,y s ,z s ) T |H1-ΔH / 2≤y s

[0159]

[0160] Where ΔH is the height of the spray coverage area, which is taken as 0.6m in this embodiment. For each area Ω i Then, along with the lateral range of the tree canopy [Z] min Z max The constraints intersect to form the final effective ranging area.

[0161]

[0162] Therefore, each nozzle corresponds to a spatially finite point cloud of fruit trees, which is used to calculate the distance between the local canopy and the nozzle.

[0163] Regarding distance calculation, this embodiment assumes the sprayer's travel direction is X. s The axis is the direction of the distance to be measured, therefore the area Inner point cloud in X s The coordinate values ​​on the axis can approximate the instantaneous interval between the sprinkler and the local canopy. If the area... Contains N i If there are 1 valid point, then the original average distance of the region is... It can be represented as:

[0164]

[0165] To suppress the influence of occasional noise points and missegmentation points, this embodiment adopts a robust ranging method combining truncated mean and median: First, the mean and median are combined... Sort the samples from smallest to largest, remove the extreme values ​​at both ends (10% at each end), and calculate the cutoff mean on the remaining samples. Simultaneously calculate the median. Final distance estimate d i for:

[0166]

[0167] Where λ∈[0,1] is the balance coefficient, and in this embodiment, λ=0.6 is taken. When the number of effective points N in a certain region i Less than threshold N min When the value is typically 30, it is determined that there are currently no valid canopy targets in the area, and a null value or the default safe distance d is output. safe In subsequent control, the corresponding nozzle will be shut down or the spray volume will be reduced to a minimum.

[0168] Considering the instantaneous fluctuations in distance measurement during the sprayer's movement, this embodiment employs an exponential moving average filter to smooth the distance measurement results for each region over time. Let the instantaneous distance estimate for region i in frame k be d. i [k], then the smoothed output satisfy:

[0169]

[0170] Where α∈(0,1] is the smoothing factor, and in this embodiment, α=0.3 is taken. If invalid ranging occurs in the current frame (e.g. If the number of internal points is insufficient or the confidence level of TreeSegNet is low, the smoothing result of the previous frame will be maintained to avoid drastic fluctuations in the injection volume. Through this time-domain filtering strategy, at a frame rate of 30fps and a travel speed of 0.6m / s, the distance curve remains continuous and smooth on the time scale, which facilitates stable PWM control by the injection volume controller.

[0171] Regarding the spray volume control model, this embodiment employs a multi-nozzle variable spray strategy that combines distance and point cloud density adjustment. For example... Figure 1 As shown, the smooth distance of each region is obtained. Simultaneously, the spatial density ρ of the fruit tree point cloud within each region is calculated. i , where ρ i It can be approximated by the following formula:

[0172]

[0173] V i For the region The volume formed by the nozzle and a certain thickness ΔX in front of the camera is taken as ΔX = 0.4m in this embodiment. The target spray flow rate Q of nozzle No.i is... i The following normalization form can be adopted:

[0174]

[0175] Among them, Q min With Q maxThese represent the minimum and maximum spray volumes for a single nozzle, respectively. `clip(x,0,1)` restricts `x` to the interval [0,1]. min ,d max ρ represents the lower and upper limits of the distance to the working area, which are taken as 0.7m and 3.0m respectively in this embodiment; min ,ρ max These are the upper and lower limits of canopy point cloud density obtained from experimental statistics. Finally, the jet volume controller is based on Q... i Value conversion of PWM duty cycle u i :

[0176]

[0177] Q rated This is the nominal flow rate of the nozzle at rated pressure. Through the above-mentioned joint control strategy, when the tree canopy is close to the nozzle and the point cloud density is high, the spray volume will increase accordingly; when the distance is far, or the canopy is sparse, or even there are empty rows of trees, the spray volume will automatically decrease or the nozzle will be turned off, thereby achieving on-demand spraying.

[0178] To verify the effectiveness of multi-nozzle regionalized distance measurement and variable spray control in this embodiment, a comparative field experiment was conducted in the same citrus greenhouse as in Example 1. Two operating modes were set up: a "constant spray volume mode" and a "TreeSegNet variable spray volume mode." The spray pressure was 0.3 MPa, and the sprayer travel speed was 0.6 m / s. Water-sensitive paper was placed at different heights inside and outside the tree canopy to statistically analyze the distribution of pesticide deposition. To evaluate the distance measurement accuracy of TreeSegNet, manual distance measurements were taken at several selected operating points using a measuring tape to obtain the actual distances. The camera-network joint ranging result is denoted as The mean square error (MSE) and mean absolute percentage error (MAPE) of ranging are defined as follows:

[0179]

[0180] Where M represents the number of test samples. Experimental results show that the MSE of multi-area ranging in this embodiment is controlled within 0.012m, and the MAPE is below 3.5%, which is basically consistent with the accuracy level of single-area ranging in Example 1. Regarding spraying effect, the effective pesticide application rate of the water-sensitive paper across the entire tree canopy under variable spray volume mode is not significantly different from that under constant volume mode (difference less than 3%), but the pesticide application area of ​​the water-sensitive paper between rows and on the ground decreases by more than 20%, and the total pesticide usage per unit operating area decreases by an average of about 18% to 22%. This demonstrates that this embodiment can significantly reduce ineffective spraying and pesticide waste while ensuring target coverage.

[0181] As can be seen from Example 2 above, by refining the distance measurement results to spatial regions that correspond one-to-one with the nozzle layout and introducing canopy structure parameters such as point cloud density, a multi-nozzle variable spray control scheme that balances real-time performance, precision, and hardware feasibility can be constructed. This example not only demonstrates the engineering feasibility of the present invention in complex citrus orchard scenarios but also shows that the lightweight point cloud segmentation and regional distance measurement technology proposed in this invention can be directly embedded into existing orchard spraying equipment to achieve integrated closed-loop control of "distance measurement—tree identification—spray control," providing a reference path for subsequent promotion and application on other fruit tree species (such as apples, pears, grapevines, etc.).

[0182] Example 3:

[0183] Distance estimation of orchard point clouds based on multi-frame spatiotemporal fusion and motion compensation. This embodiment is a further optimized solution based on Embodiments 1 and 2, focusing on the problems of large speed variations of sprayers in complex orchard environments, significant frame vibration, and susceptibility of single-frame point clouds to occlusion and missing data. It introduces a multi-frame spatiotemporal fusion and motion compensation strategy to enhance the distance measurement results of orchard point clouds based on TreeSegNet, thereby maintaining high distance measurement stability and accuracy under higher speeds and more complex terrain conditions. This embodiment still uses citrus orchard plant protection spraying as a typical application scenario, extending the sprayer speed range to 0.4–1.2 m / s, suitable for sloping orchards, undulating terrain, and medium-to-tall citrus trees with more irregular tree shapes. The depth perception and point cloud segmentation process is basically the same as the previous embodiments, but new steps such as multi-frame point cloud fusion, motion compensation, and adaptive weight calculation are introduced in step S6 "Regionalized Distance Calculation" and step S7 "Validity Determination and Anomaly Handling".

[0184] In terms of hardware configuration, this embodiment further adds a motion state sensing module based on the depth sensing module and data processing module described in Embodiment 1. The motion state sensing module includes an encoder mounted on the sprayer's drive wheel and an IMU (Inertial Measurement Unit) fixed on the frame. Both communicate with the embedded processing unit via a CAN bus or serial port to acquire the sprayer's linear velocity v(t), heading angle θ(t), and rate of change in real time during operation. The system still establishes a sprayer frame coordinate system O. s -X s Y s Z s And depth camera coordinate system O c -X c Y c Z c Based on the calibration completed in Example 1, the rigid body transformation from the camera coordinate system to the frame coordinate system is denoted as:

[0185] Simultaneously, a global fusion coordinate system O is established with the position of the sprayer at time t0 as a reference. g -X g Y g Z g It is used for unified registration of point clouds across multiple frames.

[0186] To achieve multi-frame spatiotemporal fusion, this embodiment specifies the arrival time t of each frame of data. k (k = 0, 1, ..., K) Records the attitude information of the sprayer {x s (t k ),y s (t k ),θ(t k )}, where (x s ,y s Let t represent the translation coordinates of the frame in the horizontal plane, and θ be the heading angle. Assuming that the sprayer's motion is primarily planar within a local time window, then at any time t... k The pose from the lower frame coordinate system to the global fused coordinate system can be represented as a homogeneous transformation matrix.

[0187]

[0188] Among them, h s The height of the rack origin relative to the ground can be obtained during the calibration phase. For time t... k Any cloud point captured by a depth camera Firstly, through Transform to rack coordinate system, and then through Transforming to the global fused coordinate system, we get:

[0189]

[0190] Through the above two-level coordinate transformation, multiple frames of point clouds within a time window can be unified into the same global coordinate system, thereby superimposing observations of the same fruit tree from different perspectives in space, enhancing the integrity and robustness of the canopy point cloud.

[0191] After completing multi-frame point cloud registration, this embodiment performs spatiotemporal fusion on the target fruit tree point cloud based on the TreeSegNet point cloud segmentation output. Specifically, for the time window [t] k-K+1 ,t k Within a given set of K consecutive frames of data, TreeSegNet is first used to perform semantic segmentation on the point cloud of each frame, resulting in separate target tree point cloud sets. (j=0,…,K-1), and unified to the global fusion coordinate system through the above transformation. Let the point cloud of all target fruit trees within the fusion window be denoted as .

[0192]

[0193] Then, based on the nozzle arrangement, multiple ranging areas that are the same as or similar to those in Example 2 are defined in the global coordinate system. (e.g., divided by height and lateral position), and The point in it is based on its (X) g ,Y g Z g The coordinates are divided into different regions to construct a multi-frame fused regional fruit tree point cloud.

[0194] Regarding distance calculation, this embodiment addresses each ranging area. It retains the idea of ​​single-frame robust statistics (combining truncated mean and median) from Example 2, and introduces an adaptive weighted fusion mechanism in the time dimension. Let the m-th frame within the time window be in the region... The effective number of point clouds within is Its single-frame distance estimate in the direction of travel is It can be obtained according to the method of Example 2:

[0195]

[0196] in This is the cutoff mean after removing the extreme values ​​at both ends. The median is λ, and the balance coefficient is λ. To comprehensively utilize information from multiple frames, the final value at time t is... k Output fusion distance Defined as:

[0197]

[0198] in, The time-quality weight of the m-th frame in region i.

[0199] Time-quality weight Taking into account both observation freshness and regional point cloud quality, it can be expressed as:

[0200]

[0201] Where β>0 is the time decay coefficient, exp(-β(t) k -t m This is used to reduce the impact of earlier frames on the current distance; This is a quality factor used to characterize the ranging reliability of the current frame. It can be calculated based on the number of valid points in the region and the class confidence score output by TreeSegNet. For example:

[0202]

[0203] Where N ref For reference points, σ tree (p) represents the predicted probability that point p is classified as a fruit tree, and clip(·) restricts the ratio to [0,1]. This definition ensures that when the point cloud in a given region is sparse or the network confidence is low in a particular frame, its weight in multi-frame fusion is automatically reduced, thus preventing unreliable observations from adversely affecting the final ranging result.

[0204] Considering the potential systematic biases of depth cameras at different distances, this embodiment adds a distance error compensation step based on a calibration curve after multi-frame fusion. Before system deployment, several known distance d points are set up in the experimental site. true The calibration target board records the TreeSegNet ranging output. And the least squares method is used to fit linear or quadratic polynomial compensation models, for example:

[0205]

[0206] Where a0, a1, and a2 are the compensation coefficients obtained from the fitting. In actual operation, the multi-frame fusion results for each ranging region are... Substituting into the above model, we can obtain the final distance d after compensation. i,corr (t k For scenarios with a narrow range of distances or where the calibration results show a good linear relationship, a2 can be set to 0, and a simple first-order linear compensation can be used to reduce the complexity of embedded implementation.

[0207] In step S7, validity determination and anomaly handling, this embodiment extends single-frame anomaly detection to multi-frame consistency determination. On one hand, it still checks the number of valid points in each ranging region of each frame. and original distance Perform threshold judgment, when or When the observation exceeds the physically feasible range, the frame is marked as an anomalous observation and assigned a weight close to 0 during multi-frame fusion; on the other hand, a time series smoothing constraint is introduced for the fused distance series d. i,corr (t) Calculate the rate of change |d| between two adjacent frames i,corr (t k )-d i,corr (t k-1 When it exceeds the maximum travel speed v of the sprayer max The derived theoretical upper limit Δd max =v max (t k -t k-1When ∈, it is determined that there may be a sudden ranging anomaly in the current frame. The system can choose to retain the result of the previous frame or use local median filtering for correction, where ∈ is a safety margin considering tree shape changes and sensor noise. Through this multi-frame consistency determination mechanism, distance abrupt changes caused by short-term occlusion, direct sunlight, or rack vibration can be effectively suppressed.

[0208] After completing the multi-frame spatiotemporal fusion and anomaly processing described above, the final distance d of each ranging region is... i,corr (t k The data is output to the spray control unit via the communication interface module according to the predetermined data format. For the multi-nozzle variable spray control model given in Example 2, this example can directly replace the original single-frame or simple smoothed distance input with the compensated distance, thereby improving the stability and accuracy of the controlled object (distance signal) while maintaining the control logic unchanged. Experiments show that, under conditions where the driving speed is increased to 1.0 m / s and there are obvious gaps and local shading between fruit tree rows, the multi-frame spatiotemporal fusion and motion compensation strategy adopted in this example can reduce the standard deviation of regional distance measurement from approximately 4.5 cm in the single-frame scheme to approximately 2.0 cm, further reducing the mean square error of distance by approximately 30% to 40%. Compared with the constant spray mode, under the variable spray mode, the effective pesticide application rate of the water-sensitive paper within the canopy remains basically unchanged or even slightly improved, provided that the pesticide application rate per unit area is reduced by more than 15% in the variable spray mode. This verifies the engineering feasibility and technical advantages of this example under complex operating conditions.

[0209] In summary, this embodiment significantly improves the ranging stability and robustness of the invention in complex orchard scenarios such as high speeds and undulating terrain by introducing multi-frame point cloud registration based on the sprayer's motion state, spatiotemporal fusion ranging with time-quality joint weighting, and systematic error compensation based on calibration curves, without changing the TreeSegNet network structure. This scheme fully demonstrates the scalability of the invention's method in the integrated design of "algorithm-sensor-control," making the TreeSegNet-based orchard point cloud ranging system suitable not only for the standard citrus orchard scenario described in Embodiment 1, but also for actual plant protection operations with more complex driving conditions and stronger environmental disturbances. This provides a solid technical foundation for subsequent promotion to various fruit tree types such as apple orchards, pear orchards, and grape trellises.

[0210] This invention provides a method and system for measuring distances from fruit tree point clouds based on TreeSegNet. By introducing lightweight point cloud segmentation and ranging technology based on TreeSegNet, it effectively solves the problem of difficulty in obtaining the distance between sprinklers and fruit trees in real time and accurately in existing orchard plant protection. It achieves fine point cloud segmentation by fusing color and geometric features, significantly eliminating background interference and improving ranging accuracy and robustness in complex scenes. The lightweight network model can run in real time on an embedded platform, meeting the real-time requirements of operations. Regional distance calculation combined with sprinkler layout provides directly controllable multi-channel distance information for precise variable spraying. Simultaneously, the use of a single depth camera reduces system cost and integration difficulty, providing a reliable technical foundation for achieving efficient, pesticide-saving, and environmentally friendly precision plant protection operations.

[0211] Those skilled in the art will understand that, besides implementing the system and its various devices, modules, and units provided by this invention in the form of purely computer-readable program code, the same functions can be achieved entirely through logical programming of the method steps, making the system and its various devices, modules, and units of this invention function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system and its various devices, modules, and units provided by this invention can be considered as a hardware component, and the devices, modules, and units included therein for implementing various functions can also be considered as structures within the hardware component; alternatively, the devices, modules, and units for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0212] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.

Claims

1. A method for ranging fruit tree point clouds based on TreeSegNet, characterized in that, include: Step S1: Data acquisition and synchronization. Using a depth camera installed on the plant protection sprayer, simultaneously acquire depth images and registered color images of the target fruit trees. Step S2: Point cloud construction and feature fusion. Based on camera intrinsic parameters, the depth image is converted into three-dimensional point cloud data containing spatial coordinates. The RGB color information of corresponding pixels in the color image is associated with the three-dimensional point cloud data point by point to form orchard scene point cloud data with six-dimensional features. Step S3: Point cloud preprocessing, spatial cropping and downsampling are performed on the point cloud data of the orchard scene to obtain standardized point cloud data; Step S4: TreeSegNet semantic segmentation. The standardized point cloud data is input into the lightweight point cloud segmentation network TreeSegNet. TreeSegNet adopts a hierarchical structure of encoder, local feature extraction, channel attention and classification to perform point-by-point semantic classification on each point and output point cloud data labeled with fruit tree and background categories. Step S5: Extract point cloud of target fruit trees. Filter point clouds of fruit tree categories according to the category labels to form a subset of target fruit tree point clouds. Step S6: Regional distance measurement calculation. Based on the installation geometry of the depth camera and the sprayer, multiple distance measurement areas corresponding one-to-one with the nozzle arrangement are preset. The target fruit tree point cloud subset is divided into each distance measurement area, and the spatial distance between the target fruit tree point cloud and the sprayer in each distance measurement area is calculated. Step S7: Validity determination and anomaly handling. Determine whether the number of target fruit tree point clouds in each ranging area exceeds the preset threshold. If it does not exceed the threshold, output a null value or the default distance. Step S8: Output distance results. Output the distance results of each measuring area that has passed the validity determination to the spray controller or host computer.

2. The tree point cloud ranging method based on TreeSegNet according to claim 1, characterized in that, The point cloud preprocessing in step S3 further includes at least one of coordinate normalization, noise point removal, and ground stripping. The downsampling is either voxel grid downsampling or random downsampling, which unifies the number of point clouds to a preset range.

3. The tree point cloud ranging method based on TreeSegNet according to claim 1, characterized in that, In step S4, the encoder of TreeSegNet performs two-layer linear transformations on the six-dimensional features. After each layer of linear transformation, batch normalization and ReLU activation function processing are performed sequentially to obtain a compact high-dimensional feature representation. In step S4, the local feature extraction adopts the EdgeConv structure, selects the k nearest neighbors of each point by Euclidean distance, calculates the feature difference between the current point and the neighboring points and performs feature concatenation, and aggregates the local geometric features by max pooling after nonlinear transformation by multilayer perceptron.

4. The tree point cloud ranging method based on TreeSegNet according to claim 1, characterized in that, In step S4, the channel attention uses the SE module, which obtains the channel description vector through global average pooling, calculates the channel weights through two fully connected transformations and the Sigmoid activation function, and performs channel-level adaptive recalibration on the encoder output features.

5. The tree point cloud ranging method based on TreeSegNet according to claim 1, characterized in that, The spatial distance in step S6 is calculated as average distance, median distance, or a weighted fusion of the truncated mean and median. In the weighted fusion, the weight λ∈[0,1] of the truncated mean is calculated by removing 10% of the extreme values ​​at both ends.

6. The tree point cloud ranging method based on TreeSegNet according to claim 1, characterized in that, It also includes a multi-frame spatiotemporal fusion step: the linear velocity, heading angle and their rate of change of the sprayer are obtained through the encoder and inertial measurement unit, the point clouds of multiple frames within the time window are unified into the global fusion coordinate system, the target fruit tree point clouds after TreeSegNet segmentation of each frame are spatiotemporally fused, and the fusion distance is calculated using a time-quality weighted mechanism.

7. The tree point cloud ranging method based on TreeSegNet according to claim 6, characterized in that, In the time-quality weighted mechanism, the weight is the product of the time decay factor and the quality factor; the time decay factor adopts an exponential decay function, and the quality factor is calculated based on the number of valid points in the region and the class confidence score output by TreeSegNet.

8. The tree point cloud ranging method based on TreeSegNet according to claim 1, characterized in that, The exception handling in step S7 further includes: Distance abrupt change determination: When the rate of change of distance between adjacent frames exceeds the theoretical upper limit derived from the maximum driving speed of the sprayer, the result of the previous frame or local median filtering is used for correction.

9. A tree point cloud ranging system based on TreeSegNet, comprising the tree point cloud ranging method based on TreeSegNet as described in any one of claims 1-8, characterized in that, include: The depth sensing module includes a depth camera and a support structure. The support structure fixes the depth camera to the plant protection sprayer and faces the spray direction, for simultaneously acquiring depth images and color images of the orchard operation area. The data processing module includes an embedded processing unit and a memory. The memory stores a computer program. The embedded processing unit is used to convert a depth image into three-dimensional point cloud data and fuse it with RGB color information, and to preprocess the fused point cloud data. The point cloud segmentation module runs within the data processing module. It calls the stored TreeSegNet model parameters to perform semantic segmentation on the preprocessed point cloud and outputs point cloud data labeled with fruit tree and background categories. The distance calculation module runs within the data processing module. It presets a distance measurement area corresponding to the nozzle arrangement, extracts the point cloud of fruit trees in each distance measurement area and calculates the spatial distance, and determines the validity of the distance results. The communication interface module is used to send the distance result output by the distance calculation module to the spray controller or the host computer.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the tree point cloud ranging method based on TreeSegNet as described in any one of claims 1-8.