Intelligent reading method for a mechanical water meter with rotating wheels
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHANGJIANG SURVEY PLANNING DESIGN & RES CO LTD
- Filing Date
- 2026-04-21
- Publication Date
- 2026-07-14
AI Technical Summary
Existing technology cannot accurately correct the orientation of the readings of rotary mechanical water meters when the water meter image taken by the mobile phone is tilted at a large angle or inverted, resulting in the high and low order of the recognition results being reversed and the recognition accuracy being insufficient.
By detecting the rotating digital area and reference mark in the water meter dial, the direction vector is calculated using their fixed spatial topological relationship, and perspective transformation correction is performed to ensure the correct orientation of the reading area.
Even when the water meter image is tilted or inverted at any angle, the orientation of the reading area is accurately corrected, improving the accuracy and robustness of water meter reading recognition and avoiding the problem of reversed order of high and low readings.
Smart Images

Figure CN122391613A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image recognition technology, specifically to an intelligent recognition method for readings of a rotary mechanical water meter. Background Technology
[0002] In the metering process for urban and rural water supply, mechanical water meters have long dominated the terminal metering equipment market due to their simple structure, low cost, and lack of external power supply. Among them, rotary mechanical water meters are the most widely used. For a long time, water supply companies have faced a rigid demand for large-scale water meter reading collection in their daily operations. A significant number of meter readings still rely on manual labor—meter readers go to each water meter installation location, visually read the value displayed on the rotating wheel of the meter, and then manually record the reading into paper or electronic work orders. This traditional model, highly dependent on manpower, is not only inefficient and slow in coverage, but also carries the risk of errors in both the reading and data entry stages, leading to frequent billing disputes. Therefore, the industry urgently needs a smart identification technology that can automatically obtain water meter readings by taking a photo with a mobile phone.
[0003] Currently, several technologies have been explored for automatic water meter reading recognition. One approach involves adding external hardware to mechanical water meters, integrating photography, communication, and edge computing functions to transform the meters into digital terminals with remote meter reading capabilities. However, these devices are precisely aligned with the meter during installation, and their algorithms rely on perfectly upright images, making them unsuitable for situations where images are tilted, rotated, or even inverted, as is common in mobile phone photography. Another approach combines mobile phone photography with image recognition, without modifying the original meter, resulting in lower implementation costs and becoming a key focus for both academia and industry. At the algorithm level, early research primarily used traditional image processing methods such as region aggregation and template matching for character recognition. However, these methods rely heavily on manual parameter tuning and lack accuracy under complex imaging conditions such as water mist and dirt. In recent years, deep learning-based object detection methods have been introduced into water meter reading recognition scenarios, utilizing convolutional neural networks to detect and recognize meter areas or individual digits, achieving a certain level of accuracy improvement under standard conditions.
[0004] However, existing technologies still face significant shortcomings when mobile phone images of water meters are taken at large angles or even upside down. Specifically, existing image correction algorithms typically rely on detecting local linear features of the rotating wheel's frame and then calculating the rotation correction amount based on the angle between the line and the horizontal direction. This correction strategy based on local geometric features works effectively when the image is tilted at a small angle, but when the tilt angle increases to close to or exceeds 90°, or even when the image is completely upside down, the angle between the rotating wheel's frame and the horizontal line becomes very small. The rotation angle calculated by the algorithm may differ from the actual required correction amount by 180°, resulting in the corrected image orientation being completely opposite to the true orientation. Ultimately, this causes the identified readings to be in reverse order, rendering the identification result completely invalid. The root cause of this deficiency is that existing solutions lack a direction discrimination mechanism that can accurately determine the true orientation of the image at any rotation angle. Summary of the Invention
[0005] In view of this, the present application provides a method for intelligent recognition of readings of rotary mechanical water meters, which can accurately correct the orientation of the reading area when the water meter image is tilted at a large angle or even inverted, ensuring that the high and low order of the recognition result is always correct, thereby improving the accuracy and robustness of intelligent recognition of water meter readings.
[0006] The first aspect of this application provides a method for intelligent identification of readings of a rotary mechanical water meter, characterized in that it includes: Rotational target detection is performed on the water meter image to be identified, and the rotation frame coordinates of the first target and the rotation frame coordinates of the second target are obtained simultaneously; wherein, the first target is the rotating digit area in the water meter dial, and the second target is a reference marker in the water meter dial that has a fixed spatial topological relationship with the rotating digit area; Based on the rotation frame coordinates of the first target and the rotation frame coordinates of the second target, the direction vector of the second target relative to the first target is calculated to obtain the direction angle; The corner points of the rotating frame coordinates of the first target are sorted and corrected according to the direction angle to obtain the target corner point coordinates with a standard point order; wherein, the standard point order is the arrangement order corresponding to the upper left corner, upper right corner, lower right corner, and lower left corner in the upright reading view. Based on the target corner coordinates with the standard point sequence, a perspective transformation is performed on the area where the first target is located in the water meter image to be identified to obtain an upright rotating wheel area image. The water meter reading is obtained by performing text recognition on the image of the upright rotating wheel area.
[0007] The intelligent recognition method for rotary mechanical water meter readings provided in the first aspect of this application simultaneously detects the rotary digit area in the water meter dial image and a reference marker with a fixed spatial topological relationship. It establishes an absolute direction reference using the direction vector between the two targets, corrects the arrangement order of the corner points of the reading area, and performs perspective transformation correction. This ensures that even when the water meter image is tilted at a large angle or even inverted, the image of the rotary area with the correct orientation can be obtained, guaranteeing that the high and low order of the recognition result is accurate and effectively improving the accuracy and robustness of intelligent water meter reading recognition. Attached Figure Description
[0008] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0009] Figure 1 This is a flowchart illustrating an embodiment of the intelligent identification method for readings of a rotary mechanical water meter provided in this application; Figure 2 This is a flowchart illustrating a method for intelligent identification of readings of a rotary mechanical water meter according to another embodiment of this application; Figure 3a This is the original image of the water meter. Figure 3b The image is corrected using an existing algorithm; Figure 3c The image of the upright rotating wheel region obtained after correction using the method of this application; Figure 4 This is a schematic flowchart of a method for recognizing decimal readings based on color analysis, provided in an embodiment of this application. Figure 5 This is a schematic diagram of a water meter image containing red numbers provided in an embodiment of this application; Figure 6 This is the running interface of the smart meter reading APP provided in one embodiment of this application on a mobile device. Detailed Implementation
[0010] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0011] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0012] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0013] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0014] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0015] The intelligent reading recognition method for rotary mechanical water meters provided in this invention can be applied to mobile terminal devices with camera functions, such as mobile phones and tablets, or deployed on a server as a remote recognition service. It is particularly suitable for automatically reading and recognizing images of rotary mechanical water meter dials taken by mobile phones in urban and rural water supply meter reading operations. This method can be integrated into mobile meter reading applications to achieve photo-based recognition, thereby replacing the traditional methods of manual reading and data entry. This invention does not impose any restrictions on the specific type of terminal device or deployment method.
[0016] like Figure 1 As shown, Figure 1The overall processing flow of an embodiment of the present invention is illustrated exemplarily. The flow begins with the data preparation stage at the top, sequentially proceeding through dataset labeling, format conversion, model building and training to complete the offline preparation of the rotating target detection model. After model preparation is complete, the flow enters the online inference stage: the water meter image to be detected is input into the water meter image multi-target detection module to obtain the rotation box coordinates of the two targets, the rotating wheel digital border and the unit of measurement symbol; subsequently, it enters the dial dual-target spatial topology orientation auxiliary correction module, which includes three sub-steps: calculating the right azimuth angle, correcting the coordinate sequence of the four points in the rotating wheel reading area, and perspective transformation correction, outputting an upright rotating wheel area image; then, it enters the color semantic parsing segmentation module, which includes three sub-steps: color space conversion, defining a red mask to detect the red column, and segmenting the integer and decimal places based on color; finally, it enters the rotating wheel character recognition module, which recognizes the integer and decimal places respectively and outputs the water meter reading.
[0017] like Figure 2 As shown, the intelligent identification method for readings of a rotary mechanical water meter provided in this embodiment of the invention includes the following steps S101 to S105: Step S101: Perform rotation target detection on the water meter image to be identified, and simultaneously obtain the rotation frame coordinates of the first target and the rotation frame coordinates of the second target; wherein, the first target is the rotating digit area in the water meter dial, and the second target is a reference marker in the water meter dial that has a fixed spatial topological relationship with the rotating digit area.
[0018] In this application, the water meter image to be identified is obtained by meter readers using a mobile terminal's camera to capture images of the water meter dial at the meter reading site. Rotational target detection is a target detection technology that outputs a detection box (i.e., a rotational frame) with rotation angle information. Unlike conventional target detection, which only outputs a horizontal rectangular box, rotational target detection can more accurately fit the contours of tilted or rotated targets. The primary target is the reading display area on the water meter dial, composed of multiple digital dials arranged side-by-side. Its rotational frame coordinates are based on four-point coordinates. The second objective is a reference marker on the water meter dial, whose rotation frame coordinates are expressed in four-point coordinates. The form is represented as follows. Among them, the fixed spatial topology means that no matter how the water meter image is rotated or inverted, the relative positional relationship between the first target and the second target remains unchanged in physical space.
[0019] In the application, after completing the rotating target detection in step S101, the validity of the detection results needs to be determined. When both the first and second targets are successfully detected, the process proceeds normally to the subsequent step S102. Otherwise, the current image is determined not to meet the recognition conditions, and a detection failure message is returned, prompting the meter reader to retake the image. When the detection confidence of a target is lower than the preset confidence threshold, the alternative orientation strategy or retry mechanism is also triggered.
[0020] Step S102: Based on the rotation frame coordinates of the first target and the rotation frame coordinates of the second target, calculate the direction vector of the second target relative to the first target to obtain the direction angle.
[0021] In application, the direction vector is from the geometric center of the first target. Geometric center pointing to the second target A two-dimensional vector. Where, the direction angle... This is the angle representation of the direction vector in the image coordinate system, with a value range of (-180°, 180°], calculated using the atan2 function. Since the physical positions of the first and second targets on the water meter dial are fixed, under normal reading angles, the second target (m...) 3 The unit symbol is always located to the right of the first target (rotating digit area). Therefore, this orientation angle can uniquely determine the correct orientation of the water meter image, and this topological relationship will not change even if the image is rotated or inverted at any angle.
[0022] In the application, the orientation angle is calculated in step S102. Next, it is necessary to... The validity of the data is verified. The verification method is as follows: using... The corner point sorting operation in step S103 is performed on the four-point coordinates of the rotated frame of the first target to obtain temporarily sorted four-point coordinates. Then, it is checked whether the four points form a convex quadrilateral. Specifically, the four corner points are connected in the sorted order, and the cross product of adjacent edge vectors is calculated. If all cross products have the same sign (all positive or all negative), then the four points form a convex quadrilateral. Valid; if the cross product signs are inconsistent, it indicates that the four points are arranged in a cross pattern (i.e., forming a bow shape rather than a convex quadrilateral), indicating... The calculation results are inaccurate. When the convexity check fails, the direction angle is determined to be... If invalid, the process returns to the step of rotating target detection on the water meter image to be identified, while simultaneously obtaining the rotation box coordinates of the first target and the second target. This verification mechanism can detect and correct potential orientation angle deviations before perspective transformation is performed, avoiding severely distorted output images.
[0023] Step S103: Sort and correct the corner points of the rotation frame coordinates of the first target according to the direction angle to obtain the target corner point coordinates with a standard point order; wherein, the standard point order is the arrangement order corresponding to the upper left corner, upper right corner, lower right corner and lower left corner in turn under the upright reading view.
[0024] In applications, the coordinates of the four points of the rotating bounding box output by the rotating target detection model do not necessarily follow a specific corner point arrangement order. However, subsequent perspective transformation correction requires the input corner points to be arranged in a fixed order of top left, top right, bottom right, and bottom left; otherwise, the perspective transformation will produce an incorrect output image. The sorting correction refers to using the direction angle obtained in step S102 as an absolute reference, calculating the angular deviation of each corner point relative to the direction angle to determine the orientation of each corner point in physical space. This rearranges the four-point coordinates of the detection model in any order into a standard point order consistent with the real physical space. The core value of this mechanism lies in the fact that traditional correction methods based on Hough line detection have a 180° ambiguity when determining image orientation. For example, in a large-angle tilt or even inverted state, the angle between the wheel frame and the horizontal line is very small. This algorithm will cause the calculated rotation angle to differ from the actual situation by 180°. This invention, by introducing a second target as an absolute direction reference, fundamentally eliminates this ambiguity.
[0025] Step S104: Based on the target corner coordinates with the standard point sequence, perform perspective transformation on the area where the first target is located in the water meter image to be identified to obtain an upright rotating wheel area image.
[0026] In applications, perspective transformation is a geometric transformation method that maps any quadrilateral region in an image to a standard rectangle. This involves obtaining the target corner coordinates using a standard point order. Then, using these four corner points as source points and the corresponding four corners of the upright rectangle as target points, the perspective transformation matrix M is calculated, and based on this, the tilted or deformed first target area in the original image is remapped into an upright rectangular image img_bbox. This upright rotating wheel area image is the rotating wheel number area observed from the frontal viewpoint, where the numbers from left to right correspond to the readings from the highest to the lowest digit.
[0027] Figure 3 illustrates an exemplary comparison of the effects of a set of water meter images under a large-angle tilt after being corrected by the present invention. Figure 3a The image is the original water meter image (which is tilted at a large angle). Figure 3b For the image corrected by the existing algorithm, Figure 3cThis is an image of the upright rotating wheel region obtained after undergoing the dual-target spatial topology orientation correction proposed in this application. It can be seen that regardless of the tilt angle of the original image, the corrected rotating wheel region image maintains the correct high and low digit arrangement, with the numbers from left to right corresponding to the readings from high to low digits, verifying the correction effect of this invention.
[0028] Step S105: Perform text recognition on the image of the upright rotating wheel area to obtain the water meter reading.
[0029] In the application, after obtaining the upright image (img_bbox) of the rotating wheel area, optical character recognition technology (such as PaddleOCR) is used to recognize the digits in the image. Since the input image has been corrected to an upright viewpoint through perspective transformation, the orientation of the digits is correct and their arrangement is clear, thus the optical character recognition engine achieves high recognition accuracy. The recognized water meter readings can be automatically entered into the meter reading system, replacing the manual data entry process.
[0030] The intelligent recognition method for rotary mechanical water meter readings provided in this invention simultaneously detects two targets, the rotary digit area and the reference mark, and establishes an absolute direction reference using their spatial topological relationship. This ensures that even when the water meter image is tilted at any angle or even completely inverted, the correct orientation of the reading area can be accurately restored. This fundamentally avoids the problem of reversed high and low order of readings caused by ambiguity in direction judgment in traditional correction algorithms, and significantly improves the accuracy and robustness of intelligent recognition.
[0031] In one embodiment, the reference identifier is a unit of measurement symbol on the water meter dial, and the fixed spatial topology is such that, from an upright reading perspective, the reference identifier is located to the right of the rotating digit area.
[0032] In one embodiment, calculating the direction vector of the second target relative to the first target based on the rotation frame coordinates of the first target and the rotation frame coordinates of the second target, to obtain the direction angle, includes: Calculate the center point of the rotation frame coordinates of the first target respectively. The center point of the rotation frame coordinates of the second target Wherein, the rotation frame coordinates of the first target are four-point coordinates. The center point The calculation formula is: The rotation frame coordinates of the second target are four-point coordinates. The center point The calculation formula is: Based on the center point With the center point Positional relationships, calculated by point to Direction angle of the direction vector The calculation formula is: in,( x b , y b () is the center point coordinates, ( x u , y u () is the center point The coordinates.
[0033] In applications, the dial of a rotary mechanical water meter is usually printed with the unit of measurement symbol "m". 3 The symbol's position on the physical dial remains fixed, always located to the right of the rotating digit area. This "right" refers to a region slightly above and below the right, not limited to the exact right side. This physical constraint constitutes the fixed spatial topology between the two detection targets in this embodiment. In practice, firstly, the arithmetic mean of the four coordinates of the two rotating frames is taken to obtain their respective geometric center points. and Then, calculate from point to The direction vector is used to obtain the direction angle of the vector through the atan2 function. The atan2 function is a four-quadrant arctangent function that returns the angle value of the direction vector in the image coordinate system, with a range of (-180°, 180°). Physically, the direction angle represents the actual angle of the "right direction" in the current image coordinate system. If the water meter image is upright, θ is close to 0°; if the image is rotated 90°, θ is approximately 90°; if the image is completely inverted, θ is approximately ±180°.
[0034] In one embodiment, step S103, which involves sorting and correcting the corner points of the rotation frame coordinates of the first target according to the direction angle to obtain target corner point coordinates with a standard point order, includes: Calculate the coordinates of the four points of the rotating frame of the first target. Each corner point relative to the center point polar angle The calculation formula is: in,( x i ,y i () represents the coordinates of the i-th corner point; Calculate the relative angle between the polar angle and the direction angle at each corner point. The calculation formula is: The relative angle Normalization to the range of [-180°, 180°] uses the following normalization formula: The normalized relative angles Sort the coordinates of the four points of the first target's frame in ascending order, and rearrange them according to the sorted indices to obtain the target corner coordinates with a standard point order. .
[0035] In application, the core idea of this corner sorting algorithm is to use the azimuth angle as a compass, measure the orientation of each corner point relative to the compass, and then sort them according to the azimuth angle from smallest to largest. Specifically: the polar angle is the angle of the i-th corner point relative to the center of the rotating frame. The angular position in the image coordinate system is calculated using the atan2 function. Relative angle. This is the difference between the polar angle and the direction angle, representing the angular deviation of the corner point relative to the right-hand direction. Since the angle difference may exceed the valid range, it is normalized to the interval (-180°, 180°) using a modulo operation. The normalization formula is: For the normalized After sorting from smallest to largest and performing index remapping, the four corner points are rearranged into a standard "top left → top right → bottom right → bottom left" order. This algorithm does not rely on any local linear features and is based entirely on the spatial topology of the two targets. Therefore, no matter how the original image is tilted or inverted, after point sorting and spatial transformation correction, a rotating region image in an upright state is always obtained.
[0036] In one embodiment, step S104, which involves performing a perspective transformation on the region containing the first target in the water meter image to be identified based on the target corner coordinates with the standard point order, to obtain an upright rotating wheel region image, includes: Based on the target corner coordinates The vector lengths between adjacent corner points are used to determine the width w and height h of the perspective transformation target rectangle; wherein the width w is the larger of the upper vector length and the lower vector length, and the height h is the larger of the left vector length and the right vector length. Construct a perspective transformation target rectangle ; Construct from the coordinates of the target corner point To the perspective transformation target rectangle The perspective transformation matrix M is used to perform perspective transformation on the water meter image to be identified, and an upright rotating wheel area image with size (w, h) is output.
[0037] In the application, the width w is calculated separately from the top edge ( arrive ) and below ( arrive The vector length of ) is obtained by taking the larger of the two; the height h is obtained by calculating the length of the vector on the left ( arrive ) and the right side ( arrive The length of the vector is obtained by taking the larger of the two values. Construct a standard rectangle with (0, 0) as the top-left corner, width w, and height h. Its four corner points and The four corner points correspond one-to-one. (From the source quadrilateral) With the target rectangle The four sets of corresponding corner point pairs are solved by solving a system of linear equations to obtain a 3×3 perspective transformation matrix M. After applying the perspective transformation to the first target area of the original water meter image with matrix M, an upright rotating wheel area image img_bbox with size (w,h) can be obtained.
[0038] In one embodiment, step S101, which involves rotating the target detection of the water meter image to be identified, includes: The water meter image to be identified is input into a pre-trained rotating target detection model for inference. The rotating target detection model embeds a deformable convolutional module between the feature extraction layer and the feature fusion layer of the backbone network. This deformable convolutional module introduces learnable sampling point offsets and modulation scalars on top of standard convolution, enabling the convolutional kernel to dynamically adjust the sampling grid according to the input features. The convolution operation formula of the deformable convolutional module is as follows: in, Indicates the output feature map at position The feature value at point R represents the sampling grid set of the standard convolution kernel. This represents the nth sampling offset position of the standard convolution kernel. Indicates the convolution kernel at the offset position The weight at each position, x(·), represents the feature value at the corresponding position on the input feature map. Indicates that the network targets sampling points The learned offset; The rotating target detection model simultaneously outputs the coordinates of the four points of the rotating frame of the first target and the coordinates of the four points of the rotating frame of the second target.
[0039] In applications, standard convolution operations sample on a regular square grid. When the water meter dial image is tilted or distorted due to the shooting angle of the mobile phone, the matching accuracy between the square sampling grid and the distorted digital contour decreases. The DeformableConv2d module is a custom module based on the idea of Deformable ConvNets v2, which learns an additional two-dimensional offset for each sampling point in the standard sampling grid. This causes the actual sampling location to change from a fixed position. + Become variable + + This allows the receptive field of the convolutional kernel to dynamically fit the tilted or deformed target contour. This module is inserted after the C2f module of the backbone and before the feature pyramid network, with an output channel configuration of 512 and a convolutional kernel size of 3. Based on this model structure, the Deformable-YOLO rotating target detection model can simultaneously output the four-point coordinates of the rotating bounding boxes for both rotating digit regions (bounding boxes) and reference units.
[0040] In one embodiment, the pre-trained rotating target detection model is trained through the following steps: Step S201: Use the rotating target annotation tool to rotate and annotate the rotating digit area and the reference mark in the water meter dial image, and output the annotation data; wherein, the annotation data includes water meter dial images under various tilt angles and lighting conditions, and the number of target categories is set to 2, corresponding to the rotating digit area and the reference mark respectively.
[0041] In the application, the labeled data comes from images of water meter dials taken with mobile phones in actual meter reading scenarios, covering various shooting angles such as upright, tilted, and inverted, as well as various lighting conditions such as sunlight, shadow, and nighttime. The specific rotating target labeling tool is roLabelImg. Operators use this tool to label a rotated rectangle around the rotating digit area in each image, marking it as a boundingbox, and simultaneously labeling the unit of measurement symbol "m". 3 "Annotate another rotated rectangle, label it as a unit, and output the annotation result in PascalVOC format."
[0042] Step S202: Convert the format of the annotation data into a rotated box annotation format; wherein the rotated box annotation format is a four-point coordinate format.
[0043] In application, since YOLOv8 does not support PascalVOC format annotations, it is necessary to convert the annotation information described by the rotation rectangle parameter in PascalVOC format into YOLO OBB format which is directly described by four-point coordinates.
[0044] Step S203: Embed a deformable convolutional module between the feature extraction layer and the feature fusion layer of the backbone network of the target detection network to construct the rotating target detection model.
[0045] In this application, this embodiment uses YOLOv8-OBB (rotated box detection version) as the base network, defines a custom deformable convolutional module DeformableConv2d, registers the DeformableConv2d module class in the model file and modifies the model definition file to insert the module after the Backbone C2f module and before the feature pyramid network.
[0046] Step S204: Based on the pre-trained rotating target detection weights, fine-tune the rotating target detection model using the annotation data in the rotating bounding box annotation format to obtain the pre-trained rotating target detection model.
[0047] In the application, a data configuration file was prepared according to YOLOv8 requirements. The number of target categories in the configuration file was set to two: bounding boxes and units. Rotated bounding box mode was enabled, and the annotation format for the rotated bounding boxes was specified as four-point coordinates. The pre-trained weights yolov8n-obb.pt were loaded as model initialization parameters, and the model was fine-tuned using the YOLO OBB format annotation data obtained in step S202. During training, the model simultaneously learned to detect both bounding boxes and units. After training, the water meter image target detection model Deformable-YOLO-Best.pt was obtained.
[0048] In one embodiment, such as Figure 4 As shown, before performing text recognition on the image of the upright rotating wheel area in step S105 to obtain the water meter reading, the following steps S201~S206 are also included: Step S201: Convert the image of the upright rotating wheel area from the RGB color space to the HSV color space; Step S202: Generate a color mask according to the preset color threshold conditions; Step S203: Perform column-by-column statistics on the color mask and calculate the percentage of pixels in each column that meet the color threshold condition; Step S204: Determine the target color column set based on the pixel ratio; Step S205: When the target color column set is empty, it is determined that there is no decimal place wheel region, and the entire upright wheel region image is taken as the integer place region image; Step S206: When the target color column set is not empty, it is determined that there is a decimal wheel region. The segmentation boundary is determined according to the minimum and maximum values of the column index in the target color column set, and the upright wheel region image is segmented into an integer region image and a decimal region image.
[0049] In applications, the last digit (i.e., the digit with the lowest precision) on the dial of a rotary mechanical water meter is usually marked with red characters to distinguish it from the black characters on the integer digit ...
[0050] First, the image `img_bbox` of the upright water meter wheel region is converted from the RGB color space to the HSV color space. The RGB color space represents colors using a mixture of red, green, and blue channels, making color determination in this space susceptible to interference from changes in light intensity. The HSV color space represents colors using separate channels for hue, saturation, and value. Its hue channel is independent of light intensity, making it more suitable for specific color detection. Then, a color mask is generated based on a preset red hue range and saturation and value thresholds. Next, horizontal projection is used to detect red columns, counting the number of red pixels in each column. The percentage of red pixels in a column is normalized, and columns with a percentage exceeding a preset threshold are identified as red columns, resulting in a red column set `C`. Finally, the decimal wheel region is divided based on the red column set `C`: if `C` is empty, the water meter wheel has no decimal places, and the entire `img_bbox` is treated as the integer wheel region image `img_integer`; if `C` is not empty, the minimum column index in `C` is taken as the integer wheel region image. x min The maximum value is used as x max Move the img_bbox horizontally along the [0, x min The image is divided into integer-digit rotating regions within the range of [img_integer]. x min ,x max The image is segmented into a decimal place rotating region named `img_decimal` within the specified range. After segmentation, PaddleOCR is used to perform text recognition on `img_integer` and `img_decimal` respectively, obtaining the integer-place text string `txt_integer` and the decimal-place text string `txt_decimal` (if `img_decimal` does not exist, `txt_decimal` is assigned the string "00"). Finally, `txt_integer` and `txt_decimal` are converted into the numbers `num_integer` and `num_decimal`, concatenated to form a complete numerical value, retaining two decimal places, and the final water meter reading `num_water` is output.
[0051] like Figure 5 As shown, an exemplary schematic diagram of a water meter image containing red digits is presented. Through the color semantic parsing mechanism proposed in the above embodiments, the column range containing the red characters can be accurately located, and the rotating wheel area image can be correctly segmented into integer and decimal regions. This allows subsequent hierarchical OCR recognition to output water meter readings of an order of magnitude accuracy, avoiding serious errors caused by decimal places being misidentified as integer places.
[0052] In one embodiment, the color mask The definition of is: When the hue value of pixel (x, y) Within the preset target color range, saturation value Greater than or equal to the preset saturation threshold And brightness value Greater than or equal to the preset brightness threshold hour, = 1; otherwise, = 0; Wherein, the preset target hue range is the red hue range, and the preset saturation threshold is... and the preset brightness threshold The settings are based on the imaging conditions of the water meter dial; The step of performing column-by-column statistical analysis on the color mask and calculating the percentage of pixels in each column that meet the color threshold condition includes: Count the number of pixels with a mask value of 1 in each column x. The calculation formula is: Where H is the height of the upright rotating wheel region image; Calculate the percentage of target color pixels in each column x. The calculation formula is: Will Columns with a percentage greater than or equal to a preset column proportion threshold are identified as target color columns and are aggregated into the target color column set C.
[0053] In applications, red spans near 0° on the color wheel in the hue channel of the HSV color space, therefore two sub-ranges need to be set to cover the red region: H values in the range of [0, 10] or [160, 180] (in OpenCV's HSV implementation, the H channel ranges from 0 to 180). Saturation threshold and brightness threshold Used to filter background and dark pixels, with a value of 50. This is obtained by accumulating the mask value along the vertical direction for each column. yes Divide by the normalized value of the image height H. When If the percentage of a column is greater than or equal to a preset column percentage threshold, that column is designated as the target color column, and the indexes of all target color columns constitute the target color column set. Preset column percentage threshold.
[0054] In other embodiments, when there is no decimal place color mark in the upright rotating wheel area image or there is no need to distinguish between integer and decimal places, step S105 can also be implemented by direct recognition, without performing the above-mentioned color semantic parsing and segmentation process.
[0055] In one embodiment, step S105, which involves performing text recognition on the image of the upright rotating wheel area to obtain the water meter reading, includes: The image of the upright rotating wheel area is used to perform text recognition using an optical character recognition engine to obtain a text string; The text string is converted into a numerical value to obtain the water meter reading.
[0056] In applications, when there are no decimal place marks or no need to distinguish decimal places in the upright rotating wheel area image, the entire rotating wheel area image can be directly used to call an optical character recognition engine (such as PaddleOCR) for recognition.
[0057] In one embodiment, the deformable convolutional module is configured with 512 output channels and a kernel size of 3; the fine-tuning training is performed in 100 to 150 epochs.
[0058] In this application, the number of output channels is set to 512 to balance the feature complexity of the target in the water meter dial image with the computational efficiency of the model. More output channels provide richer feature representation capabilities, and 512 is an empirically optimal value achieved between feature representation sufficiency and inference speed. A 3×3 kernel size is a widely adopted receptive field size in deep learning; with the adjustment of deformable offsets, the actual receptive field can be much larger than the fixed range of 3×3. The fine-tuning training epochs are set to 100 to 150 epochs based on the size of the water meter dial dataset and the model's convergence speed. Less than 100 epochs may not allow the model to converge sufficiently, while more than 150 epochs may lead to overfitting.
[0059] In some application scenarios, users can upload water meter images through the APP software interface. The system automatically completes processing steps such as rotating target detection, dual-target spatial topology orientation correction, color semantic parsing and segmentation, and hierarchical OCR recognition, and displays the recognized water meter reading on the interface.
[0060] like Figure 6 As shown, the illustrative interface of the smart meter reading APP provided in this embodiment of the invention is illustrated on a mobile device. After the meter reader uses the APP to take a picture of the water meter dial with the phone's camera, the APP automatically calls the background intelligent recognition service to process the captured image and automatically fills the recognized water meter reading into the meter reading interface, replacing the traditional manual reading and data entry process, thus improving the efficiency and accuracy of meter reading operations.
[0061] In one embodiment, after segmenting the integer and decimal regions of the image, text recognition is performed on each region to obtain integer and decimal text strings, respectively. These strings are then converted to numerical values and concatenated to obtain the complete water meter reading. In the application, PaddleOCR is used to perform text recognition on the integer region image (img_integer) and the decimal region image (img_decimal), respectively, yielding the integer text string (txt_integer) and the decimal text string (txt_decimal). These strings are then converted to their corresponding numerical values and concatenated to form the complete water meter reading.
[0062] In one embodiment, when the decimal region image does not exist, the decimal text string is assigned a preset default value; the integer text string and the decimal text string are converted to numerical values and concatenated, retaining a preset number of decimal places. In the application, when the decimal region image img_decimal does not exist, the decimal text string txt_decimal is assigned the value "00". After converting txt_integer and txt_decimal to the numbers num_integer and num_decimal respectively, they are concatenated to form a complete numerical value, retaining two decimal places, and the final water meter reading num_water is output.
[0063] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0064] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention.
[0065] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for intelligent identification of readings of a rotary mechanical water meter, characterized in that, include: Rotational target detection is performed on the water meter image to be identified, and the rotation frame coordinates of the first target and the rotation frame coordinates of the second target are obtained simultaneously; wherein, the first target is the rotating digit area in the water meter dial, and the second target is a reference marker in the water meter dial that has a fixed spatial topological relationship with the rotating digit area; Based on the rotation frame coordinates of the first target and the rotation frame coordinates of the second target, the direction vector of the second target relative to the first target is calculated to obtain the direction angle; The corner points of the rotating frame coordinates of the first target are sorted and corrected according to the direction angle to obtain the target corner point coordinates with a standard point order; wherein, the standard point order is the arrangement order corresponding to the upper left corner, upper right corner, lower right corner, and lower left corner in the upright reading view. Based on the target corner coordinates with the standard point sequence, a perspective transformation is performed on the area where the first target is located in the water meter image to be identified to obtain an upright rotating wheel area image. The water meter reading is obtained by performing text recognition on the image of the upright rotating wheel area.
2. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 1, characterized in that, The reference identifier is the unit of measurement symbol on the water meter dial, and the fixed spatial topology is as follows: in an upright reading view, the reference identifier is located to the right of the rotating digit area.
3. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 2, characterized in that, The step of calculating the direction vector of the second target relative to the first target based on the rotation frame coordinates of the first target and the rotation frame coordinates of the second target, to obtain the direction angle, includes: Calculate the center point of the rotation frame coordinates of the first target respectively. The center point of the rotation frame coordinates of the second target Wherein, the rotation frame coordinates of the first target are four-point coordinates. The center point The calculation formula is: The rotation frame coordinates of the second target are four-point coordinates. The center point The calculation formula is: Based on the center point With the center point Positional relationships, calculated by point to Direction angle of the direction vector The calculation formula is: in,( x b , y b () is the center point coordinates, ( x u , y u () is the center point The coordinates.
4. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 3, characterized in that, The step of sorting and correcting the corner points of the rotation frame coordinates of the first target according to the direction angle to obtain target corner point coordinates with a standard point order includes: Calculate the coordinates of the four points of the rotating frame of the first target. Each corner point relative to the center point polar angle The calculation formula is: in,( x i , y i () represents the coordinates of the i-th corner point; Calculate the relative angle between the polar angle and the direction angle at each corner point. The calculation formula is: The relative angle Normalization to the range of [-180°, 180°] uses the following normalization formula: The normalized relative angles Sort the coordinates of the four points of the first target's frame in ascending order, and rearrange them according to the sorted indices to obtain the target corner coordinates with a standard point order. .
5. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 4, characterized in that, The step of performing perspective transformation on the region where the first target is located in the water meter image to be identified, based on the target corner coordinates with the standard point sequence, to obtain an upright rotating wheel region image, includes: Based on the target corner coordinates The vector lengths between adjacent corner points are used to determine the width w and height h of the perspective transformation target rectangle; wherein the width w is the larger of the upper vector length and the lower vector length, and the height h is the larger of the left vector length and the right vector length. Construct a perspective transformation target rectangle ; Construct from the coordinates of the target corner point To the perspective transformation target rectangle The perspective transformation matrix M is used to perform perspective transformation on the water meter image to be identified, and an upright rotating wheel area image with size (w, h) is output.
6. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 3, characterized in that, The calculation is by point to Direction angle of the direction vector Following that, it also includes: Using the aforementioned direction angle The corner points of the rotating frame coordinates of the first target are sorted to obtain the coordinates of the four points after temporary sorting. Check whether the coordinates of the four points after the temporary sorting form a convex quadrilateral; When the coordinates of the four points form a convex quadrilateral, the direction angle is determined. efficient; When the coordinates of the four points do not form a convex quadrilateral, the direction angle is determined. If invalid, return to the step of rotating target detection on the water meter image to be identified, and simultaneously obtain the rotation box coordinates of the first target and the rotation box coordinates of the second target.
7. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 1, characterized in that, The rotating target detection of the water meter image to be identified includes: The water meter image to be identified is input into a pre-trained rotating target detection model for inference. The rotating target detection model embeds a deformable convolutional module between the feature extraction layer and the feature fusion layer of the backbone network. This deformable convolutional module introduces learnable sampling point offsets and modulation scalars on top of standard convolution, enabling the convolutional kernel to dynamically adjust the sampling grid according to the input features. The convolution operation formula of the deformable convolutional module is as follows: in, Indicates the output feature map at position The feature value at point R represents the sampling grid set of the standard convolution kernel. This represents the nth sampling offset position of the standard convolution kernel. Indicates the convolution kernel at the offset position The weight at each position, x(·), represents the feature value at the corresponding position on the input feature map. Indicates that the network targets sampling points The learned offset; The rotating target detection model simultaneously outputs the coordinates of the four points of the rotating frame of the first target and the coordinates of the four points of the rotating frame of the second target.
8. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 7, characterized in that, The pre-trained rotating target detection model is obtained through the following steps: The rotating target annotation tool is used to rotate and annotate the rotating digit area and the reference mark in the water meter dial image, and the annotation data is output. The annotation data includes water meter dial images under various tilt angles and lighting conditions, and the number of target categories is set to 2, corresponding to the rotating digit area and the reference mark respectively. The format of the labeled data is converted into a rotated box label format; wherein the rotated box label format is a four-point coordinate format; A deformable convolutional module is embedded between the feature extraction layer and the feature fusion layer of the backbone network of the target detection network to construct the rotating target detection model. Based on the pre-trained rotating target detection weights, the rotating target detection model is fine-tuned using the labeled data in the rotating bounding box annotation format to obtain the pre-trained rotating target detection model.
9. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 8, characterized in that, The deformable convolution module has 512 output channels and a kernel size of 3; the fine-tuning training takes 100 to 150 epochs.
10. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 1, characterized in that, Before performing text recognition on the image of the upright rotating wheel area to obtain the water meter reading, the method further includes: Convert the image of the upright rotating wheel area from the RGB color space to the HSV color space; Generate a color mask based on preset color threshold conditions; The color mask is statistically analyzed column by column, and the percentage of pixels in each column that meet the color threshold condition is calculated. The target color column set is determined based on the pixel ratio; When the target color column set is empty, it is determined that there is no decimal place wheel region, and the entire upright wheel region image is taken as the integer place region image; When the target color column set is not empty, it is determined that there is a decimal wheel region. The segmentation boundary is determined according to the minimum and maximum values of the column indices in the target color column set, and the upright wheel region image is segmented into an integer region image and a decimal region image.
11. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 10, characterized in that, The color mask The definition of is: When the hue value of pixel (x, y) Within the preset target color range, saturation value Greater than or equal to the preset saturation threshold And brightness value Greater than or equal to the preset brightness threshold hour, = 1; otherwise, = 0; Wherein, the preset target hue range is the red hue range, and the preset saturation threshold is... and the preset brightness threshold The settings are based on the imaging conditions of the water meter dial; The step of performing column-by-column statistical analysis on the color mask and calculating the percentage of pixels in each column that meet the color threshold condition includes: Count the number of pixels with a mask value of 1 in each column x. The calculation formula is: Where H is the height of the upright rotating wheel region image; Calculate the percentage of target color pixels in each column x. The calculation formula is: Will Columns with a percentage greater than or equal to a preset column proportion threshold are identified as target color columns and are aggregated into the target color column set C.
12. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 10, characterized in that, The step of performing text recognition on the image of the upright rotating wheel area to obtain the water meter reading includes: Perform text recognition on the integer part region image and the fractional part region image respectively to obtain integer part text strings and fractional part text strings respectively; The integer and decimal literal strings are converted into numerical values and concatenated to obtain the complete water meter reading.
13. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 1, characterized in that, The step of performing text recognition on the image of the upright rotating wheel area to obtain the water meter reading includes: The image of the upright rotating wheel area is used to perform text recognition using an optical character recognition engine to obtain a text string; The text string is converted into a numerical value to obtain the water meter reading.
14. The intelligent identification method for readings of a rotary mechanical water meter as described in claim 12, characterized in that, When the image of the decimal region does not exist, the decimal text string is assigned a preset default value; the integer text string and the decimal text string are converted into numerical values and concatenated, and the preset number of decimal places is retained.