An automatic reading method for a pointer-type instrument based on mechanical center-of-circle backstepping and robust calibration

CN123016414APending Publication Date: 2026-10-30CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611268122.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-20
Publication Date
2026-10-30

AI Technical Summary

Benefits of technology

[0020](1)通过数据标准化空间拟合方法,显著提高了倾斜表盘和非理想成像条件下椭圆拟合的数值稳定性与成功率,解决了传统方法在点坐标数值量级差异大时协方差矩阵病态导致拟合失败的核心问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123016414A_ABST
    Figure CN123016414A_ABST
Patent Text Reader

Abstract

The present application relates to computer vision, in particular to a kind of pointer instrument automatic reading method based on mechanical center of circle backstepping and robust calibration, comprising: using segmentation model to detect and segment dial area, extract dial mask point set;After coordinate standardization to mask point set, ellipse fitting is carried out, and dial is corrected to standard positive circle image by perspective transformation;Again, scale text, physical unit and character detection frame in dial are identified, and real mechanical center of circle is identified based on character detection frame;With real mechanical center of circle as origin, dial is converted into horizontal scale image, the area where pointer is located is confirmed, the column pixel projection peak value in this area is determined as pointer position, linear interpolation is carried out according to the angle interval where pointer is located, or extrapolation is carried out outside effective scale range using regression model, and instrument reading is output.The present application can improve the reading accuracy and stability under the scene of tilt, eccentricity, poor illumination and OCR misrecognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer vision, image processing and industrial automation inspection, and in particular to an automatic reading method for pointer instruments based on mechanical center back-calculation and robust calibration. Background Technology

[0002] Pointer-type instruments (such as pressure gauges, thermometers, and flow meters) are widely used in industrial settings. Traditional manual meter reading methods are time-consuming, labor-intensive, subjective, and unsuitable for high-risk environments. With the advancement of intelligent manufacturing, the use of computer vision technology to achieve automatic reading of pointer-type instruments has become an urgent need.

[0003] Existing computer vision-based automatic instrument reading methods typically include the following steps: (1) target detection and dial segmentation; (2) ellipse fitting or circle detection to determine dial geometric parameters; (3) perspective transformation correction; (4) OCR extraction of scale values; (5) pointer position detection; and (6) reading calculation and output. However, existing technologies have significant shortcomings in the following key aspects:

[0004] First, in the ellipse fitting stage, existing methods directly perform least squares or RANSAC ellipse fitting on the coordinate points of the segmentation mask. When the dial tilt angle is large or the magnitude of the point coordinate values ​​is large, the covariance matrix is ​​prone to ill-conditioned behavior, leading to fitting failure or a severe decrease in accuracy.

[0005] Secondly, regarding the positioning of the dial center, existing technologies typically use the geometric center of the ellipse fitting or the centroid of the image contour as the center. However, due to printing process deviations, perspective distortion, or installation errors, the geometric center of the dial often deviates significantly from the actual rotation center of the hands, leading to systematic errors in subsequent polar coordinate unfolding and reading calculations.

[0006] Third, in the OCR recognition stage, existing methods simply convert the OCR output string into a floating-point number. In industrial settings, OCR often makes character recognition errors such as misinterpreting "9" as "6" or omitting decimal points, resulting in abnormal values ​​such as "1015" (actually 10.15) or "0015" (actually 0.015), leading to completely incorrect readings.

[0007] Fourth, in the calibration stage, existing methods directly perform linear interpolation on all identified scale values. Once outliers generated by OCR are mixed in, the interpolation results will deviate significantly from the true values, lacking an effective mechanism for filtering outlier scale values.

[0008] Fifth, in the pointer detection stage, existing methods mostly use Hough line detection or edge detection. In the unfolded ruler image, long strip-shaped unit characters such as "kPa" are easily misdetected as pointers, leading to positioning failure. Summary of the Invention

[0009] To address the shortcomings of existing technologies and improve reading accuracy and stability in scenarios involving tilt, eccentricity, poor lighting, and OCR misidentification, this invention proposes an automatic reading method for pointer-type instruments based on mechanical center back-calculation and robust calibration, specifically including the following steps:

[0010] S1. Obtain the image of the pointer-type instrument to be read, use a pre-trained deep learning segmentation model to infer the input image, detect the dial area and generate the corresponding binary segmentation mask, and extract the set of dial outline pixel coordinates from the mask.

[0011] S2. For the extracted contour point set, calculate the geometric center and scale factor of the contour point set, decenter the point coordinates and uniformly scale them to the standardized space, perform RANSAC ellipse fitting in the standardized space, and then inversely transform the fitting result back to the original image coordinate system to obtain the dial ellipse parameters.

[0012] S3. Calculate the circumscribed rectangle vertices using the ellipse parameters, and calculate the perspective transformation matrix with the square vertices as the target point set to correct the elliptical dial image into a standard circular dial image.

[0013] S4. After performing Gamma correction on the circular dial image, use an OCR model to perform text detection and recognition, extracting the scale values, physical units, and corresponding text detection box coordinates; perform reverse regularization correction processing on the OCR output, including character confusion mapping correction, implicit decimal point regularization completion, and dimension unification alignment based on the statistical mode.

[0014] S5. Calculate the geometric center of each valid scale text detection box as a circumferential sampling point, traverse all sampling point pairs to construct the perpendicular bisector equation, form an overdetermined linear equation system, and solve the mechanical center coordinates by the least squares method; when the ratio of the minor axis to the major axis of the ellipse is greater than the preset threshold, directly use the geometric center of the image as the mechanical center.

[0015] S6. Perform a linear polar coordinate transformation with the mechanical center as the origin, and unfold the circular dial image into a one-dimensional scale image along the circumference.

[0016] S7. Using the cleaned scale value as the dependent variable and its polar coordinate angle relative to the mechanical center as the independent variable, construct a linear regression model, introduce the RANSAC regressor for fitting, extract the inner point mask to actively remove outlier scale points and corresponding detection boxes whose residuals exceed the dynamic threshold, and retain the fitted model for extrapolation calculation.

[0017] S8. Apply CLAHE enhancement, bilateral filtering, OTSU binarization, and morphological opening to the image after polar coordinate transformation in sequence, and then perform connected component analysis. Using the physical prior that the pointer runs through the entire length of the unfolded image, set a double geometric threshold to filter candidate connected components of the pointer: the height is greater than 60% of the image height and the width is less than 15% of the image width. Select the connected component with the largest height among those that meet the conditions, project its mask vertically along the column direction, and take the projection peak index as the pointer's horizontal coordinate.

[0018] S9. Determine whether the pointer's horizontal coordinate falls within the known valid interval of the scale. If it is within the interval, calculate the reading by linear interpolation of the nearest scale point. If it is outside the interval, use the regression model retained in S7 to perform extrapolation calculation. Finally, concatenate the numerical value with the physical unit to output the complete measurement result.

[0019] Compared with existing technologies, the beneficial effects of this invention are as follows:

[0020] (1) By using the data standardization spatial fitting method, the numerical stability and success rate of ellipse fitting under tilted dial and non-ideal imaging conditions are significantly improved, and the core problem of fitting failure caused by ill-conditioned covariance matrix when the numerical magnitude of point coordinates is large is solved.

[0021] (2) By using the mechanical center-inverse method based on the geometric distribution of OCR text, without relying on any pixel grayscale or boundary gradient information, the true rotation axis of the pointer can be accurately solved by using only the geometric topological relationship of the scale marking, which fundamentally eliminates the adverse effects of printing eccentricity and installation deviation on reading accuracy.

[0022] (3) By integrating regular rules and statistical mode scaling, the OCR post-processing correction method can effectively correct common OCR errors such as flipped characters and missing decimal points without additional training data or model fine-tuning, based solely on the prior rules of the physical scale of the dial, greatly improving the reliability of readings under harsh lighting conditions in industrial settings.

[0023] (4) By using the scale-angle global calibration method of RANSAC regression, RANSAC is extended from a traditional "line finding" tool to a "scale cleaning" tool, realizing the automatic detection and active filtering of outlier scale values, thereby ensuring the accuracy of linear interpolation and extrapolation calculation.

[0024] (5) By using the pointer positioning method based on the geometric prior of connected components, the pointer will inevitably pass through the entire length of the unfolded graph. This method replaces the complex Hough transform or edge detection with a simple and efficient geometric threshold screening, effectively avoiding the problem of long characters being misdetected as pointers. Attached Figure Description

[0025] Figure 1A simplified flowchart illustrating the pointer-type instrument reading recognition method provided in this embodiment of the invention. Detailed Implementation

[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0027] This invention proposes an automatic reading method for pointer-type instruments based on mechanical center reverse calculation and robust calibration, specifically including the following steps:

[0028] S1. Obtain the image of the pointer-type instrument to be read, use a pre-trained deep learning segmentation model to infer the input image, detect the dial area and generate the corresponding binary segmentation mask, and extract the set of dial outline pixel coordinates from the mask.

[0029] S2. For the extracted contour point set, calculate the geometric center and scale factor of the contour point set, decenter the point coordinates and uniformly scale them to the standardized space, perform RANSAC ellipse fitting in the standardized space, and then inversely transform the fitting result back to the original image coordinate system to obtain the dial ellipse parameters.

[0030] S3. Calculate the circumscribed rectangle vertices using the ellipse parameters, and calculate the perspective transformation matrix with the square vertices as the target point set to correct the elliptical dial image into a standard circular dial image.

[0031] S4. After performing Gamma correction on the circular dial image, use an OCR model to perform text detection and recognition, extracting the scale values, physical units, and corresponding text detection box coordinates; perform reverse regularization correction processing on the OCR output, including character confusion mapping correction, implicit decimal point regularization completion, and dimension unification alignment based on the statistical mode.

[0032] S5. Calculate the geometric center of each valid scale text detection box as a circumferential sampling point, traverse all sampling point pairs to construct the perpendicular bisector equation, form an overdetermined linear equation system, and solve the mechanical center coordinates by the least squares method; when the ratio of the minor axis to the major axis of the ellipse is greater than the preset threshold, directly use the geometric center of the image as the mechanical center.

[0033] S6. Perform a linear polar coordinate transformation with the mechanical center as the origin, and unfold the circular dial image into a one-dimensional scale image along the circumference.

[0034] S7. Using the cleaned scale value as the dependent variable and its polar coordinate angle relative to the mechanical center as the independent variable, construct a linear regression model, introduce the RANSAC regressor for fitting, extract the inner point mask to actively remove outlier scale points and corresponding detection boxes whose residuals exceed the dynamic threshold, and retain the fitted model for extrapolation calculation.

[0035] S8. Apply CLAHE enhancement, bilateral filtering, OTSU binarization, and morphological opening to the image after polar coordinate transformation in sequence, and then perform connected component analysis. Using the physical prior that the pointer runs through the entire length of the unfolded image, set a double geometric threshold to filter candidate connected components of the pointer: the height is greater than 60% of the image height and the width is less than 15% of the image width. Select the connected component with the largest height among those that meet the conditions, project its mask vertically along the column direction, and take the projection peak index as the pointer's horizontal coordinate.

[0036] S9. Determine whether the pointer's horizontal coordinate falls within the known valid interval of the scale. If it is within the interval, calculate the reading by linear interpolation of the nearest scale point. If it is outside the interval, use the regression model retained in S7 to perform extrapolation calculation. Finally, concatenate the numerical value with the physical unit to output the complete measurement result.

[0037] The main differences between this invention and the prior art are as follows:

[0038] (1) The present invention adopts an ellipse robust fitting method in data-normalized space;

[0039] (2) The present invention is based on the mechanical center least squares back-calculation method of OCR text geometric distribution;

[0040] (3) The present invention adopts an OCR post-processing correction method that integrates regularization rules and statistical mode scaling;

[0041] (4) The present invention adopts a scale-angle global calibration and outlier anchor point active removal method based on RANSAC regression;

[0042] (5) A method for identifying connected component pointers based on the scaling constraints of unfolded graphs;

[0043] These five points are interconnected and together constitute a complete and highly robust technical solution from image input to reading output.

[0044] This embodiment proposes a specific implementation process, such as... Figure 1 Specifically, it includes the following steps:

[0045] S1. Obtain the image of the pointer-type instrument to be read, use the pre-trained YOLOv11-seg deep learning segmentation model to infer the input image, detect the dial area and generate the corresponding binary segmentation mask, and extract the set of dial outline pixel coordinates from the mask.

[0046] S2, the set of dial outline points extracted from S1 Instead of directly fitting an ellipse in the original image coordinate space, it first calculates the geometric center vector of the point set. and peak-to-peak range in each dimension :

[0047]

[0048]

[0049] Where n is the number of pixels in the dial outline point set; Let i be the position of the i-th pixel in the dial outline point set. Let be the x-coordinate of the i-th pixel. Let be the y-coordinate value of the i-th pixel; This represents the difference between the maximum and minimum values ​​of the pixels in the dial outline point set on the x-axis. This represents the difference between the maximum and minimum values ​​of the pixels in the dial outline point set on the y-axis.

[0050] All point coordinates are decentralized and uniformly scaled to a standardized space:

[0051]

[0052] in, This refers to the position of the i-th pixel in the dial outline point set after conversion to the normalized space.

[0053] As an optional implementation, this embodiment calls skimage.measure.ransac and EllipseModel to standardize the point set. As input for RANSAC ellipse fitting, RANSAC ellipse fitting is performed; the minimum number of sampling points (min_samples=5) is set, and the residual threshold is adaptively adjusted to residual_threshold / s with the scaling factor, where the minimum number of sampling points represents the minimum number of sampling points used to build a candidate ellipse model; residual_threshold represents the residual threshold used to distinguish inliers from outliers at the original image coordinate scale; the standardized ellipse parameters are then obtained. ,in This represents the x-axis coordinate value of the center of the ellipse obtained by fitting in the standardized space; This represents the y-axis coordinate value of the center of the ellipse obtained by fitting in the standardized space; This represents the semi-major axis of the ellipse fitted in the standardized space. This represents the minor semi-axis of the ellipse fitted in the standardized space. This represents the rotation angle of the ellipse fitted in the standardized space.

[0054] After fitting, the ellipse parameters obtained in the standardized space are inversely transformed back to the original image coordinate system:

[0055] ,

[0056] , ,

[0057] in, This represents the x-axis coordinate value of the ellipse center obtained by fitting the original image coordinate system. This represents the y-axis coordinate value of the ellipse center obtained by fitting the coordinates in the original image coordinate system; This represents the semi-major axis of the ellipse obtained by fitting it in the original image coordinate system; This represents the minor semi-axis of the ellipse obtained by fitting it in the original image coordinate system; This represents the rotation angle of the ellipse fitted in the original image coordinate system.

[0058] This data standardization preprocessing step maps the numerical optimization problem from the original physical space to a normalized space for solution, effectively avoiding ill-conditioned covariance matrix problems caused by dial tilt or inconsistent coordinate magnitudes.

[0059] S3. Using the ellipse parameters in the original coordinate system obtained in S2 (i.e., the center coordinates of the ellipse) Long half shaft short half shaft Rotation angle ), calculate the four vertices of the circumscribed rectangle of the ellipse:

[0060]

[0061] After sorting by quadrant, the perspective transformation matrix is ​​calculated using the square vertices as the target point set, and the elliptical dial image is corrected to a standard circular dial image by using OpenCV's getPerspectiveTransform to calculate the perspective transformation matrix.

[0062] S4. For the circular dial image obtained in S3, first perform Gamma correction (gamma value set to...). To enhance contrast, the PP-OCR model within the PaddleOCR framework is used for text detection and recognition. Each tick mark value and its corresponding text detection box coordinates are extracted, and the image rotation angle is automatically corrected using the document orientation classification module. To address common OCR errors such as flipping and missing decimal points, a three-layer reverse regularization correction process is implemented, specifically including:

[0063] The first layer is character mapping correction. This addresses the OCR character confusion caused by rotating or inverting instrument images by establishing a numeric character confusion mapping relationship. For numeric strings without decimal points that satisfy the regular expression r"^[3-9]0*0$" (this regular expression represents a numeric string where the first digit is 3-9 and the remaining characters are 0), the first digit is extracted and replaced according to the character mapping relationship (in this embodiment, if the identified digit 6 is replaced with digit 9, and if the identified digit 9 is replaced with digit 6, other digits are not replaced), and the entire string is reversed (i.e., the string is looped to the right until the first digit at the leftmost position loops to the last digit at the rightmost position), thus restoring the correct numeric characters. For example, if the OCR recognition result is "900", the first digit "9" needs to be replaced with "6", the string becomes "600", and then the string is looped and shifted, finally restoring the string to "006". A decimal point is then added directly after the first 0 character from the left to obtain the final scale value, "0.06".

[0064] The second layer is implicit decimal point regular expression completion. That is, for a pure number string that matches the regular expression pattern r"^-?00*[1-9]$" (this regular expression pattern means including a minus sign, starting with the number 0, followed by 0 to 2 additional zero characters and the last digit is 1 to 9), a decimal point is added after the first 0. For example, the OCR recognition result "001" will have a scale value of "0.01" after the first 0 is added.

[0065] The third layer involves unifying and aligning the dimensions of all units. Specifically, this includes statistically analyzing the distribution of decimal places in the text after the previous two layers of cleaning. This represents the number of numerical values ​​with i decimal places (i∈[0, 9]), with the most frequent number of decimal places selected as the base unit. :

[0066]

[0067] For other strings without decimal points, these are strings that do not contain a decimal point and do not satisfy either the aforementioned regular expression pattern r"^[3-9]0*0$" or the regular expression pattern r"^-?00*[1-9]$". In other words, they are strings that have a decimal point added without being processed by the aforementioned two regular expression patterns, based on the baseline unit. To unify the dimensions, that is:

[0068]

[0069] in, This indicates the i-th other string. Other strings refer to strings that do not contain decimal points and do not satisfy the regular expression pattern r"^[3-9]0*0$" or the regular expression pattern r"^-?00*[1-9]$". express The scale value obtained after unifying the dimensions.

[0070] This invention selects the number of digits that appear most frequently as the reference unit. Divide all non-decimal integer values ​​by This ensures that all scale values ​​on the entire dial are within a uniform physical dimension.

[0071] S5. This step does not rely on the pixel grayscale information of the image, but instead uses the geometric center of the scale text detection box obtained in S4 to infer the center of the mechanical circle. First, the geometric center coordinates of each valid scale text detection box are extracted to form a set of circumferential sampling points. Determine the ratio of the minor axis to the major axis of the ellipse obtained by S2:

[0072]

[0073] If the ratio is not greater than 0.65 (i.e., the dial has obvious perspective distortion), then traverse all sampling point pairs and use the perpendicular bisector theorem of a circle, that is, the perpendicular bisector of the line connecting any two points on a circle must pass through the center of the circle, to construct a linear equation. For any sampling point... and Using the perpendicular bisector theorem, a linear equation for solving the coordinates of the circle's center can be constructed as follows:

[0074]

[0075]

[0076] For the j-th group of valid sampling points and (In this embodiment, it is defined that the Euclidean distance between two sampling points is greater than 1 pixel to be valid.) Definition:

[0077]

[0078]

[0079]

[0080] in, is an intermediate parameter, which represents the difference in the x-coordinates of the j-th effective sampling point pair; is an intermediate parameter, which represents the difference in the ordinates of the j-th effective sampling point pairs; is an intermediate parameter, which represents the difference between the squares of the horizontal and vertical coordinates of the j-th effective sampling point.

[0081] Pair each valid point with the corresponding As coefficient matrices respectively The j-th row, will As the j-th term of the constant vector C, this forms an overdetermined system of equations, expressed as:

[0082]

[0083] in, Let be the coordinates of the center of the circle to be solved. To find the x-coordinate of the center of the circle, Let be the value of the ordinate of the center of the circle to be solved.

[0084] In this embodiment, np.linalg.lstsq is used to solve the least squares solution of the overdetermined system of equations, obtaining the unique intersection point coordinates. This refers to the mechanical center. This method does not rely on pixel grayscale or edge gradients, but only on the geometric topological relationship of the scale markings, fundamentally eliminating the adverse effects of printing eccentricity and installation deviation on reading accuracy.

[0085] S6, the mechanical center obtained from S5 Using the origin as the coordinate point, perform a linear polar coordinate transformation on the circular dial image obtained in S3, unfolding the circular dial along the circumference into a one-dimensional strip scale image. The transformation relationship is as follows:

[0086]

[0087]

[0088] in, To expand the column coordinates of the image, The row coordinates of the expanded image; and These are the width and height of the expanded image, respectively, and are generally taken as... , ; For the first The corresponding circumferential angles; For the first The radial sampling distance corresponding to the row, originating from the mechanical center; This represents the maximum radial sampling radius allowed within the current dial image boundaries; To expand the image coordinates The pixel value at that location.

[0089] S7. This step will use the cleaning scale value obtained in S4. Treating it as the dependent variable, its polar coordinate angle relative to the center of the mechanical circle is... Treating them as independent variables, construct a univariate linear mapping model. Where k is the coefficient of the univariate linear equation and b is the bias of the univariate linear equation, a RANSAC regressor is introduced to perform robust fitting based on the LinearRegression as the basic estimator: a stopping score threshold of stop_score=0.95 is set, and the RANSAC regressor stops iterating early when the coefficient of determination of the univariate linear mapping exceeds this value, based on the cleaned set of scale values. The standard deviation is set to a second residual threshold. As an optional implementation, this embodiment sets the second residual threshold to... ;

[0090] After fitting is complete, i.e., the optimal univariate linear equation coefficients and biases are obtained, thus yielding the optimal univariate linear mapping relationship. For each set of data consisting of scale values ​​and their corresponding scale values ​​( Cleaning will be carried out, that is... Input the optimal univariate linear mapping relationship to obtain the fitted scale value y, and then compare the fitted scale value y with the true scale value. Does the error between them exceed the second residual threshold? If it does, then the data ( The data marked ) is outlier and needs to be deleted. This step extends RANSAC from the traditional "line finding" function to a "scale cleaning" function, realizing automatic detection and active filtering of outlier scales.

[0091] S8. Apply the following processing chain to the expanded ruler image obtained in S6: CLAHE adaptive histogram equalization → bilateral filtering → OTSU adaptive binarization → morphological opening operation. Then perform 8-adjacent connected component analysis to obtain the statistical features of each independent white patch, including the coordinates of the top-left corner, width, height, and area, denoted as follows: , , , and Using the absolute physical prior that the pointer will always traverse the entire length of the unfolded graph, a candidate set is defined for filtering:

[0092]

[0093] in, and Let be the height and width of the i-th connected component, respectively. If the array is not empty, then the connected component with the largest height in the candidate set is selected as the pointer region:

[0094]

[0095] Create a binary mask containing only pointer candidate connected components. (Set candidate regions to 1, others to 0), vertically project and accumulate along the column direction, taking the peak index of the accumulated value as the sub-pixel level horizontal coordinate of the pointer:

[0096]

[0097]

[0098] in, Indicates the binary mask in coordinates Pixel value at; This is the accumulated value of the u-th column pixel of the mask; express The row index of the column corresponding to the maximum value is used as the pointer's horizontal pixel coordinate in the expanded image.

[0099] This method replaces complex Hough transforms or edge detection with simple and efficient geometric threshold filtering, effectively avoiding the problem of long characters being misdetected as pointers.

[0100] S9. Check the x-coordinate of the pointer obtained in S8. Does it fall within the valid range of the known scale? If it does, then calculate the accurate reading using linear interpolation between the two nearest neighbor scale points:

[0101]

[0102] in, The desired instrument reading; and These are the scale values ​​of two adjacent valid scale anchor points on either side of the pointer; and These are the polar coordinate angles of the two scale anchor points relative to the center of the machine circle, respectively. According to The polar coordinate angle of the pointer obtained by inverse calculation.

[0103] If the pointer is outside the valid range (such as before the start point or after the end point of the measurement range), extrapolation is performed using the linear regression model retained by S7. Finally, the calculated value is concatenated with the physical units (Pa, kPa, MPa, etc.) recognized by OCR to output the complete instrument measurement result.

[0104] This embodiment uses a pointer-type pressure gauge with a range of 0-0.1 MPa, commonly found in industrial settings, as an example. After detecting the dial area from an image with a resolution of 1920×1080, the YOLOv11-seg model outputs a mask contour point set of approximately 350 pixels. These points have a large offset in the original image coordinate system (x-coordinates are distributed in the range of 1200-1800, and y-coordinates are distributed in the range of 200-800). When directly using the original coordinates for ellipse fitting, the ellipse fitted by RANSAC deviates significantly from the actual dial position.

[0105] The present invention first calculates the geometric center of the point set center = (1503.2, 498.7), the peak-to-peak range of each dimension ptp(x) = 598.8, ptp(y) = 601.3, and obtains scale = max(598.8, 601.3) / 2 ≈ 300.7.

[0106] In the transformed standardized space, the fitting converged within an average of 17 iterations, yielding the standardized ellipse parameters. After inverse transformation to restore the original coordinate system, the ellipse's center is (1502.8, 497.9), with a major semi-axis of a = 288.5 px, a minor semi-axis of b = 274.1 px, and a rotation angle θ = 3.2°. On 100 test images with different tilt angles (0° to 55°), the fitting success rate of this method was 97.0%, an improvement of 25 percentage points compared to the traditional direct fitting method (success rate approximately 72%).

[0107] The PP-OCR model under the PaddleOCR framework performs text recognition on the corrected circular dial (577×577 pixels). The pressure gauge has six scale markings: 0, 0.02, 0.04, 0.06, 0.08, and 0.10 (MPa).

[0108] Due to the shooting angle and lighting conditions, the original OCR output is: "0", "002", "004", "006", "008", "01". Among them, "002", "004", "006", "008", and "01" have lost the decimal point.

[0109] Scan all 6 texts. "002", "004", "006", "008", and "01" match pattern 1 (ptn_1: r"^-?00*[1-9]$", which is a string containing a minus sign, starting with the number 0, followed by 0 to 2 additional zero characters, and ending with 1 to 9). Add a decimal point after the first 0 to correct them to "0.02", "0.04", "0.06", "0.08", and "0.1".

[0110] If no string matches the regular expression pattern r"^-?00*[1-9]$", skip that matching pattern.

[0111] In addition to the two matching modes mentioned above, this also includes unprocessed string "0" and counting the number of decimal places in the processed strings. "0.02", "0.04", "0.06", and "0.08" all have two decimal places, while "0.1" has one decimal place. In other words, the most frequent string has two decimal places. Divide the value corresponding to the string by 10 2 The final tick value corresponding to the string is 0. If the string is "1", then its tick value is "0.01". The final tick value set is {0, 0.02, 0.04, 0.06, 0.08, 0.1}, which is completely consistent with the actual value.

[0112] As an optional implementation, the number of decimal places retained by each element in the final scale value set can be unified to the precision unit with the most decimal places. For example, the scale value set {0, 0.02, 0.04, 0.06, 0.08, 0.1} can be represented with a precision of {0.00, 0.02, 0.04, 0.06, 0.08, 0.10} after unifying the precision unit.

[0113] The geometric center coordinates of the six valid scale text detection frames are (412, 288), (375, 520), (521, 508), (561, 289), (478, 110), and (297, 118), respectively. In this embodiment, the dial exhibits significant perspective distortion before correction, with the ratio of the minor axis to the major axis of the ellipse, b / a, being 0.58, which is not greater than the preset threshold of 0.65. Therefore, a mechanical center-reverse calculation step based on the geometric distribution of the scale text detection frames is performed.

[0114] Construct perpendicular bisector equations for all n-1=5 pairs of points, filter out degenerate point pairs with a distance less than 1.0 pixel, and obtain a system of 5 linear equations. The least squares solution to the overdetermined system of equations is as follows: =348.3, =318.6, this coordinate serves as the mechanical center around which the pointer rotates.

[0115] If the geometric center of the perspective-corrected image is directly used for polar coordinate expansion, the scale angles will be affected by installation eccentricity and perspective residuals. After using the mechanical center obtained by this invention, the angle distribution of the center of each scale text box relative to the center is consistent with the actual scale order, thereby reducing the systematic error of subsequent scale-angle calibration and pointer interpolation calculation.

[0116] Assuming that the OCR correction was not fully corrected in a certain instance, i.e., if six scale values ​​and their corresponding angles are obtained from the aforementioned example, we now simulate the situation where the OCR misinterprets "0.06" as "0.6". The six data points are: (0°, 0.00), (60°, 0.02), (120°, 0.04), (180°, 0.6), (240°, 0.08), and (300°, 0.10).

[0117] The fourth point (180°, 0.6) significantly deviates from the linear trend formed by the other five points. RANSACRegressor was used to iteratively fit the data points, with the residual threshold parameter `residual_threshold = ...` =0.2×0.208=0.0416; After the fitting converges, the inlier_mask_=[True, True, True, False, True, True] is extracted. The 4th point is correctly marked as an outlier and removed. Linear regression is performed on the remaining 5 inliers to obtain... R 2 =0.999. This model is used for extrapolation calculations when the pointer is outside the range. For example, when θ=-15°, the reading is 0.000167×(-15)≈-0.0025 MPa, indicating that it may be under negative pressure.

[0118] The generated ruler unfolded image has a size of 1810×577 pixels. After preprocessing, connected component analysis detected a total of 8 connected components. The attributes of each connected component are as follows:

[0119] Connected component #1 (pointer): x=1120, y=15, w=8, h=547, height 547 > 0.6×577=346.2, width 8 < 0.15×1810=271.5;

[0120] Connected component #2 (character "0"): x=38, y=310, w=22, h=18, height not satisfied;

[0121] Connected components #3-#7 (other tick characters): Similarly, their heights are all less than 100, which does not satisfy the height constraint;

[0122] Connected component #8 (character "MPa"): x=895, y=185, w=98, h=35, height not satisfied;

[0123] Only the connected component #1 satisfies both geometric thresholds and is selected as a pointer candidate; after summing the binary mask containing only #1 along the column direction, the vertical projection function reaches its peak at column 1124, therefore the pointer's horizontal coordinate... =1124. After manual annotation and comparison, the true horizontal coordinate of the pointer is 1123.8, with a positioning error of only 0.2 pixels, meeting industrial precision requirements. On 1000 test images, the pointer positioning accuracy rate is 98.7%, and the false detection rate per unit character has decreased from 3.2% in the traditional Hough method to 0%.

[0124] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for automatic reading of pointer-type instruments based on mechanical center reverse calculation and robust calibration, characterized in that, Specifically, the following steps are included: S1. Obtain the image of the pointer-type instrument to be read, use a pre-trained deep learning segmentation model to infer the input image, detect the dial area and generate the corresponding binary segmentation mask, and extract the set of dial outline pixel coordinates from the mask. S2. For the extracted contour point set, calculate the geometric center and scale factor of the contour point set, decenter the point coordinates and uniformly scale them to the standardized space, perform RANSAC ellipse fitting in the standardized space, and then inversely transform the fitting result back to the original image coordinate system to obtain the dial ellipse parameters. S3. Calculate the circumscribed rectangle vertices using the ellipse parameters, calculate the perspective transformation matrix with the square vertices as the target point set, and correct the elliptical dial image to a standard circular dial image. S4. After performing Gamma correction on the circular dial image, use an OCR model to perform text detection and recognition, extracting the scale values, physical units, and corresponding text detection box coordinates; perform reverse regularization correction processing on the OCR output. S5. When the ratio of the minor axis to the major axis of the ellipse is greater than the preset threshold, the geometric center of the image is directly used as the mechanical center; otherwise, the geometric center of each effective scale text detection box is calculated as the circumferential sampling point, all sampling point pairs are traversed to construct the perpendicular bisector equation, forming an overdetermined linear equation system, and the coordinates of the mechanical center are solved by the least squares method. S6. Perform a linear polar coordinate transformation with the mechanical center as the origin, and unfold the circular dial image into a one-dimensional scale image along the circumference. S7. Using the cleaned scale value as the dependent variable and its polar coordinate angle relative to the mechanical center as the independent variable, construct a linear regression model, introduce the RANSAC regressor for fitting, extract the inner point mask to actively remove outlier scale points and corresponding detection boxes whose residuals exceed the dynamic threshold, and retain the fitted model for extrapolation calculation. S8. Apply CLAHE enhancement, bilateral filtering, OTSU binarization, and morphological opening to the image after polar coordinate transformation in sequence, and then perform connected component analysis. Using the physical prior that the pointer runs through the entire length of the unfolded image, set a double geometric threshold to filter candidate connected components of the pointer: the height is greater than 60% of the image height and the width is less than 15% of the image width. Select the connected component with the largest height among those that meet the conditions, project its mask vertically along the column direction, and take the projection peak index as the pointer's horizontal coordinate. S9. Determine whether the pointer's horizontal coordinate falls within the known valid interval of the scale. If it is within the interval, calculate the reading by linear interpolation of the nearest scale point. If it is outside the interval, use the regression model retained in S7 to perform extrapolation calculation. Finally, concatenate the numerical value with the physical unit to output the complete measurement result.

2. The automatic reading method for pointer-type instruments based on mechanical center reverse calculation and robust calibration according to claim 1, characterized in that, Step S2, data standardization and spatial ellipse fitting, specifically includes: Extract the dial outline point set in the original coordinate system as n is the number of points in the dial outline. Represents the coordinates of the i-th point; Calculate the arithmetic mean of the coordinates of all points in the dial outline point set. and scale factor ,in This is the arithmetic mean of the x-coordinates of all points in the dial outline point set. This is the arithmetic mean of the ordinates of all points in the dial outline point set. This represents the difference between the maximum and minimum values ​​on the x-axis. This represents the difference between the maximum and minimum values ​​on the y-axis. Transform all point coordinates, mapping the point cloud to a normalized space centered at the origin with a scale of [-1, +1]. The coordinates of the i-th point after the transformation are represented as follows: ; All standardized dial outline points Composition of standardized point sets and with standardized point sets As input for RANSAC ellipse fitting; When initializing the RANSAC parameters, the minimum number of sampling points in the normalized space is set to 5, and the residual threshold used to distinguish inliers and outliers in the normalized space is set to the ratio of the residual threshold used to distinguish inliers and outliers in the original image coordinate scale to the scale factor. RANSAC samples from a standardized point set and builds candidate ellipse models. It then determines interior points based on the residuals of each standardized contour point relative to the candidate ellipse models, ultimately obtaining the ellipse parameters in the standardized space. ,in Let x be the x-coordinate of the center of the ellipse in the standardized space. The ordinate of the center of the ellipse in the standardized space. The major axis value of the ellipse in the standardized space. The minor axis value of the ellipse in the standardized space. Let be the rotation angle of the ellipse in the normalized space; Using the inverse transformation formula, the ellipse in standard space is restored to the original coordinate system. The x-coordinate of the ellipse's center in the original coordinate system is represented as: The ordinate of the center of the ellipse in the original coordinate system is represented as: The semi-major axis of the ellipse in the original coordinate system is represented as The minor semi-axis of the ellipse in the original coordinate system is represented as The rotation angle of the ellipse in the original coordinate system is expressed as... .

3. The automatic reading method for pointer-type instruments based on mechanical center reverse calculation and robust calibration according to claim 1, characterized in that, Step S5, which involves solving for the coordinates of the mechanical center using the least squares method, specifically includes: Extract the geometric center coordinates of each valid tick mark text detection box to form a circumferential sampling point set. If the Euclidean distance between any two sampling points is greater than 1.0 pixels, then the perpendicular bisector theorem is used to construct a linear equation to solve for the coordinates of the center of the circle. The linear equations of all adjacent points with an Euclidean distance greater than 1.0 pixels form an overdetermined system of linear equations. The NumPy least squares solver is called to solve the overdetermined system of equations to obtain the coordinates of the unique intersection point. These coordinates are the mechanical center of the circle around which the pointer rotates.

4. The automatic reading method for pointer-type instruments based on mechanical center reverse calculation and robust calibration according to claim 3, characterized in that, like and For two sampling points with a Euclidean distance greater than 1.0 pixels, the linear equation for solving the coordinates of the circle center is constructed using the perpendicular bisector theorem and expressed as: in, and The center point of any two valid tick text detection boxes that are more than 1 pixel apart; Let be the coordinates of the center of the circle to be solved.

5. The automatic reading method for pointer instruments based on mechanical center reverse calculation and robust calibration according to claim 1, characterized in that, Step S4, the OCR reverse regularization correction process specifically includes: For a numeric string that does not contain a decimal point, whose first digit is 3 to 9 and all other characters are 0, if the first digit is 6, it is corrected to 9; if the first digit is 9, it is corrected to 6. Then it is restored to a decimal string with 0 characters and the last decimal is the first digit, thus obtaining the corrected scale value. For numeric strings without a decimal point that contain a minus sign, start with the number 0, are followed by 0 to 2 additional zero characters, and end with 1 to 9, add a decimal point after the first 0 to restore it to the corresponding decimal scale value. The distribution of decimal places in the cleaned text is statistically analyzed, and the digits with the highest frequency are selected as the baseline. For other strings that do not contain decimal points and do not meet the criteria, a unified baseline is applied.

6. The automatic reading method for pointer-type instruments based on mechanical center reverse calculation and robust calibration according to claim 5, characterized in that, For other strings that do not contain a decimal point, the process of unifying the units based on the baseline units includes: in, It is the i-th string among other strings that do not contain a decimal point; This is the most frequently occurring decimal place. It represents the scale value after unifying the physical dimensions of the entire dial.

7. The automatic reading method for pointer-type instruments based on mechanical center reverse calculation and robust calibration according to claim 1, characterized in that, Step S7, RANSAC regression calibration and outlier removal, specifically includes: Set of cleaned scale values As the dependent variable, its polar coordinate angle relative to the center of the mechanical circle is used. As an independent variable, construct A univariate linear mapping relationship; Introducing a RANSAC regressor, with LinearRegression as the basic estimator, based on a cleaned set of scale values. Set the standard deviation as the second residual threshold; The RANSAC regressor establishes a univariate linear mapping relationship through repeated random sampling and calculates whether the determination coefficient of the univariate linear mapping relationship reaches the preset stopping score. If it does, the iteration ends early; otherwise, sampling continues until the maximum number of iterations is reached. When the RANSAC regressor meets the early stopping condition or reaches the maximum number of iterations and determines the current optimal linear regression model, the true polar coordinate angle is input into the optimal linear regression model. If the error between the scale value output by the optimal linear regression model and the true scale value exceeds the second residual threshold, the data set is removed as outlier data.

8. The automatic reading method for pointer-type instruments based on mechanical center reverse calculation and robust calibration according to claim 1, characterized in that, Step S8, which involves filtering and locating geometric prior pointers for connected components, specifically includes: Perform 8-adjacent connected component analysis on the preprocessed binary image to obtain the first... Width of each connected component ,high Using the absolute physical prior that a pointer will always traverse the entire length of the unfolded graph, a candidate set is defined for filtering. The candidate set is... ,in To expand the image height, To expand the image width; The candidate with the largest height in the candidate set is selected as the unique pointer candidate connected component; if no connected component meets the condition, the process reverts to the weighted vertical projection scheme, applies a higher weight to the upper half of the binary image, and then takes the projection peak. Mask for extracting candidate connected components of pointers That is, the candidate region is set to 1 and the rest are set to 0. The vertical projection of the mask along the column direction is summed, and the index of the column corresponding to the projection peak is taken as the sub-pixel level horizontal coordinate of the pointer.