A universal method, device, equipment and medium for generating a standard template for an electric meter

Through deep learning models, segmentation and identification of meter images are generated to generate meter standard templates, solving the problems of low efficiency and limited accuracy of traditional handmade meter standard templates, and achieving efficient and accurate meter detection.

CN117115834BActive Publication Date: 2025-08-15HANGZHOU DECHUANG ELECTRONICS +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311126306.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-01
Publication Date
2025-08-15
Estimated Expiration
2043-09-01

AI Technical Summary

Technical Problem

Traditional meter detection methods rely on hand-made meter standard templates, resulting in waste of manpower and time. The accuracy of the template is affected by human factors, making it difficult to efficiently generate meter standard templates.

Method used

A deep learning-based object detection and character recognition model is used to generate a meter standard template through segmentation and character recognition, and a pre-trained model is used to segment and character recognition of the initial meter image, and a meter standard template is obtained by splicing.

Benefits of technology

The generation process of meter standard templates is simplified, the possibility of manual errors is reduced, and the model is improved, and it can be used for many types of meters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117115834B_ABST
    Figure CN117115834B_ABST
Patent Text Reader

Abstract

The present application discloses a universal method, apparatus, device, and medium for generating a standard template for an electric meter, relating to the field of computer technology. The method comprises the following steps: acquiring an initial electric meter image of a target electric meter; segmenting the initial electric meter image using a target detection model pre-trained based on electric meter images of different types of electric meters to obtain a plurality of target segmented regions; performing character recognition on the plurality of target segmented regions using a target character recognition model pre-trained based on electric meter images of different types of electric meters to obtain a character recognition result corresponding to each target segmented region; and concatenating the character recognition results corresponding to all target segmented regions to obtain a standard template for the target electric meter. The present application utilizes a target detection model and a target character recognition model to quickly and easily generate a standard template for an electric meter, thereby reducing the possibility of template errors; and training the model based on electric meter images of different types of electric meters improves the versatility of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer technology, and in particular to a universal method, device, equipment and medium for generating a standard template for an electric meter. Background Art

[0002] Currently, electricity meters are one of the most important energy measurement tools in modern society. To ensure their performance and safety, they need to be tested. At this time, a standard meter template is needed as a testing template. However, traditional meter testing methods mainly rely on manually made standard meter templates, which wastes a lot of manpower and time. The accuracy of the template is also affected by human factors.

[0003] In summary, how to simply and efficiently generate a standard template for an electric meter is an urgent problem to be solved. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a universal method, device, equipment and medium for generating a standard template for an electric meter, which can simply and efficiently generate a standard template for an electric meter. The specific scheme is as follows:

[0005] In a first aspect, the present application discloses a general method for generating a standard template for an electric meter, comprising:

[0006] Acquire an initial meter image of the target meter;

[0007] The initial meter image is segmented using a target detection model pre-trained based on meter images of different types of meters to obtain a plurality of target segmentation regions; the target detection model is a model for segmenting the region required for the template from the initial meter image;

[0008] Performing character recognition on the target segmented regions using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result corresponding to each target segmented region;

[0009] The character recognition results corresponding to all the target segmented areas are spliced together to obtain an electric meter standard template of the target electric meter.

[0010] Optionally, the initial electricity meter image is segmented using a target detection model pre-trained based on electricity meter images of different types of electricity meters to obtain a plurality of target segmentation regions, including:

[0011] The initial meter image is segmented using a target detection model pre-trained based on meter images of different types of meters to obtain a plurality of target segmentation regions and target segmentation labels for the target segmentation regions; the target segmentation labels include a region name, a region width, a region height, and a region position coordinate of the target segmentation region in the initial meter image with the upper left corner of the meter as the origin;

[0012] Accordingly, the target character recognition model pre-trained based on the meter images of the different types of meters is used to perform character recognition on the plurality of target segmented regions to obtain a character recognition result corresponding to each target segmented region, including:

[0013] Performing character recognition on the target segmented areas using a target character recognition model pre-trained based on meter images of different types of meters to obtain a character recognition result and a target character recognition label corresponding to each target segmented area; the target character recognition label includes a character category, a character width, a character height, and a character position coordinate of the target character in the target segmented area with the upper left corner of the area as the origin;

[0014] Accordingly, the step of splicing the character recognition results corresponding to all the target segmented areas to obtain the standard template of the target electric meter includes:

[0015] Based on the target segmentation label and the target character recognition label, the character recognition results corresponding to all the target segmentation areas are spliced together to obtain an electric meter standard template of the target electric meter.

[0016] Optionally, the step of combining the character recognition results corresponding to all the target segmented regions based on the target segmentation label and the target character recognition label to obtain a standard electric meter template for the target electric meter includes:

[0017] Determining the target position coordinates of each target character in the initial electricity meter image with the upper left corner of the electricity meter as the origin based on the region position coordinates of the target segmented region with the upper left corner of the electricity meter as the origin in the initial electricity meter image and the character position coordinates of the target character in the target segmented region with the upper left corner of the region as the origin;

[0018] Based on the target position coordinates and the area name, area width and area height of the target segmented area and the character category, character width and character height of the corresponding character, the character recognition results corresponding to all the target segmented areas are spliced to obtain the meter standard template of the target meter.

[0019] Optionally, before segmenting the initial electricity meter image to obtain a plurality of target segmentation regions using a target detection model pre-trained based on electricity meter images of different types of electricity meters, the method further includes:

[0020] collecting meter images of the different types of meters;

[0021] Adjusting the brightness of the meter images of the different types of meters according to a pixel-level image processing formula to achieve meter image expansion under different illumination conditions, and adjusting the clarity of the meter images of the different types of meters to achieve meter image expansion under different resolutions to obtain an expanded meter image including the meter images of the different types of meters and the adjusted image;

[0022] Setting a segmentation label to be trained for each template required region in the expanded electricity meter image to obtain a plurality of electricity meter images to be trained; the segmentation label to be trained includes the region name, region width and region height of the template required region and the region position coordinates of the template required region in the corresponding electricity meter image;

[0023] The target detection model is obtained by training an initial detection model constructed based on a deep learning algorithm using the electric meter image to be trained.

[0024] Optionally, the pixel-level image processing formula is:

[0025]

[0026] Among them, n 2 Indicates the number of pixels in the filter window, n is an odd number; is the grayscale value of the pixel in the i-th row and j-th column of the expanded electricity meter image; The first image of the electric meter before expansion OK Grayscale value of the column pixel; s is the grayscale value offset.

[0027] Optionally, before performing character recognition on the target segmented regions using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result corresponding to each target segmented region, the method further includes:

[0028] Cutting out the required area of the template in the electric meter image to be trained based on the segmentation label to be trained;

[0029] Setting a to-be-trained character recognition label for each character in the required area of the template to obtain the to-be-trained segmented area; the to-be-trained character recognition label includes the character width, character height and character category of the to-be-trained character and the character position coordinates of the to-be-trained character in the required area of the template;

[0030] The target character recognition model is obtained by training an initial character recognition model constructed based on a deep learning algorithm using the segmented area to be trained.

[0031] Optionally, setting a to-be-trained character recognition label for each character in the required area of the template to obtain the to-be-trained segmented area includes:

[0032] Setting a character recognition label to be trained for each character in the required area of the template to obtain a character recognition area;

[0033] The character recognition area is processed multiple times using any one or more of a random flipping method, a random brightness adjustment method, and a random Gaussian blur processing method to obtain a processed area, and the character recognition area and the processed area are used as the segmentation area to be trained.

[0034] Optionally, the using the to-be-trained electric meter image to train an initial detection model constructed based on a deep learning algorithm to obtain the target detection model includes:

[0035] Extracting a feature map of each of the to-be-trained electric meter images using a downsampling method, and inputting the feature map into an initial detection model to train the initial detection model to obtain a temporary detection model;

[0036] The size of the feature map obtained by the upsampling method is restored to the size of the electric meter image to be trained to obtain a restored image, and the temporary detection model is trained using the restored image to obtain a target detection model.

[0037] In a second aspect, the present application discloses a general electric meter standard template generating device, comprising:

[0038] An image acquisition module, used for acquiring an initial meter image of a target meter;

[0039] a segmentation module, configured to segment the initial meter image to obtain a plurality of target segmentation regions using a target detection model pre-trained based on meter images of different types of meters; the target detection model is a model for segmenting the region required for the template from the initial meter image;

[0040] a character recognition module, configured to perform character recognition on the target segmented regions using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result corresponding to each target segmented region;

[0041] The splicing module is used to splice the character recognition results corresponding to all the target segmented areas to obtain an electric meter standard template of the target electric meter.

[0042] In a third aspect, the present application discloses an electronic device, comprising:

[0043] Memory, used to store computer programs;

[0044] The processor is configured to execute the computer program to implement the aforementioned disclosed general method for generating a standard template for an electric meter.

[0045] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned general method for generating a standard template for an electric meter is implemented.

[0046] It can be seen that the present application collects an initial meter image of the target meter; uses a target detection model pre-trained based on meter images of different types of meters to segment the initial meter image to obtain several target segmentation areas; the target detection model is a model for segmenting the area required for the template from the initial meter image; uses a target character recognition model pre-trained based on meter images of different types of meters to perform character recognition on several target segmentation areas to obtain a character recognition result corresponding to each target segmentation area; and splices the character recognition results corresponding to all the target segmentation areas to obtain a meter standard template for the target meter. It can be seen that the present application uses a pre-built target detection model and a target character recognition model for segmentation and recognition, and subsequently splices the character recognition results to obtain a meter standard template for the target meter. Compared with manually constructing templates, this process is simpler and faster, and also reduces the possibility of template errors; in addition, since the models are trained based on meter images of different types of meters, the models can be used to construct meter standard templates for multiple types of meters, thereby improving the versatility of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0048] Figure 1 This is a flow chart of a general method for generating a standard template for an electric meter disclosed in this application;

[0049] Figure 2 This is a schematic diagram of an initial electric meter image disclosed in this application;

[0050] Figure 3 This is a schematic diagram of a standard template for a single-phase electric meter LCD screen disclosed in this application;

[0051] Figure 4 This is a schematic diagram of a standard template for a three-phase electric meter LCD screen disclosed in this application;

[0052] Figure 5 This is a flowchart of a specific general method for generating a standard template for an electric meter disclosed in this application;

[0053] Figure 6 This is a schematic structural diagram of a general electric meter standard template generating device disclosed in this application;

[0054] Figure 7 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0055] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0056] Currently, electricity meters are one of the important energy measurement tools in modern society. In order to ensure the performance and safety of electricity meters, they need to be tested. However, traditional electricity meter testing methods mainly rely on manually made meter standard templates, which wastes a lot of manpower and time. The accuracy of the templates is also affected by human factors.

[0057] To this end, an embodiment of the present application proposes a solution for generating a standard template for an electric meter, which can generate a standard template for an electric meter simply and efficiently.

[0058] The present application discloses a general method for generating a standard template for an electric meter. Figure 1 As shown, the method includes:

[0059] Step S11: Acquire an initial meter image of the target meter.

[0060] In this embodiment, the collected initial electricity meter image must be a functioning electricity meter image, that is, an electricity meter image without missing characters, incomplete characters, virtual display on the LCD screen, or other abnormal conditions.

[0061] In this embodiment, the target electricity meter may be a three-phase electricity meter, a single-phase electricity meter, an overseas electricity meter, or other types of electricity meters.

[0062] Step S12: segmenting the initial meter image to obtain a number of target segmentation regions using a target detection model pre-trained based on meter images of different types of meters; the target detection model is a model for segmenting the region required for the template from the initial meter image.

[0063] In this embodiment, the template area may include the LCD screen, nameplate, seal bean and other areas, of course, it can also include only the LCD screen area, which is determined according to the actual situation and is not specifically limited here. Figure 2 FIG. 1 shows a schematic diagram of an initial electric meter image.

[0064] In this embodiment, during the process of segmenting the initial electricity meter image, a mask technology may be used to mask areas other than the area required by the template and highlight the area required by the template to facilitate segmentation.

[0065] In this embodiment, the target detection model can adopt various deep learning networks such as YOLO (You Only Look Once), SSD (Single Shot MultiBox Detector) or Faster R-CNN (Region based Convolutional Neural Network); the target detection model can be a YOLOv5 model, the core part of which is the detection head (Detection Head), and the detection technology used is the anchor box (Anchor Box) target detection technology.

[0066] In this embodiment, the target detection model pre-trained based on meter images of different types of meters is used to segment the initial meter image to obtain a number of target segmentation areas, including: the target detection model pre-trained based on meter images of different types of meters is used to segment the initial meter image to obtain a number of target segmentation areas and target segmentation labels of the target segmentation areas; the target segmentation label includes the area name, area width and area height of the target segmentation area, and the area position coordinates of the target segmentation area in the initial meter image with the upper left corner of the meter as the origin; the area name of the target segmentation area can be an LCD screen, a nameplate, a seal bean, etc., and the area position coordinates include the X-axis coordinate and the Y-axis coordinate with the upper left corner of the meter as the origin.

[0067] Step S13: performing character recognition on a plurality of the target segmented regions using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result corresponding to each of the target segmented regions.

[0068] In this embodiment, the target character recognition model can adopt various deep learning networks such as YOLO, SSD or Faster R-CNN; the target detection model and the target character recognition model can be the same deep learning network or different deep learning networks.

[0069] In this embodiment, the target character recognition model obtained by pre-training based on the meter images of the different types of meters is used to perform character recognition on several target segmented areas to obtain a character recognition result corresponding to each target segmented area, including: using the target character recognition model obtained by pre-training based on the meter images of the different types of meters to perform character recognition on several target segmented areas to obtain a character recognition result and a target character recognition label corresponding to each target segmented area; the target character recognition label includes the character category, character width and character height of the target character and the character position coordinates of the target character in the target segmented area with the upper left corner of the area as the origin; it should be pointed out that the character recognition result mainly includes the character category of each character, that is, what specific word it is; the character position coordinates include the X-axis coordinate and the Y-axis coordinate with the upper left corner of the meter as the origin.

[0070] Step S14: splicing the character recognition results corresponding to all the target segmented areas to obtain an electric meter standard template of the target electric meter.

[0071] In this embodiment, the character recognition results corresponding to all the target segmented areas are spliced together to obtain the standard meter template of the target meter, including: based on the target segmentation label and the target character recognition label, the character recognition results corresponding to all the target segmented areas are spliced together to obtain the standard meter template of the target meter.

[0072] In this embodiment, based on the target segmentation label and the target character recognition label, the character recognition results corresponding to all the target segmentation areas are spliced to obtain the meter standard template of the target meter, including: based on the area position coordinates of the target segmentation area in the corresponding initial meter image with the upper left corner of the meter as the origin and the character position coordinates of the target character in the target segmentation area with the upper left corner of the area as the origin, determining the target position coordinates of each target character in the initial meter image with the upper left corner of the meter as the origin; based on the target position coordinates and the area name, area width and area height of the target segmentation area and the character category, character width and character height of the corresponding character, splicing the character recognition results corresponding to all the target segmentation areas to obtain the meter standard template of the target meter.

[0073] In this embodiment, the meter standard template of the target meter obtained by splicing is stored in a computer storage medium in a certain format. Specifically, the character recognition results are stored in a text document in the order of the X coordinate, Y coordinate, character width W, character height H, and character category of the upper left corner of each character in the image, and each recognition result occupies a line in the text document.

[0074] In this embodiment, see Figure 3 The following is a schematic diagram of a standard template for a single-phase meter LCD screen; see Figure 4 The figure shows a schematic diagram of a standard template of a three-phase electricity meter LCD screen.

[0075] It can be seen that the present application collects an initial meter image of the target meter; uses a target detection model pre-trained based on meter images of different types of meters to segment the initial meter image to obtain several target segmentation areas; the target detection model is a model for segmenting the area required for the template from the initial meter image; uses a target character recognition model pre-trained based on meter images of different types of meters to perform character recognition on several target segmentation areas to obtain a character recognition result corresponding to each target segmentation area; and splices the character recognition results corresponding to all the target segmentation areas to obtain a meter standard template for the target meter. It can be seen that the present application uses a pre-built target detection model and a target character recognition model for segmentation and recognition, and subsequently splices the character recognition results to obtain a meter standard template for the target meter. Compared with manually constructing templates, this process is simpler and faster, and also reduces the possibility of template errors; in addition, since the models are trained based on meter images of different types of meters, the models can be used to construct meter standard templates for multiple types of meters, thereby improving the versatility of the model.

[0076] The embodiment of the present application discloses a specific universal method for generating a standard template for an electric meter. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Figure 5 As shown, specifically including:

[0077] Step S21: collecting meter images of the different types of meters; adjusting the brightness of the meter images of the different types of meters according to a pixel-level image processing formula to achieve meter image expansion under different lighting conditions, and adjusting the clarity of the meter images of the different types of meters to achieve meter image expansion with different resolutions to obtain an expanded meter image including the meter images of the different types of meters and the adjusted image.

[0078] In this embodiment, different types of electricity meters include three-phase electricity meters, single-phase electricity meters, and overseas electricity meters.

[0079] In this embodiment, the pixel-level image processing formula is:

[0080]

[0081] Among them, n 2 Indicates the number of pixels in the filter window, n is an odd number; is the grayscale value of the pixel in the i-th row and j-th column of the expanded electricity meter image; The first OK The grayscale value of the column pixel; s is the grayscale value offset. Where n is an odd number, different n means different clarity; s is the grayscale value offset, different s means different lighting.

[0082] It should be pointed out that the convolution kernel size in the formula is n×n. This application mainly uses the change of the grayscale value offset of s to simulate the different grayscale values caused by different lighting. s is within the preset range, and the preset range can be -30 to 50. The clarity is adjusted by the size of n. The larger n is, the blurrier it is.

[0083] It should be noted that n is generally an odd number for the following reasons: applying a kernel spanning two pixels (even-numbered kernel) around each pixel will produce an asymmetric effect because the weight of each pixel is different. In addition, the center position of the even-numbered kernel may be empty or overlap with two adjacent pixels, which makes the filtering result unstable or difficult to understand. In order to ensure the symmetry and stability of the smoothing filter, the size of the filter kernel usually needs to be an odd number, so that the kernel position is exactly at the center of the pixel and the weight provided to each pixel is the same. Therefore, common filter kernel sizes are odd sizes such as 3×3, 5×5, 7×7, so n is generally an odd number.

[0084] It should be pointed out that the larger n is, the blurrier it is. The specific reasons are as follows: the larger n is, the larger the range of pixels involved in the operation will be, the details and sharpness in the image will be reduced, and the picture will become more and more blurry.

[0085] It should be pointed out that the existence of pixel-level image processing formulas increases the number of images involved in training, and makes the images involved in training images under different lighting and resolutions, which further makes the trained model suitable for processing images under various lighting and resolutions, enhancing the applicability of the model.

[0086] Step S22: setting a segmentation label to be trained for each template required area in the expanded electricity meter image to obtain a plurality of electricity meter images to be trained; the segmentation label to be trained includes the area name, area width and area height of the template required area and the area position coordinates of the template required area in the corresponding electricity meter image.

[0087] In this embodiment, the Labelimg labeling tool is used to set the segmentation labels to be trained.

[0088] Step S23: Using the electric meter image to be trained, an initial detection model constructed based on a deep learning algorithm is trained to obtain the target detection model.

[0089] In this embodiment, the target detection model is obtained by training an initial detection model constructed based on a deep learning algorithm using the to-be-trained electricity meter images, including: extracting a feature map of each to-be-trained electricity meter image using a downsampling method, and inputting the feature map into the initial detection model to train the initial detection model to obtain a temporary detection model; restoring the size of the feature map using an upsampling method to the size of the to-be-trained electricity meter image to obtain a restored image, and using the restored image to train the temporary detection model to obtain a target detection model.

[0090] It's important to note that downsampling reduces the image resolution to extract target features, reducing computational and memory requirements while preserving key features. Upsampling restores the feature size to facilitate object detection and recognition in the original image. These two steps, combined, reduce computational complexity while ensuring accurate object detection and recognition. Downsampling and upsampling are often used together in image processing to achieve better results in specific tasks. This combination achieves several goals: First, feature extraction and dimensionality reduction: In image processing and computer vision tasks, images typically have a high resolution, resulting in significant computational overhead. Downsampling reduces the image resolution, reducing computational complexity and memory space. Downsampling also helps extract more abstract and important features, as higher-level features can be represented at different scales. Second, it increases the receptive field: In deep learning models such as convolutional neural networks, a small receptive field may not capture global image information. Downsampling can expand the receptive field, enabling the model to perceive a wider range of image information. Third, it can reduce overfitting: Downsampling can reduce redundant image information, thereby helping to reduce the risk of overfitting and improve the model's generalization ability. However, simply downsampling can result in loss of image detail due to the reduced resolution. In this case, upsampling is necessary to restore image detail and resolution. The upsampling process involves enlarging a low-resolution image to preserve more detail. Common upsampling methods include interpolation and deconvolution. In tasks such as object detection, the upsampling results are often used to restore low-resolution feature maps to the original image size for object localization and detection. This combination of downsampling and upsampling can maintain computational efficiency while obtaining sufficiently high-resolution feature maps, enabling the model to accurately detect objects.

[0091] In this embodiment, the target detection model is the YOLOv5 target detection model, the core of which is the detection head. It uses target detection technology based on anchor boxes to accurately detect and segment targets in images. During model training and inference, the target area is masked and highlighted by combining Mask technology, and class imbalance loss is weighted to improve the accuracy and robustness of the model. In order to reduce the number of trainable parameters and learn image features more robustly, the embodiment of the present invention uses the lightweight model GhostNet as the backbone network of YOLOv5, and uses Focal loss as the standard loss function during training.

[0092] Specifically, the embodiments of the present invention use YOLOv5 as the underlying object detection model. The YOLOv5 model workflow can be divided into the following steps: image input, feature extraction, anchor box generation, object classification and localization, and post-processing. First, image input: The model first receives an input image as its input data. Second, feature extraction: The backbone network (GhostNet) performs feature extraction on the input image to extract high-level semantic features from the image. Third, anchor box generation: Based on the feature map, anchor box technology is used to generate a series of candidate boxes. These candidate boxes are used to capture objects of different sizes and scales. Fourth, object classification and localization: For each candidate box, the model uses the detection head to classify and localize the object. The detection head uses information in the feature map to predict the object classification and location based on the object features within the candidate box. Fifth, post-processing: The model performs post-processing on the predicted object classification and localization results. This includes removing overlapping candidate boxes, applying non-maximum suppression (NMS) to select the best candidate box, and filtering the final detection results based on a preset confidence threshold. In this embodiment, Mask technology is also introduced to enhance the performance of the model. During the training and inference process, Mask technology is combined to mask and highlight the target area. In this way, the model can pay more attention to the important parts of the target and improve the accuracy and segmentation effect of the target. In order to reduce the number of model parameters and speed up the training and inference of the model, the lightweight model GhostNet is selected as the backbone network of YOLOv5. At the same time, during the training process, Focal loss is used as the standard loss function to help the model better deal with the category imbalance problem in target detection. It should be pointed out that the process of using the model for detection after training is completed is similar to the above steps.

[0093] It should be noted that post-processing is performed using the Mean Shift algorithm. Specifically, in object detection post-processing, the Mean Shift algorithm can further improve detection performance and speed by performing the following key functions: First, it removes redundant detection boxes: During object detection, the same object may be detected by multiple detection boxes, a phenomenon known as redundant detection. The Mean Shift algorithm clusters these redundant detection boxes, merging similar detection boxes into a single box, thereby reducing duplicate and redundant detection results. Second, it refines object localization: By performing density estimation in feature space, the Mean Shift algorithm clusters similar feature points, resulting in more accurate object localization. This clustering effect ensures that the object detection boxes more precisely cover the target area, improving object detection accuracy. Third, it suppresses noise and outliers: During object detection, noise and outliers may occur, which can lead to erroneous detection results. The mean shift algorithm uses density estimation to identify and filter out noise and outliers, thereby reducing the occurrence of false detections. Fourth, it accelerates computation: Optimized versions of the mean shift algorithm, such as Mean Shift Fast Mode Finding, can efficiently perform density estimation and clustering operations. This efficiency enables the mean shift algorithm to quickly complete computations in target detection post-processing, thereby improving detection speed. In summary, the mean shift algorithm can further improve the effectiveness and speed of target detection in post-processing by clustering, refining target positioning, and suppressing noise and outliers. It is an effective technique often used to optimize target detection results, making detectors more robust and efficient.

[0094] Step S24: cutting out the required area of the template in the electricity meter image to be trained based on the segmentation label to be trained.

[0095] In this embodiment, the images can be captured manually or using a previously trained target detection model.

[0096] Step S25: setting a character recognition label to be trained for each character in the required area of the template to obtain the segmented area to be trained; the character recognition label to be trained includes the character width, character height and character category of the character to be trained and the character position coordinates of the character to be trained in the required area of the template.

[0097] In this embodiment, the Labelimg labeling tool is used to set the character recognition labels to be trained.

[0098] In this embodiment, before training, it is possible to consider improving the generalization ability of the model by increasing the training data, and to improve the robustness of the model by increasing the noise data. Therefore, it is possible to consider setting the character recognition label to be trained, and then performing random flipping processing, random brightness adjustment processing, and random Gaussian blur processing, and simulating the differences in position, brightness, and camera resolution when taking pictures, to obtain different images of the segmented areas to be trained that are horizontally flipped or vertically flipped or flipped horizontally and vertically at the same time, and whose brightness and clarity are randomly changed; specifically, setting the character recognition label to be trained for each character in the required area of the template to obtain the segmented area to be trained, including: setting the character recognition label to be trained for each character in the required area of the template to obtain a character recognition area; using any one or more of the random flipping method, random brightness adjustment method, and random Gaussian blur processing method to process the character recognition area multiple times to obtain a processed area, and using the character recognition area and the processed area as the segmented area to be trained.

[0099] Step S26: Using the segmented area to be trained, the initial character recognition model constructed based on the deep learning algorithm is trained to obtain the target character recognition model.

[0100] It can be seen that the present application collects meter images of the different types of meters; sets a to-be-trained segmentation label for each template required area in the meter images of the different types of meters to obtain a number of meter images to be trained; the to-be-trained segmentation label includes the area name, area width and area height of the template required area and the area position coordinates of the template required area in the corresponding meter image; uses the meter images to be trained to train the initial detection model constructed based on the deep learning algorithm to obtain the target detection model; based on the to-be-trained segmentation label, the template required area in the meter image to be trained is intercepted; a to-be-trained character recognition label is set for each character in the template required area to obtain the to-be-trained segmentation area; the to-be-trained character recognition label includes the character width, character height and character category of the character to be trained and the character position coordinates of the character to be trained in the template required area; uses the to-be-trained segmentation area to train the initial character recognition model constructed based on the deep learning algorithm to obtain the target character recognition model. It can be seen that the present application obtains a target detection model and a target character recognition model for generating a standard model of an electric meter by training the initial detection model and the initial character recognition model constructed by the deep learning algorithm, so as to generate a standard template of an electric meter; in addition, the models are constructed based on the electric meter models of different types of electric meters, so that standard templates of electric meters of different types of electric meters can be generated, thereby improving the versatility of the model; in addition, the existence of pixel-level image processing formulas increases the number of images involved in the training, further making the trained model suitable for processing images under various lighting and resolutions, thereby enhancing the applicability of the model.

[0101] Correspondingly, the present application also discloses a general electric meter standard template generating device, see Figure 6 As shown, the device includes:

[0102] An image acquisition module 11 is used to acquire an initial meter image of a target meter;

[0103] a segmentation module 12 for segmenting the initial meter image to obtain a plurality of target segmentation regions using a target detection model pre-trained based on meter images of different types of meters; the target detection model is a model for segmenting the region required for the template from the initial meter image;

[0104] A character recognition module 13 is configured to perform character recognition on the target segmented regions using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result corresponding to each target segmented region;

[0105] The splicing module 14 is configured to splice the character recognition results corresponding to all the target segmented areas to obtain a standard template of the target electric meter.

[0106] Among them, for more specific working processes of the above modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0107] It can be seen that the present application collects an initial meter image of the target meter; uses a target detection model pre-trained based on meter images of different types of meters to segment the initial meter image to obtain several target segmentation areas; the target detection model is a model for segmenting the area required for the template from the initial meter image; uses a target character recognition model pre-trained based on meter images of different types of meters to perform character recognition on several target segmentation areas to obtain a character recognition result corresponding to each target segmentation area; and splices the character recognition results corresponding to all the target segmentation areas to obtain a meter standard template for the target meter. It can be seen that the present application uses a pre-built target detection model and a target character recognition model for segmentation and recognition, and subsequently splices the character recognition results to obtain a meter standard template for the target meter. Compared with manually constructing templates, this process is simpler and faster, and also reduces the possibility of template errors; in addition, since the models are trained based on meter images of different types of meters, the models can be used to construct meter standard templates for multiple types of meters, thereby improving the versatility of the model.

[0108] Furthermore, an embodiment of the present application also provides an electronic device. Figure 7 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram should not be considered as any limitation to the scope of application of the present application.

[0109] Figure 7 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps of the general electric meter standard template generation method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0110] In this embodiment, the power supply 26 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 25 can create a data transmission channel between the electronic device 20 and the external device. The communication protocol it follows is any communication protocol that can be applied to the technical solution of this application and is not specifically limited here; the input and output interface 24 is used to obtain external input data or output data to the outside world. Its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0111] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, a magnetic disk, or an optical disk, etc. The resources stored thereon can include a computer program 221, which can be stored in a temporary or permanent manner. In addition to including a computer program capable of implementing the general method for generating a standard electricity meter template executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 221 can further include a computer program capable of implementing other specific tasks.

[0112] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed general method for generating a standard template for an electric meter is implemented.

[0113] For the specific steps of this method, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0114] The various embodiments in this application are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.

[0115] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0116] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0117] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0118] The above is a detailed introduction to a general method, device, equipment, and storage medium for generating a standard template for an electric meter provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for those skilled in the art, based on the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A general method for generating a standard template for an electric meter, characterized in that: include: Acquire an initial meter image of the target meter; Segmenting the initial electricity meter image using a target detection model pre-trained based on electricity meter images of different types of electricity meters to obtain a plurality of target segmentation regions; The target detection model is a YOLOv5 model that segments the area required for the template from the initial electricity meter image; wherein, during the segmentation process, a masking operation is performed on other areas outside the target segmented area using a masking technique, and a mean shift algorithm is used to complete the post-processing operation; Performing character recognition on the target segmented regions using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result corresponding to each target segmented region; splicing the character recognition results corresponding to all the target segmented areas to obtain an electric meter standard template of the target electric meter; The target detection model pre-trained based on images of different types of meters is used to segment the initial meter image to obtain a number of target segmentation regions, including: The initial meter image is segmented using a target detection model pre-trained based on meter images of different types of meters to obtain a plurality of target segmentation regions and target segmentation labels for the target segmentation regions; the target segmentation labels include a region name, a region width, a region height, and a region position coordinate of the target segmentation region in the initial meter image with the upper left corner of the meter as the origin; Accordingly, the target character recognition model pre-trained based on the meter images of the different types of meters is used to perform character recognition on the plurality of target segmented regions to obtain a character recognition result corresponding to each target segmented region, including: A target character recognition model pre-trained based on the meter images of the different types of meters is used to perform character recognition on several target segmented areas to obtain a character recognition result and a target character recognition label corresponding to each target segmented area; the target character recognition label includes the character category, character width and character height of the target character and the character position coordinates of the target character in the target segmented area with the upper left corner of the area as the origin.

2. The method for generating a universal electric meter standard template according to claim 1, characterized in that: The step of splicing the character recognition results corresponding to all the target segmented areas to obtain the standard template of the target electric meter includes: Based on the target segmentation label and the target character recognition label, the character recognition results corresponding to all the target segmentation areas are spliced together to obtain an electric meter standard template of the target electric meter.

3. The method for generating a universal electric meter standard template according to claim 2, wherein: The step of combining the character recognition results corresponding to all target segmented regions based on the target segmentation label and the target character recognition label to obtain a standard electric meter template for the target electric meter includes: Determining the target position coordinates of each target character in the initial electricity meter image with the upper left corner of the electricity meter as the origin based on the region position coordinates of the target segmented region with the upper left corner of the electricity meter as the origin in the initial electricity meter image and the character position coordinates of the target character in the target segmented region with the upper left corner of the region as the origin; Based on the target position coordinates and the area name, area width and area height of the target segmented area and the character category, character width and character height of the corresponding character, the character recognition results corresponding to all the target segmented areas are spliced to obtain the meter standard template of the target meter.

4. The method for generating a universal electric meter standard template according to claim 2, wherein: Before segmenting the initial electricity meter image to obtain a plurality of target segmentation regions using a target detection model pre-trained based on electricity meter images of different types of electricity meters, the method further includes: collecting meter images of the different types of meters; Adjusting the brightness of the meter images of the different types of meters according to a pixel-level image processing formula to achieve meter image expansion under different illumination conditions, and adjusting the clarity of the meter images of the different types of meters to achieve meter image expansion under different resolutions to obtain an expanded meter image including the meter images of the different types of meters and the adjusted image; Setting a segmentation label to be trained for each template required region in the expanded electricity meter image to obtain a plurality of electricity meter images to be trained; the segmentation label to be trained includes the region name, region width and region height of the template required region and the region position coordinates of the template required region in the corresponding electricity meter image; The target detection model is obtained by training an initial detection model constructed based on a deep learning algorithm using the electric meter image to be trained.

5. The method for generating a universal electric meter standard template according to claim 4, characterized in that: The pixel-level image processing formula is: Among them, n 2 Indicates the number of pixels in the filter window, n is an odd number; is the grayscale value of the pixel in the i-th row and j-th column of the expanded electricity meter image; The first OK Grayscale value of the column pixel; s is the grayscale value offset.

6. The method for generating a universal electric meter standard template according to claim 4, characterized in that: Before performing character recognition on the target segmented regions using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result corresponding to each target segmented region, the method further includes: Cutting out the required area of the template in the electric meter image to be trained based on the segmentation label to be trained; Setting a to-be-trained character recognition label for each character in the required area of the template to obtain the to-be-trained segmented area; the to-be-trained character recognition label includes the character width, character height and character category of the to-be-trained character and the character position coordinates of the to-be-trained character in the required area of the template; The target character recognition model is obtained by training an initial character recognition model constructed based on a deep learning algorithm using the segmented area to be trained.

7. The method for generating a universal electric meter standard template according to claim 6, characterized in that: The step of setting a character recognition label to be trained for each character in the required area of the template to obtain the segmented area to be trained comprises: Setting a character recognition label to be trained for each character in the required area of the template to obtain a character recognition area; The character recognition area is processed multiple times using any one or more of a random flipping method, a random brightness adjustment method, and a random Gaussian blur processing method to obtain a processed area, and the character recognition area and the processed area are used as the segmentation area to be trained.

8. The method for generating a universal electric meter standard template according to any one of claims 5 to 7, characterized in that: The method of using the electric meter image to be trained to train an initial detection model constructed based on a deep learning algorithm to obtain the target detection model includes: Extracting a feature map of each of the to-be-trained electric meter images using a downsampling method, and inputting the feature map into an initial detection model to train the initial detection model to obtain a temporary detection model; The size of the feature map obtained by the upsampling method is restored to the size of the electric meter image to be trained to obtain a restored image, and the temporary detection model is trained using the restored image to obtain a target detection model.

9. A general electric meter standard template generating device, characterized in that: include: An image acquisition module, used for acquiring an initial meter image of a target meter; a segmentation module, configured to segment the initial electricity meter image using a target detection model pre-trained based on electricity meter images of different types of electricity meters to obtain a plurality of target segmentation regions; The target detection model is a YOLOv5 model that segments the area required for the template from the initial electricity meter image; wherein, during the segmentation process, a masking operation is performed on other areas outside the target segmented area using a masking technique, and a mean shift algorithm is used to complete the post-processing operation; a character recognition module, configured to perform character recognition on the target segmented regions using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result corresponding to each target segmented region; A splicing module, configured to splice the character recognition results corresponding to all the target segmented areas to obtain an electric meter standard template of the target electric meter; The segmentation module is specifically configured to segment the initial meter image using a target detection model pre-trained based on meter images of different types of meters to obtain a plurality of target segmentation regions and target segmentation labels for the target segmentation regions; the target segmentation labels include the region name, region width, and region height of the target segmentation region, as well as the region position coordinates of the target segmentation region in the initial meter image with the upper left corner of the meter as the origin; Correspondingly, the character recognition module is specifically used to perform character recognition on several target segmented areas using a target character recognition model pre-trained based on the meter images of the different types of meters to obtain a character recognition result and a target character recognition label corresponding to each target segmented area; the target character recognition label includes the character category, character width and character height of the target character and the character position coordinates of the target character in the target segmented area with the upper left corner of the area as the origin.

10. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor is configured to execute the computer program to implement the universal method for generating a standard template for an electric meter as claimed in any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that Used to store a computer program; wherein, when the computer program is executed by a processor, the universal electric meter standard template generation method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Character detection and recognition method for various types of digital display instruments

    CN115116071A