Industrial liquid level meter intelligent reading method based on deep learning
By using the YOLOv8 model and image preprocessing technology, combined with tilt correction and historical data analysis, automated reading of industrial level gauges was achieved, solving the problems of inaccurate reading and insufficient robustness in traditional methods, and improving reading efficiency and system applicability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-04-03
AI Technical Summary
Existing methods for reading industrial level gauges are susceptible to the influence of ambient light, viewing angle, and subjective experience. Furthermore, traditional visual inspection lacks robustness in complex scenarios, making it difficult to achieve accurate and stable monitoring.
The YOLOv8 model is used in conjunction with image preprocessing (grayscale conversion, illumination normalization, CLAHE enhancement) and tilt correction (edge detection + Hough transform). The model is trained through transfer learning to achieve automatic detection and positioning of the level gauge body and the float on the liquid surface, and to generate anomaly alarms by combining historical data analysis.
It improves the accuracy and stability of level gauge readings, reduces subjective errors from manual readings, and enhances the system's applicability and safety in complex industrial environments.
Smart Images

Figure CN121789192A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial automation detection technology, specifically to a deep learning-based intelligent reading method for industrial level gauges. Background Technology
[0002] Industrial level gauges are indispensable key instruments in process industries, and the accuracy of their readings directly impacts production safety, process control, and operational efficiency. Currently, the most common reading methods in industrial settings are still manual visual judgment or contact sensors. These methods have significant limitations: manual readings are easily affected by ambient light, observation angle, and subjective experience, making it difficult to achieve continuous and accurate monitoring; contact sensors face harsh conditions such as media corrosion, high temperature, and high pressure, and their long-term stability is difficult to guarantee.
[0003] Current visual inspection methods based on traditional image processing have been introduced to some extent to assist in reading, but they generally lack robustness when dealing with complex scenarios such as liquid surface reflection, instrument tilt, or partial obstruction, which limits their widespread application in actual industrial environments.
[0004] With the rapid development of deep learning technology in the field of object detection, advanced algorithms such as YOLO and Faster R-CNN have provided new possibilities for automatic liquid level recognition. However, directly applying these technologies to industrial liquid level gauge readings still faces many unique challenges: on the one hand, liquid level gauges are usually installed in complex equipment areas surrounded by interfering objects such as pipes and valves, making the object detection model susceptible to background interference and misjudgment; on the other hand, dynamic factors such as changes in lighting and water vapor obstruction in industrial environments can significantly affect image quality, thereby interfering with model performance. In addition, liquid level gauges may be tilted or have incomplete displays during actual installation, making it difficult for traditional vision methods to accurately reproduce the true liquid level height under such circumstances, further increasing the design difficulty of intelligent reading systems. Summary of the Invention
[0005] The purpose of this invention is to provide a deep learning-based intelligent reading method for industrial liquid level gauges to solve the problems raised in the prior art.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a deep learning-based intelligent reading method for industrial liquid level gauges; The method includes the following steps: Step S1: Take images of the liquid level gauge with a camera, manually mark the bounding boxes of the liquid level gauge body and the liquid surface float to form a labeled dataset, which provides input information for subsequent model training; The specific operation of step S1 to form the labeled dataset is as follows: use a camera to acquire an image of the liquid level gauge every set time interval ∆t to ensure that the main body of the liquid level gauge and the float on the liquid surface are clearly visible; use rectangular bounding boxes to manually label the liquid level gauge and the float on the liquid surface in the image to form a labeled dataset, wherein the float on the liquid surface is a visible label floating on the liquid surface; the labeled dataset includes image files and corresponding labeled files, wherein the labeled files record the category and bounding box coordinates of each target object.
[0007] Step S2: Preprocess the labeled dataset to enhance image quality, reduce interference from factors such as lighting and contrast, and improve the model's adaptability to complex industrial environments. The preprocessing of the labeled dataset in step S2 specifically involves: converting the labeled dataset to grayscale to obtain a grayscale image dataset; applying an illumination normalization algorithm to the grayscale image dataset to eliminate uneven illumination and obtain an illumination normalized image dataset; and applying a contrast-limited adaptive histogram equalization algorithm to the illumination normalized image dataset to enhance image contrast, thereby obtaining an input image dataset and improving the model's ability to recognize illumination changes and low-contrast scenes. The cropping limiting coefficient is set to 2.0, and the grid size is 8×8.
[0008] Step S3: Using the YOLOv8 model, input the labeled dataset, train it through transfer learning to obtain the optimal model weights, and use the pre-trained model and transfer learning to accelerate the training process and improve the model's generalization ability. The specific steps in step S3 using the YOLOv8 model are as follows: The input image dataset is divided into a training set and a validation set according to a preset ratio; YOLOv8 pre-trained weights are loaded, and the model is trained through transfer learning; training is terminated when the validation set loss no longer decreases for x consecutive periods to prevent overfitting and ensure the model has optimal generalization performance; the optimal model weights on the validation set are saved to provide a benchmark for subsequent height comparisons, where x is set by professionals, and the optimal model weights refer to the model parameters that achieve the highest mAP on the validation set; during training, the average height H of the level gauges in the training set is calculated. average .
[0009] Step S4: Use the trained YOLOv8 model to detect the level gauge and the float, realize automated target detection, quickly locate the position of the level gauge and the float, and obtain the coordinates; The specific method for obtaining coordinates in step S4 is as follows: input the input image dataset into the YOLOv8 model trained in step S3 to obtain the bounding box coordinates (X, Y, X) of the level gauge body. bar1 ,Y bar1 ,X bar2 ,Y bar2 ) and the bounding box coordinates (X) of the liquid surface floatpiece1 ,Y piece1 ,X piece2 ,Y piece2 ), the (X) bar1 ,Y bar1 () represents the pixel coordinates of the upper left corner of the level gauge's main body bounding box, where (X) bar2 ,Y bar2 () represents the bottom right pixel coordinates, where (X) piece1 ,Y piece1 ) represents the pixel coordinates of the top left corner of the liquid surface float bounding box, where (X) piece2 ,Y piece2 () indicates the pixel coordinates of the lower right corner of the liquid surface float's bounding box.
[0010] Step S5: Calculate the pixel height of the level gauge and the ordinate of the center point of the float on the liquid surface. Convert the image coordinates into the actual liquid level ratio to obtain the relative liquid level ratio, providing standardized input for subsequent liquid level calculations. The level gauge pixel height H in step S5 bar =Y bar2 -Y bar1 The ordinate of the center point of the liquid surface float is Y. piece Y represents the distance from the bottom of the float to the bottom of the level gauge. piece =(Y piece1 +Y piece2 ) / 2; The relative liquid level ratio R represents the relative position of the liquid in the total height of the liquid level gauge: R = (Y) / 2; bar2 -Y piece ) / H bar In the formula, the relative liquid level ratio R is between 0 and 1, where 0 represents the lowest liquid level and 1 represents the highest liquid level. The standardized calculation formula converts the pixel coordinates into an intuitive liquid level ratio, which is convenient for subsequent actual height conversion and system monitoring.
[0011] Step S6: When the detected level gauge height is less than k times the average height, it is determined to be an incomplete display situation, and edge detection and Hough transform are performed to compensate for the missing information; The specific process for edge detection and Hough transform correction in step S6 is as follows: when H bar <d×H average When d∈[0,1], it is set by professionals. The current input image is determined to be incomplete. The binary image of the liquid level gauge edge features is extracted by the Canny edge detection algorithm. The Hough transform is used on the binary image to filter and output the set of straight line segments belonging to the side of the liquid level gauge. The liquid level gauge edge features refer to the outline of the liquid level gauge in the image.
[0012] Step S7: Fit a straight line through edge detection, calculate the tilt angle, correct the liquid surface position, compensate for the relative liquid level ratio, correct the image tilt caused by the shooting angle, ensure accurate liquid level calculation, and reduce viewing angle error; In step S7, fitting the straight line through edge detection specifically involves: extracting all pixels from the set of straight line segments to form a set of side pixels; fitting the set of side pixels using the least squares method to obtain the straight line equation y=kx+b; calculating the tilt angle θ=arctan(k) of the straight line equation; and using the tilt angle relative to the ordinate Y of the center of the float on the liquid surface. piece Calibration is performed to ensure that the liquid level reading remains highly accurate under different shooting angles, resulting in the corrected ordinate Y. corrected =Y piece / cosθ; Recalculate the relative liquid level ratio R′=R×(H average / H bar In the linear equation y=kx+b, the fitting difference satisfies... ≤8 pixels, that is, each edge point (x i ,y i The vertical distance from the fitted line y=kx+b is ≤8 pixels.
[0013] Step S8: Set constraint rules for the width of the liquid surface float and the vertical coordinate of the center of the liquid surface float. When the constraint rules are broken, smooth the relative liquid level ratio to improve the stability and reliability of the output data. The constraint rules in step S8 specifically include the following: Liquid surface float width W piece No more than the width W of the level gauge bar The width W of the liquid surface float is y times that of the float. piece =X piece2 -X piece1 The width W of the level gauge bar =X bar2 -X bar1 ; The ordinate of the center of the liquid surface float is Y piece Satisfy Y bar1 ≤Y piece ≤Y bar2 The y is a determination factor, which is set by professionals; When the width of the liquid surface float exceeds y times the width of the liquid level gauge, the vertical coordinate of the center of the liquid surface float is Y. piece No Satisfy Y bar1 ≤Y piece ≤Y bar2 The current relative liquid level ratio R detected Perform smoothing: R current =a1×R detected+a2×R history ; In the formula, R current This represents the output after smoothing, and the final adopted effective relative level ratio reading, R. detected R represents the current relative liquid level ratio reading. history This represents the average of the relative liquid level ratio readings that have satisfied the aforementioned constraint rules in the most recent n times. a1 and a2 are weighting coefficients, which are set by professionals.
[0014] Step S9: Maintain the historical relative liquid level ratio queue, calculate the mean and standard deviation, output the final liquid level position when the relative liquid level ratio reading is normal, and trigger an alarm when the current reading is abnormal, so as to realize dynamic monitoring and abnormal early warning.
[0015] Step S9 includes the following steps: Step S9-1: Maintain a relative liquid level ratio queue of size N, Q=[R1,R2,...,R N The system stores the relative liquid level ratios that have most recently satisfied the constraint rules (N times) to establish a historical data benchmark, providing a statistical basis for anomaly detection. Here, N is a preset positive integer. The system also calculates the mean μ of the queue. q With standard deviation σ q ; Step S9-2: In the current calculation cycle, obtain the relative liquid level ratio and the final effective reading R after smoothing when the constraint rules are satisfied. t When |R t -μ q |>b1σ q or |R t -R t−1 When |> b2, an abnormal alarm is triggered, and manual intervention is required to confirm the value. Here, b1 is the judgment multiple and b2 is the judgment threshold, which are set by professionals. Step S9-3: When |R is satisfied t -μ q |≤b1σ q And |R t -R t−1 When |≤b2, output the current actual height H of the liquid surface. liquid =R t ×H physical This enables seamless conversion from images to physical quantities. In the formula, H... liquid H represents the actual height of the liquid level. physical This indicates the actual physical height of the liquid level gauge.
[0016] Compared with the prior art, the beneficial effects of the present invention are: 1. The YOLOv8 model is used to realize the automatic detection and positioning of the liquid level gauge body and the liquid surface float, which avoids the subjective error and labor intensity of traditional manual reading and improves the reading efficiency and consistency.
[0017] 2. Image preprocessing (grayscale conversion, illumination normalization, CLAHE enhancement) and tilt correction mechanism (edge detection + Hough transform) are adopted to deal with complex scenarios such as uneven illumination, tilted level gauge, and partial occlusion, thereby improving the applicability of the system in real industrial environments.
[0018] 3. The relative liquid level ratio is calculated by the ratio of the vertical coordinate of the center of the liquid level float to the height of the liquid level gauge. Combined with tilt correction and smoothing strategies, the accuracy and stability of liquid level measurement are improved.
[0019] 4. Based on the analysis of the mean and standard deviation of historical data, combined with threshold judgment, abnormal readings are identified in real time and alarms are triggered to ensure the safety and reliability of system operation and facilitate timely manual intervention. Attached Figure Description
[0020] Figure 1 This is a schematic diagram illustrating the steps of applying the present invention to an intelligent reading method for industrial liquid level gauges based on deep learning; Figure 2 This is a schematic diagram of the structure of an intelligent reading method for industrial liquid level gauges based on deep learning, according to the present invention. Detailed Implementation
[0021] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. 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.
[0022] Example: Figures 1-2 As shown, this invention provides a technical solution: a deep learning-based intelligent reading method for industrial liquid level gauges. A chemical plant's tank area is equipped with multiple transparent glass tube liquid level gauges for monitoring liquid level. Traditional manual reading is inefficient and prone to errors. This invention deploys a deep learning-based intelligent reading method for industrial liquid level gauges, which includes the following steps: Step S1: Take images of the liquid level gauge with a camera, manually mark the bounding boxes of the liquid level gauge body and the liquid surface float to form a labeled dataset, which provides input information for subsequent model training; The specific operation of step S1 to form the labeled dataset is as follows: use a camera to acquire an image of the liquid level gauge every set time interval ∆t to ensure that the main body of the liquid level gauge and the float on the liquid surface are clearly visible; use rectangular bounding boxes to manually label the liquid level gauge and the float on the liquid surface in the image to form a labeled dataset, wherein the float on the liquid surface is a visible label floating on the liquid surface; the labeled dataset includes image files and corresponding labeled files, wherein the labeled files record the category and bounding box coordinates of each target object.
[0023] Example 1: Data acquisition equipment: A fixed-mount industrial camera (1920×1080 resolution) is used to acquire an image of the level gauge every Δt=5 seconds.
[0024] Annotation content: The bounding boxes of the level gauge and the surface float (red buoy) in each image were manually annotated to form an annotated dataset. A total of 1000 images were collected, and the annotation files are in YOLO format, containing category labels for the level gauge and the surface float, as well as normalized bounding box coordinates.
[0025] Step S2: Preprocess the labeled dataset to enhance image quality, reduce interference from factors such as lighting and contrast, and improve the model's adaptability to complex industrial environments. The preprocessing of the labeled dataset in step S2 specifically involves: converting the labeled dataset to grayscale to obtain a grayscale image dataset; applying an illumination normalization algorithm to the grayscale image dataset to eliminate uneven illumination and obtain an illumination normalized image dataset; and applying a contrast-limited adaptive histogram equalization algorithm to the illumination normalized image dataset to enhance image contrast, thereby obtaining an input image dataset and improving the model's ability to recognize illumination changes and low-contrast scenes. The cropping limiting coefficient is set to 2.0, and the grid size is 8×8.
[0026] Example 2: Grayscale conversion: Converting an RGB image to a grayscale image.
[0027] Illumination normalization: Gamma correction (γ=1.2) is used to eliminate uneven illumination.
[0028] Contrast enhancement: The CLAHE algorithm (cropping factor = 2.0, grid size = 8×8) is applied to enhance image details.
[0029] Step S3: Using the YOLOv8 model, input the labeled dataset, train it through transfer learning to obtain the optimal model weights, and use the pre-trained model and transfer learning to accelerate the training process and improve the model's generalization ability. The specific steps in step S3 using the YOLOv8 model are as follows: The input image dataset is divided into a training set and a validation set according to a preset ratio; YOLOv8 pre-trained weights are loaded, and the model is trained through transfer learning; training is terminated when the validation set loss no longer decreases for x consecutive periods to prevent overfitting and ensure the model has optimal generalization performance; the optimal model weights on the validation set are saved to provide a benchmark for subsequent height comparisons, where x is set by professionals, and the optimal model weights refer to the model parameters that achieve the highest mAP on the validation set; during training, the average height H of the level gauges in the training set is calculated. average .
[0030] Example 3: Dataset split: The 1000 images were split into a training set (800 images) and a validation set (200 images) in an 8:2 ratio.
[0031] Model configuration: YOLOv8s pre-trained weights, input image size 640×640, batch size = 16, learning rate = 0.01.
[0032] Training process: Train for 100 epochs, then terminate early when the validation set loss no longer decreases for x=10 consecutive epochs. Save the optimal model weights (validation set mAP=0.92). Calculate the average height: During training, the pixel height of the level gauge is statistically analyzed, and the average height H is set. average =450 pixels.
[0033] Step S4: Use the trained YOLOv8 model to detect the level gauge and the float, realize automated target detection, quickly locate the position of the level gauge and the float, and obtain the coordinates; The specific method for obtaining coordinates in step S4 is as follows: input the input image dataset into the YOLOv8 model trained in step S3 to obtain the bounding box coordinates (X, Y, X) of the level gauge body. bar1 ,Y bar1 ,X bar2 ,Y bar2 ) and the bounding box coordinates (X) of the liquid surface float piece1 ,Y piece1 ,X piece2 ,Y piece2 ), the (X) bar1 ,Y bar1 () represents the pixel coordinates of the upper left corner of the level gauge's main body bounding box, where (X) bar2 ,Y bar2 () represents the bottom right pixel coordinates, where (X) piece1 ,Y piece1 ) represents the pixel coordinates of the top left corner of the liquid surface float bounding box, where (X) piece2 ,Y piece2() indicates the pixel coordinates of the lower right corner of the liquid surface float's bounding box.
[0034] Example 4: Inference input: Input the preprocessed image into the trained YOLOv8 model.
[0035] Output coordinates: Level gauge body boundary frame: (X bar1 =100,Y bar1 =50, Xbar2 =180,Y bar2 =500); Liquid surface float bounding box: (X piece1 =120,Y piece1 =300,X piece2 =160,Y piece2 =320).
[0036] Step S5: Calculate the pixel height of the level gauge and the ordinate of the center point of the float on the liquid surface. Convert the image coordinates into the actual liquid level ratio to obtain the relative liquid level ratio, providing standardized input for subsequent liquid level calculations. The level gauge pixel height H in step S5 bar =Y bar2 -Y bar1 The ordinate of the center point of the liquid surface float is Y. piece Y represents the distance from the bottom of the float to the bottom of the level gauge. piece =(Y piece1 +Y piece2 ) / 2; The relative liquid level ratio R represents the relative position of the liquid in the total height of the liquid level gauge: R = (Y) / 2; bar2 -Y piece ) / H bar In the formula, the relative liquid level ratio R is between 0 and 1, where 0 represents the lowest liquid level and 1 represents the highest liquid level. The standardized calculation formula converts the pixel coordinates into an intuitive liquid level ratio, which is convenient for subsequent actual height conversion and system monitoring.
[0037] Example 5: Level gauge pixel height H bar =Y bar2 -Y bar1 =500−50=450 pixels.
[0038] The ordinate of the center of the liquid surface float is Y. piece =(Y piece1 +Y piece2 ) / 2=(300+320) / 2=310 pixels.
[0039] Relative liquid level ratio R = (Y bar2 -Y piece ) / Hbar =0.422.
[0040] Step S6: When the detected level gauge height is less than k times the average height, it is determined to be an incomplete display situation, and edge detection and Hough transform are performed to compensate for the missing information; The specific process for edge detection and Hough transform correction in step S6 is as follows: when H bar <d×H average When d∈[0,1], it is set by professionals. The current input image is determined to be incomplete. The binary image of the liquid level gauge edge features is extracted by the Canny edge detection algorithm. The Hough transform is used on the binary image to filter and output the set of straight line segments belonging to the side of the liquid level gauge. The liquid level gauge edge features refer to the outline of the liquid level gauge in the image.
[0041] Step S7: Fit a straight line through edge detection, calculate the tilt angle, correct the liquid surface position, compensate for the relative liquid level ratio, correct the image tilt caused by the shooting angle, ensure accurate liquid level calculation, and reduce viewing angle error; In step S7, fitting the straight line through edge detection specifically involves: extracting all pixels from the set of straight line segments to form a set of side pixels; fitting the set of side pixels using the least squares method to obtain the straight line equation y=kx+b; calculating the tilt angle θ=arctan(k) of the straight line equation; and using the tilt angle relative to the ordinate Y of the center of the float on the liquid surface. piece Calibration is performed to ensure that the liquid level reading remains highly accurate under different shooting angles, resulting in the corrected ordinate Y. corrected =Y piece / cosθ; Recalculate the relative liquid level ratio R′=R×(H average / H bar In the linear equation y=kx+b, the fitting difference satisfies... ≤8 pixels, that is, each edge point (x i ,y i The vertical distance from the fitted line y=kx+b is ≤8 pixels.
[0042] Example 6: Conditional judgment: Set d=0.8, when H bar When the value is less than 0.8 × 450 = 360, it is considered incomplete display. In this example, H... bar =450, no correction required.
[0043] Assuming incomplete display case: If H in a certain image bar =300, trigger edge detection, use Canny algorithm to extract edges, Hough transform to detect straight lines, fit the straight line on the side of the level gauge, set the tilt angle θ=5° to correct the float's ordinate: Y corrected=Y piece / cos(5°)≈311.2, compensated relative liquid level ratio: R′=R×(450 / 300)=0.422×1.5=0.633.
[0044] Step S8: Set constraint rules for the width of the liquid surface float and the vertical coordinate of the center of the liquid surface float. When the constraint rules are broken, smooth the relative liquid level ratio to improve the stability and reliability of the output data. The constraint rules in step S8 specifically include the following: Liquid surface float width W piece No more than the width W of the level gauge bar The width W of the liquid surface float is y times that of the float. piece =X piece2 -X piece1 The width W of the level gauge bar =X bar2 -X bar1 ; The ordinate of the center of the liquid surface float is Y piece Satisfy Y bar1 ≤Y piece ≤Y bar2 The y is a determination factor, which is set by professionals; When the width of the liquid surface float exceeds y times the width of the liquid level gauge, the vertical coordinate of the center of the liquid surface float is Y. piece No Satisfy Y bar1 ≤Y piece ≤Y bar2 The current relative liquid level ratio R detected Perform smoothing: R current =a1×R detected +a2×R history ; In the formula, R current This represents the output after smoothing, and the final adopted effective relative level ratio reading, R. detected R represents the current relative liquid level ratio reading. history a1 represents the average of the most recent n relative level ratio readings that satisfy the aforementioned constraint rules. a2 is a weighting coefficient, set by professionals.
[0045] Example 7:
[0046] Rule settings: Set the width of the liquid level float to no more than y = 1.2 times the width of the liquid level gauge: W piece =40, W bar =80, satisfying 40<1.2×80=96, the ordinate of the center of the float on the liquid surface satisfies 50≤310≤500, which meets the rules.
[0047] Hypothetical violation case: Suppose that W is detected in a certain instance. piece =100, perform smoothing, and set the current reading R. detected =0.5, historical average R history =0.45, weights a1=0.7, a2=0.3, the smoothed reading is: R current =0.7×0.5+0.3×0.45=0.485.
[0048] Step S9: Maintain the historical relative liquid level ratio queue, calculate the mean and standard deviation, output the final liquid level position when the relative liquid level ratio reading is normal, and trigger an alarm when the current reading is abnormal, so as to realize dynamic monitoring and abnormal early warning.
[0049] Step S9 includes the following steps: Step S9-1: Maintain a relative liquid level ratio queue of size N, Q=[R1,R2,...,R N The system stores the relative liquid level ratios that have most recently satisfied the constraint rules (N times) to establish a historical data benchmark, providing a statistical basis for anomaly detection. Here, N is a preset positive integer. The system also calculates the mean μ of the queue. q With standard deviation σ q ; Step S9-2: In the current calculation cycle, obtain the relative liquid level ratio and the final effective reading R after smoothing when the constraint rules are satisfied. t When |R t -μ q |>b1σ q or |R t -R t−1 When |> b2, an abnormal alarm is triggered, and manual intervention is required to confirm the value. Here, b1 is the judgment multiple and b2 is the judgment threshold, which are set by professionals. Step S9-3: When |R is satisfied t -μ q |≤b1σ q And |R t -R t−1 When |≤b2, output the current actual height H of the liquid surface. liquid =R t ×H physical This enables seamless conversion from images to physical quantities. In the formula, H... liquid H represents the actual height of the liquid level. physical This indicates the actual physical height of the liquid level gauge.
[0050] Example 8:
[0051] Set the historical relative level ratio queue with maintenance size N=50: Set the queue mean μ q=0.43, standard deviation σ q =0.02, current reading R t =0.5, set b1=2, b2=0.1; the calculated value is |0.50−0.43|=0.07>2×0.02=0.04, triggering an abnormal alarm, requiring manual intervention to confirm the value.
[0052] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.
Claims
1. A deep learning-based intelligent reading method for industrial liquid level gauges, characterized in that: The method includes the following steps: Step S1: Take images of the level gauge with a camera and manually mark the bounding boxes of the level gauge body and the float on the liquid surface to form an labeled dataset; Step S2: Preprocess the labeled dataset; Step S3: Using the YOLOv8 model, input the labeled dataset, train it through transfer learning, and obtain the optimal model weights; Step S4: Use the trained YOLOv8 model to detect the level gauge and the surface float, and obtain their coordinates; Step S5: Calculate the pixel height of the level gauge and the ordinate of the center point of the liquid surface float to obtain the relative liquid level ratio; Step S6: When the detected level gauge height is less than k times the average height, it is determined to be an incomplete display case, and edge detection and Hough transform are performed. Step S7: Fit a straight line through edge detection, calculate the tilt angle, correct the liquid surface position, and compensate for the relative liquid level ratio; Step S8: Set constraint rules for the width of the liquid surface float and the vertical coordinate of the center of the liquid surface float. When the constraint rules are broken, smooth the relative liquid level ratio. Step S9: Maintain the historical relative liquid level ratio queue, calculate the mean and standard deviation, output the final liquid level position when the relative liquid level ratio reading is normal, and trigger an alarm when the current reading is abnormal.
2. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 1, characterized in that: The specific operation of step S1 to form the labeled dataset is as follows: using a camera to acquire an image of the liquid level gauge once every set time interval ∆t; manually labeling the liquid level gauge and the surface float in the image using rectangular bounding boxes to form a labeled dataset, wherein the surface float is a visible label floating on the liquid surface; the labeled dataset includes image files and corresponding labeled files, wherein the labeled files record the category and bounding box coordinates of each target object.
3. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 2, characterized in that: The preprocessing of the labeled dataset in step S2 specifically involves: converting the labeled dataset to grayscale to obtain a grayscale image dataset; applying an illumination normalization algorithm to the grayscale image dataset to obtain an illumination normalized image dataset; and applying a contrast-limited adaptive histogram equalization algorithm to the illumination normalized image dataset to enhance image contrast, thereby obtaining an input image dataset.
4. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 3, characterized in that... The specific steps in step S3 using the YOLOv8 model are as follows: The input image dataset is divided into a training set and a validation set according to a preset ratio; YOLOv8 pre-trained weights are loaded, and model training is performed through transfer learning; training is terminated when the validation set loss no longer decreases for x consecutive cycles, and the optimal model weights on the validation set are saved, where x is set by professionals, and the optimal model weights refer to the model parameters that achieve the highest mAP on the validation set; during training, the average height H of the level gauges in the training set is calculated. average .
5. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 4, characterized in that: The specific method for obtaining coordinates in step S4 is as follows: input the input image dataset into the YOLOv8 model trained in step S3 to obtain the bounding box coordinates (X, Y, X) of the level gauge body. bar1 ,Y bar1 ,X bar2 ,Y bar2 ) and the bounding box coordinates (X) of the liquid surface float piece1 ,Y piece1 ,X piece2 ,Y piece2 ), the (X) bar1 ,Y bar1 () represents the pixel coordinates of the upper left corner of the level gauge's main body bounding box, where (X) bar2 ,Y bar2 () represents the bottom right pixel coordinates, where (X) piece1 ,Y piece1 ) represents the pixel coordinates of the top left corner of the liquid surface float bounding box, where (X) piece2 ,Y piece2 () indicates the pixel coordinates of the lower right corner of the liquid surface float's bounding box.
6. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 5, characterized in that: The level gauge pixel height H in step S5 bar =Y bar2 -Y bar1 The ordinate of the center point of the liquid surface float is Y. piece =(Y piece1 +Y piece2 ) / 2; The relative liquid level ratio R = (Y) / 2; bar2 -Y piece ) / H bar In the formula, the relative liquid level ratio R is between 0 and 1, where 0 represents the lowest liquid level and 1 represents the highest liquid level.
7. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 6, characterized in that: The specific process for edge detection and Hough transform correction in step S6 is as follows: when H bar <d×H average When d∈[0,1], it is set by professionals. The current input image is determined to be incomplete. The binary image of the liquid level gauge edge features is extracted by the Canny edge detection algorithm. The Hough transform is used on the binary image to filter and output the set of straight line segments belonging to the side of the liquid level gauge. The liquid level gauge edge features refer to the outline of the liquid level gauge in the image.
8. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 7, characterized in that: In step S7, fitting the straight line through edge detection specifically involves: extracting all pixels from the set of straight line segments to form a set of side pixels; fitting the set of side pixels using the least squares method to obtain the straight line equation y=kx+b; calculating the tilt angle θ=arctan(k) of the straight line equation; and using the tilt angle relative to the ordinate Y of the center of the float on the liquid surface. piece After correction, the corrected ordinate Y is obtained. corrected =Y piece / cosθ; Recalculate the relative liquid level ratio R′=R×(H average / H bar ).
9. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 8, characterized in that: The constraint rules in step S8 specifically include: the following: Liquid surface float width W piece No more than the width W of the level gauge bar The width W of the liquid surface float is y times that of the float. piece =X piece2 -X piece1 The width W of the level gauge bar =X bar2 -X bar1 ; The ordinate of the center of the liquid surface float is Y piece Satisfy Y bar1 ≤Y piece ≤Y bar2 The y is a determination factor, which is set by professionals; When the width of the liquid surface float exceeds y times the width of the liquid level gauge, the vertical coordinate of the center of the liquid surface float is Y. piece No Satisfy Y bar1 ≤Y piece ≤Y bar2 The current relative liquid level ratio R detected Perform smoothing: R current =a1×R detected +a2×R history ; In the formula, R current This represents the output after smoothing, and the final adopted effective relative level ratio reading, R. detected R represents the current relative liquid level ratio reading. history This represents the average of the relative liquid level ratio readings that have satisfied the aforementioned constraint rules in the most recent n times. a1 and a2 are weighting coefficients, which are set by professionals.
10. The intelligent reading method for industrial liquid level gauges based on deep learning according to claim 9, characterized in that: Step S9 includes the following steps: Step S9-1: Maintain a relative liquid level ratio queue of size N, Q=[R1,R2,...,R N The system stores the relative liquid level ratios that have most recently satisfied the constraint rules N times, where N is a preset positive integer; it also calculates the mean μ of the queue. q With standard deviation σ q ; Step S9-2: In the current calculation cycle, obtain the relative liquid level ratio and the final effective reading R after smoothing when the constraint rules are satisfied. t When |R t -μ q |>b1σ q or |R t -R t−1 When |> b2, an abnormal alarm is triggered, and manual intervention is required to confirm the value. Here, b1 is the judgment multiple and b2 is the judgment threshold, which are set by professionals. Step S9-3: When |R is satisfied t -μ q |≤b1σ q And |R t -R t−1 When |≤b2, output the current actual height H of the liquid surface. liquid =R t ×H physical In the formula, H liquid H represents the actual height of the liquid level. physical This indicates the actual physical height of the liquid level gauge.