Liquid level measuring device and method
Patent Information
- Application Number
- CN202611183455.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-05
- Publication Date
- 2026-10-23
AI Technical Summary
[0005]本申请实施例提供液位测量装置及方法,用以解决现有技术中存在测量精度低的问题
[0045]本申请实施例提供的液位测量装置及方法,该装置包括:通过在被测设备内部沿预设方向间隔设置多个视觉检测区域,使不同位置处的液体状态能够被分段采集和表征,从而建立液面变化与空间位置之间的对应关系。在实际检测过程中,多个视觉检测区域相当于沿液体高度方向布置的多个采样基准,通过合理设置检测区域之间的间距,可以覆盖被测设备内部液面的变化范围,当液体液面发生升降变化时,不同位置的视觉检测区域能够采集到对应区域内液体与非液体区域之间的视觉差异信息。图像采集模块获取覆盖多个视觉检测区域的图像数据,通过摄像元件对各检测区域内的图像进行同步采集,使图像数据中包含液面边界、液体分布以及对应空间区域的视觉特征信息。处理模块对采集到的图像数据进行图像识别和特征分析,通过对图像中的亮度、颜色、纹理、边缘特征或液体与空气之间的视觉差异进行提取,确定液面边界在各个视觉检测区域中的具体位置,并进一步获得液面相对于各视觉检测区域的相对位置信息。在获得各视觉检测区域中的液面相对位置后,处理模块结合多个视觉检测区域在被测设备中的实际空间布置关系,对各检测区域对应的空间坐标、间隔距离以及液面位置数据进行融合计算,通过对多个离散检测位置之间的液面变化趋势进行拟合或插值处理,将离散的视觉检测结果转换为连续的液位测量结果。通过上述方式,无需依赖传统液位传感器与液体直接接触,即可利用视觉信息实现非接触式液位检测,同时通过多个空间位置上的视觉检测结果进行联合计算,提高了液位测量的连续性和准确性,降低了单点检测方式容易受到液面波动、局部遮挡或安装误差影响的问题,能够适用于复杂环境下被测设备内部液体状态的实时监测。
Smart Images

Figure CN122961524A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of liquid level measurement, and more particularly to a liquid level measurement device and method. Background Technology
[0002] In chemical, pharmaceutical, food processing, and energy industries, equipment such as reactors, evaporators, crystallizers, and fermenters often experience intense liquid movement, including bubble layers from boiling, surface foam coverage, and surface fluctuations caused by agitation. These conditions significantly interfere with the stability of traditional level measurement technologies. For example, in pharmaceutical fermenters, foam layers of varying thickness may form on the surface of the culture medium, making it difficult to determine the true liquid level. In chemical reactors, the intense boiling under high temperature and pressure causes frequent bubble bursts, resulting in drastic surface fluctuations. Furthermore, some equipment cannot utilize direct contact measurement methods (such as magnetic level gauges) due to sealing requirements or corrosive media. Therefore, there is an urgent need for a stable, low-cost, and highly accurate level measurement method capable of operating in complex dynamic environments to meet the real-time and reliability requirements of industrial automation for level monitoring.
[0003] In the existing technology, liquid level measurement using a differential pressure level gauge is one of the most common methods. The differential pressure level gauge measures the pressure difference between the pressure generated by the liquid phase medium and the reference pressure of the gas phase at the top of the container by installing pressure taps at the bottom (or at different heights on the side) of the container. The current liquid level height is then calculated based on the known density of the medium.
[0004] However, in existing measurement methods, the conversion between differential pressure and liquid level depends on the accuracy and stability of the medium density, resulting in low measurement accuracy. Summary of the Invention
[0005] This application provides a liquid level measuring device and method to solve the problem of low measurement accuracy in the prior art.
[0006] In a first aspect, embodiments of this application provide a liquid level measuring device, comprising:
[0007] The visual inspection component includes at least two visual inspection areas spaced apart along a preset direction of the device under test, for visual inspection information corresponding to the liquid state inside the device under test;
[0008] The image acquisition module is used to acquire image data covering the multiple visual detection areas;
[0009] The processing module, connected to the image acquisition module, is used to analyze and process the image data to obtain the relative position of the liquid surface in each visual detection area;
[0010] The processing module is also used to calculate the continuous liquid level measurement result based on the relative position and the spatial position of each visual detection area.
[0011] In one possible implementation, the visual detection area is a transparent detection window, which is arranged at intervals along the height direction of the device under test. The spacing between each transparent detection window is determined according to the liquid level inside the device under test and the height of the transparent detection window.
[0012] In one possible implementation, the visual detection component further includes an auxiliary lighting device;
[0013] The auxiliary lighting device is located outside the device under test, on one side of the transparent detection window, and is used to provide stable lighting conditions to the transparent detection window.
[0014] In one possible implementation, the image acquisition module includes a single industrial image acquisition device whose field of view covers the entire visual detection area.
[0015] In a second aspect, embodiments of this application provide a liquid level measurement method, applied to the processing module of the liquid level measurement device described in the first aspect above and / or the first aspect, comprising:
[0016] Acquire image data corresponding to multiple visual detection areas acquired by the image acquisition module;
[0017] The image data is processed to determine the relative position of the liquid surface in each visual detection area;
[0018] Obtain the spatial location information corresponding to each visual detection area;
[0019] The continuous liquid level measurement result is calculated based on the relative position of the liquid surface in each visual detection area and the spatial position information.
[0020] In one possible implementation, the image processing of the image data to determine the relative position of the liquid surface in each visual detection area includes:
[0021] The image data is preprocessed, and the preprocessing includes at least one of image enhancement, noise removal, and region localization.
[0022] The preprocessed image data is input into a trained lightweight convolutional neural network model, and the lightweight convolutional neural network model is used to regress and output the liquid surface ratio in the visual detection area.
[0023] The relative position of the liquid surface in each visual detection area is determined based on the liquid level ratio and the height of the visual detection area.
[0024] In one possible implementation, the training process of the trained lightweight convolutional neural network model is as follows:
[0025] A training sample set is obtained, which includes multiple sample images. Each sample image is an image that contains the visual detection area. Each sample image is labeled with a corresponding liquid level ratio label. The liquid level ratio label is used to characterize the proportion of the actual relative height of the liquid level in the visual detection area to the total height of the visual detection area.
[0026] The sample images in the training sample set are input into the initial lightweight convolutional neural network model, and the predicted liquid level ratio is obtained through forward propagation.
[0027] The loss function value is calculated based on the predicted liquid level ratio and the liquid level ratio label;
[0028] The network parameters of the initial lightweight convolutional neural network model are updated by backpropagation based on the loss function value until the model converges, thus obtaining the trained lightweight convolutional neural network model.
[0029] In one possible implementation, the spatial location information includes at least the installation height of the lower edge of each visual detection area relative to the bottom of the device under test and the effective height of each visual detection area;
[0030] The step of calculating the continuous liquid level measurement result based on the relative position of the liquid surface in each visual detection area and the spatial position information includes:
[0031] The current position of the liquid surface is determined based on its relative position in each visual detection area;
[0032] When the liquid surface is located within any visual detection area, the continuous liquid level measurement result is calculated based on the spatial location of the visual detection area and the relative position of the liquid surface within that visual detection area.
[0033] When the liquid level is located between two adjacent visual detection areas, interpolation calculation is performed based on the spatial position of the two adjacent visual detection areas and the relative position of the liquid level within the two adjacent visual detection areas to obtain the continuous liquid level measurement result.
[0034] In one possible implementation, the method further includes:
[0035] When the liquid level is higher than the uppermost visual detection area, the continuous liquid level measurement result is determined as the first preset value;
[0036] When the liquid level is below the lowest visual detection area, the continuous liquid level measurement result is determined as the second preset value, and the first preset value is greater than the second preset value.
[0037] In one possible implementation, if the liquid to be tested is a transparent liquid and the auxiliary lighting device is a red-green dual-color backlight, determining the relative position of the liquid surface in each of the visual detection areas includes:
[0038] The target detection model is used to identify the boundary between the red and green regions in the preprocessed image data.
[0039] The relative position of the liquid surface in each of the visual detection areas is determined based on the location of the dividing line.
[0040] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;
[0041] The memory stores computer-executed instructions;
[0042] The processor executes computer execution instructions stored in the memory, causing the processor to perform the second aspect and / or various possible implementations of the second aspect as described above.
[0043] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the second aspect and / or various possible implementations of the second aspect as described above.
[0044] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the second aspect and / or various possible implementations of the second aspect as described above.
[0045] The liquid level measurement device and method provided in this application include: setting multiple visual detection areas at intervals along a preset direction inside the device under test, so that the liquid state at different locations can be collected and characterized in segments, thereby establishing a correspondence between liquid level changes and spatial positions. In actual detection, the multiple visual detection areas are equivalent to multiple sampling references arranged along the liquid height direction. By reasonably setting the spacing between the detection areas, the range of liquid level changes inside the device under test can be covered. When the liquid level rises or falls, the visual detection areas at different locations can collect visual difference information between liquid and non-liquid areas within the corresponding area. An image acquisition module acquires image data covering multiple visual detection areas, and synchronously acquires images within each detection area through a camera element, so that the image data contains visual feature information of liquid surface boundaries, liquid distribution, and corresponding spatial areas. A processing module performs image recognition and feature analysis on the acquired image data. By extracting brightness, color, texture, edge features, or visual differences between liquid and air in the image, the specific position of the liquid surface boundary in each visual detection area is determined, and the relative position information of the liquid surface with respect to each visual detection area is further obtained. After obtaining the relative positions of the liquid surface in each visual detection area, the processing module combines the actual spatial arrangement of multiple visual detection areas within the device under test to perform fusion calculations on the spatial coordinates, interval distances, and liquid surface position data corresponding to each detection area. By fitting or interpolating the liquid surface change trends between multiple discrete detection positions, the discrete visual detection results are converted into continuous liquid level measurement results. In this way, non-contact liquid level detection can be achieved using visual information without relying on traditional liquid level sensors directly contacting the liquid. Furthermore, by jointly calculating the visual detection results from multiple spatial locations, the continuity and accuracy of liquid level measurement are improved, reducing the susceptibility of single-point detection methods to liquid surface fluctuations, partial obstruction, or installation errors. This makes it suitable for real-time monitoring of the internal liquid state of devices under test in complex environments. Attached Figure Description
[0046] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0047] Figure 1 This is a schematic diagram of the liquid level measuring device provided in the embodiments of this application;
[0048] Figure 2 A diagram showing the positional relationship of each module in the liquid level measuring device provided in the embodiments of this application;
[0049] Figure 3 A schematic diagram of the measurement base point deviation provided in the embodiments of this application;
[0050] Figure 4 A schematic flowchart illustrating the liquid level measurement method provided in the embodiments of this application;
[0051] Figure 5 A comparison curve of the full-range alignment effect of the liquid level measurement method provided in the embodiments of this application;
[0052] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0053] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0054] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application.
[0055] In chemical, pharmaceutical, food processing, and energy industries, equipment such as reactors, evaporators, crystallizers, and fermenters often experience intense liquid movement, including bubble layers from boiling, surface foam coverage, and surface fluctuations caused by agitation. These conditions significantly interfere with the stability of traditional level measurement technologies. For example, in pharmaceutical fermenters, foam layers of varying thickness may form on the surface of the culture medium, making it difficult to determine the true liquid level. In chemical reactors, the intense boiling under high temperature and pressure causes frequent bubble bursts, resulting in drastic surface fluctuations. Furthermore, some equipment cannot utilize direct contact measurement methods (such as magnetic level gauges) due to sealing requirements or corrosive media. Therefore, there is an urgent need for a stable, low-cost, and highly accurate level measurement method capable of operating in complex dynamic environments to meet the real-time and reliability requirements of industrial automation for level monitoring.
[0056] In the existing technology, liquid level measurement using a differential pressure level gauge is one of the most common methods. The differential pressure level gauge measures the pressure difference between the pressure generated by the liquid phase medium and the reference pressure of the gas phase at the top of the container by installing pressure taps at the bottom (or at different heights on the side) of the container. The current liquid level height is then calculated based on the known density of the medium.
[0057] However, existing methods require setting pressure taps on the container and having them in direct contact with the liquid being measured. In practical applications, these methods are easily affected by factors such as changes in medium density, temperature fluctuations, pressure disturbances, and blockages in the pressure tapping pipeline, leading to reduced accuracy in liquid level measurement. Furthermore, they are not well-suited for equipment with complex internal structures that cannot easily accommodate pressure tapping devices.
[0058] Based on this, and according to the principle that visual information can reflect changes in the boundary between liquid and non-liquid areas, the inventors set up multiple visual detection areas along the direction of liquid level change inside the device under test, enabling the liquid state at different heights to form corresponding spatial sampling information. In the specific implementation, an image acquisition device simultaneously captures images of multiple visual detection areas, obtaining image data containing liquid surface boundary features. By analyzing visual features such as color, brightness, texture, and edge changes in the images, the relative positional relationship of the liquid surface in each visual detection area is identified. Combined with the pre-determined spatial interval relationship between each visual detection area, the liquid surface detection results at multiple discrete locations are fused and calculated. A continuous liquid level change curve is obtained through data fitting or interpolation, thereby achieving continuous measurement of the liquid level height. This technical solution avoids the problems of traditional differential pressure liquid level measurement requiring contact with the liquid and relying on the physical parameters of the medium, improving adaptability to different liquid media and complex equipment structures. Simultaneously, the joint analysis using multiple visual detection areas effectively reduces measurement errors caused by factors such as liquid surface fluctuations and local obstruction in single-point detection, improving the continuity, accuracy, and reliability of liquid level detection.
[0059] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0060] Figure 1 This is a schematic diagram of the structure of the liquid level measuring device provided in the embodiments of this application; as shown. Figure 1 As shown, the device includes: a visual inspection component 10, an image acquisition module 20, and a processing module 30. The visual inspection component 10 includes at least two transparent inspection windows 101 and an auxiliary lighting device 102.
[0061] It should be understood that traditional single-window vision solutions are limited by the window's height and cannot cover a large measurement range. Furthermore, in complex conditions such as foam coverage or liquid boiling, non-contact level gauges using radar or ultrasound suffer severe attenuation of electromagnetic or acoustic signals by the foam layer, leading to measurement failure. This application solves the problem of limited single-window measurement range by setting multiple transparent detection windows vertically along the side wall of the device. Each window only needs to cover its corresponding segment, and the combination of multiple windows can cover a larger total range, fundamentally solving the problem of limited single-window measurement range.
[0062] A flange interface is opened on the side wall of the equipment under test, and a transparent detection window 101 made of quartz glass or other temperature- and pressure-resistant transparent material is installed. The inner surface of the window can be treated with a hydrophobic coating to prevent liquid adhesion and contamination. After installation, each window is numbered and its actual installation height relative to the equipment reference point is recorded. The spacing between each transparent detection window 101 is determined according to the target measurement range and the height of the window itself—the smaller the spacing, the higher the measurement accuracy, but the more windows are required; the larger the spacing, the fewer windows are required, but the interpolation range between adjacent windows increases.
[0063] In one specific implementation, taking two transparent detection windows 101 as an example, the vertical distance D between the two windows is determined according to the required liquid measurement range L and the height H of a single window, satisfying: L≈D+2H. Taking a measurement range of 50-60cm and a single window diameter of 20cm as an example, setting the vertical distance between the two windows to 10-20cm is sufficient to cover the target measurement range.
[0064] It should be noted that when creating transparent inspection windows 101 vertically on the side wall of the equipment under test, a mature industrial sight glass installation method can be used. Specifically, firstly, mechanical openings are made in the side wall of the equipment under test according to the required number and location of transparent inspection windows 101; then, high-neck flanges are welded or flange bases are installed at the openings to reinforce the structure of the opening area and ensure the equipment's compressive strength; then, quartz glass or other temperature- and pressure-resistant transparent materials are fixed to the flange base through flanges, glands, and gaskets. During installation, it is necessary to ensure that the flange sealing surface is flat, clean, free of welding slag and scratches, and to select appropriate gaskets (such as PTFE gaskets, graphite gaskets, etc.) according to the operating temperature; when tightening bolts, force should be applied gradually in a diagonal and even manner to avoid glass breakage due to excessive local stress. For equipment with special linings such as enamel-lined parts, welding operations should only be performed on the outer surface of non-enamel-lined parts such as jackets, and appropriate cooling measures should be taken to prevent damage to the lining. In this way, even if the wall of the device under test is made of an opaque material (such as metal, enamel, etc.), multiple transparent detection windows 101 can be stably installed on its side wall to provide a clear optical channel for subsequent image acquisition.
[0065] On the other hand, due to the complex and variable lighting conditions in industrial environments, the intensity and direction of natural or ambient light are unstable, which can severely affect the quality of image acquisition and the accuracy of intelligent image recognition. The auxiliary lighting device 102 provides controllable and stable backlighting, creating a clear brightness contrast between the liquid and gas / foam areas within the transparent detection window 101, thereby significantly reducing the difficulty of image recognition. The backlight source can be a white surface light source, a red-green dual-color LED light source, or an adjustable brightness LED light source.
[0066] In one specific embodiment, the auxiliary lighting device 102 is installed outside the device under test, located on the back of the transparent detection window 101 (i.e., the side opposite to the image acquisition module) or offset on the same side, ensuring that light can pass through the transparent detection window 101 uniformly. For a white light source solution, the brightness and angle of the light source need to be adjusted after installation to ensure uniform illumination in the window area; for a red-green dual-color LED solution, it is necessary to ensure that the liquid phase displays one color (e.g., green) and the gas phase displays another color (e.g., red), so that the liquid surface position is clearly presented through the color boundary line. For an adjustable brightness light source solution, it is also necessary to cooperate with an ambient light sensor to form a closed-loop brightness control to adapt to day and night changes and differences in the transparency of different liquids.
[0067] Understandably, by setting at least two transparent detection windows 101 along the height of the device under test, the liquid level change range can be segmented and mapped to different observation positions, thus maintaining an imaging scale suitable for recognition in each detection area even under large-scale conditions. The spacing between each transparent detection window 101 is determined based on the liquid level height and the window height, ensuring that adjacent detection areas can cover the target liquid level change range while reducing ineffective redundant areas, thereby balancing range expansion and detection accuracy. The auxiliary lighting device is located on one side of the transparent detection window 101 and provides stable lighting conditions, making the brightness, contrast, and liquid surface boundary features at the window more stable. Therefore, it is beneficial to continuously acquire clear visual information even under conditions of steam, foam, or fluctuating ambient light, thereby improving the continuity of liquid level recognition and measurement stability.
[0068] Furthermore, the image acquisition module 20 is used to acquire image data covering the entire transparent detection window 101. The image acquisition module 20 includes a single industrial image acquisition device.
[0069] Existing multi-point image measurement systems employ a multi-camera-to-multi-measurement-point scheme, with each window configured with an independent camera. Hardware costs increase linearly with the measurement range. This application utilizes a single industrial image acquisition device whose field of view covers the entire transparent detection window 101. By replacing the multi-camera-to-multi-window scheme with a single camera covering multiple windows, image data from each visual detection area can be acquired under the same time reference, the same installation coordinate system, and consistent imaging parameters. This reduces measurement errors caused by installation deviations, trigger asynchrony, and calibration differences between multiple devices, significantly lowering hardware costs while ensuring synchronous image acquisition across all windows.
[0070] Specifically, a single industrial camera is installed outside the device under test, directly facing the transparent inspection window 101. The lens focal length is adjusted so that the camera's field of view covers the entire transparent inspection window 101. A global shutter model is preferred for the camera to clearly capture the instantaneous liquid surface morphology under boiling conditions. The camera connects to the processing module 30 via a gigabit Ethernet interface or a USB interface, transmitting image data in real time at a frame rate of 20fps or higher.
[0071] Understandably, by using a single industrial image acquisition device to cover the entire transparent detection window 101, the hardware cost does not increase linearly with the range—only the number of quartz windows needs to be increased when the range increases, without increasing the cost of electronic components such as cameras. The total hardware cost is low, and the images of all windows are acquired synchronously by the same device, avoiding the time synchronization problems between different devices in multi-camera solutions. Global shutter technology can capture the entire image simultaneously during a single exposure, avoiding the image distortion problems common in rolling shutters, making it suitable for industrial vision systems that require precise measurement and positioning.
[0072] The processing module 30 is connected to the image acquisition module 20 and is used to analyze and process the image data to obtain the relative position of the liquid surface in each transparent detection window 101. The processing module 30 is also used to calculate the continuous liquid level measurement result based on the relative position of the liquid surface in each transparent detection window 101 and the spatial position of each transparent detection window 101.
[0073] It should be understood that existing artificial intelligence (AI) visual liquid level identification solutions require pixel-level liquid surface boundary segmentation across the entire image. These solutions involve complex AI models, require large amounts of training data (typically thousands of labeled images), and demand high inference computing resources (GPU / NPU), making them difficult to deploy on low-cost edge computing devices. This application reduces the AI recognition task from pixel-level liquid surface boundary segmentation to determining the liquid surface position within a window. Specifically, it only requires determining the relative height (0~100%) of the liquid surface within each transparent detection window, rather than searching for the liquid surface boundary across the entire image.
[0074] In the specific implementation process, after receiving the real-time image data from the image acquisition module 20, the processing module 30 first performs preprocessing on the image, including grayscale conversion, Gaussian filtering for noise reduction, and contrast enhancement. Subsequently, the region of interest (ROI) of each transparent detection window 101 is used to identify the liquid surface position, which can be done in the following way:
[0075] Method 1 (Traditional Vision): This method locates the liquid surface edge based on Canny edge detection and Otsu thresholding, and calculates the vertical pixel percentage of the liquid surface within the window. This method requires no training and is suitable for deployment on low-computing-power devices.
[0076] Method 2 (Lightweight AI): Train a lightweight CNN model (such as a simplified version of MobileNet) to directly regress the liquid surface ratio within the window. The training data only requires dozens to hundreds of labeled images.
[0077] Method 3 (Dual-color recognition): When using a red and green dual-color backlight and the liquid is transparent, the position of the red-green dividing line in the image is identified. AI recognition is simplified to color boundary detection.
[0078] It should also be noted that the multiple transparent detection windows 101 provide discrete point sampling information, while industrial control requires continuous liquid level values. The processing module 30 of this application converts the discrete window sampling results into continuous liquid level measurements through interpolation calculations during data processing. Essentially, it replaces full-range continuous scanning with multi-point discrete sampling and mathematical interpolation.
[0079] The processing module 30 calculates the current liquid level value according to the following logic, based on the installation height of each transparent detection window 101 and the relative position of the liquid surface in each window as determined by AI:
[0080] Scenario 1: The liquid level is located within a single window – Liquid level = height of the lower edge of the window + relative height of the liquid level within the window × window height;
[0081] Scenario 2: The liquid level is located between two windows - perform linear interpolation on the recognition results of the two windows, liquid level = height of the upper edge of the lower window + (height of the lower edge of the upper window - height of the upper edge of the lower window) × confidence weighting coefficient;
[0082] Case 3: The liquid level is higher than the top window or lower than the bottom window - output the preset upper or lower limit value of the range.
[0083] With the aforementioned device, during operation, the auxiliary lighting device 102 provides stable backlight illumination for the transparent detection window 101, and a single industrial camera in the image acquisition module 20 acquires image data covering the entire transparent detection window 101 in real time. After receiving the image data, the processing module 30 identifies the liquid level position of each window's ROI to obtain the relative height of the liquid level in each window. Then, based on the actual installation height of each window and the relative position of the liquid level in each window, the processing module 30 calculates the continuous liquid level value through interpolation. Finally, the calculated continuous liquid level value is converted into a standard industrial signal (4-20mA, RS-485 Modbus, or Ethernet) and output to a distributed control system (DCS) / programmable logic controller (PLC) system to achieve remote monitoring and automatic control.
[0084] In particular, in the specific implementation process, the liquid level measuring device of this application further integrates a manual verification module, an automatic cleaning module, and a foam layer thickness output function to improve the reliability, maintainability, and information richness of the device. The specific implementation method is as follows:
[0085] The manual review module receives manual correction results when the AI recognition confidence level falls below a threshold, and feeds the corrected data back to the processing module for incremental learning. In practice, when the processing module identifies the liquid surface position in the ROI image of each transparent detection window, it simultaneously outputs a confidence score for that identification (such as Softmax output probability or edge sharpness index). The system presets a confidence threshold (e.g., 0.85). When the AI recognition confidence level falls below this threshold, it indicates poor image quality or blurred liquid surface boundaries. The system automatically pushes the frame image and recognition result to the manual review interface (e.g., a host computer monitoring screen or mobile terminal), prompting the operator to make a manual judgment. Through the interactive interface provided by the manual review module, the operator manually marks or confirms the correct position of the liquid surface on the image. The corrected result serves as a new labeled sample, fed back to the processing module through an incremental learning mechanism. The lightweight CNN model uses the corrected data to perform small iterative updates on the existing model weights, allowing the model to gradually adapt to special working conditions (such as severe fogging, abnormal lighting, etc.), continuously improving recognition accuracy. Taking a chemical plant as an example, the probability of the confidence level falling below the threshold in the first week of operation is approximately 5%. Operators review about 3-5 images daily. After two weeks of incremental learning, the model's adaptability to interference factors such as window contamination and changes in lighting significantly improves, reducing the probability of the confidence level falling below the threshold to below 1%. The system's output liquid level measurement results become more stable and reliable. This module, through a closed-loop optimization mechanism involving human-machine collaboration, enables the AI model to continuously evolve during actual operation. It can adapt to new operating conditions without downtime for retraining, significantly extending the maintenance-free operation cycle of the unit and reducing long-term maintenance costs.
[0086] An automatic cleaning module is used to periodically or on-demand blow or wipe the optically transparent window. In practice, the inner surface of the transparent detection window is in long-term contact with process liquids containing foam, bubbles, or suspended matter, while the outer surface is exposed to the dusty environment of the industrial site, both of which can lead to a decline in imaging quality due to contamination. Therefore, the device of this invention incorporates an automatic cleaning module at the transparent detection window. This module can be implemented in any of the following ways or combinations: For the outer surface of the window, a compressed air blowing device (such as an air knife or a miniature air nozzle) is configured, using a solenoid valve to control compressed air to periodically (e.g., every 4 hours) or on-demand (triggered when the AI recognition confidence level continuously falls below a threshold) blow high-pressure onto the outer surface of the window to remove adhering dust and droplets; For the inner surface of the window, an automatic wiping device (such as a miniature wiper structure or a rotating brush head) is configured, with a reciprocating wiping mechanism with a scraper blade on the inner side of the window, driven by a miniature stepper motor, to wipe and clean the inner surface of the window during device shutdown for maintenance or on-demand triggering, removing foam residue and dirt. Furthermore, for applications where internal scaling is prone to occur, an ultrasonic anti-scaling device can be added to the inside of the window. This device uses ultrasonic vibration to inhibit the deposition of dirt on the window surface, extending the automatic cleaning cycle. Taking a fermenter as an example, the automatic purging device runs every 2 hours for 10 seconds each time. Combined with an AI-based confidence monitoring-based on-demand cleaning strategy, this maintains the window's light transmittance above 85%, ensuring image acquisition quality and extending the manual maintenance cycle from once a week to once a quarter. This significantly improves the automation level and on-site applicability of the device.
[0087] The foam layer thickness information is obtained by the processing module analyzing the foam layer boundaries within the window. In practice, the foam layer typically covers the liquid surface, and the two exhibit different textures and grayscale characteristics in the image—the liquid area usually has a uniform grayscale or color response, while the foam area shows fine granular texture and high light scattering characteristics. When processing image data, the processing module not only identifies the liquid surface boundary (i.e., the upper edge of the liquid) but also simultaneously identifies the upper boundary of the foam layer (i.e., the boundary between the top of the foam and the gas phase). Specifically, when using an edge detection + threshold segmentation scheme, multi-level threshold segmentation is used to identify the boundary positions of the liquid area, foam area, and gas area respectively; when using a lightweight CNN scheme, the training model simultaneously regresses and outputs two target values: the liquid surface position and the top position of the foam layer. After identification, the processing module calculates the vertical distance between the top of the foam layer and the liquid surface within the same window, and then, combined with the installation height and physical dimensions of the window, calculates the actual foam layer thickness at that window. When the liquid surface is located between two windows, the foam layer thickness is also obtained as a continuous value through linear interpolation. Ultimately, this foam layer thickness information can be used as an independent process variable, outputting to the DCS system via standard industrial signals. This provides process engineers with a reference for operations such as foam defoaming control and defoamer dosage optimization. Taking a certain reactor as an example, the system continuously outputs foam layer thickness values (0-15cm). When the foam layer exceeds 12cm, a DCS alarm is triggered. Based on this, operators activate the automatic defoamer dosing device, ensuring the foam layer is always controlled within a safe range and avoiding the risk of production accidents caused by foam overflow. This module, without increasing any hardware costs, fully utilizes the acquired image data to achieve additional measurement output of foam layer thickness, providing richer decision-making information for process control under complex operating conditions.
[0088] The liquid level measuring device provided in this application embodiment, by setting multiple visual detection areas at preset intervals inside the tested equipment, allows the liquid state at different locations to be collected and characterized in segments, thereby establishing a correspondence between liquid level changes and spatial positions. In actual detection, the multiple visual detection areas are equivalent to multiple sampling references arranged along the liquid height direction. By reasonably setting the spacing between the detection areas, the range of liquid level changes inside the tested equipment can be covered. When the liquid level rises or falls, the visual detection areas at different locations can collect visual difference information between liquid and non-liquid areas within the corresponding area. The image acquisition module acquires image data covering multiple visual detection areas, synchronously acquiring images within each detection area through a camera element, so that the image data contains visual feature information of the liquid surface boundary, liquid distribution, and corresponding spatial areas. The processing module performs image recognition and feature analysis on the acquired image data. By extracting brightness, color, texture, edge features, or visual differences between liquid and air in the image, the specific position of the liquid surface boundary in each visual detection area is determined, and the relative position information of the liquid surface with respect to each visual detection area is further obtained. After obtaining the relative positions of the liquid surface in each visual detection area, the processing module combines the actual spatial arrangement of multiple visual detection areas within the device under test to perform fusion calculations on the spatial coordinates, interval distances, and liquid surface position data corresponding to each detection area. By fitting or interpolating the liquid surface change trends between multiple discrete detection positions, the discrete visual detection results are converted into continuous liquid level measurement results. In this way, non-contact liquid level detection can be achieved using visual information without relying on traditional liquid level sensors directly contacting the liquid. Furthermore, by jointly calculating the visual detection results from multiple spatial locations, the continuity and accuracy of liquid level measurement are improved, reducing the susceptibility of single-point detection methods to liquid surface fluctuations, partial obstruction, or installation errors. This makes it suitable for real-time monitoring of the internal liquid state of devices under test in complex environments.
[0089] Figure 2 This is a diagram showing the positional relationship of each module in the liquid level measuring device provided in the embodiments of this application; as shown below. Figure 2As shown, the sidewall of the device under test is provided with at least two transparent detection windows 101 spaced vertically (two windows are shown as an example in the figure). An auxiliary lighting device 102 is installed on the outside of the transparent detection window 101 (such as on the back or offset on the same side) to provide stable backlight illumination so that the liquid surface boundary inside the window is clearly distinguishable. The image acquisition module 20 (a single industrial camera) is installed on the outside of the device under test facing the window. Its field of view covers all transparent detection windows 101. It collects image data of each window in real time and transmits it to the processing module 30 (edge computing device). The processing module 30 performs AI recognition on the image to obtain the relative position of the liquid surface in each window. Then, it performs interpolation calculations based on the actual installation height of each window to obtain the continuous liquid level measurement result. After that, it converts the result into a standard industrial signal (such as 4-20mA or RS-485 Modbus) and outputs it to the DCS system to realize remote monitoring and automatic control. The entire system uses a single camera to cover multiple windows to achieve continuous and stable liquid level measurement with low hardware cost and low AI complexity under complex working conditions such as foam boiling.
[0090] Figure 3 This is a schematic diagram of the measurement benchmark deviation provided in the embodiments of this application; as shown. Figure 3 As shown in the figure, this diagram illustrates the vertical arrangement of the two transparent detection windows and their correspondence with the liquid level measurement range. The vertical axis represents the liquid level percentage (0%-100%), and the figure shows the vertical spacing of the two transparent detection windows (i.e., the upper and lower windows) on the side wall of the device under test, as well as the actual liquid level height reference values corresponding to the upper and lower edges of each window. By calibrating the installation height (i.e., the measurement reference point) of each window to correspond with the total range—for example, the upper window covers the high liquid level segment (e.g., 60%-100% range), and the lower window covers the low liquid level segment (e.g., 0%-40% range), with an overlapping area (e.g., 40%-60% range) formed between adjacent windows as an interpolation transition interval—a large range of complete coverage is achieved within the limited field of view of a single window. Simultaneously, the redundant information in the overlapping area ensures a smooth transition in liquid level measurement when crossing different windows, effectively eliminating measurement reference point deviations caused by window layout, providing accurate reference points for subsequent interpolation calculations, and ultimately ensuring the continuity and consistency of liquid level measurement results across the entire range.
[0091] Figure 4 This is a schematic flowchart of the liquid level measurement method provided in the embodiments of this application; as shown Figure 2 As shown, in this embodiment... Figure 1 Based on the embodiments, the process of calculating the liquid level using the processing module is described in detail. The method includes:
[0092] S401. Obtain image data corresponding to multiple visual detection areas acquired by the image acquisition module.
[0093] In this application, the liquid level measurement method is executed by the processing module in the liquid level measurement device. The image acquisition module serves as the front-end input unit of the processing module, used to acquire image data corresponding to multiple visual detection areas. The visual detection areas are partitioned observation areas arranged at intervals along a preset direction of the device under test. In the liquid level measurement scenario, this preset direction is typically vertical, and each visual detection area corresponds to a different height segment on the outer wall of the container under test. The image data is the imaging data output by the image acquisition module. When executing this step, the processing module receives the image data sent by the image acquisition module and completes the aggregation of image data corresponding to multiple visual detection areas based on the current measurement cycle.
[0094] In practical implementation, the image acquisition module uses a single industrial image acquisition device (such as an industrial camera, 1.6 megapixels, global shutter). The field of view of this image acquisition device covers multiple visual inspection areas (i.e., optically transparent windows) spaced vertically on the side wall of the device under test. The industrial camera is installed outside the device under test, directly facing the transparent inspection window, approximately 50cm away. The lens focal length is adjusted to ensure the field of view covers the entire transparent inspection window. The camera connects to the processing module via a gigabit network interface or a USB interface, acquiring image data containing the entire inspection area in real time at a frame rate of 20fps or higher, and transmitting the acquired image data to the processing module for subsequent processing. Taking a chemical reactor as an example, its side wall has two quartz glass windows with a diameter of 20cm, vertically spaced 35cm apart. The industrial camera acquires image data containing both windows in real time.
[0095] Understandably, by covering the entire visual inspection area with a single image acquisition device, the hardware cost does not increase linearly with the increase in range—only the number of quartz windows needs to be increased when the range increases, without increasing the cost of electronic components such as cameras. Meanwhile, global shutter technology can capture the entire image simultaneously during a single exposure, avoiding the image distortion problems common with rolling shutters. It is suitable for capturing clear, instantaneous liquid surface morphology under dynamic conditions such as boiling liquid and bursting bubbles, providing reliable raw data for the accuracy of subsequent image processing.
[0096] S402. Perform image processing on the image data to determine the relative position of the liquid surface in each visual detection area.
[0097] In one possible embodiment, the image data is first preprocessed; then the preprocessed image data is input into a trained lightweight convolutional neural network model, and the lightweight convolutional neural network model regresses and outputs the liquid surface ratio in the visual detection area; finally, based on the liquid surface ratio and the height of the visual detection area, the relative position of the liquid surface in each visual detection area is determined.
[0098] The preprocessing includes at least one of image enhancement, noise removal, and region localization.
[0099] It should be understood that after the image acquisition module outputs image data covering multiple visual detection areas, the processing module first preprocesses the image. Image enhancement can employ brightness correction, contrast stretching, or sharpness enhancement to make the difference between the liquid surface and the background clearer. Noise removal can utilize median filtering, Gaussian filtering, or smoothing to reduce steam interference, reflective spots, and stray textures. Region localization involves cropping corresponding image blocks based on the coordinate range of each visual detection area within the entire image, allowing subsequent analysis to focus on the target area. When using neural network recognition, the preprocessed image data is input into a lightweight convolutional neural network model. The model directly regresses the output liquid surface position ratio, position coordinates, or distance relationship relative to the reference plane based on convolutional features. This lightweight convolutional neural network model can employ a depthwise separable convolutional structure or a lightweight residual structure to reduce computational load and facilitate deployment on the processing module. In practical applications, other models of this component can also be selected, and this application does not limit this choice.
[0100] It should be noted that the training process of the trained lightweight convolutional neural network model is as follows:
[0101] First, a training sample set is obtained; then, the sample images in the training sample set are input into the initial lightweight convolutional neural network model, and the predicted liquid level ratio is obtained through forward propagation; then, the loss function value is calculated based on the predicted liquid level ratio and the liquid level ratio label; finally, the network parameters of the initial lightweight convolutional neural network model are updated by backpropagation based on the loss function value until the model converges, and the trained lightweight convolutional neural network model is obtained.
[0102] The training sample set includes multiple sample images. Each sample image is an image that contains the visual detection area. Each sample image is labeled with a corresponding liquid level ratio label. The liquid level ratio label is used to characterize the proportion of the actual relative height of the liquid level in the visual detection area to the total height of the visual detection area.
[0103] It should be understood that this embodiment first constructs a training sample set for model training. Specifically, images containing transparent detection windows are acquired in real time using the aforementioned industrial camera as raw sample images. During the acquisition process, this embodiment performs image acquisition under various working conditions, including but not limited to: different liquid levels, different foam layer thicknesses (e.g., 0-15cm), different boiling intensities, and different ambient light intensities. Preferably, no fewer than 500 raw sample images covering the above-mentioned working conditions are acquired to ensure the diversity of training samples and the generalization ability of the model. Then, the constructed training sample set is divided into a training set and a validation set, with the training set accounting for 80% of the total samples and the validation set accounting for 20%. The sample images in the training set are input into the initial lightweight convolutional neural network model for iterative training.
[0104] The initial lightweight convolutional neural network model preferably adopts a regression network based on an improved MobileNetV3 architecture. Its backbone feature extraction network uses depthwise separable convolution instead of conventional convolution to significantly reduce the number of model parameters and computational cost. Specifically, the model's input is a preprocessed window region image (preferably an RGB image with a resolution of 224×224×3), and the output is a floating-point number between 0 and 1, representing the predicted liquid surface ratio.
[0105] The iterative training process is as follows: A batch of sample images (batch size set to 32) is input into the model. After forward propagation through convolutional layers, pooling layers, and fully connected layers, the predicted liquid level ratio for each sample is obtained. Then, the mean squared error (MSE) is used as the loss function to calculate the loss between the predicted value and the labeled ground truth value. Subsequently, the Adam optimizer (with an initial learning rate of 0.001, decaying to 0.1 times the original rate every 50 epochs) is used to update the model parameters through backpropagation. The above process is repeated until the model's loss value on the validation set stabilizes and no longer decreases significantly, at which point training stops, resulting in a trained lightweight convolutional neural network model.
[0106] For each acquired raw sample image, a corresponding liquid level scale label is manually or semi-automatically labeled. The specific labeling method is as follows: First, the visual detection area (ROI) containing the optically transparent window is defined in the image. Then, an image annotation tool is used to measure the vertical position of the liquid level within the ROI. The ratio of the vertical distance between the liquid level and the bottom of the window to the total vertical height of the window is used as the liquid level scale label for that sample image. For example, if the liquid level is located at halfway down the vertical direction of the window, the scale is 0.5; if it is located at one-quarter of the vertical direction, the scale is 0.25; if it is above the top of the window (the window is completely submerged), the scale is 1.0; and if it is below the bottom of the window (the window is completely exposed to the gas phase), the scale is 0. Thus, each sample image corresponds to a continuous liquid level scale label within the range of 0 to 1.
[0107] It should also be noted that the above is only one method of using lightweight AI to identify the relative position of the liquid level. After preprocessing, visual recognition can also be used to identify the relative position of the liquid surface: that is, Canny edge detection is performed on the preprocessed window ROI image to extract edge information from the image; then, the Otsu automatic thresholding segmentation algorithm is used to separate the liquid area from the gas / foam area in the image to obtain a binary image; in the binary image, the number of pixel rows of the liquid area in the vertical direction of the window is counted, and its proportion to the total number of pixel rows in the window is calculated. This proportion is the relative position of the liquid surface within the window (0~100%). Taking a certain reactor as an example, if the liquid area in the lower window ROI occupies 65% of the total height of the window, then the relative position of the liquid surface within the window is 65%.
[0108] Furthermore, when the liquid under test is transparent and the auxiliary lighting device is a red-green dual-color backlight, the backlight emitted by the auxiliary lighting device will appear as one color (e.g., green) in the liquid phase region and another color (e.g., red) in the gas phase region. The liquid surface position is the boundary line between the two colors. The processing module first converts the image to a suitable color space, then identifies the boundary line between the red and green regions in the image data, and then calculates the relative position of the liquid surface in the detection area based on the vertical pixel position of the boundary line within the window. This method simplifies AI recognition to color boundary detection, further reducing the algorithm complexity.
[0109] It should be noted that when using any of the above methods, if the system determines that the imaging quality of a certain window is poor (such as local contamination, fogging, etc.), it can automatically reduce the recognition confidence of that window and give priority to using window data with good imaging quality for liquid level determination.
[0110] Understandably, this step improves image recognizability through preprocessing and extracts the relative position of the liquid surface through both traditional edge segmentation and neural network regression, ensuring stable output of liquid surface information within each visual detection area. Calculating the vertical proportion based on the boundary or directly regressing the position using a lightweight convolutional neural network model can convert image information into a unified position quantization result, providing input for subsequent continuous liquid level measurements. With this implementation, liquid surface boundaries are more easily recognized under complex imaging conditions, the relative position output within the visual detection area is more continuous, the processing module's adaptability to different operating conditions is improved, and the reliance on highly complex image processing is reduced while maintaining recognition accuracy.
[0111] S403. Obtain the spatial location information corresponding to each visual detection area.
[0112] The spatial location information includes at least the installation height of the lower edge of each visual inspection area relative to the bottom of the device under test, and the effective height of each visual inspection area.
[0113] It should be understood that in this application, after obtaining the relative positions of the liquid surface in each visual detection area, the processing module further obtains the spatial position information corresponding to each visual detection area to establish the relationship between the image area and the actual liquid level height. The spatial position information describes the installation height, area length, mutual spacing, and spatial coordinates of each visual detection area relative to a unified reference position within the liquid level measuring device. Specifically, it can be expressed as the upper boundary height value, lower boundary height value, center height value, or area start and end coordinates of each visual detection area. The processing module can read this spatial position information from local memory, parameter configuration files, calibration databases, or external control systems. In one possible embodiment, the visual detection areas are arranged at intervals along the vertical direction of the device under test. The processing module pre-stores the actual height interval corresponding to each area, and the spatial position information is thus represented in the form of area start and end heights. For mapping deviations caused by installation errors, lens perspective, or differences in container shape, the spatial position information can be obtained through on-site calibration. During calibration, the known height of the liquid surface or scale is sequentially mapped to multiple visual detection areas within the device under test. The processing module records the mapping parameters between the image area boundaries and the actual height values and stores the mapping parameters. Therefore, in subsequent measurement processes, the processing module can call the spatial location information corresponding to each visual detection area to calculate the liquid level.
[0114] In practical implementation, the spatial location information table in the processing module may include the region number, the lower boundary height of the region, the upper boundary height of the region, and the effective height of the region. If the correspondence between the visual detection region and the actual height has non-linear characteristics, the processing module can also store the mapping relationship from the image position within the region to the actual height. When the device is reinstalled after maintenance, the processing module can perform a recalibration process to update the spatial location information to ensure that the region height mapping is consistent with the current mechanical installation state. Based on the above analysis, this step enables each visual detection region to not only have a partitioning meaning on the image, but also to establish a correspondence with a specific height range in the actual space, thereby allowing the relative position within the region obtained in the previous step to be converted into the actual liquid level height.
[0115] S404. Calculate the continuous liquid level measurement results based on the relative position and spatial position information of the liquid surface in each visual detection area.
[0116] In one possible embodiment, the current position of the liquid surface is first determined based on its relative position in each visual detection area. When the liquid surface is located within any visual detection area, a continuous liquid level measurement result is calculated based on the spatial position of the visual detection area and the relative position of the liquid surface within that visual detection area. When the liquid surface is located between two adjacent visual detection areas, interpolation is performed based on the spatial position of the two adjacent visual detection areas and the relative position of the liquid surface within the two adjacent visual detection areas to obtain a continuous liquid level measurement result.
[0117] It should be understood that when the liquid surface is within any visual detection area, the processing module uses the spatial position information of the visual detection area as a reference, and combines it with the relative position of the liquid surface within the visual detection area to convert the normalized position into the actual liquid level height.
[0118] When the liquid surface lies between two adjacent visual detection areas, the processing module acquires the spatial position information of the two adjacent visual detection areas and the relative position of the liquid surface within each area. Based on the geometric relationship between these two areas, it performs interpolation calculations to obtain a continuous liquid level measurement result between them. The interpolation calculation can use linear interpolation, or other mathematical interpolation methods can be employed based on the spacing between visual detection areas, the overlap of the fields of view, and the liquid surface variation pattern, ensuring continuous liquid level output during area switching. This processing method allows for smooth transitions between measurement results when the liquid surface crosses different visual detection areas, preventing jumps at area boundaries.
[0119] The processing module first determines the relative position of the liquid surface in each visual detection area based on the image processing results. Then, it combines the spatial position information of each visual detection area to complete the liquid level conversion or interpolation calculation and outputs continuous liquid level measurement results. When the liquid surface is in a single area, the output value directly corresponds to the spatial reference and relative position of that area. When the liquid surface is between areas, the output value is constrained by the adjacent areas, thus forming a continuous liquid level curve.
[0120] In the specific implementation process, the processing module calculates the current liquid level value according to the following logic, based on the installation height of each visual detection area and the relative position of the liquid surface in each visual detection area as identified by AI:
[0121] Scenario 1 (Liquid surface located within a single visual detection area (window): When the liquid surface is located between the top and bottom edges of a window, the liquid level = actual installation height of the bottom edge of the window + percentage of the liquid surface's relative position within the window × window height. For example, if the bottom edge height of the lower window is 30cm, the window height is 20cm, and the AI identifies the liquid surface's relative position within the window as 65%, then the current liquid level = 30 + 65% × 20 = 43cm.
[0122] Scenario 2 (Liquid Surface Between Two Windows): When the liquid surface is located in the gap between two adjacent windows, the refracted light from the lower window and the reflected light from the upper window can be used as dual constraint information. A linear interpolation method with confidence weights can then be used to calculate the continuous liquid level. For example, in a liquid level measuring device, the lower edge of the lower window is 30cm from the device reference point, both windows have a diameter of 20cm, and the vertical distance is 35cm. When the processing module determines that the liquid level is higher than the upper edge of the lower window (i.e., the liquid level exceeds 50cm) but has not yet entered the lower edge area of the upper window, it indicates that the liquid surface is within the 35cm gap between the two windows. In this case, the degree to which the liquid surface is close to the upper edge of the lower window is determined using the refracted light characteristics collected from the lower window, and the degree to which the liquid surface is close to the lower edge of the upper window is determined using the reflected light characteristics collected from the upper window. The corresponding liquid level estimates and recognition confidence scores are obtained respectively. For example, if the recognition confidence score for the lower window is 0.7 and the recognition confidence score for the upper window is 0.3, then the interpolation coefficient is calculated based on the confidence weights of the two windows. And calculate the liquid level Calculations are performed to smoothly transition the liquid level value from the lower window detection result to the upper window detection result, thereby obtaining continuous liquid level values within the region between the two windows. This method utilizes the differences in refraction and reflection of light by the liquid in different windows to improve the reliability of liquid level estimation within the interval region, enabling the output of continuous liquid level measurement results without adding a continuous detection window.
[0123] It should be noted that during the liquid level calibration process, the container was ensured to only uniformly feed material without discharging it during the liquid level rise from 30cm to 105cm. If the entire process takes 20 minutes, the liquid level rises by 1% every 12 seconds and by 0.5% every 6 seconds. During the rise from 50cm to 85cm, an image was recorded every 6 seconds, resulting in 93 continuous liquid level change image samples. This allows the visual recognition model to cover the complete change process of the refractive area, reflection area, and transition area between the two as the liquid level moves from low to high. This continuous sampling method avoids the problem of image feature jumps or sample loss due to rapid liquid level changes, improves the AI recognition model's ability to learn the changing patterns of the liquid surface boundary, and utilizes the correlation between continuous images at multiple time points to achieve accurate fitting of the liquid level position, improving the continuity, stability, and accuracy of the liquid level detection results. This provides a reliable data foundation for subsequent liquid level interpolation calculations based on window optical features.
[0124] Case 3 (transparent liquid with red-green dual-color backlight): If the liquid to be tested is transparent and the auxiliary lighting device is a red-green dual-color backlight, the boundary line between the red and green areas in the image data is identified first. Then, the relative position of the liquid surface in the detection area is determined based on the boundary line position. Finally, interpolation calculation is performed according to the above case.
[0125] It should be noted that when the liquid level is above the uppermost detection area, the continuous liquid level measurement result is determined as the first preset value; when the liquid level is below the lowermost detection area, the continuous liquid level measurement result is determined as the second preset value. For example, if the total range of the device is 30-105cm, then the output will be 105cm when the liquid level is above 105cm and 30cm when the liquid level is below 30cm. The first preset value is greater than the second preset value.
[0126] It should also be noted that the recognition confidence score is not only used for cases where the liquid level is between two windows, but can serve as a unified evaluation parameter throughout the entire visual liquid level detection process. It calculates the reliability of the corresponding liquid level position by measuring the degree of change in optical features under different liquid level conditions. Specifically, based on the positional relationship between the liquid surface and the detection window, the recognition confidence score can be divided into the following different cases:
[0127] Liquid surface within a single window: When the liquid surface enters a certain detection window, the liquid-air interface significantly affects the light path within the window, causing some light rays to refract, transmit, and reflect. At this point, an AI recognition model identifies the boundary of the liquid region in the window image and calculates the first-type recognition confidence level based on boundary clarity, regional continuity, and the degree of optical feature matching. That is, when the liquid level is inside the lower window, a clear liquid surface boundary line can be detected in the image. If the identified liquid surface edge highly matches the standard optical features in the training model, a high score is obtained. ,(like =0.96), and then, the initial liquid level value is weighted and corrected according to the recognition confidence level to obtain the final liquid level value.
[0128] For example, suppose the lower boundary calibration height of a certain detection window is... Window height is The AI identifies the relative proportion of the liquid surface boundary within the window as r, and then the initial liquid level height is obtained based on the image recognition results:
[0129]
[0130] in, This indicates the liquid level value calculated directly based on the liquid surface's position within the window. Further, it is determined based on the current image recognition confidence level. The result is then corrected. Higher confidence indicates a clearer liquid surface boundary and a calculation result closer to the actual liquid level. Conversely, lower confidence reduces the impact of this result on the final liquid level value and fuses it with historical liquid level trends or predicted values from adjacent frames. Therefore, the following format can be used:
[0131]
[0132] Where H is the final output liquid level value. This is the liquid level value predicted based on the liquid level change trend at the previous moment.
[0133] For example, when the detection liquid level range corresponding to a certain window is 50cm to 70cm, the window height... If the AI identifies the liquid level as being at 60% of the window height, then the initial liquid level calculation is as follows:
[0134]
[0135] If the liquid surface boundary is clear and the refracted light region is continuous and stable in the current image, the recognition confidence level can be calculated. The predicted value is based on the previous liquid level change trend. The final liquid level will be:
[0136] H = 0.95 × 62 + 0.05 × 61.5 = 61.975 cm, approximately 62 cm.
[0137] As can be seen, by adopting the above method, the confidence level recognition enables dynamic evaluation and error suppression of the visual detection results. When the liquid surface is inside the window, it not only allows for direct calculation of the liquid level based on the boundary position of the liquid surface, but also utilizes the confidence level to reduce measurement deviations caused by factors such as changes in illumination, liquid fluctuations, and image noise, thereby improving the stability and accuracy of the liquid level detection results. For transparent liquids or scenarios with indistinct boundaries, the weight of the current recognition result can also be automatically reduced by using a lower confidence level, thus enhancing the robustness of the system.
[0138] When the liquid surface is located between two windows or when using a transparent liquid dual-color backlight detection: Since the liquid surface cannot be fully displayed within a single window when it is in the gap between two adjacent windows, a joint judgment is needed based on the optical change characteristics of adjacent windows. Specifically, the lower window mainly reflects the change in refracted light after the liquid surface leaves the window, while the upper window mainly reflects the change in reflected light before the liquid surface approaches the window. The corresponding recognition confidence levels are calculated for each window. and The liquid level position is determined using a confidence-weighted method. For example, when the liquid level is within the gap between two windows (70cm and 90cm), the confidence level of the refractive feature detected by the lower window is [value missing]. The confidence level of the reflection features detected by the upper window is Then, linear interpolation is performed based on the weighted proportions of the two confidence levels to obtain the continuous liquid level height. Furthermore, for transparent liquids where it is difficult to form a clear liquid surface boundary, a red-green dual-color backlight can be used to produce different color responses in the liquid and non-liquid areas. The recognition confidence level in this state is then calculated based on the proportion of red and green light areas, color change trends, and boundary transition characteristics. This enables liquid level identification under transparent liquid conditions. For such cases, the calculation method described in the above embodiments can be used, and will not be repeated in this embodiment.
[0139] When the liquid level is below the bottom window or above the top window: Since the liquid level does not enter either detection window, the liquid level height cannot be directly calculated from the liquid surface boundary. Therefore, it is necessary to use the recognition confidence level corresponding to the reflected light change characteristics for liquid level estimation. The core idea is that as the liquid level changes, the distance between the liquid surface and the window changes, causing continuous changes in the intensity, spot area, brightness distribution, and optical path change of the reflected light collected by the window. By establishing a mapping relationship between the reflected light characteristic parameters and the liquid level height, and using the recognition confidence level to correct the mapping result, the final liquid level value is obtained.
[0140] Specifically, firstly, continuous images of the liquid level change process are acquired, and the reflected light feature parameters in each frame are extracted, such as the average gray value G of the reflected area, the spot area S, and the brightness gradient change value. And so on, and input the above features into a pre-established reflected light level mapping model to obtain the initial level value calculated based on the optical features:
[0141]
[0142] in, This indicates the liquid level height directly estimated based on the current reflected light characteristics. Further, the identification confidence level is calculated based on the degree of matching between the current reflected light characteristics and the standard liquid level change curve. The recognition confidence level is used to characterize the reliability of the liquid level calculation result corresponding to the current change in reflected light. Then, the recognition confidence level is used to fuse and correct the initial liquid level value and the predicted liquid level value.
[0143]
[0144] Where H is the final output liquid level value. This is the liquid level value predicted based on the liquid level change trend at the previous moment.
[0145] For example, if the bottom edge of the lowest window is 20cm high, when the liquid level gradually rises from 10cm to 15cm, the liquid surface has not yet entered the window area. However, as the liquid level gradually approaches the lowest window, the area and intensity distribution of reflected light received by the window change continuously. By establishing the correspondence between the characteristics of reflected light and the liquid level height, an initial liquid level estimate can be obtained. The confidence level is calculated based on the degree of matching between the current trend of reflected light change and the standard change curve. The liquid level results are then corrected.
[0146] For example, if the top edge of the uppermost window is 100cm high, when the liquid level exceeds 100cm, the liquid surface moves away from the recognition area of all windows. At this point, although the boundary of the liquid surface within the window cannot be obtained, the continued rise of the liquid level will cause changes in the incident angle of reflected light, the reflection area, and the brightness distribution. The recognition confidence level is calculated by analyzing these changes. And the liquid level height is deduced based on the reflected light model.
[0147] In summary, corresponding recognition confidence parameters were constructed for different liquid level states. , , and This allows the device to automatically select the corresponding optical recognition method based on the area where the liquid surface is located, and to use confidence level to quantify and calculate the recognition results, thereby avoiding detection failures caused by window gaps, transparent liquids, or exceeding the window range, and improving the accuracy, continuity, and robustness of the visual liquid level detection system under different working conditions.
[0148] Furthermore, it should be noted that the method of setting different recognition confidence parameters for different liquid level positions in this embodiment and calculating the liquid level based on the recognition confidence is merely an illustrative example and not the only implementation method. In practical applications, the recognition confidence can be determined based on one or more parameters such as the clarity of the liquid surface boundary, the degree of change in refracted light, the change pattern of reflected light, the characteristics of the dual-color backlight area, the stability of continuous frame changes, and the model output probability. Simultaneously, the liquid level calculation process can be implemented using different methods such as weighted fusion, function mapping, interpolation calculation, and model prediction correction. Therefore, the core of this embodiment lies in evaluating the credibility of the detection results under different liquid level conditions through recognition confidence and improving the accuracy of liquid level estimation based on this credibility, without limiting the specific confidence calculation method or liquid level fusion formula.
[0149] In particular, for three-window or multi-window schemes, when the liquid level is between window 1 and window 2, if the recognition confidence of window 2 is lower than the threshold due to contamination or other reasons, it can automatically switch to window 1 and window 3 for interpolation calculation to achieve redundancy and fault tolerance.
[0150] After obtaining the continuous liquid level measurement results, the module converts these results into a preset communication format and outputs them to external control equipment. Specifically, the processing module converts the calculated continuous liquid level value into a standard industrial signal format, including but not limited to 4-20mA analog signal, RS-485 Modbus digital communication protocol, or Ethernet communication protocol, and outputs it to the DCS / PLC control system through the corresponding output interface to achieve remote real-time monitoring and automatic closed-loop control. Simultaneously, the processing module can also display the current liquid level value on a local display screen in real time and provide historical data query and trend analysis functions through a web interface or host computer software.
[0151] Figure 5 A comparison curve of the full-range alignment effect of the liquid level measurement method provided in the embodiments of this application; as shown. Figure 5As shown in the figure, this diagram illustrates the improvement in measurement accuracy and continuity when using a multi-window visual inspection scheme for liquid level measurement compared to the traditional single-window scheme. The horizontal axis represents the actual percentage of liquid level in the measured equipment, and the vertical axis represents the percentage of the measured liquid level. Theoretically, the measured result should be consistent with the actual liquid level, i.e., located near the ideal fitting line in the figure. The "single-window scheme" in the figure represents obtaining the liquid level position through a single visual inspection area. Due to the limited coverage of a single inspection window, when the liquid level is outside the window range or the liquid level position changes significantly, it is necessary to estimate the liquid level through extrapolation. Therefore, the measurement result is prone to large deviations, especially when the liquid level variation range is wide, and the actual measurement curve deviates significantly from the ideal curve. The "multi-window scheme (taking two windows as an example)" in the figure represents setting multiple visual inspection windows along the height direction of the measured equipment. Multiple windows are used to obtain liquid level position information in different height areas, and the liquid level reconstruction calculation is performed by combining the spatial positional relationships between the windows, so that multiple inspection points jointly constrain the final liquid level result.
[0152] As shown in the figure, the measurement points corresponding to the multi-window scheme are more concentrated near the ideal fitting line, exhibiting higher consistency with the actual liquid level. This indicates that by increasing the number of visual detection areas, the effective detection range can be expanded, reducing the measurement blind zone and cumulative error caused by a single detection window, thereby improving the accuracy and stability of liquid level measurement. The figure demonstrates that this scheme, through a combination of multi-window visual acquisition and spatial mapping calculation, achieves more accurate and continuous liquid level measurement results compared to the traditional single-window detection method.
[0153] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 6 As shown, the electronic device 60 provided in this embodiment includes at least one processor 601 and a memory 602. Optionally, the device 60 further includes a communication component 603. The processor 601, memory 602, and communication component 603 are connected via a bus 604.
[0154] In a specific implementation, at least one processor 601 executes computer execution instructions stored in memory 602, causing at least one processor 601 to perform the above-described method.
[0155] The specific implementation process of processor 601 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0156] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0157] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0158] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0159] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0160] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0161] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0162] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0163] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0164] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0165] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0166] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0167] Based on the above disclosure, those skilled in the art will understand that the computer-readable storage medium and its related implementation methods provided in the embodiments of the present invention are not limited to the specific hardware or logical partitioning forms described above. In actual product or system deployments, computer execution instructions can be encapsulated in different software distribution packages or firmware modules and distributed via networks, optical discs, or mobile storage devices. When computer execution instructions are loaded and executed by one or more processors, in addition to implementing the aforementioned method steps, hardware resource configurations can be automatically identified according to specific application scenarios, and thread priorities or memory allocation strategies can be dynamically adjusted to optimize execution efficiency without manual intervention. Furthermore, the computer-readable storage medium can also be integrated into IoT terminals, edge computing nodes, or cloud servers to form a distributed instruction storage and collaborative execution system to meet differentiated needs such as high concurrency, low latency, or data privacy protection.
[0168] Furthermore, it should be emphasized that the logical functions corresponding to the methods, units, modules, and storage media in this application, without departing from the core idea of this invention, allow developers to make equivalent refactoring, renaming, or re-division based on specific programming languages (such as C++, Java, Python, etc.) or framework characteristics. For example, the functions of multiple "units" can be merged into a single service process, or message queues or pipe communication can be used instead of direct function calls. Even if these implementation details are not completely the same as the foregoing embodiments, as long as they ultimately achieve the same technical effect and no creative effort is required, they should all be considered to fall within the protection scope of this invention. Similarly, any intermediate data processing forms, exception handling mechanisms, or logging methods embodied in the instructions in the computer-readable storage medium when executed are also derivative technologies of this invention and should not be construed as substantial limitations on the original solution.
[0169] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0170] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
Claims
1. A liquid level measuring device, characterized in that, include: The visual inspection component includes at least two visual inspection areas spaced apart along a preset direction of the device under test, for visual inspection information corresponding to the liquid state inside the device under test; The image acquisition module is used to acquire image data covering the visual detection area; The processing module, connected to the image acquisition module, is used to analyze and process the image data to obtain the relative position of the liquid surface in each visual detection area; The processing module is also used to calculate the continuous liquid level measurement result based on the relative position and the spatial position of each visual detection area.
2. The apparatus according to claim 1, characterized in that, The visual inspection area is a transparent inspection window, which is arranged at intervals along the height of the device under test. The spacing between each transparent inspection window is determined according to the liquid level inside the device under test and the height of the transparent inspection window.
3. The apparatus according to claim 2, characterized in that, The visual inspection component also includes auxiliary lighting equipment; The auxiliary lighting device is located outside the device under test, on one side of the transparent detection window, and is used to provide stable lighting conditions to the transparent detection window.
4. The apparatus according to claim 1, characterized in that, The image acquisition module includes a single industrial image acquisition device, the field of view of which covers the entire visual detection area.
5. A method for measuring liquid level, characterized in that, The processing module applied in the liquid level measuring device as described in any one of claims 1-4 includes: Acquire image data corresponding to multiple visual detection areas acquired by the image acquisition module; The image data is processed to determine the relative position of the liquid surface in each visual detection area; Obtain the spatial location information corresponding to each visual detection area; The continuous liquid level measurement result is calculated based on the relative position of the liquid surface in each visual detection area and the spatial position information.
6. The method according to claim 5, characterized in that, The step of performing image processing on the image data to determine the relative position of the liquid surface in each visual detection area includes: The image data is preprocessed, and the preprocessing includes at least one of image enhancement, noise removal, and region localization. The preprocessed image data is input into a trained lightweight convolutional neural network model, and the lightweight convolutional neural network model is used to regress and output the liquid surface ratio in the visual detection area. The relative position of the liquid surface in each visual detection area is determined based on the liquid surface ratio and the height of the visual detection area.
7. The method according to claim 6, characterized in that, The training process of the trained lightweight convolutional neural network model is as follows: A training sample set is obtained, which includes multiple sample images. Each sample image is an image that contains the visual detection area. Each sample image is labeled with a corresponding liquid level ratio label. The liquid level ratio label is used to characterize the proportion of the actual relative height of the liquid level in the visual detection area to the total height of the visual detection area. The sample images in the training sample set are input into the initial lightweight convolutional neural network model, and the predicted liquid level ratio is obtained through forward propagation. The loss function value is calculated based on the predicted liquid level ratio and the liquid level ratio label; The network parameters of the initial lightweight convolutional neural network model are updated by backpropagation based on the loss function value until the model converges, thus obtaining the trained lightweight convolutional neural network model.
8. The method according to claim 5, characterized in that, The spatial location information includes at least the installation height of the lower edge of each visual detection area relative to the bottom of the device under test and the effective height of each visual detection area; The step of calculating the continuous liquid level measurement result based on the relative position of the liquid surface in each visual detection area and the spatial position information includes: The current position of the liquid surface is determined based on its relative position in each visual detection area; When the liquid surface is located within any visual detection area, the continuous liquid level measurement result is calculated based on the spatial location of the visual detection area and the relative position of the liquid surface within that visual detection area. When the liquid level is located between two adjacent visual detection areas, interpolation calculation is performed based on the spatial position of the two adjacent visual detection areas and the relative position of the liquid level within the two adjacent visual detection areas to obtain the continuous liquid level measurement result.
9. The method according to claim 8, characterized in that, The method further includes: When the liquid level is higher than the uppermost visual detection area, the continuous liquid level measurement result is determined as the first preset value; When the liquid level is below the lowest visual detection area, the continuous liquid level measurement result is determined as the second preset value, and the first preset value is greater than the second preset value.
10. The method according to claim 6, characterized in that, If the liquid to be tested is a transparent liquid and the auxiliary lighting device is a red-green dual-color backlight, determining the relative position of the liquid surface in each of the aforementioned visual detection areas includes: The target detection model is used to identify the boundary between the red and green regions in the preprocessed image data. The relative position of the liquid surface in each of the visual detection areas is determined based on the location of the dividing line.