Banana recognition and pose estimation method based on YOLOv7 rotation frame

By introducing the rotating frame and depth completion algorithm into the YOLOv7 model, the computing resource consumption and positioning error problems of banana identification technology in banana orchards are solved, and high-precision, real-time banana identification and pose estimation are achieved, which is suitable for intelligent fruit and vegetable management. .

CN117611966BActive Publication Date: 2024-10-11ZHONGKAI UNIV OF AGRI & ENG
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202311433481.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2024-10-11
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

Existing banana recognition technology has problems such as high computational resource consumption, low detection accuracy, difficulty in obtaining accurate three-dimensional information, and complex processing. Especially under the influence of tilt angle and background information in banana orchards, it leads to target positioning errors.

Method used

The identification method based on the YOLOv7 rotating frame is adopted, the rotation angle parameter and the GSConv module are added, the KLD regression loss function is used, and the depth camera is combined to obtain the three-dimensional coordinates, and the depth completion algorithm Criminisi is used to repair the holes to improve the accuracy of identification and positioning.

Benefits of technology

It improves the average accuracy and F1 value of banana recognition, reduces the model size, reduces positioning errors, and achieves lightweight, high-precision, real-time and robust banana recognition, which is suitable for fruit and vegetable management operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117611966B_ABST
    Figure CN117611966B_ABST
Patent Text Reader

Abstract

The invention discloses a banana recognition and posture estimation method based on a YOLOv7 rotating frame, comprising the following steps: (1) for a photographed banana tree image, a rotation angle parameter and a GSConv module are added on the basis of a YOLOv7 model to extract image features, enhance features, and perform fusion analysis on features using the GSConv module; (2) a banana stalk is located using a rotating bounding box to surround the shape of the banana, and the orientation of the banana is determined by the direction of the stalk, and a rotation angle parameter is set; (3) the rotation bounding box regression loss calculation is performed, and the angle parameter is regarded as a probability distribution to represent the possible rotation angle of the target; in the face of the discontinuity of the periodic angle parameter, a KLD method is used to measure the probability distribution difference between two adjacent periods, and the difference is used as a part of the loss function to repair the image. The method of the invention improves the accuracy of target positioning and recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image data recognition and analysis, and in particular relates to a banana recognition and posture estimation method based on a YOLOv7 rotation frame. Background Art

[0002] There are large areas of banana plantations in the southern region, often covering hundreds or thousands of acres. When bananas bear fruit, they form a large bunch of banana stems. During the growth stage, it is necessary to observe the growth status and tilt angle of the banana stems to prevent rotten and deformed fruits. It is also necessary to adjust the posture of the banana stems so that they can hang fruits vertically and receive sunlight evenly. Pruning and care management are required frequently. However, the intelligent management and automated harvesting technology of banana orchards still lag behind other fruits and vegetables. Therefore, fast and accurate detection of banana bunches and banana stems has become a key task in realizing intelligent management.

[0003] Vision-based fruit detection algorithms have also been used in the field of fruit and vegetable detection. Before the advent of deep learning technology, most fruit and vegetable detection methods were based on traditional machine learning algorithms. Most of these algorithms are based on manually designed features to locate the object area in the image. However, these methods often lack universality and robustness.

[0004] Most existing detection methods use axis-aligned bounding boxes to locate objects, but bananas in banana orchards are usually tilted at certain angles, and these algorithms cannot provide accurate orientation information. Using horizontal bounding boxes to detect bananas will contain more background information, resulting in reduced detection accuracy. At the same time, including a large amount of background information may cause errors in target positioning, especially in three-dimensional positioning, which may be more difficult.

[0005] In order to achieve more accurate object positioning, it is necessary to obtain the three-dimensional information of the actual center of mass of the object. However, it is still difficult for existing detection methods to obtain complete three-dimensional information. In order to reduce the computational complexity, the object can be simplified into a specific shape, such as a sphere or cylinder, and its two-dimensional center and other necessary parameters can be obtained through an improved target detection algorithm to calculate the three-dimensional position of the actual center of mass of the object. The center and length and width of the orange detection frame are obtained through the improved YOLOV4, and the radius of the orange is predicted through the projection principle, so as to calculate the three-dimensional position of the actual center of mass of the orange.

[0006] The above existing methods have the following problems in identifying the state of bananas: 1) The model of the method based on deep learning is large, which consumes a lot of computing resources and is difficult to meet the requirements of real-time performance and model deployment. 2) Unlike natural scene images, the banana stalks in actual banana orchards are tilted, and the horizontal bounding box may contain more background information, resulting in a decrease in detection accuracy. Due to the inclusion of a large amount of background information, errors in target positioning may occur, especially in three-dimensional positioning, where the estimation of the center of mass position may be more difficult. 3) When the RGBD camera acquires the depth image, due to the influence of various factors (such as illumination, occlusion, etc.), there are often holes in the depth image, that is, the depth information of some pixels is missing. This missing may lead to target positioning errors, especially in three-dimensional positioning, where the positioning error may be more obvious. Summary of the invention

[0007] In order to overcome the problems of the prior art, the present invention proposes a banana recognition and pose estimation method based on the YOLOv7 rotation frame, upgrades and improves the calculation method, adopts lightweight processing, solves the shortcomings of the YOLO v7 model when detecting single-category targets, such as too many redundant channels and low detection speed, improves the accuracy of target positioning and recognition, and constructs a banana recognition method with lightweight, high precision, real-time, strong robustness and high generalization, so as to ensure the quality of fruit management operations.

[0008] In order to realize intelligent management and monitoring of orchards, such as rapid identification and accurate positioning of bananas, and understanding of their growth conditions, the method of the present invention is of course not limited to banana identification, but can also be used for fruits, vegetables and other objects. The scheme of the present invention has made significant improvements to the existing YOLO v7 model. On the basis of the YOLOv7 model, a rotation angle parameter and a GSConv module are added, and the original SmoothL1 loss function is replaced by a KLD regression loss function; in the rotating target detection stage, the banana stem positioning point and the rotation angle are regressed, and the three-dimensional coordinates of the positioning point in the camera coordinate system are obtained by a depth camera, thereby improving the accuracy of target positioning and knowing the real growth conditions of bananas.

[0009] The present invention provides a banana recognition and posture estimation method based on a YOLOv7 rotating frame, comprising the steps of:

[0010] (1) For the banana tree image taken, the rotation angle parameter and GSConv module are added on the basis of the YOLOv7 model to extract image features and enhance features, and the GSConv module is used to perform feature fusion analysis;

[0011] (2) Use the rotating bounding box to locate the banana's stalk, enclose the shape of the banana, and determine the orientation of the banana by the direction of the stalk, and set the rotation angle parameter;

[0012] (3) Calculate the rotation bounding box regression loss, and regard the angle parameter as a probability distribution, which represents the possible rotation angle of the target. The discontinuity of the periodic angle parameter means that there is a sudden change in the probability distribution at the boundary of the periodic change. The KLD method is used to measure the difference in the probability distribution between two adjacent periods, and it is used as part of the loss function to repair the image.

[0013] After the features are fused and analyzed in step (1), three enhanced effective feature layers are obtained, each of which has a width, a height and a number of channels. The feature map is regarded as a set of many feature points. There are three prior frames on each feature point, and each of the prior frames contains features of the number of channels. It is then determined whether the prior frames on these feature points correspond to the objects in the image.

[0014] Furthermore, the method also includes the step of positioning the banana stalk, which can be approximately represented by a cylinder, establishing a three-dimensional camera coordinate system, simplifying the orientation of the banana stalk to only rotate around the z-axis of the camera coordinate system, and obtaining the posture of the banana relative to the three-dimensional camera coordinate system.

[0015] Furthermore, in step (3), the banana stalk location point and rotation angle are regressed in the rotating target detection stage using the KLD regression loss function, and the three-dimensional coordinates of the location point in the camera coordinate system are obtained through the depth camera.

[0016] Furthermore, the method also includes processing the image through the depth completion algorithm Criminisi to effectively repair the holes that appear during the positioning process.

[0017] The advantages of the system and control method of the present invention are:

[0018] 1) Through comparative tests, compared with the YOLOv7 model, the improved rotation YOLOv7 model of the present invention has increased the average accuracy of banana recognition by 17.04 percentage points, and the F1 value has increased by 40.5 percentage points; the model size has been reduced by 32.16MB. The improved model has been improved in terms of model size and average accuracy value, reducing memory loss during training, which is more conducive to the migration application of the model and enhancing the effect of outdoor real-time recognition. The improved model after training of the present invention has an average recognition accuracy of more than 95% for the banana test set data, which can understand the actual growth of bananas, ensure the quality of fruit management operations, and facilitate the estimation of yield.

[0019] 2) In the positioning test, the improved rotation YOLOv7 model can effectively predict the radius of the banana stem, and the mean error and error ratio of R-YOLOv7-tiny are 7.02mm and 0.65% respectively. Compared with the YOLOv7 model, the positioning error is reduced by 24.3mm and 1.96 percentage points respectively, and the depth completion algorithm Criminisi effectively repairs the holes that appear during the positioning process. The positioning test error of the improved model is the lowest, which further reduces the positioning error of the fruit stem axis at the bottom of the banana. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 Schematic diagram of a multi-branch stacking module (Muliti Concat Block).

[0021] Figure 2 It is a schematic diagram of rotation detection of the present invention.

[0022] Figure 3 Schematic diagram of the rotational bounding box of the present invention

[0023] Figure 4 The three-dimensional position calculation principle diagram of the present invention

[0024] Figure 5 It is a restoration schematic of criminisi.

[0025] Figure 6 Comparison chart of horizontal frame and rotation frame shot in 3D. DETAILED DESCRIPTION

[0026] The technical solution in the embodiment of the invention will be clearly and completely described below in conjunction with the drawings in this embodiment.

[0027] The present invention proposes a rotating target detection algorithm based on YOLO v7, which is aimed at the identification and position and posture positioning of bananas in a large area of ​​an orchard, and adopts lightweight processing to solve the shortcomings of the existing YOLO v7 model when detecting a single category target, such as more redundant channels and low detection speed. By using a target detection method based on a rotating frame, a more compact bounding box can be used to describe directional targets, and the banana stem, that is, the banana stalk, can be simplified into a cylinder. The information obtained by the rotating target detection algorithm is used to predict the position and posture of the actual center of mass of the banana stem; at the same time, a deep repair algorithm is used to fill the lack of depth information, thereby improving the accuracy of target positioning. A lightweight, high-precision, real-time, strong robustness, and high generalization banana recognition and positioning method is constructed.

[0028] The improved model can quickly and accurately identify and locate banana stems in orchard environments, ensuring operation quality and providing an effective solution for target positioning in complex scenarios.

[0029] The present invention provides a banana recognition and posture estimation method based on a YOLOv7 rotating frame, comprising the steps of:

[0030] (1) For the banana tree image taken, the rotation angle parameter and GSConv module are added on the basis of the YOLOv7 model to extract image features and enhance features, and the GSConv module is used to perform feature fusion analysis;

[0031] (2) Use the rotating bounding box to locate the banana's stalk, enclose the shape of the banana, and determine the orientation of the banana by the direction of the stalk, and set the rotation angle parameter;

[0032] (3) Calculate the rotation bounding box regression loss, and regard the angle parameter as a probability distribution, which represents the possible rotation angle of the target. The discontinuity of the periodic angle parameter means that there is a sudden change in the probability distribution at the boundary of the periodic change. The KLD method is used to measure the difference in the probability distribution between two adjacent periods, and it is used as part of the loss function to repair the image.

[0033] The sequence of the above steps can be changed according to actual conditions, and does not limit the core technical points protected by the present invention. The processing of the orchard banana picture is specifically described below in combination with actual conditions.

[0034] First, the network architecture of the improved R-YOLOv7 rotation target detection of the present invention is introduced.

[0035] The YOLOv7 model is mainly divided into three parts: Backbone, Neck and YOLO Head. The Backbone network is the key part responsible for feature extraction in the YOLOv7 model. It extracts features from the input image and generates a series of feature layers. These feature layers can be regarded as a feature set of the input image. In the construction of the Backbone network, we selected three effective feature layers as the basis for subsequent network construction. Neck is an enhanced feature extraction network of YOLOv7. It is used to fuse the three effective feature layers obtained in the backbone part to combine feature information of different scales. In Neck, the features are upsampled and downsampled to achieve the effect of feature fusion, and the GSConv module is added to fuse the features, while ensuring that the rich features are not lost, reducing the number of network parameters and the amount of calculation. YOLO Head is the classifier and regressor of YOLOV7. Through Backbone and Neck, three enhanced effective feature layers are obtained. Each feature layer has width, height and number of channels. We can regard the feature map as a collection of many feature points. There are three prior boxes on each feature point, and each prior box contains features with the number of channels. The task of YOLO Head is to determine whether the prior boxes on these feature points correspond to the objects in the image. Similar to the previous YOLO version, YOLOv7 adopts the structure of decoupled head, that is, classification and regression are completed together in a 1x1 convolutional layer. Therefore, the overall workflow of the YOLOv7 network can be summarized as feature extraction, feature enhancement and prediction of the object corresponding to the prior box.

[0036] The solution of the present invention adopts a multi-branch stacking module (Muliti Concat Block), which generates the final input by stacking multiple branches. Figure 1 As shown, the module contains four feature layers, which are processed by GSConv after stacking to achieve feature integration. This multi-branch stacked structure actually corresponds to a denser residual structure. The residual network is easy to optimize, and the accuracy can be improved by increasing the depth of the network. Inside the module, a residual block with jump connection is used to alleviate the problem of gradient disappearance in deep neural networks. The introduction of the multi-branch stacking module plays an important role in the present invention. By integrating the features of multiple branches, the model's representation ability and feature extraction ability for complex scenes can be improved. At the same time, the use of jump connections enables information to be directly transmitted to subsequent layers, which helps to improve the training effect and accuracy of the model, and introduces a new convolution method-hybrid convolution (GSConv).

[0037] The following describes the representation method of the rotated bounding box.

[0038] In view of the directional characteristics of banana stalks in banana orchards, a rotated bounding box is introduced to generate a directional detection box to more accurately describe the shape of the banana. The traditional YOLO series of methods use horizontal bounding boxes to enclose objects, ignoring the possible rotation or tilt characteristics of the objects. However, in banana orchards, the banana stalks usually have a certain rotation angle. Therefore, our method adopts the concept of a rotated bounding box to better adapt to the shape of the banana, such as Figure 2 As shown. A rotated bounding box is a bounding box that can be rotated, and its boundaries are not necessarily parallel to the horizontal and vertical directions of the image. By introducing a directional detection frame, we are able to more accurately enclose the shape of the banana, thereby providing more reliable detection results. For example, in a banana orchard, we can use a rotated bounding box to accurately locate the banana's stalk and determine the orientation of the banana by the direction of the stalk. A rotated bounding box is a bounding box that can be rotated, and its boundaries are not necessarily parallel to the horizontal and vertical directions of the image. By introducing a directional detection frame, we are able to more accurately enclose the shape and size of the banana, thereby providing more reliable detection results.

[0039] See also Figure 2 , Figure 3 In the method of the present invention, the object position is represented by a five-tuple (x, y, w, h, q) as a rotated bounding box, where (x, y) represents the center coordinates of the rotated bounding box, that is, the position of the target instance in the image. The parameter w represents the length of the short side of the rotated bounding box, h represents the length of the long side of the rotated bounding box, and the fifth parameter q represents the rotation angle of the target instance, that is, the angle of the long side relative to the horizontal x-axis.

[0040] The angle q is defined as the angle between the long side hle and the x-axis, and its value range is [-90°, 90). Among them, 90 degrees means vertically downward, and the clockwise direction is the positive direction. However, it should be noted that the boundary values ​​​​-90 degrees and 90 degrees actually coincide, but there is a 180-degree difference in value. This means that we need to handle the discontinuity of the boundary values ​​​​to ensure that the angle parameters of the rotated bounding box are correctly interpreted and calculated.

[0041] About rotated box regression loss calculation.

[0042] Compared with the YOLO series of horizontal target detection algorithms, the rotation target detection algorithm faces the challenge of learning periodic angle parameters. Since the angle parameters are periodic, that is, there is a discontinuity at the boundary of the periodic change, which may cause a sudden increase in the loss function value, thereby increasing the difficulty of learning and training the network. We use the KLD (Kullback-Leibler Divergence) divergence method, which is a method for measuring the difference between two probability distributions. In the rotation target detection algorithm, we can regard the angle parameter as a probability distribution, representing the possible rotation angle of the target. The discontinuity of the periodic angle parameter means that there is a sudden change in the probability distribution at the boundary of the periodic change. To overcome this problem, we can use the KLD method to measure the difference in probability distribution between two adjacent periods and use it as part of the loss function.

[0043] Most IoU-based losses can be viewed as distance functions. KLD is also a regression loss function based on Gaussian distance. First, we convert the center point coordinates, width, height, and angle information B(x, y, w, h, q) of the predicted box and the true box into a two-dimensional Gaussian distribution (m, S). The conversion process is expressed by the following formula:

[0044] μ=(x,y) T (1)

[0045]

[0046] Where R represents the rotation matrix and S represents the diagonal matrix of eigenvalues.

[0047] In formula (1), we regard the center point information of the target object as the position information of the two-dimensional Gaussian distribution. This means that we regard the center point of the target object as the mean of the Gaussian distribution. In formula (2), we use the rotation matrix to regard the width, height and angle information of the target object as the scale information of the two-dimensional Gaussian distribution. Through the transformation of the rotation matrix, we can map the rotated rectangular box to a two-dimensional Gaussian distribution.

[0048] By converting the target object into a two-dimensional Gaussian distribution, we can solve the problems of periodicity of angles and commutativity of boundaries. Since the two-dimensional Gaussian distribution is periodic and commutative, we can use the distance between the real box and the generated box in the two-dimensional Gaussian distribution as the regression loss. This loss function measures the difference between the predicted box and the real box in the two-dimensional Gaussian distribution. By minimizing this loss function, we can make the generated box better match the position and scale information of the real box. The position regression loss of the KLD loss function is expressed as:

[0049]

[0050] The KLD loss function is scale invariant, that is, the value of the loss function is the same at different scales, thereby reducing the impact of different prediction box sizes on the loss. In addition, when the aspect ratio of the target increases, the derivative of the KLD loss function pays more attention to the optimization of the angle, thereby reducing the impact of large angle differences on targets with large aspect ratios. Therefore, the KLD loss function is more suitable for detecting objects with large aspect ratios, such as banana stems and banana bunches, which can provide higher-precision detection results. The KLD loss function can effectively deal with targets of different scales and aspect ratios, provide accurate detection results, and improve the accuracy and robustness of detection.

[0051]

[0052] Where: D represents the Kullback-Leibler distance between two Gaussian distributions; m t ,Σ t Represents the Gaussian distribution after the real box transformation, m p ,Σ p Represents the Gaussian distribution after the prediction box conversion; L kld Represents the regression loss of the bounding box, where the nonlinear function sqrt() is used to transform the distance D to make the loss smoother, and t is a hyperparameter for adjusting the entire loss function.

[0053] The following introduces the design of the banana stalk positioning algorithm.

[0054] like Figure 4 As shown in the figure, the banana stalk can be approximately represented by a cylinder, point P is the central surface of the stalk, and the corresponding spatial point close to the projection center of the camera part, AB is the diameter of the stalk, represented by 2R, and its projection in the camera image coordinates is ab, represented by w, which is the two-dimensional image of the banana stalk projected on the camera plane. Through the realsense camera, the real depth value of P at the projection center of the outer surface of the stalk can be obtained, represented by z, and the real depth value of the centroid of the stalk is represented by z+R.

[0055] According to projection and similar triangles, we can get:

[0056]

[0057] From formula (5), we get f is the camera internal parameter, w is the width of the banana stem prediction box, z is the center of mass (x p ,y p ) The actual depth value of the geometric center of the fruit stalk can be expressed as z+R.

[0058] The transformation relationship between the pixel coordinate system and the camera coordinate system is:

[0059]

[0060] Therefore, the three-dimensional coordinate expression of the object in space is:

[0061]

[0062] This paper simplifies the orientation of the banana to rotate only around the z-axis of the camera coordinate system, so the posture of the banana relative to the camera coordinate system is:

[0063]

[0064] Where q is the fifth parameter q in the R-YOLOv7-tiny prediction frame. Combining formula (7) and formula (8), the pose of the banana stem relative to the camera coordinate system can be obtained as follows:

[0065]

[0066] Among them, since q in the image coordinate system is defined by the long side method and the range is (-90,90), which is inconsistent with the angle definition in the camera coordinate system, an angle conversion is required. The conversion relationship is as follows:

[0067]

[0068] The present invention introduces the deep image restoration algorithm based on criminisi.

[0069] The Criminisi algorithm is a method for image restoration. Its basic principle is to select the pixel point p with the highest priority on the edge of the area to be repaired and construct a pixel block of size n×n with this pixel point as the center. In the Criminisi algorithm, the sample block that is most similar to the template block is found in the intact area, and the sample block found is used to update the information to be repaired in the template block. The selection of this sample block is based on its similarity with the template block to ensure the accuracy and consistency of the repair result. During the repair process, the algorithm updates the confidence of the pixels in the repaired block to reflect the reliability of the repair. Through iterative repair, the Criminisi algorithm gradually fills the area to be repaired until the repair is completed. The key to the Criminisi algorithm is to give priority to selecting pixels on the edge as the starting point of the repair to maximize the preservation of the structure and edge information of the image. The algorithm can use known information to fill the area to be repaired during the repair process, thereby improving the quality and accuracy of the repair result.

[0070] Figure 5This is the restoration principle diagram of criminisi. First, the Sobel operator is used to calculate the gradient of the depth image in the x and y directions to capture the edges and change information in the image. The resulting gradient map has the same size as the input depth map. Subsequently, the depth map and the gradient map are spliced ​​in the channel direction to form a new input image in order to utilize the gradient information when repairing the depth map. In order to store the repaired depth image, an output image of the same size as the input depth map is created. In the depth map, find the locations where the depth value is 0, which represent holes in the image. For each hole location, perform the following steps:

[0071] 1. Get an n×n pixel block centered on the current hole to obtain the pixel values ​​around the current hole.

[0072] 2. Find the pixel block with the largest depth value, i.e., the optimal depth value, in order to consider the influence of surrounding pixels.

[0073] 3. Assign the best depth value to the current hole, that is, fill the hole with the depth value of the surrounding best pixels.

[0074] Finally, the inpainted depth image is returned, in which the hole positions have been filled with the depth values ​​of the surrounding best pixels. The goal of this algorithm is to improve the completeness and accuracy of the depth image by filling the holes in the depth image with the surrounding depth information.

[0075] The method of the present invention is verified by conducting comparative tests through orchard on-site data collection.

[0076] The image collection location is located in a banana plantation in Zhongluotan Town, Baiyun District, Guangzhou. A total of multiple pictures of banana bunches were taken in the orchard. In the banana image, the banana bunches and stems in the growing period are green, the banana fingertips are bent upward into clusters, and the banana stems grow at an angle. Annotation principle: Since the bounding box tries to frame the banana stem, the true frame does not include the bent part of the upper half of the banana stem.

[0077] Use labelImg and roLabelImg to accurately label the banana stalk and fruit bunch in the original image, respectively.

[0078] Figure 3 Schematic diagram of the rotational bounding box of the present invention

[0079] Figure 4 The three-dimensional position calculation principle diagram of the present invention

[0080] Figure 5 It is a restoration schematic of criminisi.

[0081] The picture shows a comparison between a horizontal frame and a rotating frame. Figure 6The left side is a horizontal frame image, and the right side is a rotation frame image. In the label image, the banana stalk is 0 and the banana bunch is 1. There are 2 categories in total, and the 1000 manually annotated data sets are randomly divided into training set, validation set and test set in a ratio of 8:1:1.

[0082] (I) Compare the effects of normal YOLOv7 and the improved rotation R-YOLOv7-tiny of the present invention. In order to compare the effects between the horizontal detection frame algorithm and the rotation detection algorithm, the R-YOLOv7-tiny algorithm and the YOLOv7 algorithm are compared in the detection of banana stem targets. The experimental results show that the prediction frame output by the R-YOLOv7-tiny algorithm can better fit the real contour of the banana stem and can more accurately reflect the orientation of the banana stem in the banana garden. When the banana stems are densely arranged at an inclined angle, the detection effect of the R-YOLOv7-tiny algorithm is better and less likely to be missed.

[0083] We tested YOLOv7 and R-YOLOv7-tiny and counted the results of correct detection, false detection and missed detection. In the 118 banana images in the test set, there are 272 banana bunches and 133 banana stalks (i.e. banana stems). As shown in Table 1. As can be seen from the table, the correct detection rates of the two algorithms on banana bunches are very close, but the correct detection rates of banana stems are quite different. The detection results of the YOLOv7 algorithm model on banana stems are obviously not as high as the detection accuracy of banana bunches, and its missed detection of banana stems is also very serious, with 56 banana stems not detected and 6 banana bunches not detected. In contrast, R-YOLOv7-tiny performs better in both correct detection and missed detection. Its detection accuracy and missed detection rates for banana bunches are 98.1% and 1.8%, respectively, and its detection accuracy and missed detection rates for banana stems are 97.7% and 2.6%, respectively. It can be seen that when the same target is detected, R-YOLOv7-tiny has a higher confidence level than YOLOv7.

[0084] Table 1 Detection results under horizontal and rotation algorithms

[0085]

[0086] (II) Model comparison (comparison of the effects and ap indicators, parameter quantity and frame rate of R-YOLOv7-tiny and other networks)

[0087] In order to prove the effectiveness of the improved model of the present invention, the detection networks of different frameworks are compared and analyzed, and the detection effect on the complete test set is shown in Table 2. As can be seen from Table 2, the AP values ​​of banana bunches and banana stems of R-YOLOv7-tiny are 94.36 and 95.29 respectively. The AP values ​​of R-YOLOv7-tiny on banana bunches and banana stems are significantly higher than those of YOLOv5 (AP 92.61% and 63.64% respectively), YOLOv7 (AP 91.33% and 63.71% respectively), and YOLOv7-tiny (AP 94.50% and 78.08% respectively), and the performance is better. R-YOLOv7-tiny has higher recall and accuracy, and the inference time, number of parameters and computational complexity are similar to those of YOLOv7-tiny. It can also be seen that the accuracy of the horizontal detection algorithm for banana stems is much lower than that of banana bunches. This is because banana stems are much smaller than bananas and are more similar to the background in the banana garden (such as banana leaf stems), so it is more difficult to detect banana stems. The introduction of the KLD loss function in R-YOLOv7-tiny makes the loss regression of banana stems smoother, so the accuracy of banana stems is greatly improved, and is slightly higher than that of banana bunches. In addition, R-YOLOv7-tiny has higher recall and accuracy, and has a shorter inference time and a smaller number of parameters.

[0088] Table 2 Detection results of different detection network models

[0089]

[0090] Taking into account the detection accuracy, real-time performance and lightweight, the R-YOLOv7-tiny model proposed in this paper shows the best comprehensive detection performance. While maintaining high detection accuracy, it has low computing resource requirements and can run efficiently under limited hardware resources. This enables the model to have good performance in real-time application scenarios, and can respond in time and provide accurate banana target information. (III) Comparison of depth image restoration effect and banana stem positioning accuracy.

[0091] The present invention adopts criminisi's method to effectively repair most of the holes in the depth image, and the repaired depth image is clearer. The most important thing is that the processing time is short, and it takes 0.605s to process one image, and the running time is short.

[0092] To further illustrate the effectiveness of the rotation detection and depth image restoration algorithms, we conducted a target 3D positioning experiment. We used the horizontal detection algorithm and the rotation detection algorithm for comparison. We conducted five target 3D positioning experiments in the banana orchard and recorded the test data. This paper used a laser rangefinder to measure z and a vernier caliper to measure the radius r of the banana stem, and recorded the u and v coordinates of the laser point in the image. In order to reduce the measurement error, three sets of data were collected at the same time and the average was taken. The depth distance zt=z+r of the target in the camera coordinate system was calculated as the true value. Record zc and zt in the experiment, calculate the error mean Ev and the error ratio mean Evr, and calculate the average value. The results are shown in the table.

[0093] Table 3 Banana stem positioning test results

[0094]

[0095] where z c 、z t are the depth camera measurement value and the laser rangefinder measurement value, respectively, c1 and z c2 They are z c Corresponding depth values ​​of the banana stem detection center for YOLOv7 and R-YOLOv7-tiny; E v 、E vr are the mean error and the mean error ratio respectively.

[0096] As shown in Table 3, in the five experiments before deep image restoration, the mean error E and mean error ratio obtained by the algorithm in this paper are 7.02 mm and 0.65% respectively; while the mean error E and mean error ratio of YOLOv7 for horizontal detection are 31.32 mm and 2.61% respectively. The improved rotation YOLOv7 algorithm predicts the radius of the banana stem well and effectively reduces the mean error and mean error ratio of the center of mass positioning of the banana stem; in addition, the depth value in test number 3 is 0 because the depth camera is affected by the lighting or there are black spots on the surface of the banana stem, which makes it impossible to obtain the depth information of the position, resulting in positioning errors. In R-YOLOv7-tiny, the criminisi algorithm is used to repair the holes in the target area, which can effectively make up for the positioning errors caused by local holes and better fit the posture of the banana stem.

Claims

1. A banana recognition and pose estimation method based on a YOLOv7 rotating frame, comprising the following steps: (1) For the banana tree image taken, the rotation angle parameter and GSConv module are added on the basis of the YOLOv7 model to extract image features and enhance features, and the GSConv module is used to perform feature fusion analysis; (2) Use the rotating bounding box to locate the banana's stalk, enclose the shape of the banana, and determine the orientation of the banana by the direction of the stalk, and set the rotation angle parameter; (3) Calculate the rotation bounding box regression loss, and regard the angle parameter as a probability distribution, which indicates the possible rotation angle of the target. The discontinuity of the periodic angle parameter means that there is a sudden change in the probability distribution at the boundary of the periodic change. The KLD method is used to measure the difference in the probability distribution between two adjacent periods, and the difference is used as part of the loss function to repair the image. The information obtained by the rotation target detection algorithm is used to predict the position of the actual center of mass of the banana stem, and the image processing is performed through the depth completion algorithm Criminisi to repair the holes that appear during the positioning process.

2. The banana recognition and pose estimation method based on the YOLOv7 rotating frame according to claim 1 is characterized in that: After the features are fused and analyzed in step (1), three enhanced effective feature layers are obtained. Each feature layer has width, height and number of channels. The feature map is regarded as a set of many feature points. There are three prior frames on each feature point. Each prior frame contains features of the number of channels. Then, it is determined whether the prior frames on these feature points correspond to the objects in the image.

3. The banana recognition and pose estimation method based on the YOLOv7 rotating frame according to claim 1 is characterized in that: The method also includes the step of positioning the banana stalk, which is represented by a cylinder. A three-dimensional camera coordinate system is established, and the orientation of the banana stalk is simplified to a rotation around the z-axis of the camera coordinate system, thereby obtaining the posture of the banana relative to the three-dimensional camera coordinate system.

4. The banana recognition and pose estimation method based on the YOLOv7 rotating frame according to claim 1 is characterized in that: In step (3), the KLD regression loss function is used to regress the banana stalk location point and rotation angle in the rotating target detection stage to obtain the three-dimensional coordinates of the location point in the camera coordinate system.

Citation Information

Patent Citations

  • Orchard banana detection method, system and device based on deep neural network and medium

    CN112597897A

  • Workpiece category and pose estimation method based on YOLOv4-tiny model

    CN115100136A

  • Litchi fruit growth period identification method based on improved YOLOv5

    CN115984698A

  • Demonstration normal form-based rotating target detection method and device

    CN116953702A

  • Training method and training apparatus for rotating-ship target detection model, and storage medium

    WO2023116631A1