Method for generating handwritten text data for complex writing scene and computer product

文档序号:8389 发布日期:2021-09-17 浏览:74次 中文

1. A method for generating handwritten text data for data enhancement, comprising the steps of:

acquiring a single character sample;

determining corresponding scene parameters and enhancement parameters according to a set writing scene;

and adjusting the relation between the single character sample and the current handwritten text sample based on the scene parameters and the enhancement parameters, synthesizing the single character sample into the current handwritten text sample to generate a new handwritten text sample, and recording the corresponding single character segmentation position.

2. The method of claim 1, wherein obtaining a single word sample comprises:

selecting corresponding single characters from a single character sample library according to the corpus content to form a single character sample set, collecting single character samples from the single character sample set, and standardizing the single character samples; the normalization includes normalization, estimating the center of the single word sample, and calculating the size of the single word sample.

3. The method of claim 1, wherein the position of the current handwritten text sample is also used as a reference; the location of the current handwritten text sample includes: the center position of the current handwritten text sample, or the center position of the last character in the current handwritten text sample, where the last character is the last character in the sequence according to writing time.

4. The method of claim 1, wherein the writing scenarios comprise a plurality of typical writing scenarios and a combination of two or more typical writing scenarios, and wherein the typical writing scenarios comprise: "line/column writing", "writing in any direction", "overlapping/multi-character shingled writing", "jumping writing", and "non-uniform writing in size".

5. The method according to claim 4, wherein for the combination of more than two typical writing scenes, the synthesizing modes of the corresponding typical writing scenes are nested to determine the relationship between the single word sample and the current handwritten text sample.

6. The method of claim 1, wherein the relationship between the single word sample and the current handwritten text sample comprises a position relationship, an overlap relationship, and/or a size relationship.

7. The method of any of claims 1-6, wherein the scene parameters are associated with attributes of a written scene.

8. The method of any of claims 1-6, wherein the enhancement parameters are associated with attributes of single-word samples.

9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 8.

10. A computer-readable storage medium, on which a computer program is stored, characterized in that a processor, when executing the computer program, implements the steps of the method of any of claims 1 to 8.

Background

Handwriting input is an important way for a person to interact with a device. Accordingly, handwriting recognition technology is also widely used in various types of electronic devices in order to recognize handwriting input.

In the prior art, the handwriting recognition technology is mainly based on a machine learning and deep learning method to construct a recognition model, and the key for constructing the recognition model is as follows: the recognition model is trained using a large number of sampled data sets as input, and therefore, in order to improve the accuracy of the recognition model, sufficient data is required. For handwriting recognition of real and complex writing scenes, the handwriting recognition method is more dependent on test data which are enough to approximate or simulate various real and complex writing scenes. The writing scene refers to a mode of handwriting input by the user through the electronic equipment, and includes but is not limited to single/multiple lines, jumping writing, overlapping writing, any angle oblique writing and the like.

The collection of single character handwriting sampling data is easy to realize, for example, the single character samples in online handwriting data (obtained by certain electronic equipment and stored in a writing track mode by user handwriting input) are more; however, it is very difficult to obtain handwritten text data in various complex scenes and record a single character type (single character type: contents of written single characters) and a single character segmentation label (single character segmentation label: stroke segment marks belonging to complete single characters in a continuous written text track) at the same time. For example, for a writer, it is easy to collect several single word samples of the writer, but due to the nature of the writer's work, the cost of obtaining information, etc., it is difficult to collect a large amount of handwritten text of the writer.

In summary, in the prior art, a large number of handwritten text samples for model training are lacking.

Disclosure of Invention

In view of the foregoing, it is desirable to provide a method for generating handwritten text data for complex writing scenes, and also provide a computer device and a computer-readable storage medium based on the method.

According to an aspect of the present invention, an embodiment of the present invention provides a method for generating handwritten text data for data enhancement, including the following steps: acquiring a single character sample; determining corresponding scene parameters and enhancement parameters according to a set writing scene; and adjusting the relation between the single character sample and the current handwritten text sample based on the scene parameters and the enhancement parameters, synthesizing the single character sample into the current handwritten text sample to generate a new handwritten text sample, and recording the corresponding single character segmentation label.

In one embodiment, selecting corresponding single characters from a single character sample library according to the corpus content to form a single character sample set, collecting single character samples from the single character sample set, and standardizing the single character samples; the normalization includes normalization, estimating the center of the single word sample, and calculating the size of the single word sample.

In one embodiment, the position of the current handwritten text sample is also taken as a reference; the location of the current handwritten text sample includes: the center position of the current handwritten text sample, or the center position of the last character in the current handwritten text sample, where the last character is the last character sorted according to writing time.

In one embodiment, the writing scenes comprise a plurality of typical writing scenes and a combination of more than two typical writing scenes, and the typical writing scenes comprise: "line/column writing", "writing in any direction", "overlapping/multi-character shingled writing", "jumping writing", and "non-uniform writing in size".

In one embodiment, for the combination of more than two typical writing scenes, the corresponding synthesizing modes of the typical writing scenes are nested to determine the relationship between the single word sample and the current handwritten text sample.

In one embodiment, the relationship between the single word sample and the current handwritten text sample includes a position relationship, an overlap relationship, and/or a size relationship.

In one embodiment, the scene parameters are associated with attributes of the written scene.

In one embodiment, the enhancement parameters are associated with attributes of a single-word sample.

According to another aspect of the present invention, an embodiment of the present invention provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

According to yet another aspect of the present invention, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps of the above-mentioned method.

On one hand, the handwritten text generation method provided by the invention can generate corresponding handwritten text samples according to the set writing scene, thereby realizing the customized generation of the handwritten text, and on the other hand, the method can generate gradually abundant handwritten text samples in the cyclic process of continuous acquisition, enhancement and synthesis, thereby realizing the generation of the handwritten text samples in a simple form, and is very suitable for generating the handwritten text samples through single character samples.

Drawings

The above and other objects, features and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present invention are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar or corresponding parts and in which:

FIG. 1 is a flow diagram illustrating a method for generating handwritten text data for complex writing scenarios, in accordance with an embodiment of the invention;

FIG. 2 is a flow chart illustrating a process for obtaining a single word sample according to an embodiment of the invention;

FIG. 3 is a flowchart illustrating a normalization process for a single-word sample according to an embodiment of the invention;

FIG. 4 is a schematic illustration of a reference position according to an embodiment of the present invention;

FIG. 5-1 is a schematic diagram of the technical concept of a "single/multiple line writing" scene, and FIG. 5-2 is a composite schematic diagram of a "single/multiple line writing" scene;

FIG. 6-1 is a schematic diagram of the technical concept of a "single/multiple column writing" scene, and FIG. 6-2 is a composite schematic diagram of the "single/multiple column writing" scene;

FIG. 7-1 is a schematic diagram of the technical concept of a "free direction writing" scene, and FIG. 7-2 is a composite schematic diagram of the "free direction writing" scene;

FIG. 8-1 is a schematic diagram of the technical concept of an "overlap/multiple-word shingle writing" scenario, and FIG. 8-2 is a composite schematic diagram of an "overlap/multiple-word shingle writing" scenario;

FIG. 9-1 is a schematic diagram of the technical concept of a "jumping writing" scene, and FIG. 9-2 is a composite schematic diagram of the "jumping writing" scene;

FIG. 10-1 is a schematic diagram of the technical concept of a "size non-uniform writing" scene, and FIG. 10-2 is a composite schematic diagram of a "size non-uniform writing" scene;

FIG. 11 is a diagram summarizing the technical concept of the present invention; and

fig. 12 is a block diagram of a computer device according to an embodiment of the present invention.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

In the prior art, a technical scheme of expanding single-word samples in a data enhancement mode exists, but the handwritten text samples cannot be generated efficiently only through data enhancement of the single-word samples. The basic idea of the handwritten text data generation of the invention is therefore: sampling single character samples, performing data enhancement and synthesizing handwritten text samples, re-sampling single character samples, performing data enhancement again and synthesizing handwritten text samples, and repeating the steps to finally form the required handwritten text samples. The following detailed description is made with reference to the accompanying drawings.

Method embodiment

Fig. 1 shows a flow diagram of a method of handwritten text data generation for complex writing scenarios according to an embodiment of the invention. As shown in FIG. 1, in one embodiment, handwritten text data generation includes the steps of:

s1, obtaining single character samples;

s2, determining corresponding scene parameters and enhancement parameters according to the writing scene;

and S3, adjusting the relation between the single character sample and the current handwritten text sample based on the scene parameters and the enhancement parameters, synthesizing the single character sample into the current handwritten text sample to generate a new handwritten text sample, and recording the corresponding single character segmentation label.

In this embodiment, each time step S1 is executed, sampling is performed once to obtain a single character sample; then adding the single character sample to the current handwritten text sample in step S3 to form a new handwritten text sample; then, sampling is carried out continuously, a new handwritten text sample becomes a current handwritten text sample, and a single character sample obtained by sampling is added into the current handwritten text sample; and continuously and circularly executing the steps to gradually form a handwritten text sample with continuous rich contents, namely the handwritten text sample data.

The handwritten text generation method is a continuous and cyclic process of sampling, enhancing and synthesizing, and can generate the handwritten text samples with rich contents along with the cyclic process. The mode provides a brand new technical route for the prior art. In addition, in the embodiment of the invention, different writing scenes can be adapted by setting corresponding scene parameters and enhancement parameters, so that the method of the embodiment of the invention can generate customized handwritten text samples. For ease of description, hereinafter, a handwritten text sample is also simply referred to as a handwritten sample.

In step S2, according to a specific writing scene, determining corresponding scene parameters and enhancement parameters; where the scene parameters may be parameters associated with a particular writing scene and the enhancement parameters may be parameters associated with a single word sample. Furthermore, in a specific scenario, the scene parameters are fixed, while the enhancement parameters are adjustable. The scene parameters and the enhancement parameters are used for reflecting the corresponding writing scene together and representing the relation between the current handwriting sample and the single character sample, such as the position, the angle and the like.

The single character segmentation position in step S3 is the stroke segment mark belonging to the complete single character in the continuous writing text track, i.e. it is identified which strokes constitute a single character. The purpose of recording the single character segmentation position is to be used in the subsequent handwriting recognition method training process.

Fig. 2 and 3 show the process of collecting single-word samples and performing the standardization process. FIG. 2 is a flow chart illustrating a process for obtaining a single word sample according to an embodiment of the invention. FIG. 3 is a flow chart illustrating a normalization process for single-word samples according to an embodiment of the invention.

As shown in fig. 2, firstly, at step S101, it is determined whether customized writing content is needed, and if customized writing content is needed, step S102 is executed to extract corresponding content from the corpus (for example, if the customized writing content is "news report", then "news report" related content is extracted). If the written content does not need to be customized, step S103 is executed to randomly select the corpus. Then, in step S104, according to the customized or random corpus content, each individual word corresponding to the corpus content is selected from the individual word sample library to form an individual word sample set, where the individual word sample set includes characters such as chinese and english characters, common punctuation marks and numbers. In this embodiment, in order to make the finally obtained handwritten text data more conform to a real scene, the formed single character sample set is for a given writer, that is, the single character sample libraries are all from the same given writer. Of course, it is also possible to use word sample libraries of different writers, without considering the same restrictions of the writer. In addition, a character of a given writer may have multiple samples, such as "king" characters, and the same writer may have multiple writing samples of "king" characters, so that one character may be randomly selected and added to the single character sample set, or both of them may be added to the single character sample set.

Next, at step S105, sampling is performed from the single-word sample set, and finally, a single-word sample is acquired at step S106. In step S105, the sampling order may be an order in which the single-character samples are arranged, a specified order, or even a random order.

As shown in FIG. 3, in one embodiment, the step of normalizing the single-word sample includes step S107, step S108, and step S109.

First, in step S107, the word samples obtained in step S106 are normalized so as to operate on a plurality of word samples in a unified manner in the subsequent process. For example, the transformation can be performed according to equation (1), where L is a predetermined range value, and through this step, originally different size word samples are transformed into a fixed range L.

xi=(xi-xmin)/L

yi=(yi-ymin)/L (1)

Next, at step S108, the center of the normalized single-word sample is estimated for the subsequent steps. The estimation of the center of the single character sample is related to the writing speed and the sampling rate of the electronic equipment, and is obtained by reverse weighting according to the distance between the stroke points, and the center of the single character sample is calculated in the formulas (2a, 2b, 2c and 2 d). Equation (2a) reflects the stroke speed during writing, and equation (2b) reflects the distance between stroke points.

In other embodiments, the center of the single character sample may also be calculated by other methods in the prior art, which are not described herein again.

Finally, in step S109, the size of the normalized single-word sample is obtained. In one embodiment, the size of a single word sample is represented by its width and height values, including: word width ═ xmax-xminI, word height ═ ymax-ymin|。xmax,xminL is the maximum and minimum of the x coordinate, ymax,yminThe maximum and minimum values of the y coordinate. The role of step S108 and step S109 is to locate the character sample so that the center position of the character sample coincides with the coordinates of the set position when the character is added to a certain set position in the current handwritten sample.

In each of the following steps S2 and S3, the normalized word sample is processed, and for the sake of simplicity, the word sample is simply referred to as the word sample. For convenience of description, the following description will be made in conjunction with steps S2 and S3.

In steps S2, S3, a reference position needs to be determined in order to add the single-word sample to the current handwriting sample. FIG. 4 shows a schematic reference position diagram in accordance with an embodiment of the invention. As shown in fig. 4, in an implementation scenario, the current handwriting sample includes a plurality of characters, such as a first character (first character), a second character … …, and a last character (last character), and the reference position may be a center position 41 of the last character in the current handwriting sample or a center position 42 of the current handwriting sample. It should be noted that the center position 41 of the last word or the center position 42 of the current handwritten sample is updated continuously during the generation of the handwritten text sample.

When adding the single character sample to the current handwriting sample in steps S2 and S3, it is also necessary to plan the relationship between the single character sample and the current handwriting sample, where the relationship includes a position relationship, an overlap relationship and/or a size relationship, and the relationship is determined by the scene parameters and the enhancement parameters, reflecting a specific writing scene. This is explained in detail below with reference to fig. 5-10.

5-10 illustrate 5 exemplary writing scenarios, wherein the "line/column writing" is divided into single/multiple line writing "and" single/multiple column writing ", which are illustrated by FIG. 5-1, FIG. 5-2, FIG. 6-1, and FIG. 6-2, respectively; "free direction writing" is illustrated by FIG. 7-1 and FIG. 7-2; "overlap/polygram" is shown by FIG. 8-1 and FIG. 8-2; "skip writing" is illustrated by FIG. 9-1 and FIG. 9-2; the "non-uniform writing in size" is illustrated by FIG. 10-1 and FIG. 10-2. The above-mentioned 5 typical writing scenarios are described separately below. It should be noted that the specific parameters and formulas sampled in the following 5 typical writing scenarios do not constitute a limitation to these typical writing scenarios, and in other embodiments, a person skilled in the art may adopt other forms of parameters and formulas based on the technical concept disclosed above. Furthermore, although 5 exemplary writing scenarios are described in the embodiments of the present invention, a person skilled in the art may expand more exemplary writing scenarios, and thus the number of exemplary writing scenarios disclosed in the present invention is also illustrative and not restrictive.

First, fig. 5-1 and 5-2 are schematic diagrams of technical concepts and composite diagrams of a "single/multiple line writing" scene. As shown in FIG. 5-1, in the "Single/Multi-line writing" scenario, with the center coordinates (x, y) as the reference position, which is the end word attribute P1 in the current handwriting sample, the scene parameter P2 includes the word spacing dcharDistance d between linesrowLocation of line start point locstartThe enhancement parameter P3 includes a random word spacing rcharRandom line spacing rrow. The end word property P1, the scene parameter P2, and the enhancement parameter P3 collectively form a single/multi-line writing enhancement component to determine the composite parameters of the single word sample, i.e., the coordinate position (x ', y'). Wherein, the word spacing dcharRepresenting the overall word spacing defined by the writing scenario, and in particular the word spacing should also be combined with a random word spacing rchar. Wherein the line spacing drowRepresenting by writing fieldThe overall line spacing defined by the scene, and the specific line spacing should also be combined with the random line spacing rrow. The last character refers to the last character sorted according to writing time, and in the case of writing according to a certain sequence, for example, in fig. 5-2, the last character is the rightmost and lower character in the current handwriting sample; in the case of unordered writing (e.g., "skip writing"), the end word may be in an arbitrary position.

Specifically, as shown in fig. 5-2, wherein (a) represents single-line writing and (b) represents multi-line writing (line feed writing). The single-line writing represents the case of continuing writing on the same line, and the coordinate x' of the synthesized single-word sample is x + dchar+rchar,y’=y+rcharThat is, x 'is offset by a certain distance (sum of word spacing and random word spacing) on the basis of x, and y' is offset by a certain distance (random word spacing) on the basis of y.

The multi-line writing represents the case of line feed writing, and the coordinate x' of the synthesized single character sample is locstart+rchar,y’=y+drow+rrow(ii) a That is, x 'is shifted by a certain distance (sum of line start position and random word pitch) from the line start position, and y' is shifted by a certain distance (sum of line pitch and random line pitch) from y.

In summary, it can be seen that the "single/multi-line writing" scene corresponds to the scene parameter P2 and the enhancement parameter P3; and (3) taking the final character attribute P1(x, y) as a reference position, adjusting the single character sample according to the corresponding scene parameter P2 and the enhancement parameter P3, and placing the single character sample at the (x ', y') position, so that the single character sample is synthesized into the current handwriting sample to form a new handwriting text sample.

The case of single/multi-column writing is similar to the above-described embodiment, and a technical concept diagram and a composite diagram of a "single/multi-column writing" scene are shown in fig. 6-1 and 6-2. As shown in FIG. 6-1, in the "single/multi-column writing" scenario, with the center coordinate (x, y) as the end word attribute P1 in the current handwriting sample as the reference position, the scenario parameter P2 includes the word spacing dcharAt a row pitch of dcolPoint of column startPlace locstart(used here to represent the column start point location, in a different sense than that shown in FIG. 5-1), the enhancement parameter P3 includes the random word spacing rcharRandom column pitch rcol. The end word property P1, the scene parameter P2, and the enhancement parameter P3 together constitute a single/multi-column handwriting enhancement component to determine a synthesis parameter for synthesizing a single word sample into the current handwritten sample, i.e., its position coordinates (x ', y'). Wherein, the word spacing dcharRepresenting the overall word spacing defined by the writing scenario, and the specific word spacing should also incorporate a random word spacing rchar. Wherein the column pitch dcolRepresenting the overall column spacing defined by the writing scene, and the specific column spacing should also incorporate a random column spacing rcol

Specifically, as shown in fig. 6-2, wherein (a) represents single-column writing and (b) represents multi-column writing (permuted writing). The single-column writing represents the case of continuing writing on the same column, namely writing down along the same column, and the coordinate x ═ x + d of the enhanced single-character samplechar+rchar,y’=y+dchar+rcharThat is, x 'is offset by a certain distance (random word spacing) on a x basis, and y' is offset by a certain distance (sum of word spacing and random word spacing) on a y basis.

The multi-column writing shows the case of line-changing writing, i.e. the case of restarting one-column writing, and the coordinate x ═ x + d of the enhanced single character samplecol+rcol,y’=locstart+rchar(ii) a That is, x' is offset by a distance (the sum of the column pitch and the random column pitch) from x; y' is offset by a distance (sum of the column start point position and the random word pitch) on the basis of y.

In summary, it can be seen that the "single/multi-column writing" scene corresponds to the scene parameter P2 and the enhancement parameter P3; and (3) taking the final character attribute P1(x, y) as a reference position, adjusting the single character sample according to the corresponding scene parameter P2 and the enhancement parameter P3, and placing the single character sample at the (x ', y') position, so that the single character sample is synthesized into the current handwriting sample to form a new handwriting text sample.

In summary, in the scenario of "line/column writing", the end word attribute P1, the scene parameter P2 and the enhancement parameter P3 are collectively referred to as the line/column writing enhancement module Z1, and the synthesis mode can be expressed as F11=f Z1(x,y)。

7-1 and 7-2 show a technical idea schematic diagram and a composite schematic diagram of a scene written in any direction. In the "free direction writing" scene in fig. 7-1, the scene parameter P2 includes the word spacing d, with the center coordinate (x, y) as a reference position, which is the end word attribute P1 in the current handwriting samplecharThe writing direction angle θ, the enhancement parameter P3 includes the random word spacing rcharRandom position perturbation (Δ x, Δ y), random angle perturbation δ. The writing direction angle theta represents the whole inclination degree of writing and is determined by the angle between the connecting line of the first character and the last character in the current handwriting sample and the x direction; the random angle disturbance delta represents the random inclination degree of the single character sample under the integral inclination degree, and determines the difference between the center of the single character sample, the connecting line of the centers of the last characters and the writing direction angle. The last word attribute P1, the scene parameter P2, and the enhancement parameter P3 together constitute an arbitrary direction writing enhancement component Z2 to determine the composite parameters of the single word sample, i.e., the coordinate position (x ', y').

Specifically, as shown in fig. 7-2, the writing in any direction shows the condition that the writing direction is inclined, and the condition is used for simulating the writing habit of some writers in real life, namely the condition that the whole line is gradually inclined when writing along the same line. The coordinates x' ═ x + d of the synthesized single word samplechar·cos(θ+δ)+rchar+Δx,y’=y+dchar·sin(θ+δ)+rchar+ Δ y. The above formula determines that x 'is the degree of offset on the basis of x and y' is the degree of offset on the basis of y, the meaning of which can be understood by those skilled in the art in conjunction with fig. 7-2.

In summary, in the scenario of "free direction writing", the end word attribute P1, the scene parameter P2 and the enhancement parameter P3 can be collectively referred to as the free direction writing enhancement component Z2, and the composition manner can be represented as F2=f Z2(x,y)。

Fig. 8-1 and 8-2 are schematic diagrams of technical concepts and composite diagrams of an "overlap/multi-word overwrite" scenario. As in fig. 8-1, in the "overlap/multi-word overwrite" scene, with the end word attribute P1 — center coordinate (x, y) in the current handwriting sample as a reference position, the scene parameter P2 includes a reference center point (x, y), an overlap area range parameter l; the enhancement parameters P3 include random position perturbations (Δ x, Δ y). The end word property P1, the scene parameter P2, and the enhancement parameter P3 collectively form an overlap/multi-word shingle enhancement component Z3 to determine the synthesis parameters for a single word sample, including the coordinate position (x ', y').

Specifically, as shown in fig. 8-2, the overlap/multi-word overlap writing represents the situation that the single words are completely or partially overlapped when writing, and is used for simulating the writing habit of some writers in real life. The coordinates x '═ x + Δ x, y' ═ y + Δ y of the synthesized single character sample; furthermore, it should be borne in generating random position perturbations (Δ x, Δ y)The formula ensures that the random location perturbation does not exceed the limit of the scenario parameter P2.

In summary, in the "overlap/multi-script" scenario, the last word attribute P1, the scene parameter P2 and the enhancement parameter P3 can be collectively referred to as the overlap/multi-script enhancement component Z3, and the composition can be represented as F3=f Z3(x,y)。

And fourthly, a technical concept schematic diagram and a synthetic schematic diagram of a 'jumping writing' scene are shown in the figures 9-1 and 9-2. As in FIG. 9-1, in the "jump writing" scenario, with the end word attribute P1-center coordinate (x, y) in the current handwriting sample as a reference position, the scenario parameter P2 includes the writing boundary (x, y)max,ymax) The minimum non-overlap range l (the same parameters are used for the overlap region range parameters in the "overlap/multiple-word overwrite" scenario described above); the enhancement parameters P3 include random position perturbations (Δ x, Δ y). The end word property P1, the scene parameter P2, and the enhancement parameter P3 collectively form an overlap/multi-word shingle enhancement component Z4 to determine the synthesis parameters for a single word sample, including the coordinate position (x ', y').

In particular, as shown in the figure9-2, jumping writing shows the situation that each individual character appears at random and lacks regularity during writing, and is used for simulating the writing habits of some writers in real life. The coordinates x '═ x + Δ x, y' ═ y + Δ y of the synthesized single character sample; furthermore, when generating random position disturbances (Δ x, Δ y) l < Δ x < x should also be experiencedmax,l<Δy<ymaxThe formula ensures that the random position disturbance does not exceed the limit of the scenario parameter P2, so that the jumping degree of the newly added single word sample is in a controllable range.

In summary, in the "jump writing" scenario, the last word attribute P1, the scene parameter P2 and the enhancement parameter P3 are collectively referred to as the jump writing enhancement component Z4, and the synthesis mode can be represented as F44=fZ4(x,y)。

And fifthly, a technical concept schematic diagram and a synthetic schematic diagram of a 'size non-uniform writing' scene are shown in the figure 10-1 and the figure 10-2. As shown in FIG. 10-1, in the "size uneven writing" scene, the last word attribute P1 includes the center coordinates (x, y) of the last word, the center coordinates (x, y) of the last word is taken as a reference position, the scene parameter P2 includes the width-height-average value s of a single word, and the writing boundary (x, y)max,ymax) The minimum non-overlapping range l; the enhancement parameters P3 include random position perturbations (Δ x, Δ y) and a single-word-size scaling factor σ. The last word property P1, the scene parameter P2, and the enhancement parameter P3 collectively form a big-small non-uniform writing enhancement component Z5 to determine the composition parameters of the single word sample, including coordinate position (x ', y') and single word size.

Specifically, as shown in fig. 10-2, the non-uniform writing shows that each single word has different size and lacks regularity during writing, and is used for simulating the writing habits of some writers in real life. The coordinates x '═ x + Δ x, y' ═ y + Δ y for the synthesized single-word samples, and l < Δ x < xmax-s’,l<Δy<ymax-s', s ═ σ · s. This system formula ensures that the position and size of the single character do not exceed the limit of the scenario parameter P2. The single character width-height average value can be obtained by calculating the width-height value of each single character in the current handwriting sample and then averaging. For example, there are three words in the current handwritten sampleThe word widths are a1, a2 and a3, respectively, and the word widths are b1, b2 and b3, respectively, then the single word width height average value s includes: the average value of the word width is (a1+ a2+ a3)/3, and the average value of the word height is (b1+ b2+ b 3)/3.

In summary, in the "non-uniform writing in size" scene, the last word attribute P1, the scene parameter P2, and the enhancement parameter P3 are collectively referred to as the non-uniform writing in size enhancement component Z5, and the synthesis method can be represented as F5=fZ5(x,y)。

As can be seen from the above description of 5 typical writing scenarios, the scenario parameter P2 is fixed for a certain scenario, and the enhancement parameter P3 is adjustable. In one embodiment, for a single word sample to be synthesized, if the writing situation is determined, the situation parameter P2 is fixed, and the enhancement parameter P3 may be a specific value within a range. For example, for a random word spacing, a reference value may be set, and then each time the value is taken, the value is taken within a certain range around the reference value. In one implementation scenario, the values of the enhancement parameter P3 may be normally distributed or uniformly distributed.

Further, in the above 5 typical writing scenarios, the enhancement parameter P3 is used to transform the word, including the translation transformation and the scaling transformation of the word, and in other embodiments, the enhancement parameter P3 may also include the rotation and shear transformation parameters, that is, the word may be rotated by a certain angle (rotation) around the center or tilted by a certain angle (shear).

Still further, since the actual writing situation is more complicated than the above-mentioned 5 typical writing scenarios, that is, there may be a scenario in which typical writing scenarios such as "jump" and "uneven size" are combined. For this case, according to the method of the embodiment of the present invention, a corresponding handwritten text sample may still be generated. The specific implementation manner may be nested based on the above 5 typical writing scenes, for example, a scene of "jump" and "size non-uniformity", and the synthesis manner may be expressed as F ═ Fz5(fz4(x, y)), i.e., nesting the composition modes corresponding to the typical writing scene. In other words, synthesis by corresponding 5 typical modesThe manner of nesting can generate a handwritten text sample simulating any specified scene. The simple nesting mode provides a simple, convenient, efficient and flexible technical means for customizing rich and diverse writing scenes; namely, only a plurality of typical writing scenes need to be constructed, more and richer combined writing scenes can be formed through nesting, and a powerful technical tool is provided for the generation of handwritten text samples.

Still further, in other embodiments, the handwritten text samples corresponding to different writing scenes can be simply combined together, for example, text written in multiple lines and text written in any direction are placed in the same figure, so as to realize the combination of different writing scenes.

In step S3, a process of recording the position of the single-character cut is also included. The word segmentation position indicates which strokes form a word, and these pieces of information are generated during word sampling (this part belongs to the prior art, and is not described here again), and in one embodiment, these pieces of information are finally recorded in the form of word segmentation labels in step S3. In one embodiment, the word-cut label may be represented by a continuous string of 01, the length of the string being the same as the number of strokes, 0 representing no cut, and 1 representing the stroke as the last stroke of the current word. For example: the handwritten text contains two characters, 10 strokes are contained, the first character is 4 strokes, the second character is 6 strokes, and the single character segmentation label is recorded as '0001000001'.

In the above embodiment, the single-word-cut position is expressed and recorded "explicitly" by the single-word-cut label (character string of 0 and 1). In another embodiment, the single-word segmentation position may not be recorded in an explicit manner, but in an implicit manner, for example: the word-slicing positions are recorded by assigning different memory locations to different words.

The method embodiments of the present invention have been illustrated and described in detail above. Fig. 11 summarizes the various embodiments described above. As shown in fig. 11, to summarize, after the synthesis parameters corresponding to the writing scene are calculated by the enhancement component corresponding to the writing scene, the normalized single character sample is transformed (translated, rotated, scaled, and the like) by using the synthesis parameters, and the transformed sample is continued to the current handwritten sample, and the single character segmentation position is recorded at the same time, so that a synthesis process is completed; the synthesis process is repeated continuously to generate ideal handwritten text samples.

Computer device embodiment

In one embodiment, the present invention provides a computer device, the internal structure of which may be as shown in FIG. 12. The computer device includes a processor, a memory, a communication interface, a display screen, and an input device connected by a system bus. The processor of the computer equipment is used for providing calculation and control capability, and various varieties such as a CPU, a singlechip, a DSP or an FPGA can be selected. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. When executed, the computer program may perform steps S1-S3 described in the above method embodiments, and is further described in the following computer readable storage medium embodiments. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a multi-sensory data fusion method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.

Those skilled in the art will appreciate that the architecture shown in fig. 12 is merely a block diagram of some of the structures associated with aspects of the present invention and is not intended to limit the computing devices of the present invention, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.

Computer-readable storage medium embodiments

In one embodiment, the present invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements steps S1-S3 described in the above-described method embodiments.

It will be understood by those skilled in the art that all or part of the processes of the embodiments of the methods described above may be implemented by a computer program, which may be stored in a non-volatile computer-readable storage medium, and when executed, may include the processes of the embodiments of the methods described above. Any reference to memory, storage, databases, or other media used in embodiments provided herein may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.

The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the claims. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:基于点状喷码的检测方法及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!