A meter code off screen standard template generation method, device, equipment and medium
By using automated edge detection and character matching technology, a standard template for meter defect detection is generated, which solves the problems of low efficiency, high cost and insufficient versatility in the production of meter templates in the existing technology, and realizes fast and accurate meter defect detection.
Patent Information
- Application Number
- CN202311128890.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-01
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2043-09-01
AI Technical Summary
In existing technologies, the detection of defects in the character display of electricity meter broken codes suffers from problems such as low efficiency, high cost, and lack of standardization due to human factors affecting the standardization, as well as insufficient universality. It is difficult to quickly and easily generate standard templates for different types of electricity meters.
By acquiring the initial meter image, the Canny edge detection algorithm is used to determine the boundary of the broken code screen, the image is rotated and corrected, and character matching is performed in combination with a preset character image library to automatically determine the target position coordinates and draw a standard template for the broken code screen of the meter.
It enables the rapid and easy generation of standard templates for different types of electricity meters, reducing manpower consumption, improving testing efficiency, reducing misjudgments and missed detections, and ensuring the standardization and universality of the templates.
Smart Images

Figure CN117079294B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image processing, in particular to a method, device and equipment for generating a standard template of a meter code screen and a medium. BACKGROUND
[0002] With the development of the power industry and the large-scale construction of smart grids, the use of smart meters has rapidly increased. The code screen is one of the important components of the smart meter, which can display the user's electricity information and various information of the power grid on the screen. In actual production of the meter, due to the problems of invisible strokes and virtual display of the code screen character strokes, it will cause the display error of the electricity information, so the character display of the code screen needs to be strictly detected before the meter is used.
[0003] The defect detection method is mainly divided into two categories: (1) manual detection; (2) automatic detection. Manual detection is slow, low in efficiency, and consumes a lot of human resources. The method used in automatic detection is usually template matching, which compares the to-be-tested character image with the standard template, calculates the similarity between the to-be-tested character image and the standard template image, and judges whether the character has defects. Therefore, the premise of detecting the defects of the meter code screen is to make a standard template of the meter. At present, the method for making a standard template of the meter is mainly manual, that is, manually cutting out images of different characters to make a standard image template. However, there are three main problems in manual template making: (1) a large amount of manpower and time are needed, the efficiency is low, and the production cost is high; (2) the standardization of the template will be affected by human factors, causing misjudgment or missed detection; (3) the template is not universal and cannot be used for different types and models of meters.
[0004] In summary, how to quickly and simply generate a standard template of the meter code screen of different types of meters is a problem to be solved at present. SUMMARY
[0005] Therefore, the purpose of the present application is to provide a method, device and equipment for generating a standard template of a meter code screen, which can quickly and simply generate a standard template of a meter code screen of different types of meters, and the specific scheme is as follows:
[0006] In the first aspect, the present application discloses a method for generating a standard template of a meter code screen, comprising:
[0007] obtaining an initial meter picture and cutting out a to-be-processed code screen area picture from the initial meter picture;
[0008] determining the code screen boundary in the to-be-processed code screen area picture to determine a forward target code screen area picture based on the code screen boundary;
[0009] sliding each to-be-matched character picture in a preset character picture library on the target broken code screen area picture to perform character matching, to determine each target character picture matched with the target broken code screen area picture, and to determine a target position coordinate of each target character picture in the target broken code screen area picture; each to-be-matched character picture corresponding to a different type of electric meter exists in the preset character picture library;
[0010] drawing a target electric meter broken code screen standard template based on the target position coordinate and the target character picture.
[0011] Optionally, the intercepting of the to-be-processed broken code screen area picture from the initial electric meter picture comprises:
[0012] performing gray scale processing on the initial electric meter picture to obtain a gray scale electric meter picture, and intercepting the to-be-processed broken code screen area picture from the gray scale electric meter picture;
[0013] Correspondingly, the determining of the broken code screen boundary in the to-be-processed broken code screen area picture comprises:
[0014] determining an edge map in the to-be-processed broken code screen area picture by using a Canny edge detection algorithm; the edge map comprises character edges and broken code screen edges;
[0015] determining a gray scale value non-zero area in the edge map, and determining a minimum circumscribed rectangle corresponding to the gray scale value non-zero area;
[0016] taking the boundary of the minimum circumscribed rectangle as the broken code screen boundary, and determining corner point position coordinates of four corner points of the broken code screen boundary in the to-be-processed broken code screen area picture.
[0017] Optionally, the determining of the forward target broken code screen area picture based on the broken code screen boundary comprises:
[0018] taking one of the four corner points with the largest vertical coordinate in the corner point position coordinates as a zeroth corner point, or taking one of the two corner points with the largest vertical coordinate in the four corner points and with a smaller horizontal coordinate as the zeroth corner point;
[0019] taking the zeroth corner point as a starting point, and sequentially determining the remaining corner points as a first corner point, a second corner point and a third corner point in a counterclockwise direction;
[0020] calculating a rotation angle based on the corner point position coordinate of the zeroth corner point and the corner point position coordinate of the third corner point;
[0021] Taking the picture center point of the to-be-processed broken screen area picture as a rotation center, the to-be-processed broken screen area picture is rotated counterclockwise based on the rotation angle to obtain a forward reference broken screen area picture, and a target broken screen area picture is obtained from the reference broken screen area picture based on the four rotated corner points.
[0022] Optionally, the sliding of each to-be-matched character picture in the preset character picture library on the target broken screen area picture for character matching to determine each target character picture matched with the target broken screen area picture and determine a target position coordinate of each target character picture in the target broken screen area picture comprises:
[0023] The sliding of each to-be-matched character picture in the preset character picture library on the target broken screen area picture for character matching is performed several times, and a first character matching degree of each time of matching is calculated.
[0024] The highest first character matching degree corresponding to each to-be-matched character picture is determined.
[0025] If the highest first character matching degree corresponding to the to-be-matched character picture is not less than a matching degree threshold, the to-be-matched character picture is taken as one target character picture matched with the target broken screen area picture, and a matching position coordinate when the first character matching degree is the highest is taken as a target position coordinate of the target character picture in the target broken screen area picture, so as to determine the target position coordinate of each target character picture in the target broken screen area picture.
[0026] Optionally, after the target position coordinate of each target character picture in the target broken screen area picture is determined, the method further comprises:
[0027] If there are several first single character regions that are not successfully matched in the target broken screen area picture, the first single character regions are manually framed to obtain several single character pictures.
[0028] Each to-be-matched character picture in the preset character picture library is slid on each single character picture for several times of character matching, and a second character matching degree of each time of matching is calculated.
[0029] The highest second character matching degree corresponding to each to-be-matched character picture on each single character picture is determined.
[0030] if the highest second character matching degree corresponding to the to-be-matched character picture on the single character picture is not less than the matching degree threshold, the to-be-matched character picture is taken as a target character picture corresponding to the single character picture in the target broken code screen region picture, and a matching position coordinate at which the second character matching degree is the highest is taken as a temporary coordinate position of the target character picture in the single character picture, so as to determine the target character picture corresponding to each single character picture and the temporary coordinate position of each target character picture in the corresponding single character picture;
[0031] based on the temporary coordinate position and a reference coordinate position of each single character picture in the target broken code screen region picture, a target coordinate position of each target character picture in the target broken code screen region picture is determined.
[0032] Optionally, after the target coordinate position of each target character picture in the target broken code screen region picture is determined based on the temporary coordinate position and the reference coordinate position of each single character picture in the target broken code screen region picture, if there is still a second single character region that is not matched successfully in the target broken code screen region picture, the drawing of the target electric meter broken code screen standard template based on the target coordinate position and the target character picture comprises:
[0033] an initial electric meter broken code screen standard template is drawn based on the target coordinate position and the target character picture, and a character box corresponding to the second single character region is manually drawn in the initial electric meter broken code screen standard template to obtain a target electric meter broken code screen standard template.
[0034] Optionally, the sliding of each to-be-matched character picture in the preset character picture library on the target broken code screen region picture for a plurality of times of character matching and the calculation of a first character matching degree of each time of matching comprise:
[0035] pixel values of all pixel points in each character picture in the preset character picture library are expressed as a first vector in a target order;
[0036] a uniform picture width and a uniform picture height of each character picture in the preset character picture library are determined;
[0037] a plurality of sliding windows are constructed based on the uniform picture width and the uniform picture height with a basic coordinate position as a top-left corner coordinate of the sliding window; the basic coordinate position comprises any coordinate combination of an x-axis coordinate range and a y-axis coordinate range; the x-axis coordinate range is from zero to a difference between a target picture width and the uniform picture width; the y-axis coordinate range is from zero to a difference between a target picture height and the uniform picture height; the target picture width and the target picture height are a width and a height of the target broken code screen region picture.
[0038] representing pixel values of all pixel points in the sliding window as a second vector according to the target order, to obtain the second vector corresponding to each sliding window;
[0039] sliding each to-be-matched character picture in a preset character picture library on the target broken code screen region picture, and calculating the first character matching degree based on the first vector of the to-be-matched character picture and the second vector of the sliding window when the to-be-matched character picture slides to the sliding window, to obtain the first character matching degree between each to-be-matched character picture and each sliding window.
[0040] In a second aspect, the present application discloses a meter broken code screen standard template generation device, comprising:
[0041] a first picture acquisition module configured to acquire an initial meter picture and cut a to-be-processed broken code screen region picture from the initial meter picture;
[0042] a second picture acquisition module configured to determine a broken code screen boundary in the to-be-processed broken code screen region picture, to determine a forward target broken code screen region picture based on the broken code screen boundary;
[0043] a third picture acquisition module configured to slide each to-be-matched character picture in a preset character picture library on the target broken code screen region picture for character matching, to determine each target character picture matched with the target broken code screen region picture and determine a target position coordinate of each target character picture in the target broken code screen region picture; the preset character picture library contains each to-be-matched character picture corresponding to different types of meters;
[0044] a template drawing module configured to draw a target meter broken code screen standard template based on the target position coordinate and the target character picture.
[0045] In a third aspect, the present application discloses an electronic device, comprising:
[0046] a memory configured to save a computer program;
[0047] a processor configured to execute the computer program to implement the meter broken code screen standard template generation method disclosed above.
[0048] In a fourth aspect, the present application discloses a computer readable storage medium configured to save a computer program; wherein the computer program is executed by a processor to implement the meter broken code screen standard template generation method disclosed above.
[0049] It can be seen that the initial electric meter picture is acquired, and a to-be-processed broken code screen region picture is intercepted from the initial electric meter picture; a broken code screen boundary in the to-be-processed broken code screen region picture is determined, so as to determine a forward target broken code screen region picture based on the broken code screen boundary; each to-be-matched character picture in a preset character picture library is slid on the target broken code screen region picture for character matching, so as to determine each target character picture matched with the target broken code screen region picture, and determine a target position coordinate of each target character picture in the target broken code screen region picture; each to-be-matched character picture corresponding to different types of electric meters exists in the preset character picture library; and a target electric meter broken code screen standard template is drawn based on the target position coordinate and the target character picture. In the application, each to-be-matched character picture in the preset character picture library is matched with the target broken code screen region picture for character matching to determine each target character picture matched with the target broken code screen region picture, so as to construct the electric meter broken code screen standard template. The application only needs to construct the electric meter broken code screen standard template through the matching process, which is simple and fast. In addition, since each to-be-matched character picture corresponding to different types of electric meters exists in the preset character picture library, the application can generate the electric meter broken code screen standard template of different types of electric meters. BRIEF DESCRIPTION OF DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only constitute the embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor based on the provided drawings.
[0051] Figure 1 A flow chart of a method for generating an electric meter broken code screen standard template disclosed by the present application is provided.
[0052] Figure 2 An intercepting region schematic diagram for intercepting a to-be-processed broken code screen region picture disclosed by the present application is provided.
[0053] Figure 3 A to-be-processed broken code screen region picture schematic diagram disclosed by the present application is provided.
[0054] Figure 4 An edge map schematic diagram disclosed by the present application is provided.
[0055] Figure 5 A reference broken code screen region picture schematic diagram disclosed by the present application is provided.
[0056] Figure 6 A target broken code screen region picture schematic diagram disclosed by the present application is provided.
[0057] Figure 7 A schematic diagram of three character pictures to be matched in a preset character picture library disclosed by the application;
[0058] Figure 8 A specific meter broken code screen standard template generation method flow chart disclosed by the application
[0059] Figure 9 A meter broken code screen standard template generation device structure schematic diagram disclosed by the application
[0060] Figure 10 An electronic device structure diagram disclosed by the application DETAILED DESCRIPTION
[0061] The technical solutions in the embodiments of the application will be clearly and completely described below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, rather than all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the application.
[0062] Defect detection methods are mainly divided into two categories: (1) manual detection; and (2) automatic detection. Manual detection is slow, low in efficiency, and large in consumption of human resources. The method used in automatic detection is usually template matching, which compares a to-be-detected character image with a standard template, and calculates the similarity between the to-be-detected character image and the standard template image to determine whether the character has a defect. Therefore, the premise of performing meter broken code screen defect detection is to make a meter standard template. At present, the meter standard template making method is mainly manual making, that is, manually cutting out images of different characters to make a standard image template. However, manual template making has three main problems: (1) a large amount of manpower and time are required, the efficiency is low, and the production cost is high; (2) the standardization of the template is affected by human factors, causing misjudgment or missed detection; and (3) the template is not universal, and cannot be used for different types and models of meters.
[0063] Therefore, the embodiments of the application provide a meter broken code screen standard template generation scheme, which can quickly and simply generate meter broken code screen standard templates of different types of meters.
[0064] The embodiments of the application disclose a meter broken code screen standard template generation method, referring to FIG. 1, Figure 1 The method comprises the following steps.
[0065] Step S11: An initial meter picture is acquired, and a to-be-processed broken code screen region picture is cut out from the initial meter picture.
[0066] In this embodiment, the initial electricity meter image is an electricity meter image with normal character display in the broken code screen area; the initial electricity meter image can be an electricity meter image of various types of electricity meters.
[0067] In this embodiment, the image of the broken screen area to be processed is a larger black border area slightly larger than the broken screen area but not exceeding the surrounding area of the broken screen area. Figure 2 The figure shows a schematic diagram of a cutout area for cutting out a picture of a broken screen area to be processed (the area inside the square box is the area to be cutout); see Figure 3 The figure shows a schematic diagram of a broken code screen area to be processed.
[0068] In this embodiment, the step of intercepting the image of the to-be-processed broken code screen area from the initial meter image includes: performing grayscale processing on the initial meter image to obtain a grayscale meter image, and intercepting the image of the to-be-processed broken code screen area from the grayscale meter image.
[0069] In a specific embodiment, the camera used to obtain the initial electricity meter image may have a resolution of 2 million pixels, an imaging height of 0.5 m, and vertical imaging.
[0070] Step S12: determining a broken screen boundary in the to-be-processed broken screen area picture, and determining a forward target broken screen area picture based on the broken screen boundary.
[0071] In this embodiment, the determination of the broken code screen boundary in the image of the broken code screen area to be processed includes: using the Canny edge detection algorithm to determine the edge map corresponding to the image of the broken code screen area to be processed; the edge map includes character edges and broken code screen edges; determining the grayscale value non-zero area in the edge map, and determining the minimum circumscribed rectangle corresponding to the grayscale value non-zero area; using the boundary of the minimum circumscribed rectangle as the broken code screen boundary, and determining the corner point position coordinates of the four corner points of the broken code screen boundary in the image of the broken code screen area to be processed. It should be noted that when determining the corner point position coordinates, the upper left corner of the image of the broken code screen area to be processed is used as the coordinate origin. See Figure 4 The figure shows a schematic diagram of an edge graph.
[0072] It should be noted that the Canny edge detection algorithm is used to determine the edge map corresponding to the to-be-processed broken code screen region picture, and specifically includes: performing Gaussian filtering on the to-be-processed broken code screen region picture to smooth the image to remove noise and obtain a smoothed picture; calculating the horizontal direction gradient component and the vertical direction gradient component of the smoothed picture by using a Sobel operator, and calculating the gradient amplitude and the gradient direction according to the horizontal direction gradient component and the vertical direction gradient component; performing non-maximum suppression to remove non-boundary points, specifically including: traversing the pixel points one by one, judging whether the current pixel point is a local maximum value with the same or opposite gradient direction in the surrounding pixel points, and deciding whether to suppress the point according to the judgment result: if the gradient amplitude of the point is a local maximum value with the same or opposite gradient direction, the point is retained and is called an edge pixel, otherwise the point is suppressed (i.e. the gradient amplitude of the point is set to zero); setting two threshold values of a high threshold value and a low threshold value for further determining the edge, if the gradient amplitude is greater than or equal to the high threshold value, the edge pixel is marked as a strong edge and is retained, if the gradient amplitude is between the high threshold value and the low threshold value, the edge pixel is marked as a virtual edge and is retained for further identification, if the gradient amplitude is less than or equal to the low threshold value, the edge pixel is suppressed. For the virtual edge, whether the virtual edge needs to be retained is determined by judging whether the virtual edge is connected with the strong edge: if connected with the strong edge, the edge is retained, otherwise the edge is suppressed. It should be noted that the edge detected according to the edge detection algorithm includes the broken code screen edge and the character edge in the broken code screen region, but the broken code screen edge is in the outermost periphery and surrounds the character edge.
[0073] In a specific embodiment, the high threshold value of the Canny edge detection algorithm can be set to 100, and the low threshold value can be set to 0; the cv2.findNonZero() function can be used to obtain a non-zero point set, the cv2.minAreaRect() function can be used to draw the minimum circumscribed rectangle of the non-zero point set, and the cv2.boxPoints() function can be used to obtain the coordinates of the four corner points.
[0074] In the embodiment, the determining the target broken screen region picture in the forward direction based on the broken screen boundary includes: taking one of the four corner points with the maximum vertical coordinate in the corner point position coordinates as a zeroth corner point, or taking one of the two corner points with the maximum vertical coordinate in the corner point position coordinates of the four corner points and with a smaller horizontal coordinate as the zeroth corner point; taking the zeroth corner point as a starting point, sequentially determining the remaining corner points as a first corner point, a second corner point and a third corner point in a counterclockwise direction; calculating a rotation angle based on the corner point position coordinates of the zeroth corner point and the corner point position coordinates of the third corner point; taking a picture center point of the to-be-processed broken screen region picture as a rotation center, rotating the to-be-processed broken screen region picture counterclockwise based on the rotation angle to obtain a reference broken screen region picture in the forward direction, and obtaining a target broken screen region picture from the reference broken screen region picture based on the four corner points after rotation. Referring to Figure 5 FIG. 2 shows a reference broken screen region picture diagram; and Figure 6 FIG. 3 shows a target broken screen region picture diagram. It should be noted that the process of obtaining the target broken screen region picture from the reference broken screen region picture removes the unexpected black part of the broken screen boundary in the reference broken screen region picture.
[0075] It should be noted that when the to-be-processed broken screen region picture itself is in the forward direction, the rotation angle is 0.
[0076] In a specific embodiment, a mapping matrix of rotation can be obtained using the cv2.getRotationMatrix2D() function, and the mapping from the source image to the rotated image can be completed using the cv2.warpAffine() function to realize the rotation of the image.
[0077] It should be noted that, specifically, the non-0 point set is obtained according to the non-0 gray value The minimum circumscribed rectangle of the non-0 point set is obtained, that is, the broken screen region boundary, and the four corner point coordinates (x ri , y ri ), i = 0, 1, 2, 3 are obtained.
[0078] It should be noted that, specifically, according to the four corner point coordinate values, the corner point with the maximum vertical coordinate y ri is named as corner point 0 (zeroth corner point), and the coordinate is (x ri , y ri ). If the two corner points have the same vertical coordinate y ri , the corner point with a smaller horizontal coordinate is named as corner point 0. Subsequently, the remaining three corner points are sequentially named as corner point 1 (first corner point), corner point 2 (second corner point) and corner point 3 (third corner point) in a counterclockwise direction, and the coordinate values are respectively (x r1 , y r1)、(x r2 ,y r2 )、(x r3 ,y r3 ). Calculate the minimum circumscribed rectangle rotation angle based on corner point 0 and corner point 3.
[0079] It should be noted that if the size of the image of the broken screen area to be processed is (w, h), where w is the width and h is the height, then the coordinates of the center point of the image are (w / 2, h / 2). With the center point of the image as the rotation center, the image of the roughly broken screen area is rotated counterclockwise by θ. The image is not scaled and the original size (w, h) is maintained. The missing part after rotation is filled with the boundary pixel value of the rotated grayscale image. After the rotation is completed, the broken screen area has been corrected, and the coordinates of the four corner points of its boundary rectangle (x ri ,y ri ), i=0,1,2,3 is transformed into (x′ ri ,y′ ri ), i = 0, 1, 2, 3, according to the coordinates of the four corner points of the boundary rectangle of the rotated broken code screen area, the broken code screen area, that is, the target broken code screen area image, is segmented.
[0080] It should be noted that since the segmentation is based on the outer edges, the segmented broken screen area inevitably contains some non-background pixels at the edge of the broken screen. These pixels need to be removed to determine the target broken screen area image to a fixed size. Specifically, the segmented broken screen area is cropped to a certain width on all four sides to change it to a uniform size and remove the non-background pixels contained in the segmented broken screen area. It should be noted that the fixed size needs to be changed as conditions such as meter type, camera parameters, and imaging height change. However, for meters of the same type and model under the same imaging conditions, the fixed size remains unchanged. That is, the size is fixed during the single template creation process.
[0081] Step S13: Slide each to-be-matched character picture in the preset character picture library on the target broken code screen area picture for character matching to determine each target character picture that matches the target broken code screen area picture, and determine the target position coordinates of each target character picture in the target broken code screen area picture; the preset character picture library contains each to-be-matched character picture corresponding to different types of electricity meters.
[0082] See also Figure 7 The figure shows a schematic diagram of three character images to be matched in a preset character image library.
[0083] In this embodiment, the preset character picture library is artificially made, each character on the code breaking screen is manually framed and segmented, and a character picture containing only a single character is segmented. It should be noted that one character can have multiple character pictures, and the character pictures can be made from different types of code breaking screen meters to be applied to the template generation of multiple types of code breaking screen meters.
[0084] It should be noted that, since the preset character picture library contains each of the to-be-matched character pictures corresponding to different types of meters, the method of the present application can construct standard templates of code breaking screens of multiple types of meters.
[0085] It should be noted that, when determining the target position coordinates, the upper left corner of the target code breaking screen region picture is taken as the coordinate origin, and the target position coordinates are the coordinates of the upper left corner of the target character picture on the target code breaking screen region picture.
[0086] Step S14: drawing a standard template of a code breaking screen of a target meter based on the target position coordinates and the target character picture.
[0087] It can be seen that, an initial meter picture is obtained, and a to-be-processed code breaking screen region picture is intercepted from the initial meter picture; a code breaking screen boundary in the to-be-processed code breaking screen region picture is determined, so as to determine a forward target code breaking screen region picture based on the code breaking screen boundary; each to-be-matched character picture in a preset character picture library is slid on the target code breaking screen region picture for character matching, so as to determine each target character picture matched with the target code breaking screen region picture and determine target position coordinates of each target character picture in the target code breaking screen region picture; the preset character picture library contains each of the to-be-matched character pictures corresponding to different types of meters; and a standard template of a code breaking screen of a target meter is drawn based on the target position coordinates and the target character picture. The present application matches each to-be-matched character picture in the preset character picture library with the target code breaking screen region picture to determine each target character picture matched with the target code breaking screen region picture, so as to construct a standard template of a code breaking screen of a meter. The present application only needs to construct a standard template of a code breaking screen of a meter through a matching process, which is simple and fast. In addition, since the preset character picture library contains each of the to-be-matched character pictures corresponding to different types of meters, the present application can generate standard templates of code breaking screens of different types of meters.
[0088] The embodiment of the present application discloses a specific method for generating a standard template of a code breaking screen of a meter. Compared with the previous embodiment, the technical solution is further described and optimized. Referring to FIG. 2, Figure 8 and specifically comprising the following steps:
[0089] Step S21: obtaining an initial meter picture and intercepting a to-be-processed code breaking screen region picture from the initial meter picture.
[0090] The more specific process of step S21 can refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.
[0091] Step S22: determining the broken screen boundary in the to-be-processed broken screen region picture, to determine the target broken screen region picture in the forward direction based on the broken screen boundary.
[0092] The more specific process of step S22 can refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.
[0093] Step S23: sliding each to-be-matched character picture in the preset character picture library on the target broken screen region picture for several times of character matching, and calculating the first character matching degree of each matching.
[0094] In this embodiment, the sliding of each to-be-matched character picture in the preset character picture library on the target broken screen region picture for several times of character matching and the calculation of the first character matching degree of each matching include: representing the pixel values of all pixel points in each character picture in the preset character picture library as a first vector in a target order; determining a uniform picture width and a uniform picture height of each character picture in the preset character picture library; constructing several sliding windows based on the uniform picture width and the uniform picture height, with a basic coordinate position as the upper left corner coordinate of the sliding window; the basic coordinate position includes any coordinate combination of an x-axis coordinate range and a y-axis coordinate range; the x-axis coordinate range is from zero to the difference between the target picture width and the uniform picture width; the y-axis coordinate range is from zero to the difference between the target picture height and the uniform picture height; the target picture width and the target picture height are the width and height of the target broken screen region picture; representing the pixel values of all pixel points in the sliding window as a second vector in the target order to obtain the second vector corresponding to each sliding window; sliding each to-be-matched character picture in the preset character picture library on the target broken screen region picture, and when the to-be-matched character picture slides to the sliding window, calculating the first character matching degree based on the first vector of the to-be-matched character picture and the second vector of the sliding window to obtain the first character matching degree between each to-be-matched character picture and each sliding window.
[0095] It should be noted that the target order is to determine the pixel values of each row from left to right as a vector, and to arrange the vectors corresponding to multiple rows of pixel values from top to bottom to obtain the corresponding first vector or second vector. It should be noted that the rightmost value of the previous row of vectors is connected to the leftmost value of the current row of vectors.
[0096] It should be noted that the picture width and picture height of each character picture in the preset character picture library can also not be uniform. In this case, when performing the matching operation on each character picture in a preset character picture library, a separate sliding window needs to be set for the character picture.
[0097] In a specific embodiment, when a character is matched, the size of a corresponding character picture T is w t ×h t , and w t ×h t pixels. The gray values of all the pixels are expressed as a vector in a target order. The size of the to-be-matched picture I is w i ×h i , and w t ×h t is the size of the sliding window. The character picture is matched with the sliding window to calculate the matching degree. Therefore, a sliding window with a size of w t ×h t is taken from the (x, y) position of the picture I, and the gray values of all the pixels in the sliding window are expressed as a vector in an order. The matching degree is:
[0098]
[0099] where (x, y) represents the coordinates of the upper left corner of the sliding window on the picture I, x = 0, 1... w i -w t ; y = 0, 1... h i -h t ; T(x', y') represents the pixel gray value at (x', y') of the character picture T; and I(x+x', y+y') represents the pixel gray value at (x+x', y+y') of the picture I. It should be noted that the matching degree δ(x, y) ∈ [-1, 1], and the closer δ(x, y) is to 1, the better the matching effect is.
[0100] Step S24: determining the highest first character matching degree corresponding to each to-be-matched character picture.
[0101] More specific processing procedures of step S24 can be referred to the corresponding content disclosed in the foregoing embodiments, which will not be described herein again.
[0102] Step S25: If the highest first character matching degree corresponding to the to-be-matched character picture is not less than the matching degree threshold, the to-be-matched character picture is taken as a target character picture matched with the target code screen region picture, and the matching position coordinate when the first character matching degree is the highest is taken as a target position coordinate of the target character picture in the target code screen region picture, so as to determine the target position coordinate of each target character picture in the target code screen region picture.
[0103] In the embodiment, the matching degree threshold is determined according to actual conditions, and is not specifically limited here. In a specific embodiment, the matching degree threshold can be 0.8.
[0104] In the embodiment, after the target position coordinate of each target character picture in the target code screen region picture is determined, if there is no first single character region that fails to be matched successfully in the target code screen region picture, a standard template is directly obtained by drawing.
[0105] In the embodiment, there is a first single character region that fails to be matched successfully in the target code screen region picture, and then matching operation needs to be performed on each first single character region. Specifically, after the target position coordinate of each target character picture in the target code screen region picture is determined, the method further includes: if there is a first single character region that fails to be matched successfully in the target code screen region picture, a single character picture is obtained by manually framing the first single character region; each to-be-matched character picture in a preset character picture library is slid on each single character picture for a plurality of times to perform character matching, and a second character matching degree of each matching is calculated; the highest second character matching degree corresponding to each to-be-matched character picture on each single character picture is determined; if the highest second character matching degree corresponding to the to-be-matched character picture on the single character picture is not less than the matching degree threshold, the to-be-matched character picture is taken as a target character picture corresponding to the single character picture in the target code screen region picture, and a matching position coordinate when the second character matching degree is the highest is taken as a temporary position coordinate of the target character picture in the single character picture, so as to determine the target character picture corresponding to each single character picture and the temporary coordinate position of each target character picture in the corresponding single character picture; based on the temporary position coordinate and a reference coordinate position of each single character picture in the target code screen region picture, a target position coordinate of each target character picture in the target code screen region picture is determined.
[0106] It should be noted that the single character region manually framed is not strictly framed to a single character, and the character picture of the character should be slightly larger, allowing the surrounding characters to be partially framed.
[0107] In this embodiment, after the matching operation is performed on each first single-character region, if there is no second single-character region that fails to match in the target meter code screen region picture, a standard template is directly drawn.
[0108] Step S26: drawing a target meter code screen standard template based on the target position coordinates and the target character picture.
[0109] In this embodiment, after the target position coordinates of each target character picture in the target meter code screen region picture are determined based on the temporary position coordinates and the reference coordinate positions of each single-character picture in the target meter code screen region picture, if there is still a second single-character region that fails to match in the target meter code screen region picture, the drawing of the target meter code screen standard template based on the target position coordinates and the target character picture includes: drawing an initial meter code screen standard template based on the target position coordinates and the target character picture, and manually drawing a character box corresponding to the second single-character region in the initial meter code screen standard template to obtain a target meter code screen standard template.
[0110] In this embodiment, the manual drawing of the character box means manually boxing the character as a character template of the character. The manually drawn character box should only contain the character, and should not include surrounding character boxes.
[0111] It should be noted that in most cases, all characters can be automatically matched successfully.
[0112] It can be seen that the application obtains an initial electric meter picture, and cuts a to-be-processed broken code screen region picture from the initial electric meter picture; determines a broken code screen boundary in the to-be-processed broken code screen region picture, to determine a forward target broken code screen region picture based on the broken code screen boundary; slides each to-be-matched character picture in a preset character picture library on the target broken code screen region picture for a plurality of times of character matching, and calculates a first character matching degree of each time of matching; determines a highest first character matching degree corresponding to each to-be-matched character picture; if the highest first character matching degree corresponding to the to-be-matched character picture is not less than a matching degree threshold, the to-be-matched character picture is taken as a target character picture matched with the target broken code screen region picture, and a matching position coordinate when the first character matching degree is the highest is taken as a target position coordinate of the target character picture in the target broken code screen region picture, to determine the target position coordinate of each target character picture in the target broken code screen region picture; and a target electric meter broken code screen standard template is drawn based on the target position coordinate and the target character picture. The application matches each to-be-matched character picture in the preset character picture library with the target broken code screen region picture to determine target character pictures matched with the target broken code screen region picture, to construct an electric meter broken code screen standard template. The application only needs to construct the electric meter broken code screen standard template through a matching process, which is simple and fast. In addition, since there are to-be-matched character pictures corresponding to different types of electric meters in the preset character picture library, the application can generate electric meter broken code screen standard templates of different types of electric meters. In addition, the application can perform secondary matching after a first matching is unsuccessful, and manually draw a character frame of a second single character picture which is not matched successfully after a second matching is unsuccessful, to ensure the integrity of the target electric meter broken code screen standard template.
[0113] Correspondingly, the application also discloses an electric meter broken code screen standard template generation device, as shown in Figure 9 The device comprises:
[0114] A first picture acquisition module 11 is configured to acquire an initial electric meter picture, and cut a to-be-processed broken code screen region picture from the initial electric meter picture.
[0115] A second picture acquisition module 12 is configured to determine a broken code screen boundary in the to-be-processed broken code screen region picture, to determine a forward target broken code screen region picture based on the broken code screen boundary.
[0116] The third picture acquisition module 13 is configured to slide each to-be-matched character picture in the preset character picture library on the target broken code screen area picture to perform character matching, to determine each target character picture matched with the target broken code screen area picture, and to determine a target position coordinate of each target character picture in the target broken code screen area picture; and the preset character picture library contains each to-be-matched character picture corresponding to different types of electric meters.
[0117] The template drawing module 14 is configured to draw a target electric meter broken code screen standard template based on the target position coordinate and the target character picture.
[0118] The working processes of the above modules are more specifically described in the foregoing embodiments, and thus will not be repeated here.
[0119] It can be seen that the present application acquires an initial electric meter picture, and cuts a to-be-processed broken code screen area picture from the initial electric meter picture; determines a broken code screen boundary in the to-be-processed broken code screen area picture, to determine a forward target broken code screen area picture based on the broken code screen boundary; slides each to-be-matched character picture in a preset character picture library on the target broken code screen area picture to perform character matching, to determine each target character picture matched with the target broken code screen area picture, and to determine a target position coordinate of each target character picture in the target broken code screen area picture; the preset character picture library contains each to-be-matched character picture corresponding to different types of electric meters; and a target electric meter broken code screen standard template is drawn based on the target position coordinate and the target character picture. The present application performs character matching between each to-be-matched character picture in a preset character picture library and the target broken code screen area picture to determine each target character picture matched with the target broken code screen area picture, to thereby construct an electric meter broken code screen standard template. The present application only needs to perform matching to construct an electric meter broken code screen standard template, which is simple and fast. In addition, since the preset character picture library contains each to-be-matched character picture corresponding to different types of electric meters, the present application can generate electric meter broken code screen standard templates of different types of electric meters.
[0120] Further, the present application provides an electronic device. Figure 10 FIG. 1 is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the contents in the figure should not be considered as any limitation on the use range of the present application.
[0121] Figure 10A structural schematic diagram of an electronic device 20 is provided in the embodiments of the present application. The electronic device 20 can specifically include at least one processor 21, at least one memory 22, a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26 and a communication bus 27. The memory 22 is configured to store a computer program, and the processor 21 is configured to load and execute the computer program to implement the related steps in the meter break screen standard template generation method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the embodiments of the present application can be specifically an electronic computer.
[0122] In the embodiments of the present application, the power supply 26 is configured to provide working voltage for each hardware device on the electronic device 20; the communication interface 25 is configured to create a data transmission channel between the electronic device 20 and external devices, and the communication protocol followed by the communication interface 25 can be any communication protocol applicable to the technical solution of the present application, which is not limited specifically herein; the input / output interface 24 is configured to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which is not limited specifically herein.
[0123] In addition, the memory 22 as a carrier for resource storage can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon can include a computer program 221, and the storage mode can be temporary storage or permanent storage. In addition to the computer program capable of completing the meter break screen standard template generation method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 221 can further include a computer program capable of completing other specific work.
[0124] Further, the embodiments of the present application further disclose a computer readable storage medium for storing a computer program, wherein the computer program is executed by a processor to implement the meter break screen standard template generation method disclosed above.
[0125] The specific steps of the method can refer to the corresponding content disclosed in the foregoing embodiments, which will not be repeated here.
[0126] The embodiments in the present application are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts of each embodiment can be referred to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant parts can refer to the method part.
[0127] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality, without referring to a specific sequence of operations for implementing the functions. The order of various illustrative blocks, modules, circuits, and steps may be re-arranged or otherwise implemented without departing from the spirit of the application, which is defined by the appended claims.
[0128] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in random access memory (RAM), flash memory, read-only memory (ROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0129] Finally, it should be noted that the terms "first", "second", and the like, herein do not denote any order, quantity, combination, or importance, but rather are used to distinguish one element from another, and are more especially used for the purpose of distinction from other elements in the specification. Also, the terms "include", "comprise", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements does not include only those elements recited, but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element preceded by "comprises a" does not, without more constraints, foreclose additional identical elements of the process, method, article, or apparatus including the specific element. Any reference to claim "includes something" means that anything can be added thereto.
[0130] The above provides a kind of electric meter broken code screen standard template generation method, device, equipment, storage medium provided in the present application, the principle and implementation mode of the present application are described in this paper by specific example, the above example is only for helping understanding the method of the present application and its core idea;For those skilled in the art, according to the idea of the present application, there will be changes in specific implementation mode and application range, and the above description should not be understood as the limitation of the present application.
Claims
1. A method for generating a standard template for an electric meter's broken code screen, characterized in that: include: Obtain an initial electric meter image, and intercept an image of the to-be-processed broken code screen area from the initial electric meter image; Determining a broken screen boundary in the to-be-processed broken screen area picture, and determining a forward target broken screen area picture based on the broken screen boundary; Slide each to-be-matched character image in a preset character image library on the target broken code screen area image to perform character matching, so as to determine each target character image that matches the target broken code screen area image, and determine the target position coordinates of each target character image in the target broken code screen area image; the preset character image library contains each to-be-matched character image corresponding to different types of electricity meters; Drawing a target meter break code screen standard template based on the target position coordinates and the target character picture; The step of sliding each to-be-matched character image in the preset character image library on the target broken code screen area image to perform character matching to determine target character images that match the target broken code screen area image, and determining target position coordinates of each target character image in the target broken code screen area image, includes: Slide each to-be-matched character image in the preset character image library on the target broken code screen area image to perform character matching several times, and calculate the first character matching degree of each match; Determine the highest first character matching degree corresponding to each of the to-be-matched character images; If the highest matching degree of the first character corresponding to the to-be-matched character picture is not less than a matching degree threshold, the to-be-matched character picture is used as a target character picture to be matched with the target broken code screen area picture, and the matching position coordinates when the first character matching degree is the highest are used as the target position coordinates of the target character picture in the target broken code screen area picture, so as to determine the target position coordinates of each target character picture in the target broken code screen area picture; Wherein, after determining the target position coordinates of each target character picture in the target broken code screen area picture, the method further includes: If there are several first single-character areas that are not successfully matched in the target broken code screen area image, manually select the first single-character areas to obtain several single-character images; Slide each to-be-matched character image in the preset character image library on each of the single character images to perform character matching several times, and calculate the second character matching degree of each match; Determine the highest matching degree of the second character corresponding to each of the to-be-matched character images on each of the single-character images; If the highest matching degree of the second character corresponding to the character picture to be matched on the single character picture is not less than the matching degree threshold, the character picture to be matched is used as one of the target character pictures corresponding to the single character picture in the target broken code screen area picture, and the matching position coordinates when the second character matching degree is the highest are used as the temporary position coordinates of the target character picture in the single character picture, so as to determine the target character picture corresponding to each single character picture and the temporary coordinate position of each target character picture in the corresponding single character picture; Determine the target position coordinates of each target character picture in the target broken code screen area picture based on the temporary position coordinates and the reference coordinate position of each single character picture in the target broken code screen area picture; Wherein, if after determining the target position coordinates of each target character picture in the target broken code screen area picture based on the temporary position coordinates and the reference coordinate position of each single character picture in the target broken code screen area picture, there still exists a second single character area in the target broken code screen area picture that has not been successfully matched, then drawing the target electric meter broken code screen standard template based on the target position coordinates and the target character picture includes: An initial meter code break screen standard template is drawn based on the target position coordinates and the target character picture, and a character frame corresponding to the second single character area is manually drawn in the initial meter code break screen standard template to obtain a target meter code break screen standard template.
2. The method for generating a standard template for an electric meter break code screen according to claim 1, characterized in that: The step of intercepting the image of the to-be-processed broken code screen area from the initial electric meter image includes: grayscale processing is performed on the initial electricity meter image to obtain a grayscale electricity meter image, and a picture of the broken code screen area to be processed is intercepted from the grayscale electricity meter image; Accordingly, the step of determining the boundary of the broken screen in the broken screen area picture to be processed includes: Using the Canny edge detection algorithm to determine the edge map in the image of the broken code screen area to be processed; the edge map includes character edges and broken code screen edges; Determining a grayscale value non-zero region in the edge image, and determining a minimum circumscribed rectangle corresponding to the grayscale value non-zero region; The boundary of the minimum circumscribed rectangle is used as the broken screen boundary, and the corner point position coordinates of the four corner points of the broken screen boundary in the broken screen area picture to be processed are determined.
3. The method for generating a standard template for an electric meter code display according to claim 2, characterized in that: The determining of a positive target broken screen area picture based on the broken screen boundary includes: The corner point with the largest ordinate among the corner point position coordinates of the four corner points is used as the zeroth corner point, or the corner point with the smaller abscissa among the two corner points with the largest ordinate among the corner point position coordinates of the four corner points is used as the zeroth corner point; Taking the zeroth corner point as the starting point, the remaining corner points are determined as the first corner point, the second corner point and the third corner point in a counterclockwise direction; Calculating a rotation angle based on the corner point position coordinates of the zeroth corner point and the corner point position coordinates of the third corner point; Taking the center point of the image of the broken code screen area to be processed as the rotation center, the image of the broken code screen area to be processed is rotated counterclockwise based on the rotation angle to obtain a positive reference broken code screen area image, and the target broken code screen area image is obtained from the reference broken code screen area image based on the four corner points after rotation.
4. The method for generating a standard template for an electric meter code display according to any one of claim 1, characterized in that: The step of sliding each to-be-matched character image in the preset character image library on the target broken code screen area image for several character matches and calculating the first character matching degree of each match includes: Representing the pixel values of all pixels in each character image in the preset character image library as a first vector in target order; Determining a uniform picture width and a uniform picture height of each character picture in the preset character picture library; A plurality of sliding windows are constructed based on the unified picture width and the unified picture height and with the base coordinate position as the upper left corner coordinate of the sliding window; the base coordinate position includes any coordinate combination of the x-axis coordinate range and the y-axis coordinate range; the x-axis coordinate range is from zero to the difference between the target picture width and the unified picture width; the y-axis coordinate range is from zero to the difference between the target picture height and the unified picture height; the target picture width and the target picture height are the width and height of the target broken code screen area picture; Representing pixel values of all pixels within the sliding window as a second vector in the target order to obtain the second vector corresponding to each sliding window; Each to-be-matched character picture in the preset character picture library is slid on the target broken code screen area picture, and when the to-be-matched character picture slides to the sliding window, the first character matching degree is calculated based on the first vector of the to-be-matched character picture and the second vector of the sliding window to obtain the first character matching degree between each to-be-matched character picture and each of the sliding windows.
5. A device for generating a standard template for an electric meter's broken code screen, characterized in that: include: A first image acquisition module is used to acquire an initial electric meter image and intercept an image of a to-be-processed broken code screen area from the initial electric meter image; The second image acquisition module is configured to determine a broken screen boundary in the broken screen area image to be processed, so as to determine a forward target broken screen area image based on the broken screen boundary; a third image acquisition module, configured to slide each to-be-matched character image in a preset character image library on the target broken code screen area image to perform character matching, so as to determine target character images that match the target broken code screen area image, and to determine target position coordinates of each target character image in the target broken code screen area image; the preset character image library contains the to-be-matched character images corresponding to different types of electric meters; A template drawing module, configured to draw a target meter break code screen standard template based on the target position coordinates and the target character image; The third image acquisition module is specifically configured to slide each to-be-matched character image in the preset character image library on the target broken code screen area image to perform character matching several times, and calculate the first character matching degree of each match; Determine the highest first character matching degree corresponding to each of the to-be-matched character images; If the highest matching degree of the first character corresponding to the to-be-matched character picture is not less than a matching degree threshold, the to-be-matched character picture is used as a target character picture to be matched with the target broken code screen area picture, and the matching position coordinates when the first character matching degree is the highest are used as the target position coordinates of the target character picture in the target broken code screen area picture, so as to determine the target position coordinates of each target character picture in the target broken code screen area picture; Wherein, the device for generating a standard template for an electric meter break code screen further includes: a fourth image acquisition module, configured to manually select a plurality of first single-character areas that are not successfully matched in the target broken code screen area image to obtain a plurality of single-character images; Slide each to-be-matched character image in the preset character image library on each of the single character images to perform character matching several times, and calculate the second character matching degree of each match; Determine the highest matching degree of the second character corresponding to each of the to-be-matched character images on each of the single-character images; If the highest matching degree of the second character corresponding to the character picture to be matched on the single character picture is not less than the matching degree threshold, the character picture to be matched is used as one of the target character pictures corresponding to the single character picture in the target broken code screen area picture, and the matching position coordinates when the second character matching degree is the highest are used as the temporary position coordinates of the target character picture in the single character picture, so as to determine the target character picture corresponding to each single character picture and the temporary coordinate position of each target character picture in the corresponding single character picture; Determine the target position coordinates of each target character picture in the target broken code screen area picture based on the temporary position coordinates and the reference coordinate position of each single character picture in the target broken code screen area picture; Among them, if after the target position coordinates of each target character picture in the target broken code screen area picture are determined based on the temporary position coordinates and the reference coordinate position of each single character picture in the target broken code screen area picture, there is still a second single character area in the target broken code screen area picture that has not been successfully matched, then the template drawing module is specifically used to draw the initial meter broken code screen standard template based on the target position coordinates and the target character picture, and manually draw the character box corresponding to the second single character area in the initial meter broken code screen standard template to obtain the target meter broken code screen standard template.
6. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor is used to execute the computer program to implement the method for generating a standard template for an electric meter code screen according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that Used to store a computer program; wherein, when the computer program is executed by a processor, the method for generating a standard template for an electric meter fault code screen according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Image registration method and device, equipment and medium
CN113643180A