Ammeter appearance defect detection method and device based on deep learning
Through deep learning technology combining the first-stage and second-stage object detection models, standard character templates are established and image correction is carried out, which solves the problems of low efficiency and missed detection of existing meter appearance defect detection methods, and realizes high-precision and high-efficiency meter character detection.
Patent Information
- Application Number
- CN202510210486.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-06-17
AI Technical Summary
Existing meter appearance defect detection methods are inefficient, easily affected by light and angle changes, and it is difficult to accurately detect subtle defects in complex backgrounds, resulting in frequent occurrence of false detection and missed detection.
Using a deep learning-based method, through the collaborative work of the first-stage and second-stage object detection models, a standard character template is established and combined with character similarity calculations are carried out to accurately identify and defect detection of electricity meter characters, and an image correction module is designed to deal with lighting and angle problems.
It significantly improves the accuracy and robustness of meter character detection, reduces false detection and missed detection rates, enhances the fault tolerance of detection, and improves batch detection efficiency, which is suitable for real-time detection requirements of meter production lines.
Smart Images

Figure CN120164201A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of image processing and deep learning, and particularly relates to a method and device for detecting appearance defects of electric meters based on deep learning. Background Art
[0002] In modern industrial production, the quality inspection of electric meters is a crucial link. Character defects on the appearance of electric meters, including missing, blurred or damaged characters, will affect the reading accuracy of electric meters, and further affect the electricity measurement and cost settlement of users. Therefore, the detection of appearance defects of electric meters is of great significance in the production and maintenance of electric meters.
[0003] Traditional methods for detecting appearance defects of electric meters mainly rely on manual visual inspection or simple image processing algorithms. However, manual inspection is inefficient and easily affected by subjective factors, resulting in inconsistent detection results. Simple image processing algorithms are often limited by image quality and lighting conditions, and it is difficult to accurately detect subtle character defects. In addition, traditional methods are difficult to handle the complex background and diverse defect forms of the appearance of electric meters, and it is easy to miss detections or make false detections.
[0004] In recent years, deep learning technology has made remarkable progress in the field of computer vision, especially in object detection and image recognition. Deep learning models can automatically extract features in images and perform defect detection through the training of a large amount of data, significantly improving the accuracy and robustness of detection. However, existing methods for detecting electric meter characters face multiple challenges in practical applications. The complex background of the electric meter dial (such as liquid crystal displays, nameplates, two-dimensional codes, etc.) and interferences such as surface reflections, stains, and scratches bring difficulties to character recognition. In addition, electric meter characters may have diverse defects such as blurring, breakage, and missing due to production or use problems, and it is difficult for traditional methods to accurately detect these subtle and random features. At the same time, changes in lighting conditions and deviations in shooting angles will also cause character distortion or incomplete display, increasing the detection difficulty. Traditional detection technologies rely on fixed rules or simple template matching, and it is easy to have false detections and missed detections, and the efficiency is low in batch detection, making it difficult to meet the real-time requirements of the production line.
[0005] Therefore, the application of existing technologies in the detection of electric meter characters still has significant deficiencies and needs to be further optimized and improved. Summary of the Invention
[0006] In view of the deficiencies of existing methods for detecting appearance defects of electric meters, the present invention proposes a method and device for detecting appearance defects of electric meters based on deep learning, in order to improve the detection efficiency and accuracy, and provide a reliable technical means for the production and maintenance of electric meters.
[0007] To achieve the above object, the present invention provides the following technical solutions:
[0008] In a first aspect, the present invention proposes a method for detecting appearance defects of electric meters based on deep learning, including the following steps:
[0009] S1: Obtain a standard electric meter picture and perform preprocessing. Use a deep learning model to identify the characters in the preprocessed standard electric meter picture, obtain the positions and labels of all characters in the picture, extract the images of individual characters according to the recognition results, and store the character images, as well as the recognized character positions and character labels, as character templates;
[0010] S2: Obtain a picture of the electric meter to be detected, and perform preprocessing on the picture of the electric meter to be detected;
[0011] S3: For the preprocessed picture of the electric meter to be detected, use a deep learning model to identify the characters in the picture, obtain the positions and labels of all characters in the picture of the electric meter to be detected, and extract the images of each character in the picture of the electric meter to be detected as the images of the characters to be detected;
[0012] S4: For each character in the picture of the electric meter to be detected, register the character template based on the current image of the character to be detected. The character image in the registered character template is the template character image, and perform character defect detection on the current character to be detected based on the template character image. Traverse all characters in the picture of the electric meter to be detected to obtain the detection result of the appearance defects of the electric meter to be detected.
[0013] In a second aspect, the present invention proposes a device for detecting appearance defects of electric meters based on deep learning, which is used to implement the above method.
[0014] In a third aspect, the present invention proposes a computer-readable storage medium, which stores computer-executable instructions for executing the above method.
[0015] Compared with the prior art, the beneficial effects of the present invention are:
[0016] 1) High-precision character detection ability. The present invention adopts deep learning technology, and through the collaborative work of one-stage and two-stage object detection models, it can accurately identify the positions of electric meter characters in complex backgrounds and effectively separate interference areas such as liquid crystal displays and nameplates. Compared with traditional image processing methods, the accuracy of character detection is greatly improved.
[0017] 2) Comprehensive adaptation to the detection of diverse defects. By establishing standard character templates and combining character similarity calculations, the present invention can detect various defect types such as character blurring, missing, and damage, and can quantify the degree of defects, providing a more fine-grained detection result. This diverse defect detection ability is significantly better than traditional methods.
[0018] 3) Effectively solve the problems of light and angle. The present invention designs an image correction module based on gray conversion, binarization, edge detection, and Hough line transformation, which can correct character inclination or distortion caused by shooting angle or light change, enabling the meter characters to always participate in the detection at the correct angle and proportion, and ensuring the reliability of the results.
[0019] 4) Low false detection and missed detection rates. By automatically extracting image features through a deep learning model and combining template matching, the present invention can reduce false detection and missed detection situations caused by simple rules in traditional methods, improve the stability and consistency of detection results, and significantly enhance the fault tolerance of detection.
[0020] 5) High - efficiency batch detection ability. Through full - process automation, from image acquisition, rotation correction to character detection and defect analysis, the present invention greatly improves the detection efficiency, is especially suitable for the batch detection requirements of the meter production line, and overcomes the problem of low efficiency in traditional methods.
[0021] 6) Strong scalability and applicability. The detection model and character templates of the present invention can be flexibly adjusted according to different models and specifications of meters, have strong versatility and scalability, and are applicable to the appearance detection of meters in various industrial scenarios. Brief Description of the Drawings
[0022] Figure 1 is a schematic flow chart of a method for detecting meter appearance defects based on deep learning provided by an embodiment of the present invention;
[0023] Figure 2 is a schematic structural diagram of a device for detecting meter appearance defects based on deep learning provided by an embodiment of the present invention;
[0024] Figure 3 is the recognition result of a one - stage object detection model provided by an embodiment of the present invention;
[0025] Figure 4 is a schematic diagram after binarization processing of the display content on the meter liquid crystal screen provided by an embodiment of the present invention;
[0026] Figure 5 is the recognition result of a two - stage object detection model provided by an embodiment of the present invention. Detailed Embodiments
[0027] In order to make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be described in detail below with specific embodiments. Specific embodiments are described below to simplify the present invention. However, it should be recognized that the present invention is not limited to the described embodiments, and various modifications of the present invention are possible without departing from the basic principles, and these equivalent forms also fall within the scope defined by the appended claims of this application.
[0028] Before introducing the present invention, first, the keywords for understanding the present invention will be described:
[0029] The electric meter referred to in the present invention means a smart electric meter, which is a terminal device with functions such as electric energy metering, data storage, communication, and remote management. Its appearance usually includes components such as a liquid crystal display screen, a nameplate, a two-dimensional code, a bar code, and buttons. Among them, the liquid crystal display screen is used to display the metering information of the electric meter (such as power consumption, power, voltage, etc.), and the nameplate and two-dimensional code / bar code usually contain character data such as the model number, serial number, and certification information of the electric meter. The said characters include Chinese characters, English characters, numerical characters, and special graphic characters (such as Figure 4 , 5 the current graphic, telephone graphic, etc. in
[0030] The standard electric meter picture referred to in the present invention means a picture of the appearance of a smart electric meter taken at a front vertical angle without appearance defects, and it is required that the characters on the liquid crystal display screen, nameplate, two-dimensional code, and bar code are clearly and completely displayed, which can be used as the basis for subsequent character template production.
[0031] The appearance defects of the electric meter referred to in the present invention specifically refer to the defects of the characters in the appearance of the electric meter, including but not limited to the situations such as character missing, blurring, damage, or abnormal font. These defects may affect the reading accuracy and information integrity of the smart electric meter, and further have an adverse impact on the user's electricity metering, cost settlement, and power system management. Therefore, the detection of the appearance defects of the electric meter is of great significance in the production and maintenance of smart electric meters, especially for ensuring the reliability of electric energy metering and the rights and interests of users.
[0032] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention.
[0033] Embodiment 1
[0034] Referring to Figure 1 , an embodiment of the present invention provides a method for detecting the appearance defects of an electric meter based on deep learning, which mainly includes the following steps:
[0035] Step 1: Collect standard electric meter pictures and use a deep learning model to make character templates;
[0036] Step 2: Preprocess the electric meter picture to be detected;
[0037] Step 3: Use a deep learning model to identify the characters in the electric meter picture to be detected;
[0038] Step 4: Load the registered character templates;
[0039] Step 5: Character defect detection.
[0040] The specific implementation of the embodiment is introduced below.
[0041] Step 1: Collect standard electricity meter images and create character templates.
[0042] Select an electric meter with good appearance and normal functions as the standard electric meter, adjust the standard electric meter to the full brightness of the LCD screen, so that all displayable contents on the LCD screen are clearly displayed, use a high-definition camera, place the camera at a vertical angle, use multiple soft lights as light sources and place them around the camera to ensure that the surface details of the electric meter are clear, and take an image of the front of the standard electric meter. Preprocess the original image obtained by the image to obtain a standard electric meter image, and the preprocessing process is the same as described in step 2. Make a character template based on the standard electric meter image. The specific steps of making a character template are as follows:
[0043] 1) Build and train a one-stage target detection model to identify the one-stage targets in the standard electric meter image, including LCD screens, nameplates, QR codes and other targets, and extract the images of each one-stage target; binarize the images of each one-stage target to obtain its binary image. Figure 3 The first-stage target recognition result of the standard electric meter image recognition in this embodiment is shown in FIG. 1 . The positions of targets in different stages are represented by prediction boxes of different colors. The images of the targets in each stage are intercepted according to the prediction boxes and binarized. The binarized image of the LCD screen is shown in FIG. Figure 4 The training data set used for the one-stage target detection model training contains 10,000 pictures of the front of different electricity meters, all of which have their LCD screens fully lit; the total loss function L used in the training is:
[0044] L=λ1L loc +λ2L cls +λ3L obj
[0045] Among them, λ1, λ2, λ3 are weight hyperparameters, L loc CIOU is the positioning loss, which is used to calculate the error between the predicted box and the true label in the recognition result, L cls is the Focal classification loss, which is used to calculate the error of target classification, L obj is the BCE target confidence loss, which is used to measure the confidence of whether the predicted box contains the target; in this embodiment, λ1 is 0.05, λ2 is 0.58, and λ3 is 1.0.
[0046] 2) Construct and train a two-stage object detection model. Feed the binary image of the first-stage object into the two-stage object detection model to perform character recognition on the image, extract the images of each character, and the character recognition results include the character positions and character labels. The second-stage objects are each character, and the recognition results of the two-stage object detection model are as shown in Figure 5 . The training process of the two-stage object detection model is the same as that of the first-stage object detection model.
[0047] 3) Store the image of the character, the position information of the character, and the character label information as a character template. The position information of the character is specifically the position of the upper left corner of the binary image of the character target in the entire standard electricity meter picture. The character label is, for example: for the character image showing "electricity", its label is "electricity"; for the character image showing the number "0", its label is "0", and for special graphic characters with different shapes, their labels are different. Taking the binary image of the liquid crystal display as an example, Figure 5 the distribution of the character templates can be seen. The position information of the character is marked in the form of a prediction box, the image inside the prediction box is the image of the character, and the character label information is marked at the upper left corner of the prediction box.
[0048] The first-stage object detection model refers to a model for quickly locating the main target areas in the electricity meter, mainly identifying larger and more prominent areas such as the liquid crystal display, nameplate, and QR code in the electricity meter picture. The second-stage object detection model refers to a model for performing higher-precision character positioning within the key areas detected in the first stage. In this embodiment, both the first-stage object detection model and the second-stage object detection model are YOLO-v5 models. The YOLO-v5 model consists of a backbone feature extraction network, a path aggregation parameter-free attention feature pyramid network, and a deformable decoupled detection head, and is commonly used in image detection tasks.
[0049] Step 2: Preprocess the electricity meter picture to be detected.
[0050] The electricity meter picture to be detected is obtained by photographing the front of the electricity meter to be detected. When photographing, the electricity meter to be detected needs to be kept in a state where the liquid crystal display is fully lit. Through image processing methods, the electricity meter picture to be detected is binarized and rotationally corrected to obtain an electricity meter picture to be detected with a normal angle for the normal operation of the subsequent process. The specific steps include:
[0051] 1) Grayscale conversion and binarization processing: In order to extract electricity meter characters and other edge features, first convert the color electricity meter picture to be detected into a grayscale image, and then adaptively perform binarization processing on the grayscale image by the Otsu method. The formula is as follows:
[0052] gray(x,y) = 0.299R(x,y) + 0.587G(x,y) + 0.114B(x,y)
[0053]
[0054] Among them, gray(x, y) represents the pixel value of the grayscale image at x and y, R(x, y), G(x, y), and B(x, y) respectively represent the red, green, and blue pixel values of the color image at (x, y), binary(x, y) represents the pixel value of the binary image at (x, y), T is the binarization threshold, and in this embodiment, the calculation formula of the binarization threshold T is as follows:
[0055] T = μ gray + k·σ gray
[0056] Among them, μ gray and σ gray are respectively the pixel mean and standard deviation of the grayscale image, and k is an adjustment parameter. In this embodiment, k takes 0.5.
[0057] 2) Edge detection: In order to extract clear edge information from the binary image, the Canny edge detection method is used, which can effectively detect the meter characters and other edge features. The specific process is as follows:
[0058] Set the low threshold T low and the high threshold T high . In this embodiment, T low = 50, T high = 120.
[0059] By calculating the pixel gradient and non-maximum suppression, the edge features are retained, and the formula is as follows:
[0060]
[0061] Among them, gradient(x, y) represents the pixel gradient value of the image at the position (x, y), which reflects the pixel intensity change amplitude at this position and is used to judge the edge intensity, and edge(x, y) represents the pixel value of the edge detection image at the position (x, y). If this position is considered an edge, it is set to 255 (white); otherwise, it is set to 0 (black) to highlight the edge area.
[0062] 3) Hough line transform to detect straight lines: Through the Hough line transform method, the straight line segments in the edge image can be detected and extracted, and the endpoint coordinates of these straight line segments can be obtained. These straight line segments usually represent the reference lines of the meter frame.
[0063] 4) Select the longest line segment and calculate the angle: Screen all the detected line segments, and select the longest one among the line segments close to horizontal as the rotation reference. The so-called "close to horizontal" means that the angle of the line segment is within the range of ±30° (including ±30°). The formulas for calculating the length and angle of the line segment are as follows:
[0064] Represent the endpoints of the longest line segment as (x1, y1) and (x2, y2), then the length L of the line segment is calculated as follows:
[0065]
[0066] Calculate the included angle α between each line segment and the horizontal line:
[0067]
[0068] 5) Image rotation: According to the angle α, perform an affine transformation on the electric meter image with the center point (w / 2, h / 2) as the reference, where w and h are the width and height of the electric meter image, so that the characters in the electric meter image are restored to horizontal. The specific process is as follows:
[0069] The calculation formula for the rotation matrix M is as follows:
[0070]
[0071] where tx and ty are translation amounts used to keep the center of the electric meter image aligned, is the angle of the rotation reference.
[0072] Use the above matrix to perform a rotation transformation on the image to achieve image correction:
[0073] I c = I * M
[0074] where, I c is the corrected image, and I is the original image.
[0075] Step 3: Recognize the characters in the electric meter picture to be detected.
[0076] Through the one-stage and two-stage object detection methods, first identify the main areas of the electric meter such as the liquid crystal display screen and the nameplate, and then further detect the character positions to ensure accurate character positioning in a complex background. The specific steps include:
[0077] Use the one-stage object detection model to identify the one-stage objects in the standard electric meter picture, including objects such as the liquid crystal display screen, the nameplate, and the two-dimensional code.
[0078] Send the objects detected in the first stage into the two-stage object detection model to identify the character objects among them, and store the partial images where each character object is located as the character images to be detected.
[0079] Step Four: Load the registered character template.
[0080] For each character in the electricity meter image to be detected, register and match it with the character template to provide a basis for the subsequent character defect detection process. The specific steps include:
[0081] Calculate the scaling ratio, W r is the width of the first-stage target image to be detected, and W t is the width of the corresponding first-stage target image of the character template image, and calculate the scaling ratio F s The formula is as follows:
[0082]
[0083] Scale the character image I in the character template c to obtain I s The scaling formula is as follows:
[0084] I s = I c * F s
[0085] Step Five: Character defect detection.
[0086] For each character in the electricity meter image to be detected, after the character template is successfully registered to the electricity meter image to be detected, perform character defect detection. The specific steps are as follows:
[0087] 1) For each character to be detected, find the nearest neighbor character template: Calculate the Euclidean distance between the position of the character image to be detected and the position of each character in the character template. The position of the character image to be detected is specifically the position of the upper left corner of the character image to be detected in the entire binary electricity meter image to be detected; Sort all character templates according to the Euclidean distance and select the nearest k character templates. In this embodiment, k is taken as 5.
[0088] 2) Match the labels and calculate the similarity: Among the k most adjacent templates found, filter out the character templates with the same label as the character to be detected. Once a character template with a matching label is found, calculate its similarity with the character image to be detected, and judge whether the current character to be detected has defects according to the similarity; if no character template with a matching label is found, the current character to be detected has defects; The process of calculating similarity is as follows:
[0089] a) Align the images: Scale the character image B to be detected r to the same size as the binary image B in the character template t
[0090] b) Calculate the image difference: Through the character image B to be detectedr and the binary image B in the character template t Calculate the difference image B d . The specific steps are to calculate the absolute difference between the corresponding pixels of the two images to highlight the pixel differences between them, and obtain the binary difference image B d .
[0091] c) Calculate the similarity: In the difference image B d , count the number of pixels in the difference region. The difference region refers to the region of non-zero pixels in the difference image, and the number of pixels in the difference region is the number of non-zero pixels in the difference image. Use the ratio of this number of pixels to the total number of pixels of the binary image B t of the character template to calculate the similarity between the two. The formula for calculating the similarity is as follows:
[0092]
[0093] where S is the similarity, and the value range is between 0 and 1. The closer S is to 1, the more similar the test character is to the template character; N d is the number of pixels in the difference region, and N t is the total number of pixels of the binary image B t of the character template.
[0094] After traversing all the character images to be detected, according to the number of defective character images to be detected, obtain the appearance defect detection result of the electricity meter to be detected. The appearance defect detection result is qualified or unqualified. In this embodiment, when the number of defective character images to be detected exceeds 3, the appearance defect detection result is unqualified, otherwise it is qualified.
[0095] Embodiment 2
[0096] In this embodiment, an electricity meter appearance defect detection device based on deep learning is provided. This system is used to implement the above embodiment. The following terms "module", "unit", etc. can be a combination of software and / or hardware that can achieve a predetermined function. Although the system described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible. The device includes:
[0097] An image acquisition and template making module, which is used to acquire standard electricity meter pictures and generate character templates;
[0098] An image preprocessing module, which is used to preprocess the electricity meter pictures to be detected;
[0099] A character detection module, which is used to identify the characters in the electricity meter pictures to be detected and extract the character images to be detected;
[0100] A template registration module for registering character templates;
[0101] A character defect detection module for performing defect detection on a current character image to be detected based on a template character image, and obtaining an appearance defect detection result of the electricity meter to be detected.
[0102] For the system embodiment, since it basically corresponds to the method embodiment, the relevant parts can be referred to the partial description of the method embodiment. The implementation methods of the remaining modules will not be elaborated here. The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present invention. Those of ordinary skill in the art can understand and implement it without creative efforts.
[0103] The embodiments of the system of the present invention can be applied to any device with data processing capabilities, and the any device with data processing capabilities can be a device or apparatus such as a computer. The system embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a logically meaningful device, it is formed by the processor of any device with data processing capabilities reading the corresponding computer program instructions in the non-volatile memory into the memory for operation.
[0104] Embodiment 3
[0105] In this embodiment, a computer-readable storage medium is provided. The computer-readable storage medium stores computer-executable instructions for executing the method for detecting the appearance defect of an electricity meter based on deep learning according to any one of claims 1 to 7.
[0106] The above embodiments only represent several implementation manners of the present invention. The description is relatively specific and detailed, but it should not be construed as a limitation on the scope of the patent of the present invention. For those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all belong to the protection scope of the present invention.
Claims
1. A method for detecting appearance defects of electric meters based on deep learning, characterized in that: The steps include: S1: Obtain a standard electric meter image and preprocess it, use a deep learning model to recognize characters in the preprocessed standard electric meter image, obtain the positions and labels of all characters in the image, extract the image of a single character according to the recognition result, and store the character image and the recognized character position and character label as a character template; S2: Obtain an image of the electric meter to be detected and pre-process the image of the electric meter to be detected; S3: for the preprocessed image of the electric meter to be detected, a deep learning model is used to recognize characters in the image, positions and labels of all characters in the image of the electric meter to be detected are obtained, and images of each character in the image of the electric meter to be detected are extracted as the character images to be detected according to the recognition results; S4: For each character in the image of the electric meter to be detected, a character template is registered based on the current image of the character to be detected. The character image in the registered character template is the template character image. Character defect detection is performed on the current character to be detected based on the template character image; all characters in the image of the electric meter to be detected are traversed to obtain the appearance defect detection result of the electric meter to be detected.
2. The electric meter appearance defect detection method based on deep learning according to claim 1 is characterized in that: The standard electric meter image described in step (1) refers to an electric meter appearance image that is normal and has no appearance defects.
3. The electric meter appearance defect detection method based on deep learning according to claim 1 is characterized in that: The deep learning model used in S1 and S3 to recognize characters in images uses the same method, including: A one-stage target detection model is constructed and trained, and the trained one-stage target detection model is used to identify all the one-stage targets in the image to be identified, wherein the one-stage targets include LCD screens, nameplates and QR codes; the images of all the one-stage targets are binarized to obtain their binarized images; a two-stage target detection model is constructed and trained, and the binarized images of the one-stage targets are sent to the trained two-stage target detection model to identify all the characters in the binarized images of the one-stage targets, and obtain the position and label of each character.
4. The method for detecting appearance defects of electric meters based on deep learning according to claim 3 is characterized in that: The one-stage target detection model and the two-stage target detection model are both YOLO models.
5. The method for detecting electric meter appearance defects based on deep learning according to claim 1, characterized in that: In S2, the preprocessing comprises the following steps: S2.1: Convert the image to be preprocessed into a grayscale image, and perform binarization on the grayscale image to obtain a binary image; S2.2: Use the Canny edge detection method to perform edge detection on the binary image to obtain an edge image; S2.3: Use the Hough line transform method to perform straight line detection on the edge image, and detect all straight line segments contained in the edge image; S2.4: Calculate the lengths and angles of all straight line segments, and select the longest straight line segment within the angle range of ±30° as the rotation reference; S2.5: Rotate the binary image so that the rotation base reaches the horizontal level.
6. The method for detecting appearance defects of electric meters based on deep learning according to claim 3, characterized in that: In S4, the character template registration based on the current character image to be detected includes the following steps: Get the image width W of the first-stage target of the preprocessed electric meter image to be detected r , get the image width W of the first-stage target of the standard electric meter image t , for image width W r and W t The ratio is calculated as the scaling ratio, and the character image in the character template is scaled according to the scaling ratio to obtain a template character image.
7. The method for detecting electric meter appearance defects based on deep learning according to claim 1, characterized in that: In S4, the character defect detection of the current character image to be detected based on the template character image comprises the following steps: Calculate the Euclidean distance between the position of the current character to be detected and the position of each character in the character template; select k character templates that are the nearest neighbors to the current character to be detected according to the calculated Euclidean distance; Among the k nearest neighbor character templates, select the character template that is consistent with the test character label; If a character template with the same label can be found, the similarity between the template character image in the character template and the current character image to be detected is calculated, and whether the current character to be detected has defects is determined based on the similarity; If no character template with the same label is found, it is determined that the current character to be detected has a defect.
8. The method for detecting appearance defects of electric meters based on deep learning according to claim 7, characterized in that: The similarity calculation process is specifically as follows: a) Take the character image B to be detected r Scale to the character template consistent with the label template character image B t Consistent size; b) Calculate image B r and image B t The difference between image B d , the difference image B d The pixel value of image B r and image B t The absolute difference of corresponding pixels; Statistical difference image B d The number of non-zero pixels N in d , based on the number of non-zero pixels N d With image B t The total number of pixels N t , calculate image B r and image B t Similarity 9. A device for detecting appearance defects of electric meters based on deep learning, characterized in that: For implementing the detection method of claim 1, the device comprises: Image acquisition and template making module, used to acquire standard electric meter pictures and generate character templates; An image preprocessing module, used to preprocess the standard electric meter image and the electric meter image to be tested; A character detection module is used to identify characters in the image of the electric meter to be detected and extract the image of the characters to be detected; Template registration module, used to register character templates; The character defect detection module is used to perform defect detection on the current character to be detected based on the template character image.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to execute the electric meter appearance defect detection method based on deep learning as described in any one of claims 1 to 8.
Citation Information
Patent Citations
AOI character defect detection method and device based on industrial machine vision
CN111474184A
Defect area determination method and determination device, storage medium and processor
CN111612774A
Detection method, device, system and equipment for jet code on production line, and medium
CN113436180A
Water gauge automatic reading method based on deep learning
CN113971779A
Digital instrument intelligent identification method and system based on deep learning
CN114067304A