A honey quality detection method based on machine vision
By using machine vision technology to extract the bubble and color characteristics of honey samples and establish a detection model, the accuracy and efficiency problems of honey quality detection are solved, and efficient and personalized honey quality detection is achieved.
Patent Information
- Application Number
- CN202510587818.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-05-08
AI Technical Summary
Existing honey quality testing relies on manual experience, which is unstable, costly, and inefficient. Instrument testing is difficult to apply on a large scale, and counterfeiting technology causes feature detection to fail.
Using machine vision technology, the bubble characteristics and color characteristics of honey samples are extracted from the defoaming video, and a detection model for unique honey and non-unique honey is established. The bubble model of non-unique honey is established based on the bubble changes for quality inspection.
It improves the accuracy and efficiency of honey quality testing, reduces the amount of calculation, provides more specific testing basis, and standardizes the testing process.
Smart Images

Figure CN120102475B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and more specifically, to a honey quality detection method based on machine vision. Background Art
[0002] In order to ensure the safety of honey food, it is often necessary to conduct quality testing on honey.
[0003] Currently, honey quality testing relies primarily on manual judgment to determine whether characteristics such as color, viscosity, and surface bubbles are consistent with those of genuine honey. However, due to varying experience and visual abilities, honey quality testing is unstable and lacks accuracy. With the development of optical instruments and the maturity of component detection technology, instrumentation is also being used to detect the content of various components in the honey being tested. However, instrument-based testing is costly and inefficient, making it impractical for large-scale quality testing.
[0004] Manual quality inspection of honey is based on its color, viscosity, and surface bubbles, while machine vision can more accurately analyze these characteristics. Therefore, machine vision technology can reduce reliance on manual inspection and improve inspection efficiency. However, with the development of counterfeiting techniques, such as the addition of coloring, fructose syrup, and the substitution of inferior products for genuine ones, it is difficult to accurately inspect honey quality based on these characteristics. Summary of the Invention
[0005] In order to solve the above technical problem of poor honey quality detection effect, the present invention provides a honey quality detection method based on machine vision, comprising:
[0006] Honey is sampled to obtain a honey sample, the honey sample is stirred and then allowed to stand to obtain a defoaming video of the honey sample; bubble characteristics are extracted from the defoaming video of the honey sample, including the number of bubbles, average bubble size and average bubble life; the bubble uniqueness of each honey is determined based on the bubble characteristic differences of all honey samples; the color uniqueness of each honey is determined based on the color differences of all honey samples; all honeys are divided into unique honey and non-unique honey based on the bubble uniqueness and color uniqueness; a detection model for unique honey is established; a bubble model for non-unique honey is established based on the bubble changes during the standing process; based on the differences in the bubble models of all non-unique honeys, characteristic video frames of each non-unique honey are obtained, and a detection model for each non-unique honey is established; the honey sample to be tested is compared with the detection models of unique honey and non-unique honey to complete quality inspection.
[0007] The present invention stirs honey samples and captures defoaming videos, leveraging the ability of certain enzymes in honey to react and generate bubbles. This allows for differentiation and effective detection of the type and authenticity of the honey being tested. The present invention classifies honey based on bubble characteristics and color, enabling more detailed quality testing and more specific quantification of honey quality. This allows for more detailed analysis of honey composition and the characteristics of counterfeit honey, benefiting the honey quality testing industry.
[0008] Preferably, the extracting bubble features from the honey sample defoaming video includes: performing Hough circle detection on all video frames of the honey sample defoaming video to obtain several detection circles for each video frame; recording one detection circle as a bubble; recording the center of the detection circle as the bubble center of the bubble; obtaining the area of the detection circle through the radius of the detection circle, which is recorded as the bubble size; for any bubble center, obtaining continuous video frames in which the bubble center exists, and recording the corresponding duration as the bubble life of the bubble corresponding to the bubble center; counting the bubbles in all different bubble centers to obtain the number of bubbles in the honey sample defoaming video; and obtaining the average bubble size and average bubble life of the honey sample defoaming video.
[0009] The bubble characteristics of the present invention fully consider the liquid environment of honey. Honey with different viscosities will result in different speeds of bubble disappearance and diffusion sizes. Therefore, the average bubble size and average bubble life in the bubble characteristics can distinguish the type of honey and its authenticity.
[0010] Preferably, the method of determining the bubble uniqueness of each honey based on the bubble characteristic differences of all honey samples includes: taking the mean of the bubble characteristics of all honey sample defoaming videos of each honey as the characteristic value of the bubble characteristics of each honey; for two honeys, calculating the difference of all identical bubble characteristics and taking the absolute value as the difference of the identical bubble characteristics of the two honeys; normalizing the differences of all identical bubble characteristics of the two honeys and then summing them to obtain the bubble difference of the two honeys; and taking the mean of the bubble differences between each honey and all other honeys as the bubble uniqueness of each honey.
[0011] Preferably, the method of determining the color uniqueness of each honey based on the color difference of all honey samples includes: recording the average hue, average saturation, and average brightness of all pixel points in the last video frame of the defoaming video of all honey samples of each honey as the hue, saturation, and brightness of each honey; for two honeys, calculating the difference in hue, saturation, and brightness and taking the absolute value as the hue difference, saturation difference, and brightness difference of the two honeys, normalizing the hue difference, saturation difference, and brightness difference of the two honeys and summing them to obtain the color difference of the two honeys; and taking the average of the color difference between each honey and all other honeys as the color uniqueness of each honey.
[0012] The present invention takes into account the color characteristics of honey and uses the HSV color space to clearly represent the color of honey. When the color of honey is unique, the honey can be distinguished based on the color.
[0013] Preferably, the method of classifying all honeys into unique honey and non-unique honey based on bubble uniqueness and color uniqueness includes: setting a first threshold, and when the color uniqueness of honey is greater than the first threshold and the bubble uniqueness is greater than the first threshold, recording the honey as unique honey; when the color uniqueness of honey is less than or equal to the first threshold or the bubble uniqueness is less than or equal to the first threshold, recording the honey as non-unique honey.
[0014] The present invention divides honey into unique honey and non-unique honey. Due to the variety of honey types, some of the more unique honeys, such as those with extremely high viscosity and special colors, have very few bubbles and are easy to identify. Therefore, quality inspection can be carried out based on bubble characteristics and color. However, due to the similarity of bubble characteristics and color of non-unique honey, the defoaming process should also be specifically analyzed.
[0015] Preferably, the establishment of a detection model for unique honey includes: if the value range of the a-th feature of the i-th unique honey only contains the i-th unique honey, then the value range is recorded as the detection value range of the a-th feature of the i-th unique honey; if the value range of the a-th feature of the i-th unique honey contains characteristic values of other honeys, then the mean value of the a-th feature of the i-th unique honey is used as the detection threshold of the a-th feature of the i-th unique honey; the bubble characteristics, hue, saturation, brightness of the honey, and the corresponding detection thresholds or detection value ranges together constitute the detection model for the unique honey.
[0016] Preferably, the method of establishing a bubble model of non-unique honey based on the bubble changes during the standing process includes: all bubble sizes and corresponding bubble numbers in the video frame constitute the bubble distribution of the video frame; the bubble distribution of the video frames at the same moment of the defoaming videos of all honey samples of the same non-unique honey is averaged to serve as the bubble distribution of the non-unique honey; the bubble distribution at all moments constitutes the bubble model of the non-unique honey.
[0017] Preferably, the step of obtaining the characteristic video frames of each non-unique honey includes:
[0018] Obtain the bubble distribution types of the neighborhood video frames of the sth video frame of each non-unique honey;
[0019] ;
[0020] Take any non-unique honey as the target non-unique honey, where, Represents the feature saliency index of the target non-unique honey in the s-th video frame; Indicates the bubble distribution type of the neighborhood video frame of the s-th video frame of the target non-unique honey; Indicates the type of bubble size; 、 represents the number of bubbles of the gth bubble size in the uth and vth bubble distributions of the target non-unique honey in the sth video frame; represents the normalization function;
[0021] The video frames whose feature significance index is greater than the second threshold are recorded as the feature video frames of the target non-unique honey, and the corresponding bubble distribution is the feature value.
[0022] The present invention selects the time that can represent the change of bubble distribution from the defoaming video of non-unique honey, which reduces the computational complexity of analyzing each video frame. When detecting honey quality, only a few characteristic video frames need to be analyzed, thereby improving the efficiency of honey quality detection.
[0023] Preferably, the establishment of the detection model of each non-unique honey includes: comparing the bubble distribution of the honey sample to be tested with all characteristic video frames of each non-unique honey to obtain the qualification of the honey sample to be tested relative to each non-unique honey; setting a qualification threshold, and using all characteristic video frames of each non-unique honey, the corresponding bubble distribution and the qualification threshold as the detection model of each non-unique honey.
[0024] Preferably, the qualification of the honey sample to be tested relative to each non-unique honey satisfies the expression:
[0025] ;
[0026] Where, Indicates the qualification of the detection model of the honey sample to be tested and the dth non-unique honey; The number of feature video frames representing the detection model of the d-th type of non-unique honey; Indicates the type of bubble size; 、 It represents the number of bubbles of the gth bubble size of the honey sample to be tested and the detection model of the dth non-unique honey at the yth feature video frame time; Represents an exponential function with a natural constant as its base.
[0027] The beneficial effects of the present invention are:
[0028] (1) The present invention standardizes the process of honey quality detection, avoids the problem of insufficient accuracy of manual experience judgment, and also avoids the problem of high cost and low efficiency of instrument detection, thereby improving the accuracy and efficiency of honey quality detection;
[0029] (2) The detection model of unique honey and non-unique honey of the present invention makes honey detection more personalized, reduces the computational complexity of unique honey detection, and further improves the efficiency of honey quality detection;
[0030] (3) In the present invention, the bubble model of non-unique honey enables the defoaming process of non-unique honey to be visualized, providing a more specific basis for staff to detect honey. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 is a flow chart schematically illustrating a honey quality detection method based on machine vision in the present invention;
[0032] Figure 2 is a schematic diagram schematically illustrating a stirring device;
[0033] Figure 3 is a diagram schematically illustrating characteristic values of unique honey;
[0034] Figure 4 is a diagram schematically illustrating a bubble model of non-unique honey. DETAILED DESCRIPTION
[0035] The embodiment of the present invention discloses a honey quality detection method based on machine vision, referring to Figure 1 , including steps S1 to S4:
[0036] S1: Sample honey to obtain a honey sample, stir the honey sample and let it stand, and obtain a video of the honey sample defoaming.
[0037] It should be noted that honey contains at least 200 substances, including sugars, water, proteins, enzymes, pigments, and aroma compounds. Natural honey, rich in organic matter and various enzymes, reacts to generate gases, often resulting in small bubbles. Stirring the honey promotes the enzyme reactions within it, and the resulting changes in the state of the bubbles reflect the concentrations of the corresponding honey components, serving as a characteristic indicator of honey quality. Therefore, a video of the honey defoaming process is first required.
[0038] Specifically, several kinds of honey are obtained, and samples are taken from each kind of honey to obtain several honey samples of each kind of honey. Each honey sample is placed in a stirring device and stirred for a preset time. Then, each honey sample is placed in a static device to obtain several honey sample defoaming videos.
[0039] Among them, the sampling process, the sampling quantity and sampling capacity of each type of honey are set by the implementer according to the actual implementation situation, and there is no specific restriction. For example, 5 samples of each type of honey are taken, and the sampling capacity is 10 ml.
[0040] The stirring device schematic diagram is as follows Figure 2 , place the stirring head at the center of the honey sample; the stirring parameters including the speed of the stirring head and the stirring time are set by the implementer according to the actual implementation situation, and there is no specific restriction, for example, the speed is 600 rpm and the stirring time is 20 s.
[0041] The stationary device includes a platform, a camera placed directly above it, and a shadowless light source directly above it.
[0042] The duration of the honey sample defoaming video is unified and is set by the implementer according to the actual implementation situation, without specific restrictions, for example, 10 minutes.
[0043] So far, several honey sample defoaming videos of several types of honey have been obtained.
[0044] S2: Extract bubble features from the defoaming video of honey samples, including the number of bubbles, average bubble size, and average bubble lifetime; determine the bubble uniqueness of each honey based on the differences in bubble features of all honey samples; determine the color uniqueness of each honey based on the color differences of all honey samples; classify all honeys into unique honey and non-unique honey based on bubble uniqueness and color uniqueness; and establish a detection model for unique honey.
[0045] It should be noted that the formation of bubbles in honey is related to its components, while the rise and disappearance of bubbles are related to the solution in which they are located, namely, the honey. Therefore, bubble size and bubble lifespan can be used as bubble characteristics to describe a honey sample. First, bubbles need to be detected. Since bubbles are all round, bubble detection is also known as circle detection. Hough circle detection is an existing technique for detecting circular objects in image processing and can therefore be used for bubble detection in this invention. Next, the bubbles are located, and the lifespan and size of each bubble are obtained, thereby obtaining the bubble characteristics of the honey sample.
[0046] It should be noted that, since different types of honey have certain similarities in composition, color, as a significant characteristic, can also characterize honey. For example, acacia honey is watery white, eucalyptus honey is dark amber, and linden honey is light amber. Therefore, it is possible to distinguish honey by combining bubble characteristics and color characteristics to avoid detection errors caused by a single characteristic. In addition, the more unique the bubble characteristics and color characteristics of honey, the more they can represent a particular honey. Therefore, the bubble uniqueness and color uniqueness of the honey are first calculated. The more unique the honey type, the easier it is to distinguish. Conversely, the less unique the honey type, the more difficult it is to distinguish if the characteristics are more similar. Therefore, honey can be divided into unique honey and non-unique honey. For unique honey, bubble characteristics and color characteristics can be used as detection models for detection.
[0047] Specifically, bubble features are extracted from the honey sample defoaming video.
[0048] Hough circle detection is performed on all video frames of the honey sample defoaming video to obtain several detection circles for each video frame; a detection circle is recorded as a bubble; the center of the detection circle is recorded as the bubble center of the bubble; the area of the detection circle is obtained by the radius of the detection circle, which is recorded as the bubble size; for any bubble center, continuous video frames in which the bubble center exists are obtained, and the corresponding duration is recorded as the bubble lifespan of the bubble corresponding to the bubble center; bubbles at all different bubble centers are counted to obtain the number of bubbles in the honey sample defoaming video.
[0049] Get the average bubble size and average bubble lifespan of the honey sample defoaming video.
[0050] Preferably, the bubble uniqueness of each honey is determined based on the differences in bubble characteristics of all honey samples:
[0051] The mean value of the bubble characteristics of all honey sample defoaming videos of each honey is used as the characteristic value of the bubble characteristics of each honey;
[0052] The difference in bubbles between the two honeys satisfies the expression:
[0053] ;
[0054] Where, represents the difference in bubbles between the i-th honey and the k-th honey; 、 represents the number of bubbles in the i-th and k-th honeys; 、 Indicates the bubble size of the i-th and k-th honey; 、 represents the bubble lifespan of the i-th and k-th honeys; Represents the maximum function.
[0055] Where, 、 、 represents the difference in the number of bubbles, the size of bubbles, and the lifespan of bubbles between the i-th and k-th honeys; 、 、 Indicates the maximum number of bubbles, maximum bubble size, and maximum bubble life of the i-th and k-th honeys; 、 、 It indicates that the difference in the number of bubbles, the size of bubbles, and the life span of bubbles between the i-th and k-th honeys is normalized.
[0056] The uniqueness of bubbles in any type of honey satisfies the expression:
[0057] ;
[0058] Where, represents the bubble uniqueness of the i-th honey; Indicates the type of honey; represents the difference in bubbles between the i-th honey and the k-th honey.
[0059] Where, It means that the mean of the bubble difference between the i-th honey and all honeys is taken as the bubble uniqueness of the i-th honey. The greater the bubble difference between the i-th honey and the rest of the honeys, the greater the bubble uniqueness of the i-th honey.
[0060] It should be noted that honey has similar colors. International trade standards classify honey colors into seven levels: water white, extra white, white, extra light amber, light amber, amber, and dark amber. The RGB color space uses three channels (red, green, and blue) to represent images, which is not intuitive for honey colors. The HSV color space, on the other hand, uses hue, saturation, and lightness to represent images. Honey has similar lightness, but hue and saturation fall within the same range, making it capable of accurately representing analogous colors like "amber." Therefore, this paper uses the HSV color space to compare honey color differences.
[0061] Preferably, the color uniqueness of each honey is determined based on the color differences of all honey samples:
[0062] The average hue, average saturation, and average brightness of all pixels in the last video frame of all honey sample defoaming videos of each honey are recorded as the hue, saturation, and brightness of each honey;
[0063] The color difference between any two honeys satisfies the expression:
[0064] ;
[0065] Where, represents the color difference between the i-th honey and the k-th honey; 、 represents the hue of the i-th and k-th honey; 、 Indicates the saturation of the i-th and k-th honeys; 、 Indicates the brightness of the i-th and k-th honeys.
[0066] Where, 、 、 Indicates the difference in hue, saturation, and brightness between the i-th and k-th honeys; , 255, 255 represents the value range of hue, saturation, and brightness; 、 、 It means normalizing the hue, saturation, and brightness differences between the i-th and k-th honeys.
[0067] The color uniqueness of any kind of honey satisfies the expression:
[0068] ;
[0069] Where, represents the color uniqueness of the i-th honey; Indicates the type of honey; Indicates the color difference between the i-th honey and the k-th honey.
[0070] Where, It means that the mean of the color difference between the i-th honey and all honeys is taken as the color uniqueness of the i-th honey. The greater the color difference between the i-th honey and the rest of the honeys, the greater the color uniqueness of the i-th honey.
[0071] At this point, the bubble uniqueness and color uniqueness of various honeys were obtained.
[0072] A first threshold is set. When the color uniqueness of honey is greater than the first threshold and the bubble uniqueness is greater than the first threshold, the honey is recorded as unique honey; when the color uniqueness of honey is less than or equal to the first threshold or the bubble uniqueness is less than or equal to the first threshold, the honey is recorded as non-unique honey.
[0073] It should be noted that the first threshold is set by the implementer according to the actual implementation situation and is not specifically limited. For example, the first threshold is set to 0.5.
[0074] For the ath feature of the unique honey, plot a one-dimensional coordinate system, and plot the eigenvalues of the ath feature of all honey samples in a one-dimensional coordinate system.
[0075] Figure 3 is a schematic diagram of the characteristic values of unique honey, such as Figure 3 In case A, if the value range of the a-th feature of the i-th unique honey only contains the i-th unique honey, then this value range is recorded as the detection value range of the a-th feature of the i-th unique honey; Figure 3 In case B, if the value range of the a-th feature of the i-th unique honey contains the feature values of other honeys, the mean value of the a-th feature of the i-th unique honey is used as the detection threshold of the a-th feature of the i-th unique honey.
[0076] Preferably, the bubble characteristics, hue, saturation, brightness of honey, and the corresponding detection threshold or detection value range together constitute a detection model for unique honey.
[0077] At this point, the detection models for all unique honeys are obtained.
[0078] S3: Based on the bubble changes during the static process, a bubble model of the non-unique honey is established; based on the differences in the bubble models of all non-unique honeys, a feature video frame of each non-unique honey is obtained, and a detection model for each non-unique honey is established.
[0079] It should be noted that for non-unique honey, in order to conduct more accurate detection, a more specific analysis should be conducted on the defoaming process. Due to the complex composition of honey and the different proportions of various components, factors such as viscosity that affect the disappearance of bubbles are different. Therefore, in non-unique honey, the defoaming process still has certain differences. In the honey sample defoaming video, bubbles rise from the honey to the surface and eventually disappear. The proportion of bubbles of different sizes in each frame is different. At the beginning, the surface bubble density is larger, and the number of bubbles will decrease as time goes by, and eventually all disappear. Therefore, the changes in the number of bubbles of each size over time together constitute the bubble model of the honey sample.
[0080] It should be noted that in the bubble model of non-unique honey, due to the viscosity of honey, the bubbles cannot disappear quickly, so there will be a large number of video frames with repeated states. If the bubbles at every moment of the honey to be tested are compared with each bubble model, the similarity between the honey to be tested and each bubble model will be relatively high, making it difficult to effectively distinguish them. Therefore, the bubble model of non-unique honey should be screened, and feature video frames that can better distinguish non-unique honey should be selected, so that the quality of the honey to be tested can be effectively tested by comparing these feature video frames.
[0081] Preferably, a bubble model of non-unique honey is established based on the bubble changes during the standing process:
[0082] All bubble sizes and corresponding bubble numbers in a video frame constitute the bubble distribution of the video frame.
[0083] The bubble distribution of the video frames at the same moment of the defoaming videos of all honey samples of the same non-unique honey is averaged to obtain the bubble distribution of the non-unique honey. The bubble distribution at all moments constitutes the bubble model of the non-unique honey, as shown in the following example: Figure 4 Schematic diagram of the bubble model for non-unique honey.
[0084] Preferably, the characteristic video frames of each non-unique honey are obtained:
[0085] It should be noted that at the beginning of the honey sample defoaming video, there are more bubbles on the surface, so the number of larger bubbles is greater. As the surface bubbles disappear and the bubbles in the middle of the honey rise, the number of bubbles is maintained for a certain period of time and the proportion of each bubble size changes. However, due to the viscosity of honey, the change of bubbles is relatively slow. Therefore, there are the same continuous video frames in the video. Therefore, for the video frame, the greater the change in the number and proportion of bubbles within a certain period of time, and the greater the difference with other non-unique honeys, the more obvious the feature performance of the video frame, and the more it can be used as a feature video frame to represent non-unique honey.
[0086] Obtain the bubble distribution types for the neighboring video frames of the sth video frame for each non-unique honey. It should be noted that the neighboring video frames include videos of the left and right neighboring frames within a preset time. The preset time is set by the implementer based on actual implementation and is not limited to specific settings. For example, the preset time is set to 2 seconds.
[0087] It should be noted that, the more types of bubble distributions there are in the neighborhood of a video frame, and the greater the differences in the bubble distributions, the more significant the changes in bubbles in the neighborhood of the video frame.
[0088] The feature saliency index of each non-unique honey in the sth video frame satisfies the expression:
[0089] ;
[0090] Take any non-unique honey as the target non-unique honey, where, Represents the feature saliency index of the target non-unique honey in the s-th video frame; Indicates the bubble distribution type of the neighborhood video frame of the s-th video frame of the target non-unique honey; Indicates the type of bubble size; 、 represents the number of bubbles of the gth bubble size in the uth and vth bubble distributions of the target non-unique honey in the sth video frame; Represents the normalization function.
[0091] Where, represents the difference in the number of bubbles of the same size with different bubble distributions, It means adding up the differences in the number of bubbles of different bubble distributions, and it means the difference in the number of bubbles of different bubble distributions. It means adding up the differences in the number of bubbles of all different bubble distributions in the s-th video frame. The larger the value, the more drastic the change of bubbles in the neighborhood of the s-th video frame, and thus the larger the feature significance index of the s-th video frame.
[0092] Video frames with a Feature Significance Index greater than the second threshold are recorded as feature frames of the target non-unique honey, and the corresponding bubble distribution is the feature value. It should be noted that if there are consecutive video frames that meet this requirement, the one with the highest Feature Significance Index among the consecutive frames should be selected. The second threshold is set by the implementer based on actual implementation and is not limited to specific settings. For example, the second threshold can be set to 0.5.
[0093] Preferably, a detection model for each non-unique honey is established:
[0094] The bubble distributions of all characteristic video frames of the honey sample to be tested and each non-unique honey are compared to obtain the qualification of the honey sample to be tested relative to each non-unique honey.
[0095] The qualification of the honey sample to be tested relative to each non-unique honey satisfies the expression:
[0096] ;
[0097] Where, Indicates the qualification of the detection model of the honey sample to be tested and the dth non-unique honey; The number of feature video frames representing the detection model of the d-th non-unique honey; Indicates the type of bubble size; 、 It represents the number of bubbles of the gth bubble size of the honey sample to be tested and the detection model of the dth non-unique honey at the yth feature video frame time; Represents an exponential function with a natural constant as its base.
[0098] Where, It represents the difference in the number of bubbles of one bubble size between the honey sample to be tested and the detection model of the d-th non-unique honey. It means adding up the differences in the number of bubbles of all types of bubble sizes. It represents the sum of the differences in the number of bubbles in all characteristic time frames between the honey sample to be tested and the detection model of the d-th non-unique honey. It represents the difference between the detection model of the honey sample to be tested and the d-th non-unique honey. The larger the value, the less the honey to be tested conforms to the defoaming process of the d-th non-unique honey, and the lower the qualification of the detection model for the d-th non-unique honey.
[0099] A pass threshold is set, and all characteristic video frames of the non-unique honey, the corresponding bubble distribution, and the pass threshold are used as a detection model for the non-unique honey. It should be noted that the pass threshold is set by the implementer based on actual implementation circumstances and is not limited to specific circumstances. For example, the pass threshold is set to 0.5.
[0100] At this point, the detection models for each non-unique honey were obtained.
[0101] S4: Compare the honey sample to be tested with the detection models of unique honey and non-unique honey to complete the quality detection.
[0102] It should be noted that after obtaining the honey sample to be tested, it is necessary to determine the type and authenticity of the honey. If the degree of match with the detection model of unique honey is high, the type and quality of the honey to be tested can be obtained. If the degree of match with the detection model of unique honey is relatively low, it is necessary to continue to compare with the detection model of non-unique honey to obtain the type and quality of the honey to be tested.
[0103] It's important to note that the stirring process allows the enzymes responsible for bubble formation to fully react. The defoaming of the bubbles then reflects the enzyme content in the honey, as well as the honey's viscosity. The viscosity of real honey affects the disappearance of bubbles, causing them to disappear more slowly. Therefore, the authenticity of the honey under test can be determined by using the variation in the number of bubbles in real honey, a detection model for non-unique honey.
[0104] Specifically, first obtain the defoaming video of the honey sample to be tested, and use the detection model of all unique honeys to detect it. If all the features of a unique honey meet the detection threshold or the detection threshold range, the honey to be tested is the corresponding unique honey and is qualified. Otherwise, use the detection model of all non-unique honeys to detect it, and take the non-unique honey corresponding to the detection model with the highest pass rate as the type of honey to be tested. At the same time, set a third threshold. If the maximum pass rate is lower than the third threshold, the honey to be tested is unqualified.
[0105] It should be noted that the third threshold is set by the implementer according to the actual implementation situation and is not specifically limited. For example, the third threshold is set to 0.5.
[0106] Although this specification has shown and described multiple embodiments of the present invention, it is obvious to those skilled in the art that such embodiments are provided by way of example only. It should be understood that in the process of practicing the present invention, various alternatives to the embodiments of the present invention described herein may be adopted.
[0107] The above are all preferred embodiments of the present invention, and are not intended to limit the scope of protection of the present invention. Therefore, any equivalent changes made based on the structure, shape, and principle of the present invention should be included in the scope of protection of the present invention.
Claims
1. A honey quality detection method based on machine vision, characterized in that: include: Sampling honey to obtain a honey sample, stirring the honey sample and then letting it stand, and obtaining a defoaming video of the honey sample; Extract bubble features from honey sample defoaming videos, including bubble number, average bubble size, and average bubble lifetime. Determine the bubble uniqueness of each honey based on the differences in bubble features across all honey samples. Determine the color uniqueness of each honey based on the color differences among all honey samples; Based on the uniqueness of bubbles and color, all honeys are divided into unique honey and non-unique honey; a detection model for unique honey is established; The sizes of all bubbles and the corresponding number of bubbles in a video frame constitute the bubble distribution of the video frame; the bubble distributions of the video frames at the same moment in the defoaming videos of all honey samples of the same non-unique honey are averaged to form the bubble distribution of the non-unique honey; the bubble distributions at all moments constitute the bubble model of the non-unique honey; based on the differences in the bubble models of all non-unique honeys, characteristic video frames of each non-unique honey are obtained, and a detection model for each non-unique honey is established; The honey sample to be tested is compared with the detection models of unique honey and non-unique honey to complete the quality inspection.
2. The honey quality detection method based on machine vision according to claim 1, characterized in that: The method of extracting bubble features from the honey sample defoaming video includes: Hough circle detection is performed on all video frames of the honey sample defoaming video to obtain several detection circles for each video frame; each detection circle is recorded as a bubble; the center of the detection circle is recorded as the bubble center of the bubble; the area of the detection circle is obtained from the radius of the detection circle and recorded as the bubble size; for any bubble center, consecutive video frames containing the bubble center are obtained, and the corresponding duration is recorded as the bubble lifespan of the bubble corresponding to the bubble center; bubbles at all different bubble centers are counted to obtain the number of bubbles in the honey sample defoaming video; Get the average bubble size and average bubble lifespan of the honey sample defoaming video.
3. The honey quality detection method based on machine vision according to claim 1, characterized in that: The method of determining the bubble uniqueness of each honey based on the differences in bubble characteristics of all honey samples includes: The mean value of the bubble characteristics of all honey sample defoaming videos of each honey is used as the characteristic value of the bubble characteristics of each honey; For two kinds of honey, the difference of all the same bubble features is calculated and the absolute value is taken as the difference of the same bubble features of the two honeys; the differences of all the same bubble features of the two honeys are normalized and then summed to obtain the bubble difference of the two honeys; The mean of the bubble differences between each honey and all other honeys was taken as the bubble uniqueness of each honey.
4. The honey quality detection method based on machine vision according to claim 1, characterized in that: Determining the color uniqueness of each honey based on the color differences of all honey samples includes: The average hue, average saturation, and average brightness of all pixels in the last video frame of all honey sample defoaming videos of each honey are recorded as the hue, saturation, and brightness of each honey; For two kinds of honey, calculate the difference in hue, saturation, and lightness and take the absolute value as the hue difference, saturation difference, and lightness difference of the two honeys. Normalize the hue difference, saturation difference, and lightness difference of the two honeys and sum them to get the color difference of the two honeys. The mean of the color differences between each honey and all other honeys was taken as the color uniqueness of each honey.
5. The honey quality detection method based on machine vision according to claim 1, characterized in that: Based on the uniqueness of bubbles and color, all honeys are divided into unique honey and non-unique honey, including: A first threshold is set. When the color uniqueness of honey is greater than the first threshold and the bubble uniqueness is greater than the first threshold, the honey is recorded as unique honey; when the color uniqueness of honey is less than or equal to the first threshold or the bubble uniqueness is less than or equal to the first threshold, the honey is recorded as non-unique honey.
6. The honey quality detection method based on machine vision according to claim 1, characterized in that: The detection model for establishing unique honey comprises: If the value range of the a-th feature of the i-th unique honey only contains the i-th unique honey, then this value range is recorded as the detection value range of the a-th feature of the i-th unique honey; if the value range of the a-th feature of the i-th unique honey contains the characteristic values of other honeys, then the mean value of the a-th feature of the i-th unique honey is used as the detection threshold of the a-th feature of the i-th unique honey; The bubble characteristics, hue, saturation, brightness of honey, and the corresponding detection threshold or detection value range are combined to form a unique honey detection model.
7. The honey quality detection method based on machine vision according to claim 1, characterized in that: The step of obtaining the characteristic video frames of each non-unique honey comprises: Obtain the bubble distribution types of the neighborhood video frames of the sth video frame of each non-unique honey; ; Take any non-unique honey as the target non-unique honey, where, Represents the feature saliency index of the target non-unique honey in the s-th video frame; Indicates the bubble distribution type of the neighborhood video frame of the s-th video frame of the target non-unique honey; Indicates the type of bubble size; 、 represents the number of bubbles of the gth bubble size in the uth and vth bubble distributions of the target non-unique honey in the sth video frame; represents the normalization function; The video frames whose feature significance index is greater than the second threshold are recorded as the feature video frames of the target non-unique honey, and the corresponding bubble distribution is the feature value.
8. The honey quality detection method based on machine vision according to claim 1, characterized in that: The method of establishing a detection model for each non-unique honey comprises: Comparing the bubble distribution of all characteristic video frames of the honey sample to be tested and each non-unique honey to obtain the qualification of the honey sample to be tested relative to each non-unique honey; A pass threshold is set, and all feature video frames of each non-unique honey, the corresponding bubble distribution and the pass threshold are used as the detection model of each non-unique honey.
9. The honey quality detection method based on machine vision according to claim 8, characterized in that: The qualification of the honey sample to be tested relative to each non-unique honey satisfies the expression: ; Where, Indicates the qualification of the detection model of the honey sample to be tested and the dth non-unique honey; The number of feature video frames representing the detection model of the d-th non-unique honey; Indicates the type of bubble size; 、 It represents the number of bubbles of the gth bubble size of the honey sample to be tested and the detection model of the dth non-unique honey at the yth feature video frame time; Represents an exponential function with a natural constant as its base.
Citation Information
Patent Citations
Method for high-precision recognition of leakage of hydrogen producing and adding system based on machine vision
CN115661151A