A method and apparatus for identifying a document image

By matching a preset template with the ticket image, the target recognition area is generated and determined, which solves the problem of incorrect cropping of the recognition area in ticket image recognition and improves the accuracy and efficiency of OCR recognition.

CN114743207BActive Publication Date: 2025-11-07SHENZHEN YIHUA COMP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210320570.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-29
Publication Date
2025-11-07
Estimated Expiration
2042-03-29

AI Technical Summary

Technical Problem

In existing technologies, the accuracy of OCR recognition is affected by errors in the cropping of the area to be recognized due to unstable printing equipment and improper placement of tickets.

Method used

By matching a preset template with the ticket image, an initial region to be identified is generated. The target region to be identified is then determined using bounding rectangle and projection techniques, eliminating interference factors and improving recognition accuracy.

Benefits of technology

It improves the accuracy and efficiency of OCR recognition, is suitable for image recognition of various documents, and has strong versatility and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114743207B_ABST
    Figure CN114743207B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a kind of bill image recognition method and device, the method comprises: first, call preset template, obtain the initial to be identified area of bill image by matching preset template with bill image, wherein, initial to be identified area includes multiple characters, when determining that multiple characters include printed character, the contour of multiple characters is generated circumscribed rectangle, then target circumscribed rectangle is determined from multiple characters' circumscribed rectangle, horizontal projection and vertical projection are carried out to target circumscribed rectangle, obtain the boundary of printed character, again, the area formed by boundary is determined as the target to be identified area of bill image, finally, the printed character of target to be identified area is identified.The embodiment of the present application is suitable for the image recognition of various bills, has strong universality and stability, can solve the problem that to be identified area is intercepted wrong due to printing equipment, operation is not standard, improve the accuracy of OCR identification, improve the efficiency of algorithm execution.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image recognition, in particular to a bill image recognition method and device. BACKGROUND

[0002] OCR (Optical Character Recognition) refers to a process in which an electronic device checks characters printed on paper, determines the shape thereof by detecting light and dark patterns, and then translates the shape into computer text by using character recognition methods.

[0003] Before OCR recognition, it is necessary to determine a target region of a printed element to be recognized on a bill. A common method is to first intercept a fixed region, then perform binarization, and then find a connected domain. An external rectangle is found from the connected domain, and the external rectangle is used as a target region, so as to perform subsequent OCR recognition.

[0004] However, due to unstable printing of a printing device or non-standard placement of a bill, the printed content is shifted up and down or left and right, so that it cannot be accurately printed in a specified region. Therefore, the intercepted fixed region is prone to position interception errors. In addition, due to the interference of factors such as horizontal lines, ink, and background texture in the region, the intercepted region is too large or too small, thereby affecting the accuracy of subsequent OCR recognition. SUMMARY

[0005] In view of the above problems, the embodiments of the present application provide a bill image recognition method to solve the problem of incorrect interception of a region to be recognized due to non-standard printing device and operation.

[0006] The embodiments of the present application also provide a bill image recognition device to ensure implementation of the above method.

[0007] The embodiments of the present application disclose a bill image recognition method, which comprises:

[0008] A preset template is called, and the preset template is matched with the bill image to obtain an initial region to be recognized of the bill image; the initial region to be recognized includes a plurality of characters;

[0009] When it is determined that the plurality of characters include printed characters, an external rectangle is generated for the contour of the plurality of characters, and a target external rectangle is determined from the external rectangle of the plurality of characters;

[0010] Horizontal projection and vertical projection are performed on the target external rectangle to obtain a boundary of the printed characters, and a region formed by the boundary is determined as a target region to be recognized of the bill image;

[0011] recognize a printed character in the target region to be recognized.

[0012] Optionally, the bill image includes a printed character, and the preset template includes a preset character. The matching of the preset template with the bill image to obtain an initial region to be recognized of the bill image includes:

[0013] determining a target preset character matching the printed character;

[0014] determining a position of the target preset character as a position of the printed character;

[0015] offsetting the position of the printed character to obtain an initial position to be recognized;

[0016] generating an initial region to be recognized of the bill image according to the initial position to be recognized.

[0017] Optionally, the method further includes:

[0018] binarizing the bill image under different light sources and different color channels to obtain a plurality of first binary images;

[0019] respectively for the plurality of first binary images, counting a number of pixel points with a target pixel value in each row of the initial region to be recognized;

[0020] if the number of pixel points is greater than a first number threshold, determining a row in which the number of pixel points is located as a valid row;

[0021] determining a number of rows of consecutive valid rows;

[0022] if the number of rows is greater than a second number threshold, determining that the plurality of characters include printed characters;

[0023] if the number of rows is not greater than the second number threshold, determining that the plurality of characters do not include printed characters.

[0024] Optionally, the method further includes:

[0025] obtaining a plurality of binarization thresholds with pixel values decreasing;

[0026] respectively binarizing the bill image by using the plurality of binarization thresholds with pixel values decreasing to obtain a plurality of second binary images;

[0027] selecting a second binary image from the plurality of second binary images as a target binary image in an order from large to small of pixel values;

[0028] the generating of the circumscribed rectangle according to the contour of the plurality of characters includes:

[0029] The step of generating a circumscribed rectangle for the contours of the plurality of characters is performed using the target binary image.

[0030] Optionally, the step of determining a target circumscribed rectangle from the plurality of circumscribed rectangles comprises:

[0031] determining a height of the circumscribed rectangle of the plurality of characters;

[0032] determining the circumscribed rectangle with a height within a first preset range as the target circumscribed rectangle.

[0033] Optionally, the step of performing horizontal projection and vertical projection on the target circumscribed rectangle to obtain the boundary of the printed character comprises:

[0034] based on the horizontal projection, traversing each row of the target circumscribed rectangle to determine a plurality of pairs of upper and lower boundaries;

[0035] determining a target pair of upper and lower boundaries from the plurality of pairs of upper and lower boundaries;

[0036] based on the vertical projection, traversing each column between the target pair of upper and lower boundaries to determine a plurality of pairs of left and right boundaries;

[0037] determining a target pair of left and right boundaries from the plurality of pairs of left and right boundaries;

[0038] the step of determining the region formed by the boundary as the target region to be recognized of the bill image comprises:

[0039] the step of determining the region formed by the target pair of upper and lower boundaries and the target pair of left and right boundaries as the target region to be recognized of the bill image.

[0040] Optionally, the step of determining a target pair of upper and lower boundaries from the plurality of pairs of upper and lower boundaries comprises:

[0041] determining a height of each pair of upper and lower boundaries;

[0042] determining the pair of upper and lower boundaries with a height within a second preset range as the target pair of upper and lower boundaries;

[0043] the step of determining a target pair of left and right boundaries from the plurality of pairs of left and right boundaries comprises:

[0044] determining a width of each pair of left and right boundaries;

[0045] determining the pair of left and right boundaries with a width within a third preset range as the target pair of left and right boundaries.

[0046] Optionally, the method further comprises:

[0047] When the target outer-rectangular, the target upper and lower boundary, or the target left and right boundary does not exist, a next second binary image is selected as a target binary image from the plurality of second binary images in an order of pixel values from large to small.

[0048] The embodiment of the application further discloses a bill image recognition device, the device comprises:

[0049] An initial to-be-recognized region obtaining module is configured to call a preset template and match the preset template with the bill image to obtain an initial to-be-recognized region of the bill image; the initial to-be-recognized region comprises a plurality of characters.

[0050] A target outer-rectangular determining module is configured to, when it is determined that the plurality of characters comprise printed characters, generate an outer-rectangular for the contour of the plurality of characters, and determine a target outer-rectangular from the outer-rectangular of the plurality of characters.

[0051] A target to-be-recognized region determining module is configured to perform horizontal projection and vertical projection on the target outer-rectangular to obtain a boundary of the printed characters, and determine a region formed by the boundary as a target to-be-recognized region of the bill image.

[0052] An identifying module is configured to identify the printed characters in the target to-be-recognized region.

[0053] Optionally, the bill image comprises printed characters, the preset template comprises preset characters, and the initial to-be-recognized region obtaining module comprises:

[0054] A matching sub-module is configured to determine a target preset character matched with the printed character.

[0055] A position determining sub-module is configured to determine the position of the target preset character as the position of the printed character.

[0056] An offsetting sub-module is configured to offset the position of the printed character to obtain an initial to-be-recognized position.

[0057] An initial to-be-recognized region generating sub-module is configured to generate an initial to-be-recognized region of the bill image according to the initial to-be-recognized position.

[0058] Optionally, the device further comprises:

[0059] A first binary image obtaining module is configured to binarize the bill image under different light sources and different color channels to obtain a plurality of first binary images.

[0060] A pixel point number counting module is configured to count the number of pixel points with a target pixel value in each row of the initial to-be-recognized region for the plurality of first binary images, respectively.

[0061] An effective row determination module is configured to determine a row in which the number of pixel points is located as an effective row if the number of pixel points is greater than a first number threshold.

[0062] A row number determination module is configured to determine a row number of consecutive effective rows.

[0063] A first printed character determination module is configured to determine that the plurality of characters include a printed character if the row number is greater than a second number threshold.

[0064] A second printed character determination module is configured to determine that the plurality of characters do not include a printed character if the row number is not greater than the second number threshold.

[0065] Optionally, the device further comprises:

[0066] A binarization threshold acquisition module is configured to acquire a plurality of binarization thresholds in descending order of pixel value.

[0067] A second binary image obtaining module is configured to perform binarization on the bill image respectively by using the plurality of binarization thresholds in descending order of pixel value to obtain a plurality of second binary images.

[0068] A first target binary image selection module is configured to select a second binary image from the plurality of second binary images as a target binary image in descending order of pixel value.

[0069] The target bounding rectangle determination module comprises:

[0070] A bounding rectangle generation submodule is configured to perform the contour generation bounding rectangle step on the plurality of characters by using the target binary image.

[0071] Optionally, the target bounding rectangle determination module comprises:

[0072] A height determination submodule of the bounding rectangle is configured to determine a height of the bounding rectangle of the plurality of characters.

[0073] A target bounding rectangle determination submodule is configured to determine a bounding rectangle with a height within a first preset range as a target bounding rectangle.

[0074] Optionally, the target to-be-recognized region determination module comprises:

[0075] A first traversal submodule is configured to traverse each row of the target bounding rectangle based on horizontal projection to determine a plurality of pairs of upper and lower boundaries.

[0076] A target upper and lower boundary determination submodule is configured to determine a target upper and lower boundary from the plurality of pairs of upper and lower boundaries.

[0077] The second traversing submodule is configured to traverse each column between the target upper and lower boundaries based on vertical projection to determine a plurality of pairs of left and right boundaries.

[0078] The target left and right boundary determining submodule is configured to determine target left and right boundaries from the plurality of pairs of left and right boundaries.

[0079] The target region to be recognized determining module comprises:

[0080] The target region to be recognized determining submodule is configured to determine a region formed by the target upper and lower boundaries and the target left and right boundaries as the target region to be recognized of the bill image.

[0081] Optionally, the target left and right boundary determining submodule comprises:

[0082] The height determining unit of the upper and lower boundaries is configured to determine the height of each pair of upper and lower boundaries.

[0083] The target upper and lower boundary determining unit is configured to determine the upper and lower boundaries with the height in the second preset range as the target upper and lower boundaries.

[0084] The target left and right boundary determining submodule comprises:

[0085] The width determining unit of the left and right boundaries is configured to determine the width of each pair of left and right boundaries.

[0086] The target left and right boundary determining unit is configured to determine the left and right boundaries with the width in the third preset range as the target left and right boundaries.

[0087] Optionally, the device further comprises:

[0088] The second target binary image selecting module is configured to select the next second binary image as the target binary image from the plurality of second binary images in descending order of pixel value when the target bounding rectangle, the target upper and lower boundaries or the target left and right boundaries do not exist.

[0089] The embodiment of the application further discloses an electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus.

[0090] The memory is configured to store a computer program.

[0091] The processor is configured to execute the program stored on the memory to implement the method as described in the embodiment of the application.

[0092] The embodiment of the present application further discloses a computer readable storage medium, which stores instructions, and the instructions, when executed by one or more processors, cause the processors to perform the method according to the embodiment of the present application.

[0093] Compared with the prior art, the embodiment of the present application has the following advantages:

[0094] In the embodiment of the present application, a preset template is first called, the preset template is matched with the bill image, and an initial to-be-recognized region of the bill image is obtained, wherein the initial to-be-recognized region includes a plurality of characters; when it is determined that the plurality of characters include printed characters, a circumscribed rectangle is generated for the contours of the plurality of characters; then a target circumscribed rectangle is determined from the circumscribed rectangle of the plurality of characters; horizontal projection and vertical projection are performed on the target circumscribed rectangle, the boundary of the printed characters is obtained, the region formed by the boundary is determined as a target to-be-recognized region of the bill image, and finally the printed characters in the target to-be-recognized region are recognized. The embodiment of the present application is suitable for image recognition of various bills, has strong universality and stability, can solve the problem of incorrect to-be-recognized region interception caused by non-standard printing equipment and operation, improve the accuracy of OCR recognition, and improve the efficiency of algorithm execution. BRIEF DESCRIPTION OF DRAWINGS

[0095] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without any creative effort on the basis of these drawings.

[0096] Figures 1A-1B is a to-be-recognized region interception schematic diagram in the prior art;

[0097] Figure 2 is a step flowchart of a bill image recognition method provided by the embodiment of the present application;

[0098] Figure 3 is a bill image schematic diagram provided by the embodiment of the present application;

[0099] Figure 4 is a template matching schematic diagram provided by the embodiment of the present application;

[0100] Figures 5A-5B is a first binary diagram provided by the embodiment of the present application;

[0101] Figure 6 is a circumscribed rectangle schematic diagram provided by the embodiment of the present application;

[0102] Figures 7A-7C is an effect display diagram provided by the embodiment of the present application;

[0103] Figure 8 is a bill image recognition flowchart provided by an embodiment of the present application;

[0104] Figure 9 is a structural block diagram of a bill image recognition device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0105] The technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts fall within the scope of the present application.

[0106] In the recycling of checks, deposit receipts, and account statements, and the reimbursement of invoices, the staff needs to check the printed information on the bill. Manual checking consumes a lot of time, resulting in low efficiency and easy errors.

[0107] OCR can well solve the problems of low efficiency and easy errors in manual checking. Generally, before OCR recognition, the region to be recognized needs to be intercepted on the bill, so that the OCR recognizes the characters in the region to be recognized.

[0108] Reference Figures 1A-1B shows a schematic diagram of interception of a region to be recognized in the prior art, wherein, Figure 1A is due to unstable printing of the printing device or non-standard placement of the bill, the printed content is shifted up and down or left and right, so that it cannot be accurately printed in the specified region. Therefore, the intercepted fixed region is prone to position interception errors, as shown in A1-A3 regions in Figure 1A . In addition, Figure 1B is due to the existence of horizontal lines, ink, background texture and other irrelevant factors on the bill surface. Therefore, using connected domain searching, the region to be recognized is prone to be too large or too small due to the interference of horizontal lines, ink, background texture and other irrelevant factors, as shown in B1-B3 regions in Figure 1B . It can be seen that the above two cases will affect the accuracy of subsequent OCR recognition.

[0109] In view of the problems of easy interception errors caused by directly intercepting a fixed region and easy interference caused by other irrelevant factors on the bill surface in the prior art, an embodiment of the present application provides a bill image recognition method, which can be applied to image recognition of various bills, has strong universality and stability, can solve the problem of interception errors of the region to be recognized caused by unstable printing devices and non-standard operation, improve the accuracy of OCR recognition, and improve the efficiency of algorithm execution.

[0110] Referring to Figure 2 , a step flow chart of a bill image recognition method provided by an embodiment of the present application is shown, which can specifically include the following steps:

[0111] Step 201, a preset template is called and matched with the bill image to obtain an initial to-be-recognized region of the bill image; the initial to-be-recognized region includes multiple characters.

[0112] In the embodiment of the present application, the bill image can be applied to a bill device, the bill to be recognized can be placed on the bill device, and the bill device can scan the bill to obtain the bill image of the bill. Wherein, the bill image can be a white light image scanned under white light, and the bill device can set the white light image as a gray image, so that subsequent template matching steps can be performed on the gray image.

[0113] As an example, referring to Figure 3 , a bill image schematic diagram provided by an embodiment of the present application is shown, wherein the bill image can include printed characters, printed characters, horizontal lines, inks, background textures and other elements, wherein the printed characters can be "name", "account number", "amount", "XX bank", "XX seal" and the like, and the printed characters can be "Xiaohua", "111111111111111111", "one thousand yuan", "1000.00" and the like.

[0114] The printed characters are the objects to be recognized by the subsequent OCR, therefore, the embodiment of the present application can call a preset template, and by matching the preset template with the bill image, an initial to-be-recognized region of the bill image can be obtained, wherein the initial to-be-recognized region can include multiple characters, and the characters can include printed characters and printed characters, and the initial to-be-recognized region can also include horizontal lines, inks, background textures and other elements.

[0115] In an optional embodiment of the present application, the bill image includes printed characters, and the preset template includes preset characters, and step 201 can include the following sub-steps:

[0116] Sub-step S11, determining a target preset character matched with the printed character;

[0117] Sub-step S12, determining the position of the target preset character as the position of the printed character;

[0118] Sub-step S13, offsetting the position of the printed character to obtain an initial to-be-recognized position;

[0119] Sub-step S14, generating an initial to-be-recognized region of the bill image according to the initial to-be-recognized position.

[0120] In the embodiment of the present application, the bill image can include a plurality of printed characters, and can be for various types of bills, such as checks, deposit certificates, deposit slips, and the like, and can also be for the same type of bill published by different companies or different banks, such as deposit certificates published by different banks. The embodiment of the present application conducts a large amount of image research on bills, thereby setting a plurality of preset templates. The plurality of preset templates can be used to match various bill images, thereby obtaining an initial to-be-recognized region of the bill image.

[0121] As an example, the plurality of preset templates can be called in sequence according to a preset order, and each preset template can include one or more preset characters. Referring to Figure 4 , a schematic diagram of template matching provided by the embodiment of the present application is shown, in which M1-M3 are preset characters, and M1'-M3' are printed characters. The embodiment of the present application can first determine a target preset character that matches the printed character on the bill image, and then can determine the position of the target preset character as the position of the printed character. For example, the preset character M1 matches the printed character M1', the preset character M2 matches the printed character M2', and the preset character M3 matches the printed character M3', so the position of the preset character M1 can be determined as the position of the printed character M1', the position of the preset character M2 can be determined as the position of the printed character M2', and the position of the preset character M3 can be determined as the position of the printed character M3'. It should be noted that if there is no target preset character that matches the printed character, the preset template can be called again until a target preset character that matches the printed character is determined.

[0122] In the embodiment of the present application, the relative positions of the printed characters and the printed characters on the bill image can be fixed, thereby setting position offset information. The position offset information can include an offset distance and an offset direction. After the position of the printed character is obtained, the position of the printed character can be offset according to the offset distance and the offset direction, thereby obtaining an initial to-be-recognized position, and then an initial to-be-recognized region of the bill image can be generated according to the initial to-be-recognized position.

[0123] As an example, as shown in Figure 4 , after the positions of the printed characters M1'-M3' are obtained, the positions M1'-M3' of the printed characters can be offset to the right by X pixel points according to the position offset information, thereby obtaining an initial to-be-recognized position, and then an initial to-be-recognized region of the bill image can be generated with the initial to-be-recognized position as a center point, referring to the C1-C3 regions in Figure 4 . It should be noted that the initial to-be-recognized region is generally relatively large, so even if the printing device is unstable or the bill is not placed normally, causing the printed characters to be offset up and down or left and right, the initial to-be-recognized region of the embodiment of the present application will still cover the complete printed characters.

[0124] In an optional embodiment of the present application, the method can further comprise:

[0125] The bill image is binarized under different light sources and different color channels to obtain a plurality of first binary images; the number of pixel points with a target pixel value in each row of the initial to-be-recognized region is counted for each of the plurality of first binary images; if the number of pixel points is greater than a first number threshold, the row in which the number of pixel points is located is determined as a valid row; the number of rows of consecutive valid rows is determined; if the number of rows is greater than a second number threshold, it is determined that the plurality of characters include printed characters; and if the number of rows is not greater than the second number threshold, it is determined that the plurality of characters do not include printed characters.

[0126] In actual application, there can be blank bills or invalid bills with missing content on the bills, such as blank deposit receipts or deposit receipts with missing account name. In order to avoid the OCR recognition of these invalid bills, whether the initial to-be-recognized region has printed characters can be determined after the initial to-be-recognized region is obtained.

[0127] In actual application, the white light image can have interference of underlines, and it is easy to identify the presence of elements as the absence of elements, and the error probability is relatively large. Although the infrared image is clean, the calculation of the threshold value can be deviated due to the printing being too light, and it is easy to cause the presence of elements to be identified as the absence of elements. Therefore, the embodiment of the present application can combine the characteristics of different light sources and different color channels to detect elements, so as to reduce the possibility of element detection error.

[0128] In the implementation of the present application, the bill image can be set to the image obtained by scanning under different light sources and different color channels, wherein the light sources can include white light and infrared light, and the color channels can include red (R), green (G), and blue (B). The white light image and the infrared image of the bill image can be obtained in the implementation of the present application, and then different color channels can be selected according to different bills.

[0129] Taking a deposit receipt as an example, the green channel of the white light image of the deposit receipt can be selected, and the infrared image of the deposit receipt is relatively clean, so the color channel can not be selected. Then the white light image and the infrared image of the green channel can be binarized to obtain a plurality of first binary images. Referring to FIG. 2, a first binary image provided by the embodiment of the present application is shown, wherein, Figures 5A-5B Figure 5A the first binary image of the white light image of the green channel, Figure 5B the first binary image of the infrared image. As can be seen from the above, Figure 5A the first binary image in the white light image of the green channel has more interference of underlines, Figure 5B ​The printed characters in the first binary image are much lighter. The embodiment of the present application respectively adopts the first binary image of the white light image of the green channel and the first binary image of the infrared image to determine whether the multiple characters in the initial to-be-recognized region include printed characters.

[0130] In the embodiment of the present application, the bill image can include pixel values of 0-255. The number of pixel points corresponding to each pixel value can be counted first, and then the first pixel value threshold can be selected from the top 30% of the pixel values in the pixel points. In order to find the optimal threshold, the second pixel value threshold can be adjusted by subtracting a certain bias from the first pixel value threshold, so that the second pixel value threshold can be used for binarization of the bill image.

[0131] Specifically, assuming that the size of the bill image is 100*100, the total number of pixel points is 10000, and the number of 30% pixel points is 3000. Starting from the maximum pixel value 255, the number of pixel points is accumulated until the top 30% pixel value is found. Assuming that the number of pixel points of the pixel value 255 is 1000, the number of pixel points of the pixel value 254 is 1000, and the number of pixel points of the pixel value 253 is 1000, the accumulated number of pixel points is 3000 at this time. The next pixel value 252 is the top 30% pixel value, and the pixel value 252 is used as the first pixel value threshold. Then a certain bias is subtracted from the first pixel value threshold 252 to obtain the optimal second pixel value threshold. Assuming that the second pixel value threshold is 250, the second pixel value threshold 250 can be used for binarization of the bill image, so that the pixel value greater than or equal to the second pixel value threshold 250 is set to white, and the pixel value less than the second pixel value threshold 250 is set to black, so that the first binary image presents a black and white effect. The white pixel points constitute the text part, and the black pixel points constitute the background part.

[0132] In the embodiment of the present application, in each row of the initial to-be-recognized region, the number of pixel points with the target pixel value can be counted. When the number of pixel points is greater than the first number threshold, the row in which the number of pixel points is located can be determined as a valid row; when the number of pixel points is not greater than the first number threshold, the row in which the number of pixel points is located can be determined as an invalid row. Then the number of rows of continuous valid rows can be counted. When the number of rows of valid rows is greater than the second number threshold, it can be determined that the multiple characters include printed characters; when the number of rows of valid rows is not greater than the second number threshold, it can be determined that the multiple characters do not include printed characters.

[0133] Specifically, since the first binary image only has two pixel values of white (255) and black (0), and the white pixel points form the text part and the black pixel points form the background part, the white pixel value can be taken as the target pixel value. Assuming that the first quantity threshold is set to 50, and the first row in the initial to-be-recognized region has 20 white pixel points, the second row has 30 white pixel points, and the third row has 51 white pixel points, the third row can be taken as the effective row, and the first row and the second row are taken as the ineffective row. Then the number of continuous effective rows can be counted, and assuming that the second quantity threshold is 8 rows, and the third row to the thirteenth row in the initial to-be-recognized region are all effective rows, it can be determined that the multiple characters in the initial to-be-recognized region include the printed character.

[0134] Step 202, when it is determined that the multiple characters include the printed character, generating a circumscribed rectangle for the contour of the multiple characters, and determining a target circumscribed rectangle from the circumscribed rectangle of the multiple characters.

[0135] In the implementation of the present application, when it is determined that the multiple characters in the initial to-be-recognized region include the printed character, the binary image of the infrared image of the bill image can be used to generate a circumscribed rectangle for the contour of the multiple characters, and then a target circumscribed rectangle can be determined from the circumscribed rectangle of the multiple characters. Referring to Figure 6 , a schematic diagram of a circumscribed rectangle provided by an embodiment of the present application is shown, wherein, Figure 6 is a second binary image of the infrared image, and in the initial to-be-recognized region of the second binary image, based on the contour searching mode, the contour of each character can be obtained, and then a circumscribed rectangle for the contour of the multiple characters is generated, referring to Figure 6 the circumscribed rectangles of a to g in FIG. 8, and then a target circumscribed rectangle can be determined from the circumscribed rectangles a to g to adopt the target circumscribed rectangle for the subsequent projection step.

[0136] In an optional embodiment of the present application, the method can further include:

[0137] obtaining a plurality of pixel value decreasing binarization thresholds; using the plurality of pixel value decreasing binarization thresholds to respectively binarize the bill image, and obtaining a plurality of second binary images; and selecting a second binary image as a target binary image from the plurality of second binary images in the order of pixel value from large to small.

[0138] In this invention, multiple binarization thresholds with decreasing pixel values ​​can be preset. After determining that printed characters exist in the initial area to be recognized, these binarization thresholds can be obtained. Then, these binarization thresholds can be used to binarize the infrared image of the ticket image, thereby obtaining a series of second binary images. For example, 10 different binarization thresholds can be preset, such as 200, 198, 196, 194, 192, 190, 188, 186, 184, and 182. These 10 different binarization thresholds can then be used to binarize the infrared image of the ticket image, thereby obtaining a series of second binary images.

[0139] In an optional embodiment of the present invention, step 202 may include the following sub-steps:

[0140] Sub-step S21: Use the target binary image to perform the step of generating the bounding rectangle for the outline of the multiple characters.

[0141] In this invention, after obtaining multiple second binary images, one second binary image can be selected as the target binary image in descending order of pixel values. Then, the target binary image can be used to perform the step of generating an outer rectangle for the outline of multiple characters. For example, the second binary image corresponding to the largest pixel value (e.g., 200) can be used as the target binary image. If no matching target outer rectangle, target top and bottom boundaries, or target left and right boundaries are found subsequently, this step can be returned to, and the second binary image corresponding to the second largest pixel value (e.g., 198) can be used as the target binary image. Then, the step of generating an outer rectangle for the outline of multiple characters can be performed using the target binary image, and so on, until a matching target outer rectangle, target top and bottom boundaries, or target left and right boundaries are found.

[0142] In an optional embodiment of the present invention, step 202 may include the following sub-steps:

[0143] Sub-step S31: Determine the height of the bounding rectangle of the plurality of characters;

[0144] Sub-step S32: Determine the bounding rectangle whose height is within the first preset range as the target bounding rectangle.

[0145] In this invention, a first preset range can be pre-set. After performing contour searches for each character, multiple bounding rectangles can be obtained. (See [reference]). Figure 6 The bounding rectangles of characters a through g are used. Then, a first preset range can be used to determine the target bounding rectangle from the bounding rectangles of multiple characters. Specifically, the height of each bounding rectangle can be determined first. When the height of a bounding rectangle falls within the first preset range, that bounding rectangle can be determined as the target bounding rectangle. See [link to relevant documentation]. Figure 6When the height of the circumscribed rectangle is not located in the first preset range, it is indicated that the circumscribed rectangle is too large or too small, such as the circumscribed rectangle of the noise points a and g and the circumscribed rectangle of the horizontal line f, and these circumscribed rectangles can be filtered.

[0146] In step 203, horizontal projection and vertical projection are performed on the target circumscribed rectangle, the boundary of the printed character is obtained, and the region formed by the boundary is determined as the target to-be-recognized region of the bill image.

[0147] In the embodiment of the application, the horizontal projection can be used to find the upper boundary and the lower boundary of the printed character, and the vertical projection can be used to find the left boundary and the right boundary of the printed character. By performing the horizontal projection and the vertical projection on the target circumscribed rectangle, the upper boundary, the lower boundary, the left boundary and the right boundary of the printed character can be obtained, so that the region formed by the upper boundary, the lower boundary, the left boundary and the right boundary can be determined as the target to-be-recognized region of the bill image.

[0148] In an optional embodiment of the application, the step 203 can include the following sub-steps.

[0149] In sub-step S41, based on the horizontal projection, each row of the target circumscribed rectangle is traversed to determine a plurality of pairs of upper and lower boundaries.

[0150] In sub-step S42, the target upper and lower boundaries are determined from the plurality of pairs of upper and lower boundaries.

[0151] In sub-step S43, based on the vertical projection, each column between the target upper and lower boundaries is traversed to determine a plurality of pairs of left and right boundaries.

[0152] In sub-step S44, the target left and right boundaries are determined from the plurality of pairs of left and right boundaries.

[0153] In a specific implementation, in the target circumscribed rectangle, each row can be traversed from top to bottom by horizontal projection. When a row with white pixel points is traversed, the row can be recorded as the starting row of the printed character, and the traversal is continued. When a row without white pixel points is traversed, the last row of the row can be recorded as the ending row of the printed character. Then, the starting row and the ending row can be determined as a pair of upper and lower boundaries, and the target upper and lower boundaries can be determined from the plurality of pairs of upper and lower boundaries.

[0154] In a specific implementation, after the target upper and lower boundaries are found, the pixel values of the pixels in the regions outside the target upper and lower boundaries can be cleared to exclude interference. In the target upper and lower boundaries, each column can be traversed from left to right by vertical projection. When a white pixel is found in a column, the column can be recorded as the starting column of the printed character. The traversal continues. When no white pixel is found in a column, the previous column can be recorded as the ending column of the printed character. Then, the starting column and the ending column can be determined as a pair of left and right boundaries. Then, the target left and right boundaries can be determined from the multiple pairs of left and right boundaries.

[0155] In an optional embodiment of the present application, the sub-step S42 can include the following sub-steps:

[0156] Sub-step S421: determining the height of each pair of upper and lower boundaries;

[0157] Sub-step S422: determining the upper and lower boundaries with the height in the second preset range as the target upper and lower boundaries.

[0158] In a specific implementation, the second preset range can be set in advance. After the horizontal projection is performed on each target bounding rectangle, multiple pairs of upper and lower boundaries can be obtained. Then, the second preset range can be used to determine the target upper and lower boundaries from the multiple pairs of upper and lower boundaries. Specifically, the height of each pair of upper and lower boundaries can be determined first. When the height of the upper and lower boundaries is in the second preset range, the upper and lower boundaries can be determined as the target upper and lower boundaries. When the height of the upper and lower boundaries is not in the second preset range, it means that the distance between the upper and lower boundaries is too large or too small, which does not conform to the height of the printed character. Therefore, these upper and lower boundaries can be filtered.

[0159] In an optional embodiment of the present application, the sub-step S44 can include the following sub-steps:

[0160] Sub-step S441: determining the width of each pair of left and right boundaries;

[0161] Sub-step S442: determining the left and right boundaries with the width in the third preset range as the target left and right boundaries.

[0162] In a specific implementation, a third preset range can be preset, after the vertical projection is performed on each pair of target upper and lower boundaries, a plurality of pairs of left and right boundaries can be obtained, and then the third preset range can be used to determine the target left and right boundaries from the plurality of pairs of left and right boundaries. Specifically, the width of each pair of left and right boundaries can be determined first, when the width of the left and right boundaries is within the third preset range, the left and right boundaries can be determined as the target left and right boundaries; when the width of the left and right boundaries is not within the third preset range, it indicates that the distance between the left and right boundaries is too large or too small, which does not conform to the width of the printed character, and then the next second binary graph can be selected from the plurality of second binary graphs as the target binary graph, and the step of generating the contour of the plurality of characters and generating the circumscribed rectangle is re-executed.

[0163] In an optional embodiment of the present application, the method can further include:

[0164] When the target circumscribed rectangle, the target upper and lower boundaries, or the target left and right boundaries do not exist, the next second binary graph can be selected from the plurality of second binary graphs as the target binary graph in the order of pixel value from large to small.

[0165] In a specific implementation, when the target circumscribed rectangle that meets the condition is not found, or when the target upper and lower boundaries that meet the condition are not found, or when the target left and right boundaries that meet the condition are not found, the next second binary graph can be selected from the plurality of second binary graphs as the target binary graph in the order of pixel value from large to small, and the step of generating the contour of the plurality of characters and generating the circumscribed rectangle is re-executed using the target binary graph, until the target circumscribed rectangle, the target upper and lower boundaries, and the target left and right boundaries that meet the condition are found, so that a fine target to-be-recognized region can be obtained.

[0166] In an optional embodiment of the present application, the step 203 can include the following sub-steps:

[0167] In the sub-step S51, the region formed by the target upper and lower boundaries and the target left and right boundaries is determined as the target to-be-recognized region of the bill image.

[0168] In the embodiment of the present application, after the target upper and lower boundaries and the target left and right boundaries are obtained, the region formed by the target upper and lower boundaries and the target left and right boundaries can be determined as the target to-be-recognized region of the bill image. Referring to Figures 7A-7C , an effect display diagram provided by the embodiment of the present application is shown, wherein, Figure 7A corresponds to Figure 1A , Figure 7B corresponds to Figure 1B , Figure 7C corresponds to Figure 4 , and Figures 1A-1BThe displayed is the intercepted region to be identified in the prior art. As can be seen, compared with the intercepted regions to be identified A1-A3, B1-B3 in the prior art, the intercepted target regions to be identified A1'-A3', B1'-B3' in the embodiment of the present application are more fine, and in addition, compared with the initially intercepted initial regions to be identified C1-C3, the finally intercepted target regions to be identified C1'-C3' are also more fine.

[0169] Step 204, identifying the printed character of the target region to be identified.

[0170] In the embodiment of the present application, the bill equipment can include an OCR module. After obtaining the target region to be identified, since the target region to be identified not only covers complete printed characters but also excludes the interference of irrelevant factors such as horizontal lines, ink and background texture, the OCR module can be used to identify the printed character of the target region to be identified, so as to solve the problem of incorrect interception of the region to be identified due to non-standard printing equipment and operation, improve the accuracy of OCR identification, and improve the efficiency of algorithm execution. Moreover, the embodiment of the present application can be applied to image identification of various bills, and has strong universality and stability.

[0171] In the embodiment of the present application, a preset template is first called to match the preset template with the bill image to obtain an initial region to be identified of the bill image. The initial region to be identified includes multiple characters. When it is determined that the multiple characters include a printed character, a circumscribed rectangle is generated for the contour of the multiple characters. Then, a target circumscribed rectangle is determined from the circumscribed rectangle of the multiple characters. The target circumscribed rectangle is subjected to horizontal projection and vertical projection to obtain the boundary of the printed character. The region formed by the boundary is determined as the target region to be identified of the bill image. Finally, the printed character of the target region to be identified is identified. The embodiment of the present application is applicable to image identification of various bills, has strong universality and stability, can solve the problem of incorrect interception of the region to be identified due to non-standard printing equipment and operation, improve the accuracy of OCR identification, and improve the efficiency of algorithm execution.

[0172] In order for those skilled in the art to better understand the embodiments of the present application, refer to Figure 8 The figure shows the bill image identification flowchart provided by the embodiment of the present application, and the bill image identification process is specifically described in combination with the following examples:

[0173] Step 801, obtaining a bill image; the bill image includes multiple printed characters;

[0174] Step 802, sequentially calling multiple preset templates in a preset order; each preset template includes one or more preset characters;

[0175] Step 803, matching the preset template with the bill image;

[0176] Step 804, judging whether there is a target preset character matching the printed character;

[0177] Step 805, if there is, determining the position of the target preset character as the position of the printed character, offsetting the position of the printed character to obtain a printed initial to-be-recognized position, and then generating a printed initial to-be-recognized region according to the printed initial to-be-recognized position; if not, returning to step 802;

[0178] Step 806, setting the bill image as an infrared image and a white light image of different color channels respectively, binarizing the infrared image and the white light image of different color channels to obtain a plurality of first binary images;

[0179] Step 807, judging whether there is a printed character in the initial to-be-recognized region by using the plurality of first binary images;

[0180] Step 808, if there is, obtaining a plurality of pixel value decreasing binarization thresholds, setting the bill image as an infrared image, and binarizing the infrared image by using the plurality of pixel value decreasing binarization thresholds to obtain a plurality of second binary images; if not, returning to step 806;

[0181] Step 809, selecting a target binary image from the plurality of second binary images in the order of pixel value from large to small;

[0182] Step 810, performing contour finding by using the target binary image, and generating a plurality of character circumscribed rectangles for the contours of a plurality of characters in the initial to-be-recognized region;

[0183] Step 811, judging whether there is a target circumscribed rectangle satisfying a first preset range from the plurality of character circumscribed rectangles;

[0184] Step 812, if there is, performing horizontal projection on the target circumscribed rectangle to generate a plurality of pairs of upper and lower boundaries; if not, returning to step 809;

[0185] Step 813, judging whether there is a target upper and lower boundary satisfying a second preset range from the plurality of pairs of upper and lower boundaries;

[0186] Step 814, if there is, performing vertical projection on the target upper and lower boundary to generate a plurality of pairs of left and right boundaries; if not, returning to step 809;

[0187] Step 815, judging whether there is a target left and right boundary satisfying a third preset range from the plurality of pairs of left and right boundaries;

[0188] Step 816, if the region formed by the target upper and lower boundaries and the target left and right boundaries exists, the region is determined as the target to-be-recognized region; if not, the step 809 is returned to;

[0189] Step 817, the printed character in the target to-be-recognized region is recognized.

[0190] Referring to Figure 9 , a structure block diagram of a bill image recognition device provided in an embodiment of the present application is shown, which can specifically include the following modules:

[0191] An initial to-be-recognized region obtaining module 901 is configured to call a preset template and match the preset template with the bill image to obtain an initial to-be-recognized region of the bill image; the initial to-be-recognized region includes a plurality of characters;

[0192] A target bounding rectangle determining module 902 is configured to, when it is determined that the plurality of characters include a printed character, generate a bounding rectangle for the contour of the plurality of characters and determine a target bounding rectangle from the bounding rectangle of the plurality of characters;

[0193] A target to-be-recognized region determining module 903 is configured to perform horizontal projection and vertical projection on the target bounding rectangle to obtain the boundary of the printed character and determine a region formed by the boundary as a target to-be-recognized region of the bill image;

[0194] A recognition module 904 is configured to recognize the printed character in the target to-be-recognized region.

[0195] In an optional embodiment of the present application, the bill image includes a printed character, the preset template includes a preset character, and the initial to-be-recognized region obtaining module 901 can include:

[0196] A matching sub-module is configured to determine a target preset character matched with the printed character;

[0197] A position determining sub-module is configured to determine the position of the target preset character as the position of the printed character;

[0198] An offset sub-module is configured to offset the position of the printed character to obtain an initial to-be-recognized position;

[0199] An initial to-be-recognized region generating sub-module is configured to generate an initial to-be-recognized region of the bill image according to the initial to-be-recognized position.

[0200] In an optional embodiment of the present application, the device can further include:

[0201] a first binary image obtaining module configured to obtain a plurality of first binary images by binarizing the bill image under different light sources and different color channels;

[0202] a pixel point number counting module configured to count, for each of the plurality of first binary images, a number of pixel points having the target pixel value in each row of the initial to-be-recognized region;

[0203] an effective row determining module configured to determine a row in which the number of pixel points is located as an effective row if the number of pixel points is greater than a first number threshold;

[0204] a row number determining module configured to determine a number of consecutive effective rows;

[0205] a first printed character determining module configured to determine that the plurality of characters include a printed character if the number of rows is greater than a second number threshold;

[0206] a second printed character determining module configured to determine that the plurality of characters do not include a printed character if the number of rows is not greater than the second number threshold.

[0207] In an optional embodiment of the present application, the device can further include:

[0208] a binarization threshold obtaining module configured to obtain a plurality of binarization thresholds decreasing in pixel value;

[0209] a second binary image obtaining module configured to obtain a plurality of second binary images by binarizing the bill image using the plurality of binarization thresholds decreasing in pixel value;

[0210] a first target binary image selecting module configured to select a second binary image as a target binary image from the plurality of second binary images in descending order of pixel value;

[0211] The target bounding rectangle determining module 902 can include:

[0212] a bounding rectangle generating submodule configured to generate a bounding rectangle for the contour of the plurality of characters using the target binary image.

[0213] In an optional embodiment of the present application, the target bounding rectangle determining module 902 can include:

[0214] a height determining submodule of the bounding rectangle configured to determine a height of the bounding rectangle of the plurality of characters;

[0215] a target bounding rectangle determining submodule configured to determine a bounding rectangle whose height is within a first preset range as a target bounding rectangle.

[0216] In an optional embodiment of the present application, the target region to be identified determination module 903 can comprise:

[0217] a first traversal submodule, configured to traverse each row of the target bounding rectangle based on horizontal projection, and determine a plurality of pairs of upper and lower boundaries;

[0218] a target upper and lower boundary determination submodule, configured to determine target upper and lower boundaries from the plurality of pairs of upper and lower boundaries;

[0219] a second traversal submodule, configured to traverse each column between the target upper and lower boundaries based on vertical projection, and determine a plurality of pairs of left and right boundaries;

[0220] a target left and right boundary determination submodule, configured to determine target left and right boundaries from the plurality of pairs of left and right boundaries;

[0221] The target region to be identified determination module 903 can comprise:

[0222] a target region to be identified determination submodule, configured to determine a region formed by the target upper and lower boundaries and the target left and right boundaries as the target region to be identified of the bill image.

[0223] In an optional embodiment of the present application, the target left and right boundary determination submodule can comprise:

[0224] an upper and lower boundary height determination unit, configured to determine the height of each pair of upper and lower boundaries;

[0225] a target upper and lower boundary determination unit, configured to determine the upper and lower boundaries with the height within a second preset range as the target upper and lower boundaries;

[0226] The target left and right boundary determination submodule can comprise:

[0227] a left and right boundary width determination unit, configured to determine the width of each pair of left and right boundaries;

[0228] a target left and right boundary determination unit, configured to determine the left and right boundaries with the width within a third preset range as the target left and right boundaries.

[0229] In an optional embodiment of the present application, the device can further comprise:

[0230] a second target binary image selection module, configured to, when the target bounding rectangle, or the target upper and lower boundaries, or the target left and right boundaries do not exist, select a next second binary image from the plurality of second binary images as a target binary image in the order of pixel value from large to small.

[0231] In the embodiment of the present application, a preset template is first invoked, the preset template is matched with the bill image, and an initial to-be-recognized region of the bill image is obtained, wherein the initial to-be-recognized region includes multiple characters, when it is determined that the multiple characters include printed characters, a circumscribed rectangle is generated for the contours of the multiple characters, then a target circumscribed rectangle is determined from the circumscribed rectangle of the multiple characters, horizontal projection and vertical projection are performed on the target circumscribed rectangle, the boundary of the printed characters is obtained, then the region formed by the boundary is determined as a target to-be-recognized region of the bill image, and finally the printed characters in the target to-be-recognized region are recognized. The embodiment of the present application is suitable for image recognition of various bills, has strong universality and stability, can solve the problem of incorrect to-be-recognized region interception caused by non-standard printing equipment and operation, improve the accuracy of OCR recognition, and improve the efficiency of algorithm execution.

[0232] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the related parts refer to the part of the method embodiment.

[0233] Preferably, the embodiment of the present application further provides an electronic device, which comprises a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the processes of the above bill image recognition method embodiment are realized, and the same technical effects can be achieved. To avoid repetition, this will not be repeated here.

[0234] The embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is executed by the processor, the processes of the above bill image recognition method embodiment are realized, and the same technical effects can be achieved. To avoid repetition, this will not be repeated here. The computer readable storage medium includes a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0235] It should be noted that in this document, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusions, so that processes, methods, articles or devices including a series of elements not only include those elements, but also include other elements not explicitly listed, or include elements inherent to such processes, methods, articles or devices. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.

[0236] Those skilled in the art can clearly understand that the above-mentioned embodiment method can be realized by means of software and necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes a plurality of instructions for making a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) execute the method described in each embodiment of the present application.

[0237] The embodiments of the present application are described above with reference to the accompanying drawings, but the present application is not limited to the above-mentioned specific embodiments, and the above-mentioned specific embodiments are only illustrative, not restrictive. Those skilled in the art can make many forms without departing from the purpose of the present application and the scope protected by the claims under the inspiration of the present application, which all belong to the protection of the present application.

[0238] Those skilled in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed in the embodiments of the present application can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solutions. Those skilled in the art can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0239] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-mentioned system, device and unit can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.

[0240] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed ones can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0241] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0242] In addition, each functional unit in each embodiment of the application can be integrated in one processing unit, or each unit can be physically present alone, or two or more units can be integrated in one unit.

[0243] The functions, if realized in the form of software functional units and sold or used as independent products, can be stored in a computer readable storage medium. Based on such understanding, the technical scheme of the application or the part of the prior art that contributes essentially or the part of the technical scheme can be embodied in the form of a software product. The computer software product stored in a storage medium includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk, and various program code storage media.

[0244] The above is only a specific embodiment of the application, but the protection scope of the application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the application, which should be covered within the protection scope of the application. Therefore, the protection scope of the application should be subject to the protection scope of the claims.

Claims

1. A method of identifying a document image, characterized by, The method comprises: calling a preset template and matching the preset template with the bill image to obtain an initial to-be-recognized region of the bill image; the initial to-be-recognized region comprises a plurality of characters; when it is determined that the plurality of characters comprise printed characters, generating a circumscribed rectangle for the contour of the plurality of characters and determining a target circumscribed rectangle from the circumscribed rectangle of the plurality of characters; performing horizontal projection and vertical projection on the target circumscribed rectangle to obtain the boundary of the printed characters and determining a region formed by the boundary as a target to-be-recognized region of the bill image; recognizing the printed characters in the target to-be-recognized region; under different light sources and different color channels, binarizing the bill image to obtain a plurality of first binary images; respectively for the plurality of first binary images, counting the number of pixel points with a target pixel value in each row of the initial to-be-recognized region; if the number of pixel points is greater than a first quantity threshold, determining the row in which the number of pixel points is located as a valid row; determining the number of rows of continuous valid rows; if the number of rows is greater than a second quantity threshold, determining that the plurality of characters comprise printed characters; if the number of rows is not greater than the second quantity threshold, determining that the plurality of characters do not comprise printed characters; obtaining a plurality of binarization threshold values decreasing in pixel value; using the plurality of binarization threshold values decreasing in pixel value to respectively binarize the bill image to obtain a plurality of second binary images; selecting a second binary image as a target binary image from the plurality of second binary images in descending order of pixel value; the step of generating a circumscribed rectangle for the contour of the plurality of characters comprises: using the target binary image to perform the step of generating a circumscribed rectangle for the contour of the plurality of characters.

2. The method of claim 1, wherein, The bill image comprises printed characters, and the preset template comprises preset characters. The matching of the preset template with the bill image to obtain the initial to-be-recognized region of the bill image comprises: determining a target preset character matching the printed character; determining the position of the target preset character as the position of the printed character; offsetting the position of the printed character to obtain an initial to-be-recognized position; generating the initial to-be-recognized region of the bill image according to the initial to-be-recognized position.

3. The method of claim 1, wherein, The determination of a target circumscribed rectangle from the circumscribed rectangle of the plurality of characters comprises: determining the height of the circumscribed rectangle of the plurality of characters; determining a circumscribed rectangle with a height within a first preset range as a target circumscribed rectangle.

4. The method of claim 1, wherein, The horizontal projection and vertical projection on the target circumscribed rectangle to obtain the boundary of the printed characters comprise: based on horizontal projection, traversing each row of the target circumscribed rectangle to determine a plurality of pairs of upper and lower boundaries; determining a target upper and lower boundary from the plurality of pairs of upper and lower boundaries; based on vertical projection, traversing each column between the target upper and lower boundary to determine a plurality of pairs of left and right boundaries; determining a target left and right boundary from the plurality of pairs of left and right boundaries; The determination of a region formed by the boundary as a target to-be-recognized region of the bill image comprises: An area formed by the target upper and lower boundaries and the target left and right boundaries is determined as a target to-be-recognized area of the bill image.

5. The method of claim 4, wherein, The target upper and lower boundaries are determined from the multiple pairs of upper and lower boundaries, and the target left and right boundaries are determined from the multiple pairs of left and right boundaries, including: Determining a height of each pair of upper and lower boundaries; Determining the upper and lower boundaries with the height in a second preset range as the target upper and lower boundaries; Determining a width of each pair of left and right boundaries; Determining the left and right boundaries with the width in a third preset range as the target left and right boundaries. The method further includes:

6. The method of claim 5, wherein, When the target bounding rectangle, the target upper and lower boundaries, or the target left and right boundaries do not exist, selecting a next second binary image from the multiple second binary images as a target binary image in a descending order of pixel values. The device includes:

7. A bill image recognition apparatus characterized by comprising: An initial to-be-recognized area obtaining module configured to call a preset template and match the preset template with the bill image to obtain an initial to-be-recognized area of the bill image; the initial to-be-recognized area includes multiple characters; A target bounding rectangle determining module configured to, when it is determined that the multiple characters include printed characters, generate a bounding rectangle for contours of the multiple characters, and determine a target bounding rectangle from the bounding rectangles of the multiple characters; A target to-be-recognized area determining module configured to perform horizontal projection and vertical projection on the target bounding rectangle to obtain boundaries of the printed characters, and determine an area formed by the boundaries as a target to-be-recognized area of the bill image; An identifying module configured to identify the printed characters in the target to-be-recognized area; A first binary image obtaining module configured to binarize the bill image under different light sources and different color channels to obtain multiple first binary images; A pixel point number counting module configured to count, for each of the multiple first binary images, a number of pixel points with a target pixel value in each row of the initial to-be-recognized area; An effective row determining module configured to, if the number of pixel points is greater than a first number threshold, determine a row in which the number of pixel points is located as an effective row; A row number determining module configured to determine a row number of consecutive effective rows; A first printed character determining module configured to, if the row number is greater than a second number threshold, determine that the multiple characters include printed characters; A second printed character determining module configured to, if the row number is not greater than the second number threshold, determine that the multiple characters do not include printed characters; A binarization threshold value obtaining module configured to obtain multiple binarization threshold values in a descending order of pixel values; A second binary image obtaining module configured to binarize the bill image by using the multiple binarization threshold values in the descending order of pixel values to obtain multiple second binary images; A first target binary image selecting module configured to select one second binary image from the multiple second binary images as a target binary image in a descending order of pixel values. The target bounding rectangle determining module includes: A bounding rectangle generating submodule configured to perform the step of generating a bounding rectangle for contours of the multiple characters by using the target binary image. The device includes:

8. An electronic device, comprising: ​ A processor, a memory, and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implements the steps of the banknote image recognition method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer program is stored on the computer readable storage medium and, when executed by the processor, implements the steps of the banknote image recognition method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Document recognizing device

    JP1995114619A