A method and apparatus for generating a handwritten line sample
By learning the user's handwriting style through neural networks, realistic full-line handwritten samples are generated, solving the problem of difficulty in obtaining handwritten text recognition samples and improving the efficiency and richness of handwritten text recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING YIDAO BOSHI TECH
- Filing Date
- 2022-06-17
- Publication Date
- 2026-07-31
AI Technical Summary
In existing technologies, the accuracy of handwritten text recognition is far lower than that of printed text. The main bottleneck is the difficulty in obtaining handwritten samples, making it impossible to obtain a large number of training samples. Furthermore, the collection process relies on manual writing, which is inefficient.
By learning the user's handwriting style through neural networks, a handwriting style transfer model library is established. Handwriting character images are randomly generated, and a sample image of a whole line of handwritten characters is synthesized to simulate a whole line of human writing. Only a small set of characters needs to be written by the user.
It achieves efficient generation of realistic handwritten line samples, reduces the workload of manual writing, and provides a rich variety of samples suitable for OCR recognition training.
Smart Images

Figure CN115331236B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automatic image sample generation methods, and in particular to a method and apparatus for generating offline handwritten line OCR recognition training samples. Background Technology
[0002] In the field of OCR recognition, advancements in random techniques have achieved a relatively high accuracy rate for printed text recognition, with single-character recognition rates exceeding 99.5%. However, for handwritten text recognition, it is far from practical. The main bottleneck is the difficulty in obtaining handwritten samples, as the sheer volume of training samples available for printed text is unattainable. Handwritten sample collection still relies heavily on manual handwriting, which severely limits the speed and quantity of sample acquisition. Printed text samples, on the other hand, can be generated from font files, corpora, and background images, providing a continuous stream of diverse samples.
[0003] Therefore, there is an urgent need to provide a method for generating samples of entire lines of handwritten text. Summary of the Invention
[0004] To address the above problems, this invention proposes a method and apparatus for generating handwritten line samples, which can simulate human-written line samples to the greatest extent possible. However, it does not require an individual to write a complete set of characters; only a small subset (1% to 5%) of characters needs to be written, and the program can learn the writing style to automatically generate single characters from the remaining unwritten character set.
[0005] According to a first aspect of the present invention, a method for generating a complete line of handwritten samples is provided, the method comprising the following steps:
[0006] Step 1: Handwriting style learning. The user's handwriting style is learned through a neural network, and a handwriting style transfer model library is established.
[0007] Step 2: Randomly generate handwritten character images, randomly select printed text and handwritten style transfer model, input the selected printed text into the handwritten style transfer model, and generate handwritten character images of each character of the selected printed text;
[0008] Step 3: Synthesize the entire line of handwritten character sample images. Merge the handwritten character images of each character in the selected printed text to obtain the entire line of handwritten character sample images.
[0009] Furthermore, step 1 specifically includes:
[0010] Step 11: Collect and annotate the user's handwriting, crop all characters and store them;
[0011] Step 12: Based on all the stored characters, learn the user's handwriting style through a neural network to obtain the user's handwriting style transfer model. Collect all users' handwriting style transfer models and establish a handwriting style transfer model library.
[0012] Furthermore, in step 11, annotating the user's handwriting specifically involves locating the coordinates and encoding of each handwritten character.
[0013] Furthermore, in step 11, all the cut characters are stored according to their encoding.
[0014] Furthermore, step 2 specifically includes:
[0015] Step 21: Randomly select a line of printed text from the corpus and generate printed images of each character in sequence;
[0016] Step 22: Create a background image library and randomly select one as the background image;
[0017] Step 23: Randomly select a handwriting style transfer model from the handwriting style transfer model library;
[0018] Step 24: Input the image of each character in the printed text line into a randomly selected handwritten style transfer model to generate the handwritten character image of each character corresponding to the printed text line.
[0019] Furthermore, in step 24,
[0020] If the randomly selected handwriting style transfer model has parameter control, then the parameters are randomized, and the handwritten character images of each character in the printed text line are generated in real time, so that the handwritten character images of each character are different.
[0021] If the randomly selected handwritten font style transfer model does not have parameter control, the handwritten character images of all characters in the character set can be pre-generated, and this step can be directly indexed and queried based on the character encoding.
[0022] Furthermore, step 3 specifically includes:
[0023] Step 31: Generate random parameters related to character rendering;
[0024] Step 32: Render each handwritten character image sequentially onto the randomly selected background image according to random parameters to generate a fused image;
[0025] Step 33: Crop sample images of handwritten text lines from the fused image;
[0026] Step 34: Output the generated full line of handwritten character sample image and the true value, where the true value is the text line encoding.
[0027] Furthermore, step 31 specifically includes:
[0028] Step 311: Generate the character position center curve;
[0029] Step 312: Randomly generate the spacing between characters;
[0030] Step 313: Randomly generate character size.
[0031] Further, step 311 specifically includes:
[0032] On a circle of radius R, rotate N times with a random angular velocity ω. The starting position of the rotation angle is random, and the sampling interval is random. Obtain N consecutive points on the curve as offset position sampling points. N is a positive integer and equal to the number of handwritten characters.
[0033] The center points of N handwritten characters are offset according to the coordinates of N offset sampling points.
[0034] Further, step 312 specifically includes:
[0035] The spacing between characters is randomly generated and follows a Gaussian distribution.
[0036] μ = CharHeight / 7;
[0037] σ = CharHeight / 3,
[0038] CharHeight represents the character height.
[0039] Further, step 313 specifically includes:
[0040] Randomly generate the character height NewHeight, and then randomly generate the aspect ratio AspectRatio. Then the character width NewWidth is: NewWidth = NewHeight / AspectRatio;
[0041] By calculating the width and height parameters of each character, we can obtain the width and height parameters of each character.
[0042] Furthermore, in step 32,
[0043] When the pixel value of a handwritten character image is greater than the threshold T, it is considered a background pixel and is filtered out during rendering.
[0044] When the pixel value of the handwritten character image is less than or equal to the threshold T, the pixel value is merged with the background image to highlight the pixel value of the handwritten character image.
[0045] Furthermore, the threshold T is in the range of [1, 255], preferably greater than 128, and more preferably 220.
[0046] Furthermore, step 33 specifically includes:
[0047] The bounding rectangles of all handwritten characters in the fused image are combined to form the bounding rectangles of the text lines, and then cropped to obtain a sample image of the handwritten text lines.
[0048] Furthermore, after step 33, the method further includes an image transformation process for the handwritten text line sample image, which includes, but is not limited to, image grayscale re-transformation, image enhancement, noise addition, and image deformation (cv2.remap).
[0049] Furthermore, step 34 specifically includes:
[0050] The handwritten text line sample image and its corresponding handwritten text line string encoding are output to obtain the samples needed later, including the whole line of handwritten character sample image and the true value, i.e., the text line encoding.
[0051] According to a second aspect of the present invention, a handwritten line sample generation apparatus is provided, the apparatus operating based on the method provided in any of the foregoing aspects, the apparatus comprising:
[0052] The handwriting style learning unit is used to learn the user's handwriting style through neural networks and build a handwriting style transfer model library.
[0053] A random handwritten character image unit is used to randomly select printed text, background and handwritten style transfer model to generate handwritten character images of each character of the selected printed text.
[0054] The unit for synthesizing a whole line of handwritten character sample images is used to merge the handwritten character images of each character of the selected printed text to obtain a whole line of handwritten character sample images.
[0055] According to a third aspect of the present invention, a handwritten line sample generation system is provided, the system comprising: a processor and a memory for storing executable instructions; wherein the processor is configured to execute the executable instructions to perform the handwritten line sample generation method as described in any of the preceding aspects.
[0056] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, characterized in that a computer program is stored thereon, which, when executed by a processor, implements the handwritten line sample generation method as described in any of the preceding aspects.
[0057] The beneficial effects of this invention are:
[0058] This invention provides a method for generating a complete line of handwritten samples by using a handwritten font style transfer scheme, combined with dynamic parameter generation and image processing.
[0059] 1. Realism: Sample generation requires that the generated samples be as realistic as possible. The handwritten image generated by this patent can achieve a level of realism that is indistinguishable from the real thing.
[0060] 2. High efficiency: The handwritten style writer does not need to write all the characters in the character set, but only needs to write a certain number of samples according to the requirements, which greatly reduces the workload of manual writing;
[0061] 3. Abundance: Due to the series of random parameters in the generation process, each generated sample is different, resulting in a very rich variety of samples. This method can be directly used by the training program. Attached Figure Description
[0062] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0063] Figure 1 The flowchart of the method for generating a whole line of handwritten samples according to an embodiment of the present invention is shown.
[0064] Figure 2 A schematic diagram illustrating font style migration according to an embodiment of the present invention is shown.
[0065] Figure 3a and Figure 3b The diagrams show sample examples of handwritten characters used by sampler A and sampler B according to embodiments of the present invention.
[0066] Figure 4 A schematic diagram of the character position center curve according to an embodiment of the present invention is shown.
[0067] Figure 5a and Figure 5b Schematic diagrams of text lines cropped from a rendered image according to embodiments of the present invention are shown respectively.
[0068] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0069] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0070] The terms "first," "second," etc., used in this disclosure are for distinguishing similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented, for example, in orders other than those illustrated or described herein.
[0071] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, such that a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units that are explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such process, method, product, or apparatus.
[0072] Multiple, including two or more.
[0073] And / or, it should be understood that, for the purposes of this disclosure, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.
[0074] Example
[0075] 1. Learning handwritten font styles
[0076] Generating handwritten samples is quite difficult, mainly because of the sheer number of Chinese characters (or English words). There are approximately 7,000 commonly used Chinese characters, 27,000 in GB18030, and over 110,000 in extended characters. Creating a complete Chinese character set (or English word set) by handwriting would take several months. Currently, some researchers both domestically and internationally have explored methods that allow neural networks to learn a person's handwriting style by simply handwriting a few characters. Then, by inputting a printed character image, they can generate a corresponding handwritten character image. Specifically, for example... Figure 2 As shown.
[0077] 1.1 Offline Handwritten Style Single Character Collection
[0078] Each person writes a certain number of handwritten single characters for later study of their handwriting style. A sampling form can be designed according to the requirements and distributed to each participant. After completion, the forms are collected and annotated, primarily to locate the coordinates and code of each handwritten character. Then, all characters written by each person are cut out and stored according to their codes. The samples after writing and cutting are as follows: Figure 3a and Figure 3b As shown.
[0079] 1.2 Learning the style of handwritten single characters
[0080] The program learns each person's handwriting style to obtain a handwriting style model. This allows it to generate a similar handwritten character image (e.g., from a printed font image, such as KaiTi) based on the model. Figure 2 ).
[0081] Currently, style transfer is a popular research area, with many researchers studying various languages and scripts. This application employs the following method:
[0082] Users write certain Chinese characters as specified by the system, take photos, and upload them to the system. After receiving these text images, the system segments the characters on the sample images according to a grid, obtaining handwritten images of the specified Chinese characters. The system automatically generates a user's handwriting font library in approximately five hours. First, based on a non-rigid point set registration method and several heuristic rules, the writing trajectory of each stroke is extracted from each handwritten character image segmented from the input text image. Then, a neural network is used to learn and reconstruct the user's overall handwriting style, decomposing the user's handwriting style into stroke shape style and stroke layout style. At the same time, handwriting details such as stroke connectivity and contour shape are also correctly described and restored. Finally, a complete personal font library can be generated by vectorizing images of all other handwritten characters, including human-written samples and machine-generated handwritten images.
[0083] With this method, users only need to spend 10-30 minutes writing a small number of Chinese characters on paper (it is recommended to write no less than 200 characters), take a photo and upload it, and the system can automatically generate a handwritten Chinese character library that meets the GB18030-2000 national standard and has the user's writing style.
[0084] Collect all the font style transfer models of each person and build a handwritten font style transfer model library for later use.
[0085] 2. Randomly select and generate data
[0086] 2.1 Select a line of text from the corpus
[0087] Select a line of text from the prepared corpus. You can prepare different categories of corpora as needed, such as science and technology, news, education, agriculture, sports, etc. You can also divide them into addresses, names, capitalized amounts, lowercase number strings, etc., and they can be Chinese, English, Japanese, Korean, etc.
[0088] You can add certain rules to the selected text lines as needed to meet the requirements of real-world scenarios. For example, the number of characters in the text line cannot exceed a certain limit, it cannot consist entirely of punctuation marks, and it cannot contain characters outside of a specified character set.
[0089] 2.2 Randomly select a background image
[0090] To produce paper backgrounds based on real samples, it is necessary to simulate real writing backgrounds. Therefore, it is necessary to prepare paper background images for various environments. Paper background images can be categorized into the following main types:
[0091] • Use white as the main color for the A4 paper background, and also prepare appropriate amounts of red, yellow, etc.
[0092] • Remove text from various newspaper backgrounds to obtain a clean background image;
[0093] • Background information on various documents, such as passports, ID cards, travel permits, property ownership certificates, etc.;
[0094] • Various types of invoice backgrounds, such as VAT invoices, flight itineraries, fixed-amount invoices, etc.;
[0095] • Background information on various bank documents, including bank deposit slips, transfer checks, account opening applications, bank drafts, etc.
[0096] • Background information on various insurance documents, including insurance policies, insurance claim forms, medical invoices, medical receipts, etc.
[0097] We also collect all kinds of document backgrounds from everyday life, aiming to recreate the real-life document writing backgrounds as much as possible.
[0098] Collect these background images and store them in a background image library. The program will then randomly select one background image from this library to be used as the writing background for this line of samples in subsequent processing.
[0099] 2.3 Select a handwritten font style model
[0100] Randomly select a style transfer model from the handwritten font style model library.
[0101] 2.4 Generate handwritten images of each character in the corresponding string based on the model.
[0102] Using the selected handwritten font style model, input the corresponding printed text image, and obtain the corresponding handwritten character image through reasoning.
[0103] Style transfer models typically have parameters to control the magnitude of changes in the generated model. Therefore, this step uses real-time generation with randomized parameters to ensure that each generated handwritten image of the same encoded character is different.
[0104] If the style transfer model does not have parameter control, the handwritten character images of all characters in the character set can be pre-generated, and this step can be directly indexed and queried based on the character encoding.
[0105] 3. Synthesize a complete line of handwritten samples
[0106] 3.1 Generate random parameters related to character rendering
[0107] Printed text lines are printed by a printer. Apart from variations in size, font, bold, underline, italics, etc., there are very few other variations. Printed or generated text lines are all on the same horizontal line. Unless the paper is bent or deformed or the photography produces distortion, there is generally not much randomness.
[0108] The generation of handwritten text lines needs to simulate human writing as closely as possible, so it is necessary to consider many randomnesses, such as changes in character size, character shape deformation, changes in the thickness of character strokes, changes in the angle of writing characters, changes in the baseline of writing characters, changes in the gap between characters, changes in the color of character strokes, etc., which can be parameterized by controlling the parameter changes.
[0109] During implementation, the following random parameters were used:
[0110] a) Generation of character position center curve:
[0111] When simulating handwriting a whole line, the center line of the character is not horizontal or vertical, but has undulations, and it must also maintain continuity.
[0112] Various frequency-related functions can be used for generation. Here, we introduce a generation method based on the sine function to obtain the offset of the center line. The method is as follows: Figure 4 As shown, on a circle of radius R, a rotation is performed with a random angular velocity ω. The initial position of the rotation angle is also random (generally between 0 and 2π). Assuming there are N characters, N rotations will yield N consecutive points on the curve. This is equivalent to... Figure 4The sine curve on the right has a random starting position and a random sampling interval. Remove the offset value of the center point of a line of text from this curve. The black dots in the figure are the offset sampling points of N (13) characters. The center point of the written character can be offset according to this value.
[0113] b) Randomly generated spacing between characters:
[0114] The spacing between characters varies when handwritten. You can refer to the character height (CharHeight) of the handwritten text line as a guide. The character spacing can be a random parameter within the range [0 ~ CharHeight], but the random output character spacing should follow a Gaussian distribution.
[0115] μ = CharHeight / 7
[0116] σ = CharHeight / 3
[0117] c) Character size scaling is randomly generated:
[0118] For style transfer output, each character is the same size, following the generator network's preset dimensions, such as a width of 64 and a height of 96. We can transform the aspect ratio and size of each generated character to obtain a new character height and width, but the character deformation must not be too drastic. Here, we can first obtain a new character height, which can be randomly generated within a preset range, resulting in a height (NewHeight). Then, we randomly generate a reasonable aspect ratio (AspectRatio), and the width can be obtained as a new width (NewWidth = NewHeight / AspectRatio).
[0119] By calculating the width and height parameters of each character, we can obtain the width and height parameters of each character.
[0120] 3.2 Render the individual character images sequentially onto the background image according to the parameters.
[0121] According to the parameters set in the previous step, the single character image is rendered into the background image randomly selected in step 2.2. During the font generation process, it can be agreed that the pixel values in the character image that are greater than the threshold T (T = 220 in this embodiment of the invention) are background pixels and are directly filtered out during rendering. When the pixel value is less than or equal to T, the pixel values in the character image are merged with the background image to highlight the pixel values of the character image.
[0122] 3.3 Extracting handwritten text lines from the merged image
[0123] Combine the bounding boxes of all rendered characters into a single large bounding box for the entire text line, and then crop the desired line of text image from the rendered image, such as... Figure 5a and Figure 5b As shown, the character center line changes, the character spacing also varies, and the character size also changes randomly. In other words, the state of the characters is random, thus making the realism higher.
[0124] 3.4 Image transformation processing of handwritten text line images
[0125] Since this is an image generation process, the simulation might not be accurate enough for training. Some image processing transformations can be applied to the text image, such as grayscale re-transformation, image enhancement, adding noise, and image deformation (cv2.remap). For deep learning training, this step can be omitted and placed in the image preprocessing section of the deep learning training process.
[0126] 3.5 Output: Generate an image of the handwritten text line and its ground truth value.
[0127] By outputting the processed image of the handwritten text line and the encoding of its corresponding text line string, we obtain the samples (images and ground truth values) needed later:
[0128] One method is to save it to a disk for use by different learning and training programs;
[0129] Another approach is to directly connect to the training program, using the generator program as a sample generator for the training program, without storing the samples.
[0130] Here, the true value is the text line encoding.
[0131] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0132] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0133] Through the above description of the embodiments, those skilled in the art can clearly understand that the above implementation methods can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0134] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims. All of these forms are within the protection scope of the present invention.
Claims
1. A method of generating a handwriting justification sample, characterized by, The method includes the following steps: Step 1: Handwriting style learning. The user's handwriting style is learned through a neural network, and a handwriting style transfer model library is established. Step 2: Randomly generate handwritten character images, randomly select printed text and handwritten style transfer model, input the selected printed text into the handwritten style transfer model, and generate handwritten character images of each character of the selected printed text; Step 3: Synthesize the entire line of handwritten character sample images. This involves merging the handwritten character images of each character in the selected printed text to obtain the entire line of handwritten character sample images. Specifically, this includes: Step 31: Generate random parameters related to character rendering; Step 32: Render each handwritten character image sequentially onto the background image according to random parameters to generate a merged image; Step 33: Crop sample images of handwritten text lines from the fused image; Step 34: Output the generated full-line handwritten character sample image and ground value, where the ground value is the text line encoding; wherein, the output includes directly connecting the generated full-line handwritten character sample image and ground value to the training program, using the generation program as a sample generator for the learning and training program, and the samples are not stored on the ground; Step 35: Perform image transformation processing on the handwritten text line sample image. The image transformation processing includes image grayscale re-transformation, image enhancement, adding noise, or image deformation. Specifically, step 31 includes: Step 311: Generate the character position center curve, specifically: on a circle with radius R, rotate N times with a random angular velocity ω. The starting position of the rotation angle is random, and the sampling interval is random. Obtain N consecutive points on the circle as offset position sampling points, where N is a positive integer and equal to the number of handwritten characters; the center points of the N handwritten characters are offset according to the coordinates of the N offset position sampling points. Step 312: Randomly generate the spacing between characters, specifically: the spacing between characters is randomly generated and satisfies a Gaussian distribution: μ=CharHeight / 7; σ=CharHeight / 3, where CharHeight is the character height; Step 313: Randomly generate character sizes, specifically: randomly generate character height NewHeight, and then randomly generate aspect ratio AspectRatio. The character width NewWidth is: NewWidth = NewHeight / AspectRatio. By calculating for each character, the width and height parameters of each character are obtained.
2. The handwriting line-up sample generation method of claim 1, wherein Step 1 specifically includes: Step 11: Collect and annotate the user's handwriting, crop all characters and store them; Step 12: Based on all the stored characters, learn the user's handwriting style through a neural network to obtain the user's handwriting style transfer model. Collect all users' handwriting style transfer models and establish a handwriting style transfer model library.
3. The handwriting lineation sample generation method of claim 1, wherein, Step 2 specifically includes: Step 21: Randomly select a line of printed text from the corpus and generate printed images of each character in sequence; Step 22: Create a background image library and randomly select one as the background image; Step 23: Randomly select a handwriting style transfer model from the handwriting style transfer model library; Step 24: Input the image of each character in the printed text line into a randomly selected handwritten style transfer model to generate the handwritten character image of each character corresponding to the printed text line.
4. The method for generating a complete line of handwritten samples according to claim 3, characterized in that, In step 24, If the randomly selected handwriting style transfer model has parameter control, then the parameters are randomized, and the handwritten character images of each character in the printed text line are generated in real time, so that the handwritten character images of each character are different. If the randomly selected handwritten font style transfer model does not have parameter control, then the handwritten character images of all characters in the character set are pre-generated, and step 24 directly performs index lookup based on the character encoding.
5. The method for generating a complete line of handwritten samples according to claim 1, characterized in that, In step 32 When the pixel value of a handwritten character image is greater than the threshold T, it is considered a background pixel and is filtered out during rendering. When the pixel value of the handwritten character image is less than or equal to the threshold T, the pixel value is merged with the background image to highlight the pixel value of the handwritten character image.
6. The method for generating a complete line of handwritten samples according to claim 5, characterized in that, The threshold T ranges from [1, 255].
7. The method for generating a complete line of handwritten samples according to claim 1, characterized in that, Step 33 specifically involves: The bounding rectangles of all handwritten characters in the fused image are combined to form the bounding rectangles of the text lines, and then cropped to obtain a sample image of the handwritten text lines.
8. The method for generating a complete line of handwritten samples according to claim 1, characterized in that, Step 34 specifically involves: The handwritten text line sample image and its corresponding handwritten text line string encoding are output to obtain the samples needed later, including the whole line of handwritten character sample image and the true value, i.e., the text line encoding.
9. A device for generating a complete line of handwritten samples, characterized in that, The apparatus operates based on the handwritten line sample generation method according to any one of claims 1 to 8, and the apparatus comprises: The handwriting style learning unit is used to learn the user's handwriting style through neural networks and build a handwriting style transfer model library. A random handwritten character image unit is used to randomly select printed text, background and handwritten style transfer model to generate handwritten character images of each character of the selected printed text. The unit for synthesizing a whole line of handwritten character sample images is used to merge the handwritten character images of each character of the selected printed text to obtain a whole line of handwritten character sample images.
10. A system for generating a complete line of handwritten samples, characterized in that, The system includes: a processor and a memory for storing executable instructions; wherein the processor is configured to execute the executable instructions to perform the handwritten line sample generation method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, It stores a computer program, which, when executed by a processor, implements the method for generating a whole line of handwritten samples according to any one of claims 1 to 8.