Electronic device, bill recognition method and storage medium
By performing straight line detection and feature vector calculation on bill images, combined with Haar features and Adaboost algorithm, accurate recognition of bill images is achieved, solving the problem of low classification efficiency in the existing technology, saving labor costs and improving work efficiency.
Patent Information
- Application Number
- CN201811260786.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-10-26
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2038-10-26
AI Technical Summary
The classification processing of bill images in the existing technology is inefficient and error-prone, requires a large amount of human participation, and cannot achieve efficient and accurate automatic recognition.
Design a method for identifying electronic devices and bills. By detecting straight lines on bill pictures, calculating feature vectors, and comparing similarity with predetermined standard vectors, using pre-trained classifiers to identify bill types and subtypes, using Haar features and Adaboost algorithm for classification.
It achieves accurate recognition of bill images, saves labor costs, improves work efficiency, and reduces errors.
Smart Images

Figure CN109635633B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of bill recognition, and in particular to an electronic device, a bill recognition method and a storage medium. Background Art
[0002] With the rapid development of the financial industry, the number and types of images involved in financial business are increasing. As for the bill images involved, they usually need to be counted within a certain period of time and used as the basis for collection, reimbursement and other businesses. This requires the classification and management of bill images to facilitate the smooth progress of related businesses. However, the classification of bill images still requires a lot of manpower, and the classification process is inefficient and prone to errors.
[0003] Therefore, how to propose a method to efficiently and accurately automatically identify the type of bill images has become an urgent problem to be solved. Summary of the invention
[0004] In view of this, the present invention proposes an electronic device, a bill recognition method and a storage medium, which can accurately recognize the type of bill image, save labor costs and improve work efficiency.
[0005] First, to achieve the above-mentioned purpose, the present invention proposes an electronic device, which includes a memory and a processor connected to the memory, wherein the processor is used to execute a bill recognition program stored in the memory, and the bill recognition program implements the following steps when executed by the processor:
[0006] A1. Perform straight line detection on the form in the bill image to be recognized, and obtain the positional relationship between each form frame line and each form frame line in the bill image;
[0007] A2. Calculate the feature vector of the bill image according to the positional relationship between each form frame line and each form frame line;
[0008] A3. Calculate the similarity between the feature vector of the table and the pre-determined standard vector of each type of bill table. If the similarity between the standard vector of a certain type of bill table and the feature vector of the table is less than or equal to a preset similarity threshold, determine that the bill image to be identified is a bill of that type.
[0009] Preferably, the step A2 comprises:
[0010] According to the positional relationship between each form frame line and each form frame line, each intersection point of the form frame line is extracted, and information of each intersection point is obtained, and information of the horizontal form frame line and information of the vertical form frame line in each form frame line are obtained;
[0011] Identify the form in the bill image according to the information of each intersection, the information of the horizontal form frame line, and the information of the vertical form frame line;
[0012] Marking positions of all intersections of the identified table, and sorting the position marks according to a predetermined sorting rule to generate a position sequence;
[0013] The pixel distances between each intersection point and a predefined position point in the position sequence are calculated respectively, and each calculated pixel distance is normalized to obtain a feature vector of the table.
[0014] Preferably, when the bill recognition program is executed by the processor, the following steps are also implemented:
[0015] If it is determined that the bill type corresponding to the bill image to be identified includes multiple subtypes, the bill type is identified according to a pre-trained classifier to identify the subtype corresponding to the bill image to be identified.
[0016] Preferably, the training process of the pre-trained classifier includes:
[0017] Construct the structural Haar feature of the bill type and form a new feature library with the basic Haar feature, and use the feature library to extract sample feature values;
[0018] The Adaboost algorithm is used to train the classifier, extract the adaptive classification threshold, and obtain the best weak classifier;
[0019] Train multiple weak classifiers through multiple iterations and average them into a strong classifier;
[0020] A plurality of strong classifiers are trained to form a cascade classifier, wherein the cascade classifier is a trained classifier.
[0021] Preferably, the step of constructing the structural Haar feature of the bill type and forming a new feature library with the basic Haar feature, and extracting the sample feature value using the feature library includes:
[0022] Design three structural Haar rectangular features of the bill type, including the Haar features of the number of rows and types contained in the bill type, wherein the Haar features of the number of columns contained in each row and the number of printed fields contained in the columns, and the Haar features of the number of rows contained in each column and the number of printed fields contained in the rows;
[0023] A new Haar feature library is formed by combining five basic Haar features including horizontal edge, vertical edge, horizontal center, vertical center and diagonal features;
[0024] The integral graph acceleration algorithm is used to extract all sample eigenvalues.
[0025] In addition, in order to achieve the above object, the present invention also proposes a bill recognition method, which comprises the following steps:
[0026] S1. Perform straight line detection on the form in the bill image to be recognized, and obtain the positional relationship between each form frame line and each form frame line in the bill image;
[0027] S2. Calculate the feature vector of the bill image according to the positional relationship between each form frame line and each form frame line;
[0028] S3. Calculate the similarity between the feature vector of the table and the pre-determined standard vector of each type of bill table. If the similarity between the standard vector of a certain type of bill table and the feature vector of the table is less than or equal to a preset similarity threshold, determine that the bill image to be identified is a bill of that type.
[0029] Preferably, step S2 comprises:
[0030] According to the positional relationship between each form frame line and each form frame line, each intersection point of the form frame line is extracted, and information of each intersection point is obtained, and information of the horizontal form frame line and information of the vertical form frame line in each form frame line are obtained;
[0031] Identify the form in the bill image according to the information of each intersection, the information of the horizontal form frame line, and the information of the vertical form frame line;
[0032] Marking positions of all intersections of the identified table, and sorting the position marks according to a predetermined sorting rule to generate a position sequence;
[0033] The pixel distances between each intersection point and a predefined position point in the position sequence are calculated respectively, and each calculated pixel distance is normalized to obtain a feature vector of the table.
[0034] Preferably, the method further comprises the steps of:
[0035] If it is determined that the bill type corresponding to the bill image to be identified includes multiple subtypes, the bill type is identified according to a pre-trained classifier to identify the subtype corresponding to the bill image to be identified.
[0036] Preferably, the training process of the pre-trained classifier includes:
[0037] Construct the structural Haar feature of the bill type and form a new feature library with the basic Haar feature, and use the feature library to extract sample feature values;
[0038] The Adaboost algorithm is used to train the classifier, extract the adaptive classification threshold, and obtain the best weak classifier;
[0039] Train multiple weak classifiers through multiple iterations and average them into a strong classifier;
[0040] A plurality of strong classifiers are trained to form a cascade classifier, wherein the cascade classifier is a trained classifier.
[0041] In addition, to achieve the above objectives, the present invention also proposes a computer-readable storage medium, which stores a bill recognition program, and the bill recognition program can be executed by at least one processor so that the at least one processor executes the steps of the bill recognition method as described above.
[0042] The electronic device, bill recognition method and storage medium proposed in the present invention perform straight line detection on the form in the bill image to be recognized, obtain the positional relationship between each form frame line and each form frame line in the bill image; calculate the feature vector of the bill image according to the positional relationship between each form frame line and each form frame line; calculate the similarity between the feature vector of the form and the standard vector of each type of bill form determined in advance, and if the similarity between the standard vector of a certain type of bill form and the feature vector of the form is less than or equal to the preset similarity threshold, the bill image to be recognized is determined to be a bill of this type. The type of bill image can be accurately identified, saving labor costs and improving work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 is a schematic diagram of an optional hardware architecture of the electronic device proposed by the present invention;
[0044] Figure 2 It is a schematic diagram of a program module of a bill recognition program in an embodiment of an electronic device of the present invention;
[0045] Figure 3 It is an implementation flow chart of a preferred embodiment of the bill identification method of the present invention.
[0046] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical scheme and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0048] It should be noted that the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0049] See also Figure 1 , which is a schematic diagram of an optional hardware architecture of an electronic device proposed by the present invention. In this embodiment, the electronic device 10 may include, but is not limited to, a memory 11, a processor 12, and a network interface 13 that can communicate with each other through a communication bus 14. It should be noted that Figure 1 The electronic device 10 is shown only with components 11 - 14 , but it is understood that implementing all of the components shown is not a requirement, and more or fewer components may alternatively be implemented.
[0050] The memory 11 includes at least one type of computer-readable storage medium, and the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of the electronic device 10, such as a hard disk or memory of the electronic device 10. In other embodiments, the memory 11 may also be an external storage device of the electronic device 10, such as a plug-in hard disk equipped on the electronic device 10, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Of course, the memory 11 may also include both the internal storage unit of the electronic device 10 and its external storage device. In this embodiment, the memory 11 is generally used to store the operating system and various application software installed on the electronic device 10, such as a bill recognition program, etc. In addition, the memory 11 can also be used to temporarily store various types of data that have been output or are to be output.
[0051] In some embodiments, the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 12 is generally used to control the overall operation of the electronic device 10. In this embodiment, the processor 12 is used to run the program code stored in the memory 11 or process data, such as running a bill recognition program.
[0052] The network interface 13 may include a wireless network interface or a wired network interface. The network interface 13 is generally used to establish a communication connection between the electronic device 10 and other electronic devices.
[0053] The communication bus 14 is used to realize the communication connection between the components 11-13.
[0054] Figure 1 Only the electronic device 10 having components 11 - 14 and a bill recognition program is shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0055] Optionally, the electronic device 10 may further include a user interface ( Figure 1 (not shown in the figure), the user interface may include a display, an input unit such as a keyboard, wherein the user interface may also include a standard wired interface, a wireless interface, etc.
[0056] Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED touch device, etc. Further, the display may also be referred to as a display screen or a display unit, which is used to display information processed in the electronic device 10 and to display a visual user interface.
[0057] Optionally, in some embodiments, the electronic device 10 may further include an audio unit (audio unit Figure 1 (not shown in the figure), the audio unit can convert the received or stored audio data into an audio signal when the electronic device 10 is in a call signal receiving mode, a talk mode, a recording mode, a voice recognition mode, a broadcast receiving mode, etc.; further, the electronic device 10 may also include an audio output unit, which outputs the audio signal converted by the audio unit, and the audio output unit can also provide audio output related to a specific function performed by the electronic device 10 (such as a call signal reception sound, a message reception sound, etc.), and the audio output unit may include a speaker, a buzzer, etc.
[0058] Optionally, in some embodiments, the electronic device 10 may further include an alarm unit (not shown in the figure), which may provide an output to notify the electronic device 10 of the occurrence of an event. Typical events may include call reception, message reception, key signal input, touch input, and the like. In addition to audio or video output, the alarm unit may provide output in different ways to notify the occurrence of an event. For example, the alarm unit may provide an output in the form of a vibration, and when a call, message, or some other event that may cause the electronic device 10 to enter a communication mode is received, the alarm unit may provide a tactile output (i.e., vibration) to notify the user thereof.
[0059] In one embodiment, when the bill recognition program stored in the memory 11 is executed by the processor 12, the following operations are implemented:
[0060] A1, performing straight line detection on the form in the bill image to be recognized, and obtaining the positional relationship between each form frame line and each form frame line in the bill image;
[0061] Specifically, before the step of performing straight line detection on the form in the bill image to be identified, the bill image is also processed; specifically, the processing method includes denoising the bill image, such as performing Gaussian blur denoising on a 5*5 window, performing image correction on the bill image, such as performing edge detection on the bill image, and performing appropriate rotation correction in the case of tilt, performing corresponding mapping correction for stretching, etc., and performing bill interception processing on the bill image; further, if it is detected that the bill image contains a closed table of a first preset size and a second preset size (the first preset size is a commonly used bill size, and the second preset size is a commonly used size of a bill sub-copy), only the table of the second preset size is selected as the bill to be identified. It should be noted that the bill image usually includes bill images such as bank drafts, acceptance bills, bank promissory notes, settlement business orders, and deposit slips.
[0062] Furthermore, for the form in the bill image, its line segments are mostly regular straight lines, and the line detection can obtain the positional relationship between each form frame line of the form and each form frame line, wherein the form frame line represents each line segment in the form.
[0063] A2, calculating a feature vector of the bill image according to the positional relationship between each form frame line and each form frame line;
[0064] Specifically, based on the positional relationship between each form frame line and each form frame line, each intersection point of the form frame line can be extracted to obtain information of each intersection point, as well as information of the horizontal form frame line and information of the vertical form frame line in each form frame line; based on the information of each intersection point, the information of the horizontal form frame line and the information of the vertical form frame line, the table in the bill image can be identified.
[0065] Furthermore, all the intersections of the identified table are marked with positions, and the position marks are sorted according to a predetermined sorting rule to generate a position sequence; specifically, the predetermined sorting rule is to sort the position marks in order from top to bottom and from left to right to generate a position sequence; the pixel distance between each intersection and a predefined position point in the position sequence (for example, the first position point in the position sequence) is calculated respectively, and each calculated pixel distance is normalized to obtain a feature vector of the table.
[0066] A3, calculate the similarity between the feature vector of the table and the pre-determined standard vector of each type of bill table. If the similarity between the standard vector of a certain type of bill table and the feature vector of the table is less than or equal to a preset similarity threshold, determine that the bill image to be identified is a bill of this type.
[0067] Furthermore, if the similarity between the standard vector of each type of bill table and the feature vector of the table is greater than a preset similarity threshold, it is determined that the bill images to be identified do not belong to the predetermined types of bills.
[0068] Furthermore, if it is determined that the bill type corresponding to the bill image to be identified includes multiple subtypes, the bill type is identified according to a pre-trained classifier to identify the subtype corresponding to the bill image to be identified.
[0069] Specifically, the training process of the pre-trained classifier includes:
[0070] Construct the structural Haar feature of the bill type and form a new feature library with the basic Haar feature, and use the feature library to extract sample feature values;
[0071] The Adaboost algorithm is used to train the classifier, extract the adaptive classification threshold, and obtain the best weak classifier;
[0072] Train multiple weak classifiers through multiple iterations and average them into a strong classifier;
[0073] A plurality of strong classifiers are trained to form a cascade classifier; the cascade classifier is a trained classifier.
[0074] Specifically, the step of constructing the structural Haar feature of the bill type includes: designing three structural Haar rectangular features of the bill type, including the Haar features of the number of rows and types contained in the bill type, wherein the number of columns contained in each Haar row and the Haar features of the printed fields contained in the columns, and the number of rows contained in each column and the Haar features of the printed fields contained in the rows;
[0075] Furthermore, a new Haar feature library is formed by combining five basic Haar features including horizontal edge, vertical edge, horizontal center, vertical center and diagonal features;
[0076] The integral graph acceleration algorithm is used to extract all sample eigenvalues.
[0077] Furthermore, in the step of using the Adaboost algorithm to train the classifier, extract the adaptive classification threshold, and obtain the best weak classifier, the weak classifier h of the i-th Haar feature on the training sample set is i
[0078]
[0079] Where x represents the sample, feai(x) is the value of the i-th class Haar feature feai on sample x, pi is the classification direction symbol, pi∈[-1,+1], θi is the threshold of the classifier hi; the training process of hi is as follows: let the vector composed of the eigenvalues of all training samples be Vec, sort the elements in Vec from small to large to obtain a new vector SortVec; traverse the eigenvalues after the above sorting, and calculate the following four values for each eigenvalue SortVec[j]: (1) the sum of the weights of all samples of this bill type T+; (2) the sum of the weights of all samples of non-this bill type T-; (3) the sum of the weights of all samples of this bill type before the sample corresponding to this eigenvalue SortVec[j] S+; (4) the sum of the weights of all samples of non-this bill type before the sample corresponding to this eigenvalue SortVec[j] S-; calculate the classification error under the sorted eigenvalues according to the following formula:
[0080] ej=min(S++(T--S-),S-+(T+-S+))
[0081] Traverse all features and select the weak classifier trained with the feature with the smallest classification error as the optimal weak classifier;
[0082] The position with the smallest classification error obtained above is counted as η, and the prior probability of the class output being Label when the eigenvalue is less than or equal to SortVec[η] is
[0083] P1(Lable|SortVec[k]≤SortVec[eta])=∑yk=Lablewk / ∑k≤ηwk
[0084] When the eigenvalue is greater than or equal to SortVec[η], the prior probability of the category output being -Label is:
[0085] P2(-Lable|SortVec[k]≥SortVec[η+1])=∑yk=-Lablewk / ∑k≤η+1wk
[0086] Among them, Lable∈[-1,+1], wk is the weight of the training sample with subscript k, and yk is the true label of the training sample with subscript k; according to the distribution law of the samples, the classification threshold is set as follows:
[0087]
[0088] Using the above method, read in the bill type corresponding to the bill image to be identified; generate sub-windows of different sizes and positions, assuming that the number of candidate sub-windows obtained is num; import the parameters of the cascade classifier; for each sub-window, normalize it to 24×24, and use the Haar features selected in the training process to calculate the corresponding feature values; use the bill type classifier to classify each obtained sub-window, if it is the corresponding sub-type, save the position information of the sub-window to obtain the initial detection result; perform grayscale symmetry operation on the initial detection result to eliminate the misjudged window; classify and merge the sub-windows selected for detection at different sizes to obtain the final classification result.
[0089] It can be known from the above-mentioned embodiments that the electronic device proposed by the present invention performs straight line detection on the form in the bill image to be identified, obtains the positional relationship between each form frame line in the bill image and each form frame line; calculates the feature vector of the bill image according to the positional relationship between each form frame line and each form frame line; calculates the similarity between the feature vector of the form and the standard vector of each type of bill form determined in advance, and if the similarity between the standard vector of a certain type of bill form and the feature vector of the form is less than or equal to the preset similarity threshold, the bill image to be identified is determined to be a bill of this type. It can accurately identify the type of bill image, save labor costs, and improve work efficiency.
[0090] In addition, the bill recognition program of the present invention can be described by program modules with the same functions according to the different functions implemented by its various parts. Figure 2 , is a schematic diagram of the program module of the bill recognition program in an embodiment of the electronic device of the present invention. In this embodiment, the bill recognition program can be divided into an acquisition module 201, a calculation module 202 and a second calculation module 203 according to the different functions implemented by each part. As can be seen from the above description, the program module referred to in the present invention refers to a series of computer program instruction segments that can complete specific functions, which is more suitable for describing the execution process of the bill recognition program in the electronic device 10 than a program. The functions or operation steps implemented by the modules 201-203 are similar to those above and will not be described in detail here. For example, for example:
[0091] The acquisition module 201 is used to perform straight line detection on the form in the bill image to be identified, and obtain the positional relationship between each form frame line and each form frame line in the bill image;
[0092] The first calculation module 202 is used to calculate the feature vector of the bill image according to the position relationship between each form frame line and each form frame line;
[0093] The second calculation module 203 is used to calculate the similarity between the feature vector of the table and the pre-determined standard vector of each type of bill table. If the similarity between the standard vector of a certain type of bill table and the feature vector of the table is less than or equal to a preset similarity threshold, the bill image to be identified is determined to be a bill of that type.
[0094] In addition, the present invention also proposes a bill recognition method, see Figure 3 As shown, the bill recognition method includes the following steps:
[0095] S301, performing straight line detection on the form in the bill image to be recognized, and obtaining the positional relationship between each form frame line and each form frame line in the bill image;
[0096] Specifically, before the step of performing straight line detection on the form in the bill image to be identified, the bill image is also processed; specifically, the processing method includes denoising the bill image, such as performing Gaussian blur denoising on a 5*5 window, performing image correction on the bill image, such as performing edge detection on the bill image, and performing appropriate rotation correction in the case of tilt, performing corresponding mapping correction for stretching, etc., and performing bill interception processing on the bill image; further, if it is detected that the bill image contains a closed table of a first preset size and a second preset size (the first preset size is a commonly used bill size, and the second preset size is a commonly used size of a bill sub-copy), only the table of the second preset size is selected as the bill to be identified. It should be noted that the bill image usually includes bill images such as bank drafts, acceptance bills, bank promissory notes, settlement business orders, and deposit slips.
[0097] Furthermore, for the form in the bill image, most of its line segments are regular straight lines, and by performing straight line detection on it, the positional relationship between each form frame line of the form and each form frame line can be obtained. Among them, the form frame line represents each line segment in the form.
[0098] S302, calculating a feature vector of the bill image according to the positional relationship between each form frame line and each form frame line;
[0099] Specifically, based on the positional relationship between each form frame line and each form frame line, each intersection point of the form frame line can be extracted to obtain information of each intersection point, as well as information of the horizontal form frame line and information of the vertical form frame line in each form frame line; based on the information of each intersection point, the information of the horizontal form frame line and the information of the vertical form frame line, the table in the bill image can be identified.
[0100] Furthermore, all the intersections of the identified table are marked with positions, and the position marks are sorted according to a predetermined sorting rule to generate a position sequence; specifically, the predetermined sorting rule is to sort the position marks in order from top to bottom and from left to right to generate a position sequence; the pixel distance between each intersection and a predefined position point in the position sequence (for example, the first position point in the position sequence) is calculated respectively, and each calculated pixel distance is normalized to obtain a feature vector of the table.
[0101] S303, calculating the similarity between the feature vector of the table and the pre-determined standard vector of each type of bill table. If the similarity between the standard vector of a certain type of bill table and the feature vector of the table is less than or equal to a preset similarity threshold, the bill image to be identified is determined to be a bill of that type.
[0102] Furthermore, if the similarity between the standard vector of each type of bill table and the feature vector of the table is greater than a preset similarity threshold, it is determined that the bill images to be identified do not belong to the predetermined types of bills.
[0103] Furthermore, if it is determined that the bill type corresponding to the bill image to be identified includes multiple subtypes, the bill type is identified according to a pre-trained classifier to identify the subtype corresponding to the bill image to be identified.
[0104] Specifically, the training process of the pre-trained classifier includes:
[0105] Construct the structural Haar feature of the bill type and form a new feature library with the basic Haar feature, and use the feature library to extract sample feature values;
[0106] The Adaboost algorithm is used to train the classifier, extract the adaptive classification threshold, and obtain the best weak classifier;
[0107] Train multiple weak classifiers through multiple iterations and average them into a strong classifier;
[0108] A plurality of strong classifiers are trained to form a cascade classifier; the cascade classifier is a trained classifier.
[0109] Specifically, the step of constructing the structural Haar feature of the bill type includes: designing three structural Haar rectangular features of the bill type, including the Haar features of the number of rows and types contained in the bill type, wherein the number of columns contained in each Haar row and the Haar features of the printed fields contained in the columns, and the number of rows contained in each column and the Haar features of the printed fields contained in the rows;
[0110] Furthermore, a new Haar feature library is formed by combining five basic Haar features including horizontal edge, vertical edge, horizontal center, vertical center and diagonal features;
[0111] The integral graph acceleration algorithm is used to extract all sample eigenvalues.
[0112] Furthermore, in the step of using the Adaboost algorithm to train the classifier, extract the adaptive classification threshold, and obtain the best weak classifier, the weak classifier h of the i-th Haar feature on the training sample set is i
[0113]
[0114] Where x represents the sample, feai(x) is the value of the i-th class Haar feature feai on sample x, pi is the classification direction symbol, pi∈[-1,+1], θi is the threshold of the classifier hi; the training process of hi is as follows: let the vector composed of the eigenvalues of all training samples be Vec, sort the elements in Vec from small to large to obtain a new vector SortVec; traverse the eigenvalues after the above sorting, and calculate the following four values for each eigenvalue SortVec[j]: (1) the sum of the weights of all samples of this bill type T+; (2) the sum of the weights of all samples of non-this bill type T-; (3) the sum of the weights of all samples of this bill type before the sample corresponding to this eigenvalue SortVec[j] S+; (4) the sum of the weights of all samples of non-this bill type before the sample corresponding to this eigenvalue SortVec[j] S-; calculate the classification error under the sorted eigenvalues according to the following formula:
[0115] ej=min(S++(T--S-),S-+(T+-S+))
[0116] Traverse all features and select the weak classifier trained with the feature with the smallest classification error as the optimal weak classifier;
[0117] The position with the smallest classification error obtained above is counted as η, and the prior probability of the class output being Label when the eigenvalue is less than or equal to SortVec[η] is
[0118] P1(Lable|SortVec[k]≤SortVec[eta])=∑yk=Lablewk / ∑k≤ηwk
[0119] When the eigenvalue is greater than or equal to SortVec[η], the prior probability of the category output being -Label is:
[0120] P2(-Lable|SortVec[k]≥SortVec[η+1])=∑yk=-Lablewk / ∑k≤η+1wk
[0121] Among them, Lable∈[-1,+1], wk is the weight of the training sample with subscript k, and yk is the true label of the training sample with subscript k; according to the distribution law of the samples, the classification threshold is set as follows:
[0122]
[0123] Using the above method, read in the bill type corresponding to the bill image to be identified; generate sub-windows of different sizes and positions, assuming that the number of candidate sub-windows obtained is num; import the parameters of the cascade classifier; for each sub-window, normalize it to 24×24, and use the Haar features selected in the training process to calculate the corresponding feature values; use the bill type classifier to classify each obtained sub-window, if it is the corresponding sub-type, save the position information of the sub-window to obtain the initial detection result; perform grayscale symmetry operation on the initial detection result to eliminate the misjudged window; classify and merge the sub-windows selected for detection at different sizes to obtain the final classification result.
[0124] It can be seen from the above-mentioned embodiments that the bill recognition method proposed by the present invention performs straight line detection on the form in the bill image to be recognized, obtains the positional relationship between each form frame line in the bill image and each form frame line; calculates the feature vector of the bill image according to the positional relationship between each form frame line and each form frame line; calculates the similarity between the feature vector of the form and the pre-determined standard vector of each type of bill form, and if the similarity between the standard vector of a certain type of bill form and the feature vector of the form is less than or equal to the preset similarity threshold, the bill image to be recognized is determined to be a bill of this type. It can accurately identify the type of bill image, save labor costs, and improve work efficiency.
[0125] In addition, the present invention further provides a computer-readable storage medium, on which a bill recognition program is stored, and when the bill recognition program is executed by a processor, the following operations are implemented:
[0126] Perform straight line detection on the form in the bill image to be recognized, and obtain the positional relationship between each form frame line and each form frame line in the bill image;
[0127] Calculating a feature vector of the bill image according to the positional relationship between each form frame line and each form frame line;
[0128] The similarity between the feature vector of the table and the predetermined standard vector of each type of bill table is calculated. If the similarity between the standard vector of a certain type of bill table and the feature vector of the table is less than or equal to a preset similarity threshold, the bill image to be identified is determined to be a bill of that type.
[0129] The specific implementation process of the computer-readable storage medium of the present invention is similar to the specific implementation process of the above-mentioned electronic device and bill recognition method, and will not be repeated here.
[0130] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM / RAM, disk, CD), including a number of instructions to enable a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention. The above is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the present invention specification and drawings, or directly or indirectly used in other related technical fields, are similarly included in the patent protection scope of the present invention.
Claims
1. An electronic device, characterized in that: The electronic device includes a memory and a processor connected to the memory, wherein the processor is used to execute a bill recognition program stored in the memory, and the bill recognition program implements the following steps when executed by the processor: A1. De-noising the bill image to be identified, performing straight line detection on the form in the processed bill image to be identified, and obtaining the positional relationship between each form frame line and each form frame line in the bill image; A2. According to the positional relationship between each form frame line and each form frame line, the table in the bill image is identified, all intersections of the table are marked, and the position marks are sorted according to a predetermined sorting rule to generate a position sequence, and the pixel distance between each intersection and a predefined position point in the position sequence is calculated respectively, and each calculated pixel distance is normalized to obtain a feature vector of the table; A3, calculating the similarity between the feature vector of the table and the pre-determined standard vector of each type of bill table, if the similarity between the standard vector of a certain type of bill table and the feature vector of the table is less than or equal to a preset similarity threshold, then determining that the bill image to be identified is a bill of this type; A4. Read in the type of bill corresponding to the bill image to be identified, generate sub-windows of different sizes and positions, detect all sub-windows according to the pre-trained classifier to obtain an initial detection result, perform grayscale symmetry operation on the initial detection result and delete the sub-windows of the misjudged type, classify and merge the sub-windows in the initial detection result, obtain the final classification result and use it as the sub-type of the bill image to be identified, and the training process of the pre-trained classifier includes: designing three structural Haar rectangular features of the bill type, combining five basic Haar features including horizontal edge, vertical edge, horizontal center, vertical center and diagonal features to form a new Haar feature library, using integral graph acceleration algorithm to extract all sample feature values, using Adaboost algorithm to train classifier, extracting adaptive classification threshold, obtaining the best weak classifier, iteratively training multiple weak classifiers, weighted averaging into strong classifiers, training multiple strong classifiers, forming a cascade classifier, the cascade classifier is a trained classifier, wherein the three structural Haar rectangular features of the bill type are designed, including the Haar features of the number of rows and types contained in the bill type, wherein the number of columns contained in each row of the Haar and the Haar features of the printed fields contained in the number of columns, the number of rows contained in each column and the Haar features of the printed fields contained in the number of rows.
2. The electronic device according to claim 1, wherein: The step of identifying the table in the bill image according to the positional relationship between each form frame line and each form frame line includes: According to the positional relationship between each form frame line and each form frame line, each intersection point of the form frame line is extracted, and information of each intersection point is obtained, and information of the horizontal form frame line and information of the vertical form frame line in each form frame line are obtained; The table in the bill image is identified according to the information of each intersection, the information of the horizontal form frame line and the information of the vertical form frame line.
3. A bill recognition method, characterized in that: The method comprises the following steps: S1. Perform denoising on the bill image to be identified, perform straight line detection on the form in the processed bill image to be identified, and obtain the positional relationship between each form frame line and each form frame line in the bill image; S2. According to the positional relationship between each form frame line and each form frame line, identify the table in the bill image, mark all intersections of the table, sort the position marks according to a predetermined sorting rule, generate a position sequence, calculate the pixel distance between each intersection and a predefined position point in the position sequence, normalize the calculated pixel distances, and obtain a feature vector of the table; S3, calculating the similarity between the feature vector of the table and the pre-determined standard vector of each type of bill table, if the similarity between the standard vector of a certain type of bill table and the feature vector of the table is less than or equal to a preset similarity threshold, then determining that the bill image to be identified is a bill of this type; S4, read in the type of bill corresponding to the bill image to be identified, generate sub-windows of different sizes and positions, detect all sub-windows according to the pre-trained classifier to obtain an initial detection result, perform grayscale symmetry operation on the initial detection result and delete the sub-windows of the misjudged type, classify and merge the sub-windows in the initial detection result to obtain the final classification result as the sub-type of the bill image to be identified, and the training process of the pre-trained classifier includes: designing three structural Haar rectangular features of the bill type, combining five basic Haar features including horizontal edge, vertical edge, horizontal center, vertical center and diagonal features to form a new Haar feature library, using integral graph acceleration algorithm to extract all sample feature values, using Adaboost algorithm to train classifier, extracting adaptive classification threshold, obtaining the best weak classifier, iteratively training multiple weak classifiers, weighted averaging into strong classifiers, training multiple strong classifiers, forming a cascade classifier, the cascade classifier is a trained classifier, wherein the three structural Haar rectangular features of the bill type are designed, including the Haar features of the number of rows and types contained in the bill type, wherein the number of columns contained in each row of the Haar and the Haar features of the printed fields contained in the number of columns, the number of rows contained in each column and the Haar features of the printed fields contained in the number of rows.
4. The bill recognition method according to claim 3, characterized in that: The step of identifying the table in the bill image according to the positional relationship between each form frame line and each form frame line includes: According to the positional relationship between each form frame line and each form frame line, each intersection point of the form frame line is extracted, and information of each intersection point is obtained, and information of the horizontal form frame line and information of the vertical form frame line in each form frame line are obtained; The table in the bill image is identified according to the information of each intersection, the information of the horizontal form frame line and the information of the vertical form frame line.
5. A computer-readable storage medium storing a bill recognition program, wherein the bill recognition program can be executed by at least one processor so that the at least one processor performs the steps of the bill recognition method as described in any one of claims 3 to 4.
Citation Information
Patent Citations
Method and device for identifying forms
CN103577817A
Vehicle detection method
CN107862341A
