Method, system, medium and device for automatic calculation of liquid level height based on spectral characteristics

By employing an automatic liquid level height calculation method based on spectral features and utilizing a camera and a Bayesian online change point detection algorithm, the shortcomings of traditional liquid level measurement technology in terms of accuracy, cost, and environmental adaptability are overcome. This enables low-cost and accurate monitoring of liquid level changes, and is applicable to fields such as soil and water conservation, industrial production, environmental protection, and water conservancy projects.

CN121430771BActive Publication Date: 2026-06-02PEARL RIVER HYDRAULIC RES INST OF PEARL RIVER WATER RESOURCES COMMISSION

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PEARL RIVER HYDRAULIC RES INST OF PEARL RIVER WATER RESOURCES COMMISSION
Filing Date
2025-10-27
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing liquid level measurement technologies have not yet achieved an effective balance between measurement accuracy, hardware cost, and environmental adaptability. Traditional contact sensors are susceptible to contamination and corrosion, while non-contact measurements have large errors and high costs under complex working conditions. Existing visual recognition methods are difficult to adapt to dynamic liquid level changes and containers with complex materials.

Method used

An automatic liquid level height calculation method based on spectral features is adopted. The method uses a camera to capture changes in the liquid level inside the container, and uses the spectral curve change point detection algorithm of the Bayesian online change point detection (BOCPD) framework, combined with the RGB three-channel spectral curve features, to monitor and calculate the liquid level height in real time. This avoids sensor intrusion and contact, reduces hardware costs, and adapts to complex working conditions.

Benefits of technology

It achieves low-cost, non-contact liquid level change monitoring, reduces maintenance costs, improves applicability under complex working conditions such as high temperature and high pressure, reduces measurement errors caused by environmental interference, and realizes accurate perception and continuous monitoring of dynamic liquid levels.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121430771B_ABST
    Figure CN121430771B_ABST
Patent Text Reader

Abstract

The application discloses a liquid level height automatic calculation method and system based on spectral characteristics, a medium and equipment, and particularly relates to the technical field of container liquid level automatic calculation and dynamic monitoring. The method improves the algorithm through spectral curve change point detection, accurately captures the spectral feature difference between gas phase and liquid phase through spectral sequence modeling, introduces the running length index and dynamic updating mechanism, filters out the real gas-liquid interface change point through the multiple check mechanism to filter the false change point, infers the type according to the mean difference before and after the change point and the running length change, takes the clear mutation point or the midpoint of the gradual transition zone as the interface, combines the pixel resolution and the bottom starting position, and obtains the actual liquid level height through formula calculation, establishes the conversion relationship between the pixel quantity and the actual liquid level height through the proportional relationship between the image axis pixel number and the absolute height of the container, and finally takes the average value of the calculation results of three wave bands as the absolute height of the liquid level based on the pixel number of the spectral curve feature point.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of automated calculation and dynamic monitoring technology of container liquid level, specifically to a method, system, medium, and equipment for automatic calculation of liquid level height based on spectral characteristics. Background Technology

[0002] Currently, the mainstream technologies for container liquid level measurement can be divided into three categories: contact measurement based on physical sensors, non-contact measurement based on acoustic / optical signals, and intelligent recognition methods based on computer vision. Contact measurement works by having a sensor directly contact the liquid or by relying on the liquid's physical properties. Representative technologies include float-type level gauges and capacitive sensors. While this method offers high measurement accuracy, its invasive installation requires direct contact with the measured substance, making the equipment susceptible to contamination or corrosion, resulting in high maintenance costs and limited applicability in many complex working conditions.

[0003] Non-contact measurement based on acoustic / optical signals is based on the principle of indirectly measuring liquid level by utilizing the reflection of external energy waves or optical properties, without contact with the liquid. Key technologies include laser ranging (Zhu Jian, Ge Chang, Zhang Jingzhi, et al., 2025. A liquid level gauge based on laser ranging: CN202510693269.0 [P / OL]. 2025-07-15 [2025-07-22].) and ultrasonic ranging (Xu Xiwen, Luo Liming, 2024. A non-contact precision measuring device and method for liquid level gauge: CN202310695927.0 [P / OL]. 2024-12-13 [2025-07-22].). While this type of non-contact measurement avoids the risks of pollution and corrosion, it is highly dependent on the straight-line propagation path of sound waves or light, and is prone to measurement errors under complex working conditions such as high temperature and high pressure.

[0004] In recent years, with the rapid development of image sensors and edge computing capabilities, intelligent recognition methods based on computer vision algorithms have gradually emerged. Li Cijun, Lu Xince, He Yichun, et al., 2024. A Machine Vision-Based Method for Evaporator Tank Level Detection: CN202411357907.3 [P / OL]. 2024-12-27 [2025-07-22]. This invention proposes a machine vision-based method for evaporator tank level detection. This method is based on RGB images, calculates RGB values ​​pixel-by-pixel and converts them to the LAB color space, uses pixel percentage thresholds to determine the liquid level height, and combines multi-view data fusion to achieve non-contact measurement. However, this method only analyzes the static threshold of a single color space (LAB), fails to explore the spectral curve features of the combined RGB three channels, and relies on manually calibrated areas, making it difficult to adapt to dynamic liquid level changes or containers with complex materials. Ma Wandong, Shen Wenming, Zhang Wenguo, et al., 2021. Rapid detection method and device for water color: CN202110388519A[P / OL]. 2021-10-01[2025-07-23]. The effectiveness of RGB band standardization and colorimetric card spectral library matching was verified at the remote sensing scale, providing a methodological reference for spectral threshold setting. However, there are scale differences between its application in macroscopic water bodies and container-level measurements. Song Xudong, Shen Yuhua, Zhao Yuedong, et al., 2025. High-precision fully automatic titration system and method based on spectral sensor and PLC fusion: CN202510761479.9 [P / OL]. 2025-07-08 [2025-07-23]. This paper further combines a 14-channel spectral sensor (AS7341) with an LSTM time-series model, using the 350–1000nm full-band reflectance curve to dynamically calibrate the titration endpoint, introducing the concept of time-series monitoring in liquid level detection. This demonstrates the potential of "spectroscopy + AI" in improving measurement accuracy, but is limited by the cost of dedicated hardware and is geared towards titration endpoint detection rather than continuous liquid level change monitoring. Given the limitations of traditional algorithms in liquid image feature extraction and feature matching, convolutional neural networks (CNNs) in deep learning methods have received widespread attention due to their excellent feature extraction capabilities. Shen Jun, 2025. A liquid recognition method and system based on visual neural network: CN202510266057.4[P / OL]. 2025-06-27[2025-07-22]. A liquid recognition method based on visual neural network is proposed. Liquid image features are extracted by convolutional neural network and liquid type classification is achieved by combining semi-supervised learning. However, its goal is liquid classification rather than liquid level height recognition, and it does not involve spectral curve analysis.

[0005] In summary, existing research on liquid level measurement has not yet achieved an effective balance between measurement accuracy, hardware cost, and environmental adaptability. In the latest visual recognition methods, current research generally remains at the stage of single color spaces or dedicated sensors, and has not yet established a low-cost, highly universal liquid level recognition framework that integrates "video recording - image frame extraction - spectral curve extraction - automatic detection of spectral change points - liquid level height calculation - long-term automatic monitoring of liquid level changes." This is precisely the technological gap that this invention fills by combining spectral features with an intelligent interpretation model. Summary of the Invention

[0006] Current liquid level monitoring technologies have limitations. While traditional contact sensors offer fast response and high measurement accuracy, their direct contact with the measured medium easily leads to surface contamination and material corrosion, resulting in increased maintenance costs and decreased measurement reliability. Non-contact measurement devices based on photoelectric signals, relying on linear signal propagation paths and high-precision hardware, suffer from significantly increased measurement errors under complex conditions, and their high cost limits their large-scale application. This invention innovatively proposes a method, system, medium, and device for automatic liquid level height calculation based on spectral characteristics, aiming to construct a low-cost, minimally manual, non-contact solution for monitoring container liquid level changes. This method integrates optical spectral analysis with intelligent algorithms to achieve accurate perception and dynamic tracking of container liquid level changes. It provides a cost-effective, interference-resistant, and accurate container liquid level identification solution for fields such as soil and water conservation, industrial production, environmental protection, and water conservancy projects, laying a technological foundation for subsequent intelligent dynamic monitoring.

[0007] To achieve the above objectives, the present invention provides the following technical solution: an automatic liquid level height calculation method based on spectral features, which utilizes a camera with video recording capabilities to capture images of the liquid level in a transparent or semi-transparent container, thereby continuously recording the process of liquid level changes within the container. For the captured video, frames are automatically extracted at preset time intervals to obtain sample images for subsequent liquid level calculations. Using the central axis of the image as a reference, spectral values ​​of the red, green, and blue bands are extracted pixel by pixel to construct the corresponding spectral curve. The method includes the following steps:

[0008] An improved algorithm for detecting spectral curve change points based on the Bayesian online change point detection (BOCPD) framework is used to accurately capture the differences in spectral characteristics between the gas and liquid phases through spectral sequence modeling. A running length index and a dynamic update mechanism are introduced to achieve real-time monitoring of spectral changes. Through a multi-verification mechanism, real gas-liquid interface change points are screened out to filter out false change points.

[0009] The type is inferred based on the difference in mean values ​​before and after the change point and the change in running length. The clear abrupt change point or the midpoint of the gradual transition zone is taken as the interface. The actual liquid level height is calculated by formula by combining the pixel resolution and the bottom starting position.

[0010] By establishing the ratio between the number of pixels along the central axis of the image and the absolute height of the container, a conversion relationship between the number of pixels and the actual liquid level is established. Finally, based on the number of pixels at the feature points of the spectral curve (from the first change point b to point d), the average of the calculation results of the three bands is taken as the absolute height of the liquid level.

[0011] Based on images automatically extracted at preset time intervals, the absolute height of the liquid level at each moment is calculated. After the data is organized into a record table, a curve is plotted with time as the X-axis and the absolute height of the liquid level as the Y-axis.

[0012] Preferably, the improved algorithm for detecting spectral curve change points based on the Bayesian online change point detection (BOCPD) framework includes the following steps:

[0013] 1) Spectral sequence modeling: Collect the spectral sequence X=[x1, x2, ..., x] along the central axis of the container. n Gaussian models were constructed for the gas phase and liquid phase respectively, and the differences in spectral characteristics between the gas phase and liquid phase were captured by the mean μ and variance σ. The gas phase phase corresponds to the gas phase region from the top of the container to the gas phase and the transition point to the gas-liquid phase, and the liquid phase phase corresponds to the liquid phase region from the transition point to the liquid phase to the bottom of the container.

[0014] 2) Dynamic monitoring and optimization: Introducing the running length index r t That is, the number of consecutive observations at the distance of the t-th pixel from a point of change, and the online calculation of the spectrum x of each pixel. t The probability density P(x) t |r t x 1:t-1 It determines whether the current segment pattern is consistent; it dynamically updates the model parameters, namely the mean μ and variance σ, based on Bayes' theorem, and automatically generates the growth probability and the probability of change points. It does not require a preset number of change points and tracks the dynamic changes of the spectral sequence in real time, providing a probabilistic basis for determining whether changes have occurred for the identification of change points from the gas phase to the gas-liquid transition and from the gas-liquid transition to the liquid phase.

[0015] 3) Change point verification and screening: Potential gas-liquid interfaces are initially marked using a probability threshold, i.e., candidate change points from the gas phase to the gas-liquid transition and from the gas-liquid transition to the liquid phase. Assuming the probability threshold is ε, when the probability of the change point P(r) is... t =0|x 1:tWhen ε > 0, it is initially marked as a potential gas-liquid interface; through secondary verification under the dual conditions of continuous multi-window probability exceeding the standard and segment mean difference meeting the standard, false change points are filtered out, providing clear statistical significance basis for determining the change points from gas phase to gas-liquid transition and from gas-liquid transition to liquid phase, thereby improving the reliability of liquid level detection.

[0016] Preferably, the absolute height of the liquid level is calculated as follows:

[0017] H lR = ;

[0018] H lG = ;

[0019] H lB = ;

[0020] H l = ;

[0021] In the formula, H l H represents the absolute height of the liquid level. lR H lG H lB The absolute height of the liquid level is calculated for the red, green, and blue bands, respectively; point a is the top of the container; point b corresponds to the first change point in the spectral curve, which is the change point from the gas phase to the gas-liquid transition point, representing the characteristic point of the absolute height of the liquid surface; point c is the visual observation point of the liquid surface, corresponding to the second change point in the spectral curve, which is the change point from the gas-liquid transition to the liquid phase; point d cannot be directly observed through the image and is derived and calculated based on geometric relationships; point e is the bottom of the container.

[0022] X bdR、 X bdG、 X bdB The numbers represent the number of pixels from point b to point d on the spectral curve for the red, green, and blue bands, respectively (the distance from point b to point c is shifted to the bottom so that point c coincides with point e; the point aligned with point b at this point is point d, i.e., bc = de, i.e., bd = be - bc); H is the absolute height of the container; X... aeR、 X aeG、 X aeB This represents the number of pixels from the top to the bottom of the container.

[0023] This invention discloses an automatic liquid level height calculation system based on spectral characteristics, in which the system executes the method described above.

[0024] The present invention discloses an apparatus comprising a processor and a memory, wherein the memory stores at least one program, which is loaded and executed by the processor to implement the above-described method.

[0025] The present invention discloses a medium storing at least one program, which is loaded and executed by a processor to implement the above-described method.

[0026] This invention employs an improved algorithm for spectral curve change point detection based on the Bayesian online change point detection (BOCPD) framework. It accurately captures the spectral feature differences between the gas and liquid phases through spectral sequence modeling. It introduces a running length index and a dynamic update mechanism to achieve real-time monitoring of spectral changes. A multi-verification mechanism filters out false change points by identifying genuine gas-liquid interface change points. The type is inferred based on the difference in mean values ​​before and after the change point and the running length change, selecting clear abrupt changes or the midpoint of a gradual transition zone as the interface. Combining pixel resolution and bottom starting position, the actual liquid level height is calculated using a formula. A conversion relationship between pixel count and actual liquid level height is established by using the ratio of the number of pixels along the image's central axis to the absolute height of the container. Finally, based on the number of pixels at the feature points of the spectral curve, the average of the calculation results from three bands is taken as the absolute liquid level height. Compared with existing technologies, this invention adopts a non-contact measurement mode, analyzing the liquid level by extracting frames from video recordings. It eliminates the need for sensors to penetrate the container or contact the liquid, fundamentally avoiding contact-based methods. This invention addresses the issues of equipment susceptibility to contamination and corrosion during measurement, reducing maintenance costs and improving applicability under complex conditions such as high temperature, high pressure, and corrosiveness. It achieves liquid level detection by analyzing the combined RGB three-channel spectral curves of the gas and liquid phases in images, independent of the linear propagation of energy waves. Therefore, even in complex environments with high temperature and high pressure causing light refraction and sound wave scattering, it can still stably capture the gas-liquid interface characteristics, reducing measurement errors caused by environmental interference. Regarding the issues of "scale differences and high costs of dedicated hardware," this invention uses conventional image sensors (rather than dedicated spectral sensors) to achieve container-level measurement, avoiding the mismatch between remote sensing scale methods and container-level measurement while significantly reducing hardware costs. Addressing the issue of "only detecting the endpoint and not continuous monitoring," this invention achieves full-process coverage from "change point detection" to "continuous liquid level monitoring" through automatic frame extraction at preset time intervals, long-term liquid level change calculation, and curve plotting, overcoming the limitations of traditional methods that can only target static scenarios such as titration endpoints. Attached Figure Description

[0027] Figure 1 The technical flowchart provided for this invention;

[0028] Figure 2 A pixel location map corresponding to the spectral curve change points provided by the present invention;

[0029] Figure 3 Provided by the present invention Figure 2 The container image in the image;

[0030] Figure 4 The spectral curve provided for this invention;

[0031] Figure 5 The liquid level change curve with a 5-second monitoring interval is provided for this invention. Detailed Implementation

[0032] The following specific embodiments illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0033] like Figure 1 As shown, this invention provides an automatic liquid level height calculation method based on spectral features. It utilizes a camera with video recording capabilities to capture images of the liquid level in a transparent or semi-transparent container, continuously recording the liquid level changes within the container. For the captured video, frames are automatically extracted at preset time intervals to obtain sample images for subsequent liquid level calculations. Using the image's central axis as a reference, spectral values ​​in the red, green, and blue bands are extracted pixel by pixel to construct the corresponding spectral curve. The method includes the following steps:

[0034] An improved algorithm for detecting spectral curve change points based on the Bayesian online change point detection (BOCPD) framework is used to accurately capture the differences in spectral characteristics between the gas and liquid phases through spectral sequence modeling. A running length index and a dynamic update mechanism are introduced to achieve real-time monitoring of spectral changes. Through a multi-verification mechanism, real gas-liquid interface change points are screened out to filter out false change points.

[0035] An improved algorithm for detecting spectral curve change points based on the Bayesian online change point detection (BOCPD) framework includes the following steps:

[0036] 1) Spectral sequence modeling: Collect the spectral sequence X=[x1, x2, ..., x] along the central axis of the container. n Gaussian models were constructed for the gas phase and liquid phase respectively, and the differences in spectral characteristics between the gas phase and liquid phase were captured by the mean μ and variance σ. The gas phase phase corresponds to the gas phase region from the top of the container to the gas phase and the transition point to the gas-liquid phase, and the liquid phase phase corresponds to the liquid phase region from the transition point to the liquid phase to the bottom of the container.

[0037] 2) Dynamic monitoring and optimization: Introducing the running length index r tThat is, the number of consecutive observations at the distance of the t-th pixel from a point of change, and the online calculation of the spectrum x of each pixel. t The probability density P(x) t |r t x 1:t-1 It determines whether the current segment pattern is consistent; it dynamically updates the model parameters, namely the mean μ and variance σ, based on Bayes' theorem, and automatically generates the growth probability and the probability of change points. It does not require a preset number of change points and tracks the dynamic changes of the spectral sequence in real time, providing a probabilistic basis for determining whether changes have occurred for the identification of change points from the gas phase to the gas-liquid transition and from the gas-liquid transition to the liquid phase.

[0038] 3) Change point verification and screening: Potential gas-liquid interfaces are initially marked using a probability threshold, i.e., candidate change points from the gas phase to the gas-liquid transition and from the gas-liquid transition to the liquid phase. Assuming the probability threshold is ε, when the probability of the change point P(r) is... t =0|x 1:t When ε > 0, it is initially marked as a potential gas-liquid interface; through secondary verification under the dual conditions of continuous multi-window probability exceeding the standard and segment mean difference meeting the standard, false change points are filtered out, and clear statistical significance is given to the change points from gas phase to gas-liquid transition and the change points from gas-liquid transition to liquid phase, thereby improving the reliability of liquid level detection.

[0039] The type is inferred based on the difference in mean values ​​before and after the change point and the change in running length. The clear abrupt change point or the midpoint of the gradual transition zone is taken as the interface. The actual liquid level height is calculated by formula by combining the pixel resolution and the bottom starting position.

[0040] By establishing the ratio between the number of pixels along the central axis of the image and the absolute height of the container, a conversion relationship between the number of pixels and the actual liquid level is established. Finally, based on the number of pixels at the feature points of the spectral curve (from the first change point b to point d), the average of the calculation results of the three bands is taken as the absolute height of the liquid level.

[0041] Preferably, the absolute height of the liquid level is calculated as follows:

[0042] H lR = ;

[0043] H lG = ;

[0044] H lB = ;

[0045] H l = ;

[0046] In the formula, H l H represents the absolute height of the liquid level. lR HlG H lB The absolute liquid level heights are calculated for the red, green, and blue bands, respectively; point a is the top of the container; point b corresponds to the first change point in the spectral curve, i.e., the change point from the gas phase to the gas-liquid transition, representing a characteristic point of the absolute liquid level height; point c is the visual observation point of the liquid level, corresponding to the second change point in the spectral curve, i.e., the change point from the gas-liquid transition to the liquid phase; point d is the actual bottom of the container, which cannot be directly observed through images and is calculated based on geometric relationships; point e is the bottom of the container.

[0047] This invention uses cluster analysis to detect inflection points where adjacent data point labels change, namely the first change point (point b) and the second change point (point c). These inflection points correspond to pixel positions where the spectral curve shows a significant jump. Figure 2 In step five, based on the pixel positions of these two change points, the number of pixels (XbdR / G / B) from the first change point (point b) to point d in the red, green, and blue bands is calculated (this distance is shifted to the bottom so that point c coincides with point e; the point aligned with the first change point b is point d, where the determination of point d depends on the distance relationship between point b and point c: bc=de). Finally, combining the absolute height of the container (H) and the number of pixels from the top to the bottom of the container (XaeR / G / B), the absolute height of the liquid level in each band is calculated, and the average value is taken as the final result.

[0048] X bdR、 X bdG、 X bdB These represent the number of pixels from point b to point d on the spectral curve for the red, green, and blue bands, respectively; this distance is the distance from point b to point c. Shifting this distance to the bottom, so that point c coincides with point e, the point aligned with the first change point b is point d, i.e., bc = de; H is the absolute height of the container; X aeR、 X aeG、 X aeB This represents the number of pixels from the top to the bottom of the container.

[0049] Based on images automatically extracted at preset time intervals, the absolute height of the liquid level at each moment is calculated. After the data is organized into a record table, a curve is plotted with time as the X-axis and the absolute height of the liquid level as the Y-axis.

[0050] To achieve the goal of automated liquid level calculation, this invention completes the core process through a self-designed program.

[0051] Algorithm: Spectral liquid level height calculation based on Bayesian online change point detection (BOCPD)

[0052] Input:

[0053] X = [x1, x2, ..., x n / / Spectral sequence collected along the central axis of the container

[0054] ε / / Threshold for the probability of the point of change (e.g., 0.95)

[0055] Output:

[0056] ChangePoints[] / / List of detected gas-liquid interface locations

[0057] Begin:

[0058] / / Step 1: Initialize model parameters

[0059] μ_gas, σ_gas ← Initialize() / / Gaussian parameters for the gas phase segment

[0060] μ_liq, σ_liq ← Initialize() / / Gaussian parameters for the liquid phase segment

[0061] r0 ← 0 / / Initial runtime

[0062] ChangePoints ← []

[0063] / / Step 2: Online dynamic monitoring

[0064] for t ← 1 to n do:

[0065] / / Calculate the probability density of the current running length

[0066] P(x t | r t x1: t ₋1) ← Calculate_Likelihood(x t (μ_current, σ_current)

[0067] / / Bayesian update of runtime distribution (core BOCPD operation)

[0068] P(r t | x1: t ) ∝ P(x t | r t x1: t ₋1) × P(r t | r t ₋1) × P(r t ₋1 | x1: t ₋1)

[0069] / / Dynamically update the Gaussian parameters (μ, σ) of the current segment.

[0070] if r t > 0: / / Continue the current segment

[0071] Update_Gaussian_Parameters(μ_current, σ_current, x t )

[0072] else: / / Potential change points detected

[0073] Reset_Gaussian_Parameters() / / Reset to the initial parameters of the new fragment

[0074] / / Step 3: Probability Verification of Change Points

[0075] if P(r t = 0 | x1: t ) > ε:

[0076] CandidatePoints.add(t) / / Record candidate change points

[0077] / / Step 4: Secondary Validation and Filtering

[0078] for each candidate in CandidatePoints:

[0079] / / Condition 1: The probability of consecutive W windows exceeds the limit (e.g., W=3)

[0080] isWindowValid ← Check_Consecutive_Windows(candidate, W, ε)

[0081] / / Condition 2: The mean difference between adjacent segments meets the standard (e.g., |μ p ᵣ e ᵥ - μ next | > δ)

[0082] isMeanDiffValid ← Check_Mean_Difference(candidate, δ)

[0083] if isWindowValid AND isMeanDiffValid:

[0084] ChangePoints.append(candidate) / / Confirms that the change point is real.

[0085] return ChangePoints

[0086] End

[0087] Taking a sample image extracted from a video as an example, this image corresponds to turbid liquid inside an 8cm high acrylic container. Figure 3 It includes three bands: red, green, and blue, and the shooting range is exactly tangent to the top and bottom of the container.

[0088] Step 1: Extract key frames from the video recordings obtained by the camera, which will serve as the basis for the automated liquid level calculation.

[0089] Step 2: Using a self-designed program, read the spectral values ​​of the red, green, and blue bands corresponding to each pixel along the central axis of the image, and plot the spectral curve. Figure 4 (The image contains 1543 pixels along its central axis, where the X-axis represents the sequence of pixels and the Y-axis represents the spectral values.)

[0090] Step 3: An improved algorithm for detecting spectral curve change points based on the Bayesian Online Change Point Detection (BOCPD) framework is used to automatically identify the first and second change points of the spectral curve using a self-designed program.

[0091] Step 4: Establish a conversion model between the number of pixels along the central axis of the image and the absolute height of the container. Calculate the absolute liquid level height based on the number of pixels at the feature points of the spectral curve (from the first change point to point d), and take the average of the calculation results for the red, green, and blue bands as the final absolute liquid level height. The calculated absolute liquid level height in this image is 4.05 cm, while the visually read absolute liquid level height is 4.01 cm, with an error of only 0.4 mm.

[0092] band R G B mean ae pixel count 1543 1543 1543 1543 ab pixel count 652 654 651 652.33 bc pixels 192 191 188 190.33 de pixels 192 191 188 190.33 ce pixel count 685 686 683 684.67 bd pixel count 685 686 683 684.67 CD pixel count 493 495 495 494.33 ad pixels 1337 1340 1334 1337 absolute height of container 8cm 8cm 8cm 8cm absolute height of liquid level 4.06cm 4.06cm 4.03cm 4.05cm

[0093] Note: The pixel number relationships in the table are ae=ab+bc+ce; ce=cd+de; bc=de; ce=bd; cd=ce-bc; bd=cd+bc; ad=ae-de.

[0094] Step 5: Based on the images automatically extracted at preset time intervals, calculate the absolute height of the liquid level at each moment. After organizing the data into a record table, plot a curve with time as the X-axis and the absolute height of the liquid level as the Y-axis. In this case, the video recording duration is 5 minutes. During the experiment, liquid was slowly added along both walls of the container, and the liquid level rose steadily without fluctuation. The frame extraction interval was set to 5 seconds per frame. The final liquid level change curve for the 5-second monitoring interval is shown below. Figure 5 As shown.

[0095] Although the present invention has been described in detail above with general descriptions and specific embodiments, modifications or improvements can be made to it, which will be obvious to those skilled in the art. Therefore, all such modifications or improvements made without departing from the spirit of the present invention fall within the scope of protection claimed by the present invention.

Claims

1. An automatic liquid level height calculation method based on spectral features, which utilizes a camera with video recording function to capture images of the liquid level in a transparent or semi-transparent container, continuously recording the process of liquid level changes within the container. For the captured video, frames are automatically extracted at preset time intervals to obtain sample images for subsequent liquid level calculations. Using the central axis of the image as a reference, spectral values ​​in the red, green, and blue bands are extracted pixel by pixel to construct the corresponding spectral curve. The method is characterized by: Includes the following steps: An improved algorithm for detecting spectral curve change points based on the Bayesian online change point detection (BOCPD) framework is used to accurately capture the differences in spectral characteristics between the gas and liquid phases through spectral sequence modeling. A running length index and a dynamic update mechanism are introduced to achieve real-time monitoring of spectral changes. Through a multi-verification mechanism, real gas-liquid interface change points are screened out to filter out false change points. The type is inferred based on the difference in mean values ​​before and after the change point and the change in running length. The clear abrupt change point or the midpoint of the gradual transition zone is taken as the interface. The actual liquid level height is calculated by formula by combining the pixel resolution and the bottom starting position. By establishing the ratio between the number of pixels along the central axis of the image and the absolute height of the container, a conversion relationship between the number of pixels and the actual liquid level is established. Finally, based on the number of pixels at the feature points of the spectral curve, the average of the calculation results of the three bands is taken as the absolute height of the liquid level. The improved algorithm for detecting spectral curve change points based on the Bayesian online change point detection (BOCPD) framework includes the following steps: 1) Spectral sequence modeling: Collect the spectral sequence X=[x1, x2, ..., x] along the central axis of the container. n Gaussian models were constructed for the gas phase and liquid phase respectively, and the differences in spectral characteristics between the gas phase and liquid phase were captured by the mean μ and variance σ. The gas phase section corresponds to the gas phase region from the top of the container to the point of transition from the gas phase to the liquid phase, and the liquid phase section corresponds to the liquid phase region from the point of transition from the gas phase to the liquid phase to the point of transition from the gas phase to the liquid phase to the bottom of the container. 2) Dynamic monitoring and optimization: Introducing the running length index r t That is, the number of consecutive observations at the distance of the t-th pixel from a point of change, and the online calculation of the spectrum x of each pixel. t The probability density P(x) t |r t x 1:t-1 It determines whether the current segment pattern is consistent; it dynamically updates the model parameters, namely the mean μ and variance σ, based on Bayes' theorem, and automatically generates the growth probability and the probability of change points. It does not require a preset number of change points and tracks the dynamic changes of the spectral sequence in real time, providing a probabilistic basis for determining whether changes have occurred for the identification of change points from the gas phase to the gas-liquid transition and from the gas-liquid transition to the liquid phase. 3) Change point verification and screening: Potential gas-liquid interfaces are initially marked using a probability threshold, i.e., candidate change points from the gas phase to the gas-liquid transition and from the gas-liquid transition to the liquid phase. Assuming the probability threshold is ε, when the probability of the change point P(r) is... t =0|x 1:t When ε > 0, it is initially marked as a potential gas-liquid interface; through secondary verification under the dual conditions of continuous multi-window probability exceeding the standard and segment mean difference meeting the standard, false change points are filtered out, and clear statistical significance is given to the change points from gas phase to gas-liquid transition and the change points from gas-liquid transition to liquid phase, thereby improving the reliability of liquid level detection.

2. The automatic liquid level height calculation method based on spectral characteristics according to claim 1, characterized in that: The absolute height of the liquid level is calculated as follows: H lR = ; H lG = ; H lB = ; H l = ; In the formula, H l H represents the absolute height of the liquid level. lR H lG H lB The absolute liquid level heights are calculated for the red, green, and blue bands, respectively; point a is the top of the container; point b corresponds to the first change point in the spectral curve, i.e., the change point from the gas phase to the gas-liquid transition, representing the characteristic point of the absolute liquid level height; point c is the visual observation point of the liquid level, corresponding to the second change point in the spectral curve, i.e., the change point from the gas-liquid transition to the liquid phase; point d is the actual bottom of the container, which cannot be directly observed through images and is calculated based on geometric relationships; point e is the bottom of the container. X bdR、 X bdG、 X bdB These represent the number of pixels from point b to point d on the spectral curve for the red, green, and blue bands, respectively; this distance is the distance from point b to point c. Shifting this distance to the bottom, so that point c coincides with point e, the point aligned with the first change point b is point d, i.e., bc = de; H is the absolute height of the container; X aeR、 X aeG、 X aeB This represents the number of pixels from the top to the bottom of the container.

3. An automatic liquid level height calculation system based on spectral characteristics, characterized in that: The system performs the method as described in any one of claims 1-2.

4. A device, characterized in that: The device includes a processor and a memory, the memory storing at least one program, which is loaded and executed by the processor to implement the method as described in any one of claims 1-2.

5. A medium, characterized in that: The medium stores at least one program segment, which is loaded and executed by a processor to implement the method as described in any one of claims 1-2.