Egg counter and counting method based on intelligent vision
By splitting the image into R channel, G channel and B channel, extracting suspected areas and edge pixels, and using edge feature vectors to identify egg areas, the problem of low counting accuracy in the existing technology is solved and more efficient eggs are achieved count.
Patent Information
- Application Number
- CN202410924267.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-11
AI Technical Summary
Existing egg counting technology based on intelligent vision has the problem of low counting accuracy. This is mainly due to the high computational complexity of the YOLO target recognition algorithm, which results in inaccurate egg counting on fast-moving conveyor belts.
An egg counter based on intelligent vision is used, including an image acquisition unit, a splitting unit, a suspected area extraction unit, a suspected egg edge extraction unit and a counting unit. By splitting the image into R channel, G channel and B channel, the suspected egg counter is extracted Area and edge pixels, use edge feature vectors to identify egg areas, abandon convolution operations and pooling operations, and reduce the amount of calculation.
The accuracy of egg counting is improved. Through the identification of color and edge structure, the amount of calculation is reduced and the accuracy of counting is enhanced.
Smart Images

Figure CN118468919B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an egg counter and a counting method based on intelligent vision. Background Art
[0002] In modern agricultural production and food processing industries, the production and processing of eggs is an important link. In order to improve production efficiency and reduce labor costs, automated egg counting technology has emerged. Traditional egg counting methods mainly rely on manual operations, which are not only inefficient but also prone to errors. Image processing is commonly used to count eggs. By capturing video images of eggs on a conveyor belt in real time, images are captured at specific times to ensure that the images are clear and usable, and the eggs in the image are identified using the YOLO target recognition algorithm. Finally, each time an egg is identified, the count is accumulated to complete the egg counting. Because the eggs on the conveyor belt move at a fast speed, and the YOLO target recognition algorithm has high computational complexity, the calculation speed is slow and there is a problem of low counting accuracy. Summary of the invention
[0003] In view of the above-mentioned deficiencies in the prior art, the present invention provides an egg counter and counting method based on intelligent vision to solve the problem of low counting accuracy in the existing egg counting solutions based on intelligent vision.
[0004] In order to achieve the above-mentioned invention object, the technical solution adopted by the present invention is: an egg counter based on intelligent vision, comprising: an image acquisition unit, a splitting unit, a suspected area extraction unit, a suspected egg edge extraction unit and a counting unit;
[0005] The image acquisition unit is used to acquire an image of the area to be counted to obtain an initial image;
[0006] The splitting unit is used to split the initial image into an R channel image, a G channel image and a B channel image;
[0007] The suspected region extraction unit is used to extract each suspected region according to the R channel image, the G channel image and the B channel image;
[0008] The suspected egg edge extraction unit is used to extract edge pixels of each suspected area to obtain the suspected egg edge;
[0009] The counting unit is used to extract edge feature vectors according to the position distribution of each pixel point on the edge of the suspected egg, identify whether each suspected area is an egg area, and obtain the number of eggs according to the number of egg areas.
[0010] Further, the suspected region extraction unit includes: a first similarity calculation subunit, a second similarity calculation subunit, a third similarity calculation subunit, a suspected pixel point recognition subunit and a partitioning subunit;
[0011] The first similarity calculation subunit is used to calculate the similarity between the R channel value of each pixel and the comparison R channel value on the R channel image to obtain the R channel similarity;
[0012] The second similarity calculation subunit is used to calculate the similarity between the G channel value of each pixel and the comparison G channel value on the G channel image to obtain the G channel similarity;
[0013] The third similarity calculation subunit is used to calculate the similarity between the B channel value of each pixel and the comparison B channel value on the B channel image to obtain the B channel similarity;
[0014] The suspected pixel point identification subunit is used to calculate the average similarity of the pixel points according to the R channel similarity, the G channel similarity and the B channel similarity of the pixel points at the same position. When the average similarity of the pixel points is greater than the first similarity threshold, the corresponding pixel point is a suspected pixel point;
[0015] The partitioning subunit is used to retain the closed areas where the number of suspected pixels is between an upper limit and a lower limit according to the multiple closed areas formed by each suspected pixel point, so as to obtain the suspected area.
[0016] Furthermore, the counting unit includes: a correction processing subunit, an edge feature extraction subunit and a recognition subunit;
[0017] The correction processing subunit is used to correct the coordinates of abnormal pixel points on the suspected egg edge to obtain the suspected egg edge after correction;
[0018] The edge feature extraction subunit is used to extract edge features from the corrected edge of the suspected egg to form an edge feature vector;
[0019] The identification subunit is used to calculate the edge similarity coefficient according to the edge feature vector. When the edge similarity coefficient is greater than the second similarity threshold, the corresponding suspected area is the egg area, and the number of eggs is obtained according to the number of egg areas.
[0020] Further, the correction processing subunit includes: a deviation coefficient calculation module and a correction module;
[0021] The deviation coefficient calculation module is used to calculate the coordinate deviation coefficient of the center point and the pixel points on both sides with each pixel point on the edge of the suspected egg as the center point;
[0022] The correction module is used to identify the center point as an abnormal pixel point when the coordinate deviation coefficient is greater than the deviation threshold, and perform correction processing on the coordinates of the abnormal pixel point to obtain the suspected egg edge after correction processing.
[0023] Furthermore, the formula for calculating the coordinate deviation coefficient between the center point and the pixels on both sides is: , , , where γ is the coordinate deviation coefficient between the center point and the pixels on both sides, x o is the horizontal coordinate of the center point, y o is the ordinate of the center point, x r,i is the horizontal coordinate of the ith pixel in the neighborhood to the right of the center point, y r,i is the ordinate of the ith pixel in the neighborhood to the right of the center point, x l,i is the horizontal coordinate of the ith pixel in the neighborhood to the left of the center point, y l,i is the ordinate of the i-th pixel in the left neighborhood of the center point, i is a positive integer, d r,i is the right distance of the ith position, d l,i is the i-th left distance, and N is the number of pixels.
[0024] Furthermore, the formula for correcting the coordinates of abnormal pixel points is: , ,in, is the horizontal coordinate of the abnormal pixel after correction, It is the ordinate of the abnormal pixel after correction.
[0025] Furthermore, the edge feature extraction subunit includes: a position fluctuation value calculation module and a feature vector construction module;
[0026] The position fluctuation value calculation module is used to divide the corrected suspected egg edge into multiple segments, and calculate the position fluctuation value on each suspected egg edge;
[0027] The feature vector construction module is used to construct an edge feature vector from each position fluctuation value.
[0028] Furthermore, the calculated position fluctuation value is: , , where h is the position fluctuation value, d j is the distance of the jth pixel point on each suspected egg edge, x j is the horizontal coordinate of the jth pixel point on each suspected egg edge, y j is the ordinate of the jth pixel on each suspected egg edge, M is the number of pixels on each suspected egg edge, and j is a positive integer.
[0029] Furthermore, the formula for calculating the edge similarity coefficient is: , where θ is the edge similarity coefficient, h n is the fluctuation value of the nth position in the edge feature vector, H n To compare the nth element in the eigenvector, n is a positive integer.
[0030] A counting method of an egg counter based on intelligent vision comprises the following steps:
[0031] S1, collecting an image of the area to be counted to obtain an initial image;
[0032] S2, splitting the initial image into an R channel image, a G channel image and a B channel image;
[0033] S3, extracting each suspected area according to the R channel image, the G channel image and the B channel image;
[0034] S4, extracting edge pixels of each suspected area to obtain the suspected egg edge;
[0035] S5. According to the position distribution of each pixel point on the edge of the suspected egg, identify whether each suspected area is an egg area, and obtain the number of eggs according to the number of egg areas.
[0036] In summary, the beneficial effects of the present invention are as follows: the present invention collects an image of the area to be counted to obtain an initial image, and the initial image is split into an R channel image, a G channel image, and a B channel image, so as to find each suspected area from three color channels, improve the accuracy of extracting each suspected area, extract the edge pixel points of each suspected area, obtain the suspected egg edge, characterize the edge structure by the edge feature vector on the suspected egg edge, identify whether each suspected area is an egg area, and obtain the number of eggs according to the number of egg areas. The present invention abandons the target recognition algorithm with a large number of convolution operations and pooling operations, and recognizes eggs by color and edge structure, reduces the amount of calculation, and improves the counting accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a system block diagram of an egg counter based on intelligent vision. DETAILED DESCRIPTION
[0038] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0039] Example 1: Figure 1 As shown, an egg counter based on intelligent vision includes: an image acquisition unit, a splitting unit, a suspected area extraction unit, a suspected egg edge extraction unit and a counting unit;
[0040] The image acquisition unit is used to acquire an image of the area to be counted to obtain an initial image;
[0041] The splitting unit is used to split the initial image into an R channel image, a G channel image and a B channel image;
[0042] The suspected region extraction unit is used to extract each suspected region according to the R channel image, the G channel image and the B channel image;
[0043] The suspected egg edge extraction unit is used to extract edge pixels of each suspected area to obtain the suspected egg edge;
[0044] The counting unit is used to extract edge feature vectors according to the position distribution of each pixel point on the edge of the suspected egg, identify whether each suspected area is an egg area, and obtain the number of eggs according to the number of egg areas.
[0045] In this embodiment, the edge pixel points of each suspected area may be extracted by using the hollowing out internal point method in contour extraction.
[0046] In the present invention, the image acquisition unit is placed above the conveyor belt where the eggs are located, so that the eggs in the captured image are not adjacent to each other and the boundaries are clear.
[0047] The suspected region extraction unit includes: a first similarity calculation subunit, a second similarity calculation subunit, a third similarity calculation subunit, a suspected pixel point recognition subunit and a partitioning subunit;
[0048] The first similarity calculation subunit is used to calculate the similarity between the R channel value of each pixel and the comparison R channel value on the R channel image to obtain the R channel similarity;
[0049] The second similarity calculation subunit is used to calculate the similarity between the G channel value of each pixel and the comparison G channel value on the G channel image to obtain the G channel similarity;
[0050] The third similarity calculation subunit is used to calculate the similarity between the B channel value of each pixel and the comparison B channel value on the B channel image to obtain the B channel similarity;
[0051] The suspected pixel point identification subunit is used to calculate the average similarity of the pixel points according to the R channel similarity, the G channel similarity and the B channel similarity of the pixel points at the same position. When the average similarity of the pixel points is greater than the first similarity threshold, the corresponding pixel point is a suspected pixel point;
[0052] The partitioning subunit is used to retain the closed areas where the number of suspected pixels is between an upper limit and a lower limit according to the multiple closed areas formed by each suspected pixel point, so as to obtain the suspected area.
[0053] In this embodiment, the formula for calculating the R channel similarity is: , where ζ R is the R channel similarity, R is the R channel value of the pixel, R c To compare the R channel value.
[0054] The formula for calculating the G channel similarity is: , where ζ G is the G channel similarity, G is the G channel value of the pixel, G c For comparison of G channel values.
[0055] The formula for calculating the B channel similarity is: , where ζ B is the B channel similarity, B is the B channel value of the pixel, and B c For comparison of B channel values.
[0056] In this embodiment, the comparison R channel value, the comparison G channel value and the comparison B channel value are the stored R channel value, G channel value and B channel value after the egg is imaged.
[0057] In this embodiment, the upper limit and the lower limit are set according to the number of pixels occupied by the egg after imaging.
[0058] The present invention splits an original image into an R channel image, a G channel image and a B channel image, calculates the R channel similarity on the R channel image to achieve R channel color contrast, calculates the G channel similarity on the G channel image to achieve G channel color contrast, calculates the B channel similarity on the B channel image to achieve B channel color contrast, takes an average of the three channel similarities, comprehensively considers the color contrast of the three channels, and screens out suspected pixel points.
[0059] In this embodiment, the implementation process of forming a closed area is as follows:
[0060] A1. Take any unpartitioned suspected pixel as a growth point and assign the growth point to the mth closed area. The initial value of m is 1.
[0061] A2, determine whether there are other unpartitioned suspected pixels in the neighborhood of the growth point. If so, add other suspected pixels in the neighborhood to the mth closed area and go to step A3. If not, add 1 to m and jump to A1 until all suspected pixels have corresponding closed areas.
[0062] A3, select a suspected pixel point that has not been a growth point from the closed area as a growth point, and jump to step A2, until all the suspected pixels in the closed area have been growth points, and then enter step A4;
[0063] A4. Jump to step A1 and add 1 to m until all suspected pixels have corresponding closed areas.
[0064] The present invention classifies each of the suspected pixels that are in contact with each other into a closed area, so that it is easy to know the number of pixels contained in each closed area.
[0065] The counting unit includes: a correction processing subunit, an edge feature extraction subunit and a recognition subunit;
[0066] The correction processing subunit is used to correct the coordinates of abnormal pixel points on the suspected egg edge to obtain the suspected egg edge after correction;
[0067] The edge feature extraction subunit is used to extract edge features from the corrected edge of the suspected egg to form an edge feature vector;
[0068] The identification subunit is used to calculate the edge similarity coefficient according to the edge feature vector. When the edge similarity coefficient is greater than the second similarity threshold, the corresponding suspected area is the egg area, and the number of eggs is obtained according to the number of egg areas.
[0069] The present invention corrects the coordinates of abnormal pixel points on the edge of a suspected egg, thereby eliminating the interference of the abnormal pixel points and making the edge smooth. The edge features of the corrected suspected egg edge are extracted to form an edge feature vector. The edge similarity coefficient is calculated according to the edge feature vector. When the edge similarity coefficient is greater than a second similarity threshold, the corresponding suspected area is an egg area. The present invention firstly selects the suspected area by color, and then further identifies it by the edge shape of the suspected area.
[0070] The correction processing subunit includes: a deviation coefficient calculation module and a correction module;
[0071] The deviation coefficient calculation module is used to calculate the coordinate deviation coefficient of the center point and the pixel points on both sides with each pixel point on the edge of the suspected egg as the center point;
[0072] The correction module is used to identify the center point as an abnormal pixel point when the coordinate deviation coefficient is greater than the deviation threshold, and perform correction processing on the coordinates of the abnormal pixel point to obtain the suspected egg edge after correction processing.
[0073] The formula for calculating the coordinate deviation coefficient of the center point and the pixels on both sides is: , , , where γ is the coordinate deviation coefficient between the center point and the pixels on both sides, x o is the horizontal coordinate of the center point, y o is the ordinate of the center point, x r,i is the horizontal coordinate of the ith pixel in the neighborhood to the right of the center point, y r,i is the ordinate of the ith pixel in the neighborhood to the right of the center point, x l,i is the horizontal coordinate of the ith pixel in the neighborhood to the left of the center point, y l,i is the ordinate of the i-th pixel in the left neighborhood of the center point, i is a positive integer, d r,i is the right distance of the ith position, d l,i is the i-th left distance, and N is the number of pixels.
[0074] The formula for correcting the coordinates of abnormal pixel points is: , ,in, is the horizontal coordinate of the abnormal pixel after correction, It is the ordinate of the abnormal pixel after correction.
[0075] The present invention takes each pixel point on the edge of the suspected egg as the center point, calculates the coordinate deviation coefficient between the center point and the pixel points on both sides, and reflects the degree of deviation in position between the center point and the pixel points on both sides. When the coordinate deviation coefficient is greater than the deviation threshold, the coordinates of the abnormal pixel points are corrected, the coordinate points are removed, and new coordinate points are inserted to make the edge of the suspected egg smooth.
[0076] The edge feature extraction subunit includes: a position fluctuation value calculation module and a feature vector construction module;
[0077] The position fluctuation value calculation module is used to divide the corrected suspected egg edge into multiple segments, and calculate the position fluctuation value on each suspected egg edge;
[0078] The feature vector construction module is used to construct an edge feature vector from each position fluctuation value.
[0079] The calculated position fluctuation value is: , , where h is the position fluctuation value, d j is the distance of the jth pixel point on each suspected egg edge, x j is the horizontal coordinate of the jth pixel point on each suspected egg edge, y j is the ordinate of the jth pixel on each suspected egg edge, M is the number of pixels on each suspected egg edge, and j is a positive integer.
[0080] The formula for calculating the edge similarity coefficient is: , where θ is the edge similarity coefficient, h n is the fluctuation value of the nth position in the edge feature vector, H n To compare the nth element in the eigenvector, n is a positive integer.
[0081] In the present invention, the comparison feature vector is the stored egg edge position fluctuation value.
[0082] The present invention divides the corrected suspected egg edge into multiple segments, calculates the position fluctuation value on each segment, reflects the position fluctuation of the pixel points in the segment, characterizes the edge contour features of the egg imaging, and compares each edge feature vector with the comparison feature vector to obtain the similarity between the two. When the edge contour and color are similar, the corresponding area is an egg.
[0083] In this embodiment, all thresholds are set according to requirements or experience.
[0084] In the present invention, the number of egg regions is equal to the number of eggs.
[0085] Embodiment 2: A counting method of an egg counter based on intelligent vision, comprising the following steps:
[0086] S1, collecting an image of the area to be counted to obtain an initial image;
[0087] S2, splitting the initial image into an R channel image, a G channel image and a B channel image;
[0088] S3, extracting each suspected area according to the R channel image, the G channel image and the B channel image;
[0089] S4, extracting edge pixels of each suspected area to obtain the suspected egg edge;
[0090] S5. According to the position distribution of each pixel point on the edge of the suspected egg, identify whether each suspected area is an egg area, and obtain the number of eggs according to the number of egg areas.
[0091] The specific implementation process in Example 2 is the same as that in Example 1.
[0092] The present invention collects an image of a region to be counted to obtain an initial image, which is split into an R channel image, a G channel image and a B channel image, so as to find each suspected region from three color channels, improve the accuracy of extracting each suspected region, extract edge pixel points of each suspected region, obtain suspected egg edges, characterize edge structures by edge feature vectors on the suspected egg edges, identify whether each suspected region is an egg region, and obtain the number of eggs according to the number of egg regions. The present invention abandons a target recognition algorithm with a large number of convolution operations and pooling operations, recognizes eggs by color and edge structure, reduces the amount of operations, and improves counting accuracy.
[0093] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An egg counter based on intelligent vision, characterized in that: include: An image acquisition unit, a splitting unit, a suspected region extraction unit, a suspected egg edge extraction unit and a counting unit; The image acquisition unit is used to acquire an image of the area to be counted to obtain an initial image; The splitting unit is used to split the initial image into an R channel image, a G channel image and a B channel image; The suspected region extraction unit is used to extract each suspected region according to the R channel image, the G channel image and the B channel image; The suspected egg edge extraction unit is used to extract edge pixels of each suspected area to obtain the suspected egg edge; The counting unit is used to extract edge feature vectors according to the position distribution of each pixel point on the edge of the suspected egg, identify whether each suspected area is an egg area, and obtain the number of eggs according to the number of egg areas; The suspected region extraction unit includes: a first similarity calculation subunit, a second similarity calculation subunit, a third similarity calculation subunit, a suspected pixel point recognition subunit and a partitioning subunit; The first similarity calculation subunit is used to calculate the similarity between the R channel value of each pixel and the comparison R channel value on the R channel image to obtain the R channel similarity; The second similarity calculation subunit is used to calculate the similarity between the G channel value of each pixel and the comparison G channel value on the G channel image to obtain the G channel similarity; The third similarity calculation subunit is used to calculate the similarity between the B channel value of each pixel and the comparison B channel value on the B channel image to obtain the B channel similarity, wherein the comparison R channel value, the comparison G channel value and the comparison B channel value are the R channel value, the G channel value and the B channel value after the egg imaging is stored; The suspected pixel point identification subunit is used to calculate the average similarity of the pixel points according to the R channel similarity, the G channel similarity and the B channel similarity of the pixel points at the same position. When the average similarity of the pixel points is greater than the first similarity threshold, the corresponding pixel point is a suspected pixel point; The partitioning subunit is used to retain the closed areas where the number of suspected pixels is between an upper limit and a lower limit according to the multiple closed areas formed by each suspected pixel point, so as to obtain the suspected area.
2. The egg counter based on intelligent vision according to claim 1, characterized in that: The counting unit includes: a correction processing subunit, an edge feature extraction subunit and a recognition subunit; The correction processing subunit is used to correct the coordinates of abnormal pixel points on the suspected egg edge to obtain the suspected egg edge after correction; The edge feature extraction subunit is used to extract edge features from the corrected edge of the suspected egg to form an edge feature vector; The identification subunit is used to calculate the edge similarity coefficient according to the edge feature vector. When the edge similarity coefficient is greater than the second similarity threshold, the corresponding suspected area is the egg area, and the number of eggs is obtained according to the number of egg areas.
3. The egg counter based on intelligent vision according to claim 2, characterized in that: The correction processing subunit includes: a deviation coefficient calculation module and a correction module; The deviation coefficient calculation module is used to calculate the coordinate deviation coefficient of the center point and the pixel points on both sides with each pixel point on the edge of the suspected egg as the center point; The correction module is used to identify the center point as an abnormal pixel point when the coordinate deviation coefficient is greater than the deviation threshold, and perform correction processing on the coordinates of the abnormal pixel point to obtain the suspected egg edge after correction processing.
4. The egg counter based on intelligent vision according to claim 3, characterized in that: The formula for calculating the coordinate deviation coefficient of the center point and the pixels on both sides is: , , , where γ is the coordinate deviation coefficient between the center point and the pixels on both sides, x o is the horizontal coordinate of the center point, y o is the ordinate of the center point, x r,i is the horizontal coordinate of the ith pixel in the neighborhood to the right of the center point, y r,i is the ordinate of the ith pixel in the neighborhood to the right of the center point, x l,i is the horizontal coordinate of the ith pixel in the neighborhood to the left of the center point, y l,i is the ordinate of the i-th pixel in the left neighborhood of the center point, i is a positive integer, d r,i is the right distance of the ith position, d l,i is the i-th left distance, and N is the number of pixels.
5. The egg counter based on intelligent vision according to claim 4, characterized in that: The formula for correcting the coordinates of abnormal pixel points is: , ,in, is the horizontal coordinate of the abnormal pixel after correction, is the ordinate of the abnormal pixel after correction.
6. The egg counter based on intelligent vision according to claim 2, characterized in that: The edge feature extraction subunit includes: a position fluctuation value calculation module and a feature vector construction module; The position fluctuation value calculation module is used to divide the corrected suspected egg edge into multiple segments, and calculate the position fluctuation value on each suspected egg edge; The feature vector construction module is used to construct an edge feature vector from each position fluctuation value.
7. The egg counter based on intelligent vision according to claim 6, characterized in that: The calculated position fluctuation value is: , , where h is the position fluctuation value, d j is the distance of the jth pixel point on each suspected egg edge, x j is the horizontal coordinate of the jth pixel point on each suspected egg edge, y j is the ordinate of the jth pixel on each suspected egg edge, M is the number of pixels on each suspected egg edge, and j is a positive integer.
8. The egg counter based on intelligent vision according to claim 2, characterized in that: The formula for calculating the edge similarity coefficient is: , where θ is the edge similarity coefficient, h n is the fluctuation value of the nth position in the edge feature vector, H n To compare the nth element in the eigenvector, n is a positive integer.
9. A counting method for an egg counter based on intelligent vision, implemented based on the egg counter based on intelligent vision according to any one of claims 1 to 8, characterized in that: The following steps are involved: S1, collecting an image of the area to be counted to obtain an initial image; S2, splitting the initial image into an R channel image, a G channel image and a B channel image; S3, extracting each suspected area according to the R channel image, the G channel image and the B channel image; S4, extracting edge pixels of each suspected area to obtain the suspected egg edge; S5. According to the position distribution of each pixel point on the edge of the suspected egg, identify whether each suspected area is an egg area, and obtain the number of eggs according to the number of egg areas.
