Circular pointer instrument reading method based on ellipse target detection
By using a deep learning method based on elliptical target detection and employing an improved YOLOX model and OCR model to automatically read the values of pointer-type instruments, the problems of low reading efficiency and angle deviation of traditional instruments are solved, and efficient and accurate automated reading is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SOUTH CHINA UNIV OF TECH
- Filing Date
- 2026-02-09
- Publication Date
- 2026-05-29
AI Technical Summary
Traditional pointer-type instruments require manual reading, which is inefficient and prone to errors. Existing automated methods are limited by shooting angles and are slow, failing to meet real-time requirements.
A deep learning method based on elliptical target detection is adopted. An improved YOLOX model is used to detect the elliptical contour of the instrument panel. Combined with an OCR model, the values are automatically read. The image angle deviation is corrected by elliptical transformation to achieve automated reading.
It improves the accuracy and speed of instrument readings, reduces the impact of noise, is suitable for various scenarios, has real-time performance and robustness, has low equipment requirements, and high economic value.
Smart Images

Figure CN122115565A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of pointer instrument reading, and in particular to a method for reading circular pointer instruments based on elliptical target detection. Background Technology
[0002] In sectors such as industrial production and power transmission, operators need to monitor system operation and promptly identify system risks. This requires sensors and instruments to convert the status of equipment into intuitive digital displays, and the instrument readings can directly determine whether the equipment is functioning properly.
[0003] However, traditional instruments require manual reading, cannot be automatically summarized, are inefficient, and are prone to errors. Although some new devices now incorporate IoT technology, allowing data uploads, traditional pointer-type instruments still exist in large quantities and are widely manufactured and used due to their low cost. Replacing instruments with existing equipment would be extremely costly, but with the widespread use of monitoring equipment, automatic reading from instrument images has become a crucial operation.
[0004] Current pointer-type instrument reading methods are limited by the shooting angle method, resulting in significant errors when the viewpoint is not perpendicular to the dial. Some methods use segmentation to generate correction information to reconstruct the angle, but this method is slow and does not meet real-time requirements. Therefore, there is a need for an instrument reading method that can both correct the image to improve accuracy and maintain operating speed.
[0005] In conclusion, intelligent reading of traditional pointer instruments is an economically viable task. Summary of the Invention
[0006] The purpose of this invention is to overcome the shortcomings and deficiencies of the prior art and propose a method for reading circular pointer instruments based on elliptical target detection. This method uses an elliptical target detection model with elliptical target detection capabilities to process image input. When obtaining the area where the dial is located, it simultaneously obtains the elliptical outline of the pointer instrument dial in the image. This provides an efficient and universal method for solving the problem of reading pointer instruments under large shooting angle deviations using computer vision methods.
[0007] To achieve the above objectives, the technical solution provided by this invention is: a method for reading a circular pointer instrument based on elliptical target detection, comprising the following steps:
[0008] 1) Collect instrument images containing pointer instruments, label the instrument dial area in the instrument image with a mask, and fit an ellipse using the mask label to obtain the major and minor axis lengths, center point and rotation angle of the ellipse, which are used to generate ellipse parameters representing the outline of the instrument dial, and obtain the instrument image and its corresponding label, which serve as the instrument dial dataset for subsequent training models.
[0009] 2) The instrument panel dataset is fed into the improved YOLOX model for training. This improved YOLOX model has the ability to detect elliptical targets and can detect instrument panels after training. It takes the image data of the instrument panel dataset as input and the bounding rectangle and ellipse parameters of the instrument panel as output. The trained improved YOLOX model is used as the elliptical target detection model. The improved YOLOX model improves both the feature fusion module and the model head. For the feature fusion module, a dynamic upsampling module is used to replace the original static upsampling module to enhance detection performance. For the model head, an ellipse parameter prediction branch is added to the model head to enable it to detect elliptical targets.
[0010] 3) Input the image of the target instrument containing the pointer instrument into the elliptical target detection model, output the predicted rectangle of the target instrument dial and the corresponding predicted ellipse parameters, decode the major and minor axis lengths, center point and rotation angle of the ellipse, and use the predicted rectangle to segment the area where the dial is located.
[0011] 4) Calculate ellipse information using the predicted ellipse parameters output by the ellipse target detection model, set the area outside the ellipse to 0, eliminate interference from irrelevant background areas, and use the ellipse information to perform affine transformation correction on the dial image to reduce the adverse effects of shooting angle deviation on instrument readings, thus completing the preprocessing stage of the dial image and obtaining the corrected dial image.
[0012] 5) Use an OCR model to process the corrected dial image to obtain the position and value information of the scale numbers. Use digital image processing methods to fit the straight line corresponding to the pointer on the dial image. Then, combine the position and value information of the scale numbers above and use the distance method to calculate the instrument reading, thereby completing the automatic reading of the circular pointer instrument.
[0013] Furthermore, step 1) includes the following steps:
[0014] 1.1) Image collection: Obtain instrument images from the Internet and take preset amounts of instrument images yourself;
[0015] 1.2) Image annotation: Remove blurry, dirty, or incomplete images from the collected images; use a mask in the annotation tool to annotate all instrument panel areas to obtain the original image annotations;
[0016] 1.3) Label Conversion: The original image labels are converted to obtain image labels containing bounding box labels and elliptical parameter labels. First, the bounding rectangle of the mask for each image label is obtained as the bounding box label. Then, ellipse fitting is performed on the mask of the image label to obtain the length of the major and minor axes, the center position, and the rotation angle of the ellipse. The affine transformation matrix of the ellipse relative to the unit circle is then calculated. This is called the original ellipse parameter, which is a 2×3 matrix containing six parameter terms. This is represented as a matrix, and it is divided into two submatrices:
[0017] ;
[0018] In the formula, This is an ellipse shape information matrix, 2×2 in size, representing the shape change of the ellipse compared to the unit circle. This is an ellipse position information matrix, 2×1 in size, representing the positional offset of the ellipse relative to the unit circle. Its specific composition and calculation method are as follows:
[0019] ;
[0020] ;
[0021] In the formula, Let be the rotation angle of the major axis of the ellipse relative to the x-axis. and These are the lengths of the semi-major axis and semi-minor axis of the ellipse, respectively. These are the x and y coordinates of the center of the ellipse, respectively. These are the x and y coordinates of the center of the rectangle's annotation;
[0022] Next, using the width and height of the rectangle annotations, the original ellipse parameters are scaled to obtain a normalized matrix. This is called the ellipse parameter annotation, which is a 2×3 matrix containing six parameter terms. express:
[0023] ;
[0024] In the formula, and These are the width and height of the rectangle, respectively.
[0025] Furthermore, in step 2), the training process for the improved YOLOX model is as follows:
[0026] First, the dashboard dataset is augmented using random scaling, random erasure, and Mosiac data augmentation techniques. Simultaneously, because the model's input size is fixed, to ensure input consistency, the images in the dashboard dataset need to be scaled to a uniform size and normalized. During this process, the image dimensions will change. To ensure the accuracy of the ellipse parameters, ellipse parameter preprocessing is required, resulting in preprocessed image annotations, i.e., ellipse parameter annotations. Further modifications yielded the input model. These are called the training ellipse parameters:
[0027] ;
[0028] In the formula, and These represent the width ratio and length ratio of the images before and after preprocessing, respectively, as shown in the following formula:
[0029] ;
[0030] ;
[0031] In the formula, , The width and height of the image before preprocessing. , The width and height of the preprocessed image; image annotation and image matching after preprocessing;
[0032] The enhanced image is input into the improved YOLOX model. The improved YOLOX model's backbone network extracts the instrument's feature information, and then the extracted feature information is input into the improved feature fusion module for feature fusion at different scales. The dynamic upsampling module DySample is used to replace the original static upsampling module, which improves the model's ability to understand and fuse feature information at different scales. At the same time, dynamic upsampling can dynamically select sampling points, which is beneficial for the model to understand different elliptical shapes, thereby improving the effect of elliptical target detection.
[0033] The fused features are input into the improved model head to obtain the prediction result. This improved model head adds an output convolutional layer as an elliptic parameter prediction branch. This elliptic parameter prediction branch shares input features with other regression parameters and outputs a 6-channel result after convolution processing, used to predict the elliptic parameter output. :
[0034] ;
[0035] In the formula, Represents the Sigmoid function. Represents a convolutional layer. Represents input features, The representative reshapes the outcome. This represents the width and height of the feature layer corresponding to the input features; where In the input feature layer, each feature point corresponds to a 2×3 matrix representing the parameters of the predicted ellipse, called... ;
[0036] The predicted results are compared with the preprocessed image annotations. After calculating the loss function, the gradient is calculated using the backpropagation model, and the parameters are adjusted using the gradient descent method to make the model asymptotically optimized. Finally, an elliptical target detection model that can be used to detect the elliptical outline of pointer instruments is obtained.
[0037] Furthermore, in step 3), an elliptical target detection model is used to predict the instrument image. After inputting the instrument image, the model outputs the predicted bounding boxes and predicted ellipse parameters corresponding to each instrument panel target in the image.
[0038] Among them, the width and height of the predicted rectangle are and The center point is located at Predicting ellipse parameters It is a 2×3 matrix containing six parameters. This represents the normalized result of the model's prediction. Each number in this matrix is a value between 0 and 1, and it is recorded using the following formula:
[0039] ;
[0040] First, based on the relative proportion of the input image to the model input, the width and height of the predicted bounding box are reconstructed, along with the aspect ratio of the ellipse parameters, to obtain the ellipse shape information matrix. :
[0041] ;
[0042] in, and The width and height of the predicted rectangle;
[0043] Calculate using the eigenvalue calculation formula Eigenvalues:
[0044] ;
[0045] In the formula, It is a 2×2 identity matrix. for The eigenvalues; solving this expression yields two roots. The larger of the roots is taken as the length of the semi-major axis of the ellipse. The smaller one is the semi-minor axis length. Then lengthen the semi-major axis. Substitute into the following formula to calculate its corresponding direction vector :
[0046] ;
[0047] Obtain the direction vector corresponding to the major axis ,in yes The component in the x-axis direction, for The component in the y-axis direction;
[0048] Direction vector Substitute into the following formula to obtain the rotation angle of the ellipse. :
[0049] ;
[0050] In the formula, This represents the arctangent value of two of the values;
[0051] The x and y coordinates of the center point of the ellipse Then it is:
[0052] ;
[0053] In the formula, and Represents the x and y coordinates of the center of the predicted rectangle. and To predict the width and height of the rectangle;
[0054] At this point, the major and minor axis lengths, center point, and rotation angle of the ellipse are obtained. Unreliable results are then filtered out based on confidence level, and redundant results are eliminated using NMS. The instrument dial detection is completed, and the areas containing the dial in the image are extracted for later use.
[0055] Furthermore, in step 4), the area outside the ellipse is set to 0 to eliminate the background influence outside the instrument panel. Then, the affine transformation matrix from the ellipse to the unit circle is calculated using the major and minor axes, center point, and angle parameters of the ellipse obtained in step 3), and this matrix is used as the transformation matrix. :
[0056] ;
[0057] In the formula, This is an inverse transformation of the elliptical shape information matrix. The inverse transformation ellipse position information matrix is calculated as follows:
[0058] ;
[0059] ;
[0060] use The image is corrected by affine transformation, which transforms the elliptical instrument dial into a circular shape, making the dial in the image perpendicular to the camera angle. This reduces the adverse effects of shooting angle deviation on instrument readings, completing the preprocessing stage of the dial image.
[0061] Further, in step 5), the dial image is processed using an OCR model to obtain the positions of each scale digit on the dial, and the center point of the transformed circle is used as the center point of the dial. Next, the image is binarized using the OTSU algorithm, and then noise is removed using a graphics operation of erosion followed by dilation. Each region is extracted, and the region with the largest area is retained as the pointer. The distance between the center point of each scale digit and the pointer is calculated, and the two closest points are selected as backups. Let these two points be... and Finally, the reading results were calculated using the distance method. :
[0062] ;
[0063] In the formula, , represent , The scale values corresponding to the two points This represents the length of line segment AC. The length of line segment AB represents the intersection point of the line fitted after refining the pointer area and the line connecting the two nearest scale numbers. Using the ratio of the distances between this point and the two scale numbers, as well as the scale value, the current reading of the instrument can be obtained.
[0064] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0065] 1. This invention utilizes deep learning to achieve intelligent instrument readings, which has better speed and real-time performance compared to manual methods, better accuracy compared to traditional image processing methods, and is less affected by image noise.
[0066] 2. This invention uses an elliptical target detection model for the detection of instrument dials. It has the ability to directly detect elliptical targets. Compared with the traditional pointer-type instrument detection method, this invention can directly obtain the elliptical parameters of the instrument contour, simplifying the operation steps and reducing equipment requirements.
[0067] 3. In the feature fusion part of the elliptical target detection model, a dynamic upsampling module is used to replace the static upsampling operation, which enables the model to process image features more effectively and improves the model's ability to detect targets.
[0068] 4. This invention enables rapid identification and reading of circular pointer-type instruments, and is applicable to various scenarios such as inspection and monitoring, and has potential economic value.
[0069] 5. This invention has excellent real-time performance and robustness, can be deployed and used on various devices, and has good environmental adaptability and practicality. Attached Figure Description
[0070] Figure 1 This is a flowchart illustrating the overall process of the method of the present invention.
[0071] Figure 2 To improve the YOLOX model structure diagram; in the diagram, Focus is the input processing module, Dark is the residual backbone network, Concat is the fusion operation, C3 is the residual convolution module, DySample is the dynamic upsampling module, ConvBNSiLU is the convolution module, and EllipseHead is the model head that supports ellipses.
[0072] Figure 3 The diagram shows the structure of the improved model head; in the diagram, ConvBNSiLU is the convolutional module, Conv is the basic convolutional module, and Sigmoid is the normalization module.
[0073] Figure 4 This is a structural diagram of the dynamic upsampling module DySample. In the diagram, X represents the input feature, the cube represents the feature in the processing, Linear is the linear layer, Sigmoid is the normalization module, Shuffle is the pixel recombination module, S is the output result, and O is the original upsampling grid. Detailed Implementation
[0074] The present invention will be further described below with reference to embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.
[0075] See Figure 1 As shown, this embodiment discloses a method for reading circular pointer meters based on elliptical target detection. This method uses deep learning target detection to extract the meter dial area and deep learning key information extraction to understand the dial information. By combining deep learning with traditional image processing methods, each step is implemented, and the combination achieves an automated reading process for pointer meter images.
[0076] The specific implementation of this circular pointer instrument reading method includes the following steps:
[0077] 1) Collect instrument images containing pointer gauges, label the instrument dial area in the instrument images with a mask, and fit an ellipse using the mask label to obtain the major and minor axis lengths, center point, and rotation angle of the ellipse. These are used to generate ellipse parameters representing the outline of the instrument dial, resulting in instrument images and their corresponding labels. This serves as the instrument dial dataset for subsequent model training, as follows:
[0078] 1.1) Image collection: Obtain publicly available instrument datasets and instrument images from the Internet, and take a certain number of instrument images using the instruments themselves;
[0079] 1.2) Image annotation: First, remove blurry, dirty, incomplete or other images from the collected images that are unsuitable for training; then, use a mask in the annotation tool to annotate all instrument panel areas to obtain the original image annotations.
[0080] 1.3) Label Conversion: The original image labels are converted to obtain image labels containing bounding box labels and elliptical parameter labels. First, the bounding rectangle of the mask for each image label is obtained as the bounding box label. Then, ellipse fitting is performed on the mask of the image label to obtain the length of the major and minor axes, the center position, and the rotation angle of the ellipse. The affine transformation matrix of the ellipse relative to the unit circle is then calculated. This is called the original ellipse parameter, which is a 2×3 matrix containing six parameter terms. This is represented as a matrix, and it is divided into two submatrices:
[0081] ;
[0082] In the formula, This is an ellipse shape information matrix, 2×2 in size, representing the shape change of the ellipse compared to the unit circle. This is an ellipse position information matrix, 2×1 in size, representing the positional offset of the ellipse relative to the unit circle. Its specific composition and calculation method are as follows:
[0083] ;
[0084] ;
[0085] In the formula, Let be the rotation angle of the major axis of the ellipse relative to the x-axis. and These are the lengths of the semi-major axis and semi-minor axis of the ellipse, respectively. These are the x and y coordinates of the center of the ellipse, respectively. These are the x and y coordinates of the center of the rectangle's annotation;
[0086] Next, using the width and height of the rectangle annotations, the original ellipse parameters are scaled to obtain a normalized matrix. This is called the ellipse parameter annotation, which is a 2×3 matrix containing six parameter terms. express:
[0087] ;
[0088] In the formula, and These are the width and height of the rectangle, respectively.
[0089] 2) See Figure 2 As shown, the instrument panel dataset is fed into an improved YOLOX model for training. This improved YOLOX model has the ability to detect elliptical targets and can detect instrument panels after training. It takes the image data of the instrument panel dataset as input and the bounding rectangle and ellipse parameters of the instrument panel as output. The trained improved YOLOX model is used as an elliptical target detection model. The improved YOLOX model improves both the feature fusion module and the model head. For the feature fusion module, a dynamic upsampling module is used to replace the original static upsampling module to enhance detection performance. For the model head, an ellipse parameter prediction branch is added to the model head to enable it to detect elliptical targets.
[0090] During model training, to avoid overfitting, the images in the dashboard dataset need to be preprocessed. First, data augmentation improves robustness; here, random scaling, random erasure, and Mosiac augmentation are used. Simultaneously, because the model's input size is fixed, to ensure input consistency, the images need to be scaled to a uniform size and normalized. During this process, the image's width and height will change. To ensure the accuracy of the ellipse parameters, ellipse parameter preprocessing is required, resulting in preprocessed image annotations, i.e., ellipse parameter annotations. Further modifications yielded the input model. These are called the training ellipse parameters:
[0091]
[0092] In the formula, and These represent the width ratio and length ratio of the images before and after preprocessing, respectively, as shown in the following formula:
[0093] ;
[0094] ;
[0095] In the formula, , The width and height of the image before preprocessing. , The width and height of the preprocessed image; image annotation and image matching after preprocessing;
[0096] The enhanced image is input into the improved YOLOX model. The improved YOLOX model's backbone network extracts the instrument's feature information, and then the feature information at different scales is fed into the feature fusion module for fusion. The dynamic upsampling module DySample replaces the original static upsampling module, enhancing detection performance. The principle is as follows: Figure 4 As shown: Based on the static original upsampling grid, let the input features be... The data is processed through two linear layers, one of which is normalized after being multiplied by 0.5. The two sets of data are then multiplied and subjected to pixel recombination before being superimposed on the original upsampled grid to obtain the result. DySample generates point-by-point offsets through linear projection and achieves dynamic upsampling by controlling the initial sampling position, adjusting the range of offset movement, and dividing the upsampling process into multiple independent groups. Compared with the dynamic convolution used in traditional dynamic upsampling, this method simplifies the process, reduces the amount of computation, and ensures the improvement of the model.
[0097] The fused features are input into the improved model head to obtain the prediction result. Compared to the original YOLOX model, the improved model head adds an output convolution with six channels, corresponding to six ellipse parameters. The improved model head is called EllipseHead; see [link to EllipseHead] for its specific structure. Figure 3 As shown, this convolutional layer shares input features with other regression parameters, and after convolution processing, it outputs a result with 6 channels, which is used to predict the elliptic parameter output. :
[0098] ;
[0099] In the formula, Represents the Sigmoid function. Represents a convolutional layer. Represents input features, The representative reshapes the outcome. This represents the width and height of the feature layer corresponding to the input features; where In the input feature layer, each feature point corresponds to a 2×3 matrix representing the parameters of the predicted ellipse, called... ;
[0100] Finally, the prediction results are compared with the preprocessed image annotations, the loss is calculated using the loss function, the gradient is calculated using the backpropagation model, and the parameters are adjusted using the gradient descent method to make the model asymptotically optimized, resulting in an elliptical target detection model that can be used to detect the elliptical contour of pointer instruments.
[0101] 3) Input the image of the target instrument containing the pointer meter into the elliptical target detection model, output the predicted bounding box of the target instrument dial and the corresponding predicted ellipse parameters, decode the major and minor axis lengths, center point and rotation angle of the ellipse, and segment the area where the dial is located using the predicted bounding box, as follows:
[0102] Among them, the width and height of the predicted rectangle are and The center point is located at Predicting ellipse parameters It is a 2×3 matrix containing six parameters. This represents the normalized result of the model's prediction. Each number in this matrix is a value between 0 and 1, and it is recorded using the following formula:
[0103] ;
[0104] First, based on the relative proportion of the input image to the model input, the width and height of the predicted bounding box are reconstructed, along with the aspect ratio of the ellipse parameters, to obtain the ellipse shape information matrix. :
[0105] ;
[0106] in, and The width and height of the predicted rectangle;
[0107] Calculate using the eigenvalue calculation formula Eigenvalues:
[0108] ;
[0109] In the formula, It is a 2×2 identity matrix. for The eigenvalues; solving this expression yields two roots. The larger of the roots is taken as the length of the semi-major axis of the ellipse. The smaller one is the semi-minor axis length. Then lengthen the semi-major axis. Substitute into the following formula to calculate its corresponding direction vector :
[0110] ;
[0111] Obtain the direction vector corresponding to the major axis ,in yes The component in the x-axis direction, for The component in the y-axis direction;
[0112] Direction vector Substitute into the following formula to obtain the rotation angle of the ellipse. :
[0113] ;
[0114] In the formula, This represents the arctangent value of two of the values;
[0115] The x and y coordinates of the center point of the ellipse Then it is:
[0116] ;
[0117] In the formula, and Represents the x and y coordinates of the center of the predicted rectangle. and To predict the width and height of the rectangle;
[0118] At this point, the major and minor axis lengths, center point, and rotation angle of the ellipse are obtained. Unreliable results are then filtered out based on confidence level, and redundant results are eliminated using NMS. The instrument dial detection is completed, and the areas containing the dial in the image are extracted for later use.
[0119] 4) Calculate ellipse information using the predicted ellipse parameters output by the elliptical target detection model, set the area outside the ellipse to 0 to eliminate interference from irrelevant background areas, and use the ellipse information to perform affine transformation correction on the dial image to reduce the adverse effects of shooting angle deviation on instrument readings. This completes the preprocessing stage of the dial image, resulting in the corrected dial image, as detailed below:
[0120] Set the area outside the ellipse to 0 to eliminate background influences other than the instrument panel. Then, use the major and minor axes, center point, and angle parameters of the ellipse obtained in step 3) to calculate the affine transformation matrix from the ellipse to the unit circle, and use this matrix as the transformation matrix. :
[0121] ;
[0122] In the formula, This is an inverse transformation of the elliptical shape information matrix. The inverse transformation ellipse position information matrix is calculated as follows:
[0123] ;
[0124] ;
[0125] use The image is corrected by affine transformation, which transforms the elliptical instrument dial into a circular shape, making the dial in the image perpendicular to the camera angle. This reduces the adverse effects of shooting angle deviation on instrument readings, completing the preprocessing stage of the dial image.
[0126] 5) Process the corrected dial image using an OCR model to obtain the position and value information of the scale digits. Use digital image processing methods to fit the straight line corresponding to the pointer on the dial image. Then, combine the position and value information of the scale digits above and use the distance method to calculate the instrument reading, thereby completing the automatic reading of the circular pointer instrument, as follows:
[0127] The dial image is processed using an OCR model to obtain the positions of each scale digit on the dial, and the center point of the transformed circle is used as the center point of the dial. Next, the image is binarized using the OTSU algorithm, and then noise is removed using erosion-dilation graphics operations. Each region is extracted, and the region with the largest area is retained as the pointer. The distance between the center point of each scale digit and the pointer is calculated, and the two closest points are selected as backups. Let these two points be... and Finally, the reading results were calculated using the distance method. :
[0128] ;
[0129] In the formula, , represent , The scale values corresponding to the two points This represents the length of line segment AC. The length of line segment AB represents the intersection point of the line fitted after refining the pointer area and the line connecting the two nearest scale numbers. Using the ratio of the distances between this point and the two scale numbers, as well as the scale value, the current reading of the instrument can be obtained.
[0130] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A method for reading circular pointer instruments based on elliptical target detection, characterized in that, Includes the following steps: 1) Collect instrument images containing pointer instruments, label the instrument dial area in the instrument image with a mask, and fit an ellipse using the mask label to obtain the major and minor axis lengths, center point and rotation angle of the ellipse, which are used to generate ellipse parameters representing the outline of the instrument dial, and obtain the instrument image and its corresponding label, which serve as the instrument dial dataset for subsequent training models. 2) The instrument panel dataset is fed into the improved YOLOX model for training. This improved YOLOX model has the ability to detect elliptical targets and can detect instrument panels after training. It takes the image data of the instrument panel dataset as input and the bounding rectangle and ellipse parameters of the instrument panel as output. The trained improved YOLOX model is used as the elliptical target detection model. The improved YOLOX model improves both the feature fusion module and the model head. For the feature fusion module, a dynamic upsampling module is used to replace the original static upsampling module to enhance detection performance. For the model head, an ellipse parameter prediction branch is added to the model head to enable it to detect elliptical targets. 3) Input the image of the target instrument containing the pointer instrument into the elliptical target detection model, output the predicted rectangle of the target instrument dial and the corresponding predicted ellipse parameters, decode the major and minor axis lengths, center point and rotation angle of the ellipse, and use the predicted rectangle to segment the area where the dial is located. 4) Calculate ellipse information using the predicted ellipse parameters output by the ellipse target detection model, set the area outside the ellipse to 0, eliminate interference from irrelevant background areas, and use the ellipse information to perform affine transformation correction on the dial image to reduce the adverse effects of shooting angle deviation on instrument readings, thus completing the preprocessing stage of the dial image and obtaining the corrected dial image. 5) Use an OCR model to process the corrected dial image to obtain the position and value information of the scale numbers. Use digital image processing methods to fit the straight line corresponding to the pointer on the dial image. Then, combine the position and value information of the scale numbers above and use the distance method to calculate the instrument reading, thereby completing the automatic reading of the circular pointer instrument.
2. The method for reading a circular pointer instrument based on elliptical target detection according to claim 1, characterized in that, Step 1) includes the following steps: 1.1) Image collection: Obtain instrument images from the Internet and take preset amounts of instrument images yourself; 1.2) Image annotation: Remove blurry, dirty, or incomplete images from the collected images; use a mask in the annotation tool to annotate all instrument panel areas to obtain the original image annotations; 1.3) Label Conversion: The original image labels are converted to obtain image labels containing bounding box labels and elliptical parameter labels. First, the bounding rectangle of the mask for each image label is obtained as the bounding box label. Then, ellipse fitting is performed on the mask of the image label to obtain the length of the major and minor axes, the center position, and the rotation angle of the ellipse. The affine transformation matrix of the ellipse relative to the unit circle is then calculated. This is called the original ellipse parameter, which is a 2×3 matrix containing six parameter terms. This is represented as a matrix, and it is divided into two submatrices: ; In the formula, This is an ellipse shape information matrix, 2×2 in size, representing the shape change of the ellipse compared to the unit circle. This is an ellipse position information matrix, 2×1 in size, representing the positional offset of the ellipse relative to the unit circle. Its specific composition and calculation method are as follows: ; ; In the formula, Let be the rotation angle of the major axis of the ellipse relative to the x-axis. and These are the lengths of the semi-major axis and semi-minor axis of the ellipse, respectively. These are the x and y coordinates of the center of the ellipse, respectively. These are the x and y coordinates of the center of the rectangle's annotation; Next, using the width and height of the rectangle annotations, the original ellipse parameters are scaled to obtain a normalized matrix. This is called the ellipse parameter annotation, which is a 2×3 matrix containing six parameter terms. express: ; In the formula, and These are the width and height of the rectangle, respectively.
3. The method for reading a circular pointer instrument based on elliptical target detection according to claim 2, characterized in that, In step 2), the training process for the improved YOLOX model is as follows: First, the dashboard dataset is augmented using random scaling, random erasure, and Mosiac data augmentation techniques. Simultaneously, because the model's input size is fixed, to ensure input consistency, the images in the dashboard dataset need to be scaled to a uniform size and normalized. During this process, the image dimensions will change. To ensure the accuracy of the ellipse parameters, ellipse parameter preprocessing is required, resulting in preprocessed image annotations, i.e., ellipse parameter annotations. Further modifications yielded the input model. These are called the training ellipse parameters: ; In the formula, and These represent the width ratio and length ratio of the images before and after preprocessing, respectively, as shown in the following formula: ; ; In the formula, , The width and height of the image before preprocessing. , These are the width and height of the preprocessed image; Preprocessed image annotations are matched with the image. The enhanced image is input into the improved YOLOX model. The improved YOLOX model's backbone network extracts the instrument's feature information, and then the extracted feature information is input into the improved feature fusion module for feature fusion at different scales. The dynamic upsampling module DySample is used to replace the original static upsampling module, which improves the model's ability to understand and fuse feature information at different scales. At the same time, dynamic upsampling can dynamically select sampling points, which is beneficial for the model to understand different elliptical shapes, thereby improving the effect of elliptical target detection. The fused features are input into the improved model head to obtain the prediction result. This improved model head adds an output convolutional layer as an elliptic parameter prediction branch. This elliptic parameter prediction branch shares input features with other regression parameters and outputs a 6-channel result after convolution processing, used to predict the elliptic parameter output. : ; In the formula, Represents the Sigmoid function. Represents a convolutional layer. Represents input features, The representative reshapes the outcome. This represents the width and height of the feature layer corresponding to the input features; where In the input feature layer, each feature point corresponds to a 2×3 matrix representing the parameters of the predicted ellipse, called... ; The predicted results are compared with the preprocessed image annotations. After calculating the loss function, the gradient is calculated using the backpropagation model, and the parameters are adjusted using the gradient descent method to make the model asymptotically optimized. Finally, an elliptical target detection model that can be used to detect the elliptical outline of pointer instruments is obtained.
4. The method for reading a circular pointer instrument based on elliptical target detection according to claim 3, characterized in that: In step 3), an elliptical target detection model is used to predict the instrument image. After inputting the instrument image, the model outputs the predicted bounding boxes and predicted ellipse parameters corresponding to each instrument panel target in the image. Among them, the width and height of the predicted rectangle are and The center point is located at Predicting ellipse parameters It is a 2×3 matrix containing six parameters. This represents the normalized result of the model's prediction. Each number in this matrix is a value between 0 and 1, and it is recorded using the following formula: ; First, based on the relative proportion of the input image to the model input, the width and height of the predicted bounding box are reconstructed, along with the aspect ratio of the ellipse parameters, to obtain the ellipse shape information matrix. : ; in, and The width and height of the predicted rectangle; Calculate using the eigenvalue calculation formula Eigenvalues: ; In the formula, It is a 2×2 identity matrix. for The eigenvalues; solving this expression yields two roots. The larger of the roots is taken as the length of the semi-major axis of the ellipse. The smaller one is the semi-minor axis length. Then lengthen the semi-major axis. Substitute into the following formula to calculate its corresponding direction vector : ; Obtain the direction vector corresponding to the major axis ,in yes The component in the x-axis direction, for The component in the y-axis direction; Direction vector Substitute into the following formula to obtain the rotation angle of the ellipse. : ; In the formula, This represents the arctangent value of two of the values; The x and y coordinates of the center point of the ellipse Then it is: ; In the formula, and Represents the x and y coordinates of the center of the predicted rectangle. and To predict the width and height of the rectangle; At this point, the major and minor axis lengths, center point, and rotation angle of the ellipse are obtained. Unreliable results are then filtered out based on confidence level, and redundant results are eliminated using NMS. The instrument dial detection is completed, and the areas containing the dial in the image are extracted for later use.
5. The method for reading a circular pointer instrument based on elliptical target detection according to claim 4, characterized in that: In step 4), the area outside the ellipse is set to 0 to eliminate background influences outside the instrument panel. Then, the affine transformation matrix from the ellipse to the unit circle is calculated using the major and minor axes, center point, and angle parameters of the ellipse obtained in step 3), and this matrix is used as the transformation matrix. : ; In the formula, This is an inverse transformation of the elliptical shape information matrix. The inverse transformation ellipse position information matrix is calculated as follows: ; ; use The image is corrected by affine transformation, which transforms the elliptical instrument dial into a circular shape, making the dial in the image perpendicular to the camera angle. This reduces the adverse effects of shooting angle deviation on instrument readings, completing the preprocessing stage of the dial image.
6. The method for reading a circular pointer instrument based on elliptical target detection according to claim 5, characterized in that: In step 5), the dial image is processed using an OCR model to obtain the positions of each scale digit on the dial, and the center point of the transformed circle is used as the center point of the dial. Next, the image is binarized using the OTSU algorithm, and then noise is removed using a graphics operation of erosion followed by dilation. Each region is extracted, and the region with the largest area is retained as the pointer. The distance between the center point of each scale digit and the pointer is calculated, and the two closest points are selected as backups. Let these two points be... and Finally, the reading results were calculated using the distance method. : ; In the formula, , represent , The scale values corresponding to the two points This represents the length of line segment AC. The length of line segment AB represents the intersection point of the line fitted after refining the pointer area and the line connecting the two nearest scale numbers. Using the ratio of the distances between this point and the two scale numbers, as well as the scale value, the current reading of the instrument can be obtained.