A method for automatically extracting water meter character templates
Through the method of automatically extracting water meter character templates, the problems of low production efficiency and large recognition errors in traditional water meter character templates are solved, and high-precision automated production is achieved, saving manpower and material resources and reducing safety risks.
Patent Information
- Application Number
- CN202111079367.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-15
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-09-15
AI Technical Summary
Traditional water meter character templates need to be manually made, resulting in large recognition errors and a large amount of manpower and material resources, and poses safety risks.
Design a method for automatic extraction of water meter character templates. By installing a water meter character extraction device to take pictures in real time, build background images, extract foreground images, select connectivity fields, measure character spacing values, and automatically splice character templates.
The automatic production of water meter character templates has been realized, which improves recognition accuracy, saves manpower and material resources, and reduces safety risks.
Smart Images

Figure CN113780279B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of water meter image recognition, and in particular to a method for automatically extracting water meter character templates. Background Art
[0002] Traditional mechanical water meters require manual on-site reading, which is inefficient and labor-intensive. The water meter reading process affects the normal lives of residents. At the same time, some users’ water meters are set in dangerous areas, which poses a certain threat to the personal safety of meter readers.
[0003] In recent years, camera-based remote water meters have appeared on the market. Camera-based remote water meters use cameras to take pictures of the dial readings and upload the images through a variety of communication methods for background software and manual recognition. In order to automatically identify water meter readings, most camera-based remote water meters first obtain a large number of water meter images, and then train neural networks to obtain neural networks that can recognize water meter readings. However, this method has a high computational cost. In order to achieve better recognition results, neural network training may take several weeks. Different styles of mechanical water meters may require different neural network models. At the same time, the trained neural network models also have recognition errors of varying sizes.
[0004] In order to achieve better recognition accuracy and reduce resource consumption, a water meter character template can be made first, and then the captured image can be uploaded to the background software, and the real-time reading of the water meter can be recognized by the water meter character template. However, in the prior art, water meter character templates are made manually, and the water meter character templates made in this way will have large recognition errors. For each type of water meter, a water meter character template needs to be made, and manual production will consume a lot of manpower and material resources. Summary of the invention
[0005] Aiming at the problems existing in manually making water meter character templates, the present invention provides a method for automatically extracting water meter character templates to realize automatic making of water meter character templates.
[0006] The present invention protects a method for automatically extracting a water meter character template, comprising the following steps:
[0007] Step 1: Install the water meter character extraction device on the water meter of the character template to be extracted;
[0008] The water meter character extraction device can take pictures in real time and upload the taken pictures to the back end.
[0009] Step 2: Select a character at a certain position in the water meter and adjust the selected character to the starting position;
[0010] Furthermore, the starting position is the midline position of the gap area between the numbers 0 and 9, which is located on the vertical midline of the character frame.
[0011] Step 3: The water meter character extraction device takes real-time photos of the rotating water meter character wheel to obtain N frames of images;
[0012] Furthermore, a blower is aimed at the water inlet of the water meter to blow air at a uniform speed to make the water meter character wheel rotate.
[0013] Furthermore, the frame rate of the water meter character extraction device is 25fps.
[0014] Step 4: Build the background image;
[0015] Furthermore, the specific process of step 4 is as follows:
[0016] Step 4.1: uniformly extract n frames of images obtained in step 3 above;
[0017] Step 4.2: Extract pixels at the same position in n frames of image respectively, compare the pixel values of n pixels at the same position, select the smallest 10% of the pixel values, take the average value, and use it as the pixel at this position in the background image;
[0018] Step 4.3: Repeat step 4.2 until all position pixels are traversed to obtain the background image.
[0019] Step 5: Subtract the pixel positions corresponding to the N-frame image from the background image, set the pixel brightness values of the pixels whose difference is greater than the threshold m to 255, and set the brightness values of the pixels whose difference is not greater than m to 0, to obtain the N-frame foreground image, and then obtain the N-frame current image through positioning and cropping;
[0020] Furthermore, the threshold m is set to 20.
[0021] Step 6: Select 10 current images with the best character positions and 10 character spacing values from the N current images through the connected domain;
[0022] The 10 character spacing values are 0 and 1, 1 and 2, and up to the spacing between 9 and 0, for a total of 10 character spacing values.
[0023] Furthermore, the specific process of step 6 is: first, extract the connected domains in the current image of N frames; then, determine the number of connected domains in the current image of N frames according to the order in which the pictures are taken; if there is only one connected domain, select 10 current images of different characters whose center points of the connected domain are closest to the vertical center line of the character wheel frame; if there are two connected domains, select 10 different current images whose vertical center lines of the gap areas between the lower edge of the upper connected domain and the upper edge of the lower connected domain are closest to the vertical center line of the character wheel frame, wherein the 10 different current images are current images containing two different half-wheel characters, and then measure to obtain 10 character spacing values.
[0024] Furthermore, in step 6, the number of pixels in each connected domain is counted for the connected domains obtained, and the connected domains with fewer pixels in the foreground image are removed.
[0025] Step 7: Arrange the 10 character current images from top to bottom in the order of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, and then splice the character current images according to the character spacing value to form a water meter character template.
[0026] The beneficial effects of the present invention are as follows: 1. The present invention can realize the automatic production of water meter character templates, saving a lot of manpower and material resources; 2. The water meter character templates produced by the present invention have the advantage of high recognition accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 A schematic diagram of a flow chart of a method for automatically extracting water meter character templates;
[0028] Figure 2 This is a schematic diagram of the starting position of the water meter in Example 1;
[0029] Figure 3 The image captured in Example 1 is extracted;
[0030] Figure 4 is the current image of the captured image extracted in Example 1;
[0031] Figure 5 This is a schematic diagram of a character template for a certain model of water meter in Example 1. DETAILED DESCRIPTION
[0032] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The embodiments of the present invention are provided for the purpose of illustration and description, and are not intended to be exhaustive or to limit the present invention to the disclosed forms. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiments are selected and described in order to better illustrate the principles and practical applications of the present invention, and to enable those of ordinary skill in the art to understand the present invention and thereby design various embodiments with various modifications suitable for specific uses.
[0033] Example 1
[0034] This embodiment takes the liquid-sealed water meter LXS series as an example to describe the technical solution of the present invention (main process as shown in FIG. Figure 1 ) are described in detail.
[0035] A method for automatically extracting water meter character templates, used for automatically making character templates of LXS series of liquid-sealed water meters, comprises the following steps:
[0036] Step 1: Install the water meter character extraction device on the liquid-sealed water meter;
[0037] Specifically, the frame rate of the water meter character extraction device is 25fps. When the template is produced, the water meter is photographed in real time, and the photographed picture is uploaded to the backend server.
[0038] Step 2: Adjust the last character of the liquid-sealed water meter to the vertical center of the gap between the numbers 0 and 9, and to the vertical center of the character frame. Figure 2 ,The rotation of the characters in the mechanical water meter is linked through gears, and the last character rotates more sensitively. The last character is selected to facilitate the water meter character extraction device to capture enough sample pictures;
[0039] Among them, since the multiple character wheels of each water meter are the same, only one of the character wheels needs to be selected to establish a character template.
[0040] Step 3: Use a blower to blow air at a uniform speed to the water inlet of the water meter, so that the characters on the water meter rotate slowly and uniformly. The blower works until the water meter character wheel completes a 360-degree rotation, and the water meter character extraction device takes a real-time photo of the liquid-sealed water meter.
[0041] Specifically, the wind speed of the blower is set so that the character at the end of the water meter rotates once in about 5 hours, and the water meter character extraction device takes a total of about 450,000 real-time images of the water meter.
[0042] Step 4: Construct the background image of the liquid-sealed water meter;
[0043] Specifically, the specific process of step 4 is:
[0044] Step 4.1: Evenly sample 10,000 images obtained in step 3 above, such as Figure 3 As shown, an image with a width of 60 pixels and a length of 100 pixels is captured.
[0045] Step 4.2: Extract the pixels at the same position in 10,000 frames of images respectively, sort the pixel values of the 10,000 pixels at the same position from large to small, select the smallest 10% of the pixel values, take the average value, and use it as the pixel at this position in the background image. According to the 10% selection, the interference of character pixels and reflections of the captured image can be removed.
[0046] Step 4.3: Repeat step 4.2 until all position pixels are traversed to obtain the background image. By traversing all position pixels, the inconsistency of the background image caused by the reflection when taking the picture can be avoided.
[0047] Step 5: Subtract the pixel positions of about 450,000 frames of images from the background image, set the pixel brightness values of pixels with a difference greater than 20 to 255, and set the brightness values of pixels with a difference less than 20 to 0, and output 450,000 frames of foreground images; then obtain 450,000 current images through positioning and cropping, as shown in the figure. Figure 4 As shown, Figure 3 The current image; by setting the difference to 20, a better current image can be obtained.
[0048] Step 6: Select 10 current images with the best character positions and 10 character spacing values from about 450,000 current images through the connected domain;
[0049] Among them, the 10 character spacing values are 0 and 1, 1 and 2, and up to the spacing between 9 and 0, a total of 10 character spacing values; the connected domain refers to the image area composed of foreground pixels with the same pixel value and adjacent positions in the image.
[0050] Specifically, the specific process of step 6 is: first, extract the connected domains in 450,000 current images; then, according to the order of taking pictures, determine the number of connected domains in the current image; if there is only one connected domain, select 10 current images of different characters whose center points are closest to the horizontal center line of the character wheel frame; if there are two connected domains, select 10 different current images whose vertical center lines of the gap areas between the lower edge of the upper connected domain and the upper edge of the lower connected domain are closest to the vertical center line of the character wheel frame, wherein the 10 different current images are current images containing two different half-wheel characters, and then measure to obtain 10 character spacing values.
[0051] Specifically, in step 6, the number of pixels in each connected domain is counted for the connected domains obtained, and the connected domains with fewer pixels in the foreground image are removed. Since the part with fewer pixels in the connected domain is a small half of the character, it is not helpful for finding the character spacing value and the best current image of the character. Removing this part of the image is conducive to reducing the amount of image processing and reducing interference.
[0052] Step 7: Figure 5 As shown, the 10 character current images are arranged in the order of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and 0, and then spliced according to the character spacing value to obtain the character template of the water meter.
[0053] There is a certain amount of space above the top 0 and below the bottom 0. The heights of these two spaces are equal, and their sum is exactly the gap between 9 and 0.
[0054] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field and related fields without creative work should fall within the scope of protection of the present invention.
Claims
1. A method for automatically extracting water meter character templates, Features: The steps include: Step 1: Install the water meter character extraction device on the water meter of the character template to be extracted; Step 2: Select a character at a certain position in the water meter and adjust the selected character to the starting position; Step 3: The water meter character extraction device takes real-time photos of the rotating water meter character wheel to obtain N frames of images; Step 4: Construct the background image. The specific process is as follows: Step 4.1: uniformly extract n frames of images obtained in step 3 above; Step 4.2: Extract pixels at the same position in n frames of image respectively, compare the pixel values of n pixels at the same position, select the smallest 10% of the pixel values, take the average value, and use it as the pixel at this position in the background image; Step 4.3: Repeat step 4.2 until all position pixels are traversed to obtain the background image; Step 5: Subtract the pixel positions corresponding to the N-frame image from the background image, set the pixel brightness values of the pixels whose difference is greater than the threshold m to 255, and set the brightness values of the pixels whose difference is not greater than m to 0, to obtain the N-frame foreground image, and then obtain the N-frame current image through positioning and cropping; Step 6: Select 10 current images with the best character positions and 10 character spacing values from the N current images through the connected domain; The 10 character spacing values are 0 and 1, 1 and 2, and up to the spacing between 9 and 0, for a total of 10 character spacing values; Step 7: Arrange the 10 character current images from top to bottom in the order of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, and then splice the character current images according to the character spacing value to form a water meter character template.
2. The method for automatically extracting water meter character templates according to claim 1, Features: In step 2, the starting position is the midline position of the gap area between the numbers 0 and 9, which is located at the vertical center of the character frame.
3. The method for automatically extracting water meter character templates according to claim 1, It is characterized in that The specific process of step 6 is as follows: first, extract the connected domains in the current image of N frames; then, determine the number of connected domains in the current image of N frames according to the order in which the pictures are taken; if there is only one connected domain, select 10 current images of different characters whose center points of the connected domain are closest to the vertical center line of the character wheel frame; if there are two connected domains, select 10 different current images whose vertical center lines of the gap areas between the lower edge of the upper connected domain and the upper edge of the lower connected domain are closest to the vertical center line of the character wheel frame, wherein the 10 different current images are current images containing two different half-wheel characters, and then measure to obtain 10 character spacing values.
4. The method for automatically extracting water meter character templates according to claim 3, It is characterized in that In step 6, the number of pixels in each connected domain is counted for the obtained connected domains, and the connected domains with fewer pixels in the foreground image are removed.
5. The method for automatically extracting water meter character templates according to claim 4, It is characterized in that In step 3, a blower is aimed at the water inlet of the water meter and blows air at a uniform speed to rotate the water meter wheel.
6. The method for automatically extracting water meter character templates according to claim 1, It is characterized in that The value of m in step 5 is set to 20.
7. The method for automatically extracting water meter character templates according to any one of claims 1 to 6, It is characterized in that The frame rate of the water meter character extraction device is 25fps.
