A method and system for detecting liquid level in a liquid storage bottle
By extracting luminance information in the LAB color space and combining it with convolution operations and image morphology processing, the error problem of liquid level detection in semi-transparent frosted plastic bottles is solved, achieving high-precision liquid level detection suitable for automated production lines.
Patent Information
- Application Number
- CN202011265494.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-12
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2040-11-12
AI Technical Summary
Existing liquid level detection methods have significant errors and poor detection results for semi-transparent and frosted plastic bottles.
The edge line of the liquid surface of the storage bottle is extracted by using LAB color space conversion, brightness dimension information extraction, convolution operation and image morphology processing, combined with background and light source.
It achieves high-precision liquid level detection in semi-transparent frosted plastic bottles and is suitable for online detection in automated production lines.
Smart Images

Figure CN112508852B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of machine vision, and in particular to a method and system for detecting a liquid level in a liquid storage bottle. Background Art
[0002] With the continuous development of social economy, liquid volume detection is a necessary inspection step in the production and filling process. At present, many domestic production lines still use manual visual inspection methods, which are relatively inefficient. With the continuous improvement of technology, machine vision, as an efficient and non-contact non-destructive testing method, has been increasingly used in industrial intelligent production inspection.
[0003] An existing method for realizing liquid level detection is: for transparent bottled liquid, a white backlight is used to illuminate and take an image, and then the liquid level is detected based on region extraction, threshold segmentation, and edge detection. However, for translucent and frosted plastic bottles, the error is large and the effect is not good. Summary of the invention
[0004] The main technical problem solved by the present invention is that the detection results of the existing liquid level detection method have large errors.
[0005] A method for detecting liquid level in a liquid storage bottle, comprising:
[0006] Collect image information of the liquid storage bottle;
[0007] Convert the collected image information into LAB color space and extract the brightness dimension information therein;
[0008] Extracting the target area image where the liquid storage bottle is located according to the brightness dimension information;
[0009] Performing a convolution operation on the target area image to obtain edge contour information of the liquid level;
[0010] The edge contour information is binarized and image morphology processed to extract the edge line of the liquid surface in the liquid storage bottle.
[0011] In one embodiment, before collecting the image information of the liquid storage bottle, the method further includes: arranging a background plate for reference and a light source for lighting around the liquid storage bottle.
[0012] In one embodiment, performing a convolution operation on the target area image to obtain edge contour information of the liquid level includes: performing a convolution operation on the target area using a preset convolution kernel matrix, and extracting lateral edge information in the target area image as edge contour information of the liquid level.
[0013] In one embodiment, binarizing the edge contour information and performing image morphological processing to extract the edge line of the liquid surface in the liquid storage bottle includes:
[0014] The edge contour information is subjected to an opening operation, a closing operation and an erosion process to extract the region with the largest contour area, and the region with the largest contour area is subjected to a skeleton process to obtain a liquid surface edge skeleton line.
[0015] In one embodiment, the binarization of the edge contour information and the image morphological processing to extract the liquid surface edge line in the liquid storage bottle also includes: after obtaining the liquid surface edge skeleton line, using the least squares method to perform curve fitting on the points on the liquid surface edge skeleton line to obtain the liquid surface edge line.
[0016] A liquid level detection system in a liquid storage bottle, comprising:
[0017] A collection device, used for collecting image information of the liquid storage bottle;
[0018] The first extraction module is used to convert the collected image information into the LAB color space and extract the brightness dimension information therein;
[0019] A second extraction module, used to extract the target area image where the liquid storage bottle is located according to the brightness dimension information;
[0020] A convolution operation module, used for performing a convolution operation on the target area image to obtain edge contour information of the liquid level;
[0021] The third extraction module is used to perform binarization and image morphological processing on the edge contour information to extract the edge line of the liquid surface in the liquid storage bottle.
[0022] In one embodiment, it also includes:
[0023] A background plate, which is arranged on the back of the liquid storage bottle and serves as a background reference;
[0024] A light source is used to illuminate the liquid storage bottle.
[0025] In one embodiment, performing a convolution operation on the target area image to obtain edge contour information of the liquid level includes: performing a convolution operation on the target area using a preset convolution kernel matrix, and extracting lateral edge information in the target area image as edge contour information of the liquid level.
[0026] In one embodiment, binarizing the edge contour information and performing image morphological processing to extract the edge line of the liquid surface in the liquid storage bottle includes:
[0027] The edge contour information is subjected to an opening operation, a closing operation and an erosion process to extract the region with the largest contour area, and the region with the largest contour area is subjected to a skeleton process to obtain a liquid surface edge skeleton line.
[0028] In one embodiment, the binarization of the edge contour information and the image morphological processing to extract the liquid surface edge line in the liquid storage bottle also includes: after obtaining the liquid surface edge skeleton line, using the least squares method to perform curve fitting on the points on the liquid surface edge skeleton line to obtain the liquid surface edge line.
[0029] According to the method and system for detecting the liquid level in the liquid storage bottle of the above embodiment, the method includes: collecting image information of the liquid storage bottle; converting the collected image information into LAB color space and extracting the brightness dimension information therein; extracting the target area image where the liquid storage bottle is located according to the brightness dimension information, performing convolution operation on the target area image to obtain the edge contour information of the liquid level; binarizing the edge contour information and performing image morphological processing to extract the edge line of the liquid surface in the liquid storage bottle. It is verified through actual measurement that the liquid level detected by the method of the present application is completely consistent with the actual liquid level, with high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a flow chart of the liquid level detection method of this application;
[0031] Figure 2 The L-dimensional information graph extracted for the embodiment of the present application;
[0032] Figure 3 The target area image extracted by the embodiment of the present application;
[0033] Figure 4 The image after the convolution operation is performed in the embodiment of the present application;
[0034] Figure 5 is the convolution kernel matrix in the embodiment of the present application;
[0035] Figure 6 This is the image after skeletonization processing in the embodiment of the present application;
[0036] Figure 7 This is a schematic diagram of the liquid level curve after fitting in the embodiment of the present application;
[0037] Figure 8 This is a structural block diagram of the liquid level detection system of this application. DETAILED DESCRIPTION
[0038] The present invention is further described in detail below by specific embodiments in conjunction with the accompanying drawings. Wherein similar elements in different embodiments adopt associated similar element numbers. In the following embodiments, many detailed descriptions are for making the present application better understood. However, those skilled in the art can easily recognize that some features can be omitted in different situations, or can be replaced by other elements, materials, methods. In some cases, some operations related to the present application are not shown or described in the specification, this is to avoid the core part of the present application being overwhelmed by too much description, and for those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations according to the description in the specification and the general technical knowledge in the art.
[0039] In addition, the features, operations or characteristics described in the specification can be combined in any appropriate manner to form various implementations. At the same time, the steps or actions in the method description can also be interchanged or adjusted in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a required sequence, unless otherwise specified that a certain sequence must be followed.
[0040] Embodiment 1:
[0041] Please refer to Figure 1 This embodiment provides a method for detecting the liquid level in a liquid storage bottle, the detection method comprising:
[0042] Step 101: Collect image information of a liquid storage bottle;
[0043] Step 102: converting the collected image information into the LAB color space and extracting the brightness dimension information therein;
[0044] Step 103: extracting the target area image where the liquid storage bottle is located according to the brightness dimension information;
[0045] Step 104: performing a convolution operation on the target area image to obtain edge contour information of the liquid level;
[0046] Step 105: Binarize the edge contour information and perform image morphology processing to extract the edge line of the liquid surface in the liquid storage bottle.
[0047] Among them, before collecting the image information of the liquid storage bottle, it also includes: setting a background plate for reference and a light source for lighting around the liquid storage bottle. In this embodiment, the frosted liquid storage bottle to be tested is taken as an example to illustrate the detection method of the present application. First, the liquid storage bottle to be tested is placed on the test station. The background plate of this embodiment is selected to be black, and a double-strip light source is used to illuminate the liquid storage bottle to be tested, and the color image information of the liquid storage bottle is captured by a universal high-resolution camera. It should be noted that the selected background plate color and the color of the light used for lighting can be selected according to the actual measurement environment. In other embodiments, the background plate can also be selected as white, etc., and the light bar can also be selected as other colors.
[0048] In step 102, the color image information obtained in step 101 is converted into a LAB (Lab Color Space) color space, and the L dimension information in the LAB color space is extracted. The Lab color space is a color-opposition space designed to be close to human vision, in which the dimension L represents brightness, and a and b represent color opposition dimensions; because we do not care about the color of the liquid, we only consider the difference in brightness between the liquid and non-liquid parts, so we only extract the L dimension information (i.e., brightness dimension information). The extracted L dimension information is as follows: Figure 2 shown.
[0049] In step 103, the circumscribed rectangle of the area where the bottle is located is firstly extracted, and based on the principle that the area of the bottle body does not change relative to the entire bottle area, the target area image where the bottle body is located is extracted. The target area image in this embodiment refers to the area image where the bottle body is located, such as Figure 3 As shown, the liquid level curve is included in the target area image.
[0050] Because there are small granular elements and reflections on the surface of this translucent frosted plastic bottle, some traditional methods, such as canny edge detection or binarization, are not effective and cannot locate the contour area; Figure 4 As can be seen from the figure, the difference between the upper and lower areas of the liquid surface is quite obvious (the upper area is brighter and the lower area is darker). Therefore, in step 104 of this embodiment, convolution is used as an edge detection method, and the convolution kernel size is 9*9 (the size is not limited to 9*9). Because the liquid surface tends to be horizontal, the convolution kernel matrix is designed to calculate the longitudinal gradient (i.e., the lateral edge). The size of the convolution kernel matrix can be adjusted according to the actual situation. This embodiment provides the following Figure 5 The convolution kernel matrix shown.
[0051] After the convolution kernel operation, this embodiment further performs OTSU (maximum between-class variance method, sometimes also called Otsu algorithm) binarization processing on the image after the convolution kernel operation, so that the parts with large color differences on the upper and lower sides of the liquid surface of the bottle can be identified. By binarizing the image, the color information and background information of the image can be ignored, and more important morphological information can be retained. After the image is binarized, the amount of information in the image is greatly reduced, and it is more convenient to process.
[0052] Furthermore, in step 105, the image after the binary processing is opened, closed and eroded. The opening operation can separate the slightly connected features and remove the interfering feature points, and the closing operation can close the features on the liquid surface curve. Finally, the corrosion process is used to eliminate the noise in the image. Finally, the largest area of the contour area is extracted, which is the area where the liquid surface edge is located, and the skeleton is processed to obtain the skeleton line of the liquid surface edge as shown in FIG. Figure 6 shown.
[0053] Furthermore, in this embodiment, the points on the liquid surface edge skeleton line are fitted with a least squares curve, such as Figure 7 As shown, the equivalent liquid surface edge curve can be obtained, and the equivalent horizontal line can be calculated based on the principle of equal area under the curve. The equivalent horizontal line can be used to estimate the mass of the liquid in the liquid storage bottle.
[0054] The detection method provided in this embodiment adopts a black background and a dual-bar light source for image acquisition, and combines convolution to achieve the method of liquid level detection of a translucent frosted plastic bottle. The algorithm is simple, the steps are few, the real-time performance is good, the feasibility is strong, and it can be attached to an automated production line to realize online detection while producing.
[0055] It should be noted that in similar industrial detection scenarios, light sources with different spectra can be used to detect liquid levels based on convolution and liquid surface curve fitting, and the types of liquid storage bottles that can be detected are not limited to translucent frosted plastic bottles.
[0056] Embodiment 2:
[0057] Please refer to Figure 8 This embodiment provides a liquid level detection system in a liquid storage bottle, and the detection system includes: a collection device 201, a first extraction module 202, a second extraction module 203, a convolution operation module 204, and a third extraction module 205.
[0058] Among them, the acquisition device 201 is used to acquire image information of the liquid storage bottle; the first extraction module 202 is used to convert the acquired image information into the LAB color space and extract the brightness dimension information therein; the second extraction module 203 is used to extract the target area image where the liquid storage bottle is located based on the brightness dimension information; the convolution operation module 204 is used to perform a convolution operation on the target area image to obtain the edge contour information of the liquid level; the third extraction module 205 is used to binarize the edge contour information and perform image morphological processing to extract the liquid surface edge line in the liquid storage bottle.
[0059] Furthermore, the liquid level detection system in the liquid storage bottle of this embodiment also includes a background plate and a light source. The background plate is arranged on the back of the liquid storage bottle to serve as a background reference, and the light source is used to illuminate the liquid storage bottle.
[0060] In addition, the working methods of the above modules of the system in this embodiment are the same as those in the first embodiment and will not be repeated here.
[0061] The above specific examples are used to illustrate the present invention, which is only used to help understand the present invention and is not intended to limit the present invention. For those skilled in the art, according to the concept of the present invention, some simple deductions, modifications or substitutions can be made.
Claims
1. A method for detecting the liquid level in a liquid storage bottle, characterized in that: include: Collect image information of the liquid storage bottle; Convert the collected image information into LAB color space and extract the brightness dimension information therein; Extracting the target area image where the liquid storage bottle is located according to the brightness dimension information; Performing a convolution operation on the target area image to obtain edge contour information of the liquid level; Binarizing the edge contour information and performing image morphology processing to extract the edge line of the liquid surface in the liquid storage bottle; The step of performing a convolution operation on the target area image to obtain edge contour information of the liquid level includes: performing a convolution operation on the target area using a preset convolution kernel matrix, and extracting lateral edge information in the target area image as edge contour information of the liquid level.
2. The method for detecting the liquid level in a liquid storage bottle according to claim 1, characterized in that: Before collecting the image information of the liquid storage bottle, the method further includes: arranging a background plate for reference and a light source for lighting around the liquid storage bottle.
3. The method for detecting the liquid level in a liquid storage bottle according to claim 1, characterized in that: The binarization and image morphological processing of the edge contour information to extract the edge line of the liquid surface in the liquid storage bottle includes: The edge contour information is subjected to an opening operation, a closing operation and an erosion process to extract the region with the largest contour area, and the region with the largest contour area is subjected to a skeleton process to obtain a liquid surface edge skeleton line.
4. The method for detecting the liquid level in a liquid storage bottle as claimed in claim 3, characterized in that: The method of binarizing the edge contour information and performing image morphological processing to extract the liquid surface edge line in the liquid storage bottle further includes: after obtaining the liquid surface edge skeleton line, using the least squares method to perform curve fitting on the points on the liquid surface edge skeleton line to obtain the liquid surface edge line.
5. A liquid level detection system in a liquid storage bottle, characterized in that: include: A collection device, used for collecting image information of the liquid storage bottle; The first extraction module is used to convert the collected image information into the LAB color space and extract the brightness dimension information therein; A second extraction module, used to extract the target area image where the liquid storage bottle is located according to the brightness dimension information; A convolution operation module, used for performing a convolution operation on the target area image to obtain edge contour information of the liquid level; wherein, performing a convolution operation on the target area image to obtain edge contour information of the liquid level comprises: performing a convolution operation on the target area using a preset convolution kernel matrix, and extracting lateral edge information in the target area image as edge contour information of the liquid level; The third extraction module is used to perform binarization and image morphological processing on the edge contour information to extract the edge line of the liquid surface in the liquid storage bottle.
6. The liquid level detection system in the liquid storage bottle as claimed in claim 5, characterized in that: Also includes: A background plate, which is arranged on the back of the liquid storage bottle and serves as a background reference; A light source is used to illuminate the liquid storage bottle.
7. The liquid level detection system in the liquid storage bottle as claimed in claim 5, characterized in that: The binarization of the edge contour information and the image morphology processing to extract the edge line of the liquid surface in the liquid storage bottle include: The edge contour information is subjected to an opening operation, a closing operation and an erosion process to extract the region with the largest contour area, and the region with the largest contour area is subjected to a skeleton process to obtain a liquid surface edge skeleton line.
8. The liquid level detection system in the liquid storage bottle as claimed in claim 7, characterized in that: The method of binarizing the edge contour information and performing image morphological processing to extract the liquid surface edge line in the liquid storage bottle further includes: after obtaining the liquid surface edge skeleton line, using the least squares method to perform curve fitting on the points on the liquid surface edge skeleton line to obtain the liquid surface edge line.
Citation Information
Patent Citations
Detection method of PET bottle cap and liquid level
CN102519972A
Infusion monitoring alarm method, user equipment, storage medium and device
CN110287926A