A water meter reading method, device, equipment and storage medium
By masking the reading area and character recognition of the water meter image, and using the HSV color space and character recognition model, the error problem of traditional OCR technology in identifying water meters with decimals is solved, and the accuracy and efficiency of water meter reading recognition are improved.
Patent Information
- Application Number
- CN202410471684.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-19
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-04-19
AI Technical Summary
When traditional OCR technology recognizes water meter readings with decimals, it is easy to recognize the decimal part as an integer, resulting in low accuracy of the recognition results and affecting the recognition accuracy of the integer part.
By obtaining the water meter image, masking and character recognition of the reading area are performed, and the HSV color space conversion, color selection, expansion processing and character recognition model are used to extract and identify the integer part of the water meter reading to improve the recognition accuracy.
It effectively solves the error problem of traditional recognition models in identifying decimal water meters, and improves the accuracy and efficiency of water meter reading recognition.
Smart Images

Figure CN118072312B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image detection and recognition technology, and in particular, relates to a water meter reading method, device, equipment and storage medium. Background Art
[0002] In the water supply industry, in order to record water consumption more accurately, water meters produced in the past all displayed red decimals. Nowadays, such water meters with decimals are gradually being phased out of history. When reading such water meters, water companies will only write down the integer part and omit the decimal part. Since personnel can clearly distinguish the integer part and the decimal part when reading manually, such water meters with decimals will not cause much trouble.
[0003] However, when using OCR (Optical Character Recognition) technology to identify this type of water meter, the decimal part will be identified as an integer, which will affect the accuracy of OCR recognition of the integer part, resulting in errors in the recognition results. Summary of the invention
[0004] The embodiments of the present application provide a water meter reading method, device, equipment and storage medium, which can solve the problem that traditional recognition models will recognize decimals as integers when identifying water meter readings with decimals, resulting in errors in recognition results and low recognition accuracy.
[0005] In a first aspect, an embodiment of the present application provides a water meter reading method, the method comprising:
[0006] Acquire a first water meter image, wherein the first water meter image at least includes: a reading area;
[0007] Masking the area where the first value in the reading area is located to obtain a second water meter reading image; wherein the first value is a type of predetermined value in the reading area;
[0008] Character recognition is performed on the reading area in the second water meter reading image to obtain a second numerical value in the reading area.
[0009] In a possible implementation manner of the first aspect, masking the area where the first value is located in the reading area to obtain the second water meter reading image includes:
[0010] Performing HSV color space conversion on the first water meter image through a color recognition model to obtain an HSV image;
[0011] Perform color selection on the HSV image according to preset selection conditions to obtain the area where the first value is located in the reading area; wherein the preset selection conditions include: the selected color hue is within a preset hue threshold interval, the selected color saturation is within a preset saturation threshold interval, and the selected color brightness is within a preset brightness threshold interval;
[0012] Performing expansion processing on the area where the first value is located to obtain the coordinates of the minimum circumscribed rectangle corresponding to the area where the first value is located;
[0013] According to the minimum circumscribed rectangle coordinates, the area where the first value is located is masked to obtain the second water meter reading image.
[0014] In a possible implementation manner of the first aspect, the method further includes: when the preset hue threshold interval includes a first preset hue threshold interval and a second preset hue threshold interval,
[0015] Performing color selection on the HSV image according to the first preset hue threshold interval, the preset saturation threshold interval, and the preset brightness threshold interval to obtain a corresponding first binary image;
[0016] Performing color selection on the HSV image according to the second preset hue threshold interval, the preset saturation threshold interval, and the preset brightness threshold interval to obtain a corresponding second binary image;
[0017] According to the first binary image and the second binary image, the area where the first value is located in the reading area is obtained.
[0018] In a possible implementation manner of the first aspect, performing character recognition on the reading area in the second water meter reading image to obtain a second value in the reading area includes:
[0019] Converting the second water meter reading image into a corresponding first depth feature map through a convolution layer and a pooling layer in a character recognition model;
[0020] Obtaining the dependency relationship between all features in the first deep feature map through the self-attention mechanism in the character recognition model;
[0021] According to the dependency relationship, feature conversion is performed on the first depth feature map to obtain a corresponding second depth feature map;
[0022] The second depth feature map is converted into a second numerical value in the reading area through a fully connected layer and an activation function in the character recognition model.
[0023] In a possible implementation manner of the first aspect, acquiring the first water meter image includes:
[0024] According to the coordinates of the reading area in the initial water meter image, marking the reading area from the initial water meter image;
[0025] The initial water meter image is segmented according to the marked reading area by using an image segmentation model to obtain the first water meter image.
[0026] In a possible implementation manner of the first aspect, segmenting the initial water meter image according to the marked reading area using an image segmentation model to obtain the first water meter image includes:
[0027] Extracting multi-scale feature information from the initial water meter image through the feature pyramid network module in the image segmentation model, and fusing all the multi-scale feature information to obtain fused feature information;
[0028] The fused feature information is filtered and pooled by a hollow space pyramid pooling module in the image segmentation model to obtain enhanced feature information;
[0029] The initial water meter image is segmented according to the reading area coordinates and the enhanced feature information to obtain the first water meter image.
[0030] In a possible implementation manner of the first aspect, before segmenting the initial water meter image according to the marked reading area using an image segmentation model to obtain the first water meter image, the method further includes:
[0031] Acquire a training set, where the training set includes a plurality of sample images and segmentation and annotation results of the plurality of sample images;
[0032] Build an initial image segmentation model;
[0033] The initial image segmentation model is trained using the multiple sample images and the segmentation and annotation results of the multiple sample images to obtain the image segmentation model.
[0034] In a second aspect, an embodiment of the present application provides a water meter reading device, comprising:
[0035] An image acquisition module is used to acquire a first water meter image, wherein the first water meter image at least includes: a reading area;
[0036] An image masking module is used to mask the area where the first value in the reading area is located to obtain a second water meter reading image; wherein the first value is a type of predetermined value in the reading area;
[0037] The character recognition module is used to perform character recognition on the reading area in the second water meter reading image to obtain a second numerical value in the reading area.
[0038] In a third aspect, an embodiment of the present application provides a water meter reading device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-described water meter reading methods when executing the computer program.
[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the water meter reading method described in any one of the above items is implemented.
[0040] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes any of the water meter reading methods described above.
[0041] Compared with the prior art, the embodiments of the present application have the following beneficial effects: obtaining a first water meter image, the first water meter image at least including: a reading area; masking the area where the first value is located in the reading area to obtain a second water meter reading image; wherein the first value is a type of predetermined value in the reading area; performing character recognition on the reading area in the second water meter reading image to obtain a second value in the reading area. By partially masking and character recognition of the reading area of the input water meter image, the problem that the traditional recognition model will recognize decimals as integers in the process of recognizing water meter readings with decimals, resulting in errors in the recognition results and low recognition accuracy, is solved, thereby being able to accurately recognize the integer part of the water meter reading, thereby improving the efficiency and accuracy of water meter reading recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0043] Figure 1 It is a flow chart of a water meter reading method provided by an embodiment of the present application;
[0044] Figure 2 is a flow chart of a water meter reading method provided by another embodiment of the present application;
[0045] Figure 3is a process schematic diagram of a water meter reading method provided by another embodiment of the present application;
[0046] Figure 4 It is a structural schematic diagram of a water meter reading device provided in an embodiment of the present application;
[0047] Figure 5 It is a structural schematic diagram of a water meter reading device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0049] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0050] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0051] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0052] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0053] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0054] See also Figure 1 , Figure 1 : is a flow chart of a water meter reading method provided in an embodiment of the present application. The method comprises:
[0055] S11, acquiring a first water meter image; the first water meter image at least includes: a reading area;
[0056] S12, masking the area where the first value in the reading area is located to obtain a second water meter reading image; wherein the first value is a type of predetermined value in the reading area;
[0057] S13, performing character recognition on the reading area in the second water meter reading image to obtain a second numerical value in the reading area.
[0058] It should be noted that, in this embodiment, the execution subject may be a terminal device such as a server, and no specific limitation is made to this.
[0059] It should be noted that, in this embodiment, the first water meter image is a water meter image including a reading area obtained by segmenting the initial water meter image according to the reading area and the non-reading area, that is, the display range of the first water meter image is smaller than or equal to the initial water meter image, and the first water meter image is a part of the initial water meter image. The initial water meter image is an initial water meter photo with water meter readings. The second water meter image is a water meter image obtained by covering the area where the first value in the reading area is located.
[0060] Among them, the reading area is the area in the initial water meter image that can display the water meter value. The range of the first water meter image is greater than or equal to the reading area. This reading area can be a rectangle or other shapes. The reading area includes the area where the first value is located and the area where the second value is located. The first value and the second value are combined to form the water meter reading. Usually, the water meter reading is composed of a plurality of natural numbers 0-9, including an integer part and a decimal part, and the last digit is the decimal part. The integer part is displayed in black and the decimal part is displayed in red. That is, the first value is the decimal part of the water meter reading, a class of predetermined values is any natural number from 0 to 9, and the second value is the integer part of the water meter reading. In this embodiment, the colors of the first value and the second value are not specifically limited.
[0061] In this embodiment, the area where the first value is located in the first water meter image reading area is first masked, and then character recognition is performed on the unmasked part of the reading area, that is, the second value of the reading area, so as to identify the integer part of the water meter reading.
[0062] It can be understood that the present application obtains a first water meter image, which at least includes: a reading area; masks the area where the first value in the reading area is located to obtain a second water meter reading image; wherein the first value is a type of predetermined value in the reading area; and performs character recognition on the reading area in the second water meter reading image to obtain a second value in the reading area. By partially masking and character recognition of the reading area of the input water meter image, the problem that the traditional recognition model will recognize decimals as integers in the process of recognizing water meter readings with decimals, resulting in errors in the recognition results and low recognition accuracy, is solved, thereby being able to accurately recognize the integer part of the water meter reading, thereby improving the efficiency and accuracy of water meter reading recognition.
[0063] In one possible implementation, Figure 2 As shown, Figure 2 FIG. 1 is a flow chart of a water meter reading method provided by another embodiment of the present application. Figure 2 , the method comprising:
[0064] S21, performing HSV color space conversion on the first water meter image through a color recognition model to obtain an HSV image;
[0065] S22, performing color selection on the HSV image according to preset selection conditions to obtain an area where the first value is located in the reading area; wherein the preset selection conditions include: the selected color hue is within a preset hue threshold interval, the selected color saturation is within a preset saturation threshold interval, and the selected color brightness is within a preset brightness threshold interval;
[0066] S23, dilating the area where the first value is located to obtain the coordinates of the minimum circumscribed rectangle corresponding to the area where the first value is located;
[0067] S24. Mask the area where the first value is located according to the coordinates of the minimum circumscribed rectangle to obtain a second water meter reading image.
[0068] It should be noted that, in this embodiment, the color recognition model can be used to detect a specific color, such as red, in the first water meter image. Once the specific color area is detected, the area will be masked. The color recognition model can use the OpenCV model. The OpenCV model is a powerful computer vision library that can perform various image processing tasks, such as filtering, edge detection, feature extraction, etc. In this embodiment, the specific model of the color recognition model is not limited, as long as the corresponding function can be achieved.
[0069] Specifically, in step S21, the HSV image is an image obtained by converting the first water meter image from the BGR color space to the HSV color space using a color recognition model, that is, an image obtained after the HSV color space conversion. Among them, the BGR color space is an image color model, which is a variant of the RGB color space and can better represent the sensitivity of the human visual system to different colors. However, the BGR color space has problems such as inconsistent perception and information mixing of chromaticity and brightness, which may lead to difficulties in segmenting colors under different light and dark conditions. The HSV color space is a perception-based color model that is more suitable for color-based segmentation. It separates hue (H), saturation (S) and brightness (V), making color selection and segmentation more intuitive and accurate.
[0070] In step S22, when the color is selected from the HSV image by the color recognition model, it is necessary to set the H, S, and V ranges of the selected color, that is, to set the preset selection conditions, that is, the hue of the selected color must be in the corresponding preset hue threshold interval, the color saturation must be in the corresponding preset saturation threshold interval, and the color brightness must be in the corresponding preset brightness threshold interval. Among them, the preset hue threshold interval is a preset hue range corresponding to the selected color; the preset saturation threshold interval is a preset saturation range corresponding to the selected color; the preset brightness threshold interval is a preset brightness range corresponding to the selected color.
[0071] According to the preset selection condition, a binary image that meets the preset selection condition is screened out in the HSV image, that is, the area where the first value in the first water meter image is located, that is, the decimal part in the water meter reading area. Usually, the inRange() function in the OpenCV model can be used to screen the binary image that meets the preset selection condition.
[0072] Specifically, in this embodiment, the dilation process is a morphological operation in digital image processing, which is mainly used to expand the boundary points of the binary image, merge all the background points in contact with the object into the object, and expand the boundary outward. The minimum circumscribed rectangle coordinates are parameters that describe the minimum bounding rectangle of the target area. This rectangle can completely contain the target area, and its length and width are the smallest. The minimum circumscribed rectangle coordinates usually include the coordinates of the upper left corner and the lower right corner of the rectangle, or the coordinates of its center point and the length and width information.
[0073] That is, before masking the area where the first value is located, the area where the first value is located needs to be dilated, that is, the boundary points of the area where the first value is located are expanded to obtain the minimum circumscribed rectangle corresponding to the area where the first value is located, and then, according to the coordinates of this minimum circumscribed rectangle, the area where the first value is located is masked to obtain a second water meter image containing the second value.
[0074] It is understandable that by dilating the area where the first value is located, the shape, position and relationship of the area where the first value is located can be better understood and analyzed. Since the decimal part on the water meter may affect the accuracy of the subsequent character recognition model in recognizing the integer part due to factors such as color, font size or position, therefore, by masking the area where the first value is located, the error of recognizing the decimal part in the water meter reading area as an integer can be reduced, thereby improving the accuracy.
[0075] In a possible implementation, the method further includes:
[0076] In the case where the preset hue threshold interval includes a first preset hue threshold interval and a second preset hue threshold interval,
[0077] Performing color selection on the HSV image according to a first preset hue threshold interval, a preset saturation threshold interval, and a preset brightness threshold interval to obtain a corresponding first binary image;
[0078] Performing color selection on the HSV image according to a second preset hue threshold interval, a preset saturation threshold interval, and a preset brightness threshold interval to obtain a corresponding second binary image;
[0079] According to the first binary image and the second binary image, an area where the first value is located in the reading area is obtained.
[0080] It should be noted that, since the hue of red exists in two ranges in the HSV model, such as the hue of red can be 0-10 and 156-180. Therefore, when selecting the red color of the HSV image through the color recognition model, it is necessary to set the preset hue threshold interval to two threshold ranges including a first preset hue threshold interval and a second preset hue threshold interval, and select the red color in the HSV image according to the two threshold ranges.
[0081] Specifically, a binary image is a digital image that contains only two color values, usually black and white. In the process of image processing, it is usually necessary to convert a grayscale image or a color image into a binary image for subsequent analysis and processing. Among them, the first binary image is a binary image that meets the preset selection conditions of the first preset hue threshold interval, the preset saturation threshold interval and the preset brightness threshold interval when selecting the red color of the HSV image. The second binary image is another binary image that meets the preset selection conditions of the second preset hue threshold interval, the preset saturation threshold interval and the preset brightness threshold interval when selecting the red color of the same HSV image. The first binary image and the second binary image may be complementary to each other, that is, the red color area identified in the first binary image may be an unidentified red color area in the other image.
[0082] Then, the first binary image and the second binary image can be added by performing a bitwise operation, the white parts in the first binary image and the second binary image can be fused, and the black parts can be retained to obtain the area where the first value is located in the reading area. Bitwise operation is an operation method that directly operates on the binary bits of integers in memory. In image processing, bitwise operation can operate on each pixel of the image bit by bit. For example, bitwise operation can very effectively perform image superposition, difference detection and other processing on binary images.
[0083] In a possible implementation, character recognition is performed on a reading area in the second water meter reading image to obtain a second value in the reading area, including:
[0084] Converting the second water meter reading image into a corresponding first depth feature map through a convolution layer and a pooling layer in the character recognition model;
[0085] Obtain the dependency relationship between all features in the first deep feature map through the self-attention mechanism in the character recognition model;
[0086] According to the dependency relationship, feature conversion is performed on the first depth feature map to obtain a corresponding second depth feature map;
[0087] Through the fully connected layer and activation function in the character recognition model, the second depth feature map is converted to obtain the second value in the reading area.
[0088] It should be noted that in this embodiment, the character recognition model is a model that uses computer vision and machine learning technology to automatically recognize and extract text information from an image. In this embodiment, the character recognition model can adopt the SATRN model, which is a text recognition model based on the transformer network structure, and can recognize text in an image and convert it into an editable text format. It uses the self-attention mechanism to capture long-distance dependencies between text features, and has excellent performance for processing texts with complex structures and context dependencies, such as handwritten text or text with artistic fonts.
[0089] Specifically, the specific process of performing character recognition on the reading area in the second water meter reading image using the character recognition model includes:
[0090] First, the second water meter reading image is converted into the first deep feature map through the convolution layer and pooling layer in the character recognition model. Among them, the main function of the convolution layer is to extract useful feature information from the input image. The pooling layer is mainly used to reduce the size of the feature map and extract the most important features. Through the pooling operation, the spatial dimension of the feature map can be reduced, thereby reducing the computational complexity and memory usage. At the same time, the most significant features of the input data can be retained, and the response and robustness of the model to important features can be enhanced. The first deep feature map is used to characterize the main information and structure of the second water meter reading image.
[0091] Secondly, the self-attention mechanism in the character recognition model is used to obtain the dependencies between all features in the first deep feature map, and the first deep feature map is transformed to obtain the second deep feature map. Among them, the self-attention mechanism is a key technology for improving recognition accuracy. By calculating the dependencies between different positions in the input sequence, a weight matrix is generated, which determines which other elements the model should pay attention to when processing each element. The self-attention mechanism helps the character recognition model better understand and recognize the text information in the image. The second deep feature map is the feature map output after the first deep feature map is transformed by the self-attention mechanism, which can involve all the information of the input features.
[0092] Finally, the second depth feature map is converted to obtain the second value in the reading area through the fully connected layer and activation function in the character recognition model. Among them, the fully connected layer (Fully Connected Layer) is usually located at the back end of the network in the character recognition model, accepts the feature map output by the previous layer (such as convolution layer, pooling layer, etc.), that is, the second depth feature map, and converts it into a feature vector. The activation function is to add nonlinear characteristics to the character recognition model so that it can learn and approximate complex functions. In this embodiment, the activation function can be a Softmax activation function, which is not specifically limited. Through the fully connected layer and activation function in the character recognition model, the second depth feature map is mapped to the character set to obtain the probability distribution of each character, and then the character with the highest probability is selected as the prediction result to output the final text sequence. The text sequence is the result output by the character recognition model, which represents the order of characters recognized from the second water meter image, reflects the text content in the image, that is, the second value in the reading area, that is, the integer part of the water meter reading.
[0093] It is understandable that in the character recognition process, by introducing the self-attention mechanism to establish global dependencies and expand the receptive field of the image, the recognition accuracy and efficiency can be further improved.
[0094] In a possible implementation manner, acquiring a first water meter image includes:
[0095] Marking the reading area from the initial water meter image according to the coordinates of the reading area in the initial water meter image;
[0096] The initial water meter image is segmented according to the marked reading areas through the image segmentation model to obtain a first water meter image.
[0097] Specifically, in this embodiment, the initial water meter image needs to be annotated and segmented to obtain a first water meter image. These annotations are the coordinates of the reading areas so that the image segmentation model can learn to recognize these areas. The image segmentation model is a model used to segment the input image. The initial water meter image can be segmented according to the annotated reading areas to obtain a second water meter image that only includes the reading areas after segmentation.
[0098] It should be noted that the reading area coordinates usually represent the reading area on the dial of the water meter, that is, the part that displays the time, value or other measurement results. By determining the reading area coordinates, it is helpful to improve the image segmentation model to accurately extract the reading information, thereby realizing automatic reading and analysis of the water meter. It should be noted that the reading area coordinates depend on the content of the image, the type of water meter and the image segmentation model used. In this embodiment, the reading area coordinates are not specifically limited.
[0099] In a possible implementation, the initial water meter image is segmented according to the marked reading area by using an image segmentation model to obtain a first water meter image, including:
[0100] Through the feature pyramid network module in the image segmentation model, multi-scale feature information is extracted from the initial water meter image, and all multi-scale feature information is fused to obtain fused feature information;
[0101] The fused feature information is filtered and pooled through the hollow space pyramid pooling module in the image segmentation model to obtain enhanced feature information;
[0102] The initial water meter image is segmented according to the reading area coordinates and the enhanced feature information to obtain a first water meter image.
[0103] It should be noted that, in this embodiment, the image segmentation model adopts an improved Deeplab model. The Deeplab model is a powerful deep neural network model designed for semantic segmentation tasks. By classifying the image at the pixel level, it can accurately identify different areas in the image. In this embodiment, the improved Deeplab model is based on the Deeplab model, and introduces a feature pyramid network module (Feature Pyramid Network, FPN module) and an atrous spatial pyramid pooling module (Atrous Spatial Pyramid Pooling, ASPP module), thereby improving the image segmentation model's processing power and efficiency for targets of different sizes and shapes. Among them, the FPN module extracts target features at different scales by constructing a pyramid-like feature map, fusing shallow features with high resolution and deep features with rich semantic information, thereby realizing multi-scale detection. The ASPP module can filter and pool the input features by using multiple rates and multiple effective fields of view, thereby encoding multi-scale context information, thereby enhancing the model's ability to segment complex scenes.
[0104] Specifically, first, the multi-scale feature information is extracted from the initial water meter image through the FPN module in the image segmentation model, and all the multi-scale feature information is fused to obtain fused feature information. Among them, multi-scale feature information refers to image features extracted at different scales, resolutions and receptive fields. These features provide rich descriptions of object size, shape, structure and context information, which helps to more accurately understand and identify the content in the image. The fused feature information is the feature information obtained after the multi-scale feature information is fused through the FPN module. After the multi-scale feature information is fused, the image segmentation model can capture the detailed information and global context information of the image at the same time.
[0105] Secondly, the fused feature information is filtered and pooled by the ASPP module in the image segmentation model to obtain enhanced feature information. Among them, the enhanced feature information is the feature information obtained after the fused feature information is filtered and pooled by the ASPP module, which is a further processing of the fused feature information.
[0106] Finally, after obtaining the enhanced feature information, the initial water meter image is segmented according to the reading area coordinates to obtain the first water meter image containing the reading area. The information of the reading area coordinates can guide the image segmentation model to focus on a specific area, ensuring that the reading area can be accurately identified during the segmentation process.
[0107] It can be understood that in this embodiment, since the water meter has important features at different scales, these features may be crucial for understanding and identifying the water meter readings. Therefore, this improved Deeplab model will improve the image segmentation model's processing capabilities for water meter readings, and can better meet the requirements for water meter reading accuracy and real-time identification of water meter readings.
[0108] In a possible implementation, before segmenting the initial water meter image according to the marked reading area using the image segmentation model to obtain the first water meter image, the method further includes:
[0109] Obtaining a training set, where the training set includes a plurality of sample images and segmentation and annotation results of the plurality of sample images;
[0110] Build an initial image segmentation model;
[0111] An initial image segmentation model is trained using multiple sample images and segmentation annotation results of the multiple sample images to obtain an image segmentation model.
[0112] It should be noted that, in this embodiment, before using the image segmentation model to segment the initial water meter image, it is necessary to perform model training on the constructed initial image segmentation model. The initial image segmentation model is a newly constructed image segmentation model that has not been trained. The training set is a subset of data used to train the model, which contains known input features and expected output labels, that is, sample images and segmentation and annotation results of the sample images. The sample image is the collected initial water meter image with the water meter reading. The segmentation and annotation results of the sample image are the images after the sample image is annotated according to the coordinates of the reading area, that is, the image that the model expects to output, that is, the first water meter image.
[0113] It can be understood that by training the initial image segmentation model, the model can accurately predict or classify new data and accurately segment the image of the water meter reading area.
[0114] In specific applications, such as Figure 3 As shown, Figure 3 This is a schematic diagram of a water meter reading method provided by another embodiment of the present application. Figure 3 , Figure 3 30 represents the initial water meter image, 31 represents the first water meter image, 32 represents the second water meter image, 311 represents the area where the first value is located, 312 represents the area where the second value is located, and 313 represents the minimum circumscribed rectangle corresponding to the area where the first value is located. First, the first water meter image 31 including the reading area is segmented by the image segmentation model; secondly, the color recognition model is used to perform color screening on the first water meter image 31 to screen out the area 311 where the first value is located, that is, the decimal part of the water meter. Figure 3 The first value in the image is 5; then, the area 311 where the first value is located is expanded to obtain the minimum circumscribed rectangle 313 corresponding to the area where the first value is located. Finally, according to the coordinates of the minimum circumscribed rectangle, the area 311 where the first value is located is masked to obtain the second water meter reading image 32, that is, the area 311 where the first value is located in the second water meter reading image 32 is masked, and only the area 312 where the second value is located is displayed. Finally, the character recognition model is used to perform character recognition on the area 312 where the second value is located to identify the second value in the reading area, that is, Figure 3 The second value is 0013, which is the integer part of the water meter.
[0115] It can be understood that the present application solves the problem that the traditional recognition model will recognize decimals as integers in the process of identifying water meter readings with decimals, resulting in errors in the recognition results and low recognition accuracy, by segmenting the input water meter image, identifying the area where the masked first value is located, and performing character recognition. This can accurately identify the integer part of the water meter reading, thereby improving the efficiency and accuracy of water meter reading recognition.
[0116] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean 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 application.
[0117] Corresponding to a water meter reading method in the above embodiment, Figure 4 A schematic structural diagram of a water meter reading device provided in one embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0118] Reference Figure 4 The water meter reading device 4 provided in this embodiment includes:
[0119] The image acquisition module 41 is used to acquire a first water meter image, wherein the first water meter image at least includes: a reading area;
[0120] An image masking module 42 is used to mask the area where the first value in the reading area is located to obtain a second water meter reading image; wherein the first value is a type of predetermined value in the reading area;
[0121] The character recognition module 43 is used to perform character recognition on the reading area in the second water meter reading image to obtain a second value in the reading area.
[0122] It can be understood that in this embodiment, the water meter reading device 4 solves the problem that the traditional recognition model will recognize decimals as integers during the process of identifying water meter readings with decimals, resulting in errors in the recognition results and low recognition accuracy, by partially masking and character recognition of the reading area of the input water meter image. It can thus accurately identify the integer part of the water meter reading, thereby improving the efficiency and accuracy of water meter reading recognition.
[0123] It should be noted that the information interaction, execution process and other contents between the modules in the above-mentioned water meter reading device 4 are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0124] The present application also provides a water meter reading device, such as Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of a water meter reading device provided in an embodiment of the present application. Figure 5 The water meter reading device 5 provided in this embodiment includes: a memory 51, a processor 52, and a computer program stored in the memory 51 and executable on the processor 52. When the processor 52 executes the computer program, the steps in any one of the above-mentioned water meter reading method embodiments are implemented.
[0125] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0126] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0127] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0128] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0129] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0130] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0131] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0132] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A method for reading a water meter, It is characterized in that include: Acquire a first water meter image, wherein the first water meter image at least includes: a reading area; Masking the area where the first value in the reading area is located to obtain a second water meter reading image; wherein the first value is a type of predetermined value in the reading area; Performing character recognition on the reading area in the second water meter reading image to obtain a second value in the reading area; The step of acquiring the first water meter image includes: According to the coordinates of the reading area in the initial water meter image, marking the reading area from the initial water meter image; The initial water meter image is segmented according to the marked reading area by an image segmentation model to obtain the first water meter image, specifically: Extracting multi-scale feature information from the initial water meter image through the feature pyramid network module in the image segmentation model, and fusing all the multi-scale feature information to obtain fused feature information; The fused feature information is filtered and pooled by a hollow space pyramid pooling module in the image segmentation model to obtain enhanced feature information; Segmenting the initial water meter image according to the reading area coordinates and the enhanced feature information to obtain the first water meter image; and The step of masking the area where the first value is located in the reading area to obtain a second water meter reading image includes: Performing HSV color space conversion on the first water meter image through a color recognition model to obtain an HSV image; Perform color selection on the HSV image according to preset selection conditions to obtain the area where the first value is located in the reading area; wherein the preset selection conditions include: the selected color hue is within a preset hue threshold interval, the selected color saturation is within a preset saturation threshold interval, and the selected color brightness is within a preset brightness threshold interval; Performing expansion processing on the area where the first value is located to obtain the coordinates of the minimum circumscribed rectangle corresponding to the area where the first value is located; According to the minimum circumscribed rectangle coordinates, the area where the first value is located is masked to obtain the second water meter reading image.
2. The water meter reading method according to claim 1, It is characterized in that The method further includes: when the preset hue threshold interval includes a first preset hue threshold interval and a second preset hue threshold interval, Performing color selection on the HSV image according to the first preset hue threshold interval, the preset saturation threshold interval, and the preset brightness threshold interval to obtain a corresponding first binary image; Performing color selection on the HSV image according to the second preset hue threshold interval, the preset saturation threshold interval, and the preset brightness threshold interval to obtain a corresponding second binary image; According to the first binary image and the second binary image, the area where the first value is located in the reading area is obtained.
3. The water meter reading method according to claim 1, It is characterized in that The performing character recognition on the reading area in the second water meter reading image to obtain a second value in the reading area includes: Converting the second water meter reading image into a corresponding first depth feature map through a convolution layer and a pooling layer in a character recognition model; Obtaining the dependency relationship between all features in the first deep feature map through the self-attention mechanism in the character recognition model; According to the dependency relationship, feature conversion is performed on the first depth feature map to obtain a corresponding second depth feature map; The second depth feature map is converted into a second numerical value in the reading area through a fully connected layer and an activation function in the character recognition model.
4. The water meter reading method according to claim 1, It is characterized in that Before segmenting the initial water meter image according to the marked reading area using the image segmentation model to obtain the first water meter image, the method further includes: Acquire a training set, where the training set includes a plurality of sample images and segmentation and annotation results of the plurality of sample images; Build an initial image segmentation model; The initial image segmentation model is trained using the multiple sample images and the segmentation and annotation results of the multiple sample images to obtain the image segmentation model.
5. A water meter reading device, It is characterized in that include: An image acquisition module is used to acquire a first water meter image, wherein the first water meter image at least includes: a reading area; An image masking module is used to mask the area where the first value in the reading area is located to obtain a second water meter reading image; wherein the first value is a type of predetermined value in the reading area; A character recognition module, used for performing character recognition on the reading area in the second water meter reading image to obtain a second value in the reading area; Wherein, the image acquisition module is specifically used for: According to the coordinates of the reading area in the initial water meter image, marking the reading area from the initial water meter image; The initial water meter image is segmented according to the marked reading area by an image segmentation model to obtain the first water meter image, specifically: Extracting multi-scale feature information from the initial water meter image through the feature pyramid network module in the image segmentation model, and fusing all the multi-scale feature information to obtain fused feature information; The fused feature information is filtered and pooled by a hollow space pyramid pooling module in the image segmentation model to obtain enhanced feature information; Segmenting the initial water meter image according to the reading area coordinates and the enhanced feature information to obtain the first water meter image; and The image mask module is specifically used for: Performing HSV color space conversion on the first water meter image through a color recognition model to obtain an HSV image; Perform color selection on the HSV image according to preset selection conditions to obtain the area where the first value is located in the reading area; wherein the preset selection conditions include: the selected color hue is within a preset hue threshold interval, the selected color saturation is within a preset saturation threshold interval, and the selected color brightness is within a preset brightness threshold interval; Performing expansion processing on the area where the first value is located to obtain the coordinates of the minimum circumscribed rectangle corresponding to the area where the first value is located; According to the minimum circumscribed rectangle coordinates, the area where the first value is located is masked to obtain the second water meter reading image.
6. A water meter reading device, It is characterized in that The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Character wheel water meter reading identification method and system based on deep learning
CN113392834A
Water meter value reading method based on target detection and segmentation identification
CN113569835A
Ammeter reading identification method and device, electronic equipment and storage medium
CN113642582A
Character recognition device, character recognition program and character recognition method
JP2017207910A
Image Segmentation Method and Apparatus, Computer Device, and Readable Storage Medium
US20230368394A1
