Automatic egg grading method based on image recognition

Through an automated method based on image recognition, combined with high-resolution cameras and uniform lighting equipment, the automatic classification of eggs is achieved, solving the problem that traditional methods cannot accurately judge the freshness of eggs, and ensuring the accuracy and credibility of grading.

CN120021568AActive Publication Date: 2025-05-23HUBEI ZHENGRENTANG TECHNOLOGY CO LTD

Patent Information

Application Number
CN202510026225.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-05-23
Estimated Expiration
2045-01-08

AI Technical Summary

Technical Problem

The traditional egg grading method relies on manual experience and cannot accurately judge the freshness of eggs. There are limitations in sampling and testing, which cannot cover all products.

Method used

Using an automated method based on image recognition, egg images are collected through high-resolution cameras and uniform lighting equipment, combined with image preprocessing, outer contour data fitting, weight measurement and density calculation, a functional relationship between density and freshness is established to realize the automated classification of eggs.

Benefits of technology

Accurate judgment on the freshness of eggs is achieved, illegal vendors are avoided using detection loopholes to replace inferior products, and ensure market order and consumer rights.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120021568A_ABST
    Figure CN120021568A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic egg grading method based on image recognition, belongs to the technical field of image recognition detection, and aims to solve the problem that existing egg freshness detection cannot cover all products. According to the method, clear images are collected through a high-resolution camera and uniform lighting equipment, discrete point coordinates of the egg contour can be accurately extracted in combination with an advanced image preprocessing algorithm, and the relation between outer contour data and the transverse diameter and the longitudinal diameter is established by adopting an optimized ellipse fitting least square method; according to the method, the egg freshness can be accurately judged by using a high-precision electronic scale to measure the weight and performing outer contour matching and correction through an improved algorithm based on the Haushold distance, so that the egg freshness can be accurately divided according to an accurate function relationship between the density and the freshness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image recognition and detection, and in particular to an automatic egg grading method based on image recognition. Background Art

[0002] In the production, sales and related industrial chain of eggs, accurate classification of egg grades is of vital importance to ensuring product quality, meeting market demand and achieving reasonable pricing. Traditional egg grading methods mainly rely on manual experience and grade eggs by manually observing their appearance, such as size, shape, color and surface condition. This manual grading method has many limitations and cannot judge the freshness of eggs.

[0003] In terms of freshness detection, most traditional methods can only be determined through sampling testing. Sampling testing itself has limitations and cannot cover all products. This gives unscrupulous merchants an opportunity to take advantage of it. For example, they may mix a small amount of stale eggs into the samples sent for inspection. Since consumers cannot intuitively judge the freshness of the eggs when purchasing, this behavior of passing inferior products off as good ones harms consumer rights and disrupts market order. Therefore, image recognition is needed to conduct more comprehensive and detailed inspections of eggs, which is expected to overcome the many drawbacks of traditional grading methods and realize the automation and precision of egg grading. Summary of the invention

[0004] The purpose of the present invention is to provide an automated egg grading method based on image recognition, which solves the problem that the existing egg freshness detection in the background technology cannot cover all products.

[0005] To achieve the above object, the present invention provides the following technical solution: an automated egg grading method based on image recognition, comprising the following steps:

[0006] S1. Image acquisition: Use a high-resolution camera and uniform lighting equipment to obtain a clear image of the egg. The camera resolution is not less than 2000×2000 pixels. The lighting equipment uses a multi-angle white LED light source to ensure that the image is free of shadow interference.

[0007] S2. Image preprocessing: The collected images are processed by grayscale, filtering and noise reduction, and image segmentation in turn to obtain the discrete point coordinates of the egg outline (x i ,y i ), i=1,2,…,n;

[0008] S3. Storage and processing of outer contour data: Store the coordinate data of discrete points of the outer contour of multiple eggs, establish the algorithm formula between the outer contour data and the horizontal diameter and vertical diameter, and calculate the coordinates of the discrete points of the outer contour of the egg (x i ,y i), i = 1, 2, ... n, and the transverse diameter D is determined by ellipse fitting x and longitudinal diameter D y The ellipse fitting adopts the least square method to minimize the sum of the squares of the distances from the fitted ellipse to each discrete point. The ellipse equation is: in The ellipse parameters are solved by the optimization algorithm to obtain the relationship between the outer contour data and the horizontal diameter and vertical diameter. The formula is verified and optimized based on a large amount of sample data. The formula is: Where V is the volume of the egg, C is the outer contour data, k 1 and k 2 is the correction coefficient obtained by fitting the sample data;

[0009] S4. Egg contour matching and correction: After the egg contour is detected, the distance between it and the stored contour data is calculated using an improved algorithm based on the Householder distance. For the discrete point set A = {(x ai ,y ai )} and B={(x bi ,y bi )}, the Householder distance is defined as Calculate the Householder distance between the detected egg contour and the stored contours, find the contour with the smallest distance as the closest contour, and calculate the difference between the two Δ = H (A test ,A closest ), where A test To detect the outer contour of the egg, A closest The correction coefficient k is determined according to the gap to obtain the closest storage outer contour. The correction coefficient is obtained by fitting the experimental data in advance and using a quadratic function: k = aΔ 2 +bΔ+c, where a, b, and c are parameters determined experimentally;

[0010] S5. Egg weight measurement: Use a high-precision electronic scale to measure the egg weight m, with an accuracy of ±0.1 grams. The egg needs to be placed stably on the scale plate during measurement;

[0011] S6. Egg volume calculation: Measure the egg's horizontal diameter D x and longitudinal diameter D y , according to the matched closest outer contour and the corresponding transverse and longitudinal diameters, the egg volume is calculated by combining the outer contour data with the algorithm formula between the transverse and longitudinal diameters, and the correction coefficient k is considered in the calculation, that is, V final =V×(1+k);

[0012] S7. Density calculation and freshness relationship establishment: Based on the measured weight m and calculated volume V finalThe egg density was obtained, and the functional relationship between density and freshness was established through a large number of samples. The linear regression method was used to accurately judge the freshness of eggs.

[0013] S8. Grading and result output: Eggs are graded based on the established freshness function and preset grade standards, and relevant data is recorded. The system automatically diverts the eggs to the corresponding grade packaging areas to achieve automated grading of eggs.

[0014] Furthermore, the grayscale in the image preprocessing step adopts a weighted average method, and the formula is Gray=0.299R+0.587G+0.114B, where R, G, and B are the red, green, and blue channel pixel values ​​of the color image, respectively.

[0015] Furthermore, the filtering and noise reduction in the image preprocessing step uses Gaussian filtering, and its two-dimensional Gaussian function formula is: Where σ is the standard deviation, ranging from 0.5 to 1.5.

[0016] Furthermore, the image segmentation in the image preprocessing step uses an adaptive threshold segmentation algorithm, with the formula T(x,y)=μ(x,y)+kσ(x,y), where μ(x,y) is the average grayscale value of the local area (x,y), σ(x,y) is the standard deviation of the local area, and k ranges from 0.8 to 1.2. The threshold is dynamically determined according to the local grayscale characteristics of the image to separate the egg image from the background to obtain a binary image, in which the egg part is the foreground, the pixel value is set to 255, and the background part is 0.

[0017] Furthermore, in the step of establishing the relationship between density calculation and freshness, the density formula is used according to the measured egg weight m and the calculated volume V. Calculate the density of the egg.

[0018] Furthermore, the specific steps of using the linear regression method to determine the freshness of eggs in the step of establishing the relationship between density calculation and freshness are: assuming freshness to be F, the functional relationship between freshness and density is F=aρ+b, wherein a and b are coefficients obtained by fitting sample data, and the number of samples is no less than 500, covering eggs of different varieties and storage conditions.

[0019] Furthermore, in the grading and result outputting step, the egg grade is divided into four grades according to the full score of 100: eggs with F≥90 are classified as extra fresh, 80≤F<90 are classified as first-grade fresh, 70≤F<80 are classified as second-grade fresh, and F<70 are not fresh or defective.

[0020] Furthermore, in the image acquisition step, the camera is installed 30-50 cm above the egg conveying device, and the shooting angle is perpendicular to the egg surface.

[0021] Furthermore, in the outer contour data storage and processing step, the stored egg outer contour data covers eggs of different shapes and sizes, and is updated regularly to adapt to new egg varieties or changes in breeding conditions. When establishing the relationship between the outer contour data and the horizontal diameter and vertical diameter, the irregularity of the egg contour is taken into account, the method of fitting the ellipse is optimized, and a weighted fitting method is used.

[0022] Furthermore, in the step of establishing the relationship between density calculation and freshness, when establishing the functional relationship between density and freshness, the freshness of the sample eggs is comprehensively determined using a chemical analysis method.

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

[0024] The present invention provides an automated egg grading method based on image recognition. Clear images are collected by a high-resolution camera and uniform lighting equipment. Combined with an advanced image preprocessing algorithm, the coordinates of discrete points of the egg contour can be accurately extracted. The relationship between the outer contour data and the horizontal diameter and the vertical diameter is established by using an optimized ellipse fitting least squares method. The outer contour is matched and corrected by an algorithm improved based on the Householder distance, and a more accurate egg volume is calculated. The weight is measured by a high-precision electronic scale. Based on the accurate functional relationship between density and freshness, the freshness of the eggs can be accurately judged, thereby achieving accurate classification of the freshness grades of the eggs and effectively preventing unscrupulous vendors from taking advantage of detection loopholes to pass off inferior products as good ones. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a schematic diagram of the overall process of the present invention. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] In order to solve the technical problem that the existing egg freshness detection cannot cover all products, such as Figure 1 As shown, the following preferred technical solutions are provided:

[0028] An automated egg grading method based on image recognition comprises the following steps:

[0029] Step 1. Image acquisition: Use a high-resolution camera and uniform lighting equipment to obtain a clear image of the egg. The camera resolution is not less than 2000×2000 pixels. The lighting equipment uses a multi-angle white LED light source to ensure that the image is free of shadow interference. The camera is installed 30-50 cm above the egg conveyor, and the shooting angle is perpendicular to the egg surface.

[0030] Step 2. Image preprocessing: grayscale processing, filtering and noise reduction, and image segmentation are performed on the collected images in sequence to obtain the discrete point coordinates of the egg outline (x i ,y i ), i=1,2,…,n; Grayscale is converted by weighted average method, the formula is Gray=0.299R+0.587G+0.114B, where R, G, and B are the red, green, and blue channel pixel values ​​of the color image respectively. By reasonably allocating the RGB channel weights, the color image is converted into a grayscale image, which effectively reduces the amount of image data and retains the brightness information of the image for subsequent processing; Gaussian filtering is used for filtering and denoising, and its two-dimensional Gaussian function formula is Where σ is the standard deviation, ranging from 0.5 to 1.5. By weighted summing each pixel in the image with its neighboring pixels, the image can be effectively smoothed, noise interference can be removed, and the edge and detail information of the egg image can be retained; the image segmentation uses an adaptive threshold segmentation algorithm, the formula is T(x,y)=μ(x,y)+kσ(x,y), where μ(x,y) is the average gray value of the local area (x,y), σ(x,y) is the standard deviation of the local area, and k ranges from 0.8 to 1.2. The threshold is dynamically determined according to the local grayscale characteristics of the image, and the egg image is separated from the background to obtain a binary image, in which the egg part is the foreground, the pixel value is set to 255, and the background part is 0;

[0031] Step 3. Storage and processing of outer contour data: Store the coordinate data of discrete points of multiple egg outer contours, establish an algorithm formula between the outer contour data and the horizontal and vertical diameters, and calculate the coordinates of discrete points of the egg outer contour (x i ,y i ), i = 1, 2, ... n, and the transverse diameter D is determined by ellipse fitting x and longitudinal diameter D y The ellipse fitting adopts the least square method to minimize the sum of the squares of the distances from the fitted ellipse to each discrete point. The ellipse equation is: in The ellipse parameters are solved by the optimization algorithm to obtain the relationship between the outer contour data and the horizontal diameter and vertical diameter. The formula is verified and optimized based on a large amount of sample data. The formula is: Where V is the volume of the egg, C is the outer contour data, k 1 and k 2The correction coefficient is obtained by fitting the sample data. The stored egg contour data covers eggs of different shapes and sizes, and is updated regularly to adapt to new egg varieties or changes in breeding conditions. When establishing the relationship between the contour data and the horizontal and vertical diameters, the irregularity of the egg contour is considered, the method of fitting the ellipse is optimized, and the weighted fitting method is used;

[0032] Step 4. Egg contour matching and correction: After the egg contour is detected, the distance between it and the stored contour data is calculated using an algorithm based on the Householder distance improvement. For the discrete point set A = {(x ai ,y ai )} and B={(x bi ,y bi )}, Householder distance is defined as Calculate the Householder distance between the detected egg contour and the stored contours, find the contour with the smallest distance as the closest contour, and calculate the difference between the two Δ = H (A test ,A closest ), where A test To detect the outer contour of the egg, A closest The correction coefficient k is determined according to the gap to obtain the closest storage outer contour. The correction coefficient is obtained by fitting the experimental data in advance and using a quadratic function: k = aΔ 2 +bΔ+c, where a, b, and c are parameters determined experimentally;

[0033] Step 5. Egg weight measurement: Use a high-precision electronic scale to measure the egg weight m, with an accuracy of ±0.1 grams. The egg needs to be placed stably on the scale plate during measurement;

[0034] Step 6. Calculate the egg volume: Measure the egg's horizontal diameter D x and longitudinal diameter D y , according to the matched closest outer contour and the corresponding transverse and longitudinal diameters, the egg volume is calculated by combining the outer contour data with the algorithm formula between the transverse and longitudinal diameters, and the correction coefficient k is considered in the calculation, that is, V final =V×(1+k);

[0035] Step 7. Density calculation and freshness relationship establishment: Based on the measured weight m and calculated volume V final Find the egg density The functional relationship between density and freshness is established through a large number of samples, and the linear regression method is used to accurately judge the freshness of eggs. The freshness of the sample eggs is comprehensively determined by chemical analysis to improve the accuracy of freshness judgment. The specific steps for judging the freshness of eggs are: let freshness be F, and the functional relationship between freshness and density is F=aρ+b, where a and b are coefficients obtained by fitting the sample data. The number of samples is not less than 500, covering eggs of different varieties and storage conditions. ;

[0036] Step 8. Grading and result output: Based on the established freshness function relationship and the preset grading standards, the eggs are graded and the relevant data is recorded. The system automatically diverts the eggs to the corresponding grade packaging area to achieve automatic grading of eggs. The egg grade is calculated based on a full score of 100 and is divided into four levels: eggs with F≥90 are classified as extra fresh, 80≤F<90 are classified as first-grade fresh, 70≤F<80 are classified as second-grade fresh, and F<70 are not fresh or defective.

[0037] Specifically, a high-resolution camera is used in conjunction with a multi-angle white LED light source to obtain a clear, shadow-free egg image. The collected image is subjected to grayscale, filtering, noise reduction, and image segmentation preprocessing operations to accurately extract the discrete point coordinates of the egg contour. The stored multiple egg contour data are used to establish an algorithm formula related to the horizontal diameter and vertical diameter, and the shape characteristics of the egg are determined by ellipse fitting. When a new egg is detected, its contour is compared with the stored data using an improved algorithm based on the Householder distance, the closest contour is found and the gap is calculated, thereby obtaining a correction coefficient to optimize the volume calculation. At the same time, a high-precision electronic scale measures the weight of the egg. Combined with the calculated volume, the egg density is obtained according to the density formula, and then the freshness of the egg is judged based on the density and freshness function relationship established by a large number of samples. Finally, the system automatically diverts the eggs to the corresponding grade packaging area to achieve automated grading.

[0038] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0039] The above are only preferred specific implementation modes of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical solutions and inventive concepts of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. An automated egg grading method based on image recognition, characterized in that: The following steps are involved: S1. Image acquisition: Use a high-resolution camera and uniform lighting equipment to obtain a clear image of the egg. The camera resolution is not less than 2000×2000 pixels. The lighting equipment uses a multi-angle white LED light source to ensure that the image is free of shadow interference. S2. Image preprocessing: The collected images are processed in grayscale, filtered for noise reduction, and image segmentation to obtain the discrete point coordinates of the egg outline (x i ,y i ), i=1,2,…,n; S3. Storage and processing of outer contour data: Store the coordinate data of discrete points of the outer contour of multiple eggs, establish the algorithm formula between the outer contour data and the horizontal diameter and vertical diameter, and calculate the coordinates of the discrete points of the outer contour of the egg (x i ,y i ), i = 1, 2, ... n, and the transverse diameter D is determined by ellipse fitting x and longitudinal diameter D y The ellipse fitting adopts the least square method to minimize the sum of the squares of the distances from the fitted ellipse to each discrete point. The ellipse equation is: in The ellipse parameters are solved by the optimization algorithm to obtain the relationship between the outer contour data and the horizontal diameter and vertical diameter. The formula is verified and optimized based on a large amount of sample data. The formula is: Where V is the volume of the egg, C is the outer contour data, k1 and k2 are the correction coefficients obtained by fitting the sample data; S4. Egg contour matching and correction: After the egg contour is detected, the distance between it and the stored contour data is calculated using an improved algorithm based on the Householder distance. For the discrete point set A = {(x ai ,y ai )} and B={(x bi ,y bi )}, Householder distance is defined as Calculate the Householder distance between the detected egg contour and the stored contours, find the contour with the smallest distance as the closest contour, and calculate the difference between the two Δ = H (A test ,A closest ), where A test To detect the outer contour of the egg, A closest The correction coefficient k is determined according to the gap to obtain the closest storage outer contour. The correction coefficient is obtained by fitting the experimental data in advance and using a quadratic function: k = aΔ 2 +bΔ+c, where a, b, and c are parameters determined experimentally; S5. Egg weight measurement: Use a high-precision electronic scale to measure the egg weight m, with an accuracy of ±0.1 grams. The egg needs to be placed stably on the scale plate during measurement; S6. Egg volume calculation: Measure the egg's horizontal diameter D x and longitudinal diameter D y , according to the matched closest outer contour and the corresponding transverse and longitudinal diameters, the egg volume is calculated by combining the outer contour data with the algorithm formula between the transverse and longitudinal diameters, and the correction coefficient k is considered in the calculation, that is, V final =V×(1+k); S7. Density calculation and freshness relationship establishment: Based on the measured weight m and calculated volume V final The egg density was obtained, and the functional relationship between density and freshness was established through a large number of samples. The linear regression method was used to accurately judge the freshness of eggs. S8. Grading and result output: Eggs are graded based on the established freshness function and preset grade standards, and relevant data is recorded. The system automatically diverts the eggs to the corresponding grade packaging areas to achieve automated grading of eggs.

2. An automated egg grading method based on image recognition as claimed in claim 1, characterized in that: The grayscale in the image preprocessing step adopts a weighted average method, and the formula is Gray=0.299R+0.587G+0.114B, where R, G, and B are the red, green, and blue channel pixel values ​​of the color image respectively.

3. The method for automated egg grading based on image recognition according to claim 1, characterized in that: The filtering and noise reduction in the image preprocessing step uses Gaussian filtering, and its two-dimensional Gaussian function formula is: Where σ is the standard deviation, ranging from 0.5 to 1.

5.

4. The method for automated egg grading based on image recognition as claimed in claim 1, characterized in that: The image segmentation in the image preprocessing step uses an adaptive threshold segmentation algorithm, and the formula is T(x,y)=μ(x,y)+kσ(x,y), where μ(x,y) is the average grayscale value of the local area (x,y), σ(x,y) is the standard deviation of the local area, and k ranges from 0.8 to 1.

2. The threshold is dynamically determined according to the local grayscale characteristics of the image, and the egg image is separated from the background to obtain a binary image, in which the egg part is the foreground, the pixel value is set to 255, and the background part is 0.

5. The method for automated egg grading based on image recognition as claimed in claim 1, characterized in that: In the step of establishing the relationship between density calculation and freshness, the density formula is used according to the measured egg weight m and the calculated volume V. Calculate the density of the egg.

6. An automated egg grading method based on image recognition as claimed in claim 1, characterized in that: The specific steps of using the linear regression method to determine the freshness of eggs in the step of establishing the relationship between density calculation and freshness are: assuming that freshness is F, the functional relationship between freshness and density is F=aρ+b, wherein a and b are coefficients obtained by fitting sample data, and the number of samples is not less than 500, covering eggs of different varieties and storage conditions.

7. An automated egg grading method based on image recognition as claimed in claim 6, characterized in that: In the step of grading and outputting results, the egg grade is divided into four grades according to the full score of 100: eggs with F≥90 are classified as extra fresh, 80≤F<90 are classified as first-grade fresh, 70≤F<80 are classified as second-grade fresh, and F<70 are not fresh or defective.

8. The method for automated egg grading based on image recognition as claimed in claim 1, characterized in that: In the image acquisition step, the camera is installed 30-50 cm above the egg conveying device, and the shooting angle is perpendicular to the egg surface.

9. An automated egg grading method based on image recognition as claimed in claim 1, characterized in that: In the outer contour data storage and processing step, the stored egg outer contour data covers eggs of different shapes and sizes, and is updated regularly to adapt to new egg varieties or changes in breeding conditions. When establishing the relationship between the outer contour data and the horizontal diameter and the vertical diameter, the irregularity of the egg contour is taken into account, the method of fitting the ellipse is optimized, and a weighted fitting method is used.

10. An automated egg grading method based on image recognition as claimed in claim 9, characterized in that: In the step of establishing the relationship between density calculation and freshness, when establishing the functional relationship between density and freshness, the freshness of the sample eggs is comprehensively determined by chemical analysis.

Citation Information

Patent Citations

  • Machine vision technology based method for rapidly detecting egg freshness

    CN102147402A

  • Method for processing plane figure image

    CN105787995A

  • Rapid nondestructive detection system and method for freshness of eggs

    CN108802060A

  • Tiny droplet volume measurement method adopting eight ellipsoids for fitting

    CN113686739A

  • Inkjet device and method of ink-jetting using the same

    KR1020230126298A

Cited By

  • Coal gangue processing method and system, electronic equipment and storage medium

    CN120190144A

  • Coal gangue processing method, system, electronic equipment and storage medium

    CN120190144B

  • Network model and method for identifying egg type, and storage medium

    CN121121727A

  • An egg type recognition network model and method, and a storage medium

    CN121121727B