Rose flower size measurement method and system based on deep learning and stereo vision
Through deep learning and stereo vision technology, combined with depth images and color images, a three-dimensional point cloud is generated, which solves the accuracy and automation problems of traditional rose flower size measurement and achieves efficient rose flower size measurement in greenhouse scenes.
Patent Information
- Application Number
- CN202310372492.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-10
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-04-10
AI Technical Summary
Traditional rose flower size measurement relies on manual observation, which has problems with missed measurements and mismeasurements. In addition, in a non-structural planting environment, it is difficult for color image recognition algorithms to accurately obtain the size of rose flowers.
Using a method based on deep learning and stereo vision, depth images and color images are collected through a depth camera, combined with target recognition, adaptive threshold segmentation, K-Means pixel clustering and contour feature point algorithms to generate a three-dimensional point cloud and calculate the shape of the rose. diameter size.
It achieves accurate measurement of the size of rose flowers in a greenhouse scene, improves the accuracy and automation of measurement, and adapts to the needs of large-scale planting environments.
Smart Images

Figure CN116524000B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a rose flower size measurement method and system based on deep learning and stereoscopic vision. Background Art
[0002] As one of the important evaluation indicators for rose flower quality grading, the size of rose flowers needs to be taken seriously both during the planting process and in the final sorting and sales process. Traditional rose flower size measurement is mostly done by manual visual observation and subjective experience judgment, which can easily lead to missed measurements and mismeasurements. In addition, due to the expansion of planting scale and the increase in labor costs, the traditional method of relying on manual measurement is no longer suitable for the development of the times. Therefore, the use of new artificial intelligence technologies such as machine vision and deep learning to complete rose flower size measurement has a very broad application prospect.
[0003] At present, with the rapid development of deep learning technology in the field of machine vision, scholars have made many studies in the fields of flower recognition, classification, and flower quantity statistics. However, there are few studies on size measurement. At the same time, in unstructured planting environments, it is difficult to accurately obtain the size of rose flowers using image recognition algorithms that only use color images. Summary of the invention
[0004] To this end, the technical problem to be solved by the present invention is to overcome the technical defects existing in the prior art, and propose a rose flower size measurement method and system based on deep learning and stereo vision, which utilizes color images to fuse three-dimensional point cloud information and can accurately obtain the size of rose flowers in a greenhouse scene.
[0005] In order to solve the above technical problems, the present invention provides a rose flower size measurement method based on deep learning and stereo vision, comprising:
[0006] Using a depth camera to collect depth images and color images of a rose planting row in real time, using a target recognition algorithm to detect the roses on the color image, and cropping the depth image and color image of each single rose according to the prediction frame output by the target recognition algorithm;
[0007] The dual-mask segmentation is performed using an adaptive threshold segmentation algorithm based on a depth histogram and a K-Means pixel clustering algorithm based on a LAB color model. The depth image of each single rose is roughly segmented using an adaptive threshold segmentation algorithm based on a depth histogram to obtain a rough segmentation mask. After the rough segmentation mask is mapped to a color image, the color image of each single rose is finely segmented using a K-Means pixel clustering algorithm based on a LAB color model.
[0008] The posture of each rose is estimated by using a flower posture estimation algorithm based on contour feature points. The measurement baseline that meets the posture of each rose is output. The depth image and color image after image segmentation are converted into a three-dimensional point cloud of each rose in combination with the internal and external parameters of the camera. The posture of the rose point cloud in the three-dimensional space is adjusted according to the measurement baseline.
[0009] The AABB bounding box algorithm is used to solve the optimal enclosing space of the three-dimensional point cloud after the posture of each rose is adjusted, and the diameter of the rose is calculated using the size compensation formula and the lengths of the three adjacent sides of the bounding box.
[0010] In one embodiment of the present invention, before cutting out the depth image and the color image of each individual rose according to the prediction frame output by the target recognition algorithm, the prediction frame is enlarged.
[0011] In one embodiment of the present invention, a method for roughly segmenting the depth image of each single rose using an adaptive threshold segmentation algorithm based on a depth histogram includes:
[0012] Use formula (1) to remove outliers:
[0013]
[0014] Among them, depth i Indicates the depth value corresponding to the depth histogram, num i Indicates depth i The frequency of occurrence, min_num indicates the minimum frequency of occurrence of depth values, true indicates a valid depth value, and false indicates an abnormal depth value that needs to be removed;
[0015] The effective depth value depth after sorting i Perform first-order difference to obtain the adjacent depth value gradient Δdepth i :
[0016] Δdepth i =depth i+1 -depth i (2)
[0017] Select the maximum depth gradient Δdepth max , respectively record the corresponding two depth values depth j and depth j+1 , calculate Δdepth i The variance v Δdepth :
[0018]
[0019] Where i represents the subscript number of the depth value gradient, n represents the total number of depth value gradients, and j represents the two consecutive depth value subscripts corresponding to the maximum depth gradient calculated during the algorithm loop solution process;
[0020] Judgement Δdepth Is it less than the set variance threshold? If not, remove the maximum depth value gradient and then loop the rough segmentation step. If so, use the recorded two consecutive depth values depth m and depth n is the threshold, and the ratio p of the number of pixels contained in the threshold range to all pixels is calculated. m,n , with p m,n The maximum threshold is used as the depth value threshold for segmenting the foreground and background;
[0021]
[0022] Among them, m represents the depth value subscript of the maximum depth segmentation threshold, and n represents the depth value subscript of the minimum depth segmentation threshold.
[0023] In one embodiment of the present invention, a method for finely segmenting a color image of each individual rose using a K-Means pixel clustering algorithm based on a LAB color model includes:
[0024] The color image is converted into a LAB image, and the A channel image of the LAB color model is selected as the input data of the clustering algorithm. Before clustering, the color image covered by the original rough mask is preprocessed, wherein the preprocessing operation includes image inversion, color space conversion and histogram equalization;
[0025] Perform image convolution operation on the preprocessed image to obtain the difference features between the rose flower and the foreground and background.
[0026] In one embodiment of the present invention, a method for estimating the posture of a rose flower by using a flower posture estimation algorithm based on contour feature points for color images of individual rose flowers comprises:
[0027] The edge contour of each pixel of each rose is detected by using a contour detection algorithm on the color image of each rose obtained after image segmentation;
[0028] Fit the edge contour to obtain all contour points on the fitted contour;
[0029] The least squares method is used to fit a straight line from all the contour points to obtain the slope of the straight line and the two-dimensional coordinates of a point on the straight line. The straight line is the attitude estimation indicator line of a single rose. The convex hull detection algorithm is used to obtain the points on the convex hull of the color image of each single rose. The points on the convex hull are the contour feature points. The contour feature points are paired in pairs to form line segments, which are candidate measurement reference lines.
[0030] The final measurement baseline is determined based on the candidate measurement baselines.
[0031] In one embodiment of the present invention, a method for determining a final measurement baseline based on candidate measurement baselines includes:
[0032] Calculate the distances from all contour feature points to the attitude estimation indicator line, remove contour feature points whose distances exceed the set threshold, and obtain the filtered contour feature points;
[0033] Calculate the line segments between the contour feature points, that is, the angle between the candidate measurement reference line and the attitude estimation indicator line, and continuously find the candidate measurement reference line with the smallest angle as the final measurement reference line.
[0034] In one embodiment of the present invention, a method for adjusting the posture of a rose point cloud in a three-dimensional space according to a measurement reference line includes:
[0035] Flip the point cloud;
[0036] Use the AABB bounding box algorithm to solve the optimal bounding space of the point cloud and get the center point of the bounding box (x o ,y o , z o ), take the three adjacent sides of the bounding box as the x-axis, y-axis, and z-axis respectively, and get the original coordinate system;
[0037] Adjust the posture of the rose flower around the z-axis.
[0038] In one embodiment of the present invention, a method for adjusting the posture of a rose flower to a posture around a z-axis includes:
[0039] Project the measurement reference line into the xoy plane;
[0040] Calculate the angle between the projection of the measurement reference line and the x-axis;
[0041] Calculate the attitude adjustment matrix based on the angle;
[0042] Use the attitude adjustment matrix to adjust the attitude around the Z axis.
[0043] In one embodiment of the present invention, a method for calculating the diameter of a rose flower using a size compensation formula and the lengths of three adjacent sides of a bounding box includes:
[0044] Use the AABB bounding box algorithm to solve the optimal bounding space of the three-dimensional point cloud after the posture adjustment of each rose, and get the lengths of three adjacent sides l1, l2, l3, and use the size compensation formula The y-axis posture of the three-dimensional point cloud of a single rose is adjusted, and the two calculated values are used as the size of the single rose.
[0045] In addition, the present invention also provides a rose flower size measurement system based on deep learning and stereoscopic vision, comprising:
[0046] The target detection module is used to use a depth camera to collect depth images and color images of the rose planting row in real time, use a target recognition algorithm to detect the roses on the color image, and cut out the depth image and color image of each single rose according to the prediction frame output by the target recognition algorithm;
[0047] An image segmentation module, which is used to perform dual-mask segmentation using an adaptive threshold segmentation algorithm based on a depth histogram and a K-Means pixel clustering algorithm based on a LAB color model, wherein the depth image of each single rose is roughly segmented using the adaptive threshold segmentation algorithm based on a depth histogram to obtain a rough segmentation mask, and after mapping the rough segmentation mask to a color image, the color image of each single rose is finely segmented using the K-Means pixel clustering algorithm based on the LAB color model;
[0048] A posture adjustment module, which is used to estimate the posture of each rose flower in the color image of each single rose flower by using a flower posture estimation algorithm based on contour feature points, output a measurement baseline that conforms to the posture of each single rose flower, and convert the depth image and color image after image segmentation into a three-dimensional point cloud of each single rose flower in combination with internal and external parameters of the camera, and perform posture adjustment of the rose flower point cloud in three-dimensional space according to the measurement baseline;
[0049] The size measurement module is used to use the AABB bounding box algorithm to solve the optimal enclosing space of the three-dimensional point cloud of each rose after the posture is adjusted, and use the size compensation formula and the length of the three adjacent sides of the bounding box to calculate the diameter of the rose.
[0050] The above technical solution of the present invention has the following advantages compared with the prior art:
[0051] The rose flower size measurement method and system based on deep learning and stereoscopic vision described in the present invention utilizes color images to fuse three-dimensional point cloud information, and can accurately obtain the size of the rose flower in a greenhouse scene. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein
[0053] Figure 1 It is a flow chart of a rose flower size measurement method based on deep learning and stereo vision proposed by the present invention.
[0054] Figure 2 It is a block diagram of a rose flower size measurement method based on deep learning and stereo vision proposed by the present invention.
[0055] Figure 3 It is a schematic diagram of enlarging the prediction box output by the target recognition algorithm proposed by the present invention.
[0056] Figure 4 It is a flow chart of a method proposed by the present invention for roughly segmenting the depth image of each single rose using an adaptive threshold segmentation algorithm based on a depth histogram.
[0057] Figure 5 This is a foreground and background effect diagram of a rose flower with a large difference in depth value in the segmented image after the rough segmentation mask proposed by the present invention.
[0058] Figure 6 This is the effect diagram after double mask segmentation proposed by the present invention.
[0059] Figure 7 It is a flow chart of a method proposed by the present invention for performing rose flower posture estimation on color images of individual rose flowers by using a flower posture estimation algorithm based on contour feature points.
[0060] Figure 8 It is a schematic diagram of a method for determining a final measurement baseline based on candidate measurement baselines proposed by the present invention. DETAILED DESCRIPTION
[0061] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0062] Reference Figure 1 and Figure 2 As shown, an embodiment of the present invention provides a rose flower size measurement method based on deep learning and stereoscopic vision, comprising the following steps:
[0063] Step S1: using a depth camera to collect a depth image and a color image of a rose planting row in real time, using a target recognition algorithm to detect the roses on the color image, and cropping the depth image and color image of each single rose according to the prediction frame output by the target recognition algorithm;
[0064] Step S2: performing double mask segmentation using an adaptive threshold segmentation algorithm based on a depth histogram and a K-Means pixel clustering algorithm based on a LAB color model, wherein the depth image of each single rose is roughly segmented using the adaptive threshold segmentation algorithm based on a depth histogram to obtain a rough segmentation mask, and after mapping the rough segmentation mask to a color image, the color image of each single rose is finely segmented using the K-Means pixel clustering algorithm based on a LAB color model;
[0065] Step S3: using a flower posture estimation algorithm based on contour feature points to estimate the posture of each single rose in the color image, outputting a measurement baseline that conforms to the posture of each single rose, and converting the depth image and color image after image segmentation into a three-dimensional point cloud of each single rose in combination with internal and external parameters of the camera, and adjusting the posture of the rose point cloud in the three-dimensional space according to the measurement baseline;
[0066] Step S4: Use the AABB bounding box algorithm to solve the optimal bounding space of the three-dimensional point cloud of each rose after the posture adjustment, and use the size compensation formula and the lengths of the three adjacent sides of the bounding box to calculate the diameter of the rose.
[0067] The rose flower size measurement method and system based on deep learning and stereoscopic vision described in the present invention utilizes color images to fuse three-dimensional point cloud information, and can accurately obtain the size of the rose flower in a greenhouse scene.
[0068] Specifically, step S1 can be described as using a depth camera to collect the depth image and color image of the rose planting row in real time, using the target recognition algorithm to detect each individual rose on the color image, and cutting out the depth image and color image of each individual rose according to the prediction frame output by the algorithm. In order to improve the accuracy of the size measurement result and reduce the impact of the accuracy of the target recognition algorithm on the size measurement result, this embodiment further enlarges the prediction frame output by the target recognition algorithm, such as Figure 3 As shown, preferably, the width is increased by 10 pixels and the height is increased by 20 pixels.
[0069] Wherein, step S2 can be specifically described as using the adaptive threshold segmentation algorithm based on the depth histogram and the K-Means pixel clustering algorithm based on the LAB color model to perform coarse and fine double mask segmentation on the depth image and color image of each single rose. First, the depth image of each single rose is coarsely segmented using the adaptive threshold segmentation algorithm based on the depth histogram, and the interference of the foreground and background is filtered to obtain a coarse segmentation mask. Then the coarse segmentation mask is mapped to the color image. After coarse segmentation is performed on the color image, the color image of each single rose after coarse segmentation is finely segmented using the K-Means pixel clustering algorithm based on the LAB color model to filter the interference of the pixels of the branches and leaves around the rose. Finally, the depth image and color image of each single rose are segmented twice using the coarse and fine double mask, so that only the depth value of the rose is retained on the depth image, and only the pixel value of the rose is retained on the color image.
[0070] Reference Figure 4 As shown, the method for roughly segmenting the depth image of each single rose using the adaptive threshold segmentation algorithm based on the depth histogram includes:
[0071] Affected by the performance of the depth camera itself, the depth map of the corresponding pixels of the image may have anomalies such as holes. Before analysis, the formula (1) is used to eliminate the outliers.
[0072]
[0073] Among them, depth i Indicates the depth value corresponding to the depth histogram, num i Indicates depth i The frequency of occurrence, min_num indicates the minimum value of the depth value occurrence frequency, true indicates a valid depth value, and false indicates an abnormal depth value to be eliminated. In order to enlarge the gap between the depth values of the flower and the foreground and background, and narrow the depth value gap within the pixel range of the flower itself, the sorted effective depth value depth i Perform first-order difference to obtain the adjacent depth value gradient Δdepth i , as shown in formula (2). Select the maximum depth gradient Δdepth max , respectively record the corresponding two depth values depth j and depth j+1 Calculate Δdepth i The variance v Δdepth , as shown in formula (3). Δdepth Is it less than the specified variance threshold? If not, remove the maximum depth value gradient and repeat the above steps. If so, use the recorded two consecutive depth values depth m and depth nis the threshold, and the ratio p of the number of pixels contained in the threshold range to all pixels is calculated. m,n , as shown in formula (4). m,n The maximum threshold is used as the depth value threshold for segmenting the foreground and background.
[0074] Δdepth i =depth i+1 -depth i (2)
[0075]
[0076]
[0077] Among them, depth i Indicates the depth value corresponding to the depth histogram, num i Indicates depth i The frequency of occurrence, min_num represents the minimum value of the depth value occurrence frequency, true represents the valid depth value, false represents the abnormal depth value to be eliminated, i represents the subscript number of the depth value gradient, n represents the total number of depth value gradients, j represents the two consecutive depth value subscripts corresponding to the maximum depth gradient calculated during the algorithm loop solution, m represents the depth value subscript of the maximum depth segmentation threshold, and n represents the depth value subscript of the minimum depth segmentation threshold.
[0078] The coarse segmentation mask is obtained by using the adaptive threshold segmentation algorithm based on the depth histogram to segment the foreground and background of the image whose depth values are significantly different from those of the rose. Figure 5 shown.
[0079] The method for finely segmenting the color image of each single rose using the K-Means pixel clustering algorithm based on the LAB color model includes:
[0080] Considering that roses have different varieties, their colors will also change. In order to make the clustering algorithm less affected by the color of the flowers, the RGB image is converted to a LAB image. Because the color of most roses is close to red, and the color of their branches and leaves is close to green, both of which are close to the two extreme values of the A channel, the A channel image of the LAB color model is selected as the input data of the clustering algorithm.
[0081] Before pixel clustering, in order to make the clustering effect more accurate, the original coarse mask-covered RGB image is preprocessed to increase the difference between the flower and the foreground and background pixels. The preprocessing operations include image inversion, color space conversion, and histogram equalization.
[0082] The preprocessed image is subjected to image convolution operation to obtain the difference features between the rose flower and the foreground and background, while eliminating the redundancy caused by the correlation between the features, reducing the computational complexity of pixel clustering and improving the clustering speed.
[0083] After preprocessing, proceed as follows:
[0084] 1. Perform image inversion, color space conversion, and histogram equalization preprocessing on the roughly segmented RGB image. Extract features through image convolution and represent the feature image as
[0085]
[0086] Among them, h represents the height of the RGB image, and w represents the width of the RGB image.
[0087] 2. Since the mask pixels and the leaf pixels in the feature image have similar values, while the flower pixels are significantly different from the former, the number of clusters is determined to be 2, which is recorded as:
[0088] C = {c1, c2} (6)
[0089] Among them, c1 is the cluster center of the flower pixels, and c2 is the cluster center of the remaining pixels.
[0090] 3. Flower pixels are generally located in the center of the image. To speed up the convergence of the algorithm, the initial value of c1 is the average of the 9 pixels in the center of the image, and the initial value of c2 is the average of the 12 pixels in the four corners of the image.
[0091]
[0092]
[0093] Among them, sum() means summing all elements in the matrix, [] means rounding operation, h means the height of the RGB image, and w means the width of the RGB image.
[0094] 4. Calculate each value f in the feature image i,j Euclidean distance from c1 and c2 Compare size, and the value f i,j Arrange them into the cluster with the smallest distance to form two sets F1 and F2:
[0095]
[0096]
[0097] 5. Calculate the average of all values in sets F1 and F2, and redistribute the average to c1 and c2:
[0098]
[0099]
[0100] Among them, |F1| is the number of pixels in the flower pixel set, and |F2| is the number of pixels in the remaining pixel set.
[0101] 6. Repeat steps 4 and 5 until the values of c1 and c2 remain basically unchanged.
[0102] 7. Calculate the Euclidean distance between each pixel of the preprocessed image and c1 and c2, and cluster the pixels at the center with the smallest distance. Based on the clustered pixels, a fine segmentation mask is obtained to segment the residual foreground and background images. The final segmentation effect is as follows: Figure 6 shown.
[0103] Among them, step S3 can be specifically described as using a flower posture estimation algorithm based on contour feature points to estimate the posture of each single rose in the color image of the rose, and outputting a measurement baseline that conforms to the posture of each single rose. The depth image and color image after image segmentation are combined with the internal and external parameters of the camera to convert into a three-dimensional point cloud of each single rose, and the posture of the rose point cloud in the three-dimensional space is adjusted according to the measurement baseline.
[0104] Reference Figure 7 As shown, the method for estimating the posture of a rose flower using a flower posture estimation algorithm based on contour feature points on a color image of each single rose flower comprises: first, using a contour detection algorithm to detect the edge contour of each pixel of each single rose flower on the color image of each single rose flower obtained after image segmentation. In order to reduce the amount of calculation, the edge contour is fitted to obtain all contour points on the fitted contour. According to all contour points, a straight line of these points is fitted using the least squares method to obtain the slope of the straight line and the two-dimensional coordinates of a point on the straight line. Here, the straight line is the attitude estimation indicator line of the single rose flower. Then, the convex hull detection algorithm is used to obtain the points on the convex hull of the color image of each single rose flower, and the points on the convex hull are called contour feature points. Then, the contour feature points are paired to form line segments, and these line segments are called candidate measurement baselines. The final measurement baseline is determined based on the candidate measurement baselines.
[0105] Further, refer to Figure 8 As shown, the method for determining the final measurement baseline based on the candidate measurement baselines includes: firstly, calculating the distances from all contour feature points to the attitude estimation indicator line, removing contour feature points with distances exceeding 10, and performing preliminary screening. Secondly, calculating the line segments between the contour feature points, that is, the angles between the candidate measurement baseline and the attitude estimation indicator line, and continuously looping to find the candidate measurement baseline with the smallest angle as the final measurement baseline.
[0106] The method for adjusting the posture of the rose flower point cloud in three-dimensional space according to the measurement reference line includes:
[0107] First use Flip the point cloud to facilitate subsequent calculations; then use the AABB bounding box algorithm to solve the optimal bounding space for the flower point cloud and obtain the center point of the bounding box (x o ,y o , z o ); take the three adjacent sides of the bounding box as the x-axis, y-axis, and z-axis to get the original coordinate system.
[0108] The posture adjustment of the rose flower is the posture adjustment around the z-axis: first, the measurement baseline is projected into the xoy plane, and the direction vector (m1-m2, n1-n2, 0) is calculated. Then, the angle β=α=arctana between the measurement baseline projection and the x-axis is calculated. Finally, the posture adjustment matrix is calculated. Use the attitude adjustment matrix to adjust the attitude around the Z axis.
[0109] Step S4 can be specifically described as using the AABB bounding box algorithm to solve the optimal bounding space of the three-dimensional point cloud of each rose after the posture adjustment, and obtaining the lengths of the three adjacent sides l1, l2, and l3, and using the size compensation formula The y-axis posture of the three-dimensional point cloud of a single rose is adjusted, and the two calculated values are used as the size of the single rose.
[0110] A rose flower size measurement system based on deep learning and stereoscopic vision disclosed in an embodiment of the present invention is introduced below. The rose flower size measurement system based on deep learning and stereoscopic vision described below and the rose flower size measurement method based on deep learning and stereoscopic vision described above can correspond to each other.
[0111] The present invention also provides a rose flower size measurement system based on deep learning and stereoscopic vision, comprising:
[0112] The target detection module is used to use a depth camera to collect depth images and color images of the rose planting row in real time, use a target recognition algorithm to detect the roses on the color image, and cut out the depth image and color image of each single rose according to the prediction frame output by the target recognition algorithm;
[0113] An image segmentation module, which is used to perform dual-mask segmentation using an adaptive threshold segmentation algorithm based on a depth histogram and a K-Means pixel clustering algorithm based on a LAB color model, wherein the depth image of each single rose is roughly segmented using the adaptive threshold segmentation algorithm based on a depth histogram to obtain a rough segmentation mask, and after mapping the rough segmentation mask to a color image, the color image of each single rose is finely segmented using the K-Means pixel clustering algorithm based on the LAB color model;
[0114] A posture adjustment module, which is used to estimate the posture of each rose flower in the color image of each single rose flower by using a flower posture estimation algorithm based on contour feature points, output a measurement baseline that conforms to the posture of each single rose flower, and convert the depth image and color image after image segmentation into a three-dimensional point cloud of each single rose flower in combination with internal and external parameters of the camera, and perform posture adjustment of the rose flower point cloud in three-dimensional space according to the measurement baseline;
[0115] The size measurement module is used to use the AABB bounding box algorithm to solve the optimal enclosing space of the three-dimensional point cloud of each rose after the posture is adjusted, and use the size compensation formula and the length of the three adjacent sides of the bounding box to calculate the diameter of the rose.
[0116] The rose flower size measurement system based on deep learning and stereoscopic vision of this embodiment is used to implement the embodiment part of the aforementioned rose flower size measurement method based on deep learning and stereoscopic vision. Therefore, its specific implementation method can refer to the description of the corresponding embodiments of each part and will not be introduced in detail here.
[0117] In addition, since the rose flower size measurement system based on deep learning and stereoscopic vision of this embodiment is used to implement the aforementioned rose flower size measurement method based on deep learning and stereoscopic vision, its function corresponds to that of the above method and will not be repeated here.
[0118] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0119] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0120] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0122] Obviously, the above embodiments are merely examples for clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived from these are still within the protection scope of the invention.
Claims
1. A rose flower size measurement method based on deep learning and stereo vision, characterized in that: include: Using a depth camera to collect depth images and color images of a rose planting row in real time, using a target recognition algorithm to detect the roses on the color image, and cropping the depth image and color image of each single rose according to the prediction frame output by the target recognition algorithm; The dual-mask segmentation is performed using an adaptive threshold segmentation algorithm based on a depth histogram and a K-Means pixel clustering algorithm based on a LAB color model. The depth image of each single rose is roughly segmented using an adaptive threshold segmentation algorithm based on a depth histogram to obtain a rough segmentation mask. After the rough segmentation mask is mapped to a color image, the color image of each single rose is finely segmented using a K-Means pixel clustering algorithm based on a LAB color model. The posture of each rose is estimated by using a flower posture estimation algorithm based on contour feature points. The measurement baseline that meets the posture of each rose is output. The depth image and color image after image segmentation are converted into a three-dimensional point cloud of each rose in combination with the internal and external parameters of the camera. The posture of the rose point cloud in the three-dimensional space is adjusted according to the measurement baseline. The AABB bounding box algorithm is used to solve the optimal enclosing space of the three-dimensional point cloud after the posture of each single rose is adjusted, and the diameter of the rose is calculated using the size compensation formula and the three adjacent sides of the bounding box. The method for calculating the diameter of the rose using the size compensation formula and the three adjacent sides of the bounding box includes: using the AABB bounding box algorithm to solve the optimal enclosing space of the three-dimensional point cloud after the posture of each single rose is adjusted, and the lengths of the three adjacent sides l1, l2, and l3 are obtained, and the size compensation formula is used The y-axis posture of the three-dimensional point cloud of a single rose is adjusted, and the two calculated values are used as the size of the single rose.
2. The rose flower size measurement method based on deep learning and stereoscopic vision according to claim 1, characterized in that: Before cutting out the depth image and the color image of each individual rose according to the prediction frame output by the target recognition algorithm, the prediction frame is enlarged.
3. A rose flower size measurement method based on deep learning and stereoscopic vision according to claim 1 or 2, characterized in that: The method for roughly segmenting the depth image of each single rose flower by using an adaptive threshold segmentation algorithm based on a depth histogram comprises: Use formula (1) to remove outliers: Among them, depth i Indicates the depth value corresponding to the depth histogram, num i Indicates depth i The frequency of occurrence, min-num indicates the minimum frequency of occurrence of depth values, true indicates a valid depth value, and false indicates an abnormal depth value that needs to be removed; The effective depth value depth after sorting i Perform first-order difference to obtain the adjacent depth value gradient Δdepth i : Δdepth i =depth i+1 -depth i (2) Select the maximum depth gradient Δdepth max , respectively record the corresponding two depth values depth j and depth j+1 , calculate Δdepth i The variance v Δdepth : Where i represents the subscript number of the depth value gradient, n represents the total number of depth value gradients, and j represents the two consecutive depth value subscripts corresponding to the maximum depth gradient calculated during the algorithm loop solution process; Judgement Δdepth Is it less than the set variance threshold? If not, remove the maximum depth value gradient and then loop the rough segmentation step. If so, use the recorded two consecutive depth values depth m and depth n is the threshold, and the ratio p of the number of pixels contained in the threshold range to all pixels is calculated. m,n , with p m,n The maximum threshold is used as the depth value threshold for segmenting the foreground and background; Among them, m represents the depth value subscript of the maximum depth segmentation threshold, and n represents the depth value subscript of the minimum depth segmentation threshold.
4. A rose flower size measurement method based on deep learning and stereoscopic vision according to claim 1 or 2, characterized in that: The method for finely segmenting the color image of each single rose by using the K-Means pixel clustering algorithm based on the LAB color model includes: The color image is converted into a LAB image, and the A channel image of the LAB color model is selected as the input data of the clustering algorithm. Before clustering, the color image covered by the original rough mask is preprocessed, wherein the preprocessing operation includes image inversion, color space conversion and histogram equalization; Perform image convolution operation on the preprocessed image to obtain the difference features between the rose flower and the foreground and background.
5. A rose flower size measurement method based on deep learning and stereoscopic vision according to claim 1 or 2, characterized in that: The method for estimating the posture of a rose flower by using a flower posture estimation algorithm based on contour feature points for color images of each single rose flower comprises: The edge contour of each pixel of each rose is detected by using a contour detection algorithm on the color image of each rose obtained after image segmentation; Fit the edge contour to obtain all contour points on the fitted contour; The least squares method is used to fit a straight line from all the contour points to obtain the slope of the straight line and the two-dimensional coordinates of a point on the straight line. The straight line is the attitude estimation indicator line of a single rose. The convex hull detection algorithm is used to obtain the points on the convex hull of the color image of each single rose. The points on the convex hull are the contour feature points. The contour feature points are paired in pairs to form line segments, which are candidate measurement reference lines. The final measurement baseline is determined based on the candidate measurement baselines.
6. The rose flower size measurement method based on deep learning and stereoscopic vision according to claim 5, characterized in that: The method for determining the final measurement baseline based on the candidate measurement baselines includes: Calculate the distances from all contour feature points to the attitude estimation indicator line, remove contour feature points whose distances exceed the set threshold, and obtain the filtered contour feature points; Calculate the line segments between the contour feature points, that is, the angle between the candidate measurement reference line and the attitude estimation indicator line, and continuously find the candidate measurement reference line with the smallest angle as the final measurement reference line.
7. A rose flower size measurement method based on deep learning and stereoscopic vision according to claim 1 or 2, characterized in that: The method for adjusting the posture of a rose flower point cloud in three-dimensional space according to a measurement reference line includes: Flip the point cloud; Use the AABB bounding box algorithm to solve the optimal bounding space of the point cloud and get the center point of the bounding box (x o ,y o , z o ), take the three adjacent sides of the bounding box as the x-axis, y-axis, and z-axis respectively, and get the original coordinate system; Adjust the posture of the rose flower around the z-axis.
8. The rose flower size measurement method based on deep learning and stereoscopic vision according to claim 7, characterized in that: The method for adjusting the posture of the rose flower to the posture around the z-axis includes: Project the measurement reference line into the xoy plane; Calculate the angle between the projection of the measurement reference line and the x-axis; Calculate the attitude adjustment matrix based on the angle; Use the attitude adjustment matrix to adjust the attitude around the Z axis.
9. A rose flower size measurement system based on deep learning and stereo vision, characterized in that: include: The target detection module is used to use a depth camera to collect depth images and color images of the rose planting row in real time, use a target recognition algorithm to detect the roses on the color image, and cut out the depth image and color image of each single rose according to the prediction frame output by the target recognition algorithm; An image segmentation module, which is used to perform dual-mask segmentation using an adaptive threshold segmentation algorithm based on a depth histogram and a K-Means pixel clustering algorithm based on a LAB color model, wherein the depth image of each single rose is roughly segmented using the adaptive threshold segmentation algorithm based on a depth histogram to obtain a rough segmentation mask, and after mapping the rough segmentation mask to a color image, the color image of each single rose is finely segmented using the K-Means pixel clustering algorithm based on the LAB color model; A posture adjustment module, which is used to estimate the posture of each rose flower in the color image of each single rose flower by using a flower posture estimation algorithm based on contour feature points, output a measurement baseline that conforms to the posture of each single rose flower, and convert the depth image and color image after image segmentation into a three-dimensional point cloud of each single rose flower in combination with internal and external parameters of the camera, and perform posture adjustment of the rose flower point cloud in three-dimensional space according to the measurement baseline; The size measurement module is used to use the AABB bounding box algorithm to solve the optimal enclosing space of the three-dimensional point cloud of each single rose after the posture is adjusted, and use the size compensation formula and the three adjacent sides of the bounding box to calculate the diameter of the rose; when using the size compensation formula and the three adjacent sides of the bounding box to calculate the diameter of the rose, it includes: using the AABB bounding box algorithm to solve the optimal enclosing space of the three-dimensional point cloud of each single rose after the posture is adjusted, and obtaining the three adjacent side lengths l1, l2, l3, using the size compensation formula The y-axis posture of the three-dimensional point cloud of a single rose is adjusted, and the two calculated values are used as the size of the single rose.
