A precision pressure gauge automatic reading method and device for instrument detection

CN117496492BActive Publication Date: 2026-10-23HANGZHOU E ENERGY ELECTRIC POWER TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311201309.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-18
Publication Date
2026-10-23
Estimated Expiration
2043-09-18

AI Technical Summary

Technical Problem

但该方法需要大量数据集来训练网络权重,现场数据集的采集往往较为困难,而且训练后的检测结果精度也难以控制

Benefits of technology

[0095]本发明为一种面向仪表检测的精密压力表自动读数方法及装置,具有以下优点:1)根据指针的像素特征,在表盘中准确检测出指针,能够有效减少因光照或者表盘背景干扰而导致的误识别;2)根据零刻度线和满刻度线的像素分布特征来检测和定位刻度线,算法参数大都能够自适应调整,在存在些许干扰的情况下,仍能具有较高的检测率;3)能够自动识别目标仪表的量程,无需人工给定,更体现了该算法的智能性;4)该方法中指针检测和刻度线检测方法具有较高的鲁棒性,在测试中的表现明显优于常规算法,具有较强的实用性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117496492B_ABST
    Figure CN117496492B_ABST
Patent Text Reader

Abstract

The application discloses a precision pressure gauge automatic reading method and device for instrument detection. The precision pressure gauge automatic reading method comprises the following steps: step A: the instrument image shot by a camera is preprocessed, and a dial image is obtained by cutting; step B: the dial center of the dial image obtained in step A is detected; step C: the pointer direction and the pointer deflection angle of the dial image obtained in step A are detected; step D: the zero scale line and the full scale line positions and the corresponding deflection angles of the dial image obtained in step A are detected; step E: the range of the dial image obtained in step A is automatically acquired; and step F: reading calculation is automatically completed. The application can accurately detect the positions of the pointer and the scale line of the precision pressure gauge based on the pixel distribution characteristics of the pointer and the scale line, can effectively reduce the misrecognition caused by light or dial background interference, and has high robustness and practicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image processing and computer vision technology, and relates to an automatic reading method and device for precision pressure gauges for instrument detection. Background Technology

[0002] Precision pressure gauges are widely used in engineering design, scientific research, manufacturing, and energy development. They can be used to measure the pressure of various liquids or gases, such as water, oil, gas, and steam. Precision pressure gauges can also be used to measure the pressure in mechanical equipment, such as engines, hydraulic systems, and pneumatic systems. There are many types of precision pressure gauges, mainly divided into mechanical and electronic types. Mechanical precision pressure gauges measure pressure using springs or loads, and the reading is usually displayed by a pointer. Electronic precision pressure gauges use pressure sensors and microprocessors to measure pressure and display the reading digitally. Data acquisition for electronic precision pressure gauges is relatively simple, while readings for mechanical precision pressure gauges mostly require manual operation, which is tedious, inefficient, and can easily lead to fatigue over time, affecting the accuracy of data acquisition. With the development of technology, in order to improve productivity and liberate humans from tedious manual reading, automatic reading of pointer-type instruments has become a new research area. Examples include real-time measurement and monitoring of instrument data in unmanned factories; and calibration of newly produced instruments to ensure that their accuracy meets industry standards.

[0003] Currently, automatic reading methods for precision pressure gauges based on computer vision mainly utilize digital image processing techniques and deep learning algorithms. Digital image processing preprocesses and segments the instrument image, then locates and identifies the pointer. Common image processing methods include edge detection, binarization, filtering, and morphological processing. However, these algorithms are often subject to limitations, requiring continuous parameter adjustments to achieve good detection results; furthermore, their general applicability is poor—parameters adjusted for one image often yield poor results when applied to other images. Another common approach is to train and classify instrument images using deep learning algorithms to achieve automatic pointer recognition and reading. However, this method requires a large dataset to train the network weights, which is often difficult to obtain in the field, and the accuracy of the trained detection results is also difficult to control. Summary of the Invention

[0004] The technical problem to be solved by this invention is to address the shortcomings of current automatic reading methods for precision pressure gauges by proposing an automatic reading method for precision pressure gauges oriented towards instrument testing, so as to accurately complete the automatic reading of instruments.

[0005] To achieve the above objectives, the technical solution adopted by the present invention is: an automatic reading method for precision pressure gauges for instrument testing, comprising:

[0006] Step A: Preprocess the instrument image captured by the camera and crop it to obtain the dial image;

[0007] Step B: For the dial image preprocessed in Step A, detect its dial center;

[0008] Step C: For the dial image preprocessed in Step A, detect its pointer direction and pointer deflection angle;

[0009] Step D: For the dial image preprocessed in Step A, detect the positions of its zero mark and full mark, as well as the corresponding deflection angle;

[0010] Step E: Automatically acquire the range of the dial image after preprocessing in Step A;

[0011] Step F: Automatically complete the reading calculation.

[0012] This invention proposes a method for detecting instrument pointers and scale lines based on pixel distribution characteristics. This method can accurately detect pointers and scale lines even under conditions affected by lighting or background interference on the dial, and automatically identify the instrument's range before automatically calculating the reading. This invention effectively solves the problems existing in current automatic reading methods for precision pressure gauges, reduces labor costs, promotes the development of smart factories and other industries, and better applies science and technology to production practice.

[0013] Furthermore, the specific processing procedure of step A is as follows:

[0014] Step A1: First, acquire the data of the H, S, and V channels of the outer frame of the precision pressure gauge in the image, which is a range value (H... min H max ), (S min ,S max ) and (V min V max );

[0015] Step A2: Using the range value obtained in Step A1 as a threshold, perform HSV color thresholding on the RGB image captured by the camera to obtain a binary image of the instrument panel. Specifically, for any pixel K(x,y) in the RGB image, if the corresponding H... k S k and V k If all three pixel value components are within the threshold range, then the pixel value K(x,y) of that point is set to 255; otherwise, the pixel value K(x,y) of that point is set to 0. By traversing all pixels in the RGB image, a binary image of the instrument panel is obtained.

[0016]

[0017] Step A3: Use morphological operations to process the obtained binary image to make the outer frame of the precision pressure gauge in the binary image more complete; then perform filtering to remove noise outside the dial area.

[0018] Step A4: Find the largest contour in the binary image after processing in step A3, select the bounding rectangle of the contour, and crop the corresponding area of ​​the bounding rectangle in the original RGB image to obtain the RGB dial image IMG_ROI of the precision pressure gauge.

[0019] Furthermore, the specific processing procedure of step B is as follows:

[0020] Step B: Use the center of the cropped dial image IMG_ROI as the center of the dial circle O(x) O ,y O The formula is as follows:

[0021]

[0022] Among them, IMG_ROI width and IMG_ROI height These represent the width and height of the cropped dial image, respectively.

[0023] Furthermore, the specific processing procedure of step C is as follows:

[0024] Step C1: Expand the threshold range obtained in step A1 to (0, H) max (0,S) max ) and (0,V max The RGB dial image obtained in step A4 is segmented using this threshold to obtain a binary image of the ROI.

[0025] Step C2: Set the convolution kernel to a 3×3 square and dilate the binary image of the dial obtained in step C1 to obtain a binary image with better connectivity.

[0026] Step C3: Extract the contour from the binary image obtained in step C2, find the part of the contour that has an aspect ratio of approximately square and the longest length, which is the boundary contour of the dial image, and obtain the coordinates p(x,y) of all points on the contour.

[0027] Step C4: Convert the RGB dial image obtained in step A4 to grayscale to obtain a grayscale image. Calculate the mean grayscale value of all boundary contour points obtained in step C3. As the threshold for binarizing the grayscale image in step C4, the binary image of the dial image is obtained; specifically: for any point G(x,y) in the grayscale image in step C4, if its corresponding grayscale value G(x,y) is less than the threshold, it is reassigned to 0; otherwise, it is reassigned to 255; for any point R(x,y) in the dial image, the formula for converting the R, G, and B pixel values ​​of that point to grayscale value Gray is:

[0028] Gray=R*0.299+G*0.587+B*0.114 (3)

[0029] The formula for calculating the average gray value of boundary contour points is as follows:

[0030]

[0031] Among them, Gray p(x,y) p(x,y) represents the grayscale value corresponding to p(x,y), and n represents the number of boundary points on the dial.

[0032] The formula for reassigning grayscale images is as follows:

[0033]

[0034] Step C5: In the binary image of the dial image obtained in step C4, for any coordinate point a(x,y) in the boundary contour of the dial image, use the coordinates of this point and the center coordinates O(x,y) obtained in step B. O ,y O Construct a straight line from the two endpoints, then use a line iterator to traverse each point on the line and obtain the sum of the grayscale values ​​of all pixels on the line. gray_a By traversing all points in the boundary contour, the sum of the gray values ​​of all pixels on each straight line can be obtained;

[0035] Sum of the grayscale values ​​of all pixels along the line connecting coordinate point a(x,y) and the center of the circle. gray_a The calculation formula is as follows:

[0036] Sum gray_a =∑ (u,v)∈α gray (u,v) (6)

[0037] Where α represents the set of coordinates of all pixels along the line, gray (u,v) Let β represent the grayscale value corresponding to pixel (u,v); assuming β represents the set of all contour points on the boundary of the dial image, and i is a contour point in set β, then the set ω, which is the sum of the grayscale values ​​along the line connecting all contour points to the center of the circle, is calculated as follows:

[0038] ω={Sum gray_i|i∈β} (7)

[0039] Step C6: For the set ω of the sum of gray values ​​of all boundary points and the center of the circle obtained in step C5, the boundary contour point corresponding to the smallest sum of gray values ​​is the direction point P(x) of the pointer in the instrument image. P ,y P Connect the point in that direction to the center of the circle, and calculate the slope of the line segment to obtain the deflection angle θ of the pointer. P ;

[0040] P(x P ,y P )={(x,y)|minSum gray_P ∈ω,P∈β} (8)

[0041] pointer deflection angle θ P The calculation formula is as follows:

[0042]

[0043] Furthermore, the specific processing procedure of step D is as follows:

[0044] Step D1: Crop the RGB dial image obtained in step A4 into four equal parts to obtain a partial image Pic containing the zero mark in the lower left corner. RGB_L And the partial image Pic containing full-scale tick marks in the lower right corner. RGB_R ;

[0045] Step D2: The local image Pic containing the zero-scale line obtained in step D1... RGB_L Pic is obtained by grayscale conversion. GRAY_L The system detects partial boundary points of the dial in the grayscale image, and the fan-shaped area formed by these partial boundary points and the center of the circle contains the zero scale line.

[0046] Step D2 specifically includes the following steps:

[0047] Step D21: For the grayscale image Pic obtained in step D2 GRAY_L The process iterates through the pixels row by row from left to right. For each pixel, first check its grayscale value. If it's greater than 50, change the grayscale value to 255; otherwise, change it to 0. Then, check the changes in adjacent pixels. If the previous pixel (x) is present... prev ,y prev The first pixel is white, and the next pixel (x) is white. now ,y now If the color is black, it is considered that a dial boundary point (x) has been detected. bound ,y bound The formula for determining boundary points is as follows:

[0048]

[0049] Where bound represents the set of all detected dial boundary points;

[0050] Step D22: Simultaneously limit the angle range of the boundary points (θ) min ,θ max ), such that the angle range includes the angle θ of the target zero mark. L After detecting the boundary point of the dial, calculate the angle θ between that point and the center of the circle. temp If the angle is within the range of the defined boundary point angle, it is retained; otherwise, it is discarded and not considered.

[0051] θ min <θ L <θ max (11)

[0052]

[0053]

[0054] Where γ represents the image Pic RGB_L A set of partial boundary points within a defined range of boundary point angles;

[0055] Step D3: After obtaining the partial boundary point set γ of the dial image in step D2, for a certain point in this boundary point set, connect this point to the center O(x) of the circle. O ,y O A straight line L is obtained by using the two endpoints as the two points. i Calculate the sum of gray values ​​(Sum) of all pixels along a 3 / 4-length straight line starting from that point. gray_L_i By iterating through this set of boundary points, the sum of the grayscale values ​​of all pixels within a specified range can be obtained. gray_L ;

[0056]

[0057]

[0058] Among them, gray (u,v) This represents the grayscale value of point (u,v).

[0059] Step D4: Calculate the average of the sums of the grayscale values ​​of all pixels within the specified range obtained in Step D3. Use it as a candidate threshold T for binarizing the grayscale image obtained in step D2. L ;

[0060]

[0061] Where n is the total number of boundary points in set γ, and m is any straight line L formed by connecting them. i The total number of pixels;

[0062] Step D5: The local image Pic containing the full-scale tick marks obtained in step D1... RGB_R Perform grayscale processing and detect the grayscale image Pic. GRAY_R The boundary points of the middle dial, and the fan-shaped area formed by these boundary points and the center of the circle contains the full scale line;

[0063] Step D5 specifically includes the following steps:

[0064] Step D51: For the grayscale image Pic obtained in step D5 GRAY_R The process iterates through the pixels row by row from right to left. For each pixel, the grayscale value is first checked. If it is greater than 50, the grayscale value is changed to 255. If it is less than 50, the grayscale value is changed to 0. Then, the changes of adjacent pixels are checked. If the previous pixel is white and the next pixel is black, it is considered that the dial boundary point has been detected.

[0065] Step D52: Simultaneously limit the angle range of the boundary points (α) min ,α max This ensures that the angular range includes the angle θ at the full scale. R After detecting the boundary point of the dial, calculate the angle θ between that point and the center of the circle. temp If the angle is within the specified range, it will be retained; otherwise, it will be discarded and not considered.

[0066] α min <θ R <α max (17)

[0067]

[0068] in, Representative image Pic RGB_R The set of boundary points within a defined angular range;

[0069] Step D6: After obtaining some boundary points of the dial image in step D5, for this set of boundary points... Given a point in the circle, and using that point and the center of the circle as its two endpoints, we can obtain a straight line R. i Calculate the sum of gray values ​​(Sum) of all pixels along a 3 / 4-length straight line starting from that point. gray_R_i By iterating through this set of boundary points, the sum of the grayscale values ​​of all pixels within a specified range can be obtained. gray_R ;

[0070]

[0071]

[0072] Step D7: Sum the gray values ​​of all pixels within the specified range obtained in Step D6 and calculate the average. Use it as the candidate threshold T for binarizing the grayscale image obtained in step D5. R ;

[0073]

[0074] Where w is a set The total number of boundary points, where e is any straight line R connected by these points. i The total number of pixels;

[0075] Step D8: The two candidate thresholds T obtained in steps D4 and D7 L and T R In this process, a larger candidate threshold is selected as the actual threshold T for binarizing the grayscale image in steps D2 and D5. true This is used to obtain the binary images Pic of the lower left and lower right corners of the dial image. BIN_L and Pic BIN_R ;

[0076]

[0077] Step D9: First, perform erosion processing on the binary image obtained in step D8 with a convolution kernel of 3.5×3.5, and then perform dilation processing with a convolution kernel of 2×2; accurately detect the zero scale line and the full scale line in the lower left and lower right binary images after processing, and calculate their angles.

[0078] Furthermore, step D9 specifically includes the following steps:

[0079] Step D91: In the processed bottom left and bottom right binary images Pic BIN_L and Pic BIN_R In the process, starting from the local boundary points detected in steps D2 and D5, the pixels are traversed sequentially from bottom to top. First, the boundary of pixels changing from black to white is detected. After detection, the strategy is changed to detect the boundary points changing from white to black while counting the number of white pixels passed through. In the binary image above, after a black pixel changes to a white pixel, the point with the smallest number of white pixels passed through during the first change from white to black is a point on the zero mark or the full mark.

[0080]

[0081]

[0082] Where γ represents the image Pic RGB_L Within a defined range of boundary point angles, for the binary image Pic at the lower left corner... BIN_L Any dial boundary point P L Following the above strategy, the number of white pixels obtained by traversing the image is: ξ is the set of white pixel counts, where the boundary point with the fewest white pixel counts is L(x). L ,y L ); Representative image (Pic) RGB_R Within a defined angular range, the set of boundary points for the lower right binary image Pic BIN_R Any dial boundary point P R Following the above strategy, the number of white pixels obtained by traversing the image is: ψ represents the set of white pixel counts, where the boundary point with the fewest white pixel counts is R(x). R ,y R );

[0083] Step D92: Accurately detect point L(x) on the zero mark. L ,y L ) and point R(x) on the full scale. R ,y R After that, the distance between the two points and the center O(x) of the circle can be calculated. O ,y O The angle of inclination of the connecting line, where the zero-degree line is deflected at an angle θ. L and the full-scale deflection angle θ R The calculation formula is:

[0084]

[0085]

[0086] Furthermore, step E specifically includes the following steps:

[0087] Step E1: After obtaining the partial dial image containing the full-scale lines in step D1, perform OCR text recognition on the image; by traversing the string, use regular expressions to search for and extract the range data R from the string. range .

[0088] Furthermore, step F specifically includes the following steps:

[0089] Step F1: Based on the range automatically obtained in step E1, the zero-scale deflection angle θ obtained in step D9... L Full-scale line deflection angle θ R and pointer deflection angle θP This allows for the accurate calculation of the precision pressure gauge reading R at that moment. result The calculation formula is as follows:

[0090]

[0091] Another technical solution adopted in this invention is: an automatic reading device for precision pressure gauges for instrument testing, including a processor, wherein the processor uses the above-mentioned automatic reading method for precision pressure gauges to realize automatic reading of precision pressure gauges.

[0092] Furthermore, the aforementioned automatic reading device for precision pressure gauges for instrument testing also includes an image acquisition module for acquiring instrument images; the processor completes the automatic reading of the precision pressure gauge based on the instrument images acquired by the image acquisition module.

[0093] This invention can accurately detect the readings of precision pressure gauges even under conditions of light interference and dial background interference, effectively completing the task of automatic reading.

[0094] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0095] This invention relates to an automatic reading method and device for precision pressure gauges for instrument testing, which has the following advantages: 1) It accurately detects the pointer in the dial based on the pixel characteristics of the pointer, effectively reducing misidentification caused by light or dial background interference; 2) It detects and locates the scale lines based on the pixel distribution characteristics of the zero and full scale lines, and most of the algorithm parameters can be adaptively adjusted, maintaining a high detection rate even with some interference; 3) It can automatically identify the range of the target instrument without manual input, further demonstrating the intelligence of the algorithm; 4) The pointer detection and scale line detection methods in this method have high robustness, and their performance in testing is significantly better than conventional algorithms, demonstrating strong practicality. Attached Figure Description

[0096] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0097] Figure 1 This is a flowchart of an automatic reading method for precision pressure gauges for instrument testing in an example of the present invention. Detailed Implementation

[0098] 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 of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0099] The following embodiment demonstrates the automatic reading of a precision pressure gauge; the complete process is as follows: Figure 1 As shown.

[0100] Example 1

[0101] This embodiment provides an automatic reading method for precision pressure gauges for instrument testing, including the following steps:

[0102] Step A: Preprocess the instrument image captured by the camera and crop it to obtain the dial image;

[0103] Step B: Based on the preprocessed dial image from Step A, detect the center of the dial circle;

[0104] Step C: Based on the dial image preprocessed in Step A, detect its pointer direction and pointer deflection angle;

[0105] Step D: Based on the dial image preprocessed in Step A, detect the positions of its zero mark and full mark, as well as the corresponding deflection angle;

[0106] Step E: Based on the dial image preprocessed in Step A, automatically obtain its range;

[0107] Step F: Automatically complete the reading calculation.

[0108] Example 2

[0109] Based on Example 1, the specific processing procedure of step A in this embodiment is as follows:

[0110] Step A1: First, acquire the data of the H, S, and V channels of the outer frame of the precision pressure gauge in the image. This is typically a range of values ​​(H... min H max ), (S min ,S max ) and (V min V max );

[0111] Step A2: Using the range value obtained in Step A1 as a threshold, perform HSV color thresholding on the RGB image captured by the camera to obtain a binary image of the instrument panel; specifically: for any pixel k(x,y) in the RGB image, if the H value corresponding to that pixel is... k Sk and V k If all three pixel value components are within the threshold range, then the pixel value K(x,y) of that point is set to 255; otherwise, the pixel value K(x,y) of that point is set to 0. By traversing all pixels in the RGB image, a binary image of the instrument panel is obtained.

[0112]

[0113] Step A3: Then, morphological operations such as erosion and dilation are used to process the obtained binary image to make the outer frame of the precision pressure gauge in the binary image more complete; then filtering is performed to remove noise outside the dial area.

[0114] Step A4: Find the largest contour in the binary image after processing in step A3, select the bounding rectangle of the contour, and crop the corresponding area of ​​the bounding rectangle in the original RGB image to obtain the RGB dial image IMG_ROI of the precision pressure gauge.

[0115] Example 3

[0116] Based on Example 2, the specific processing procedure of step B in this embodiment is as follows:

[0117] Use the center of the cropped dial image IMG_ROI as the center O(x) of the dial circle. O ,y O The formula is as follows:

[0118]

[0119] Among them, IMG_ROI width and IMG_ROI height These represent the width and height of the cropped dial image, respectively.

[0120] Example 4

[0121] Based on Example 3, the specific processing procedure of step C in this embodiment is as follows:

[0122] Step C1: Expand the threshold range obtained in step A1 to (0, H) max (0,S) max ) and (0,V max The RGB dial image IMG_ROI obtained in step A4 is segmented using this threshold to obtain a binary image of the dial image.

[0123] Step C2: Set the convolution kernel to a 3×3 square and dilate the binary image of the dial obtained in step C1 to obtain a binary image with better connectivity.

[0124] Step C3: Extract the contours from the binary image obtained in step C2, select the bounding rectangles of all contours, find the contour with the largest perimeter and the bounding rectangle that is approximately square, which is the boundary contour of the dial image, and obtain the coordinates p(x,y) of all points on the contour.

[0125] Step C4: Convert the RGB dial image obtained in step A4 to grayscale to obtain a grayscale image. Calculate the mean grayscale value of all boundary contour points obtained in step C3. As the threshold for binarizing the grayscale image in step C4, the binary image of the dial image is obtained; specifically: for any point g(x,y) in the grayscale image in step C4, if its corresponding grayscale value G(x,y) is less than the threshold, it is reassigned to 0; otherwise, it is reassigned to 255; for any point R(x,y) in the dial image, the formula for converting the R, G, and B pixel value components of that point to grayscale value Gray is:

[0126] Gray=R*0.299+G*0.587+B*0.114 (3)

[0127] The formula for calculating the average gray value of boundary contour points is as follows:

[0128]

[0129] Among them, Gray p(x,y) p(x,y) represents the grayscale value, and n represents the number of boundary points on the dial.

[0130] The formula for reassigning grayscale images is as follows:

[0131]

[0132] Step C5: In the binary image of the dial image obtained in step C4, for any coordinate point a(x,y) in the boundary contour of the dial image, use the coordinates of this point and the center coordinates O(x,y) obtained in step B. O ,y O Construct a straight line from the two endpoints, then use a line iterator to traverse each point on the line and obtain the sum of the grayscale values ​​of all pixels on the line. gray_a By traversing all points in the boundary contour, the sum of the gray values ​​of all pixels on each straight line can be obtained;

[0133] Sum of the grayscale values ​​of all pixels along the line connecting coordinate point a(x,y) and the center of the circle. gray_a The calculation formula is as follows:

[0134] Sum gray_a =∑ (u,v)∈α gray (u,v) (6)

[0135] Where α represents the set of coordinates of all pixels along the connection line, gray (u,v) Let β represent the grayscale value corresponding to pixel (u,v). Assuming β represents the set of all contour points on the boundary of the dial image, and i is a contour point in set β, then the set ω, the sum of the grayscale values ​​along the line connecting all contour points to the center of the circle, is calculated as follows:

[0136] ω={Sum gray_i |i∈β} (7)

[0137] Step C6: For the set ω of the sum of gray values ​​of all boundary points and the center of the circle obtained in step C5, the boundary contour point with the smallest sum of gray values ​​is the direction point P(x) of the pointer in the instrument image. P ,y P Connect the point to the center of the circle and calculate the slope of the line segment to obtain the pointer deflection angle θ. P ;

[0138] P(x,y)={(x,y)|minSum gray_P ∈ω,P∈β} (8)

[0139] pointer deflection angle θ P The calculation formula is as follows:

[0140]

[0141] Example 5

[0142] Based on Example 4, the specific processing procedure of step D in this embodiment is as follows:

[0143] Step D1: Crop the RGB dial image obtained in step A4 into four equal parts to obtain a partial image Pic containing the zero mark in the lower left corner. RGB_L And the partial image Pic containing full-scale tick marks in the lower right corner. RGB_R ;

[0144] Step D2: The local image Pic containing the zero mark obtained in step D1... RGB_L Pic is obtained by grayscale processing. GRAY_L The system detects partial boundary points of the dial in the grayscale image, and the fan-shaped area formed by the boundary points and the center of the circle contains the zero mark line.

[0145] Step D2 specifically includes the following steps:

[0146] Step D21: For the grayscale image Pic obtained in step D2 GRAY_LThe process iterates through the pixels row by row from left to right. For each pixel, first check its grayscale value. If it's greater than 50, change the grayscale value to 255; otherwise, change it to 0. Then, check the changes in adjacent pixels. If the previous pixel (x) is present... prev ,y prev The first pixel is white, and the next pixel (x) is white. now ,y now If the color is black, it is considered that a dial boundary point (x) has been detected. bound ,y bound The formula for determining boundary points is as follows:

[0147]

[0148] Where bound represents the set of all detected dial boundary points;

[0149] Step D22: Simultaneously limit the angle range of the boundary points (θ) min ,θ max ), such that the angle range includes the angle θ of the target zero mark. L After detecting the boundary point of the dial, calculate the angle θ between that point and the center of the circle. temp If the angle is within the specified range, it will be retained; otherwise, it will be discarded and not considered.

[0150] θ min <θ L <θ max (11)

[0151]

[0152]

[0153] Where γ represents the image Pic RGB_L The set of boundary points within a defined angular range;

[0154] Step D3: After obtaining the partial boundary point set γ of the dial image in step D2, for a certain point in this boundary point set, connect this point to the center O(x) of the circle. O ,y O A straight line L is obtained by using the two endpoints as the two points. i Calculate the sum of gray values ​​(Sum) of all pixels along a 3 / 4-length straight line starting from that point. gray_L_i By iterating through this set of boundary points, the sum of the grayscale values ​​of all pixels within a specified range can be obtained. gray_L ;

[0155]

[0156]

[0157] Among them, gray (u,v) This represents the grayscale value of point (u,v).

[0158] Step D4: Calculate the average of the sums of the grayscale values ​​of all pixels within the specified range obtained in Step D3. Make it

[0159] The candidate threshold T for binarizing the grayscale image obtained in step D2 L ;

[0160]

[0161] Where n is the total number of boundary points in set γ, and m is any straight line L formed by connecting them. i The total number of pixels;

[0162] Step D5: The local image Pic containing the full-scale tick marks obtained in step D1... RGB_R Perform grayscale processing and detect the grayscale image Pic. GRAY_R The boundary point of the middle dial, and the fan-shaped area formed by the boundary point and the center of the circle contains the full scale line;

[0163] Step D5 specifically includes the following steps:

[0164] Step D51: For the grayscale image Pic obtained in step D5 GRAY_R The process iterates through the pixels row by row from right to left. For each pixel, the grayscale value is first checked. If it is greater than 50, the grayscale value is changed to 255. If it is less than 50, the grayscale value is changed to 0. Then, the changes of adjacent pixels are checked. If the previous pixel is white and the next pixel is black, it is considered that the dial boundary point has been detected.

[0165] Step D52: Simultaneously limit the angle range of the boundary points (α) min ,α max This ensures that the angular range includes the angle θ at the full scale. R After detecting the boundary point of the dial, calculate the angle θ between that point and the center of the circle. temp If the angle is within the specified range, it will be retained; otherwise, it will be discarded and not considered.

[0166] α min <θ R <α max (17)

[0167]

[0168] in Representative image Pic RGB_RThe set of boundary points within a defined angular range;

[0169] Step D6: After obtaining some boundary points of the dial image in step D5, for this set of boundary points... Given a point in the circle, and using that point and the center of the circle as its two endpoints, we can obtain a straight line R. i Calculate the sum of gray values ​​(Sum) of all pixels along a 3 / 4-length straight line starting from that point. gray_R_i By iterating through this set of boundary points, the sum of the grayscale values ​​of all pixels within a specified range can be obtained. gray_R ;

[0170]

[0171]

[0172] Step D7: Sum the gray values ​​of all pixels within the specified range obtained in Step D6 and calculate the average. Use it as the candidate threshold T for binarizing the grayscale image obtained in step D5. R ;

[0173]

[0174] Where w is a set The total number of boundary points, where e is any straight line R connected by these points. i The total number of pixels;

[0175] Step D8: The two candidate thresholds T obtained in steps D4 and D7 L and T R In this process, a larger candidate threshold is selected as the actual threshold T for binarizing the grayscale image in steps D2 and D5. true This is used to obtain the binary images Pic of the lower left and lower right corners of the dial image. BIN_L and Pic BIN_R ;

[0176]

[0177] Step D9: First, perform erosion processing on the binary image obtained in step D8 with a convolution kernel of 3.5×3.5, and then perform dilation processing with a convolution kernel of 2×2; accurately detect the zero scale line and the full scale line in the lower left and lower right binary images after processing, and calculate their angles.

[0178] Example 6

[0179] Based on Example 5, step D9 in this embodiment specifically includes the following steps:

[0180] Step D91: In the processed bottom left and bottom right binary images Pic BIN_L and Pic BIN_R In the process, starting from the local boundary points detected in steps D2 and D5, the pixels are traversed sequentially from bottom to top. First, the boundary of pixels changing from black to white is detected. After detection, the strategy is changed to detect the boundary points changing from white to black while counting the number of white pixels passed through. In the binary image above, after a black pixel changes to a white pixel, the point with the smallest number of white pixels passed through during the first change from white to black is a point on the zero mark or the full mark.

[0181]

[0182]

[0183] Where γ represents the image Pic RGB_L Within a defined range of boundary point angles, for the binary image Pic at the lower left corner... BIN_L Any dial boundary point P L Following the above strategy, the number of white pixels obtained by traversing the image is Sum. PL Let ξ be the set of white pixel counts, where the boundary point with the fewest white pixels is L(x). L ,y L ); Representative image (Pic) RGB_R Within a defined angular range, the set of boundary points for the lower right binary image Pic BIN_R Any dial boundary point P R Following the above strategy, the number of white pixels obtained by traversing the image is: ψ represents the set of white pixel counts, where the boundary point with the fewest white pixel counts is R(x). R ,y R );

[0184] Step D92: Accurately detect point L(x) on the zero mark. L ,y L ) and point R(x) on the full scale. R ,y R After that, the distance between the two points and the center O(x) of the circle can be calculated. O ,y O The angle of inclination of the connecting line, where the zero-degree line is deflected at an angle θ. L and the full-scale deflection angle θ R The calculation formula is:

[0185]

[0186]

[0187] Example 7

[0188] Based on Example 6, the specific processing procedure of step E in this embodiment is as follows:

[0189] Step E1: After obtaining the partial dial image containing the full-scale lines in step D1, perform OCR text recognition on the image; by traversing the string, use regular expressions to search for and extract the range data R from the string. range .

[0190] Example 8

[0191] Based on Example 7, the specific processing procedure of step F in this embodiment is as follows:

[0192] Step F1: Based on the range automatically obtained in step E1, the zero-scale deflection angle θ obtained in step D9. L and the full-scale deflection angle θ R and the pointer deflection angle θ obtained in step C6 P This allows for the accurate calculation of the precision pressure gauge reading R at that moment. result The calculation formula is as follows:

[0193]

[0194] Example 9

[0195] This embodiment provides an automatic reading device for precision pressure gauges for instrument testing, including an image acquisition module. The acquisition of instrument images is controlled by a program, and the automatic reading method for precision pressure gauges for instrument testing described above is used to realize the automatic reading of precision pressure gauges.

[0196] Experimental samples were used to verify the effectiveness of the invention. The results show that the invention can still accurately complete pointer detection and reading results even when the input image is not ideal (uniform lighting, background interference, etc.). The method of the present invention can simultaneously meet the requirements of robustness, accuracy, and does not require strict control of auxiliary information such as lighting conditions and imaging angles for image imaging, making it highly practical.

Claims

1. A method for automatically reading precision pressure gauges for instrument testing, characterized in that, include: Step A: Preprocess the instrument image captured by the camera and crop it to obtain the dial image; Step B: For the dial image preprocessed in Step A, detect its dial center; Step C: For the dial image preprocessed in Step A, detect its pointer direction and pointer deflection angle; Step D: For the dial image preprocessed in Step A, detect the positions of its zero mark and full mark, as well as the corresponding deflection angle; Step E: Automatically acquire the range of the dial image after preprocessing in Step A; Step F: Automatically complete the reading calculation; The specific processing procedure for step A is as follows: Step A1: First, obtain the outer frame of the precision pressure gauge in the image. H , S , V The data from the three channels represents a range of values. , and ; Step A2: Using the range value obtained in Step A1 as a threshold, perform HSV color thresholding on the RGB image captured by the camera to obtain a binary image of the instrument panel. Specifically, for any pixel in the RGB image... If the pixel corresponds to H k , S k and V k If all three pixel value components are within the threshold range, then the pixel value of that point is... Set to 255; otherwise, set the pixel value of this point. Set it to 0, and obtain the binary image of the instrument panel by traversing all pixels in the RGB image; (1) Step A3: Use morphological operations to process the obtained binary image to make the outer frame of the precision pressure gauge in the binary image more complete; then perform filtering to remove noise outside the dial area. Step A4: Find the largest contour in the binary image processed in Step A3, select the bounding rectangle of the contour, and crop the corresponding area of ​​the bounding rectangle in the original RGB image to obtain the RGB dial image of the precision pressure gauge. ; The specific processing procedure for step D is as follows: Step D1: Crop the RGB dial image obtained in step A4 into four equal parts to obtain a partial image containing the zero mark in the lower left corner. And the partial image in the lower right corner containing the full-scale tick marks. ; Step D2: Extract the local image containing the zero-scale line obtained in Step D1. Grayscale image is obtained by grayscale conversion. The system detects partial boundary points of the dial in the grayscale image, and the fan-shaped area formed by these partial boundary points and the center of the circle contains the zero scale line. Step D2 specifically includes the following steps: Step D21: For the grayscale image obtained in step D2 The process iterates through the pixels row by row from left to right. For each pixel, first check its grayscale value. If it's greater than 50, change the grayscale value to 255; otherwise, change it to 0. Then, check the changes in adjacent pixels. If the previous pixel's value is present... It is white, the next pixel. If it is black, it means that a dial boundary point has been detected. The formula for determining boundary points is as follows: (10) in, This represents the set of all detected dial boundary points; Step D22: Simultaneously limit the angle range of the boundary points This ensures that the angle range includes the target zero mark. After detecting the boundary point of the dial, calculate the angle between that point and the line connecting the center of the circle. If the angle is within the range of the defined boundary point angle, it is retained; otherwise, it is discarded and not considered. (11) (12) (13) in, Representative image A set of partial boundary points within a defined range of boundary point angles; Step D3: Obtain the set of partial boundary points of the dial image in step D2. Then, for any point in this set of boundary points, compare that point with the center of the circle. A straight line is obtained from the two endpoints. Calculate the sum of the gray values ​​of all pixels along a 3 / 4-length straight line starting from that point. By traversing this set of boundary points, the sum of the grayscale values ​​of all pixels within the specified range can be obtained. ; (14) (15) in, Point grayscale value; Step D4: Calculate the average of the sums of the grayscale values ​​of all pixels within the specified range obtained in Step D3. This is used as a candidate threshold for binarizing the grayscale image obtained in step D2. ; (16) in, For set The total number of boundary points, For any straight line The total number of pixels; Step D5: Extract the local image containing the full-scale tick marks obtained in step D1. Perform grayscale processing and detect the grayscale image. The boundary points of the middle dial, and the fan-shaped area formed by these boundary points and the center of the circle contains the full scale line; Step D5 specifically includes the following steps: Step D51: For the grayscale image obtained in step D5 The process iterates through the pixels row by row from right to left. For each pixel, the grayscale value is first checked. If it is greater than 50, the grayscale value is changed to 255. If it is less than 50, the grayscale value is changed to 0. Then, the changes of adjacent pixels are checked. If the previous pixel is white and the next pixel is black, it is considered that the dial boundary point has been detected. Step D52: Simultaneously limit the angle range of the boundary points This ensures that the angle range includes the angles at full scale. After detecting the boundary point of the dial, calculate the angle between that point and the line connecting the center of the circle. If the angle is within the specified range, it will be retained; otherwise, it will be discarded and not considered. (17) (18) in, Representative image The set of boundary points within a defined angular range; Step D6: After obtaining some boundary points of the dial image in step D5, for this set of boundary points... Find a point in the circle and use that point and the center of the circle as their two endpoints to obtain a straight line. Calculate the sum of the gray values ​​of all pixels along a 3 / 4-length straight line starting from that point. By traversing this set of boundary points, the sum of the grayscale values ​​of all pixels within the specified range can be obtained. ; (19) (20) Step D7: Sum the gray values ​​of all pixels within the specified range obtained in Step D6 and calculate the average. This is used as a candidate threshold for binarizing the grayscale image obtained in step D5. ; (21) in, For set The total number of boundary points, For any straight line The total number of pixels; Step D8: The two candidate thresholds obtained in steps D4 and D7 and In step D2 and D5, a larger candidate threshold is selected as the actual threshold for binarizing the grayscale image. This is used to obtain binary images of the lower left and lower right corners of the dial image. and ; (22) Step D9: First, perform erosion processing on the binary image obtained in step D8 with a convolution kernel of 3.5×3.5, and then perform dilation processing with a convolution kernel of 2×2; accurately detect the zero scale line and the full scale line in the lower left and lower right binary images after processing, and calculate their angles.

2. The method for automatic reading of precision pressure gauges for instrument testing according to claim 1, characterized in that, The specific processing procedure for step B is as follows: The cropped dial image The center is used as the center of the dial. The formula is as follows: (2) in, and These represent the width and height of the cropped dial image, respectively.

3. The method for automatic reading of precision pressure gauges for instrument testing according to claim 1, characterized in that, The specific processing procedure for step C is as follows: Step C1: Expand the threshold range obtained in step A1 to , and The RGB dial image obtained in step A4 Use this threshold for segmentation to obtain a binary image of the dial. Step C2: Set the convolution kernel to a 3×3 square and dilate the binary image of the dial obtained in step C1 to obtain a binary image with better connectivity. Step C3: Extract the contour from the binary image obtained in step C2, and find the part of the contour that has an aspect ratio of approximately square and the longest length. This part is the boundary contour of the dial image. At the same time, obtain the coordinates of all points on the contour. ; Step C4: Convert the RGB dial image obtained in step A4 to grayscale to obtain a grayscale image. Calculate the mean grayscale value of all boundary contour points obtained in step C3. The threshold value is used as the binarization threshold for the grayscale image in step C4 to obtain the binary image of the dial image; specifically, for any point in the grayscale image in step C4... If its corresponding gray value If the value is less than the threshold, it is reassigned to 0; otherwise, it is reassigned to 255. For any point in the dial image... The R, G, and B pixel values ​​at this point are converted to grayscale values. The formula is: (3) The formula for calculating the average gray value of boundary contour points is as follows: (4) in for The corresponding grayscale value, The number of boundary points on the dial; The formula for reassigning grayscale images is as follows: (5) Step C5: In the binary image of the dial image obtained in step C4, for any coordinate point in the boundary contour of the dial image... Using the coordinates of this point and the center of the circle obtained in step B Construct a straight line for the two endpoints, then use a line iterator to traverse each point on the line, obtaining the sum of the grayscale values ​​of all pixels on the line. By traversing all points in the boundary contour, the sum of the gray values ​​of all pixels on each straight line can be obtained; coordinates The sum of the gray values ​​of all pixels along the line connecting to the center of the circle. The calculation formula is as follows: (6) in, It represents the set of coordinates of all pixels along the line. Represents pixels The corresponding grayscale value; assuming The set representing all contour points of the dial image boundary. i For set Given a given contour point, the set of sums of gray values ​​along the lines connecting all contour points to the center of the circle is given by the contour point itself. The calculation is as follows: (7) Step C6: The sum of the gray values ​​of all boundary points connected to the center of the circle obtained in step C5. The boundary contour point with the smallest sum of gray values ​​corresponds to the direction point of the pointer in the instrument image. Connect the point in that direction to the center of the circle, and calculate the slope of the line segment to obtain the deflection angle of the pointer. ; (8) pointer deflection angle The calculation formula is as follows: (9)。 4. The method for automatic reading of precision pressure gauges for instrument testing according to claim 1, characterized in that, Step D9 specifically includes the following steps: Step D91: In the processed bottom left and bottom right binary images and In the process, starting from the local boundary points detected in steps D2 and D5, the pixels are traversed sequentially from bottom to top. First, the boundary of pixels changing from black to white is detected. After detection, the strategy is changed to detect the boundary points changing from white to black while counting the number of white pixels passed through. In the binary image above, after a black pixel changes to a white pixel, the point with the smallest number of white pixels passed through during the first change from white to black is a point on the zero mark or the full mark. (23) (24) in, Representative image For the binary image at the lower left corner, a set of partial boundary points within a defined boundary point angle range. Any dial boundary point Following the above strategy, the number of white pixels obtained by traversing the image is: , Let be the set of white pixel counts, where the boundary point with the fewest white pixel counts is . ; Representative image For the set of boundary points within a defined angular range, the binary image at the lower right corner... Any dial boundary point Following the above strategy, the number of white pixels obtained by traversing the image is: , Let be the set of white pixel counts, where the boundary point with the fewest white pixel counts is . ; Step D92: Accurately detect the point on the zero mark. and the point on the full scale Then, the distance between the two points and the center of the circle can be calculated. The angle of inclination of the connecting lines, including the angle of deflection of the zero mark. Angle of full scale line The calculation formula is: (25) (26)。 5. The method for automatic reading of precision pressure gauges for instrument testing according to claim 4, characterized in that, Step E specifically includes the following steps: Step E1: After obtaining the partial dial image containing the full-scale lines in step D1, perform OCR text recognition on the image; by traversing the string, use regular expressions to search for and extract the range data from the string. .

6. The method for automatic reading of precision pressure gauges for instrument testing according to claim 5, characterized in that, Step F specifically includes the following steps: Step F1: Based on the range automatically obtained in step E1, the zero-scale deflection angle obtained in step D9. Full scale line deflection angle and pointer deflection angle This allows for accurate calculation of the precision pressure gauge reading at that moment. The calculation formula is as follows: (27) 。 7. An automatic reading device for precision pressure gauges for instrument testing, comprising a processor, characterized in that, The processor employs the precision pressure gauge automatic reading method according to any one of claims 1 to 6 to achieve automatic reading of the precision pressure gauge.

8. The automatic reading device for precision pressure gauges for instrument testing according to claim 7, characterized in that, It also includes an image acquisition module for acquiring instrument images; the processor completes automatic readings of the precision pressure gauge based on the instrument images acquired by the image acquisition module.

Citation Information

Patent Citations

  • Automatic instrument identification method and system

    CN113378814A

  • Transformer arc-shaped oil temperature meter reading method and device based on machine vision

    CN113780142A