Card image synthesis method and device, card detection method and device, medium and equipment

Through the card certificate image synthesis method, a variety of card certificate images are generated using the template library and element library, which solves the problem of insufficient training samples of card certificate OCR model and improves the accuracy of the model.

CN119313777APending Publication Date: 2025-01-14BEIJING TECHSHINO TECHNOLOGY CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310862866.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-13
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

The existing OCR deep neural network model lacks rich training samples, which makes it less accurate and difficult to meet actual needs.

Method used

By designing a card certificate image synthesis method, using a pre-established card certificate template library and element library, various card certificate images are synthesized based on layout information, location and change information, and the training samples are enriched.

Benefits of technology

The large batch of synthesized card certificate training data significantly improves the training accuracy of deep neural network models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119313777A_ABST
    Figure CN119313777A_ABST
Patent Text Reader

Abstract

The invention discloses a card image synthesis method and device, a card detection method and device, a medium and equipment, and belongs to the field of image processing and computer vision. According to the method, multiple card templates are established in advance, and various to-be-synthesized elements needing to be synthesized are determined for each card template. And during synthesis, determining a preset position of the to-be-synthesized element on the card template according to the position information and the change information of the to-be-synthesized element. Due to the existence of the change information, the positions and the sizes of the to-be-synthesized elements on the card template are not fixed, but are different according to different values of the change information, so that various different synthesized card images can be obtained, and a large amount of synthesized card training data can be obtained; the training samples of the deep neural network model for card OCR are greatly enriched, and the accuracy of the trained deep neural network model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing and computer vision, and in particular to a card image synthesis and card detection method, device, medium and equipment. Background Art

[0002] With the development of computer vision technology, the application of card inspection is becoming more and more widespread. Card inspection is to perform optical character recognition (OCR) on cards through computer vision technology. Card OCR is generally completed through a deep neural network model, and training a deep neural network model that meets the requirements requires a huge amount of data, at least in the order of tens of thousands. However, because card data involves personal privacy information, it is generally sensitive and difficult to obtain in large quantities. Therefore, the training of the deep neural network model used for card OCR lacks rich training samples, resulting in training difficulties. The accuracy of the trained deep neural network model is not high, and it is difficult to meet the card OCR requirements in actual scenarios. Summary of the invention

[0003] In order to address the defects of the prior art, the present application provides a card image synthesis and card detection method, device, medium and equipment, which can synthesize various different card images in batches, greatly enrich the training samples of the deep neural network model used for card OCR, and improve the accuracy of the trained deep neural network model.

[0004] This application provides the following technical solutions:

[0005] In a first aspect, the present application provides a card image synthesis method, the method comprising:

[0006] According to the layout information of the card image to be synthesized, a card template corresponding to the layout information is obtained from a pre-established card template library;

[0007] Obtaining each element to be synthesized corresponding to the card template;

[0008] For any element to be synthesized, the element to be synthesized and the position information and change information corresponding to the element to be synthesized are obtained from a pre-established element library, a preset position of the element to be synthesized on the card template is determined according to the position information and the change information, and the element to be synthesized is synthesized to the preset position of the card template;

[0009] After each element to be synthesized is synthesized into the card template, a synthesized card image is obtained.

[0010] Further, the elements to be synthesized include first-category elements, position information of the first-category elements is stored via an element position dictionary, and change information of the first-category elements is stored via an element perturbation dictionary;

[0011] The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises:

[0012] The first type of elements are obtained from a pre-established element library, the position information is obtained from the element position dictionary, the change information is obtained from the element disturbance dictionary, a random function is called to generate a change value, and the preset position of the first type of elements on the card template is determined.

[0013] Furthermore, the elements to be synthesized include second-category elements, the positions of the second-category elements follow a certain element to be synthesized being followed, and the position information of the second-category elements is stored via a following displacement dictionary, and the following displacement dictionary stores the position offset between the second-category elements and the element to be synthesized being followed;

[0014] The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises:

[0015] The second type of element is obtained from a pre-established element library, and the position offset is obtained from the follow displacement dictionary, and the preset position of the second type of element on the card template is determined according to the position of the element to be synthesized on the card template and the position offset.

[0016] Further, the change information of the second type of elements is stored via an element perturbation dictionary;

[0017] The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises:

[0018] The second type of element is obtained from a pre-established element library, the position offset is obtained from the follow-up displacement dictionary, the change information is obtained from the element perturbation dictionary, a random function is called to generate a change value, and the preset position of the second type of element on the card template is determined according to the position of the element to be synthesized on the card template, the position offset and the change value.

[0019] Further, the elements to be synthesized include third-category elements, the third-category elements include at least two associated elements whose positions are mutually associated, the position information of each of the associated elements is stored via an element position dictionary, and the change information of each of the associated elements is stored via an element perturbation dictionary;

[0020] The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises:

[0021] Obtain the third type of elements from a pre-established element library, and for each of the associated elements, obtain the position information from the element position dictionary, obtain the change information from the element disturbance dictionary, call a random function to generate a change value, and determine the preset position of each of the associated elements on the card template;

[0022] According to the set first probability, the preset positions of the associated elements are exchanged with each other.

[0023] Further, the elements to be synthesized include fourth-category elements, position information of the fourth-category elements is stored via a plurality of element position dictionaries, and change information of the fourth-category elements is stored via a plurality of element perturbation dictionaries;

[0024] The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises:

[0025] The fourth type of element is obtained from a pre-established element library, and according to a set second probability, one is randomly selected from multiple element position dictionaries to obtain the position information, one is randomly selected from multiple element disturbance dictionaries to obtain the change information, a random function is called to generate a change value, and the preset position of the fourth type of element on the card template is determined.

[0026] Furthermore, the element position dictionary includes the element name of the element to be synthesized and the coordinates of the diagonal points of the corresponding area of ​​the element to be synthesized, the element disturbance dictionary includes the element name, horizontal movable range and height range of the element to be synthesized, and the following displacement dictionary includes the element name of the element to be synthesized, the element name of the element to be synthesized to be followed, the horizontal movement range and vertical movement range of the position offset.

[0027] Furthermore, the step of obtaining the elements to be synthesized corresponding to the card template further includes:

[0028] Determine whether the card image to be synthesized needs a background. If so, obtain a background image from a pre-established background image library, adjust the obtained background image to the size of the card template, and use the card template as the alpha channel of the background image.

[0029] In a second aspect, the present application provides a card image synthesis device, characterized in that the device comprises:

[0030] A card template acquisition module, used to acquire a card template corresponding to the layout information of the card image to be synthesized from a pre-established card template library;

[0031] A module for determining elements to be synthesized, used for obtaining the elements to be synthesized corresponding to the card template;

[0032] An element synthesis module is used to obtain, for any element to be synthesized, the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, determine the preset position of the element to be synthesized on the card template according to the position information and the change information, and synthesize the element to be synthesized to the preset position of the card template;

[0033] The card image acquisition module is used to obtain a synthesized card image after synthesizing each element to be synthesized into the card template.

[0034] Further, the elements to be synthesized include first-category elements, position information of the first-category elements is stored via an element position dictionary, and change information of the first-category elements is stored via an element perturbation dictionary;

[0035] Accordingly, the element synthesis module is used for:

[0036] The first type of elements are obtained from a pre-established element library, the position information is obtained from the element position dictionary, the change information is obtained from the element disturbance dictionary, a random function is called to generate a change value, and the preset position of the first type of elements on the card template is determined.

[0037] Furthermore, the elements to be synthesized include second-category elements, the positions of the second-category elements follow a certain element to be synthesized being followed, and the position information of the second-category elements is stored via a following displacement dictionary, and the following displacement dictionary stores the position offset between the second-category elements and the element to be synthesized being followed;

[0038] Accordingly, the element synthesis module is used for:

[0039] The second type of element is obtained from a pre-established element library, and the position offset is obtained from the follow displacement dictionary, and the preset position of the second type of element on the card template is determined according to the position of the element to be synthesized on the card template and the position offset.

[0040] Further, the change information of the second type of elements is stored via an element perturbation dictionary;

[0041] Accordingly, the element synthesis module is used for:

[0042] The second type of element is obtained from a pre-established element library, the position offset is obtained from the follow-up displacement dictionary, the change information is obtained from the element perturbation dictionary, a random function is called to generate a change value, and the preset position of the second type of element on the card template is determined according to the position of the element to be synthesized on the card template, the position offset and the change value.

[0043] Further, the elements to be synthesized include third-category elements, the third-category elements include at least two associated elements whose positions are mutually associated, the position information of each of the associated elements is stored via an element position dictionary, and the change information of each of the associated elements is stored via an element perturbation dictionary;

[0044] Accordingly, the element synthesis module is used for:

[0045] The third category of elements is obtained from a pre-established element library, and for each of the associated elements, the position information is obtained from the element position dictionary, the change information is obtained from the element disturbance dictionary, a random function is called to generate a change value, and a preset position of each of the associated elements on the card template is determined; according to a set first probability, the preset positions of the associated elements are exchanged with each other.

[0046] Further, the elements to be synthesized include fourth-category elements, position information of the fourth-category elements is stored via a plurality of element position dictionaries, and change information of the fourth-category elements is stored via a plurality of element perturbation dictionaries;

[0047] Accordingly, the element synthesis module is used for:

[0048] The fourth type of element is obtained from a pre-established element library, and according to a set second probability, one is randomly selected from multiple element position dictionaries to obtain the position information, one is randomly selected from multiple element disturbance dictionaries to obtain the change information, a random function is called to generate a change value, and the preset position of the fourth type of element on the card template is determined.

[0049] Furthermore, the element position dictionary includes the element name of the element to be synthesized and the coordinates of the diagonal points of the corresponding area of ​​the element to be synthesized, the element disturbance dictionary includes the element name, horizontal movable range and height range of the element to be synthesized, and the following displacement dictionary includes the element name of the element to be synthesized, the element name of the element to be synthesized to be followed, the horizontal movement range and vertical movement range of the position offset.

[0050] Furthermore, the device also includes:

[0051] The background synthesis module is used to determine whether the card image to be synthesized needs a background. If so, the background image is obtained from a pre-established background image library, the obtained background image is adjusted to the size of the card template, and the card template is used as the alpha channel of the background image.

[0052] In a third aspect, the present application provides a computer-readable storage medium for card image synthesis, comprising a memory for storing processor-executable instructions, wherein the instructions, when executed by the processor, implement the steps of the card image synthesis method described in the first aspect.

[0053] In a fourth aspect, the present application provides a device for card image synthesis, characterized in that it includes at least one processor and a memory storing computer executable instructions, and when the processor executes the instructions, the steps of the card image synthesis method described in the first aspect are implemented.

[0054] In a fifth aspect, the present application provides a card detection method, the method comprising:

[0055] Obtain the image of the card to be tested;

[0056] Inputting the card image to be detected into the trained deep neural network model to obtain a card detection result;

[0057] Among them, the training set of the deep neural network model includes the card image synthesized by the card image synthesis method.

[0058] In a sixth aspect, the present application provides a card detection device, the device comprising:

[0059] The image acquisition module to be detected is used to obtain the card image to be detected;

[0060] A card detection module, used to input the card image to be detected into the trained deep neural network model to obtain a card detection result;

[0061] Among them, the training set of the deep neural network model includes the card image synthesized by the card image synthesis method.

[0062] In a seventh aspect, the present application provides a computer-readable storage medium for card detection, comprising a memory for storing processor-executable instructions, wherein the instructions, when executed by the processor, implement the steps of the card detection method described in the fifth aspect.

[0063] In an eighth aspect, the present application provides a device for card detection, characterized in that it includes at least one processor and a memory storing computer-executable instructions, and when the processor executes the instructions, the steps of the card detection method described in the fifth aspect are implemented.

[0064] This application has the following beneficial effects:

[0065] The present application pre-establishes a variety of card templates, and determines various elements to be synthesized for each card template. During synthesis, the preset position of the element to be synthesized on the card template is determined by the position information and change information of the element to be synthesized. Due to the existence of the change information, the position and size of each element to be synthesized on the card template are not fixed, but vary according to the value of the change information, so various synthesized card images can be obtained. The large-scale synthesis of card training data greatly enriches the training samples of the deep neural network model used for card OCR, and improves the accuracy of the trained deep neural network model. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] Figure 1 This is a flow chart of the card image synthesis method of the present application;

[0067] Figure 2 This is an example of a card template;

[0068] Figure 3 is an example of a background image;

[0069] Figure 4 A schematic diagram of a card image synthesis device of the present application;

[0070] Figure 5 This is a flow chart of the card detection method of this application;

[0071] Figure 6 This is a schematic diagram of the card detection device of the present application. DETAILED DESCRIPTION

[0072] In order to make the technical problems, technical solutions and advantages to be solved by the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with the drawings and specific embodiments. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0073] The present application embodiment provides a card image synthesis method, such as Figure 1 As shown, the method includes:

[0074] S100: According to the layout information of the card image to be synthesized, a card template corresponding to the layout information is obtained from a pre-established card template library.

[0075] When establishing a card template library, we first researched and collected real card photos to cover all layouts of application scenarios as much as possible. For example, the layout of bank cards includes front-stamped horizontal version, front-printed horizontal version, front-printed vertical version, back-printed horizontal version, etc. The layout of identity cards includes Chinese version, minority Chinese and other versions.

[0076] The collected layout images are then standardized, such as cutting out bank cards from photos and scaling them to a fixed size (eg, 640*400).

[0077] Finally, a card template is made based on the standardized image. Generally, a card is not a rectangle, but a quasi-rectangle with arc edges. Image processing tools can be used to make the collected representative standard layouts into a base plate to obtain a card template. A series of card templates are made based on cards of various layouts and stored in the card template library.

[0078] An example of a card template is Figure 2 As shown, Figure 2 In the figure, the white area is the card template, and the black area is the area outside the arc edge. When the card image is synthesized later, the black area will be the transparent area.

[0079] After the card template library is established, in subsequent use, the card template corresponding to the layout information of the card image to be synthesized can be obtained from the card template library. The layout information can include, for example, layout identification information, and can also include layout description information.

[0080] S200: Acquire the elements to be synthesized corresponding to the card template.

[0081] When making card templates, for each layout, comprehensively determine the elements that need to be synthesized. For example, the elements of a bank card include the bank logo, bank card number, UnionPay logo, validity period, cardholder name, etc., and the elements of an ID card include name, address, citizen ID number, etc.

[0082] After determining the elements to be synthesized, collect the materials of each element. For example, the printed text on the page needs to collect and download the relevant fonts, and the bank logo needs the corresponding logo material, etc. The elements to be synthesized, the collected element materials, and the card template are stored in association. When synthesizing, the corresponding elements to be synthesized can be determined according to the card template.

[0083] S300: For any element to be synthesized, the element to be synthesized and the position information and change information corresponding to the element to be synthesized are obtained from a pre-established element library, the preset position of the element to be synthesized on the card template is determined according to the position information and the change information, and the element to be synthesized is synthesized to the preset position of the card template.

[0084] When storing each element to be synthesized, for each element to be synthesized of each card template, the position information of each element to be synthesized on the card template is determined and stored according to its characteristics. When synthesizing, the position information of the element to be synthesized is obtained according to the element to be synthesized.

[0085] The location area corresponding to the element to be synthesized is generally a rectangular area. When describing the location information of the rectangular area, it is generally represented by the coordinates of the diagonal points of the rectangular area. For example, the location of the rectangular area of ​​an element is represented by the upper left corner coordinates + the lower right corner coordinates. In this representation method, the upper left corner coordinates + the lower right corner coordinates not only represent the location of the element to be synthesized, but also represent the size of the area of ​​the element to be synthesized.

[0086] Therefore, the position information described in this application refers not only to pure position information, but also to certain size information. This application refers to the pure position information and size information (when there is size information) as position information. The position information indicates the position of the element to be synthesized, and in some cases, it may also indicate the size of the element to be synthesized.

[0087] The variation information refers to the variable conditions of the elements to be synthesized on the card template. The variation information may be the variation information of the position of the elements to be synthesized, the variation information of the size of the elements to be synthesized, or both. When storing each element to be synthesized, the variable conditions of the position and size of each element to be synthesized on the card template are determined according to its characteristics and stored as variation information. When synthesizing, the variation information is obtained according to the elements to be synthesized.

[0088] As mentioned above, the position information of the element to be synthesized indicates the position of the element to be synthesized, and in some cases also indicates the size of the element to be synthesized, and the change information of the element to be synthesized indicates the changeable situation of the position and / or size of the element to be synthesized, which can realize the flexible regulation of the position and size of the element to be synthesized within the realistic range. Therefore, after obtaining the position information and change information of the element to be synthesized, the preset position of the element to be synthesized on the card template can be determined, and the element to be synthesized can be synthesized on the card template.

[0089] S400: After each element to be synthesized is synthesized into the card template, a synthesized card image is obtained.

[0090] The present application pre-establishes a variety of card templates, and determines various elements to be synthesized for each card template. During synthesis, the preset position of the element to be synthesized on the card template is determined by the position information and change information of the element to be synthesized. Due to the existence of the change information, the position and size of each element to be synthesized on the card template are not fixed, but vary according to the value of the change information, so various synthesized card images can be obtained. The large-scale synthesis of card training data greatly enriches the training samples of the deep neural network model used for card OCR, and improves the accuracy of the trained deep neural network model.

[0091] As an improvement of the embodiment of the present application, the above-mentioned S200 further includes:

[0092] S110: Determine whether the card image to be synthesized needs a background. If so, obtain a background image from a pre-established background image library, adjust the obtained background image to the size of the card template, and use the card template as the alpha channel of the background image.

[0093] After making the card template, you can also select and make appropriate background pictures according to the actual situation, such as Figure 3 The picture shown can be used as the background of a bank card. After making the background picture, save it in the background image library. When synthesizing, if a background image is needed, select a suitable background image from the background image library. The background image can be selected randomly or according to set conditions.

[0094] After selecting the background image, adjust the background image to the size of the card template by cropping or scaling, and use the card template as the alpha channel (alpha channel, αChannel or Alpha Channel) of the background image. The alpha channel is a channel used to represent the transparency of the image. Usually, the value range of the alpha channel is 0 to 255, where 0 means completely transparent and 255 means completely opaque. Figure 2After the card template is synthesized with the background image, the white area is the opaque part and the black area is the transparent part. The background image is displayed in the opaque part and is transparent in the transparent part.

[0095] In real scenarios, the characteristics of each element to be synthesized are different. For example, some elements to be synthesized are basically fixed, the positions of some elements to be synthesized are not fixed, but have a certain range of variation (such as the position of the bank card number on the bank card is not fixed), the positions of some elements to be synthesized are related to other elements to be synthesized, etc. In view of these elements to be synthesized with different characteristics, this application classifies the elements to be synthesized and adopts different methods for synthesis.

[0096] Among them, the elements to be synthesized in the present application may include first-category elements, which are basically stationary elements. For example, for a bank card with a horizontal steel print on the front, the bank card number, cardholder name, and validity period of the elements waiting to be synthesized are basically stationary.

[0097] For the first type of elements whose positions are basically fixed, their position information is stored through an element position dictionary, and their change information is stored through an element disturbance dictionary.

[0098] The element position dictionary may include the element name of the element to be synthesized and the coordinates of the diagonal points of the corresponding area of ​​the element to be synthesized. When making the element position dictionary, the element names of all the basically fixed elements to be synthesized (such as bank card numbers, cardholder names, etc.) of the same layout and their corresponding position areas are stored in the dictionary form of "element name: Block" and named the element position dictionary. Block is a list of 4 integers: [left, up, right, down], corresponding to the upper left corner coordinates (left, up) and lower right corner coordinates (right, down) of the element position area. An example of an element position dictionary is as follows:

[0099] {

[0100] "Bank card number": [50,255,266,583];

[0101] "Bank LOGO":[333,50,367,415];

[0102] …

[0103] }

[0104] The element perturbation dictionary can include the element name, horizontal movable range and height range of the element to be synthesized. When making the element perturbation dictionary, the element names of all the basically immobile elements to be synthesized (such as bank card numbers, cardholder names, etc.) of the same layout, as well as their horizontal movable ranges and element height ranges in their blocks, are stored in the form of a dictionary of "element name: horizontal movable range + height range", named the element perturbation dictionary. The horizontal movable range and height range are in the form of ((left min, left max), (height min, height max)). An example of the element perturbation dictionary is as follows:

[0105] {

[0106] "Bank LOGO":((22,25),(0,20));

[0107] "Bank card number": ((34,37), (0,12));

[0108] …

[0109] }

[0110] For the first type of elements whose positions are basically fixed, during synthesis, the first type of elements are first obtained from the pre-established element library, and the position information is obtained from the element position dictionary, and then the change information is obtained from the element perturbation dictionary, and the random function is called to generate the change value to determine the preset position of the first type of elements on the card template.

[0111] For example, when the position of a bank card number is determined, the bank card number Block is first obtained from the element position dictionary, and then the left movable range and height range of the bank card number are obtained from the element perturbation dictionary. The random function is called to generate the left movement value and height, and finally the preset position of the bank card number is obtained.

[0112] The element position dictionary set in the present application controls the range of the position of the element to be synthesized, and the element perturbation dictionary controls the perturbation range of the element to be synthesized, thereby achieving flexible regulation of the position and size of the element to be synthesized within a realistic range.

[0113] The elements to be synthesized in the present application also include the second type of elements, which are elements to be synthesized that are fixed and follow a certain element to be synthesized. For example, for a bank card with a horizontal steel print on the front, the small code below the bank card number follows the bank card number, and the valid period starts and ends at the position following the valid period.

[0114] For the second type of elements that follow and do not move, when the second type of elements are consistent in size and shape with the elements to be synthesized that are followed, but only have a position offset, the position information of the second type of elements is stored through a following displacement dictionary, which stores the position offset between the second type of elements and the elements to be synthesized that are followed.

[0115] The follow displacement dictionary includes the element name of the element to be synthesized, the element name of the element to be synthesized to be followed, the horizontal movement range and the vertical movement range of the position offset. An example of the follow displacement dictionary is as follows:

[0116] {

[0117] #Element name:{name of the element being followed:(horizontal moving range, vertical moving range)}

[0118] "Valid from":{"Valid until":((34,37),(0,0))};

[0119] …

[0120] }

[0121] For the second type of elements that are consistent in size and shape with the elements to be synthesized, during synthesis, the second type of elements are first obtained from the pre-established element library, and the position offset is obtained from the follow displacement dictionary. Then, the preset position of the second type of elements on the card template is determined according to the position of the elements to be synthesized on the card template and the position offset.

[0122] When the size and shape of the second-type elements are inconsistent with the elements to be synthesized, it is necessary not only to follow the displacement dictionary but also to store the change information of the second-type elements through an element perturbation dictionary.

[0123] For the second type of elements that are inconsistent with the size and shape of the elements to be synthesized, during synthesis, the second type of elements are obtained from the pre-established element library, and the position offset is obtained from the follow-up displacement dictionary, the change information is obtained from the element perturbation dictionary, and the random function is called to generate the change value. The preset position of the second type of elements on the card template is determined according to the position of the element to be synthesized on the card template, the position offset and the change value.

[0124] The elements to be synthesized in the present application also include a third type of elements, which are elements with associated changes, including at least two associated elements whose positions are mutually associated, and the position changes of at least two associated elements are associated. For example, for a bank card with a horizontal steel print on the front, the position of the card type and the UnionPay logo are interchanged.

[0125] For the third type of elements with associated changes, the position information of each associated element is stored through an element position dictionary, and the change information of each associated element is stored through an element disturbance dictionary.

[0126] During synthesis, the third type of elements are obtained from the pre-established element library, and for each associated element, the position information is obtained from the element position dictionary, the change information is obtained from the element disturbance dictionary, the random function is called to generate the change value, and the preset position of each associated element on the card template is determined. According to the set first probability, the preset positions of each associated element are exchanged with each other.

[0127] That is, for the third type of elements with associated changes, when synthesizing, first determine the preset position of each associated element on the card template according to the method of the first type of elements. Then exchange the positions according to the set first probability. The first probability can be set according to the actual probability or as needed.

[0128] The elements to be synthesized in this application also include the fourth type of elements, which are self-changing elements whose changes are not related to other elements to be synthesized. For example, on a bank card with a horizontal version printed on the back, the signature strip may be on the left or on the right, which is unrelated to other elements to be synthesized.

[0129] For the fourth type of self-changing elements, their position information is stored through multiple element position dictionaries, and their change information is stored through multiple element perturbation dictionaries.

[0130] During synthesis, the fourth type of element is obtained from a pre-established element library, and according to the set second probability, one is randomly selected from multiple element position dictionaries to obtain position information, one is randomly selected from multiple element perturbation dictionaries to obtain change information, a random function is called to generate a change value, and the preset position of the fourth type of element on the card template is determined.

[0131] That is to say, for the fourth type of self-changing elements, multiple element position dictionaries and element perturbation dictionaries are set for them according to the method of the first type of elements, and one can be randomly selected during synthesis. When setting multiple element position dictionaries and element perturbation dictionaries, the elements to be synthesized can be named with labels (such as: signature strip 1, signature strip 2, etc.). Since the range of variation of the fourth type of self-changing elements is fixed and there are only a limited number of variation positions, the synthesis of the fourth type of self-changing elements can be achieved by setting multiple element position dictionaries and element perturbation dictionaries and randomly selecting them.

[0132] For the above four types of elements to be synthesized, corresponding synthesis programs are written for each type of element to be synthesized, and have the function of recording their positions on the card surface, generating a synthesized card image + outputting key information coordinates (used in deep neural network model training), such as a bank logo mapping program, a font writing program for printing bank card numbers, etc.

[0133] The existing card synthesis algorithm is generally a fixed base + fixed element position and size + fixed perturbation method, which is used to generate cards with a relatively fixed format. For example, the ID card simulation generation program will use a fixed base, which is a fixed length and width ID card base map without Value (on the ID card, take "Name: Zhang San" as an example, the string "Name" is the Key, and the string "Zhang San" is the Value). The ID card is synthesized in a fixed element position and size (the position and character size of each ID card Value) and fixed perturbation (the up, down, left, and right offsets of the Value position).

[0134] The aforementioned fixed base + fixed element position and size + fixed perturbation card synthesis algorithm has a certain effect on documents with fixed Key-Value such as identity cards, but it is difficult to synthesize documents such as bank cards with large value fluctuations and non-fixed bases.

[0135] This application realizes a universal card synthesis algorithm through card template collection and statistics, classification of elements to be synthesized, collection of elements to be synthesized, element position dictionary and element disturbance dictionary, which can simulate the synthesis of most cards, including bank cards where the positions of elements to be synthesized are not fixed. This application divides the elements to be synthesized into four categories: basically fixed, following fixed, associated change and self-change, and processes them separately. It can simulate certificates with fixed positions of elements to be synthesized and certificates with changing positions of elements to be synthesized at the same time, basically covering common situations of certificate elements, and realizing the simulation synthesis of universal cards.

[0136] The present application also provides a card image synthesis device, such as Figure 4 As shown, the device comprises:

[0137] The card template acquisition module 100 is used to acquire a card template corresponding to the layout information of the card image to be synthesized from a pre-established card template library according to the layout information of the card image to be synthesized.

[0138] The to-be-synthesized element determination module 200 is used to obtain the to-be-synthesized elements corresponding to the card template.

[0139] The element synthesis module 300 is used to obtain, for any element to be synthesized, the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, determine the preset position of the element to be synthesized on the card template according to the position information and the change information, and synthesize the element to be synthesized to the preset position of the card template.

[0140] The card image acquisition module 400 is used to obtain a synthesized card image after synthesizing each element to be synthesized into the card template.

[0141] The present application pre-establishes a variety of card templates, and determines various elements to be synthesized for each card template. During synthesis, the preset position of the element to be synthesized on the card template is determined by the position information and change information of the element to be synthesized. Due to the existence of the change information, the position and size of each element to be synthesized on the card template are not fixed, but vary according to the value of the change information, so various synthesized card images can be obtained. The large-scale synthesis of card training data greatly enriches the training samples of the deep neural network model used for card OCR, and improves the accuracy of the trained deep neural network model.

[0142] The elements to be synthesized in the present application may include first-category elements, position information of the first-category elements is stored via an element position dictionary, and change information of the first-category elements is stored via an element disturbance dictionary.

[0143] Accordingly, the aforementioned element synthesis module is used to:

[0144] The first type of elements are obtained from a pre-established element library, the position information is obtained from the element position dictionary, the change information is obtained from the element disturbance dictionary, a random function is called to generate a change value, and the preset position of the first type of elements on the card template is determined.

[0145] The elements to be synthesized in the present application may also include a second type of element, the position of the second type of element follows a certain element to be synthesized being followed, and the position information of the second type of element is stored through a following displacement dictionary, which stores the position offset between the second type of element and the element to be synthesized being followed.

[0146] Accordingly, the aforementioned element synthesis module is used to:

[0147] The second type of element is obtained from a pre-established element library, and the position offset is obtained from the follow displacement dictionary, and the preset position of the second type of element on the card template is determined according to the position of the element to be synthesized on the card template and the position offset.

[0148] Furthermore, the change information of the second type of elements is stored via an element perturbation dictionary.

[0149] Accordingly, the aforementioned element synthesis module is used to:

[0150] The second type of element is obtained from a pre-established element library, the position offset is obtained from the follow-up displacement dictionary, the change information is obtained from the element perturbation dictionary, a random function is called to generate a change value, and the preset position of the second type of element on the card template is determined according to the position of the element to be synthesized on the card template, the position offset and the change value.

[0151] The elements to be synthesized in the present application may also include a third type of elements, which include at least two associated elements whose positions are mutually associated, the position information of each associated element is stored through an element position dictionary, and the change information of each associated element is stored through an element perturbation dictionary.

[0152] Accordingly, the aforementioned element synthesis module is used to:

[0153] The third category of elements is obtained from a pre-established element library, and for each of the associated elements, the position information is obtained from the element position dictionary, the change information is obtained from the element disturbance dictionary, a random function is called to generate a change value, and a preset position of each of the associated elements on the card template is determined; according to a set first probability, the preset positions of the associated elements are exchanged with each other.

[0154] The elements to be synthesized in the present application may also include a fourth type of elements, the position information of the fourth type of elements is stored through multiple element position dictionaries, and the change information of the fourth type of elements is stored through multiple element disturbance dictionaries.

[0155] Accordingly, the aforementioned element synthesis module is used to:

[0156] The fourth type of element is obtained from a pre-established element library, and according to a set second probability, one is randomly selected from multiple element position dictionaries to obtain the position information, one is randomly selected from multiple element disturbance dictionaries to obtain the change information, a random function is called to generate a change value, and the preset position of the fourth type of element on the card template is determined.

[0157] Specifically, the element position dictionary includes the element name of the element to be synthesized and the coordinates of the diagonal points of the corresponding area of ​​the element to be synthesized, the element perturbation dictionary includes the element name, horizontal movable range and height range of the element to be synthesized, and the following displacement dictionary includes the element name of the element to be synthesized, the element name of the element to be synthesized to be followed, the horizontal movement range and vertical movement range of the position offset.

[0158] As an improvement of the embodiment of the present application, the device further includes:

[0159] The background synthesis module is used to determine whether the card image to be synthesized needs a background. If so, the background image is obtained from a pre-established background image library, the obtained background image is adjusted to the size of the card template, and the card template is used as the alpha channel of the background image.

[0160] The device provided in the above embodiment, its implementation principle and the technical effect produced correspond to the embodiment of the above method one by one. For the sake of brief description, the part not mentioned in the embodiment of the device can refer to the corresponding content in the embodiment of the above method. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the modules and units described in the device can refer to the corresponding process in the embodiment of the above method, and will not be repeated here.

[0161] The present application also provides a card detection method, such as Figure 5 As shown, the method includes:

[0162] S10: Obtain the image of the card to be detected.

[0163] The image of the card to be detected can be collected on-site by a collection device such as a camera, or can be collected and stored in advance and then obtained from a storage space.

[0164] S20: Input the card image to be detected into the trained deep neural network model to obtain the card detection result.

[0165] Among them, the training set of the deep neural network model includes the card image synthesized by the card image synthesis method.

[0166] By synthesizing card training data in batches using the aforementioned card image synthesis method, the training samples of the deep neural network model used for card OCR can be greatly enriched, thereby improving the accuracy of the trained deep neural network model.

[0167] The present application also provides a card detection device, such as Figure 6 As shown, the device comprises:

[0168] The to-be-detected image acquisition module 10 is used to acquire the to-be-detected card image.

[0169] The card detection module 20 is used to input the card image to be detected into the trained deep neural network model to obtain the card detection result.

[0170] Among them, the training set of the deep neural network model includes the card image synthesized by the card image synthesis method.

[0171] The card image synthesis method / card detection method described in the above embodiments provided by the present application can implement business logic through a computer program and record it on a storage medium, and the storage medium can be read and executed by a computer to achieve the effect of the scheme described in the method embodiment of this specification. Therefore, the embodiment of the present application also provides a computer-readable storage medium for the card image synthesis method / card detection, including a memory for storing processor-executable instructions, and when the instructions are executed by the processor, the steps of the card image synthesis method / card detection method including the above embodiments are implemented.

[0172] The storage medium may include a physical device for storing information, which is usually a medium that digitizes the information and then stores it in an electrical, magnetic or optical manner. The storage medium may include: a device that stores information in an electrical energy manner, such as various memories, such as RAM, ROM, etc.; a device that stores information in a magnetic energy manner, such as a hard disk, a floppy disk, a magnetic tape, a magnetic core memory, a magnetic bubble memory, a USB flash drive; a device that stores information in an optical manner, such as a CD or a DVD. Of course, there are other readable storage media, such as quantum memory, graphene memory, etc.

[0173] The storage medium described above may also include other implementation methods according to the description of the method embodiment. The implementation principle and technical effects produced by this embodiment are the same as those of the aforementioned method embodiment. For details, please refer to the description of the relevant method embodiment, and no further description will be given here.

[0174] The embodiment of the present application also provides a card image synthesis / card detection device, which may be a separate computer, or may include an actual operating device using one or more of the methods or one or more of the embodiments of the present specification. The card image synthesis / card detection device may include at least one processor and a memory storing computer executable instructions, and when the processor executes the instructions, any one or more of the steps of the card image synthesis method / card detection method described above are implemented.

[0175] The device described above may also include other implementation methods according to the description of the method embodiment. The implementation principle and technical effects produced by this embodiment are the same as those of the aforementioned method embodiment. For details, please refer to the description of the relevant method embodiment, and no further description will be given here.

[0176] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application. They should all be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A card image synthesis method, characterized in that: The method comprises: According to the layout information of the card image to be synthesized, a card template corresponding to the layout information is obtained from a pre-established card template library; Obtaining each element to be synthesized corresponding to the card template; For any element to be synthesized, the element to be synthesized and the position information and change information corresponding to the element to be synthesized are obtained from a pre-established element library, a preset position of the element to be synthesized on the card template is determined according to the position information and the change information, and the element to be synthesized is synthesized to the preset position of the card template; After each element to be synthesized is synthesized into the card template, a synthesized card image is obtained.

2. The card image synthesis method according to claim 1, characterized in that: The elements to be synthesized include first-category elements, position information of the first-category elements is stored via an element position dictionary, and change information of the first-category elements is stored via an element perturbation dictionary; The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises: The first type of elements are obtained from a pre-established element library, the position information is obtained from the element position dictionary, the change information is obtained from the element disturbance dictionary, a random function is called to generate a change value, and the preset position of the first type of elements on the card template is determined.

3. The card image synthesis method according to claim 2, characterized in that: The elements to be synthesized include second-category elements, the positions of the second-category elements follow a certain element to be synthesized being followed, and the position information of the second-category elements is stored via a following displacement dictionary, and the following displacement dictionary stores the position offset between the second-category elements and the element to be synthesized being followed; The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises: The second type of element is obtained from a pre-established element library, and the position offset is obtained from the follow displacement dictionary, and the preset position of the second type of element on the card template is determined according to the position of the element to be synthesized on the card template and the position offset.

4. The card image synthesis method according to claim 3, characterized in that: The change information of the second type of elements is stored via an element perturbation dictionary; The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises: The second type of element is obtained from a pre-established element library, the position offset is obtained from the follow-up displacement dictionary, the change information is obtained from the element perturbation dictionary, a random function is called to generate a change value, and the preset position of the second type of element on the card template is determined according to the position of the element to be synthesized on the card template, the position offset and the change value.

5. The card image synthesis method according to claim 4, characterized in that: The elements to be synthesized include third-category elements, the third-category elements include at least two associated elements whose positions are mutually associated, the position information of each of the associated elements is stored via an element position dictionary, and the change information of each of the associated elements is stored via an element perturbation dictionary; The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises: Obtain the third type of elements from a pre-established element library, and for each of the associated elements, obtain the position information from the element position dictionary, obtain the change information from the element disturbance dictionary, call a random function to generate a change value, and determine the preset position of each of the associated elements on the card template; According to the set first probability, the preset positions of the associated elements are exchanged with each other.

6. The card image synthesis method according to claim 5, characterized in that: The elements to be synthesized include fourth-category elements, position information of the fourth-category elements is stored via a plurality of element position dictionaries, and change information of the fourth-category elements is stored via a plurality of element disturbance dictionaries; The step of acquiring the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, and determining the preset position of the element to be synthesized on the card template according to the position information and the change information, comprises: The fourth type of element is obtained from a pre-established element library, and according to a set second probability, one is randomly selected from multiple element position dictionaries to obtain the position information, one is randomly selected from multiple element disturbance dictionaries to obtain the change information, a random function is called to generate a change value, and the preset position of the fourth type of element on the card template is determined.

7. The card image synthesis method according to claim 6, characterized in that: The element position dictionary includes the element name of the element to be synthesized and the coordinates of the diagonal points of the corresponding area of ​​the element to be synthesized. The element perturbation dictionary includes the element name, horizontal movable range and height range of the element to be synthesized. The following displacement dictionary includes the element name of the element to be synthesized, the element name of the element to be synthesized to be followed, the horizontal movement range and vertical movement range of the position offset.

8. The card image synthesis method according to any one of claims 1 to 7, characterized in that: The obtaining of the elements to be synthesized corresponding to the card template also includes: Determine whether the card image to be synthesized needs a background. If so, obtain a background image from a pre-established background image library, adjust the obtained background image to the size of the card template, and use the card template as the alpha channel of the background image.

9. A card image synthesis device, characterized in that: The device comprises: A card template acquisition module, used to acquire a card template corresponding to the layout information of the card image to be synthesized from a pre-established card template library; A module for determining elements to be synthesized, used for obtaining the elements to be synthesized corresponding to the card template; An element synthesis module is used to obtain, for any element to be synthesized, the element to be synthesized and the position information and change information corresponding to the element to be synthesized from a pre-established element library, determine the preset position of the element to be synthesized on the card template according to the position information and the change information, and synthesize the element to be synthesized to the preset position of the card template; The card image acquisition module is used to obtain a synthesized card image after synthesizing each element to be synthesized into the card template.

10. A computer-readable storage medium for card image synthesis, characterized in that: The invention comprises a memory for storing processor executable instructions, wherein the instructions, when executed by the processor, implement the steps of the card image synthesis method according to any one of claims 1 to 8.

11. A device for card image synthesis, characterized in that: The method comprises at least one processor and a memory storing computer executable instructions, wherein when the processor executes the instructions, the steps of the card image synthesis method according to any one of claims 1 to 8 are implemented.

12. A card detection method, characterized in that: The method comprises: Obtain the image of the card to be tested; Inputting the card image to be detected into the trained deep neural network model to obtain a card detection result; Wherein, the training set of the deep neural network model includes the card image synthesized by the card image synthesis method described in any one of claims 1-8.