Electric meter intelligent recycling method and system
By using sliding window cutting and template matching technology, the problem of recognition difficulties caused by wear and tear on electricity meter barcodes has been solved, achieving efficient recognition of electricity meter digital codes and simplifying the electricity meter recycling process.
Patent Information
- Application Number
- CN202411985765.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2044-12-31
AI Technical Summary
When recycling electricity meters, severely worn barcodes make identification difficult, and damaged digital codes are also hard to identify, affecting recycling efficiency.
A sliding window cropping technique is used to crop the front image of the electricity meter. Combined with a text detection model and template matching, the meter's digital code is identified. The complete digital image is used as a template to match the target image, reducing the difficulty of recognition.
Effective identification of meter digits reduces image recognition area and computational load, simplifies the processing, and improves the identification efficiency of meter recycling.
Smart Images

Figure SMS_1 
Figure SMS_2 
Figure QLYQS_3
Abstract
Description
Technical Field
[0001] This application relates to the field of electricity meter recycling technology, and in particular to an intelligent electricity meter recycling method and system. Background Technology
[0002] The statements in this section are merely background information related to this application and do not necessarily constitute prior art.
[0003] The unique identification code of an electricity meter is usually marked on the front of the meter body by a barcode and the numbers below it. This identification code needs to be stored and recorded when the meter is recycled. However, the identification code on the recycled meter is often severely damaged, especially the barcode, which occupies a large area and is often difficult to identify. Therefore, the digital code below the meter is often used to identify the recycled meter. However, if the digital code is damaged, it will bring difficulties to the staff in the meter recycling work. Summary of the Invention
[0004] Based on this, and in response to the aforementioned technical problems, this application provides a method and system for intelligent recycling of electricity meters.
[0005] The technical solution adopted in this application to solve the problems existing in the prior art is:
[0006] This application proposes a smart recycling method for electricity meters, including the following steps:
[0007] S0: Scan the barcodes on the front of the meters to be recycled sequentially using a scanning device to obtain and store the identification code for each meter; if the barcode cannot be identified, proceed to step S1.
[0008] S1: Obtain a front image of the electricity meter to be recycled through the image acquisition unit;
[0009] S2: Use the first sliding window to crop the front image of the electricity meter sequentially from left to right. Each time a first sub-image is obtained after cropping, it is recognized by the text detection model. Cropping stops when the first sub-image contains the digital image of the electricity meter identification code. The number of cropping times is n.
[0010] Among them: the width of the first sliding window is equal to the width of the image on the front of the electricity meter;
[0011] The length of the first sliding window is δ. When the width of a single digit of the meter identification code is less than or equal to the digit spacing of the meter identification code, δ is less than the width of a single digit of the meter identification code. When the width of a single digit of the meter identification code is greater than or equal to the digit spacing of the meter identification code, δ is less than the digit spacing of the meter identification code.
[0012] S3: Select the remaining front image of the electricity meter after cropping n-1 times in step S1, and use the second sliding window to crop it sequentially from bottom to top. Each time a second sub-image is obtained by cropping, it is recognized by the text detection model. When the digital image containing the electricity meter identification code is recognized in the second sub-image, the cropping stops. The number of cropping times is m.
[0013] Wherein: the length of the second sliding window is equal to the length of the image on the front of the meter;
[0014] The width of the second sliding window = β, where β < the height value of the meter identification code;
[0015] S4: Select the remaining front image of the meter after cropping m-1 times in step S2, and use the third sliding window to crop the lower left corner once to obtain the third sub-image; recognize the text in the third sub-image to obtain the identification code of the meter to be recycled, and store the identification code in the storage unit.
[0016] in:
[0017] The width of the third sliding window = γ, where γ = the height of the meter identification code + β;
[0018] The length of the third sliding window = α, where α = the length of the meter identification code + δ;
[0019] The length of the meter identification code = width of a single digit of the meter identification code × number of digits in the meter identification code + digit spacing of the meter identification code × (number of digits in the meter identification code - 1).
[0020] Preferably,
[0021] The digital image of the meter identification code includes a partial image of a single digit of the meter identification code.
[0022] Preferably,
[0023] Step S4, which involves recognizing the text in the third sub-image, includes the following steps:
[0024] S41: Use the fourth sliding window to crop the third sub-image from left to right to obtain f fourth sub-images; let i represent the sequence number of the i-th cropped fourth sub-image, i≤f, f represents the number of digits of the meter identification code, i∈N+;
[0025] The length of the fourth sliding window = the digit spacing of the meter identification code + the width of a single digit of the meter identification code;
[0026] The width of the fourth sliding window is equal to the width of the third sliding window;
[0027] S42: Use a text detection model to perform text recognition on each fourth sub-image;
[0028] If a number is identified in the i-th fourth sub-image, then [i, DTi] is stored in the storage unit, where i is the sequence number of the fourth sub-image and DTi is the number in the i-th fourth sub-image;
[0029] If the number on the fourth sub-image cannot be recognized, proceed to step S43;
[0030] S43: Select a fourth sub-image where no digit is recognized as the template image. Use each of the pre-saved single-digit images as the target images and perform template matching to obtain the result matrix. If the value of the result matrix is greater than λ, then the digit in the fourth sub-image is the digit in the single-digit image. Store [i, DTi] in the storage unit, where i is the sequence number corresponding to the fourth sub-image.
[0031] Then, select the remaining fourth sub-images that have not been identified and repeat this step. Record the final number as [i, DTi] and store it in the storage unit, where i is the sequence number corresponding to the fourth sub-image.
[0032] Where: λ is the set threshold;
[0033] If all identifications are completed, the numerical code formed by DT1, DT2, ..., DTi, ..., DTf in sequence will be the identification code of the meter to be recycled.
[0034] If there is still a fourth sub-image with unrecognizable numbers, proceed to step S44;
[0035] S44: Clear the data in the storage unit, issue an unrecognizable alarm message, transfer to manual identification, and return to step S0.
[0036] Preferably,
[0037] The text detection model is the PPOCRv4 text detection model.
[0038] Preferably,
[0039] The single-digit image consists of ten images, each with a digit. The font, size, and color of each digit are the same as those on the digital identification code of the meter to be tested.
[0040] The ten images are labeled with the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, and 0.
[0041] Preferably,
[0042] The template matching is implemented using the OpenCV library.
[0043] Preferably,
[0044] The template matching is performed using the matchTemplate function in the OpenCV library. The formula for calculating the relevance of the matching is as follows:
[0045]
[0046] in:
[0047] T(x′,y′) is the pixel value of the fourth sub-image, i.e., the template image, where no digit was recognized. I(x+x′,y+y′) is the pixel value at the corresponding position in the target image. (x,y) is the current position of the template in the target image.
[0048] Preferably,
[0049] The method for determining λ is as follows:
[0050] S431: Use ten single-digit images as template images and the third sub-image as the target image for template matching;
[0051] S432: Obtain the matching result image src through the template matching function cv2.matchTemplate; this image src contains the matching score between the template and each possible position in the target image;
[0052] S433: Use the cv2.minMaxLoc function to find the maximum value maxVal in the matching result image src;
[0053] S434: Calculate λ:
[0054] λ=k u ×maxVal
[0055] Where: k u This is the proportionality coefficient.
[0056] Preferably,
[0057] 0 <k u ≤1.
[0058] A smart meter recycling system, based on the above-mentioned smart meter recycling method, includes:
[0059] Scanning equipment is used to identify the barcodes of the meters to be recycled;
[0060] Image acquisition unit, used to acquire front image of the electricity meter to be recycled;
[0061] The image cropping module is used to crop the front image of the electricity meter acquired by the image acquisition unit;
[0062] A text detection model is used to perform text recognition on images cropped by the image cropping module.
[0063] The storage module is used to sequentially store the identification codes of the meters to be recycled, as well as the data processed by the image processing module.
[0064] Compared with the prior art, the beneficial effects of this application are as follows:
[0065] 1. When the barcode of the meter number cannot be recognized, identification is performed using the digital code. The digital code identification uses the first and second sliding windows to crop the front image of the meter, and then uses the third sliding window to crop to the third sub-image. Only the text recognition needs to be performed on the third sub-image. This method reduces the recognition area of the meter image to be recognized during image recognition, reduces the amount of computation, and the recognition code on the third sub-image occupies a large area of the image, greatly reducing the difficulty of recognition.
[0066] 2. The traditional method of using a sliding window to crop the meter image to obtain the meter identification code image requires cropping the entire front image of the meter. This application eliminates the need to crop the right side and top of the meter identification code, simplifying the processing and reducing the computational workload.
[0067] 3. Reverse template matching is used, with worn or incomplete digits as template images and complete single-digit images as target images to analyze the digits on the meter number to be identified. Template matching only needs to consider external conditions such as lighting and angle. When calculating λ, ten single-digit images are used as template images, and the third sub-image is used as the target image for template matching to better determine maxVal, thus determining a suitable λ. Detailed Implementation
[0068] The present application will be further described below with reference to the embodiments.
[0069] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this disclosure. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms “comprising” and / or “including” are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0070] In this disclosure, terms such as "upper," "lower," "left," "right," "front," "back," "vertical," "horizontal," "side," and "bottom" are used only to indicate the orientation or positional relationship for the convenience of describing the structural relationship of the various components or elements of this disclosure, and do not specifically refer to any component or element in this disclosure, and should not be construed as a limitation of this disclosure.
[0071] When electricity meters are scrapped or no longer used, they need to be returned to the warehouse. Since each electricity meter has a unique identification code, the identification code of the returned electricity meters needs to be scanned and filed.
[0072] The identification code of an electricity meter generally consists of a barcode at the top and a string of numbers at the bottom. The barcode occupies a larger area, while the number code, located below the barcode, occupies a smaller area. For meters awaiting recycling, since these meters are often unusable after a period of use, the barcode at the top will have some wear and tear, making it difficult for staff to scan. Compared to the number code, the number code, due to its smaller area, is less susceptible to external damage and is relatively well-preserved. Therefore, for some meters awaiting recycling with worn barcodes, identifying the number code becomes an important method; however, some number codes will inevitably be worn, and text recognition remains difficult for those with only partial wear.
[0073] This application provides a smart recycling method for electricity meters, which identifies and saves the digital codes of recycled electricity meters, including the following steps:
[0074] S0: Scan the barcodes on the front of the meters to be recycled sequentially using a scanning device to obtain and store the identification code for each meter; if the barcode cannot be identified, proceed to step S1; the scanning device is generally a scanner.
[0075] S1: Obtain a front image of the electricity meter to be recycled through the image acquisition unit; in some embodiments, the image acquisition unit is a camera, and the camera takes a picture of the front image of the electricity meter to be recycled.
[0076] S2: Use the first sliding window to crop the front image of the electricity meter sequentially from left to right. Each time a first sub-image is obtained after cropping, it is recognized by the text detection model. Cropping stops when the first sub-image contains the digital image of the electricity meter identification code. The number of cropping times is n.
[0077] Among them: the width of the first sliding window is equal to the width of the image on the front of the electricity meter;
[0078] The length of the first sliding window is δ. When the width of a single digit of the meter identification code is less than or equal to the digit spacing of the meter identification code, δ is less than the width of a single digit of the meter identification code. When the width of a single digit of the meter identification code is greater than or equal to the digit spacing of the meter identification code, δ is less than the digit spacing of the meter identification code.
[0079] S3: Select the remaining front image of the electricity meter after cropping n-1 times in step S1, and use the second sliding window to crop it sequentially from bottom to top. Each time a second sub-image is obtained by cropping, it is recognized by the text detection model. When the digital image containing the electricity meter identification code is recognized in the second sub-image, the cropping stops. The number of cropping times is m.
[0080] Wherein: the length of the second sliding window is equal to the length of the image on the front of the meter;
[0081] The width of the second sliding window = β, where β < the height value of the meter identification code;
[0082] S4: Select the remaining front image of the meter after cropping m-1 times in step S2, and use the third sliding window to crop the lower left corner once to obtain the third sub-image; recognize the text in the third sub-image to obtain the identification code of the meter to be recycled, and store the identification code in the storage unit.
[0083] in:
[0084] The width of the third sliding window = γ, where γ = the height of the meter identification code + β;
[0085] The length of the third sliding window = α, where α = the length of the meter identification code + δ;
[0086] The length of the meter identification code = width of a single digit of the meter identification code × number of digits in the meter identification code + digit spacing of the meter identification code × (number of digits in the meter identification code - 1).
[0087] The digital image of the meter identification code includes a partial image of a single digit of the meter identification code.
[0088] Using a sliding window to crop an image is a common image processing technique, which will not be elaborated upon in this application.
[0089] Step S4, which involves recognizing the text in the third sub-image, includes the following steps:
[0090] S41: Use the fourth sliding window to crop the third sub-image from left to right to obtain f fourth sub-images; let i represent the sequence number of the i-th cropped fourth sub-image, i≤f, f represents the number of digits of the meter identification code, i∈N+;
[0091] The length of the fourth sliding window = the digit spacing of the meter identification code + the width of a single digit of the meter identification code;
[0092] The width of the fourth sliding window is equal to the width of the third sliding window;
[0093] S42: Use a text detection model to perform text recognition on each fourth sub-image;
[0094] If a number is identified in the i-th fourth sub-image, then [i, DTi] is stored in the storage unit, where i is the sequence number of the fourth sub-image and DTi is the number in the i-th fourth sub-image;
[0095] If the number on the fourth sub-image cannot be recognized, proceed to step S43;
[0096] S43: Select a fourth sub-image where no digit is recognized as the template image. Use each of the pre-saved single-digit images as the target images and perform template matching to obtain the result matrix. If the value of the result matrix is greater than λ, then the digit in the fourth sub-image is the digit in the single-digit image. Store [i, DTi] in the storage unit, where i is the sequence number corresponding to the fourth sub-image.
[0097] Then, select the remaining fourth sub-images that have not been identified and repeat this step. Record the final number as [i, DTi] and store it in the storage unit, where i is the sequence number corresponding to the fourth sub-image.
[0098] Where: λ is the set threshold;
[0099] If all identifications are completed, the numerical code formed by DT1, DT2, ..., DTi, ..., DTf in sequence will be the identification code of the meter to be recycled.
[0100] If there is still a fourth sub-image with unrecognizable numbers, proceed to step S44;
[0101] The method for determining λ is as follows:
[0102] S431: Use ten single-digit images as template images and the third sub-image as the target image for template matching;
[0103] S432: Obtain the matching result image src through the template matching function cv2.matchTemplate; this image src contains the matching score between the template and each possible position in the target image;
[0104] S433: Use the cv2.minMaxLoc function to find the maximum value maxVal in the matching result image src;
[0105] S434: Calculate λ:
[0106] λ=k u ×maxVal
[0107] Where: k u The proportionality coefficient; 0 <k u ≤1. k uThe value can be adjusted appropriately based on the actual situation, such as lighting conditions and photo angle. Generally, the higher the value, the better.
[0108] S44: Clear the data in the storage unit, issue an unrecognizable alarm message, transfer to manual identification, and return to step S0.
[0109] In some embodiments, the text detection model is the PPOCRv4 text detection model. The PPOCRv4 text detection model is the latest version in the PaddleOCR project. It is an upgrade and optimization based on PPOCRv3. Those skilled in the art can deploy and use it according to the actual situation, and it will not be described in detail in this application.
[0110] The single-digit image consists of ten images, each containing a digit. The font, size, and color of each digit are the same as those on the digital identification code of the meter to be tested. The ten images contain the digits 1, 2, 3, 4, 5, 6, 7, 8, 9, and 0 respectively.
[0111] Template matching can be implemented using the OpenCV library. Specifically, template matching uses the `matchTemplate` function in the OpenCV library to perform relevant matching. The formula for calculating relevant matching is as follows:
[0112]
[0113] in:
[0114] T(x′,y′) is the pixel value of the fourth sub-image, i.e., the template image, where no digit was recognized. I(x+x′,y+y′) is the pixel value at the corresponding position in the target image. (x,y) is the current position of the template in the target image.
[0115] This application provides a smart meter recycling system, wherein the smart meter recycling method includes:
[0116] Scanning equipment is used to identify the barcodes of the meters to be recycled;
[0117] Image acquisition unit, used to acquire front image of the electricity meter to be recycled;
[0118] The image cropping module is used to crop the front image of the electricity meter acquired by the image acquisition unit;
[0119] A text detection model is used to perform text recognition on images cropped by the image cropping module.
[0120] The storage module is used to sequentially store the identification codes of the meters to be recycled, as well as the data processed by the image processing module.
[0121] The intelligent meter recycling method provided in this application identifies meters by their digital codes when the barcode of the meter serial number cannot be recognized. The digital code recognition utilizes a first and second sliding window to crop the front image of the meter, and then a third sliding window to crop to a third sub-image. Only the text recognition of this third sub-image is required. This method reduces the recognition area of the meter image during image recognition, decreasing the computational load. The identification code on the third sub-image occupies a large area of the image, significantly reducing the difficulty of recognition. It eliminates the need for cropping the right and top sides of the identification code in the meter image, simplifying the processing and reducing computational complexity.
[0122] The above are merely preferred embodiments of this application and are not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
[0123] While the specific implementation methods of this application have been described above, they are not intended to limit the scope of protection of this application. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of this application are still within the scope of protection of this application.
Claims
1. A method for intelligent recycling of electricity meters, characterized in that, Includes the following steps: S0: Scan the barcodes on the front of the meters to be recycled sequentially using a scanning device to obtain and store the identification codes of each meter. If it cannot be identified, proceed to step S1; S1: Obtain a front image of the electricity meter to be recycled through the image acquisition unit; S2: Use the first sliding window to crop the front image of the electricity meter sequentially from left to right. Each time a first sub-image is obtained after cropping, it is recognized by the text detection model. Cropping stops when the first sub-image contains the digital image of the electricity meter identification code. The number of cropping times is n. Among them: the width of the first sliding window is equal to the width of the image on the front of the electricity meter; The length of the first sliding window is δ. When the width of a single digit of the meter identification code is less than or equal to the digit spacing of the meter identification code, δ is less than the width of a single digit of the meter identification code. When the width of a single digit of the meter identification code is greater than the digit spacing of the meter identification code, δ is less than the digit spacing of the meter identification code. S3: Select the remaining front image of the electricity meter after cropping n-1 times in step S2, and use the second sliding window to crop it sequentially from bottom to top. Each time a second sub-image is obtained by cropping, it is recognized by the text detection model. When the digital image containing the electricity meter identification code is recognized in the second sub-image, the cropping stops. The number of cropping times is m. Wherein: the length of the second sliding window is equal to the length of the image on the front of the meter; The width of the second sliding window is β, where β is less than the height of the meter identification code. S4: Select the remaining front image of the meter after cropping m-1 times in step S3, and use the third sliding window to crop the lower left corner once to obtain the third sub-image; recognize the text in the third sub-image to obtain the identification code of the meter to be recycled, and store the identification code in the storage unit. in: The width of the third sliding window = γ, where γ = the height of the meter identification code + β; The length of the third sliding window = α, where α = the length of the meter identification code + δ; The length of the meter identification code is equal to the width of a single digit of the meter identification code. The number of digits in the meter identification code + the spacing between the digits in the meter identification code (Number of digits in the meter identification code - 1); Step S4, which involves recognizing the text in the third sub-image, includes the following steps: S41: Use the fourth sliding window to crop the third sub-image from left to right to obtain f fourth sub-images; let i represent the sequence number of the i-th cropped fourth sub-image, i≤f, f represents the number of digits of the meter identification code, i∈N+; The length of the fourth sliding window = the spacing between the digits of the meter identification code + the width of a single digit of the meter identification code; The width of the fourth sliding window is equal to the width of the third sliding window; S42: Use a text detection model to perform text recognition on each fourth sub-image; If a number is identified in the i-th fourth sub-image, then [i, DTi] is stored in the storage unit, where i is the sequence number of the fourth sub-image and DTi is the number in the i-th fourth sub-image; If the number on the fourth sub-image cannot be recognized, proceed to step S43; S43: Select a fourth sub-image where no digit is recognized as the template image. Use each of the pre-saved single-digit images as the target images and perform template matching to obtain the result matrix. If the value of the result matrix is greater than λ, then the digit in the fourth sub-image is the digit in the single-digit image. Store [i, DTi] in the storage unit, where i is the sequence number corresponding to the fourth sub-image. Then, select the remaining fourth sub-images that have not been identified and repeat this step. Record the final number as [i, DTi] and store it in the storage unit, where i is the sequence number corresponding to the fourth sub-image. Where: λ is the set threshold; If all identifications are completed, the numerical code formed by DT1, DT2, ..., DTi, ..., DTf in sequence will be the identification code of the meter to be recycled. If there is still a fourth sub-image with unrecognizable numbers, proceed to step S44; S44: Clear the data in the storage unit, issue an unrecognizable alarm message, transfer to manual identification, and return to step S0.
2. The intelligent recycling method for electricity meters according to claim 1, characterized in that: The digital image of the meter identification code includes a partial image of a single digit of the meter identification code.
3. The method for intelligent recycling of electricity meters according to claim 1, characterized in that: The text detection model is the PPOCRv4 text detection model.
4. The method for intelligent recycling of electricity meters according to claim 1, characterized in that: The single-digit image consists of ten images, each containing a digit. The font, size, and color of each digit are the same as those on the digital identification code of the meter to be tested. The ten images are labeled with the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, and 0.
5. The method for intelligent recycling of electricity meters according to claim 1, characterized in that: The template matching is implemented using the OpenCV library.
6. The method for intelligent recycling of electricity meters according to claim 5, characterized in that: The template matching is performed using the matchTemplate function in the OpenCV library. The formula for calculating the relevance of the matching is as follows: in: These are the pixel values of the fourth sub-image, i.e., the template image, where no numbers were recognized. It is the pixel value at the corresponding location in the target image. It is the current position of the template in the target image.
7. The method for intelligent recycling of electricity meters according to claim 6, characterized in that: The method for determining λ is as follows: S431: Use ten single-digit images as template images and the third sub-image as the target image for template matching; S432: Obtain the matching result image src through the template matching function cv2.matchTemplate; this image src contains the matching score between the template and each possible position in the target image; S433: Use the cv2.minMaxLoc function to find the maximum value maxVal in the matching result image src; S434: Calculate λ: in: This is the proportionality coefficient.
8. The method for intelligent recycling of electricity meters according to claim 7, characterized in that: 。 9. A smart meter recycling system, based on the smart meter recycling method according to claim 1, characterized in that, include: Scanning equipment is used to identify the barcodes of the meters to be recycled; Image acquisition unit, used to acquire front image of the electricity meter to be recycled; The image cropping module is used to crop the front image of the electricity meter acquired by the image acquisition unit; A text detection model is used to perform text recognition on images cropped by the image cropping module. The storage module is used to sequentially store the identification codes of the meters to be recycled, as well as the data processed by the image processing module.
Citation Information
Patent Citations
Image main body extraction method and device
CN107123127A
Back propagation (BP) neural network-based degree identification method and system for dismantled ammeter
CN118658165A