Method and system for detecting liquid level height in real time based on machine vision

Through the real-time liquid level height detection method based on machine vision, Gaussian filtering and canny edge detection, combined with polygon approximation processing, the problems of large errors and low efficiency of traditional measurement methods are solved, and high-precision, automation, 24-hour uninterrupted Real-time measurement, suitable for height measurement in industrial fields.

CN119309645APending Publication Date: 2025-01-14NORTHEASTERN UNIV AT QINHUANGDAO
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411348815.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In the industrial field, traditional height measurement methods rely on manual operation, have large errors, low efficiency, and are unable to achieve 24-hour uninterrupted real-time measurement, and are costly.

Method used

Real-time liquid level height detection method based on machine vision is adopted, image processing is performed through Gaussian filtering and canny edge detection, feature points are obtained in combination with polygon approximation processing, and the liquid level height is calculated using mathematical models to achieve automated, non-contact, and high-precision measurement.

Benefits of technology

It realizes high-precision, 24-hour uninterrupted real-time measurement, reduces false detection, saves labor costs, and is suitable for high-precision measurement in narrow spaces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119309645A_ABST
    Figure CN119309645A_ABST
Patent Text Reader

Abstract

The invention discloses a real-time liquid level height measurement method and system based on machine vision, and relates to the technical field of height detection, and the system comprises an image detection and processing system and a model analysis and calculation system; according to the method for measuring the liquid level height based on machine vision, python serves as a programming basis, and real-time measurement of the liquid level height is achieved. A real-time liquid level height detection system comprises a camera, an industrial light source, a test tube and an upper computer (computer). In one or more embodiments of the invention, a Gaussian filtering model and a canny edge detection algorithm are used for image preprocessing, and proper parameters are selected based on taking a test tube as a carrier; meanwhile, in order to enhance the accuracy of model calculation, a polygon approximate processing method is adopted to carry out secondary processing on the processed image, and the accuracy in the height measurement process is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method for real-time detection of liquid level based on machine vision and a real-time liquid level detection system. Background Art

[0002] At present, in the industrial field, intelligent or digital height measurement technology has not covered a large area of ​​the field. Many companies rely mainly on manual measurement, using traditional measurement tools such as calipers and standard rulers, which are inefficient and slow. Its shortcomings are mainly manifested in: (1) Relying on the subjective judgment of the measuring workers, the readings of traditional tools have errors, and the measurement accuracy is greatly affected by human factors; (2) When the measurement target is in a small space, traditional measurement tools are inconvenient to use and the measurement difficulty is greatly increased; (3) Manual measurement cannot complete 24-hour uninterrupted real-time measurement operations. (4) Labor costs are increasing day by day. Once the measurement demand increases, the enterprise's measurement costs will also increase greatly. In contrast, with the development of computer and other technologies, the measurement method based on machine vision can effectively solve the above problems. Its advantages are mainly reflected in the following aspects: (1) The machine vision-based method can automatically perform measurements, greatly saving labor costs and time; (2) The measurement results can be visualized and presented to the workers, which is convenient for operators to collect measurement data in a timely manner; (3) The measurement accuracy is high, which effectively reduces the possibility of false detection; (4) The non-contact measurement method can effectively perform high-precision measurements in small spaces. (5) The 24-hour real-time measurement of height data can be used to complete engineering operations with specific requirements. Summary of the invention

[0003] This project is based on the industrial measurement industry. It uses machine vision and other related computer technologies, and uses test tubes as experimental tools to simulate the actual situation of industrial height measurement to train the model. It plans to design a real-time height measurement system based on machine vision to realize the industrial height measurement process with depth perception, intelligent decision-making, and automatic execution functions.

[0004] The technical solution adopted by the present invention is:

[0005] A method for measuring liquid level based on machine vision, comprising the following steps: step:

[0006] (1) Collect images of different liquid level heights in the test tube;

[0007] (2) Binarization of the acquired image;

[0008] (3) Remove the extra impurities in the image and only keep the image inside the light source;

[0009] (4) performing contour search on the retained processed image to find the outer contour of the liquid inside the test tube;

[0010] (5) Acquire feature points of the target's outer contour to prepare for subsequent calculations;

[0011] (6) Calculate the distance using the established mathematical model to obtain the actual height of the liquid level;

[0012] (7) Adjusting the set camera parameters to input real-time video and then perform height detection in real time;

[0013] The real-time liquid level detection method according to claim 1 is characterized in that: in the step (2), the collected image is first reduced in size, and then Gaussian filtering and binarization are used to simplify the grayscale value of the image from multiple levels to two levels of black and white, so as to simplify the image processing process and improve contrast and clarity. Gaussian filtering is mainly used to smooth and reduce noise in images. It can remove high-frequency noise in images, making the images smoother and clearer. Gaussian filtering is widely used in digital image processing, computer vision, pattern recognition and other fields. For example, in digital image processing, Gaussian filtering can be used to preprocess images to improve the accuracy and robustness of subsequent operations; in computer vision, Gaussian filtering can be used for image segmentation, feature extraction and other operations.

[0014] The real-time liquid level detection method according to claim 1 is characterized in that: in the step (3), the binary image processed in the step (2) is first used, and then canny edge detection is performed, and the quadrilateral corner points are found by using the characteristics of the light source rectangle, so as to locate the boundary of the retained image through trajectory finding, and drawcontours is used to draw the boundary line more clearly, so as to better separate the required image, and this process includes the affine transformation of the image.

[0015] The real-time liquid level detection method according to claim 1 is characterized in that: in the step (4), contour search is also performed on the affine transformed image obtained in the step (3). Because the order of searching for contours is inconsistent with that used in the step (3), the parameters in the findcontours function are also adjusted, in order to obtain the innermost test tube contour of the entire image.

[0016] The real-time liquid level detection method according to claim 1 is characterized in that: in the step (5), the target point is acquired by using an if function loop search method, and the appropriate feature points are taken out by comparing the sizes of the x and y coordinates, wherein a polygonal approximation method is used, starting from the rightmost point until it loops back to the original position, and finally the three required feature points are obtained.

[0017] Furthermore, the specific implementation of step (6) is as follows:

[0018] 6.1 Use the coordinate formula between the two points to calculate the midpoint of the highest points on the left and right sides (that is, the theoretical highest point of the liquid surface)

[0019] 6.2 Then use the coordinate formula between the midpoint coordinates and the bottom coordinates to calculate the final height measurement value.

[0020] A real-time liquid level detection system for realizing the real-time liquid level detection method according to claim 1, comprising: a camera, an industrial light source, a test tube, and a host computer (computer). The camera is connected to the host computer (computer) and placed directly in front of the industrial light source, the test tube is embedded in the industrial light source in the form of nano glue, and the two are connected by a black flat plate.

[0021] The real-time liquid level detection system is characterized in that the camera is directly controlled by the host computer to collect images.

[0022] The real-time liquid level detection system according to claim 7 is characterized in that: the combination of an industrial light source and a liquid with low light transmittance can separate the surrounding environment from the interior of the light source, and at the same time can more quickly find the innermost track inside the light source, that is, the required approximate polygon composed of the liquid surface and the test tube; and the use of nano-adhesive bonding can avoid the influence of traditional test tube racks and iron racks on canny edge detection, and can also have suitable light transmittance without affecting the measurement of the liquid level.

[0023] Beneficial effects of the invention:

[0024] The present invention is based on a real-time height detection device and method of machine vision, and uses a method combining Gaussian filtering and canny edge detection to perform affine transformation of images, which effectively solves the current situation that image processing is easily disturbed by the surrounding environment and debris. The polygonal approximation processing method is used to extract feature points, and the required feature points can be accurately found while ensuring the extraction speed. The measurement accuracy is high, and the false detection situation is effectively reduced. At the same time, non-contact measurement and 24-hour uninterrupted real-time measurement are realized, and high-precision measurement can be effectively performed when the space to be measured is small and the measurement demand is large. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 is a flow chart of a real-time height measurement method;

[0026] Figure 2 This is a flowchart of the affine transformation method of this project;

[0027] Figure 3 This is a schematic diagram of canny edge detection results;

[0028] Figure 4 A schematic diagram showing the results of height measurement;

[0029] Figure 5 This is the module diagram of the real-time height measurement system;

[0030] Figure 6 A flowchart implemented for the model; DETAILED DESCRIPTION

[0031] In order to describe the present invention more specifically, the technical solution of the present invention is described in detail below in conjunction with the accompanying drawings and specific implementation methods. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0032] Example 1

[0033] The present invention provides a real-time height measurement method based on machine vision, such as Figure 1 As shown, the specific steps are as follows:

[0034] Step 1: Capture an image; in this embodiment, a 1080P high-definition camera and an industrial backlight are used to build an image acquisition system, take a picture of the test tube liquid surface, and obtain a test tube liquid level height image as an image input for subsequent visual processing.

[0035] Step 2: Image preprocessing; This embodiment first reduces the size of the captured image, and then uses Gaussian filtering and binarization methods to simplify the grayscale values ​​of the image from multiple levels to two levels of black and white, so as to simplify the image processing process and improve contrast and clarity.

[0036] Since the size of the acquired image is too large to be easily processed, the original acquired image is reduced to one-fourth of its original size.

[0037] Step 3: Image affine transformation; Figure 2As shown, the binary image processed in step (2) is first used, and then canny edge detection is performed. The features of the light source rectangle are used to find the corner points of the quadrilateral and reorder the four corner points to define the w and h of the quadrilateral. Then, the boundary of the retained image is located through trajectory finding (findcontours), and the drawcontours function is used to draw the boundary line more clearly. Finally, the imgWarp function is used to perform image affine transformation to better separate the required image.

[0038] Step 4: Contour search: Contour search is also performed on the affine transformed image obtained in step (3). Because the order of finding contours is inconsistent with that used in step (3), the parameters in the findcontours function are also adjusted in order to obtain the innermost test tube contour of the entire image.

[0039] Step 5: Feature point acquisition: The target points are acquired by using the if function loop search method, which uses the polygon approximation method, starting from the rightmost point until it loops back to the original position, and finally obtains the three required feature points.

[0040] #Model calculation python code

[0041] up_most = approx2[0]

[0042] left_most = approx2[0]

[0043] right_most = approx2[0]

[0044] down_most = approx2[0]

[0045] for i in range(len(approx2)):

[0046] if approx2[i][0][1] <up_most[0][1]:

[0047] up_most[0][1]=approx2[i][0][1]

[0048] if approx2[i][0][1]<(up_most[0][1]+3):

[0049] if approx2[i][0][0] <left_most[0][0]:

[0050] left_most = approx2[i]

[0051] if approx2[i][0][0]>right_most[0][0]:

[0052] right_most = approx2[i]

[0053] for i in range(len(approx2)):

[0054] if approx2[i][0][1]>down_most[0][1]:

[0055] down_most = approx2[i]

[0056] #print(left_most,right_most,down_most)

[0057] middle_most=(left_most+right_most) / / 2

[0058] #Find the midpoint between two points

[0059] #print(middle_most,up_most,approx2[3])

[0060] dis= "%.1f"%function.finddistance(middle_most / scale,down_most / scale)

[0061] #Use the distance function to get the distance between two points

[0062] cv2.arrowedLine(imgwarp,(down_most[0][0],down_most[0][1]),(midd le_most[0][0],middle_most[0][1]),(255,0,255),3,8,0,0.005)

[0063] # Draw the trajectory of the required distance

[0064] cv2.putText(imgwarp,'{}cm'.format(dis),(middle_most[0][0]-20,middle_most[0][1]+300),cv2.FONT_HERSHEY_COMPLEX_SMALL,1,(255,0,255),2)

[0065] #Display the distance result in the picture

[0066] Step 6: Data calculation; Construct a mathematical model for height calculation, and use the three characteristic points obtained in step 5 for calculation - use the coordinate formula between the two points to calculate the midpoint of the highest points on the left and right sides (that is, the theoretical highest point of the liquid surface), and then use the coordinate formula between the two points to calculate the coordinates of the midpoint and the bottom to obtain the final height measurement value, such as Figure 4 shown.

[0067] Step 7: Parameter modification: Change the webcam parameters set at the beginning to true mode - switch to video input to achieve real-time measurement effect

[0068] In the description of this specification, the description with reference to the terms "embodiment", "example", "specific example" and the like means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0069] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0070] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A method for measuring liquid level based on machine vision, comprising the following steps: (1) Collect images of different liquid level heights in the test tube; (2) Binarization of the collected images (3) Remove the extra impurities in the image and only keep the image inside the light source (4) Perform contour search on the retained processed image to find the outer contour of the liquid inside the test tube (5) Acquire feature points of the target's outer contour to prepare for subsequent calculations (6) Use the established mathematical model to calculate the distance and obtain the actual height of the liquid level. (7) Adjust the set camera parameters to input real-time video and perform height detection in real time 2. The real-time liquid level detection method according to claim 1, characterized in that: In the step (2), the collected image is first reduced in size, and then Gaussian filtering and binarization are performed, with the aim of simplifying the grayscale values ​​of the image from multiple levels to two levels of black and white, so as to simplify the image processing process and improve contrast and clarity. Gaussian filtering is mainly used to smooth and reduce noise in images. It can remove high-frequency noise in images, making the images smoother and clearer. Gaussian filtering is widely used in digital image processing, computer vision, pattern recognition and other fields. For example, in digital image processing, Gaussian filtering can be used to preprocess images to improve the accuracy and robustness of subsequent operations; in computer vision, Gaussian filtering can be used for image segmentation, feature extraction and other operations.

3. The real-time liquid level detection method according to claim 1, characterized in that: In the step (3), the binary image processed in step (2) is first used, and then canny edge detection is performed, and the quadrilateral corner points are found using the characteristics of the light source rectangle, so as to locate the boundary of the retained image through trajectory finding, and drawcontours is used to draw the boundary line more clearly, so as to better separate the required image. This process includes affine transformation of the image.

4. The real-time liquid level detection method according to claim 1, characterized in that: In step (4), contour search is also performed on the affine transformed image obtained in step (3). Because the order of finding contours is inconsistent with that used in step (3), the parameters in the findcontours function are also adjusted in order to obtain the innermost test tube contour of the entire image.

5. The real-time liquid level detection method according to claim 1, characterized in that: In the step (5), the target point is acquired by using the if function loop search method, and the appropriate feature points are taken out by comparing the sizes of the x and y coordinates. The polygon approximation method is used, starting from the rightmost point until it loops back to the original position, and finally the three required feature points are obtained.

6. The real-time liquid level detection method according to claim 1, characterized in that: The specific implementation of step (6) is as follows: 6.1 Use the coordinate formula between the two points to calculate the midpoint of the highest points on the left and right sides (that is, the theoretical highest point of the liquid surface); 6.2 Then use the coordinate formula between the midpoint coordinates and the bottom coordinates to calculate the final height measurement value.

7. A real-time liquid level detection system for implementing the real-time liquid level detection method according to claim 1, comprising: Camera, industrial light source, test tube, host computer (computer). The camera is connected to the host computer (computer) and placed in front of the industrial light source. The test tube is embedded in the industrial light source in the form of nano glue, and the two are connected by a black flat plate.

8. The real-time liquid level detection system according to claim 7, characterized in that: The host computer directly controls the camera to collect images.

9. The real-time liquid level detection system according to claim 7, characterized in that: Combining industrial light sources and liquids with low light transmittance can separate the surrounding environment from the interior of the light source, while also more quickly finding the innermost track inside the light source, which is the required approximate polygon composed of the liquid surface and the test tube; and the use of nano-adhesive bonding can avoid the influence of traditional test tube racks and iron stands on canny edge detection, and also have appropriate light transmittance without affecting the measurement of liquid level height.

Citation Information

Cited By

  • Automatic robot control method and system for variable head permeability test

    CN120334088A