A machine vision-based edible oil filling liquid level defect detection method

By constructing a refraction and scattering entropy map and an active profile model, and using virtual mass and surface tension to drive the evolution curve, the problem of inaccurate liquid level detection under the interference of foam layer during edible oil filling was solved, achieving high-precision and robust liquid level detection.

CN121810705BActive Publication Date: 2026-05-22SHAANXI TIANHAN AGRI SCI CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHAANXI TIANHAN AGRI SCI CO LTD
Filing Date
2026-03-12
Publication Date
2026-05-22

AI Technical Summary

Technical Problem

Existing machine vision inspection solutions have difficulty accurately distinguishing the liquid level edge during the edible oil filling process due to multiple scattering interference from the foam layer, resulting in unstable inspection results and failing to meet the precise judgment requirements of industrial automation.

Method used

By constructing a refraction and scattering entropy map, an active contour model is established. The evolution curve is driven by the dynamic equations of virtual mass, virtual surface tension, and virtual damping. The evolution is iterative to extract the liquid level contour, remove foam interference, and accurately obtain the physical interface of the liquid level.

Benefits of technology

It significantly improves detection accuracy and robustness in complex optical environments, maintains geometric continuity and smoothness of liquid level edges in the presence of foam layers, and achieves complete closed-loop control from visual perception to intelligent decision-making.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121810705B_ABST
    Figure CN121810705B_ABST
Patent Text Reader

Abstract

The present application relates to the technical fields of machine vision and industrial automation detection, in particular to a kind of edible oil filling liquid level defect detection method based on machine vision;Contain image acquisition, entropy graph construction, contour evolution and state classification steps;Method is by obtaining container image, calculates texture entropy and transmissivity to construct refraction scattering entropy graph;Its core is to establish the active contour model with virtual mechanics properties, utilize entropy graph gradient to guide evolution curve to converge and lock gas-liquid interface;According to the defect classification of steady-state contour geometric information;The present application converts gray scale segmentation into optical potential field analysis, effectively distinguishes foam interference and real liquid level, significantly improves the detection precision under complex optical environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision and industrial automation inspection technology, specifically to a machine vision-based method for detecting liquid level defects in edible oil filling. Background Technology

[0002] In the high-speed filling production of edible oil, the liquid medium in the transparent container often generates a large amount of foam due to the filling impact, resulting in complex optical scattering and refraction characteristics in the liquid level detection image.

[0003] Existing machine vision inspection solutions generally employ brightness-based threshold segmentation or traditional geometric edge detection algorithms, primarily relying on pixel grayscale differences to identify gas-liquid interfaces. However, since foam layers are composed of numerous tiny bubbles, their multiple scattering of light leads to highly disordered local grayscale distributions, and traditional algorithms struggle to effectively distinguish this strong scattering interference from the actual oil interface. This technical limitation makes it difficult for the detection system to simultaneously penetrate foam interference and maintain the geometric accuracy of the liquid level edge when processing images with foam layers. It is highly prone to misjudging irregular foam edges as liquid level lines, resulting in large fluctuations and poor robustness in the detection results, failing to meet the requirements of accurate and stable product quality assessment in industrial automated production lines.

[0004] Therefore, how to accurately remove the influence of foam and extract the steady-state physical profile of liquid level under strong scattering texture interference has become an urgent technical problem to be solved. Summary of the Invention

[0005] To address the aforementioned technical problems, this invention provides a machine vision-based method for detecting liquid level defects in edible oil filling. Specifically, the technical solution of this invention includes:

[0006] Step 1: Obtain the target image to be processed, which contains the opening region of the transparent container; in the image domain, calculate the texture entropy features and transmittance features of the local region, and construct a refraction scattering entropy map to characterize the medium scattering and interface clarity based on the features.

[0007] Step 2: On the image feature field defined by the refraction and scattering entropy map, establish an active contour model, define an evolution curve with virtual mass, virtual surface tension and virtual damping, and initialize the evolution curve at the preset starting position of the image feature field;

[0008] Step 3: By solving the dynamic equation of the active contour model, the evolution curve is driven to iteratively evolve in the image domain. During the evolution process, the smoothness and continuity of the virtual surface tension constraint curve are used to suppress image noise and local texture interference, and the characteristic gradient field of the refraction and scattering entropy map is used to guide the evolution curve so that it eventually converges and locks to the interface contour between the medium and the air in the image, thereby obtaining a steady-state contour segmentation result.

[0009] Step 4: Extract the geometric information of the steady-state contour segmentation result, calculate the parameters that characterize the contour position, classify the parameters according to the preset classification rules, and output the corresponding classification results.

[0010] Preferably, step one includes:

[0011] S11. Acquire the original grayscale image containing the container opening area;

[0012] S12. Perform local texture analysis on the original grayscale image in the image domain, calculate the grayscale distribution disorder in the neighborhood of each pixel, and generate texture entropy distribution data in the image domain.

[0013] S13. The texture entropy distribution data and the brightness information of the original grayscale image are fused to construct the refraction and scattering entropy map, wherein the high texture entropy region corresponds to the interior of the medium with high scattering in the image, and the low texture entropy region corresponds to the clear physical interface in the image.

[0014] Preferably, step two includes:

[0015] S21. At a preset position above the image feature field defined by the refraction and scattering entropy map, a horizontal initial curve is generated as the initial state of the evolution curve.

[0016] S22. Configure dynamic parameters for the active contour model, including external force coefficients for driving curve evolution, surface tension coefficients for constraining curve smoothness, and field coupling coefficients for coupling image feature field information.

[0017] S23. Construct a partial differential equation describing the motion state of the evolution curve in the image domain, and introduce the texture entropy distribution data as an image force term into the partial differential equation to fully define the active contour model.

[0018] Preferably, step three includes:

[0019] S31. Using a numerical computing unit, the partial differential equation is discretized and iteratively solved. Specifically, the finite difference method is used to construct an explicit iterative format, and the coordinate positions of each point on the evolution curve in the image domain are updated according to the time step.

[0020] S32. In each iteration, the image domain forces acting on the evolution curve are calculated comprehensively. The forces include external forces defined by the model parameters, internal forces that maintain the smoothness of the curve, and reverse constraint forces determined by the gradient of the refraction and scattering entropy map.

[0021] S33. Monitor the change of the total energy functional of the evolution curve. When the rate of change of the total energy functional is lower than the preset convergence threshold, determine that the evolution has reached a steady state, stop the iteration, and output the current curve coordinate set as the final image segmentation result.

[0022] Preferably, step four includes:

[0023] S41. Obtain the image segmentation result, that is, the set of coordinates of all points on the steady-state interface contour, calculate its statistical feature value, and obtain the geometric parameters representing the current contour position.

[0024] S42. Retrieve the preset standard parameter thresholds used for state classification;

[0025] S43. Compare the current geometric parameters with the standard parameter threshold and calculate the deviation value.

[0026] Preferably, step four further includes:

[0027] S44. Based on the threshold range where the deviation value is located, classify the samples corresponding to the current image segmentation result into states, and the classification labels include qualified, low or high.

[0028] S45. Associate the classification label with the corresponding image sample or production batch identifier.

[0029] Preferably, step four further includes:

[0030] S46. Trigger the corresponding control logic based on the classification label:

[0031] In response to a valid label, a first-type instruction signal is generated;

[0032] In response to a label that is too low or too high, a second type of instruction signal is generated;

[0033] S47. Calculate the frequency of occurrence of unconventional category labels within a preset time window. If the frequency exceeds a preset alarm threshold, generate a system performance monitoring signal.

[0034] Preferably, in step three, when the processed image has strong scattering medium characteristics, the surface tension coefficient is dynamically corrected based on the mean global texture entropy of the current image to enhance the robustness of the evolution curve to high-frequency noise and complex textures in the image, ensuring that the final obtained image segmentation contour is smooth and continuous.

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

[0036] 1. This method creatively transforms the grayscale segmentation problem in traditional image processing into a feature analysis problem of the optical potential field of a non-uniform medium by constructing a refraction and scattering entropy map. By fusing local texture entropy features and transmittance features, this invention can effectively distinguish between foam layers exhibiting high multiple scattering characteristics and oil and air regions exhibiting uniform refraction or low scattering characteristics. This overcomes the shortcomings of existing technologies that rely solely on pixel brightness and are unable to distinguish between strong scattering interference and the real interface, and significantly improves the accuracy of the algorithm in identifying the state of the medium in complex optical environments.

[0037] 2. This method establishes an active contour model with physical properties, endowing the evolution curve with dynamic characteristics such as virtual mass, virtual surface tension, and virtual damping. Among them, virtual mass gives the curve inertia, enabling it to resist the slight traction of high-frequency image noise; virtual surface tension simulates the physical properties of liquids, forcing the curve to maintain a smooth shape, thereby effectively suppressing jagged misjudgments caused by irregular foam edges. This physical constraint mechanism enables the detection system to maintain the geometric continuity and smoothness of the contour when facing a foam layer composed of a large number of tiny bubbles, greatly enhancing the robustness of the detection results.

[0038] 3. This method utilizes dynamic equations to drive the evolution curve to iteratively evolve in the image feature field, realizing a method to solve the liquid level profile from the perspective of minimizing physical space energy. This mechanism enables the virtual evolution curve to treat the foam layer as a soft resistance zone and penetrate it, while treating the oil surface as a hard boundary and converging and locking it. Thus, without complex preprocessing, foam interference can be directly stripped away and the steady-state liquid level physical interface can be accurately extracted, solving the technical problem of difficulty in balancing penetration of foam interference and maintenance of liquid level edge geometric accuracy in high-speed filling scenarios.

[0039] 4. This method possesses adaptive adjustment capabilities for complex working conditions and a complete closed-loop control logic. On the one hand, the system can dynamically adjust the surface tension coefficient of the model based on the global scattering characteristics of the image, automatically enhancing the hardness of the curve under strong foam interference to prevent it from falling into local gaps, thus ensuring the universality of the algorithm. On the other hand, by converting the detection results into discrete quality labels and performing trend statistics, the system not only achieves automatic rejection of individual defective products, but also provides early warning of potential faults in filling equipment, thereby constructing a complete industrial automation closed loop from visual perception to intelligent decision-making. Attached Figure Description

[0040] The present invention will be further explained below with reference to the accompanying drawings and embodiments:

[0041] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.

[0043] Example 1:

[0044] Please see Figure 1 A machine vision-based method for detecting liquid level defects in edible oil filling processes is proposed, which involves contour extraction and state classification of images containing transparent containers and their internal media. The specific steps include:

[0045] Step 1: Obtain the target image to be processed, which contains the opening region of the transparent container; in the image domain, calculate the texture entropy features and transmittance features of the local region, and construct a refraction scattering entropy map based on the features to characterize the scattering of the medium and the clarity of the interface.

[0046] Step 2: On the image feature field defined by the refraction and scattering entropy map, establish an active contour model, define an evolution curve with virtual mass, virtual surface tension and virtual damping, and initialize the evolution curve at the preset starting position of the image feature field;

[0047] Step 3: By solving the dynamic equations of the active contour model, the evolution curve is driven to iteratively evolve in the image domain. During the evolution process, the smoothness and continuity of the curve are constrained by the virtual surface tension to suppress image noise and local texture interference. The characteristic gradient field of the refraction and scattering entropy map is used to guide the evolution curve so that it eventually converges and locks to the interface contour between the medium and the air in the image, thus obtaining a steady-state contour segmentation result.

[0048] Step 4: Extract the geometric information of the steady-state contour segmentation results, calculate the parameters that represent the contour position, classify the parameters according to the preset classification rules, and output the corresponding classification results.

[0049] This embodiment provides a machine vision-based method for detecting liquid level defects in edible oil filling, aiming to solve the contradiction between balancing penetration of foam interference and maintaining the accuracy of liquid level edges in high-speed filling scenarios. The core idea of ​​this embodiment is to transform the traditional image segmentation problem into an energy minimization and manifold evolution problem in physical space. The system executes step one, where the Refractive Scattering Entropy Map (RSEM) is a feature matrix that maps a two-dimensional grayscale image to an optical potential field of a non-uniform medium. Its purpose is to use the scattering characteristics of physical optics to distinguish the states of matter: air and bottle walls exhibit low scattering, pure oil exhibits uniform refraction, and the foam layer exhibits strong multiple scattering. In this process, the transmittance feature is concretized as the degree of brightness retention after light penetrates the medium, which is used to help distinguish between highly transparent liquids and low-transmittance liquids. The scatterer; through this mapping, the image is no longer a simple set of brightness, but a potential energy field with different penetration resistance; in step two, the active contour model is concretized into a virtual viscous manifold; unlike traditional geometric curves, this model is endowed with physical properties: virtual mass gives the curve inertia, making it less susceptible to the pull of small high-frequency noise during evolution; virtual surface tension simulates the physical properties of liquids, forcing the curve to maintain a smooth meniscus shape, thereby resisting the irregular edge jaggedness caused by foam; virtual damping is used to simulate the viscosity of the medium, ensuring the convergence stability of the evolution process; in step three, the system simulates a physical process through numerical calculation: a virtual film with tension sinks from the bottle mouth under the action of gravity; since the foam layer is defined as a soft resistance region in the refraction scattering entropy diagram, while the oil surface is defined as a hard boundary, the virtual film will cut or crush the loose foam layer and finally stop on the dense oil interface.

[0050] Example 2:

[0051] Step one includes:

[0052] S11. Acquire the original grayscale image containing the container opening area;

[0053] S12. Perform local texture analysis on the original grayscale image in the image domain, calculate the grayscale distribution disorder in the neighborhood of each pixel, and generate texture entropy distribution data in the image domain.

[0054] S13. By fusing the texture entropy distribution data with the brightness information of the original grayscale image, a refraction and scattering entropy map is constructed. The high texture entropy region corresponds to the interior of the medium with high scattering in the image, and the low texture entropy region corresponds to the clear physical interface in the image.

[0055] This embodiment is a further specification of step one in embodiment 1; Executing S11, the image is typically taken by an industrial camera under backlighting conditions to ensure clear optical contrast between the liquid and the bottle wall; Executing S12, in this embodiment, texture entropy is defined as the information entropy of the gray-level histogram in a local area of ​​the image, and its calculation formula is:

[0056]

[0057] in, The current pixel coordinates, This refers to the number of gray levels, typically 256. For The gray value within the local neighborhood window centered on the center is The probability of a pixel appearing is the ratio of the number of pixels with that grayscale value to the total number of pixels in the window. The motivation behind this formula is that foam is composed of a large number of tiny bubbles, and its refraction and reflection of light are extremely chaotic, resulting in a highly disordered grayscale distribution in local areas. In contrast, the grayscale of still oil or air is uniform, and the entropy value is extremely low. Executing S13, in this embodiment, the brightness information is a direct measure of the transmittance characteristic of Example 1. Under backlight illumination, the transmittance characteristic... The normalized result calculated as pixel grayscale value: , here Specifically, it refers to the pixel coordinates of the original grayscale image. The gray intensity value at the location; the specific fusion formula for constructing the refraction and scattering entropy map is:

[0058]

[0059] in, To pre-determine normalized weighting coefficients to balance the dimensional differences of different features; in this embodiment, we take... The purpose of setting the weights here is to balance the difference in dimensions between the texture entropy value (typically between 0 and 8) and the transmittance value (0 to 1). The physical mechanism of this formula is that the foam region experiences light attenuation due to multiple scattering, resulting in low transmittance. It means high Furthermore, cluttered textures correspond to high... The combination of the two produces high The value; forming a high potential energy resistance zone; while the oil area has good light transmittance and uniform texture, with an extremely low RSEM value; this fusion method aims to enhance the characteristic differences between the foam and the liquid surface.

[0060] Example 3:

[0061] Step two includes:

[0062] S21. At a preset position above the image feature field defined by the refraction and scattering entropy map, generate a horizontal initial curve as the initial state of the evolution curve.

[0063] S22. Configure dynamic parameters for the active contour model, including external force coefficients for driving curve evolution, surface tension coefficients for constraining curve smoothness, and field coupling coefficients for coupling image feature field information.

[0064] S23. Construct a partial differential equation describing the motion state of the evolution curve in the image domain, and introduce texture entropy distribution data as an image force term into the partial differential equation to fully define the active contour model.

[0065] This embodiment provides a detailed description of the model building process in step two; Executing S21, the initial position is usually set in the air region above the bottle opening to ensure that the curve can cover all possible liquid level heights; S21a, set the boundary conditions of the evolution curve, constraining the two endpoints of the curve to the left and right boundaries of the region of interest in the image, and setting the endpoints to satisfy the Neumann boundary conditions, allowing the endpoints to slide vertically along the boundary but not to leave the boundary, i.e., satisfying... The horizontal derivative of the evolution curve is zero at the left and right boundaries of the image to ensure that the curve always penetrates the container cross-section during the evolution process.

[0066] Execute S22 to configure the dynamic parameters: the external force coefficient corresponds to virtual gravity and determines the downward search speed of the curve; the surface tension coefficient determines the curve's ability to resist bending deformation; the larger this value, the more the curve tends to be a horizontal straight line; the field coupling coefficient determines the strength of the image features' resistance to the curve's motion; execute S23 to construct the partial differential equation, the specific dynamic equation being expressed as follows:

[0067]

[0068] in, This indicates the evolution curve under normalized parameters. and time The coordinates below; For virtual quality; For virtual damping; For surface tension coefficient, the term Generates smooth constraint force; This refers to the external force term that includes the gradient of the refraction and scattering entropy diagram; where the virtual mass is preset by the system, imparting inertia to the curve, and set within the normalized calculation framework of this embodiment. The virtual damping is preset by the system and is used to consume energy to bring the system to convergence. In this embodiment, it is taken as... To ensure an approximate critical damping state; the surface tension coefficient corresponds to the virtual surface tension, and its reference value is set as follows. The virtual gravity defined by the external force coefficient is vertically downward, i.e. ,in, As a scalar quantity of gravity, this embodiment sets... The force term in the image derived from the refraction-scattering entropy map is the gradient reaction force, the intensity of which is determined by the field coupling coefficient. Control, as set in this embodiment To ensure the solvability of the model, the external force term... Further defined as:

[0069]

[0070] in, The constant gravitational component along the vertical direction. The field coupling coefficient is... scalar potential energy field The gradient vector's mathematical direction points towards the direction of the fastest potential energy increase; the negative sign in the formula causes the external force term to point towards the direction of decreasing potential energy, thus driving the curve towards the image edge where the potential energy is minimized; simultaneously, to ensure dimensional consistency of the dynamic equations in the image domain, the virtual mass in the above formula... Virtual damping and surface tension coefficient Physical parameters are defined as dimensionless values ​​or equivalent quantities based on pixel units, thus keeping the physical meaning of both sides of the equation balanced in the image space.

[0071] Example 4:

[0072] Step three includes:

[0073] S31. Using a numerical computing unit, the partial differential equation is discretized and iteratively solved. Specifically, the finite difference method is used to construct an explicit iterative format, and the coordinate positions of each point on the evolution curve in the image domain are updated according to the time step.

[0074] S32. In each iteration, the image domain forces acting on the evolution curve are calculated comprehensively. These forces include external forces defined by the model parameters, internal forces that maintain the smoothness of the curve, and reverse constraint forces determined by the gradient of the refraction and scattering entropy map.

[0075] S33. Monitor the change of the total energy functional of the evolution curve. When the rate of change of the total energy functional is lower than the preset convergence threshold, determine that the evolution has reached a steady state, stop the iteration, and output the current curve coordinate set as the final image segmentation result.

[0076] This embodiment details the numerical solution process in step three, specifically employing the finite difference method to construct an explicit iterative scheme, whose discretization update formula is as follows:

[0077]

[0078] in, For the time step, the recommended value range is [value range missing]. ; Let the curve coordinates be those of the previous time step. Time can be initialized to Update the coordinates of each point on the evolution curve in the image domain according to the time step; the spatial second derivative in the formula The central difference method is used to perform approximate calculations on a discrete pixel grid, that is, for the th on the evolution curve The formula for calculating the second derivative of a node is: ;

[0079] Executing S31 typically involves using the finite difference method to transform the continuous PDE into a discrete system of algebraic equations, which are then computed in parallel on the GPU. Executing S32, an external force drives the curve downwards through air and foam; the internal force originates from the surface tension term, straightening the curve to ignore the fine edges of the foam; the reverse constraint force originates from the entropy gradient, which increases sharply when the curve contacts the low-entropy, high-gradient oil interface, balancing the external force and forcing the curve to stop moving; Executing S33, the energy functional is defined as the sum of kinetic energy, internal energy, and external potential energy, and its specific mathematical expression is:

[0080]

[0081] The first term is kinetic energy, the second term is elastic potential energy generated by surface tension, and the third term... Let be the potential energy of the curve in the refraction-scattering entropy diagram; specifically, the formula for this potential energy term is:

[0082]

[0083] in, The refraction and scattering entropy map matrix generated in step one, with symbols... Represents a two-dimensional convolution operation; The standard deviation is a Gaussian smoothing kernel. The smoothing scale of the potential energy field is determined; in this embodiment, it is taken as... The recommended Gaussian kernel window size is set to [value missing]. Pixel, i.e. size, For gradient operators, Represents the magnitude of a vector, and performs L2 norm operations; This is the potential energy weight, used to adjust the attractive force of external potential energy on the evolution curve. In this embodiment, it is taken as... The physical meaning of this formula is: first, Gaussian smooth the entropy map, and then calculate the square of its gradient magnitude; due to the sudden change in entropy at the oil-liquid interface, the gradient magnitude is large, and the negative sign makes a groove with a minimum potential energy value formed at that point, thus forming the adsorption evolution curve; when the rate of energy change is less than the threshold, it indicates that the curve has stabilized on the liquid surface.

[0084] Example 5:

[0085] Step four includes:

[0086] S41. Obtain the image segmentation result, that is, the set of coordinates of all points on the steady-state interface contour, calculate its statistical feature value, and obtain the geometric parameters representing the current contour position.

[0087] S42. Retrieve the preset standard parameter thresholds used for state classification;

[0088] S43. Compare the current geometric parameters with the standard parameter threshold and calculate the deviation value.

[0089] This embodiment describes the parameter extraction and comparison logic in step four; Executing S41, the geometric parameters are usually taken as the average value of the vertical coordinates of the evolution curve in the horizontal direction, or as the height of the meniscus vertex after curve fitting; since the curve has removed noise through surface tension constraints, this average value can represent the actual liquid level with extremely high accuracy; Executing S42, this threshold is set according to the statistical distribution of the liquid level in the standard sample bottle under defect-free conditions; the specific setting method is as follows: during the system initialization phase, data is collected... Group, in this embodiment Images of standard sample bottles that have been manually verified as qualified are used to extract the liquid level profile position parameters from each image, and the arithmetic mean of these parameters is calculated. and statistical standard deviation Set the standard parameter threshold to At the same time, based on Statistical principles determine the boundaries of the qualifying intervals required for subsequent classification, i.e. Execute S43 to calculate the deviation value;

[0090] In industrial automation quality control scenarios, this embodiment extracts the statistical feature values ​​of steady-state contours, reducing complex image features to a single, quantifiable geometric index. This processing method filters out local minor fluctuations in the contours, provides high-precision liquid level measurement, and enables industrial control systems to directly use this geometric parameter for accurate quality judgment, reducing the complexity of data processing.

[0091] Example 6:

[0092] Step four also includes:

[0093] S44. Based on the threshold range where the deviation value is located, classify the samples corresponding to the current image segmentation result into states, with classification labels including qualified, low or high.

[0094] S45. Associate the category label with the corresponding image sample or production batch identifier.

[0095] This embodiment further refines the classification steps; in step S44, for example, if the absolute value of the deviation is less than the tolerance, it is marked as qualified; if the deviation is less than the negative tolerance, it is marked as low; if the deviation is greater than the positive tolerance, it is marked as high; in step S45, the classification label is associated with the corresponding image sample or production batch identifier, which provides a data foundation for subsequent quality traceability.

[0096] In large-scale continuous production scenarios, this embodiment achieves the discretization and semanticization of detection results by setting a clear threshold range; this enables the output of the machine vision system to be directly understood by the production line PLC, thereby realizing a seamless conversion from visual perception to logical decision-making, ensuring that each bottle of product can obtain a clear quality status label, which is convenient for subsequent sorting and management.

[0097] Example 7:

[0098] Step four also includes:

[0099] S46. Trigger the corresponding control logic based on the category label:

[0100] In response to a valid label, a first-type instruction signal is generated;

[0101] In response to a label that is too low or too high, a second type of instruction signal is generated;

[0102] S47. Count the frequency of occurrence of non-standard category labels within the preset time window. If the frequency exceeds the preset alarm threshold, generate a system performance monitoring signal.

[0103] This embodiment adds a feedback control and monitoring link; in response to a qualified label, a first type of instruction signal such as a release signal is generated; in response to a low or high label, a second type of instruction signal such as a rejection signal is generated, driving the pneumatic push rod to remove the defective bottle from the production line; in response to S47, for example, if multiple low labels appear within 1 minute, the system determines that the filling valve may be blocked and then issues a shutdown maintenance alarm.

[0104] In the closed-loop control scenario of a smart factory, this embodiment not only realizes the quality rejection of individual products, but also realizes the trend warning of equipment status by statistically analyzing the frequency of abnormal tags. This mechanism constructs a complete closed loop from detection to control to trend warning, which can detect potential faults in filling equipment in advance, thereby significantly reducing the generation of continuous waste and reducing production losses.

[0105] Example 8:

[0106] In step three, when the processed image has strong scattering medium characteristics, the surface tension coefficient is dynamically corrected based on the mean global texture entropy of the current image to enhance the robustness of the evolution curve to high-frequency noise and complex textures in the image, ensuring that the final image segmentation contour is smooth and continuous.

[0107] This embodiment optimizes parameters for a specific working condition; in this embodiment, the strong scattering medium characteristic refers to the situation where the average global texture entropy calculated by S12 exceeds a specific threshold, i.e., there is a great deal of foam; in this embodiment, the specific threshold is... The method for determining this is as follows: A set of typical high-foaming state images and a set of non-foaming state images are collected in advance, and the mean global texture entropy of the two sets of images is calculated respectively. and The average of the two values ​​is taken as the specific threshold, i.e. Typical values ​​are approximately This threshold can be calibrated and adjusted on-site based on the ambient light intensity and the light transmittance of the container material; it is calculated based on an 8-bit grayscale image; at this time, the system automatically uses the average global texture entropy of the region of interest in the current image. For the surface tension coefficient in the partial differential equation Dynamic corrections are performed to prevent model divergence caused by negative coefficients. The correction formula uses an exponential gain function:

[0108]

[0109] in, Represented by natural constant Exponential operations with base 0; The reference surface tension coefficient set in Example 3 is taken as... , As a rigid gain factor, this embodiment sets , This represents the average global texture entropy of the currently detected image. A specific threshold is set; simultaneously, to prevent curve instability in extremely low-texture areas, such as a pure air background, due to an excessively small calculated surface tension coefficient, a setting is established. The lower limit cutoff value is That is, the final coefficient values ​​used. ;

[0110] The physical significance is that when the foam is very thick, the image gradient below the liquid surface is extremely chaotic; increasing the surface tension coefficient is equivalent to increasing the hardness of the virtual film, making it more difficult for it to bend locally; in this way, the film will be placed on the overall outline of the foam layer, or will be pressed down on the foam layer under the action of gravity, without getting stuck in the tiny gaps inside the foam, thus ensuring that the extracted outline is a smooth curve that conforms to the laws of physics, rather than a jagged line chasing the edge of the foam.

[0111] In production scenarios with different oil properties, such as different viscosities or foaming rates, this embodiment gives the algorithm the ability to adapt to complex working conditions by dynamically adjusting the surface tension coefficient. This parameter adjustment strategy based on medium characteristics enables a single algorithm model to cope with drastic changes in foam thickness, avoiding the cumbersome process of retraining the model for different working conditions required by traditional algorithms, and greatly improving the versatility and deployment efficiency of the system.

[0112] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A machine vision-based method for detecting liquid level defects in edible oil filling, characterized in that, The method for contour extraction and state classification of images containing transparent containers and their internal media includes the following steps: Step 1: Obtain the target image to be processed, which contains the opening region of the transparent container; in the image domain, calculate the texture entropy features and transmittance features of the local region, and construct a refraction scattering entropy map to characterize the medium scattering and interface clarity based on the features. Step 2: On the image feature field defined by the refraction and scattering entropy map, establish an active contour model, define an evolution curve with virtual mass, virtual surface tension and virtual damping, and initialize the evolution curve at the preset starting position of the image feature field; Step 3: By solving the dynamic equation of the active contour model, the evolution curve is driven to iteratively evolve in the image domain. During the evolution process, the smoothness and continuity of the virtual surface tension constraint curve are used to suppress image noise and local texture interference, and the characteristic gradient field of the refraction and scattering entropy map is used to guide the evolution curve so that it eventually converges and locks to the interface contour between the medium and the air in the image, thereby obtaining a steady-state contour segmentation result. Step 4: Extract the geometric information of the steady-state contour segmentation result, calculate the parameters that characterize the contour position, classify the parameters according to the preset classification rules, and output the corresponding classification results. Step one includes: S11. Acquire the original grayscale image containing the container opening area; S12. Perform local texture analysis on the original grayscale image in the image domain, calculate the grayscale distribution disorder in the neighborhood of each pixel, and generate texture entropy distribution data in the image domain. S13. The texture entropy distribution data and the brightness information of the original grayscale image are fused to construct the refraction and scattering entropy map, wherein the high texture entropy region corresponds to the interior of the medium with high scattering in the image, and the low texture entropy region corresponds to the clear physical interface in the image. Step two includes: S21. At a preset position above the image feature field defined by the refraction and scattering entropy map, a horizontal initial curve is generated as the initial state of the evolution curve. S22. Configure dynamic parameters for the active contour model, including external force coefficients for driving curve evolution, surface tension coefficients for constraining curve smoothness, and field coupling coefficients for coupling image feature field information. S23. Construct a partial differential equation describing the motion state of the evolution curve in the image domain, and introduce the texture entropy distribution data as an image force term into the partial differential equation to fully define the active contour model. Step three includes: S31. Using a numerical computing unit, the partial differential equation is discretized and iteratively solved. Specifically, the finite difference method is used to construct an explicit iterative format, and the coordinate positions of each point on the evolution curve in the image domain are updated according to the time step. S32. In each iteration, the image domain forces acting on the evolution curve are calculated comprehensively. The forces include external forces defined by the model parameters, internal forces that maintain the smoothness of the curve, and reverse constraint forces determined by the gradient of the refraction and scattering entropy map. S33. Monitor the change of the total energy functional of the evolution curve. When the rate of change of the total energy functional is lower than the preset convergence threshold, determine that the evolution has reached a steady state, stop the iteration, and output the current curve coordinate set as the final image segmentation result. Step four includes: S41. Obtain the image segmentation result, that is, the set of coordinates of all points on the steady-state interface contour, calculate its statistical feature value, and obtain the geometric parameters representing the current contour position. S42. Retrieve the preset standard parameter thresholds used for state classification; S43. Compare the current geometric parameters with the standard parameter threshold and calculate the deviation value.

2. The method according to claim 1, characterized in that: Step four also includes: S44. Based on the threshold range where the deviation value is located, classify the samples corresponding to the current image segmentation result into states, and the classification labels include qualified, low or high. S45. Associate the classification label with the corresponding image sample or production batch identifier.

3. The method according to claim 2, characterized in that: Step four also includes: S46. Trigger the corresponding control logic based on the classification label: In response to a valid label, a first-type instruction signal is generated; In response to a label that is too low or too high, a second type of instruction signal is generated; S47. Calculate the frequency of occurrence of unconventional category labels within a preset time window. If the frequency exceeds a preset alarm threshold, generate a system performance monitoring signal.

4. The method according to claim 1, characterized in that: In step three, when the processed image has strong scattering medium characteristics, the surface tension coefficient is dynamically corrected based on the mean global texture entropy of the current image to enhance the robustness of the evolution curve to high-frequency noise and complex textures in the image, ensuring that the final obtained image segmentation contour is smooth and continuous.