Text recognition method and device for express waybill, electronic equipment and storage medium
By identifying express delivery page and barcode information, determining the target rotation angle and area, and rotating the image with text facing up, the problem of low text recognition efficiency in the prior art is solved, and a more efficient text recognition effect is achieved.
Patent Information
- Application Number
- CN202310845144.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-10
- Publication Date
- 2025-01-10
AI Technical Summary
The existing express delivery page sheet text recognition methods are inefficient, mainly because the text is in any position and area of the page sheet, which leads to the low recognition efficiency after scanning the entire page sheet.
By identifying the information of the express delivery page and barcode, the target rotation angle and area are determined, the image is rotated with text facing upward, and only the target area is text-recognized to improve the recognition efficiency.
By rotating the image and identifying only the target area, the efficiency and accuracy of text recognition are improved, the recognition process is simplified, and the dependence on the direction classifier is reduced.
Smart Images

Figure CN119296125A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image recognition, and in particular to a method, device, electronic device and storage medium for text recognition of express delivery labels. Background Art
[0002] During the express delivery process, logistics companies need to identify the information of the sender and the recipient to determine the starting and ending points to ensure that the goods can be delivered to the user correctly. The existing recognition method generally scans the express delivery bill, performs text recognition on the scanned image, obtains the text on the bill, and then determines the information of the sender and the recipient.
[0003] However, the text in the express delivery bill may be at any position on the express delivery bill, and the area occupied by the text in the express delivery bill is relatively small. Recognizing the image obtained by scanning the entire express delivery bill will result in low text recognition efficiency. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a method, device, electronic device and storage medium for text recognition of express delivery bills, which can improve the text recognition efficiency of express delivery bills.
[0005] A first aspect of an embodiment of the present application provides a method for text recognition of an express delivery bill, comprising:
[0006] Identify a target image, and determine the express delivery bill information and barcode information in the target image, wherein the express delivery bill information includes a first position where a center point of the express delivery bill is located and a rotation angle of the express delivery bill, and the barcode information includes the number of barcodes, a second position where a center point of the barcode is located, and a rotation angle of the barcode;
[0007] Determining a target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode, and the number of the barcodes;
[0008] determining a target area according to the first position, the second position, and the number of the barcodes;
[0009] Rotating the target image according to the target rotation angle, and intercepting the target area from the target image; after rotating the target rotation angle, the text in the target image is oriented upward;
[0010] A text recognition result of the target area is determined.
[0011] In one embodiment, determining the target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode, and the number of the barcodes includes:
[0012] The target rotation angle is determined according to the rotation angle of the express delivery label, the rotation angle of the barcode, the number of barcodes and a preset weight coefficient, wherein the preset weight coefficient represents the proportion of the rotation angle of the express delivery label and the rotation angle of the barcode in calculating the target rotation angle.
[0013] In one embodiment, determining the target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode, the number of the barcodes, and a preset weight coefficient includes:
[0014] If the number of the barcodes is 1, a first angle is determined according to the rotation angle of the express delivery form, the rotation angle of the barcode, and a preset weight coefficient, wherein the preset weight coefficient includes a first weight coefficient corresponding to the rotation angle of the express delivery form and a second weight coefficient corresponding to the rotation angle of the barcode, wherein the first weight coefficient is less than the second weight coefficient;
[0015] A target rotation angle is determined according to the first angle and a relative positional relationship between the first position and the second position.
[0016] In one embodiment, determining the target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode, the number of the barcodes, and a preset weight coefficient includes:
[0017] If the number of the barcodes is 2, the second angle is determined according to the first rotation angle of the first barcode, the rotation angle of the express delivery bill, and a preset weight coefficient, and the first barcode is one of the barcodes;
[0018] determining a third angle according to the second angle and a second rotation angle of a second barcode, wherein the second barcode is another barcode;
[0019] A target rotation angle is determined according to the third angle and a relative position relationship between the first position and a center point of the first barcode.
[0020] In one embodiment, a first difference between the first rotation angle and the rotation angle of the express delivery label is smaller than a second difference between the second rotation angle and the rotation angle of the express delivery label.
[0021] In one embodiment, determining the target area according to the first position, the second position, and the number of the barcodes includes:
[0022] If the number of the barcodes is 1, the area separated from the express delivery label by the first straight line is used as the dividing line as the target area, the first straight line passes through the first position and is parallel to the center line of the barcode, and the second position is located in the target area.
[0023] In one embodiment, determining the target area according to the first position, the second position, and the number of the barcodes includes:
[0024] If the number of the barcodes is 2, a first area and a second area symmetrical to the first area are taken as target areas, and the first area is a circumscribed rectangle of a triangle formed by the first position and two of the second positions.
[0025] In one embodiment, determining the text recognition result of the target area includes:
[0026] Performing text detection on the target area to determine a candidate area;
[0027] Perform text recognition on the candidate area to determine a text recognition result of the candidate area.
[0028] A second aspect of an embodiment of the present application provides a text recognition device for an express delivery bill, comprising:
[0029] An image recognition module, used to recognize a target image, and determine the express delivery bill information and barcode information in the target image, wherein the express delivery bill information includes a first position where the center point of the express delivery bill is located and a rotation angle of the express delivery bill, and the barcode information includes the number of barcodes, a second position where the center point of the barcode is located, and a rotation angle of the barcode;
[0030] An angle determination module, used to determine a target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode and the number of the barcodes;
[0031] an area determination module, configured to determine a target area according to the first position, the second position and the number of the barcodes;
[0032] A capture module, used for rotating the target image according to the target rotation angle, and capturing the target area from the target image; after rotating the target rotation angle, the text in the target image is oriented upward;
[0033] The text recognition module is used to determine the text recognition result of the target area.
[0034] A third aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for text recognition of express delivery labels as described in the first aspect above is implemented.
[0035] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the text recognition method for the express delivery bill as described in the first aspect above.
[0036] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the text recognition method for the express delivery bill described in any one of the first aspects above.
[0037] Compared with the prior art, the embodiments of the present application have the following beneficial effects: by performing image recognition on the target image, the center point of the express delivery bill, the rotation angle of the express delivery bill, the number of barcodes, the center point of the barcode, and the rotation angle of the barcode are determined. Then, the target rotation angle is determined according to the rotation angle of the express delivery bill, the rotation angle of the barcode, and the number of barcodes, and the target area is determined according to the center point of the express delivery bill, the center point of the barcode, and the number of barcodes, so that when the types of express delivery bills are different, the target rotation angle can be determined based on the rotation angle of the barcode and the rotation angle of the express delivery bill, and the target area can be determined based on the center point of the barcode and the center point of the express delivery bill. Then, the target image is rotated according to the target rotation angle, and the target area is intercepted from the target image, so that the express delivery bill can be rotated to a direction where the text is facing upward, and text recognition is performed only on the target area to determine the text recognition result of the target area, thereby improving the text recognition efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] 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 are briefly introduced below.
[0039] Figure 1 It is a schematic diagram of the implementation process of the text recognition method of the express delivery bill provided in the embodiment of the present application;
[0040] Figure 2 is a schematic diagram of a method for determining a target rotation angle provided in an embodiment of the present application;
[0041] Figure 3 It is a schematic diagram of a method for determining a target area in the case of one barcode provided in an embodiment of the present application;
[0042] Figure 4is a schematic diagram of a method for determining a target area in the case of two barcodes provided in an embodiment of the present application;
[0043] Figure 5 Schematic diagram of a text recognition device for an express delivery bill provided in an embodiment of the present application;
[0044] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] 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.
[0046] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0047] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0048] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0049] In addition, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0050] In the existing delivery bill recognition method, the entire delivery bill needs to be image recognized, and a direction classifier needs to be used in the text recognition process to recognize texts in different directions, so the text recognition efficiency is low. To this end, the present application provides a text recognition method for express delivery bills, which performs image recognition on the target image, determines the target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode, and the number of barcodes in the recognition result, and determines the target area according to the center point of the express delivery bill, the center point of the barcode, and the number of barcodes, so that when the types or layouts of the express delivery bills are different, the target rotation angle can be determined based on the rotation angle of the barcode and the rotation angle of the bill, and the target area can be determined based on the center point of the barcode and the center point of the bill. Then, the target image is rotated according to the target rotation angle, and the target area is intercepted from the target image, so that the express delivery bill can be rotated to the direction where the text is facing upward, and text recognition is only performed on the target area, and the text recognition result of the target area is determined, thereby improving the text recognition efficiency.
[0051] The following is an exemplary description of the text recognition method for the express delivery bill provided in this application.
[0052] The text recognition method for express delivery bills provided in this application is executed on an electronic device. The electronic device may be a desktop computer, a notebook, a handheld computer, an express delivery cabinet, an express delivery scanner, a wearable device or other terminal.
[0053] Please see attached Figure 1 , a method for text recognition of an express delivery bill provided in an embodiment of the present application includes:
[0054] S101: Identify a target image, and determine the express delivery bill information and barcode information in the target image, wherein the express delivery bill information includes a first position where the center point of the express delivery bill is located and a rotation angle of the express delivery bill, and the barcode information includes the number of barcodes, a second position where the center point of the barcode is located, and a rotation angle of the barcode.
[0055] Specifically, the camera scans one side of the express package face sheet to obtain a target image, which includes an image of the express face sheet. The electronic device obtains the target image from the camera and performs image recognition on the target image.
[0056] In one embodiment, the target image may be first converted into a grayscale image, and then the grayscale image may be averaged, and image recognition may be performed on the averaged image, thereby improving the accuracy of image recognition and solving the problem of dim images.
[0057] In one embodiment, a detection model based on a multi-target recognition algorithm (e.g., an S2A-Net model) can be used to perform image recognition on a target image, and the detection model is a model pre-trained based on training samples. The target image is input into the detection model, and the detection model can output the express delivery bill information and the barcode information at the same time. Compared with the single-target recognition algorithm, the multi-target recognition algorithm can output more information on the bill without increasing the recognition time, and then determine multiple feature points on the bill (i.e., the center point of the scanned bill and the center point of the barcode).
[0058] The rotation angle of the express delivery bill and the rotation angle of the barcode both refer to the rotation angle relative to the preset horizontal direction. Different types of express delivery bills have different numbers of barcodes. If the number of barcodes is greater than 1, the second position where the center point of the barcode is located includes the position where the center point of each barcode is located.
[0059] By performing image recognition on the target image, one express delivery bill information can generally be obtained, that is, there is only one express delivery bill in the target image. If it is determined that the target image includes two express delivery bills, the target image can be segmented to obtain two express delivery bills. Then, a prompt message for the user to select the bill to be recognized is output, and then image recognition is performed on the express delivery bill selected by the user. If it is determined that the target image includes two express delivery bills, a prompt message of recognition error can also be directly output.
[0060] If image recognition is performed on the target image and the image of the express delivery label obtained is incomplete, an abnormal prompt message will be output.
[0061] S102: Determine a target rotation angle according to the rotation angle of the express delivery label, the rotation angle of the barcode, and the number of the barcodes.
[0062] Specifically, the orientation of the text in the express delivery bill corresponds to the orientation of the express delivery bill and the orientation of the barcode. The rotation angle of the text in the express delivery bill can be determined based on the rotation angle of the express delivery bill and the rotation angle of the barcode, and then the target rotation angle can be determined.
[0063] Since the express delivery bill may have wrinkles and distortions, the rotation angle of the express delivery bill obtained by image recognition cannot accurately reflect the actual rotation angle of the express delivery bill. The barcode is parallel to one side of the express delivery bill, so the rotation angle of the barcode is consistent with or 90 degrees different from the rotation angle of the express delivery bill. Therefore, a preset weight coefficient for the rotation angle is set, and the preset weight coefficient represents the proportion of the rotation angle of the express delivery bill and the rotation angle of the barcode in calculating the target rotation angle. The target rotation angle is determined based on the rotation angle of the express delivery bill, the rotation angle of the barcode, the number of barcodes, and the preset weight coefficient, which can improve the accuracy of the obtained target rotation angle.
[0064] In one embodiment, if the number of barcodes is 1, the first angle is determined according to the rotation angle of the express delivery bill, the rotation angle of the barcode, and the preset weight coefficient, and the first angle is the rotation angle required for the bill to rotate to the preset horizontal direction. Afterwards, the angle of the bill relative to the preset horizontal direction is determined according to the relative position relationship between the first position and the second position, and then the target rotation angle is determined to be the first angle or 90 degrees different from the first angle.
[0065] Specifically, if the number of barcodes is 1, the rotation angle of the barcode is consistent with the rotation angle of the express delivery sheet, the rotation angle of the express delivery sheet is sheet_angle1, and the rotation angle of the barcode is bar_angle2. Since the rotation angle of the barcode is more accurate than the rotation angle of the express delivery sheet, a higher weight is assigned to the rotation angle of the barcode. Exemplarily, the preset weight coefficient includes a first weight coefficient corresponding to the rotation angle of the express delivery sheet, and a second weight coefficient corresponding to the rotation angle of the barcode, and the first weight coefficient is less than the second weight coefficient. For example, the first weight coefficient is 0.3, the second weight coefficient is 0.7, and the first angle flat_angle is flat_angle=0.3*sheet_angle1+0.7*bar_angle2. Among them, the values of the first weight coefficient and the second weight coefficient can be determined according to empirical values.
[0066] In other embodiments, the second weight coefficient corresponding to the barcode may also be determined according to the distance between the center point of the barcode and the center point of the express delivery bill. For example, if the distance between the center point of the barcode and the center point of the express delivery bill is less than a set value, the second weight coefficient is reduced; if the distance between the center point of the barcode and the center point of the express delivery bill is greater than the set value, the second weight coefficient is increased.
[0067] In other embodiments, it is also possible to determine whether the barcode is deformed according to the difference between the size of the barcode and the preset size of the barcode, and to determine whether the express delivery bill is deformed according to the difference between the size of the express delivery bill and the preset size of the express delivery bill. If the barcode is deformed, the first weight coefficient is greater than the second weight coefficient, and if the express delivery bill is deformed, the first weight coefficient is less than the second weight coefficient.
[0068] In other embodiments, if the difference between the size of the barcode and the preset size of the barcode is greater than a preset value, the first weight coefficient is 1 and the second weight coefficient is 0. If the difference between the size of the express delivery bill and the preset size of the express delivery bill is greater than a preset value, the first weight coefficient is 0 and the second weight coefficient is 1.
[0069] After obtaining the first angle, determine the angle between the vector starting from the first position and ending at the second position and the preset horizontal direction. If the angle is greater than 180 degrees, determine the target rotation angle angle to be angle = flat_angle + 90. If the angle is less than 180 degrees, determine the target rotation angle to be equal to the first angle.
[0070] In one embodiment, if the number of barcodes is 1, first determine the difference between the rotation angle of the express delivery sheet and the rotation angle of the barcode. If the difference is less than the preset value, determine that the rotation angle of the barcode is consistent with the rotation angle of the express delivery sheet, use the above method to determine the first angle, and then obtain the target rotation angle. If the difference is greater than the preset value, the first angle flat_angle is flat_angle = 0.3*sheet_angle1+0.7*(bar_angle2+90), and the target rotation angle can be obtained based on the first angle. Therefore, when the layout of the barcode of the express delivery sheet changes, the accurate target rotation angle can also be obtained.
[0071] like Figure 2 As shown, in one embodiment, if the number of barcodes is 2, the two barcodes are perpendicular to each other, one barcode 21 is a horizontal barcode, and the other barcode 22 is a vertical barcode. The horizontal barcode is used as the first barcode, and the vertical barcode is used as the second barcode. After the two barcodes are identified, the difference between the rotation angles of the two barcodes and the rotation angle of the express delivery bill can be determined, and the smaller difference is used as the first difference, and the larger difference is used as the second difference. The rotation angle corresponding to the first difference is the first rotation angle of the first barcode, and the rotation angle corresponding to the second difference is the second rotation angle of the second barcode. That is, the first difference between the first rotation angle and the rotation angle of the express delivery bill is less than the second difference between the second rotation angle and the rotation angle of the express delivery bill.
[0072] In other possible implementations, a barcode that is consistent with the short side of the express delivery bill may be used as the first barcode, and a barcode that is consistent with the long side of the express delivery bill may be used as the second barcode. Alternatively, a barcode whose distance from the center point of the express delivery bill is a first preset value may be used as the first barcode, and a barcode whose distance from the center point of the express delivery bill is a second preset value may be used as the second barcode.
[0073] After determining the first barcode and the second barcode, determine the second angle according to the first rotation angle of the first barcode, the rotation angle of the express delivery sheet, and the preset weight coefficient. The second angle is the rotation angle required for the delivery sheet to rotate to the horizontal direction. Specifically, a higher weight is assigned to the rotation angle of the barcode. For example, the weight of the rotation angle of the barcode is 0.7, the rotation angle of the express delivery sheet is sheet_angle1, the first rotation angle is bar_angle2, and the second angle flat_angle is flat_angle=0.3*sheet_angle1+0.7*bar_angle2. Among them, the weight corresponding to the rotation angle of the express delivery sheet and the weight corresponding to the first rotation angle can be determined based on empirical values.
[0074] In other embodiments, the distribution method of the weight corresponding to the rotation angle of the express delivery label and the weight corresponding to the first rotation angle can also be determined according to the distance between the center point of the express delivery label and the center point of the barcode, or according to the degree of deformation of the express delivery label and the degree of deformation of the barcode.
[0075] After the second angle is obtained, the third angle is determined according to the second angle and the second rotation angle of the second barcode. The third angle is a corrected angle of the second angle, so that the accuracy of the target rotation angle obtained subsequently can be further improved. Specifically, the second rotation angle is bar_angle3, and the difference angle_distance between the second angle and the second rotation angle is determined according to the formula angle_distance=flat_angle-bar_angle3, and the third angle flat_angle2 is flat_angle+angle_distance / 2.
[0076] After obtaining the third angle, the target rotation angle is determined according to the third angle and the relative positional relationship between the first position and the center point of the first barcode. Specifically, the angle between the vector starting from the first position and the center point of the first barcode and the preset horizontal direction is determined. If the angle is greater than 180 degrees, the target rotation angle angle is determined to be angle=flat_angle2+90. If the angle is less than 180 degrees, the target rotation angle is determined to be equal to the third angle.
[0077] In the above embodiment, different target rotation angles are determined for different forms of express delivery labels according to the recognition result of the target image, so that different forms of express delivery labels can be rotated to a direction with the text facing upward.
[0078] S103: Determine a target area according to the first position, the second position, and the number of the barcodes.
[0079] Specifically, the target area is the area where the text on the express delivery bill is located, and the relative position of the text on the bill, or the relative position of the text and the barcode, can be preset. Therefore, the target area where the text is located can be determined based on the first position where the center point of the express delivery bill is located and the second position where the center point of the barcode is located.
[0080] In one embodiment, if the number of the barcode is 1, the area segmented from the express delivery bill with the first straight line as the segmentation line is used as the target area, the first straight line passes through the first position and is parallel to the center line of the barcode, and the second position is located in the target area. Figure 3 As shown, the barcode 31 is parallel to one side of the express delivery bill. A straight line passing through the first position where the center point of the express delivery bill is located and parallel to the midline of the barcode is taken as the first straight line 32. The express delivery bill is divided along the first straight line, and the half where the center point of the barcode is located after division is taken as the target area.
[0081] If the number of barcodes is 2, the first area and the second area symmetrical to the first area are taken as the target area, and the first area is the circumscribed rectangle of the triangle formed by the first position and the two second positions. Figure 4 As shown, the two barcodes are a horizontal barcode 41 and a vertical barcode 42, respectively. The center points of the two barcodes and the center point of the express delivery bill form a triangle 43. The circumscribed rectangle of the triangle is taken as the first area, and the area symmetrical to the first area about the midline of the vertical direction of the express delivery bill is taken as the second area. The first area and the second area are the target areas. Among them, the vertices of the circumscribed rectangle of the triangle can be determined according to the text layout information of the express delivery bill. The center points of the two barcodes can be taken as the vertices of the circumscribed rectangle, or the center point of one of the barcodes and the center point of the express delivery bill can be taken as the vertices of the circumscribed rectangle.
[0082] S104: rotating the target image according to the target rotation angle, and intercepting the target area from the target image; after rotating the target rotation angle, the text in the target image is oriented upward.
[0083] Specifically, by rotating and intercepting the target image, a target area including text with the text oriented upward can be obtained, which can improve the subsequent text recognition efficiency.
[0084] S105: Determine the text recognition result of the target area.
[0085] In one embodiment, text detection is performed on the target area to determine candidate areas, where text may exist. Feature extraction can be performed on the candidate areas to determine candidate areas with consistent text features, and the number of candidate areas can be one or more.
[0086] After determining the candidate area, the electronic device performs text recognition on the candidate area. Among them, a text recognition model can be used to recognize text in the candidate area, and the text recognition model is a model that can only recognize text facing upward. In one embodiment, if the text recognition model cannot recognize the text, the target area can be rotated 90 degrees or 180 degrees before performing text recognition, or an error prompt message can be directly output.
[0087] After performing text recognition on the candidate area, the electronic device may directly output the text obtained by recognizing the candidate area, or may output the information of the recipient or sender based on the recognized text.
[0088] In another embodiment, text recognition may also be performed on the entire target area.
[0089] In the above embodiment, after obtaining the target image of the express delivery bill, the target rotation angle and target area are first determined according to the features of the express delivery bill and the features of the barcode, the target image is rotated according to the target rotation angle, and the target area in the target image is intercepted, thereby obtaining an area containing text and with the text facing upward, thereby eliminating the step of using a direction classifier for classification in subsequent text recognition, simplifying the text recognition process and improving recognition efficiency. At the same time, since the target rotation angle and target area are determined based on the center point and rotation angle of the express delivery bill information and the center point and rotation angle of the barcode, the probability of the existence of text in the target area can be increased, thereby improving the accuracy of text recognition.
[0090] 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.
[0091] Corresponding to the text recognition method of the express delivery bill described in the above embodiment, Figure 5 A structural block diagram of a text recognition device for an express delivery bill provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0092] like Figure 5 As shown, the text recognition device for the express delivery bill includes:
[0093] An image recognition module 51 is used to recognize a target image and determine the express delivery bill information and barcode information in the target image, wherein the express delivery bill information includes a first position where the center point of the express delivery bill is located and a rotation angle of the express delivery bill, and the barcode information includes the number of barcodes, a second position where the center point of the barcode is located and a rotation angle of the barcode;
[0094] An angle determination module 52, used to determine a target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode and the number of the barcodes;
[0095] An area determination module 53, configured to determine a target area according to the first position, the second position and the number of the barcodes;
[0096] The interception module 54 is used to rotate the target image according to the target rotation angle and intercept the target area from the target image; after rotating the target rotation angle, the text in the target image is oriented upward;
[0097] The text recognition module 55 is used to determine the text recognition result of the target area.
[0098] In one embodiment, the angle determination module 52 is specifically configured to:
[0099] The target rotation angle is determined according to the rotation angle of the express delivery label, the rotation angle of the barcode, the number of the barcodes and a preset weight coefficient, wherein the preset weight coefficient represents the proportion of the rotation angle of the express delivery label and the rotation angle of the barcode in calculating the target rotation angle.
[0100] In one embodiment, the angle determination module 52 is specifically configured to:
[0101] If the number of the barcodes is 1, a first angle is determined according to the rotation angle of the express delivery form, the rotation angle of the barcode, and a preset weight coefficient, wherein the preset weight coefficient includes a first weight coefficient corresponding to the rotation angle of the express delivery form and a second weight coefficient corresponding to the rotation angle of the barcode, wherein the first weight coefficient is less than the second weight coefficient;
[0102] A target rotation angle is determined according to the first angle and a relative positional relationship between the first position and the second position.
[0103] In one embodiment, the angle determination module 52 is specifically configured to:
[0104] If the number of the barcodes is 2, the second angle is determined according to the first rotation angle of the first barcode, the rotation angle of the express delivery bill, and a preset weight coefficient, and the first barcode is one of the barcodes;
[0105] determining a third angle according to the second angle and a second rotation angle of a second barcode, wherein the second barcode is another barcode;
[0106] A target rotation angle is determined according to the third angle and a relative position relationship between the first position and a center point of the first barcode.
[0107] In one embodiment, a first difference between the first rotation angle and the rotation angle of the express delivery label is smaller than a second difference between the second rotation angle and the rotation angle of the express delivery label.
[0108] In one embodiment, the region determination module 53 is specifically used for:
[0109] If the number of the barcodes is 1, the area separated from the express delivery label by the first straight line is used as the dividing line as the target area, the first straight line passes through the first position and is parallel to the center line of the barcode, and the second position is located in the target area.
[0110] In one embodiment, the region determination module 53 is specifically used for:
[0111] If the number of the barcodes is 2, a first area and a second area symmetrical to the first area are taken as target areas, and the first area is a circumscribed rectangle of a triangle formed by the first position and two of the second positions.
[0112] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units 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.
[0113] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0114] like Figure 6 As shown, the electronic device of this embodiment includes: a processor 61, a memory 62, and a computer program 63 stored in the memory 62 and executable on the processor 61. When the processor 61 executes the computer program 63, the steps of the text recognition method of the above-mentioned express delivery bill are implemented, for example Figure 1 Alternatively, when the processor 61 executes the computer program 63, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 5 The functions of the image recognition module 51 to the text recognition module 55 are shown.
[0115] Exemplarily, the computer program 63 may be divided into one or more modules / units, which are stored in the memory 62 and executed by the processor 61 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 63 in the electronic device.
[0116] Those skilled in the art will understand that Figure 6 These are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0117] The processor 61 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0118] The memory 62 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 62 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 62 may also include both an internal storage unit of the electronic device and an external storage device. The memory 62 is used to store the computer program and other programs and data required by the electronic device. The memory 62 may also be used to temporarily store data that has been output or is to be output.
[0119] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0120] 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.
[0121] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the 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.
[0122] 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.
[0123] If the integrated module / 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, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. 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 include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0124] 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.
[0125] The embodiments described above 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 all be included in the protection scope of the present application.
Claims
1. A method for text recognition of express delivery labels, characterized in that: include: Identify a target image, and determine the express delivery bill information and barcode information in the target image, wherein the express delivery bill information includes a first position where a center point of the express delivery bill is located and a rotation angle of the express delivery bill, and the barcode information includes the number of barcodes, a second position where a center point of the barcode is located, and a rotation angle of the barcode; Determining a target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode, and the number of the barcodes; determining a target area according to the first position, the second position, and the number of the barcodes; Rotating the target image according to the target rotation angle, and intercepting the target area from the target image; After rotating the target rotation angle, the text in the target image is oriented upward; A text recognition result of the target area is determined.
2. The method according to claim 1, characterized in that The determining the target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode and the number of the barcodes includes: The target rotation angle is determined according to the rotation angle of the express delivery label, the rotation angle of the barcode, the number of barcodes and a preset weight coefficient, wherein the preset weight coefficient represents the proportion of the rotation angle of the express delivery label and the rotation angle of the barcode in calculating the target rotation angle.
3. The method according to claim 2, characterized in that The determining of the target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode, the number of the barcodes and a preset weight coefficient includes: If the number of the barcodes is 1, a first angle is determined according to the rotation angle of the express delivery form, the rotation angle of the barcode, and a preset weight coefficient, wherein the preset weight coefficient includes a first weight coefficient corresponding to the rotation angle of the express delivery form and a second weight coefficient corresponding to the rotation angle of the barcode, wherein the first weight coefficient is less than the second weight coefficient; A target rotation angle is determined according to the first angle and a relative positional relationship between the first position and the second position.
4. The method according to claim 2, characterized in that: The determining of the target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode, the number of the barcodes and a preset weight coefficient includes: If the number of the barcodes is 2, the second angle is determined according to the first rotation angle of the first barcode, the rotation angle of the express delivery bill, and a preset weight coefficient, and the first barcode is one of the barcodes; determining a third angle according to the second angle and a second rotation angle of a second barcode, wherein the second barcode is another barcode; A target rotation angle is determined according to the third angle and a relative position relationship between the first position and a center point of the first barcode.
5. The method according to claim 4, characterized in that A first difference between the first rotation angle and the rotation angle of the express delivery bill is smaller than a second difference between the second rotation angle and the rotation angle of the express delivery bill.
6. The method according to claim 1, characterized in that The determining the target area according to the first position, the second position and the number of the barcodes includes: If the number of the barcodes is 1, the area separated from the express delivery label by the first straight line is used as the dividing line as the target area, the first straight line passes through the first position and is parallel to the center line of the barcode, and the second position is located in the target area.
7. The method according to claim 1, characterized in that The determining the target area according to the first position, the second position and the number of the barcodes includes: If the number of the barcodes is 2, a first area and a second area symmetrical to the first area are taken as target areas, and the first area is a circumscribed rectangle of a triangle formed by the first position and two of the second positions.
8. A text recognition device for express delivery labels, characterized in that: include: An image recognition module, used to recognize a target image, and determine the express delivery bill information and barcode information in the target image, wherein the express delivery bill information includes a first position where the center point of the express delivery bill is located and a rotation angle of the express delivery bill, and the barcode information includes the number of barcodes, a second position where the center point of the barcode is located, and a rotation angle of the barcode; An angle determination module, used to determine a target rotation angle according to the rotation angle of the express delivery bill, the rotation angle of the barcode and the number of the barcodes; an area determination module, configured to determine a target area according to the first position, the second position and the number of the barcodes; A capture module, used for rotating the target image according to the target rotation angle, and capturing the target area from the target image; After rotating the target rotation angle, the text in the target image is oriented upward; The text recognition module is used to determine the text recognition result of the target area.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for text recognition of the express delivery bill as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for text recognition of an express delivery bill as described in any one of claims 1 to 7 is implemented.