Machine vision-based nested non-uniform dial reading method
Through improved machine vision methods, including improved Hough transform and regression method, combined with distance method, the robustness problem of the prior art under the conditions of light interference and uneven scales is solved, and efficient in the substation environment is achieved. Accurate meter readings.
Patent Information
- Application Number
- CN202411246015.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2044-09-06
AI Technical Summary
Existing machine vision technology is weak in dealing with lighting interference, multi-dials, and uneven scales, making it difficult to achieve efficient and accurate instrument readings, especially in complex environments of substations.
The improved machine vision method is adopted, including building instrument image sets, training detection models, using the improved Hough transformation algorithm to obtain the center and radius of the dial, fit the pointer line based on the regression method, compute the dial readings with the distance method, and track the arc segment and The bit accumulator quickly locates the center of the circle, reducing calculation complexity and hardware requirements.
It improves the robustness and efficiency of instrument readings, can accurately read in different pixel distributions and uneven scales, meets real-time automation needs, reduces hardware requirements, and is suitable for lightweight equipment.
Smart Images

Figure CN119152488A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of machine vision, in particular to a nested non-uniform scale dial reading method based on machine vision. Background Art
[0002] Machine vision plays a significant role in the digitalization of industrial production due to its efficient and precise working characteristics. Among them, the meter reading method based on machine vision works well in identifying the readings of pointer-type circular dials, in response to the problems of numerous dials in substations, low manual reading efficiency and high false detection rate. However, the mainstream dial reading method has great limitations, and its robustness is weak in situations with light interference, a large number of dials, and uneven scales, making it difficult to cope with more complex working environments. Therefore, designing a machine meter reading method that is suitable for external interference, nested large and small dials, and uneven scales is of great significance to the development of industrial automation.
[0003] In recent years, many scholars have done a lot of research in the field of machine vision:
[0004] Glenn Jocher proposed the YOLOv5 network, which has strong capabilities in image classification and positioning. Its derivative series include n, s, m, l, x, and the number of network parameters increases from left to right. The lightweight yolov5s has fewer parameters, but the regression of the bounding box is not accurate enough; yolov5l has high accuracy in target object recognition and positioning, but the required hardware requirements are high, it takes up a lot of memory, and has a slow running speed.
[0005] Zhang Jin's academic paper "An Improved YOLOv5-Based Safety Helmet Wearing Detection Algorithm" uses the K-Means++ algorithm to redesign the prior frame size and match it to the corresponding feature layer; introduces a multi-spectral channel attention module into the feature extraction network, enabling the network to autonomously learn the weight of each channel, enhance information propagation between features, and thus enhance the network's ability to distinguish foreground and background. However, this method has a large number of parameters, which reduces the meter reading speed and is difficult to meet the heavy reading tasks of substations.
[0006] Patent application CN112257676A determines the maximum angle of the pointer when it is at the zero scale line and the maximum range, as well as the deflection angle between the current position of the dial and the zero scale line, based on the principle that the reading change of the uniform dial is proportional to the deflection angle of the pointer, combined with the range and based on the proportion of the deflection angle in the maximum angle, the number pointed by the pointer is read. This method is simple and fast, but it cannot handle uneven dials.
[0007] Wang Tuo's academic paper "Research on Improved Hough Transform Algorithm" proposed an algorithm based on a lookup table and a bit accumulator. The algorithm uses the direction information of the vertical line on the circle boundary point to quickly and accurately detect and measure circular objects, while also overcoming the shortcomings of the Hough transform, which is complex in calculation and consumes a lot of memory. However, this method is only used for relatively regular and complete circles, and is less applicable in the context of searching for circles with occlusion and missing pixels.
[0008] The academic paper "Automatic Reading Method of Pointer Instrument Based on Deep Learning" published by Yang Shiqi combines the average intersection-over-union ratio and morphological corrosion method to effectively extract the scale contour through model training, providing exploration space for processing small dials and target refinement.
[0009] Although the pointer meter reading method based on machine vision has made some progress in recent years in terms of area positioning and target pixel extraction, it still has the following shortcomings:
[0010] 1. There are two representative methods for the circle detection problem. The circular Hough transform based on the whole circle regards the binary coordinates of the edge points of the circular contour as parameters, and the binary coordinates and radius of the target circle to be measured as three-dimensional vectors, and obtains the solution vector by finding the intersection of the conical surfaces with multiple parameters as vertices. This method is highly robust and not easily affected by incomplete data; however, the amount of calculation and the accumulator data structure of this method will increase exponentially with the increase of curve parameters. The RCD algorithm based on discrete points randomly selects three non-collinear points from the edge image to form a circle, and determines whether it is a true circle based on the ratio of the accumulated pixel points on the candidate circle to the circumference. This method takes up little memory, but it is easy to introduce a large number of invalid sampling, which seriously reduces the calculation speed.
[0011] 2. The commonly used method for line detection is Hough line transform, which has good robustness and strong anti-interference ability. It is insensitive to the missing part of a line in the image and the non-linear part coexisting with it, and can detect multiple lines in one image. However, the spatial complexity of Hough transform is large, resulting in low algorithm efficiency and large memory usage; at the same time, its detection accuracy is limited by parameters. The pointers of small dials in different nested dials have different aspect ratios, making it difficult to fit a straight line with the same set of parameters of Hough transform, and manual adjustment of parameters cannot meet the needs of automated inspection.
[0012] 3. The automatic reading scheme of conventional instruments usually does not rely on the relationship between the pointer and the scale for reading, so most methods only extract part of the scale outline and ignore some minor scale lines. However, for dials with uneven scales, only extracting the main scale outline will seriously weaken the reading accuracy; at the same time, most scale extraction methods use Canny edge detection to obtain the outline, and use the intersection and union ratio of overlapping outlines to filter out the real scale. However, the small dials embedded in the large instrument have dense scale lines, and the scale fitting rectangles have a high overlap rate and are very close. It is difficult to effectively eliminate redundant rectangular frames using the intersection and union ratio as a screening indicator;
[0013] 4. Most instrument reading methods use the angle method, which multiplies the range by the ratio of the deflection angle between the pointer and the zero scale line to the angle between the maximum range fitting line and the zero scale line. However, the angle method is based on the principle that the length of the arc drawn by the pointer is proportional to the deflection angle, so it has low applicability and cannot handle instruments with uneven scales. Summary of the invention
[0014] The present invention aims to address the deficiencies of the above-mentioned prior art and proposes a nested non-uniform scale dial reading method based on machine vision, in order to improve the reading efficiency and reduce the required hardware conditions while ensuring the reading accuracy, so that it can be widely used in real-time reading work scenarios relying on lightweight equipment.
[0015] In order to achieve the above-mentioned purpose, the present invention adopts the following technical scheme:
[0016] The nested non-uniform scale dial reading method based on machine vision of the present invention is characterized in that the method is performed according to the following steps:
[0017] Step 1. Build a collection of instrument images and train an instrument detection model ;
[0018] Step 2. Input the image of the instrument to be tested into the instrument detection model Processed in Single dial rectangular image ;in, represents the i-th single dial rectangular image in the instrument image to be tested, Represents the total number of single dial rectangular images;
[0019] Step 3. Perform preprocessing operations, including grayscale, median filtering, and image enhancement to obtain the i-th single dial rectangular image after preprocessing ,by The lower left corner is the origin, and the horizontal right is Axis, vertical upward Axis, thereby establishing the image coordinate system;
[0020] Step 4. Obtain based on the improved Hough transform algorithm The coordinates of the dial center and radius ;
[0021] Step 5. Obtain based on regression method The pointer fits the straight line equation: , and satisfies ,in, express The slope of the pointer fitting straight line equation, express The intercept of the pointer fitting straight line equation, express The horizontal coordinate of the pixel point in the pointer domain, express The vertical coordinate of the pixel point in the pointer domain;
[0022] Step 6. Acquire based on the real scale extraction algorithm The ordered real scale line fitting rectangle frame information set ;
[0023] Step 7. Based on the distance method, the equation of the straight line is fitted according to the pointer Get it in sequence Dial reading ;
[0024] Step 8. Dial reading Perform linear operations to obtain the final reading of the instrument image to be tested .
[0025] The method for reading a meter using a nested non-uniform dial based on machine vision according to the present invention is also characterized in that step 1 comprises the following steps:
[0026] Step 1.1: Collect nested non-uniform scale instrument images in the substation to construct an instrument image set ;
[0027] Step 1.2: Instrument image collection The instrument area in is annotated to obtain a set of instrument images with labels ;
[0028] Step 1.3: Collect the labeled instrument images Input into the improved YOLOv5 network for training to obtain the instrument detection model .
[0029] Furthermore, the improved Hough transform algorithm in step 4 comprises the following steps:
[0030] Step 4.1: Use arc segment tracking algorithm to obtain In Discrete arcs:
[0031] Step 4.2: Based on the circle gradient, multiple candidate circle centers are obtained from the discrete arc segments;
[0032] Step 4.3: Introduce a lookup table and a bit accumulator to vote for candidate circle centers to determine the target circle center;
[0033] Give each candidate circle a different center Bit binary lookup table, and each candidate circle center corresponds to In the binary lookup table, only one bit is 1, and the rest are 0;
[0034] remember The coordinates are The number of votes for the candidate center in binary, Indicates The binary values of candidate circle centers, where ;
[0035] Traverse each candidate circle center in turn and use the bit accumulator to Grant , thus obtaining the final number of votes for each candidate center, and The candidate center with the largest number of 1s is set as the target center. ,in, Represents a bitwise OR operation.
[0036] Furthermore, the step 4.1 comprises the following steps:
[0037] Step 4.1.1: Binarization is performed to obtain a binary image with a grayscale value of 255 for the edge pixels and a grayscale value of 0 for the rest of the pixels. ;
[0038] Define and initialize the number of discrete arcs , define and initialize the current point is empty;
[0039] Step 4.1.2: Scan the binary image in a certain order If the scanned pixel has a grayscale value of 255, the first scanned pixel with a grayscale value of 255 is used as the starting point. , and set the current point Starting point , define and initialize the markers Then, execute step 4.1.3, otherwise, save For each arc segment, execute step 4.2;
[0040] Step 4.1.3: Assign to , the starting point Join In the arc segment;
[0041] Step 4.1.4: The gray value of the newly added coordinate points in the arc segment is set to 0;
[0042] Step 4.1.5: Traverse the current point clockwise Among the 4 4-adjacent points, determine whether there is a 4-adjacent point with a grayscale value of 255. If so, set the first 4-adjacent point with a grayscale value of 255 read as the current point. , and the current point Join If there is no arc segment, execute step 4.1.4; if not, execute step 4.1.6;
[0043] Step 4.1.6: Traverse the current point clockwise Among the four 8-adjacent oblique points, determine whether there is an 8-adjacent oblique point with a grayscale value of 255. If so, set the first 8-adjacent oblique point with a grayscale value of 255 read as the current point. , and the current point Join arc segment, execute step 4.1.4; if it does not exist, determine Is it true? If so, go to 4.1.7; otherwise, go to step 4.1.2;
[0044] Step 4.1.7: Set the starting point For the current point , will order Then, proceed to step 4.1.5.
[0045] Furthermore, the step 4.2 comprises the following steps:
[0046] Step 4.2.1: Calculate the binary image The horizontal gradient vector of each point in and vertical gradient vector ;
[0047] The number of arcs traversed is , and initialize ; Define the number of candidate circles as , and initialize , set the maximum number of candidate circles to ;remember The center coordinates are ; Recorded as The coordinates of the centers of candidate circles are ;
[0048] Step 4.2.2: Define and initialize variables ; Record The total number of points in an arc segment is ;
[0049] Step 4.2.3: The first The points are recorded as ; Select any point from other arc segments and record it as , and satisfy: ;
[0050] from Select the point that satisfies the first change rule As The first change rule is:
[0051] like , from Change to ;
[0052] like , from Change to ;in, is a given constant;
[0053] like In the process of moving along the first change rule, if equation (1) is satisfied, then Set as symmetric point, and Set as , execute step 4.2.4; otherwise, execute step 4.2.8;
[0054] (1)
[0055] In formula (1), , Respectively , The horizontal gradient vector, , Respectively , The vertical gradient vector of
[0056] Step 4.2.4: and its symmetric point Substituting into formula (2), we get Middle The coordinates of the candidate centers and its corresponding radius :
[0057] (2)
[0058] In formula (2), int() represents the rounding operation;
[0059] Step 4.2.5: If , then Assign to , otherwise, Assign to ;
[0060] like , then Grant If yes, go to step 4.2.6; otherwise, go to step 4.2.7;
[0061] Step 4.2.6: If , then execute step 4.2.4; otherwise, save The coordinates of candidate circle centers;
[0062] Step 4.2.7: If , then Grant Then, execute step 4.2.3; otherwise, judge If so, Grant Then, execute step 4.2.2, otherwise, save The coordinates of candidate circle centers and Assign to ;
[0063] Step 4.2.8. Select any point from other arc segments and record it as , and satisfy: ;
[0064] from Select the points that satisfy the second change rule As Another preliminary point, the second change rule is:
[0065] like , from Change to ;
[0066] like , from Change to ;in, is a given constant;
[0067] like In the process of moving along the second change rule, if equation (3) is satisfied, then Set as symmetric point, and Set to , execute step 4.2.9; otherwise, execute step 4.2.7;
[0068] (3)
[0069] In formula (3), , Respectively , The horizontal gradient vector, , Respectively , The vertical gradient vector of
[0070] Step 4.2.9: and its symmetric point Substituting into formula (4), we get Middle Candidate center points and their corresponding radius :
[0071] (4)
[0072] Step 4.2.10: If , then Assign to , otherwise, Assign to ;
[0073] like , then Grant If yes, execute step 4.2.11; otherwise, execute step 4.2.7;
[0074] Step 4.2.11: If , then execute step 4.2.9; otherwise, save The coordinates of the candidate circle centers.
[0075] Furthermore, the step 5 comprises the following steps:
[0076] Step 5.1: Make a A first mask of the same size, wherein the first mask is formed by is the center of the circle and the radius is × The circle area is set to white, and the rest of the area is set to black; represents the first radius scaling factor, ;
[0077] Step 5.2: Place the first mask with Perform a bitwise AND operation to obtain a pointer image without scales ;
[0078] Step 5.3: After binarization, corrosion, and expansion operations, the image is obtained , and then the image Extract and obtain The set of pixel points in the pointer connected domain :
[0079]
[0080] in, express The mth pixel point in the pointer connected domain, express The total number of pixels in the connected domain of the pointer;
[0081] Step 5.4: Given The learning rate , the absolute value of the threshold ;
[0082] Step 5.5: Grant ;
[0083] Step 5.6: If , then it means that The pointer fits the straight line equation: ; Otherwise, return to 5.5 and execute sequentially.
[0084] Furthermore, step 6 comprises the following steps:
[0085] Step 6.1: Make a A second mask of the same size, wherein the second mask is formed by is the center of the circle and the radius is × to The circle area is set to white, and the rest of the area is set to black; represents the second radius scaling factor, ;
[0086] Step 6.2: Place the second mask with Perform bitwise AND operation to obtain the scale image ;
[0087] Step 6.3: Scale the image according to the true scale extraction algorithm Extract and obtain the ordered real scale line fitting rectangular frame information set .
[0088] Furthermore, the real scale extraction algorithm in step 6.3 comprises the following steps:
[0089] Step A: Use the improved Canny edge detection algorithm to Process and obtain All rectangular boxes in ;
[0090] Step A1: Given parameters, including: low threshold , Low threshold single cycle increase , Lower threshold upper limit , the difference between the high and low thresholds , the minimum area of the rectangular frame , maximum area , minimum aspect ratio , maximum aspect ratio , Lower limit of the number of intersecting rectangles ; The lower limit of the number of true tick marks , distance threshold ;
[0091] Will The number of edge detections is recorded as , and initialized to =1;
[0092] Step A2: If , then execute step A3; otherwise, it means that Rectangular frame information collection = , and execute step B, wherein, express The total number of rectangles contained in the information. express The Rectangular frame information, and the Rectangle information Contains the center coordinates of a rectangular box and its width ,high and rotation angle , ;
[0093] Step A3: According to , ,right Conduct the Second-rate Edge detection, get the Detected edge image ;according to , , , , After obtaining a certain number of rectangular frame information, Grant ,Will Grant , execute step A2;
[0094] Step B: Elimination The redundant rectangular boxes in the pre-screened rectangular box information set is obtained :
[0095] Step B1: If The number of elements in is greater than , then from Take out the first rectangular box information , execute step B2, otherwise, obtain the pre-screened rectangular frame information set:
[0096] , and execute step C, wherein, express Middle Rectangular frame information, express The total number of rectangular frame information contained;
[0097] Step B2: From Find the The number of intersecting rectangles ;like , then execute step B3; otherwise, from , and After reordering, return to step B1 and execute sequentially;
[0098] Step B3: The rectangular frame information is sorted in descending order according to the area of its own rectangular frame, and the first The rectangular frame information of the bit is stored in ; then The rectangular frame information is from , and After reordering, return to step B1 and execute sequentially;
[0099] Step C: Extraction After sorting the real scale in the, we get the ordered real scale line fitting rectangle information set ;
[0100] Step C1: If If it is empty, execute step C4, otherwise, execute step C2;
[0101] Step C2: From Get the first rectangular box information ,Pass The center coordinates of Draw a straight line parallel to the long side of its own rectangle , thus calculating the center of the circle To the straight line Distance , calculate the center of the circle arrive Distance , calculate the direction of the center of the circle The angle between the vector of the circle and the vector pointing to the right horizontally ;
[0102] Step C3: If , then , , Deposit as a whole , and from After being removed from the list, execute step C1. Otherwise, directly from Remove it and execute step C1;
[0103] Step C4: From Find the circle with the highest frequency of distance from the center to the center coordinates A rectangular frame will be aligned according to the angle After the rectangular boxes are arranged in descending order, the ordered real scale line fitting rectangular box information set is obtained. :
[0104] ;in, express Middle Rectangular frame information, express points within To the center The distance Indicates the direction of the center of the circle points within The angle between the vector pointing to the right and the horizontal vector pointing to the center of the circle.
[0105] Further, the step 7 comprises:
[0106] Step 7.1: Make a picture with A third mask of the same size, wherein the third mask is is the center of the circle and the radius is The circle area is set to white, and the rest of the area is set to black;
[0107] Step 7.2: Place the third mask with Perform a bitwise AND operation to obtain a circular instrument image ,and The coordinate points within Coordinate points of the inner rectangle, pointer fitting straight line equation The coordinates of the points;
[0108] Step 7.3: Create The dial polar coordinate system is the origin and the horizontal right is the polar axis;
[0109] Step 7.4: Expand the dial polar coordinate system to the set size The horizontal axis of the rectangular area is denoted by , the vertical axis of the rectangular area is denoted by ;
[0110] Use formula (1) to convert the dial polar coordinate system into The coordinates of any point in Map to the rectangular area and get the corresponding new coordinate point ; Thus, all new coordinate points constitute an ordered real scale line fitting rectangular frame information set , and get the new pointer fitting straight line equation ;in, Indicates the new pointer fitting line equation Axis coordinates;
[0111] (1)
[0112] In formula (2), is the width of the rectangular area, is the height of the rectangular area, and , ;
[0113] Step 7.5: Based on the known instrument range, we can get The absolute value of the difference between adjacent scale readings ;
[0114] Step 7.6: Use formula (2) to calculate Dial reading ;
[0115] (2)
[0116] In formula (2), Indicates The equation of the straight line from the scale line to the new pointer distance, and , Indicates The equation of the straight line from the scale line to the new pointer distance, and ,in, yes Middle The coordinates of the center of the fitted rectangle of each scale line on the horizontal axis; yes Middle The coordinates of the center of the fitted rectangle of each tick mark on the horizontal axis.
[0117] The electronic device of the present invention includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the nested non-uniform scale dial reading method, and the processor is configured to execute the program stored in the memory.
[0118] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0119] 1. The automatic meter reading method of the present invention adopts the improved circular gradient symmetric Hough transform, which obtains arc segments by tracing the edge of the image, avoiding the problem of serious noise interference on low-resolution images, and ensuring the high robustness of the method. The arc segments are used to find the target point without traversing all pixel points, which can significantly improve the calculation rate for high-resolution images; based on the symmetry of the circular gradient, the relationship between the perpendicular bisector of the symmetric point and the center of the circle is used to quickly locate the center range of the circle, while avoiding the problem that the normal direction of a single point is easy to deviate from the center of the circle, taking into account the speed and accuracy of the method; a bit accumulator is introduced to complete the center voting task based on the bitwise OR operation, which occupies less memory and has lower hardware requirements.
[0120] 2. The automatic meter reading method of the present invention is based on the regression concept to determine the pointer fitting line. The regression method has strong adaptability and can fit a straight line under different pixel distributions without manual adjustment of parameters, thus meeting the needs of automated detection. It avoids the situation where the fitting line is located at the edge of the pointer image, thereby improving the fitting accuracy. The center coordinates of the circle are introduced to transform the binary regression problem into a univariate regression problem, thereby improving the calculation speed. At the same time, the fixed point is used to reduce the error range of the fitting line, thereby further improving the fitting accuracy.
[0121] 3. The automatic meter reading method of the present invention uses a loop statement to change the set threshold of Canny edge detection one by one, and can obtain all the fitted rectangular frames on the dial, avoiding the problem of limited scale contour extraction capability caused by a single threshold. At the same time, the number of overlapping rectangular frames is used as the criterion to avoid the problem of overlapping rectangular frames being difficult to screen due to similar intersection and union ratios, and can effectively distinguish candidate scale lines from interference information; in addition, based on the geometric conditions that the scale lines are aligned with the center of the circle and the distance from the center of each scale line to the center of the circle is the same, the distance from the center of the circle to the straight line and the distance from the center of the circle to the center of the rectangular frame are introduced as further screening conditions, which can obtain scale line information with higher accuracy.
[0122] 4. The automatic meter reading method of the present invention uses the distance method to calculate the dial reading, and determines the actual reading according to the positional relationship between the pointer and the ordered scale lines, solving the problem of uneven scale meter reading that the angle method cannot cope with. In addition, the method uses coordinate transformation to map the circular scale line area to the rectangular area, and can accurately obtain the distance between the pointer fitting line and the adjacent scale rectangular frames, thereby accurately calculating the distance between the pointer fitting line and the adjacent scales. BRIEF DESCRIPTION OF THE DRAWINGS
[0123] Figure 1 It is a flow chart of the steps of the present invention;
[0124] Figure 2 This is a diagram of the improved YOLOv5 network structure of the present invention;
[0125] Figure 3 The improved CBAM module structure diagram of the present invention;
[0126] Figure 4 The working principle diagram of the SPD module introduced in the present invention;
[0127] Figure 5 This is a flow chart of the arc segment tracking algorithm of the present invention;
[0128] Figure 6 The flowchart of the improved Hough transform algorithm of the present invention;
[0129] Figure 7 This is a flow chart of the true scale extraction algorithm of the present invention. DETAILED DESCRIPTION
[0130] In this embodiment, a nested non-uniform dial reading method based on machine vision has the characteristics of high accuracy and strong robustness, and can complete the reading of various dials. The main steps include: 1. constructing an instrument image set and performing model training, 2. obtaining a single dial image, 3. obtaining the center and radius of the dial, 4. obtaining a fitting straight line of the dial pointer, 5. obtaining the dial scale fitting rectangular frame information, and 6. calculating the reading. Specifically, Figure 1As shown, the method is performed in the following steps:
[0131] Step 1. Build a collection of instrument images and train an instrument detection model ;
[0132] Step 1.1: Collect nested non-uniform scale instrument images in the substation to construct an instrument image set ;
[0133] Step 1.2: Use Labelimg to analyze the instrument image collection The instrument area in is annotated to obtain a set of instrument images with labels and a .txt file with the labeled rectangle information;
[0134] Step 1.3: Configure the .yaml file to collect instrument images with labels Input into the improved YOLOv5 network for training to obtain the instrument detection model .
[0135] In order to enable the network to recognize objects with lower resolution, retain the deep feature information of the image, and avoid interference from other objects on the detection target, such as Figure 2 As shown, the YOLOv5 network used in this embodiment makes the following improvements:
[0136] Improvement 1: Replace the C3 module in the backbone network with an improved C3 module. In the improved C3 module, each CBS is connected to an SPD module. The function of the SPD is as follows: Figure 4 As shown: Given a feature map X of arbitrary size S×S×C, SPD maps the sub-features of the feature map X into a square area with [0,0] and [scale-1,scale-1] as diagonal vertices:
[0137]
[0138] and Represents the same type of feature information, ,satisfy:
[0139]
[0140] The scale of the new feature map obtained after SPD processing is: ; Then the number of channels of the spliced image The number is converted to the original network through the subsequent CBS module; Figure 4 As shown, in this embodiment Taking 2, this method not only meets the requirements of feature extraction and information retention, but also avoids the huge amount of calculation caused by the doubling of the number of channels; in other embodiments, the SPD module can also be added to other C3 modules in the YOLOv5 network;
[0141] Improvement 2: Extend the FPN structure of the neck network, and connect CBS, UpSample, Concat, and C3 outward in sequence at the top of FPN; extend the PAN structure of the neck network, and connect C3, Concat, and CBS outward in sequence at the top of PAN; and connect the C3 module at the top of the improved FPN structure with the CBS module at the top of the improved PAN structure; connect a new detection head at the top of the FPN structure of the neck network, so that the network can detect small targets with a resolution of not less than 16 pixels;
[0142] Improvement 3: In the original YOLOv5 network, an improved CBAM module is introduced on the connection path between the C3 module of the backbone network and the Concat of the neck network, such as Figure 3 As shown; the improved CBAM module adopts the following operation process: input a The image In is processed by CAM (channel attention module) and SAM (spatial attention module) to obtain Result Plot and Result Plot ; The result graphs are And the result graph Multiply it with the image In to get the result image And the result graph ;Will and Multiply the weights Adding them together, ; Then, a batch normalization operation is performed to obtain the output graph Out. In this embodiment, and The value of is obtained by network training. Figure 3 As shown in the figure: a and b in the name of the C3ab module are both numbers, where a takes the value of 1 and 2, respectively indicating that the BottleNect1 module and BottleNect2 are used in the C3 module; b represents the number of BottleNeck modules connected in sequence in the C3 module, and its value can be 3, 6, or 9.
[0143] The automatic meter reading method in this embodiment is based on the improved YOLOv5 network to recognize the instrument image. The beneficial effects after the improvement are as follows: the neck network is extended and a new detection head is added to extract and output the shallow information of the image; the improved CBAM module is introduced in the connection path between the C3 module of the backbone network and the Concat of the neck network. The improved CBAM module uses a parallel structure to communicate the channel and spatial feature information of the image, and obtains the output image through weighted fusion, which effectively solves the different preferences of different network layers for feature information. At the same time, batch normalization operation is used after weighted fusion to regularize the data and alleviate the problems of internal covariate offset and model overfitting; the SPD module is embedded in the C3 module of the backbone network, and the feature map can be convolutionally downsampled to reduce the loss of feature information caused by convolution for small target detection.
[0144] Step 2. Input the 640×640×3 image to be tested into the instrument detection model Processed in Single dial rectangular image ;in, represents the i-th single dial rectangular image, and N represents the total number of single dial rectangular images;
[0145] Step 3. Perform preprocessing operations, including grayscale, median filtering, and image enhancement; then The lower left corner is the origin, and the horizontal right is Axis, vertical upward Axis, thereby establishing an image coordinate system. In other embodiments, the system can also be established according to other rules.
[0146] Step 4. Obtain based on the improved Hough transform algorithm The coordinates of the dial center and radius ; Specifically, the improved Hough transform algorithm is performed according to the following steps:
[0147] Step 4.1: Use arc segment tracking algorithm to obtain Discrete arc segments in :
[0148] Step 4.1.1: Figure 5 As shown, first Binarization is performed to obtain a binary image with a grayscale value of 255 for the edge pixels and a grayscale value of 0 for the rest of the pixels. In this embodiment, the grayscale value of the pixel at the edge is set to 255, and the grayscale value of the pixel at the rest is set to 0. In other embodiments, different binarization methods can also be used, but the starting point The judgment conditions of also change due to different binarization methods;
[0149] Redefine and initialize the number of discrete arc segments , define and initialize the current point Empty; front point The position of will be constantly changed during the tracking process, the purpose is to extend the arc segment in a certain direction.
[0150] Step 4.1.2: Scan the binary image in a certain order Here, in order from top to bottom and from left to right, if a pixel with a grayscale value of 255 is scanned, the first pixel with a grayscale value of 255 scanned is used as the starting point. , and set the current point Starting point ,, starting point Record the entry position of the current arc segment. When the arc segment extends to the end in a certain direction, the current point Back to the starting point , so that the arc segment extends in another direction; define and initialize the marker Then execute step 4.1.3, otherwise, save For each arc segment, execute step 4.2; The function is to record whether the starting point has been returned during the tracking process ,if Description: Has not returned to the starting point yet ,if Indicates that you have returned to the starting point .
[0151] Step 4.1.3: Assign to , the starting point Join In the arc segment;
[0152] Step 4.1.4: The grayscale value of the newly added coordinate points in the arc segment is set to 0; this step is to prevent the pixel points from being tracked repeatedly;
[0153] Step 4.1.5: Traverse the current point clockwise Among the four 4-adjacent points, determine whether there is a 4-adjacent point with a grayscale value of 255. The 4-adjacent points refer to the adjacent points in the horizontal and vertical directions. Here, the traversal starts from the adjacent points in the vertical direction. If there is, set the first 4-adjacent point with a grayscale value of 255 read as the current point. , and the current point Join If there is an arc segment, execute step 4.1.4; if it does not exist, execute step 4.1.6.
[0154] Step 4.1.6: Traverse the current point clockwise Among the four 8-adjacent oblique points, determine whether there is an 8-adjacent oblique point with a grayscale value of 255. The 8-adjacent point is a diagonal adjacent point. Here, the traversal starts from the 8-adjacent point in the lower left corner. If it exists, set the first 8-adjacent oblique point with a grayscale value of 255 read as the current point. , and the current point Join arc segment, execute step 4.1.4; if it does not exist, determine Is it true? If so, go to 4.1.7. Here, it means that the arc segment is extended in only one direction and needs to return to the starting point. Start extending in the other direction; otherwise, execute step 4.1.2, which means that the arc segment has been extended and the next arc segment to be tracked needs to be found;
[0155] Step 4.1.7: Set the starting point For the current point , will order Then, proceed to step 4.1.5.
[0156] Step 4.2: Determine the candidate circle center based on the circle gradient:
[0157] Step 4.2.1: Figure 6 As shown, the binary image is calculated The horizontal gradient vector of each point in and vertical gradient vector According to the system construction rules of the embodiment, horizontally to the right and vertically upward are respectively defined as vectors in the positive x and y directions;
[0158] The number of arcs traversed is , and initialize ; Define the number of candidate circles as , and initialize , set the maximum number of candidate circles to ;remember The center coordinates are ; Recorded as The coordinates of the centers of candidate circles are ; Set here is 64.
[0159] Step 4.2.2: Define and initialize variables ; Record The total number of points in an arc segment is ;
[0160] Step 4.2.3: The first The points are recorded as ; Select any point from other arc segments and record it as , and satisfy: ;
[0161] from Select the point that satisfies the first change rule As The first change rule is:
[0162] like , from Change to ;
[0163] like , from Change to ; here Set to 4;
[0164] like In the process of moving along the first change rule, if equation (1) is satisfied, then Set as symmetric point, and Set as , execute step 4.2.4; otherwise, execute step 4.2.8;
[0165] (1)
[0166] In formula (1), , Respectively , The horizontal gradient vector, , Respectively , The vertical gradient vector of the discrete arc segment is obtained by this operation. It does not need to traverse all the pixels in the same line, and the operation speed is fast when processing high-resolution images. At the same time, different system construction rules need to be adjusted. of changing rules.
[0167] Step 4.2.4: and its symmetric point Substituting into formula (2), we get Middle The coordinates of the candidate circle centers and its corresponding radius :
[0168] (2)
[0169] In formula (2), int() represents the rounding operation;
[0170] Step 4.2.5: If , then Assign to , otherwise, Assign to ;
[0171] like , then Grant If yes, proceed to step 4.2.6; otherwise, proceed to step 4.2.7.
[0172] Step 4.2.6: If , then execute step 4.2.4; otherwise, save The coordinates of candidate circle centers;
[0173] Step 4.2.7: If , then Grant Then, execute step 4.2.3; otherwise, judge If so, Grant Then, execute step 4.2.2, otherwise, save The coordinates of candidate circle centers and Assign to ;
[0174] Step 4.2.8. Select any point from other arc segments and record it as , and satisfy: ;
[0175] from Select the points that satisfy the second change rule As Another preliminary point, the second change rule is:
[0176] like , from Change to ;
[0177] like , from Change to ; here Set to 4;
[0178] like In the process of moving along the second change rule, if equation (3) is satisfied, then Set as symmetric point, and Set to , execute step 4.2.9; otherwise, execute step 4.2.7;
[0179] (3)
[0180] In formula (3), , Respectively , The horizontal gradient vector, , Respectively , The vertical gradient vector of of changing rules.
[0181] Step 4.2.9: and its symmetric point Substituting into formula (4), we get Middle Candidate center points and their corresponding radius :
[0182] (4)
[0183] Step 4.2.10: If , then Assign to , otherwise, Assign to ;
[0184] like , then Grant If yes, execute step 4.2.11; otherwise, execute step 4.2.7;
[0185] Step 4.2.11: If , then execute step 4.2.9; otherwise, save The center coordinates of the candidate circles.
[0186] 4.3: Introduce the lookup table and bit accumulator to vote for the candidate center and determine the target center:
[0187] Give each candidate circle a different center Bit binary lookup table, and each candidate circle center corresponds to In the binary lookup table, only one bit is 1, and the rest are 0;
[0188] remember The coordinates are The number of votes for the candidate center of the circle in binary is presented in the form of a binary number table in this embodiment. Indicates The binary values of candidate circle centers, where .
[0189] Traverse each candidate circle center in turn, such as Figure 6 As shown, and through the bit accumulator Grant , thus obtaining the final number of votes for each candidate center, and The candidate center with the largest number of 1s is set as the target center. ,in, Represents a bitwise OR operation. For example, suppose there are two candidate circle centers , , there are 5 points pointing to the coordinates , the corresponding lookup table bits are: [00000001], [00000010], [00000100], [00001000], [00010000], there are 3 points pointing to the coordinates, and the corresponding lookup tables are: [00100000], [01000000], [10000000]. Through the above operations, is [00011111], is [11100000], so the target center is .
[0190] Step 5. Obtain based on regression method The pointer fits the straight line equation: , and satisfies ,in, express The slope of the pointer fitting straight line equation, express The intercept of the pointer fitting straight line equation, express The horizontal coordinate of the pixel point in the pointer domain, express The vertical coordinate of the pixel point in the pointer domain;
[0191] Step 5.1: Make a The first mask of the same size is made by is the center of the circle and the radius is × The circle area is set to white, and the rest of the area is set to black; represents the first radius scaling factor, .
[0192] Step 5.2: Place the first mask with Perform a bitwise AND operation to obtain a pointer image without scales ;
[0193] Step 5.3: After binarization, corrosion, and expansion operations, the image is obtained , and then the image Extract and obtain The set of pixel points in the pointer connected domain :
[0194]
[0195] in, express The mth pixel point in the pointer connected domain, express The total number of pixels in the connected domain of the pointer.
[0196] Step 5.4: Given The learning rate , the absolute value of the threshold ; here Set to 0.001, set is 0.2;
[0197] Step 5.5: will be given ;in, It is obtained by the following steps: Setting the loss function , among which This is to make the loss function The coefficient of the derivative is 1; the coordinates of the center of the circle Substitute the pointer into the fitting straight line equation ,get , we can get:
[0198]
[0199] Derivative the loss function, we get:
[0200]
[0201] Step 5.6: If , then it means that The pointer fits the straight line equation: ; Otherwise, return to 5.5 and execute sequentially.
[0202] Step 6. Acquire based on the real scale extraction algorithm The ordered real scale line fitting rectangle frame information set ;
[0203] Step 6.1: Make a picture with A second mask of the same size, wherein the second mask is made by is the center of the circle and the radius is × to The circular area of is set to white, and the rest of the area is set to black; represents the second radius scaling factor, ;
[0204] Step 6.2: Place the second mask with Perform bitwise AND operation to obtain the scale image .
[0205] Step 6.3: Scale the image according to the true scale extraction algorithm Extract and obtain the ordered real scale line fitting rectangular frame information set ; Among them, Figure 7 As shown, the true scale extraction algorithm follows the following process:
[0206] Step A: Utilize the improved Edge detection algorithm Process and obtain All rectangular boxes in ;
[0207] Step A1: Given parameters, including: low threshold , Low threshold single cycle increase , Lower threshold upper limit , the difference between the high and low thresholds , the minimum area of the rectangular frame , maximum area , minimum aspect ratio , maximum aspect ratio , Lower limit of the number of intersecting rectangles ; The lower limit of the number of true tick marks , distance threshold ;
[0208] In this embodiment, the parameters are substituted as follows: , , , , , , , , , , ;at the same time, Edge detection requires input of low threshold and high threshold. As a high threshold input;
[0209] Will The number of edge detections is recorded as , and initialized to =1.
[0210] Step A2: If , then execute step A3; otherwise, it means that Rectangular frame information collection = , and execute step B, wherein, express The total number of rectangles contained in the information. express The Rectangular frame information, and the Rectangle information Contains the center coordinates of a rectangular box and its width ,high and rotation angle , ;
[0211] Step A3: According to , ,right Conduct the Second-rate Edge detection, get the Detected edge image ,like Figure 7 As shown, the above process is encapsulated into ; then Substitute into the minimum bounding rectangle algorithm to get all the rectangular boxes, and then according to the parameters , , , Filter to get multiple target rectangles, such as Figure 7 As shown, the above process is encapsulated into ,in, Represents multiple target rectangles; Figure 7 As shown, the above process is encapsulated into ; Afterwards Grant ,Will Grant , proceed to step A2.
[0212] Step B: Elimination The redundant rectangular boxes in the pre-screened rectangular box information set is obtained :
[0213] Step B1: If The number of elements in is greater than the threshold , then from Take out the first rectangular box information , execute step B2, otherwise, obtain the pre-screened rectangular frame information set:
[0214]
[0215] And execute step C, wherein, express Middle Rectangular frame information, express The total number of rectangular frame information contained; Figure 7 As shown, the judgment process of B1 is encapsulated as whether it is established;
[0216] Step B2: From Find the The number of intersecting rectangles ;like , then execute step B3; otherwise, from , and After reordering, return to step B1 and execute sequentially;
[0217] Step B3: The rectangular frame information is sorted in descending order according to the area of its own rectangular frame, and the first The rectangular frame information of the bit is stored in ; then The rectangular frame information is from , and After reordering, return to step B1 and execute sequentially; Figure 7 As shown, the rectangular frame removal and sorting process of step B2 is encapsulated as .
[0218] Step C: Extraction After sorting the real scale in the, we get the ordered real scale line fitting rectangle information set ;
[0219] Step C1: If If it is empty, execute step C4, otherwise, execute step C2;
[0220] Step C2: From Get the first rectangular box information ,Pass The center coordinates of Draw a straight line parallel to the long side of its own rectangle , thus calculating the center of the circle To the straight line Distance , calculate the center of the circle arrive Distance , calculate the direction of the center of the circle The angle between the vector of the circle and the vector pointing to the right horizontally ;like Figure 7 As shown, step C2 is encapsulated as The purpose of step C2 is to eliminate the rectangular frame with the wrong direction according to the characteristic that the dial scale line points to the center of the circle; in this embodiment, the center of the circle is calculated by To the straight line Distance In other embodiments, the angle between the line connecting the rectangular frame and the center of the circle and the long side line of the rectangular frame may be used as a judgment condition.
[0221] Step C3: If , then , , Deposit as a whole , and from After being removed from the list, execute step C1. Otherwise, directly from Remove it and execute step C1;
[0222] Step C4: From Find it in The highest frequency A rectangular frame will be right After the rectangular boxes are arranged in descending order, an ordered set of real scale line fitting rectangular box information is obtained. :
[0223] ;
[0224] in, express Middle Rectangular frame information, express points within To the center The distance Indicates the direction of the center of the circle points within The angle between the vector of the circle and the vector pointing to the right horizontally from the center of the circle. Figure 7 As shown, in step C3 , , Deposit as a whole and step C4 is encapsulated as .
[0225] Step 7. Based on the distance method, the equation of the straight line is fitted according to the pointer Get it in sequence Dial reading ;
[0226] Step 7.1: Make a picture with A third mask of the same size, wherein the third mask is made by is the center of the circle and the radius is The circle area is set to white, and the rest of the area is set to black;
[0227] Step 7.2: Place the third mask with Perform a bitwise AND operation to obtain a circular instrument image ,and The coordinate points within Coordinate points of the inner rectangle, pointer fitting straight line equation The coordinates of the points;
[0228] Step 7.3: In this embodiment, establish The dial polar coordinate system is the origin and the horizontal right is the polar axis;
[0229] Step 7.4: Expand the dial polar coordinate system to the set size In this embodiment, the rectangular area Take 250, Take 50; the horizontal axis of the rectangular area is recorded as , the vertical axis of the rectangular area is denoted by ;
[0230] Use formula (1) to convert the dial polar coordinate system into The coordinates of any point in Map to the rectangular area and get the corresponding new coordinate point ; Thus, all new coordinate points constitute an ordered real scale line fitting rectangular frame information set , and get the new pointer fitting straight line equation ;in, Indicates the new pointer fitting line equation Axis coordinates;
[0231] (1)
[0232] In formula (2), is the width of the rectangular area, is the height of the rectangular area, and , .
[0233] Step 7.5: Based on the known instrument range, we can get The absolute value of the difference between adjacent scale readings , in this embodiment is 0.2;
[0234] Step 7.6: Use formula (2) to calculate Dial reading ;
[0235] (2)
[0236] In formula (2), Indicates The equation of the straight line from the scale line to the new pointer distance, and , Indicates The equation of the straight line from the scale line to the new pointer distance, and ,in, yes Middle The coordinates of the center of the fitted rectangle of each scale line on the horizontal axis; yes Middle The coordinates of the center of the fitted rectangle of each tick mark on the horizontal axis.
[0237] Step 8. Dial reading Perform linear operations to obtain the final reading of the instrument image to be tested .
[0238] In this embodiment, an electronic device includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the above method, and the processor is configured to execute the program stored in the memory.
[0239] In this embodiment, a computer-readable storage medium stores a computer program on the computer-readable storage medium, and the computer program executes the steps of the above method when executed by a processor.
[0240] The above are only embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A nested non-uniform dial reading method based on machine vision, characterized in that: Follow these steps: Step 1. Build a collection of instrument images and train an instrument detection model ; Step 2. Input the image of the instrument to be tested into the instrument detection model Processed in Single dial rectangular image ;in, represents the i-th single dial rectangular image in the instrument image to be tested, Represents the total number of single dial rectangular images; Step 3. Perform preprocessing operations, including grayscale, median filtering, and image enhancement to obtain the i-th single dial rectangular image after preprocessing ,by The lower left corner is the origin, and the horizontal right is Axis, vertical upward Axis, thereby establishing the image coordinate system; Step 4. Obtain based on the improved Hough transform algorithm The coordinates of the dial center and radius ; Step 5. Obtain based on regression method The pointer fits the straight line equation: , and satisfies ,in, express The slope of the pointer fitting straight line equation, express The intercept of the pointer fitting straight line equation, express The horizontal coordinate of the pixel point in the pointer domain, express The vertical coordinate of the pixel point in the pointer domain; Step 6. Acquire based on the real scale extraction algorithm The ordered real scale line fitting rectangle frame information set ; Step 7. Based on the distance method, the equation of the straight line is fitted according to the pointer Get it in sequence Dial reading ; Step 8. Dial reading Perform linear operations to obtain the final reading of the instrument image to be tested .
2. The nested non-uniform dial reading method based on machine vision according to claim 1 is characterized in that: The step 1 comprises the following steps: Step 1.1: Collect nested non-uniform scale instrument images in the substation to construct an instrument image set ; Step 1.2: Instrument image collection The instrument area in is annotated to obtain a set of instrument images with labels ; Step 1.3: Collect the labeled instrument images Input into the improved YOLOv5 network for training to obtain the instrument detection model .
3. The nested non-uniform dial reading method based on machine vision according to claim 1 is characterized in that: The improved Hough transform algorithm in step 4 comprises the following steps: Step 4.1: Use arc segment tracking algorithm to obtain In Discrete arcs: Step 4.2: Based on the circle gradient, use discrete arc segments to obtain multiple candidate circle centers; Step 4.3: Introduce a lookup table and a bit accumulator to vote for candidate circle centers to determine the target circle center; Give each candidate circle a different center Bit binary lookup table, and each candidate circle center corresponds to In the binary lookup table, only one bit is 1, and the rest are 0; remember The coordinates are The number of votes for the candidate center in binary, Indicates The binary values of candidate circle centers, where ; Traverse each candidate circle center in turn and use the bit accumulator to Grant , thus obtaining the final number of votes for each candidate center, and The candidate center with the largest number of 1s is set as the target center. ,in, Represents a bitwise OR operation.
4. The nested non-uniform dial reading method based on machine vision according to claim 3 is characterized in that: The step 4.1 comprises the following steps: Step 4.1.1: Binarization is performed to obtain a binary image with a grayscale value of 255 for the edge pixels and a grayscale value of 0 for the rest of the pixels. ; Define and initialize the number of discrete arcs , define and initialize the current point is empty; Step 4.1.2: Scan the binary image in a certain order If the scanned pixel has a grayscale value of 255, the first scanned pixel with a grayscale value of 255 is used as the starting point. , and set the current point Starting point , define and initialize the markers Then, execute step 4.1.3, otherwise, save For each arc segment, execute step 4.2; Step 4.1.3: Assign to , the starting point Join In the arc segment; Step 4.1.4: The gray value of the newly added coordinate points in the arc segment is set to 0; Step 4.1.5: Traverse the current point clockwise Among the 4 4-adjacent points, determine whether there is a 4-adjacent point with a grayscale value of 255. If so, set the first 4-adjacent point with a grayscale value of 255 read as the current point. , and the current point Join If there is no arc segment, execute step 4.1.4; if not, execute step 4.1.6; Step 4.1.6: Traverse the current point clockwise Among the four 8-adjacent oblique points, determine whether there is an 8-adjacent oblique point with a grayscale value of 255. If so, set the first 8-adjacent oblique point with a grayscale value of 255 read as the current point. , and the current point Join arc segment, execute step 4.1.4; if it does not exist, determine Is it established? If yes, proceed to 4.1.7; Otherwise, proceed to step 4.1.2; Step 4.1.7: Set the starting point For the current point , will order Then, proceed to step 4.1.
5.
5. The nested non-uniform dial reading method based on machine vision according to claim 4 is characterized in that: The step 4.2 comprises the following steps: Step 4.2.1: Calculate the binary image The horizontal gradient vector of each point in and vertical gradient vector ; The number of arcs traversed is , and initialize ; Define the number of candidate circles as , and initialize , set the maximum number of candidate circles to ;remember The center coordinates are ; Recorded as The coordinates of the centers of candidate circles are ; Step 4.2.2: Define and initialize variables ; Record The total number of points in an arc segment is ; Step 4.2.3: The first The points are recorded as ; Select any point from other arc segments and record it as , and satisfy: ; from Select the point that satisfies the first change rule As The first change rule is: like , from Change to ; like , from Change to ;in, is a given constant; like In the process of moving along the first change rule, if equation (1) is satisfied, then Set as symmetric point, and Set as , execute step 4.2.4; otherwise, execute step 4.2.8; (1) In formula (1), , Respectively , The horizontal gradient vector, , Respectively , The vertical gradient vector of Step 4.2.4: and its symmetric point Substituting into formula (2), we get Middle The coordinates of the candidate centers and its corresponding radius : (2) In formula (2), int() represents the rounding operation; Step 4.2.5: If , then Assign to , otherwise, Assign to ; like , then Grant If yes, go to step 4.2.6; otherwise, go to step 4.2.7; Step 4.2.6: If , then execute step 4.2.4; otherwise, save The coordinates of candidate circle centers; Step 4.2.7: If , then Grant Then, execute step 4.2.3; otherwise, judge If so, Grant Then, execute step 4.2.2, otherwise, save The coordinates of candidate circle centers and Assign to ; Step 4.2.
8. Select any point from other arc segments and record it as , and satisfy: ; from Select the points that satisfy the second change rule As Another preliminary point, the second change rule is: like , from Change to ; like , from Change to ;in, is a given constant; like In the process of moving along the second change rule, if equation (3) is satisfied, then Set as symmetric point, and Set to , execute step 4.2.9; otherwise, execute step 4.2.7; (3) In formula (3), , Respectively , The horizontal gradient vector, , Respectively , The vertical gradient vector of Step 4.2.9: and its symmetric point Substituting into formula (4), we get Middle Candidate center points and their corresponding radius : (4) Step 4.2.10: If , then Assign to , otherwise, Assign to ; like , then Grant If yes, execute step 4.2.11; otherwise, execute step 4.2.7; Step 4.2.11: If , then execute step 4.2.9; otherwise, save The center coordinates of the candidate circles.
6. The nested non-uniform dial reading method based on machine vision according to claim 5 is characterized in that: The step 5 comprises the following steps: Step 5.1: Make a The first mask of the same size, wherein the first mask is made by is the center of the circle and the radius is × The circle area is set to white, and the rest of the area is set to black; represents the first radius scaling factor, ; Step 5.2: Place the first mask with Perform a bitwise AND operation to obtain a pointer image without scales ; Step 5.3: After binarization, corrosion, and expansion operations, the image is obtained , and then the image Extract and obtain The set of pixel points in the pointer connected domain ,in, express The mth pixel point in the pointer connected domain, express The total number of pixels in the connected domain of the pointer; Step 5.4: Given The learning rate , the absolute value of the threshold ; Step 5.5: Grant ; Step 5.6: If , then it means that The pointer fits the straight line equation: ; Otherwise, return to 5.5 and execute sequentially.
7. The nested non-uniform dial reading method based on machine vision according to claim 6 is characterized in that: The step 6 comprises the following steps: Step 6.1: Make a A second mask of the same size, wherein the second mask is made by is the center of the circle and the radius is × to The circular area of is set to white, and the rest of the area is set to black; represents the second radius scaling factor, ; Step 6.2: Place the second mask with Perform bitwise AND operation to obtain the scale image ; Step 6.3: Scale the image according to the true scale extraction algorithm Extract and obtain the ordered real scale line fitting rectangular frame information set .
8. The nested non-uniform dial reading method based on machine vision according to claim 5 is characterized in that: The true scale extraction algorithm in step 6.3 comprises the following steps: Step A: Use the improved Canny edge detection algorithm to Process and obtain All rectangular boxes in ; Step A1: Given parameters, including: low threshold , Low threshold single cycle increase , Lower threshold upper limit , the difference between the high and low thresholds , the minimum area of the rectangular frame , maximum area , minimum aspect ratio , maximum aspect ratio , Lower limit of the number of intersecting rectangles ; The lower limit of the number of true tick marks , distance threshold ; Will The number of edge detections is recorded as , and initialized to =1; Step A2: If , then execute step A3; otherwise, it means that Rectangular frame information collection = , and execute step B, wherein, express The total number of rectangles contained in the information. express The Rectangular frame information, and the Rectangle information Contains the center coordinates of a rectangular box and its width ,high and rotation angle , ; Step A3: According to , ,right Conduct the Second-rate Edge detection, get the Detected edge image ;according to , , , , After obtaining a certain number of rectangular frame information, Grant ,Will Grant , execute step A2; Step B: Elimination The redundant rectangular boxes in the pre-screened rectangular box information set is obtained : Step B1: If The number of elements in is greater than , then from Take out the first rectangular box information , execute step B2, otherwise, obtain the pre-screened rectangular frame information set: , and execute step C, wherein, express Middle Rectangular frame information, express The total number of rectangular frame information contained; Step B2: From Find the The number of intersecting rectangles ;like , then execute step B3; otherwise, from , and After reordering, return to step B1 and execute sequentially; Step B3: The rectangular frame information is sorted in descending order according to the area of its own rectangular frame, and the first The rectangular frame information of the bit is stored in ; then The rectangular frame information from , and After reordering, return to step B1 and execute sequentially; Step C: Extraction After sorting the real scale in the, we get the ordered real scale line fitting rectangle information set ; Step C1: If If it is empty, execute step C4, otherwise, execute step C2; Step C2: From Get the first rectangular box information ,Pass The center coordinates of Draw a straight line parallel to the long side of its own rectangle , thus calculating the center of the circle To the straight line Distance , calculate the center of the circle arrive Distance , calculate the direction of the center of the circle The angle between the vector of the circle and the vector pointing to the right horizontally ; Step C3: If , then , , Deposit as a whole , and from After being removed from the list, execute step C1. Otherwise, directly from Remove it and execute step C1; Step C4: From Find the circle with the highest frequency of distance from the center to the center coordinates A rectangular frame will be right After the rectangular boxes are arranged in descending order, the ordered real scale line fitting rectangular box information set is obtained. : ;in, express Middle Rectangular frame information, express points within To the center The distance Indicates the direction of the center of the circle points within The angle between the vector pointing to the right and the horizontal vector pointing to the center of the circle.
9. The nested non-uniform dial reading method based on machine vision according to claim 8, characterized in that: The step 7 comprises: Step 7.1: Make a picture with A third mask of the same size, wherein the third mask is made by is the center of the circle and the radius is The circle area is set to white, and the rest of the area is set to black; Step 7.2: Place the third mask with Perform a bitwise AND operation to obtain a circular instrument image ,and The coordinate points within Coordinate points of the inner rectangle, pointer fitting straight line equation The coordinates of the points; Step 7.3: Create The dial polar coordinate system is the origin and the horizontal right is the polar axis; Step 7.4: Expand the dial polar coordinate system to the set size The horizontal axis of the rectangular area is denoted by , the vertical axis of the rectangular area is denoted by ; Use formula (1) to convert the dial polar coordinate system into The coordinates of any point in Map to the rectangular area and get the corresponding new coordinate point ; Thus, all new coordinate points constitute an ordered real scale line fitting rectangular frame information set , and get the new pointer fitting straight line equation ;in, Indicates the new pointer fitting line equation Axis coordinates; (1) In formula (2), is the width of the rectangular area, is the height of the rectangular area, and , ; Step 7.5: Based on the known instrument range, we can get The absolute value of the difference between adjacent scale readings ; Step 7.6: Use formula (2) to calculate Dial reading ; (2) In formula (2), Indicates The equation of the straight line from the scale line to the new pointer distance, and , Indicates The equation of the straight line from the scale line to the new pointer distance, and ,in, yes Middle The coordinates of the center of the fitted rectangle of each scale line on the horizontal axis; yes Middle The coordinates of the center of the fitted rectangle of each tick mark on the horizontal axis.
10. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store a program that supports the processor to execute the nested non-uniform scale dial meter reading method described in any one of claims 1 to 9, and the processor is configured to execute the program stored in the memory.
Citation Information
Patent Citations
Pointer type instrument reading method and system and inspection robot
CN112257676A
Indicating value identification method of dial instrument
CN103207987A
Pointer type instrument panel automatic reading method under long-distance and multi-view environment
CN107145890A
An electric power inspection method and device for identifying analog pointer instrument readings
CN109711400A
Automatic pointer type instrument reading identification method based on scale searching
CN109993166A
Cited By
Instrument identification method and device, equipment and storage medium
CN120071315A
