Method for pinching of facility tomato based on length of shoot and positioning of pinching point
By developing a method for removing branches from greenhouse tomatoes based on branch length and branch removal point location, and using an image dataset to train a model to identify and segment tomato branches, this method solves the problems of inconsistent length and low efficiency in traditional branch removal methods, and improves the accuracy and efficiency of branch removal.
Patent Information
- Application Number
- CN202311674566.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-07
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-12-07
AI Technical Summary
Traditional methods of removing side shoots from tomatoes make it difficult to standardize the length of the side shoots, resulting in low manual efficiency. When removing side shoots mechanically, the size of the side shoots affects the success rate and can easily damage the plant.
A method for removing branches from greenhouse tomatoes based on branch length and branch removal point localization is adopted. The target recognition and instance segmentation models are trained through image datasets to identify and segment tomato branches, calculate branch length and determine branch removal points.
It improves the accuracy and efficiency of mechanical pruning, reduces damage to plants, and achieves uniform control of pruning length.
Smart Images

Figure CN117649603B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of deep learning technology, specifically to a method for removing branches from greenhouse tomatoes based on branch length and the location of the branch removal point. Background Technology
[0002] Pruning is a crucial aspect of tomato cultivation management, and scientific pruning is a prerequisite for high tomato yields. Scientific pruning requires timely application. In the early stages of tomato plant growth, the volume of nutrient assimilation is relatively small; pruning too early can hinder root growth and development, easily leading to slow growth. However, pruning too late will cause nutrient depletion, affecting fruit setting and fruit enlargement.
[0003] Traditionally, tomato pruning is primarily done manually, with the "prune any fork you see" method making it difficult to standardize fork lengths, affecting plant growth, and resulting in a large workload and low efficiency. With the promotion of agricultural mechanization, mechanical pruning can standardize fork lengths, reduce costs, and improve efficiency. However, the size of the tomato forks also affects the success rate of mechanical pruning. Smaller forks are difficult for the mechanical claw to position, while longer forks develop fibrous tissue, increasing the difficulty of pruning and making the plant more susceptible to damage.
[0004] Therefore, how to achieve accurate pruning of tomatoes using mechanical equipment is a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0005] In order to solve the above-mentioned technical problems, this application proposes the following technical solution:
[0006] In a first aspect, embodiments of this application provide a method for pruning forcibly grown tomatoes based on branch length and pruning point location, including:
[0007] Based on the acquired image dataset of tomato plants, a target recognition model and an instance segmentation model are obtained.
[0008] When performing the tomato branch removal operation, the target recognition model is used to identify the entire tomato branch and then the recognition box is cropped. Then, the image within the recognition box is segmented by the instance segmentation model, and the mask of the main trunk of the tomato branch is output.
[0009] After binarizing the mask, the outline of the tomato branch trunk is obtained. The outline points are traversed to obtain the pixel coordinates of the two points with the farthest Euclidean distance. These two points are recorded as the two endpoints of the branch trunk.
[0010] The length of the main trunk and the length of the entire tomato branch are determined by the two endpoints of the main trunk, the identification frame, and the mask, respectively.
[0011] If the length of the entire tomato branch reaches the requirement for pruning, then pruning points are determined on the main trunk of the branch for pruning the tomato plant.
[0012] In one possible implementation, obtaining the target recognition model and instance segmentation model based on the acquired tomato plant image dataset includes:
[0013] Image data was collected from the branches of tomato plants grown in the greenhouse. After collection, the image sizes were standardized and the images were renamed and stored as the first image set.
[0014] The first image set was manually annotated using Labelme software. The first image set and the annotation files were then expanded to obtain the target recognition dataset.
[0015] The dataset is input into the Mask R-CNN algorithm for training to generate an object recognition model;
[0016] The images of the entire tomato branch are obtained by cropping the labeled files of the first image set, unifying the image size, renaming and storing them as the second image set;
[0017] The second image set is manually annotated. The second image set and the annotation files are expanded to obtain the instance segmentation dataset. The dataset is then input into the Mask R-CNN algorithm for training to generate the instance segmentation model.
[0018] In one possible implementation, the image annotation process is as follows:
[0019] For the first image set, the entire tomato branch is labeled using a bounding box method. For the second image set, the main stem of the tomato branch is labeled along its outline using a multi-line segment and multi-point method, and the two ends of the main stem are labeled along the protrusions.
[0020] In one possible implementation, obtaining the outline of the tomato branch trunk after binarizing the mask includes:
[0021] Binary mask: binary_mask = mask.astype(bool).astype(np.uint8) * 255
[0022] In the formula: mask.astype(bool) converts all non-zero values in the input segmentation mask to the boolean value True, and all zero values to the boolean value False; mask.astype(np.uint8) converts the boolean mask to an integer type, where True is mapped to 1 and False is mapped to 0; *255 multiplies all 1s in the integer mask from the previous step by 255, mapping them to 0 or 255, thus generating a binary mask.
[0023] In one possible implementation, obtaining the pixel coordinates of the two points with the greatest Euclidean distance by traversing the contour points includes:
[0024] Use the combination function to generate all possible combinations of points on the contour.
[0025] For each pair of points, use the np.linalg.norm function to calculate the Euclidean distance between them, find the two points that are farthest apart, and extract their pixel coordinates.
[0026] In one possible implementation, determining the length of the tomato branch trunk and the entire tomato branch length using the two endpoints of the trunk, the identification frame, and the mask respectively includes:
[0027] Use a depth camera to obtain the depth values of the two endpoints;
[0028] Convert the pixel coordinates of the two endpoints to camera coordinates, and the distance between the two endpoints is the length of the tomato branch trunk.
[0029] Then, based on the pixel height ratio of the recognition box and the mask, the length of the entire tomato branch is calculated.
[0030] In one possible implementation, the depth camera acquires the endpoint depth value by acquiring all depth values of a circle with a radius of 2 pixels surrounding the endpoint pixel coordinate, and taking the minimum non-zero value of all depth values as the depth value of the endpoint pixel coordinate.
[0031] In one possible implementation, converting the pixel coordinates of the two endpoints to camera coordinates includes:
[0032] The formula for converting pixel coordinates to camera coordinates is:
[0033]
[0034]
[0035] Cz = depth_value
[0036] In the formula, (pixel_x, pixel_y) are the input pixel coordinates, and intrinsics are the camera's intrinsic parameters, including the focal length (f). x and f y ), principal points (ppx and ppy), depth_value is the depth value at the pixel coordinates measured by the depth camera; (C x C y C z ) are the camera coordinates obtained after transformation.
[0037] In one possible implementation, the formulas for calculating the length of the main stem of the tomato branch and the total length of the tomato branch are as follows:
[0038]
[0039]
[0040] In the formula, (C x 1,C y 1,C z 1) (C x 2,C y 2,C z 2) These are the camera coordinates of the two ends of the tomato branch trunk, where distance is the length of the tomato branch trunk, tol_distance is the total length of the tomato branch, roi_y is the pixel height of the recognition box, and |y1-y2| is the pixel height of the two ends of the branch trunk.
[0041] In one possible implementation, if the length of the entire tomato branch meets the requirements for pruning, then a pruning point is determined on the main trunk of the branch for tomato pruning, including:
[0042] Multiple points are selected on average along the line connecting the two ends of the branch trunk. The distance between these points and the lower end is calculated. The points with a distance of a preset length are used as approximate branch removal points.
[0043] The median line of the tomato branch trunk is obtained based on the mask contour. The pixel point closest to the approximate branch removal point is found on the median line, and this point is determined as the final branch removal point.
[0044] The tomato plants are pruned according to the final pruning point.
[0045] In this embodiment, by determining the length of the main stem of the tomato branch and the length of the entire tomato branch, the timing of pruning is determined based on the length of the entire tomato branch, and the pruning point is located based on the length of the main stem of the tomato branch, thereby improving the accuracy of mechanical pruning. Attached Figure Description
[0046] Figure 1 A flowchart illustrating a method for pruning branches of greenhouse tomatoes based on branch length and pruning point location, provided for an embodiment of this application;
[0047] Figure 2 This is a schematic diagram of the first dataset annotation method provided in the embodiments of this application;
[0048] Figure 3 This is a schematic diagram of the second dataset annotation method provided in the embodiments of this application;
[0049] Figure 4 This is a schematic diagram illustrating the transformation between the pixel coordinate system and the camera coordinate system provided in an embodiment of this application. Detailed Implementation
[0050] The present solution will now be described in conjunction with the accompanying drawings and specific embodiments.
[0051] See Figure 1 The method for pruning branches in greenhouse tomatoes based on branch length and pruning point positioning provided in this embodiment includes:
[0052] S101, Based on the acquired image dataset of tomato plants, obtain the target recognition model and instance segmentation model.
[0053] Image data of tomato branches grown in a greenhouse was collected. After collection, the images were resized, renamed, and stored as the first image set. The first image set was manually annotated using Labelme software. The first image set and the annotation file were then augmented to obtain the target recognition dataset. This dataset was input into the Mask R-CNN algorithm for training to generate the target recognition model. Based on the annotation file of the first image set, the images of the entire tomato branch were cropped, resized, renamed, and stored as the second image set. The second image set was manually annotated. The second image set and the annotation file were then augmented to obtain the instance segmentation dataset. This dataset was input into the Mask R-CNN algorithm for training to generate the instance segmentation model.
[0054] See Figure 2 In this embodiment, bounding boxes are used to label the entire tomato branch in the first image set. See also... Figure 3 For the second image set, the main trunk of the tomato branches was marked along its outline using a multi-line segment and multi-point method, and the two ends of the main trunk of the branches were marked along the protrusions.
[0055] S102, when performing the tomato branch removal operation, the target recognition model is used to identify the entire tomato branch and then the recognition box is cropped. Then, the image within the recognition box is segmented by the instance segmentation model, and the mask of the main trunk of the tomato branch is output.
[0056] In this embodiment, the binarized mask is represented as:
[0057] binary_mask=mask.astype(bool).astype(np.uint8)*255
[0058] In the formula: mask.astype(bool) converts all non-zero values in the input segmentation mask to the boolean value True, and all zero values to the boolean value False; mask.astype(np.uint8) converts the boolean mask to an integer type, where True is mapped to 1 and False is mapped to 0; *255 multiplies all 1s in the integer mask from the previous step by 255, mapping them to 0 or 255, thus generating a binary mask.
[0059] S103. After binarizing the mask, obtain the outline of the tomato branch trunk. Traverse the outline points to obtain the pixel coordinates of the two points with the farthest Euclidean distance. Record these two points as the two endpoints of the branch trunk.
[0060] In this embodiment, the pixel coordinates of the two points with the greatest Euclidean distance are obtained by traversing the contour points, including: using the combination function to generate all possible combinations of points on the contour, using the np.linalg.norm function to calculate the Euclidean distance between each pair of points, finding the two points with the greatest distance and extracting their pixel coordinates.
[0061] S104, the length of the main trunk of the tomato branch and the length of the entire tomato branch are determined by the two endpoints of the trunk, the identification frame and the mask respectively.
[0062] Use a depth camera to obtain the depth values of the two endpoints; convert the pixel coordinates of the two endpoints to camera coordinates, and the distance between the two endpoints is the length of the main stem of the tomato branch; then calculate the length of the entire tomato branch based on the pixel height ratio of the recognition box and the mask.
[0063] In this embodiment, the depth camera obtains the endpoint depth value by acquiring all depth values of a circle with a radius of 2 pixels around the endpoint pixel coordinate, and taking the minimum non-zero value of all depth values as the depth value of the endpoint pixel coordinate.
[0064] The process of converting the pixel coordinates of the two endpoints to camera coordinates includes:
[0065] The formula for converting pixel coordinates to camera coordinates is:
[0066]
[0067]
[0068] Cz = depth_value
[0069] In the formula, (pixel_x, pixel_y) are the input pixel coordinates, and intrinsics are the camera's intrinsic parameters, including the focal length (f). x and f y ), principal points (ppx and ppy), depth_value is the depth value at the pixel coordinates measured by the depth camera; (C x C y C z ) are the camera coordinates obtained after transformation. Figure 4 In the diagram, O1-u1v1 is the pixel coordinate system of the detection box, O2-u2v2 is the pixel coordinate system of the camera, and Oc-XcYcZc is the camera coordinate system.
[0070] In this embodiment, the formulas for calculating the length of the main stem of the tomato branch and the total length of the tomato branch are as follows:
[0071]
[0072]
[0073] In the formula, (C x 1,C y 1,C z 1) (C x 2,C y 2,C z 2) These are the camera coordinates of the two ends of the tomato branch trunk, where distance is the length of the tomato branch trunk, tol_distance is the total length of the tomato branch, roi_y is the pixel height of the recognition box, and |y1-y2| is the pixel height of the two ends of the branch trunk.
[0074] S105, if the length of the entire tomato branch reaches the requirement for pruning, then determine the pruning point on the main trunk of the branch and perform pruning of the tomato plant.
[0075] Multiple points are selected on average along the line connecting the two ends of the branch trunk. The distance between each of these points and the lower end is calculated, and the point with a distance of a preset length is taken as the approximate branch removal point. The median line of the tomato branch trunk is obtained according to the mask contour. The pixel point closest to the approximate branch removal point is found on the median line, and this point is determined as the final branch removal point.
[0076] The formula for calculating the median line of the main stem of a tomato branch is:
[0077]
[0078] In the formula, (x, y) are the pixel coordinates of the midline, and x0 and x1 are the left and right x pixel coordinates of the mask outline when they have the same y value.
[0079] In this embodiment, an average of 10 points are selected on the line connecting the two ends of the branch trunk, and the distance between these points and the lower end is calculated. The point with the closest distance of 20mm is the approximate branch removal point. Finally, the optimal branch removal point is determined to be on the middle line of the branch trunk, 20mm away from the lower end of the tomato branch.
[0080] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, the simultaneous existence of A and B, or the existence of B alone. A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0081] The above description is merely a specific embodiment of this application. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the protection scope of this application. The protection scope of this application should be determined by the protection scope of the claims.
Claims
1. A method for pruning fortified tomatoes based on branch length and pruning point positioning, characterized in that, include: Based on the acquired image dataset of tomato plants, a target recognition model and an instance segmentation model are obtained. When performing the tomato branch removal operation, the target recognition model is used to identify the entire tomato branch and then the recognition box is cropped. Then, the image within the recognition box is segmented by the instance segmentation model, and the mask of the main trunk of the tomato branch is output. After binarizing the mask, the outline of the tomato branch trunk is obtained. The outline points are traversed to obtain the pixel coordinates of the two points with the farthest Euclidean distance. These two points are recorded as the two endpoints of the branch trunk. The length of the main trunk and the length of the entire tomato branch are determined by the two endpoints of the main trunk, the identification frame, and the mask, respectively. If the length of the entire tomato branch reaches the requirement for pruning, then pruning points are determined on the main stem of the branch for pruning the tomato plant, including: On average, select multiple points on the line connecting the two ends of the branch trunk, calculate the distance between these points and the lower end point, and use the points with a preset distance as approximate branch removal points; The median line of the tomato branch trunk is obtained based on the mask contour. The pixel point closest to the approximate branch removal point is found on the median line, and this point is determined as the final branch removal point. The tomato plants are pruned according to the final pruning point.
2. The method for pruning side branches of greenhouse tomatoes based on branch length and pruning point positioning according to claim 1, characterized in that, The step of obtaining the target recognition model and instance segmentation model based on the acquired tomato plant image dataset includes: Image data was collected from the branches of tomato plants grown in the greenhouse. After collection, the image sizes were standardized and the images were renamed and stored as the first image set. The first image set was manually annotated using Labelme software. The first image set and the annotation files were then expanded to obtain the target recognition dataset. The target recognition dataset is input into the Mask R-CNN algorithm for training to generate a target recognition model. The images of the entire tomato branch are obtained by cropping the labeled files of the first image set, unifying the image size, renaming and storing them as the second image set; The second image set is manually annotated. The second image set and the annotation files are expanded to obtain the instance segmentation dataset. The instance segmentation dataset is then input into the Mask R-CNN algorithm for training to generate an instance segmentation model.
3. The method for pruning side branches of greenhouse tomatoes based on branch length and branch pruning point positioning according to claim 2, characterized in that, The specific process of image annotation is as follows: For the first image set, the entire tomato branch is labeled using a bounding box method. For the second image set, the main stem of the tomato branch is labeled along its outline using a multi-line segment and multi-point method, and the two ends of the main stem are labeled along the protrusions.
4. The method for pruning side branches of greenhouse tomatoes based on branch length and pruning point positioning according to claim 1, characterized in that, The step of obtaining the outline of the tomato branch trunk after binarizing the mask includes: Binary mask In the formula: To convert all non-zero values in the input segmentation mask to the boolean value True, and all zero values to the boolean value False; Convert the mask of the boolean value to an integer type, where True is mapped to 1 and False is mapped to 0; Multiply all the 1s in the integer mask from the previous step by 255 to map them to 0 or 255, thus generating a binary mask.
5. The method for pruning side branches of greenhouse tomatoes based on branch length and pruning point positioning according to claim 4, characterized in that, The process of traversing the contour points to obtain the pixel coordinates of the two points with the greatest Euclidean distance includes: Use combination functions Generate all possible combinations of points on the contour; For each pair of points The function calculates the Euclidean distance between them, finds the two points that are farthest apart, and extracts their pixel coordinates.
6. The method for pruning side branches of greenhouse tomatoes based on branch length and pruning point positioning according to claim 1, characterized in that, The process of determining the length of the tomato branch trunk and the entire tomato branch length by using the two endpoints of the trunk, the identification frame, and the mask includes: Use a depth camera to obtain the depth values of the two endpoints; Convert the pixel coordinates of the two endpoints to camera coordinates, and the distance between the two endpoints is the length of the tomato branch trunk. Then, based on the pixel height ratio of the recognition box and the mask, the length of the entire tomato branch is calculated.
7. The method for pruning side branches of greenhouse tomatoes based on branch length and pruning point positioning according to claim 6, characterized in that, The depth camera obtains the endpoint depth value by acquiring all depth values of a circle with a radius of 2 pixels around the endpoint pixel coordinates, and taking the minimum non-zero value of all depth values as the depth value of the endpoint pixel coordinates.
8. The method for pruning fortified tomatoes based on branch length and pruning point positioning according to claim 6 or 7, characterized in that, The process of converting the pixel coordinates of the two endpoints to camera coordinates includes: The formula for converting pixel coordinates to camera coordinates is: In the formula, These are the input pixel coordinates. These are the camera's internal parameters, including focal length. and Main point and , It is the depth value at the pixel coordinates measured by the depth camera; () are the camera coordinates obtained after transformation.
9. The method for pruning side branches of greenhouse tomatoes based on branch length and pruning point positioning according to claim 8, characterized in that, The formulas for calculating the length of the main stem and the total length of the tomato branch are as follows: In the formula, ( ), ( ( ) represent the camera coordinates of the two ends of the main stem of the tomato branch. This refers to the length of the main stem of the tomato branch. This refers to the total length of the tomato branch. To identify the pixel height of the bounding box, The pixel height is the height of the two ends of the branch trunk.
Citation Information
Patent Citations
Tomato plant side branch pruning point identification method
CN115861795A
Tomato branch wiping robot, tail end manipulator and use method
CN116686576A
