A method and system for detecting liquid level in a dropper bottle
Through the machine vision-based liquid level detection method, the shape matching and gradient method are used to detect the liquid level of the drip bottle, the existing problems of low liquid level detection efficiency and large error are solved, and efficient and accurate liquid level detection is achieved.
Patent Information
- Application Number
- CN202310029525.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-09
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2043-01-09
AI Technical Summary
The existing liquid level detection methods are inefficient and have large errors. Manual inspection is prone to missed and missed inspections, which affects product quality.
Using a liquid level detection method based on machine vision, we collect the image of the drop bottle, create a shape matching model, determine the position of the standard liquid level line, and use the gradient method to determine whether the liquid level is within the qualified range.
It improves detection efficiency, reduces manual operations, reduces misjudgment rate, improves detection accuracy and automation, and reduces production costs.
Smart Images

Figure CN115937208B_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of machine vision detection technology, and in particular to a method and system for detecting the liquid level of a dropper bottle. Background Art
[0002] Liquid level detection involves measuring the height of liquids using specific methods and techniques. This technology is widely used in liquid food production testing, pharmaceutical manufacturing and testing, and liquid chemical testing. Current liquid level detection methods often use differential pressure, sensors, and manual visual inspection to check consistent and uniform liquid levels in bottles, confirming product conformity. However, manual testing has many drawbacks, including slow speed, low efficiency, and inconsistent quality. It often results in missed or false detections, leading to inconsistent product quality. Human misjudgments and damage to the liquid being tested by testing equipment can severely impact product quality, leading to waste if defective products are produced.
[0003] To address the aforementioned shortcomings of manual inspection, research on liquid level detection based on machine vision is needed. Machine vision has many applications in liquid level detection, but current visual level detection algorithms are complex, time-consuming, and subject to significant errors in measuring liquid level height. Therefore, this paper proposes a liquid level detection method based on machine vision that achieves liquid level detection through simple geometric matching. Summary of the Invention
[0004] One or more embodiments of this specification provide a method for detecting the liquid level of a dropper bottle, including:
[0005] S1. Collecting the image of the dropper bottle and preprocessing the image of the dropper bottle;
[0006] S2. Create a shape matching model to detect the position coordinates of the dropper bottle in the dropper bottle image;
[0007] S3. Determine the position of the standard liquid level line according to the position coordinates, and create a qualified liquid level line area ROI with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line area ROI;
[0008] S4. Obtain the coordinates of the liquid level line of the dripping bottle according to the gradient method, and determine whether the liquid level line is within the qualified liquid level line area ROI. If so, the liquid level is qualified.
[0009] One or more embodiments of this specification provide a method and system for detecting liquid level in a dropper bottle, including:
[0010] Image processing module: used for collecting the image of the dropping bottle and preprocessing the image of the dropping bottle;
[0011] Position detection module: used to create a shape matching model and detect the position coordinates of the dropping bottle in the dropping bottle image;
[0012] Region of interest creation module: used for determining the position of the standard liquid level line according to the position coordinates, and creating a qualified liquid level line region ROI with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line region ROI;
[0013] Calculation and analysis module: used to obtain the coordinates of the liquid level line of the dropper bottle according to the gradient method, and determine whether the liquid level line is within the qualified liquid level line area ROI range. If so, the liquid level is qualified.
[0014] By adopting the embodiment of the present invention, the liquids in multiple dropping bottles can be detected at the same time, that is, the liquids in multiple dropping bottles can be collected at the same time as the liquid level images of a detection group, and the speed is significantly better than other detection equipment and methods, which greatly improves work efficiency; there is less manual operation, which significantly reduces the labor intensity of detection personnel; the detection method is novel, simple in structure, easy to use, and has a wide range of applications. It is applicable to the detection of industrial glass bottled products, has strong anti-interference ability, high measurement accuracy, fast speed, and high degree of automation; the method of the present invention can avoid misjudgment and missed detection caused by manual operation, reduce production costs caused by mechanical loss, and greatly improve the accuracy of transparent bottled liquid detection.
[0015] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate one or more embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 A flow chart of a method for detecting liquid level in a dropper bottle provided in one or more embodiments of this specification;
[0018] Figure 2 A schematic diagram of a specific process of a method for detecting liquid level in a dropping bottle provided in this embodiment;
[0019] Figure 3 A schematic diagram of a cropped image of the bottleneck position of a method for detecting the liquid level of a dripping bottle provided in one or more embodiments of this specification;
[0020] Figure 4 A schematic diagram of creating a qualified liquid level line area ROI for a method for detecting liquid level in a dripping bottle provided in one or more embodiments of this specification;
[0021] Figure 5 A schematic diagram of a method for detecting the liquid level of a dropper bottle and calculating whether the product is qualified, provided in one or more embodiments of this specification;
[0022] Figure 6 This is a schematic structural diagram of a liquid level detection system for a dropper bottle provided in one or more embodiments of this specification. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below in conjunction with the drawings in one or more embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this document.
[0024] Method Example
[0025] According to an embodiment of the present invention, a method for detecting the liquid level of a dropper bottle is provided. Figure 1 This is a flow chart of a method for detecting the liquid level of a dropper bottle provided in one or more embodiments of this specification. Figure 2 A specific flow chart of a method for detecting liquid level in a dropper bottle provided in this embodiment is shown as follows: Figure 1 、 2 As shown, the method for detecting the liquid level of a dropper bottle according to an embodiment of the present invention specifically includes:
[0026] S1. Collecting an image of a dropping bottle and preprocessing the image of the dropping bottle.
[0027] Specifically, a backlight photography method is adopted to collect the image of the dropper bottle through a CCD lens; wherein the backlight type is a high-density LED array red and white dual-purpose backlight;
[0028] Suppressing the noise of the dripping bottle image based on a mean filtering method to eliminate the noise points of the dripping bottle image includes:
[0029] Use a rectangular mask window of size M×N to traverse the image, divide the convolution result by the number of pixels in the current window area, and use the average value as the pixel value on the anchor point.
[0030] S2. Create a shape matching model to detect the position coordinates of the dropping bottle in the dropping bottle image.
[0031] Identify the processed image of the dropper bottle and find the bottleneck of the dropper bottle to crop it, such as Figure 3 As shown, the bottleneck portion of the image of the dropper bottle to be detected is cropped, a rectangular area is selected from the bottleneck portion of the image as a matching template, and a shape matching model is created; specifically,
[0032] In this embodiment, according to the size of the cropped bottleneck image, a measurement rectangle parameter with a width of 150 pixels, a height of 40 pixels, and a rotation angle Phi = 90° is generated, providing a unified parameter standard for each calculation of the liquid point.
[0033] Set the center point of the matching template as the matching base point, establish a coordinate system with the matching base point as the origin, traverse the matching template from left to right and then from top to bottom on the image of the drip bottle to be tested, and perform similarity matching between the image area of the liquid level to be tested and the template image area;
[0034] When the similarity is greater than the preset similarity threshold, the center coordinates of the matching template can be used as the position coordinates of the dripping bottle in the dripping bottle image (Row n , Column n );
[0035] It should be noted that the dripping bottle image contains more than one dripping bottle, and the dripping bottles in the dripping bottle image are closely arranged. Row represents the number of rows, that is, the vertical coordinate, Column represents the number of columns, that is, the horizontal coordinate, and n represents the number of dripping bottles matched in the dripping bottle image.
[0036] S3. Determine the position of the standard liquid level line according to the position coordinates, and create a qualified liquid level line area ROI with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line area ROI.
[0037] First, obtain the position coordinates of all the dropper bottles in the dropper bottle image (Row n , Column n ), a standard liquid level line is set according to the average value of the ordinates of the position coordinates of all the dropping bottles and the actual height of the liquid level bottle; in this embodiment, the row coordinate (ordinate) of the standard liquid level line is taken as RefLevel=mean(Row)-160, where mean(Row) represents the average value of the ordinates of all the dropping bottles, and 160 is a constant value set according to the actual height of the dropping bottles in this embodiment, indicating that the standard liquid level line is located 160 pixels away from the average value of the ordinates of all the dropping bottles;
[0038] After determining the standard liquid level line, create a qualified liquid level line area ROI with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line area ROI. The center point coordinates of the qualified liquid level line area ROI are (RefLevel, mean(Column)). The width of the qualified liquid level line area ROI is determined according to the horizontal coordinate difference of the position coordinates of all the dropping bottles in the dropping bottle image and the actual width of the dropping bottle;
[0039] In this embodiment, a rectangular area is created as the qualified liquid level line area ROI with 30+(max(Column)-min(Column)) / 2 as the half width, Tolerance as the half height, and a rotation angle Phi=90°, as shown in FIG. Figure 4 As shown, Tolerance=15 is set.
[0040] S4. Obtain the coordinates of the liquid level line of the dripping bottle according to the gradient method, and determine whether the liquid level line is within the qualified liquid level line area ROI. If so, the liquid level is qualified.
[0041] Moving the matching template to the position of the dropping bottle in the dropping bottle image in sequence, generating a section line with a ordinate equal to the ordinate of the center coordinate of the matching template at the current position of the dropping bottle to be measured;
[0042] Calculate the grayscale average of the unit pixel interval on each slice perpendicular to the section line as the grayscale value of the intersection of the slice and the section line;
[0043] By comparing the absolute value of the grayscale value difference between unit pixel intervals on the profile line, the location of the local extreme value of the grayscale change on the profile line is determined: when the absolute value of the amplitude of the change is greater than the set amplitude threshold lower limit Threshold, the actual liquid level line coordinates (x, y) of the dropping bottle to be tested are output; where Threshold is set to 7.
[0044] Calculate the distance d between the actual liquid level line of the dropper bottle and the standard liquid level line, and compare the relationship between the distance and the height of the qualified liquid level line area ROI, as shown in the figure. Figure 5 As shown, if the distance d is less than or equal to half the height of the qualified liquid level line area ROI (Tolerance), the liquid level of the dripping bottle is judged to be qualified; if the distance d is greater than half the height of the qualified liquid level line area ROI (Tolerance=), the liquid level of the dripping bottle is judged to be unqualified.
[0045] The beneficial effects of the embodiments of the present invention are as follows:
[0046] The method disclosed in the present invention can simultaneously detect liquids in multiple dropping bottles, that is, it can simultaneously collect liquids in multiple dropping bottles as liquid level images of a detection group, and the speed is significantly better than other detection equipment and methods, which greatly improves work efficiency; there is less manual operation, which significantly reduces the labor intensity of detection personnel; the detection method is novel, simple in structure, easy to use, and has a wide range of applications, and is applicable to the detection of industrial glass bottled products, with strong anti-interference ability, high measurement accuracy, fast speed, and high degree of automation; the method of the present invention can avoid misjudgment and missed detection caused by manual operation, reduce production costs caused by mechanical loss, and greatly improve the accuracy of transparent bottled liquid detection.
[0047] System Example
[0048] According to an embodiment of the present invention, a liquid level detection system for a dropper bottle is provided. Figure 6 This is a structural diagram of a liquid level detection system for a dropper bottle provided in one or more embodiments of this specification, such as Figure 6 As shown, the liquid level detection system for a dropper bottle according to an embodiment of the present invention specifically includes:
[0049] Image processing module 60: used for collecting the image of the dripping bottle and pre-processing the image of the dripping bottle.
[0050] The image processing module 60 is specifically used for:
[0051] The image of the dropper bottle is captured by a CCD lens using a backlight source; wherein the backlight source is a high-density LED array red and white dual-purpose backlight source;
[0052] The noise of the drip bottle image is suppressed based on the mean filtering method.
[0053] The position detection module 62 is used to create a shape matching model and detect the position coordinates of the dropper bottle in the dropper bottle image.
[0054] The position detection module 62 is specifically used for:
[0055] Cropping the bottleneck portion of the image of the dropper bottle to be detected, selecting a rectangular area in the bottleneck portion as a matching template, and creating a shape matching model;
[0056] Set the center point of the matching template as the matching base point, establish a coordinate system with the matching base point as the origin, traverse the matching template from left to right and then from top to bottom on the image of the drip bottle to be tested, and perform similarity matching between the image area of the liquid level to be tested and the template image area;
[0057] When the similarity is greater than the similarity threshold, the center coordinates of the matching template can be used as the position coordinates of the dropping bottle in the dropping bottle image.
[0058] The region of interest creation module 64 is configured to determine the position of the standard liquid level line according to the position coordinates, and create a qualified liquid level line region ROI with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line region ROI.
[0059] The region of interest creation module 64 is specifically used to:
[0060] Obtain the position coordinates of all the dropping bottles in the dropping bottle image, and set a standard liquid level line according to the average value of the ordinates of the position coordinates of all the dropping bottles and the actual height of the liquid level bottle;
[0061] A qualified liquid level line area ROI is created with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line area ROI. The width of the qualified liquid level line area ROI is determined according to the horizontal coordinate difference of the position coordinates of all the dropping bottles in the dropping bottle image and the actual width of the dropping bottle.
[0062] The calculation and analysis module 66 is used to obtain the coordinates of the liquid level line of the dripping bottle according to the gradient method, and determine whether the liquid level line is within the qualified liquid level line area ROI. If so, the liquid level is qualified.
[0063] The calculation and analysis module 66 is specifically used for:
[0064] The matching template is sequentially moved to the position of the dropping bottle in the dropping bottle image, and a section line whose ordinate is the ordinate of the center coordinate of the matching template is generated at the current position of the dropping bottle to be measured;
[0065] Calculate the grayscale average of the unit pixel interval on each slice perpendicular to the section line as the grayscale value of the intersection of the slice and the section line;
[0066] The grayscale value difference of the unit pixel interval on the cross-section line is used to determine the position of the local extreme value of the grayscale change on the cross-section line, and the actual liquid level line coordinates of the dropping bottle to be measured are obtained;
[0067] Calculate the distance between the actual liquid level line of the dropping bottle and the standard liquid level line, and compare the distance with the height of the qualified liquid level line area ROI. If the distance is less than or equal to half the height of the qualified liquid level line area ROI, then the liquid level of the dropping bottle is judged to be qualified. If the distance is greater than half the height of the qualified liquid level line area ROI, then the liquid level of the dropping bottle is judged to be unqualified.
[0068] The embodiment of the present invention is a system embodiment corresponding to the above-mentioned method embodiment. The specific operations of each module can be understood by referring to the description of the method embodiment, which will not be repeated here.
[0069] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting the liquid level of a dropping bottle, characterized in that: include: S1. Collecting the image of the dropper bottle and preprocessing the image of the dropper bottle; S2. Create a shape matching model to detect the position coordinates of the dropper bottle in the dropper bottle image; S3. Determine the position of the standard liquid level line according to the position coordinates, and create a qualified liquid level line area ROI with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line area ROI; The method in step S3 specifically includes: Obtain the position coordinates of all the dropping bottles in the dropping bottle image, and set a standard liquid level line according to the average value of the ordinates of the position coordinates of all the dropping bottles and the actual height of the liquid level bottle; A qualified liquid level line region ROI is created with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line region ROI, wherein the width of the qualified liquid level line region ROI is determined according to the horizontal coordinate difference of the position coordinates of all the dropping bottles in the dropping bottle image and the actual width of the dropping bottles; S4. Obtain the coordinates of the liquid level line of the dropper bottle according to the gradient method, and determine whether the liquid level line is within the qualified liquid level line area ROI range. If so, the liquid level is qualified; The method of step S4 specifically includes: The matching template is sequentially moved to the position of the dropping bottle in the dropping bottle image, and a section line whose ordinate is the ordinate of the center coordinate of the matching template is generated at the current position of the dropping bottle to be measured; Calculate the grayscale average of the unit pixel interval on each slice perpendicular to the section line as the grayscale value of the intersection of the slice and the section line; The grayscale value difference of the unit pixel interval on the cross-section line is used to determine the position of the local extreme value of the grayscale change on the cross-section line, and the actual liquid level line coordinates of the dropping bottle to be measured are obtained; Calculate the distance between the actual liquid level line of the dropping bottle and the standard liquid level line, and compare the distance with the height of the qualified liquid level line area ROI. If the distance is less than or equal to half the height of the qualified liquid level line area ROI, then the liquid level of the dropping bottle is judged to be qualified. If the distance is greater than half the height of the qualified liquid level line area ROI, then the liquid level of the dropping bottle is judged to be unqualified.
2. The method according to claim 1, characterized in that The method described in step S1 specifically includes: The image of the dropper bottle is captured by a CCD lens using a backlight source; wherein the backlight source is a high-density LED array red and white dual-purpose backlight source; The noise of the drip bottle image is suppressed based on the mean filtering method.
3. The method according to claim 1, characterized in that The method described in step S2 specifically includes: Cropping the bottleneck portion of the image of the dropper bottle to be detected, selecting a rectangular area in the bottleneck portion as a matching template, and creating a shape matching model; Set the center point of the matching template as the matching base point, establish a coordinate system with the matching base point as the origin, traverse the matching template from left to right and then from top to bottom on the image of the drip bottle to be tested, and perform similarity matching between the image area of the liquid level to be tested and the template image area; When the similarity is greater than the similarity threshold, the center coordinates of the matching template can be used as the position coordinates of the dropping bottle in the dropping bottle image.
4. A method and system for detecting liquid level in a dropping bottle, characterized in that: include: Image processing module: used for collecting the image of the dropping bottle and preprocessing the image of the dropping bottle; Position detection module: used to create a shape matching model and detect the position coordinates of the dropping bottle in the dropping bottle image; Region of interest creation module: used for determining the position of the standard liquid level line according to the position coordinates, and creating a qualified liquid level line region ROI with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line region ROI; The interest region creation module is specifically used to: Obtain the position coordinates of all the dropping bottles in the dropping bottle image, and set a standard liquid level line according to the average value of the ordinates of the position coordinates of all the dropping bottles and the actual height of the liquid level bottle; A qualified liquid level line region ROI is created with the standard liquid level line as the horizontal center dividing line of the qualified liquid level line region ROI, wherein the width of the qualified liquid level line region ROI is determined according to the horizontal coordinate difference of the position coordinates of all the dropping bottles in the dropping bottle image and the actual width of the dropping bottles; Calculation and analysis module: used to obtain the coordinates of the liquid level line of the dripping bottle according to the gradient method, and determine whether the liquid level line is within the qualified liquid level line area ROI. If so, the liquid level is qualified; The calculation and analysis module is specifically used for: The matching template is sequentially moved to the position of the dropping bottle in the dropping bottle image, and a section line whose ordinate is the ordinate of the center coordinate of the matching template is generated at the current position of the dropping bottle to be measured; Calculate the grayscale average of the unit pixel interval on each slice perpendicular to the section line as the grayscale value of the intersection of the slice and the section line; The grayscale value difference of the unit pixel interval on the cross-section line is used to determine the position of the local extreme value of the grayscale change on the cross-section line, and the actual liquid level line coordinates of the dropping bottle to be measured are obtained; Calculate the distance between the actual liquid level line of the dropping bottle and the standard liquid level line, and compare the distance with the height of the qualified liquid level line area ROI. If the distance is less than or equal to half the height of the qualified liquid level line area ROI, then the liquid level of the dropping bottle is judged to be qualified. If the distance is greater than half the height of the qualified liquid level line area ROI, then the liquid level of the dropping bottle is judged to be unqualified.
5. The system according to claim 4, characterized in that The image processing module is specifically used for: The image of the dropper bottle is captured by a CCD lens using a backlight source; wherein the backlight source is a high-density LED array red and white dual-purpose backlight source; The noise of the drip bottle image is suppressed based on the mean filtering method.
6. The system according to claim 4, characterized in that The position detection module is specifically used for: Cropping the bottleneck portion of the image of the dropper bottle to be detected, selecting a rectangular area in the bottleneck portion as a matching template, and creating a shape matching model; Set the center point of the matching template as the matching base point, establish a coordinate system with the matching base point as the origin, traverse the matching template from left to right and then from top to bottom on the image of the drip bottle to be tested, and perform similarity matching between the image area of the liquid level to be tested and the template image area; When the similarity is greater than the similarity threshold, the center coordinates of the matching template can be used as the position coordinates of the dropping bottle in the dropping bottle image.
Citation Information
Patent Citations
Medicine bottle liquid level detection method based on image processing
CN104819754A
Machine vision based liquid level sub-quality product marking method
CN106052793A