Handwriting generation method, electronic equipment and computer program product

By acquiring and fitting the handwriting data of the user, extracting personalized features and fitting them, the problem of the mechanical feel of handwriting presented by electronic devices is solved, the beauty and readability of the handwriting are improved, and the user's writing style is retained.

CN120708240APending Publication Date: 2025-09-26SHENZHEN XINWEI INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510740346.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

When electronic devices present user handwriting, directly replacing it with a standard font results in a strong mechanical feel, destroys the differences in users' writing styles, and affects aesthetics and readability.

Method used

By obtaining the handwriting data of the user, extracting its personalized feature parameters, and fitting it using the Bezier curve algorithm and the target model, a fitting handwriting is generated to preserve the user's writing style.

Benefits of technology

It improves the aesthetics and readability of the fitted handwriting, while retaining the user's personalized writing style and improving the handwriting distortion and deformation problems caused by hand shaking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120708240A_ABST
    Figure CN120708240A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a handwriting generation method, electronic equipment and a computer program product, and the method comprises the steps: obtaining first handwriting data of a first handwriting input operation under the condition that the first handwriting input operation is detected; obtaining characteristic parameters of the first handwriting input operation according to the first handwriting data; the characteristic parameters are used for reflecting personalized characteristics of the first handwriting input operation; and fitting the first handwriting data based on the feature parameters to generate fitted handwriting. According to the embodiment of the invention, the first handwriting data is fitted based on the characteristic parameters capable of reflecting the personalized characteristics of the first handwriting input operation, so that the unique writing style of the first handwriting input operation can be reserved in the generated fitting handwriting, and the mechanical feeling of the fitting handwriting is avoided; the beauty and readability of the fitting handwriting are improved, and meanwhile, the personalization of the fitting handwriting is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of writing data processing, and in particular to a handwriting generation method, electronic equipment and computer program product. Background Art

[0002] With the continuous development of digital technology, electronic devices with touch screens, such as smartphones, tablets, and infrared large screens, are becoming increasingly popular, and digital writing technology is also widely used. Users can write on the touch screen of electronic devices using their fingers, stylus pens, or other input devices, and the electronic devices can then present the user's handwriting in real-time in a digitized form through the touch screen.

[0003] In related technologies, to improve the aesthetics and readability of handwriting, electronic devices generally use optical character recognition (OCR) technology to replace the handwriting input by the user on a touch screen with a standard font, and then display the standard font corresponding to the handwriting input by the user on the touch screen. However, directly replacing the handwriting input by the user on the touch screen with a standard font will make the handwriting displayed by the electronic device have a stereotyped mechanical feel, ignoring the differences between the handwritings of different users and destroying the user's writing style. Summary of the Invention

[0004] The embodiments of the present invention provide a handwriting generation method, electronic device and computer program product, which can solve the problem in the related art that the user's handwriting presented by the electronic device has a strong mechanical feel and destroys the user's writing style.

[0005] In order to solve the above problems, in a first aspect, an embodiment of the present invention discloses a method for generating handwriting, the method comprising:

[0006] When a first handwriting input operation is detected, obtaining first handwriting data of the first handwriting input operation;

[0007] Acquiring characteristic parameters of the first handwriting input operation according to the first handwriting data; the characteristic parameters are used to reflect personalized characteristics of the first handwriting input operation;

[0008] Based on the characteristic parameters, the first handwriting data is fitted to generate fitted handwriting.

[0009] Optionally, acquiring characteristic parameters of the first handwriting input operation according to the first handwriting data includes:

[0010] inputting the first handwriting data into a first target model;

[0011] Obtaining a first stroke corresponding to the first handwriting input operation using the first target model according to the first handwriting data;

[0012] A first stroke feature of the first stroke is extracted using the first target model, and the first stroke feature is determined as a feature parameter of the first handwriting input operation.

[0013] Optionally, fitting the first handwriting data based on the characteristic parameters to generate fitted handwriting includes:

[0014] Obtaining, using the first target model and based on the first stroke feature, a first target stroke feature corresponding to the first stroke feature from a stroke feature mapping table; the stroke feature mapping table is used to construct a mapping relationship between the original stroke feature and the target stroke feature of the handwriting input operation;

[0015] The first target model is used to fit the first handwriting data according to the first target stroke feature to generate fitted handwriting.

[0016] Optionally, the method further includes:

[0017] When a second handwriting input operation is detected, obtaining second handwriting data of the second handwriting input operation;

[0018] inputting the second handwriting data into a first target model to be trained;

[0019] Obtaining a second stroke corresponding to the second handwriting input operation according to the second handwriting data using the first target model to be trained;

[0020] extracting a second stroke feature of the second stroke by using the first target model to be trained;

[0021] fitting the second handwriting data using the first target model to be trained according to the second stroke feature to obtain at least one set of candidate strokes corresponding to the second stroke feature;

[0022] determining a target stroke corresponding to the second stroke feature from the candidate strokes;

[0023] Acquiring a second target stroke feature of the target stroke using the first target model to be trained;

[0024] A stroke feature mapping table including the second stroke feature and the second target stroke feature is constructed in the first target model to be trained to obtain a first target model.

[0025] Optionally, the characteristic parameter includes operation data of the first handwriting input operation; and fitting the first handwriting data based on the characteristic parameter to generate fitted handwriting includes:

[0026] inputting the operation data and the first handwriting data into a second object model;

[0027] Determining handwriting rendering parameters corresponding to the first handwriting input operation according to the operation data using the second object model;

[0028] The first handwriting data is fitted using the second target model according to the handwriting rendering parameters to obtain fitted handwriting.

[0029] Optionally, acquiring characteristic parameters of the first handwriting input operation according to the first handwriting data includes:

[0030] calculating, based on the first handwriting data, a local curvature value of the first original handwriting corresponding to the first handwriting input operation;

[0031] The local curvature value is determined as a characteristic parameter of the first handwriting input operation.

[0032] Optionally, fitting the first handwriting data based on the characteristic parameters to generate fitted handwriting includes:

[0033] determining a shaking area corresponding to the first handwriting input operation according to the local curvature value;

[0034] Obtaining the shaking amplitude of the shaking area;

[0035] determining the number of Bezier curve control points corresponding to the jitter area according to the jitter amplitude;

[0036] The first handwriting data is fitted according to the number of Bezier curve control points corresponding to the shaking area to obtain fitted handwriting.

[0037] Optionally, the characteristic parameter includes at least one of the following:

[0038] a first stroke feature corresponding to the first handwriting input operation;

[0039] Operation data of the first handwriting input operation;

[0040] The local curvature value of the first original handwriting corresponding to the first handwriting input operation.

[0041] In a third aspect, an embodiment of the present invention further discloses an electronic device, which includes a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the handwriting generation method as described above.

[0042] In a fourth aspect, an embodiment of the present invention further discloses a computer program product, including a computer program / instruction, which implements the handwriting generation method as described above when executed by a processor.

[0043] In a fifth aspect, an embodiment of the present invention further discloses a readable storage medium, which, when instructions in the readable storage medium are executed by a processor of an electronic device, enables the processor to execute the handwriting generation method as described above.

[0044] The embodiments of the present invention include the following advantages:

[0045] An embodiment of the present invention provides a method for generating handwriting. When a first handwriting input operation is detected, first handwriting data of the first handwriting input operation is obtained, and characteristic parameters of the first handwriting input operation are obtained based on the first handwriting data. The first handwriting data is then fitted based on the characteristic parameters to generate fitted handwriting. This can improve problems such as handwriting distortion and deformation caused by hand shaking of the user during the writing process, and is beneficial to improving the fluency and aesthetics of the fitted handwriting. Furthermore, an embodiment of the present invention fits the first handwriting data based on characteristic parameters that can reflect the personalized characteristics of the first handwriting input operation. The unique writing style of the first handwriting input operation can be retained in the generated fitted handwriting, avoiding the mechanical feel of the fitted handwriting, which is beneficial to improving the personalization of the fitted handwriting while improving the aesthetics and readability of the fitted handwriting.

[0046] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0048] Figure 1 This is a flowchart of a method for generating handwriting provided by an embodiment of the present invention;

[0049] Figure 2This is a logic block diagram of a target stroke determination process provided by an embodiment of the present invention;

[0050] Figure 3 is a flowchart of another method for generating handwriting provided by an embodiment of the present invention;

[0051] Figure 4 This is a comparison diagram of a first original handwriting and a fitted handwriting provided by an embodiment of the present invention;

[0052] Figure 5 This is a logic block diagram of a handwriting generation device provided by an embodiment of the present invention;

[0053] Figure 6 This is a structural block diagram of an electronic device for generating handwriting provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0054] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0055] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0056] Method Example

[0057] Reference Figure 1 , shows a flowchart of a handwriting generation method provided by an embodiment of the present invention, the method may specifically include steps S101 to S103:

[0058] Step S101: when a first handwriting input operation is detected, obtaining first handwriting data of the first handwriting input operation.

[0059] Step S102: Acquire characteristic parameters of the first handwriting input operation according to the first handwriting data.

[0060] Step S103: Fitting the first handwriting data based on the characteristic parameters to generate fitted handwriting.

[0061] The handwriting generation method provided by the embodiment of the present invention can be applied to electronic devices with data processing functions. In some embodiments, the electronic device includes a touch screen, and the user can input handwriting on the touch screen through a finger, a stylus or other input device. The electronic device can generate fitting handwriting through the handwriting generation method provided by the embodiment of the present invention when a first handwriting input operation is detected, and display the fitting handwriting through the touch screen for the user to view. In other embodiments, the electronic device does not include a touch screen, and the electronic device establishes a communication connection with another electronic device that includes a touch screen. The electronic device can generate fitting handwriting through the handwriting generation method provided by the embodiment of the present invention when a first handwriting input operation is detected through the other electronic device that includes a touch screen, and then send the fitting handwriting to the other electronic device that includes a touch screen so that the fitting handwriting can be displayed through the other electronic device that includes a touch screen.

[0062] The first handwriting input operation is a handwriting input operation detected in real time by the electronic device during the user's handwriting input on the touch screen.

[0063] Electronic devices may include but are not limited to mobile terminals such as laptop computers, personal digital assistants (PDAs), handheld devices, computing devices, and fixed terminals such as digital TVs and desktop computers.

[0064] The following describes a specific implementation process of the embodiment of the present invention by taking an application scenario in which an electronic device includes a touch screen and a user uses a stylus pen that establishes a communication connection with the electronic device to perform handwriting input as an example.

[0065] Among them, the communication connection between the stylus pen and the electronic device may include but is not limited to: Bluetooth connection (for example, low-power Bluetooth connection), wired connection, electromagnetic induction connection, touch screen sensing connection, wireless network (Wireless Fidelity, Wi-Fi) connection and near field communication (Near Field Communication, NFC) connection, etc.

[0066] When a user uses a stylus to write or draw on the touch screen of an electronic device, the user will input handwriting to the touch screen of the electronic device through the stylus. At this time, the electronic device can detect the user's first handwriting input operation; the way in which the electronic device detects the first handwriting input operation may include but is not limited to capacitive sensing, electromagnetic induction, infrared sensing and ultrasonic sensing.

[0067] When the electronic device detects the first handwriting input operation, it can execute operations corresponding to steps S101 to S103 to generate fitted handwriting, and display the fitted handwriting through the touch screen.

[0068] Specifically, in step S101, when a first handwriting input operation is detected, the electronic device can continuously collect the coordinate data and sampling timestamp of the sampling point corresponding to the first handwriting input operation according to a preset period (for example, 10ms), and determine the coordinate data and sampling timestamp of the sampling point as the first handwriting data of the first handwriting input operation; the first handwriting data includes the coordinate data and sampling timestamp of at least one sampling point.

[0069] The coordinate data includes the abscissa x and the ordinate y of the sampling point in a two-dimensional rectangular coordinate system.

[0070] When the electronic device obtains the first handwriting data through step S101, it can process the coordinate data of the sampling points in the first handwriting data according to the time sequence of the sampling timestamps to form a coordinate sequence; then, use the Bezier curve algorithm to smoothly fit the coordinate sequence to obtain the first original handwriting corresponding to the first handwriting input operation. When the user shakes or slips his hand during the process of inputting handwriting to the touch screen of the electronic device through the stylus, the first original handwriting will be distorted and deformed. If the first original handwriting is displayed directly, the visual beauty and readability of the handwriting displayed by the electronic device will be reduced.

[0071] In step S102, the electronic device may obtain parameters related to the personalized features of the first handwriting input operation based on the first handwriting data, and use the parameters related to the personalized features of the first handwriting input operation as feature parameters of the first handwriting input operation.

[0072] In the embodiment of the present invention, the feature parameters are used to reflect the personalized features of the first handwriting input operation, and further reflect the writing style of the user. In actual application scenarios, the content included in the feature parameters can be adaptively adjusted according to the personalized features that need to be retained in the fitted handwriting.

[0073] As an optional implementation manner, the feature parameter includes the first stroke feature of the first handwriting input operation and / or the local curvature value of the first original handwriting.

[0074] Specifically, when the personalized feature that needs to be retained in the fitted handwriting is the stroke writing feature of the first handwriting input operation, in step S102, the electronic device can first use the Bezier curve algorithm to fit the first handwriting data to obtain the first original handwriting; then divide the first original handwriting into independent first strokes, and extract the first stroke feature of the first stroke as the feature parameter of the first handwriting input operation; in this scenario, the personalized feature reflected by the feature parameter is the stroke writing feature of the first handwriting input operation.

[0075] The first stroke feature may include, but is not limited to, a starting angle of the first stroke, an ending angle of the first stroke, a curvature of a turning point of the first stroke, and a stroke length of the first stroke. The first stroke may include independent strokes and partial fonts composed of independent strokes. Independent strokes may include, but are not limited to, a dot, a horizontal stroke, a vertical stroke, a left-falling stroke, a right-falling stroke, a fold, a lift, and a hook.

[0076] It should be noted that the number of the first strokes is at least 1. In step S102, when the number of the first strokes is greater than 1, the electronic device can extract the first stroke feature of each first stroke as a feature parameter of the first handwriting input operation.

[0077] In the case where the personalized feature that needs to be retained in the fitted handwriting is the jitter feature of the first handwriting input operation, in step S102, the electronic device can obtain the local curvature value of the first original handwriting and use the local curvature value as a feature parameter; in this scenario, the personalized feature reflected by the feature parameter is the jitter feature of the first handwriting input operation.

[0078] The method for the electronic device to obtain the local curvature value of the first original handwriting is as follows: first, the curvature of the curve formed by any feature point on the first original handwriting and at least two adjacent feature points is calculated to obtain the local curvature value of the first original handwriting; specifically, the electronic device can use vector operations to calculate the curvature. Assuming that any feature point on the first original handwriting is M i , the feature points adjacent to this feature point can be expressed as M i-2 , M i-1 , M i+1 , M i+2 , by calculating these feature points (M i-2 , M i-1 , M i , M i+1 , M i+2 ) points constituted by the angle and distance relationship between the vectors, it can be concluded that the feature point is P i The local curvature value of the feature point is M i The local curvature value of is determined as the local curvature value K of the first original handwriting i It can be understood that the number of local curvature values ​​of the first original handwriting is at least 1; in the case where the first original handwriting is obtained by fitting the first handwriting data using a Bezier curve algorithm, the feature point on the first original handwriting is the middle point between two adjacent sampling points in the first handwriting data.

[0079] In step S103, the electronic device may first obtain an optimization strategy matching the characteristic parameters based on the characteristic parameters, and use the Bezier curve algorithm to fit the first handwriting data to obtain the first original handwriting; then optimize the first original handwriting according to the optimization strategy to obtain the fitted handwriting.

[0080] Specifically, when the feature parameter is a first stroke feature corresponding to a first handwriting input operation, the optimization strategy that matches the feature parameter is: obtaining a target stroke feature corresponding to the first stroke feature, and optimizing the strokes in the first original handwriting that are identical to the first stroke according to the target stroke feature to obtain fitted handwriting. The target stroke feature can be a user-defined stroke feature; specifically, the user can input a first instruction into the electronic device, the first instruction carrying the target stroke feature corresponding to the first stroke; upon receiving the first instruction, the electronic device can obtain the target stroke feature from the first instruction, and optimize the strokes in the first original handwriting that are identical to the first stroke according to the target stroke feature to obtain fitted handwriting.

[0081] When the feature parameter is the local curvature value of the first original handwriting, the optimization strategy matching the feature parameter is: first, according to the local curvature value of the first original handwriting, determine the number of Bezier curve control points in the curve formed by the feature point corresponding to the local curvature value and the adjacent feature points; then, according to the number of Bezier curve control points in the curve formed by each feature point in the first original handwriting and the adjacent feature points, use the Bezier curve algorithm to smooth the first original handwriting to obtain the fitted handwriting.

[0082] Among them, the larger the local curvature value, the more severe the jitter that occurs in the curve area formed by the feature point corresponding to the local curvature value and the adjacent feature points. In order to improve the smoothness of the first original handwriting, the electronic device can assign more Bezier curve control points to the curve area; correspondingly, the smaller the local curvature value, the smaller the jitter that occurs in the curve area formed by the feature point corresponding to the local curvature value and the adjacent feature points. In order to avoid over-fitting of the first original handwriting, resulting in distortion of the generated fitting handwriting and destruction of the user's writing style, the electronic device can assign fewer Bezier curve control points to the curve area.

[0083] As an optional implementation, the electronic device may receive a second instruction input by the user before step S103, the second instruction being used to indicate the degree of optimization of the first original handwriting. The electronic device may optimize the first original handwriting according to the optimization strategy in step S103 based on the degree of optimization indicated by the first instruction to obtain fitted handwriting. As an example, the degree of optimization of the first original handwriting includes 10 levels (level 1 to level 10), with higher levels indicating a greater degree of optimization of the first original handwriting.

[0084] Specifically, the higher the degree to which the second instruction indicates that the first original handwriting is optimized, the higher the degree to which the electronic device optimizes the first original handwriting through step S103, the smaller the similarity between the generated fitting handwriting and the first original handwriting, that is, the lower the degree of personalization of the fitting handwriting; correspondingly, the lower the degree to which the second instruction indicates that the first original handwriting is optimized, the lower the degree to which the electronic device optimizes the first original handwriting through step S103, the greater the similarity between the generated fitting handwriting and the first original handwriting, that is, the higher the degree of personalization of the fitting handwriting; in actual application scenarios, the user can customize the degree to which the first original handwriting is optimized according to the needs of optimizing the first original handwriting, and the embodiments of the present invention do not specifically limit this.

[0085] In the related art, due to the large difference in material properties between touchable electronic screens and traditional paper, the user's hand is very likely to shake during the process of writing on the touchable electronic screen. This shaking will directly affect the accuracy of the writing trajectory, causing the handwriting finally presented by the electronic device to be distorted, deformed, and other problems, seriously affecting the visual beauty and readability of the handwriting. In order to improve the beauty and readability of the handwriting, the electronic device generally replaces the handwriting input by the user on the touchable electronic screen with a standard font through optical character recognition (OCR) technology, and presents the standard font corresponding to the handwriting input by the user through the touchable electronic screen. However, directly replacing the handwriting input by the user on the touchable electronic screen with a standard font will make the handwriting presented by the electronic device have a stereotyped mechanical feel, ignoring the differences between the handwritings of different users and destroying the user's writing style. The handwriting generation method provided by the embodiment of the present invention obtains first handwriting data of the first handwriting input operation when a first handwriting input operation is detected, and obtains characteristic parameters of the first handwriting input operation based on the first handwriting data, and then fits the first handwriting data based on the characteristic parameters to generate fitted handwriting, which can improve the problems of handwriting distortion and deformation caused by hand shaking of the user during the writing process, and is conducive to improving the fluency and aesthetics of the fitted handwriting; further, the embodiment of the present invention fits the first handwriting data based on the characteristic parameters that can reflect the personalized characteristics of the first handwriting input operation, and can retain the unique writing style of the first handwriting input operation in the generated fitted handwriting, avoiding the mechanical feel of the fitted handwriting, which is conducive to improving the personalization of the fitted handwriting while improving the aesthetics and readability of the fitted handwriting.

[0086] In an optional embodiment of the present invention, the step S102 of acquiring the characteristic parameters of the first handwriting input operation according to the first handwriting data includes steps S1021 to S1023:

[0087] Step S1021: input the first handwriting data into a first target model.

[0088] Step S1022: Obtain a first stroke corresponding to the first handwriting input operation using the first target model according to the first handwriting data.

[0089] Step S1023: extracting a first stroke feature of the first stroke using the first target model, and determining the first stroke feature as a feature parameter of the first handwriting input operation.

[0090] In an embodiment of the present invention, the feature parameters acquired by the electronic device include a first stroke feature corresponding to the first handwriting input operation. The electronic device may acquire the feature parameters of the first handwriting input operation by using a pre-trained first target model.

[0091] The first target model is used to obtain a first stroke corresponding to a first handwriting input operation according to the first handwriting data, and extract a first stroke feature of the first stroke.

[0092] Specifically, the first target model may be a Generative Adversarial Network (GAN) model.

[0093] Specifically, when the electronic device inputs the first handwriting data acquired in step S101 into the first target model, it can execute step S1022 to acquire the first stroke corresponding to the first handwriting input operation based on the first handwriting data using the first target model.

[0094] In some embodiments, in step S1022, the first target model can calculate the writing speed between adjacent sampling points based on the coordinate data and sampling timestamps of each sampling point in the first handwriting data, and determine the writing pause point for the sampling point whose writing speed is less than the first preset threshold, determine the stroke separation boundary based on the writing pause point, and identify the first stroke corresponding to the first handwriting input operation based on the stroke separation boundary; the electronic device can determine the sampling point whose writing speed increases from less than the first preset threshold to greater than or equal to the first preset threshold as the starting point of the first stroke, and determine the sampling point whose writing speed decreases from greater than or equal to the first preset threshold to less than the first preset threshold as the ending point of the first stroke.

[0095] Specifically, the electronic device can calculate the writing speed between adjacent sampling points based on the coordinate data and sampling timestamps of each sampling point in the first handwriting data:

[0096] v1=Δx / Δt (1)

[0097] v2=Δy / Δt (2)

[0098] Where v1 represents the writing speed along the x-axis of the two-dimensional rectangular coordinate system, in pixels / ms; v2 represents the writing speed along the y-axis of the two-dimensional rectangular coordinate system, in pixels / ms; Δx represents the absolute value of the difference between the x-axis coordinates of adjacent sampling points, in pixels; Δy represents the absolute value of the difference between the y-axis coordinates of adjacent sampling points, in pixels; and Δt represents the time difference between the timestamps of adjacent sampling points, in milliseconds.

[0099] The first preset threshold can be determined according to the average speed at which the user writes on the touch screen using the stylus pen; as an example, the first preset threshold is 0.5 pixels / ms.

[0100] In other embodiments, in step S1021, the first target model can calculate the direction angle of the stroke based on the coordinate data and sampling timestamp of each sampling point in the first handwriting data, determine the writing pause point when the direction angle changes by more than a second preset threshold, determine the stroke separation boundary based on the writing pause point, and identify the first stroke corresponding to the first handwriting input operation based on the stroke separation boundary; the electronic device can determine the sampling point at which the direction angle changes from exceeding the second preset threshold to less than or equal to the second preset threshold as the starting point of the first stroke, and determine the sampling point at which the direction angle changes from less than or equal to the second preset threshold to greater than the second preset threshold as the ending point of the first stroke.

[0101] Specifically, the electronic device can calculate the direction angle of the stroke according to the coordinate data and sampling timestamp of each sampling point in the first handwriting data:

[0102] α=arctan(Δy / Δx) (3)

[0103] Where α represents the direction angle of the stroke, unit: °.

[0104] The first preset threshold can be determined based on the average value of the tilt angle data of the stylus tip when the user lifts the pen to stop writing; as an example, the second preset threshold is 60°.

[0105] When the first stroke is acquired in step S1022, the electronic device may execute step S1023 to extract a first stroke feature of the first stroke using the first target model, and determine the first stroke feature as a feature parameter of the first handwriting input operation.

[0106] The number of the first strokes is at least 1. When the number of the first strokes is greater than 1, the electronic device can extract the first stroke feature of each first stroke using the first target model through step S1023, and determine the first stroke feature of each first stroke as the feature parameter of the first handwriting input operation.

[0107] In step S1023 , the first object model may extract a first stroke feature of the first stroke based on the first stroke acquired in step S1022 .

[0108] When the first stroke feature includes a starting angle of the first stroke, an ending angle of the first stroke, a curvature of a turning point of the first stroke, and a stroke length of the first stroke, in step S1023, the first target model may calculate the starting angle of the first stroke, the ending angle of the first stroke, the curvature of a turning point of the first stroke, and the stroke length of the first stroke respectively according to the following method:

[0109] (1) Calculating the starting angle of the first stroke: Calculate the vector angle between the starting point of the first stroke and the sampling points adjacent to the starting point to obtain the starting angle of the first stroke.

[0110] Specifically, the coordinates of the starting point of the first stroke are (x s ,y s ), the coordinates of the sampling points adjacent to the starting point are (x s+1 ,y s+1 ), then the starting angle of the first stroke is:

[0111]

[0112] Among them, θ s Indicates the starting angle of the first stroke.

[0113] (2) Calculating the ending angle of the first stroke: Calculate the vector angle between the ending point of the first stroke and the sampling point adjacent to the ending point to obtain the ending angle of the first stroke.

[0114] Specifically, the coordinates of the end point of the first stroke are (x e ,y e ), the coordinates of the sampling point adjacent to the end point are (x e+1 ,y e+1 ), then the ending angle of the first stroke is:

[0115]

[0116] Among them, θ e Indicates the ending angle of the first stroke.

[0117] (3) Calculate the curvature of the turning point of the first stroke: For each sampling point (xi ,y i ), calculate the sampling point and the adjacent sampling points (x i-1 ,y i-1 )、(x i+1 ,y i+1 ) is the curvature of the curve; specifically, the curvature can be calculated using vector cross product:

[0118]

[0119] Among them, k represents the coordinate (x i ,y i ) and the curvature of the curve formed by the sampling points before and after it.

[0120] (4) Calculate the stroke length of the first stroke: The stroke length of the first stroke is obtained by accumulating the Euclidean distances between adjacent sampling points on the first stroke:

[0121]

[0122] Wherein, L represents the stroke length of the first stroke, and n represents the total number of sampling points in the first stroke.

[0123] The handwriting generation method provided by the embodiment of the present invention can be applied to an application scenario in which the personalized features that need to be retained in the fitted handwriting are the stroke writing features of the first handwriting input operation. The electronic device uses the first target model to extract the first stroke features of the first stroke corresponding to the first handwriting input operation based on the first handwriting data, and determines the first stroke features as the feature parameters of the first handwriting input operation. This can not only improve the efficiency of obtaining the feature parameters of the first handwriting input operation, but also retain the stroke writing features of the first handwriting input operation in the fitted handwriting generated by fitting the first handwriting data based on the feature parameters, thereby improving the personalization of the stroke style in the fitted handwriting.

[0124] In an optional embodiment of the present invention, step S103 of fitting the first handwriting data based on the characteristic parameters to generate fitted handwriting includes steps S1031 to S1032:

[0125] Step S1031: using the first target model to obtain a first target stroke feature corresponding to the first stroke feature from a stroke feature mapping table according to the first stroke feature.

[0126] Step S1032: Using the first target model, fitting the first handwriting data according to the first target stroke features to generate fitting handwriting.

[0127] In an embodiment of the present invention, the feature parameters obtained by the electronic device through step S102 include a first stroke feature corresponding to the first handwriting input operation; the first target model is also used to obtain a first target stroke feature corresponding to the first stroke feature from a stroke feature mapping table based on the first stroke feature, and fit the first handwriting data based on the first target stroke feature to generate fitted handwriting.

[0128] The first target model includes a standard handwriting corresponding to the first handwriting input operation and a degree of optimization of the first original handwriting corresponding to the first handwriting input operation. The standard handwriting includes any type of font used in the industry, such as Songti, Kaiti, and Heiti. The higher the degree of optimization of the first original handwriting corresponding to the first handwriting input operation, the closer the first target stroke feature obtained by the electronic device in step S1031 is to the stroke feature of the same stroke as the first stroke in the standard handwriting. The lower the degree of optimization of the first original handwriting corresponding to the first handwriting input operation, the closer the first target stroke feature obtained by the electronic device in step S1031 is to the first stroke feature.

[0129] The stroke feature mapping table is used to establish a mapping relationship between the original stroke features of a handwriting input operation and the target stroke features. The stroke feature mapping table stores the original stroke features of the handwriting input operation and the target stroke features that are mapped to the original stroke features. Based on the original stroke features of the handwriting input operation, the target stroke features that are mapped to the original stroke features can be found in the stroke feature mapping table. The target stroke features that are mapped to the original stroke features are the stroke features of the target strokes obtained by optimizing the original strokes corresponding to the original stroke features. Methods for optimizing the original strokes corresponding to the original stroke features may include, but are not limited to, making the starting and ending strokes of the original strokes more aesthetically pleasing, making the horizontal lines in the original strokes straighter, and making the vertical lines in the original strokes more vertical.

[0130] Among them, the handwriting input operation includes the first handwriting input operation detected by the electronic device through step S101; the original stroke refers to the stroke obtained by fitting the handwriting data of the handwriting input operation, and the original stroke includes the first stroke; the original stroke feature refers to the stroke feature extracted based on the original stroke, and the original stroke feature includes the first stroke feature.

[0131] In an embodiment of the present invention, during the training of the first target model, the target stroke feature that has a mapping relationship with the original stroke feature can be added to the stroke feature mapping table and a mapping relationship between the target stroke feature and the original stroke feature can be established, so that the electronic device can use the first target model in step S1031 to search the stroke feature mapping table for the target stroke feature that has a mapping relationship with the first stroke feature based on the first stroke feature, and determine the target stroke feature in the stroke feature mapping table that has a mapping relationship with the first stroke feature as the first target stroke feature corresponding to the first stroke feature.

[0132] It can be understood that the target stroke features stored in the stroke feature mapping table include the first target stroke feature.

[0133] When the first target stroke feature corresponding to the first stroke feature is obtained through step S1031, the electronic device can execute step S1032 to continue to use the first target model to fit the first handwriting data according to the first target stroke feature, so as to correct the stroke feature of the stroke identical to the first stroke in the first original handwriting obtained by fitting based on the first handwriting data to the first target stroke feature, so that the stroke identical to the first stroke in the fitted handwriting has the same stroke feature as the first target stroke feature. Therefore, while improving the aesthetics and readability of the fitted handwriting, the stroke writing features of the first handwriting input operation are retained in the fitted handwriting, thereby improving the personalization of the stroke style in the fitted handwriting.

[0134] In an optional embodiment of the present invention, the handwriting generation method provided by the embodiment of the present invention may further include steps A11 to A18:

[0135] Step A11: When a second handwriting input operation is detected, obtain second handwriting data of the second handwriting input operation.

[0136] Step A12: input the second handwriting data into the first target model to be trained.

[0137] Step A13: using the first target model to be trained to obtain a second stroke corresponding to the second handwriting input operation according to the second handwriting data.

[0138] Step A14: extracting second stroke features of the second stroke using the first target model to be trained.

[0139] Step A15: Using the first target model to be trained, fitting the second handwriting data according to the second stroke feature to obtain at least one group of candidate strokes corresponding to the second stroke feature.

[0140] Step A16: Determine a target stroke corresponding to the second stroke feature from the candidate strokes.

[0141] Step A17: using the first target model to be trained to obtain a second target stroke feature of the target stroke.

[0142] Step A18: construct a stroke feature mapping table including the second stroke feature and the second target stroke feature in the first target model to be trained to obtain a first target model.

[0143] In an embodiment of the present invention, the electronic device may train the first target model to be trained through operations corresponding to steps A11 to A18 before step S101 to obtain the first target model.

[0144] Among them, the second handwriting input operation is a handwriting input operation input into the touch screen of the electronic device before the first handwriting input operation. The second original handwriting corresponding to the second handwriting input operation can be the same as or different from the first original handwriting corresponding to the first handwriting input operation. The embodiment of the present invention does not make specific limitations on this.

[0145] Specifically, before step A11, the electronic device may receive a third instruction input by the user, where the third instruction is used to indicate the standard handwriting corresponding to the first target model to be trained and the degree to which the first target model to be trained optimizes the original handwriting corresponding to the handwriting input operation; when the electronic device receives the third instruction, it may set the standard handwriting in the first target model to be trained to the standard handwriting indicated by the third instruction, and set the degree to which the first target model to be trained optimizes the original handwriting corresponding to the handwriting input operation to the degree to which the third instruction optimizes the original handwriting corresponding to the handwriting input operation.

[0146] The handwriting input operation includes a first handwriting input operation and a second handwriting input operation; the original handwriting includes a first original handwriting and a second original handwriting.

[0147] In step A11, when the electronic device detects the second handwriting input operation, it can continuously collect the coordinate data and sampling timestamp of the sampling point corresponding to the second handwriting input operation according to a preset period, and determine the coordinate data and sampling timestamp of the sampling point as the second handwriting data of the second handwriting input operation; the second handwriting data includes the coordinate data and sampling timestamp of at least one sampling point.

[0148] After acquiring the second handwriting data, the electronic device may execute step A12 to input the second handwriting data into the first target model to be trained.

[0149] In step A13, the electronic device may follow the same operation as step S1022 to obtain the second stroke corresponding to the second handwriting input operation based on the second handwriting data using the first target model to be trained.

[0150] In step A14, the electronic device may extract the second stroke feature of the second stroke using the first target model to be trained according to the same operation as step S1023.

[0151] When the second stroke feature is obtained, the electronic device can execute step A15, use the first target model to be trained, and fit the second handwriting data according to the second stroke feature, standard handwriting, and the degree of optimization of the original handwriting corresponding to the handwriting input operation, combined with different random noises, to obtain at least one group of candidate strokes corresponding to the second stroke feature, each group of candidate strokes having a different stroke style.

[0152] When the electronic device obtains at least one group of candidate strokes corresponding to the second stroke feature through step A15, in step A16, the electronic device can display the candidate strokes corresponding to the second stroke feature through the touch screen and prompt the user to select a group of candidate strokes from the candidate strokes; when the user selects any group of candidate strokes from the candidate strokes, the electronic device can receive a candidate stroke selection signal input by the user and determine the candidate stroke indicated by the candidate stroke selection signal as the target stroke.

[0153] Reference Figure 2 , shows a logic block diagram of a target stroke determination process provided by an embodiment of the present invention. First, the electronic device inputs the second handwriting data into the first target model to be trained through step A12; then, the electronic device obtains at least one group of candidate strokes by executing the operations corresponding to steps A13 to A15; finally, the electronic device executes step A16 to determine the target stroke from the candidate strokes.

[0154] After determining the target stroke, the electronic device may execute step A17 to extract the stroke features of the target stroke using the first target model to be trained to obtain the second target stroke features.

[0155] When the second target stroke feature is obtained, the electronic device can determine the second target stroke feature as a target stroke feature that has a mapping relationship with the second stroke feature, and execute step A18 to construct a stroke feature mapping table including the second stroke feature and the second target stroke feature in the first target model to be trained to obtain the first target model; in the stroke feature mapping table, there is a mapping relationship between the second stroke feature and the second target stroke feature.

[0156] In an embodiment of the present invention, when the number of second strokes is at least 2, the electronic device may repeatedly perform operations corresponding to steps A14 to A17, and then add the acquired second stroke feature and the second target stroke feature corresponding to the second stroke feature to the stroke feature mapping table, and establish a mapping relationship between the second stroke feature and the second target stroke feature in the stroke feature mapping table.

[0157] The handwriting generation method provided by an embodiment of the present invention obtains the first target model by constructing a stroke feature mapping table for constructing a mapping relationship between the original stroke features of the handwriting input operation and the target stroke features during the process of training the first target model to be trained. Therefore, when the electronic device applies the first target model to generate the fitted handwriting through the operations corresponding to steps S1031 to S1032, the first target stroke feature corresponding to the first stroke feature can be obtained by searching the handwriting feature mapping table, thereby simplifying the operational process of generating the fitted handwriting. While improving the aesthetics, readability and personalization of the fitted handwriting, the efficiency of generating the fitted handwriting is also improved.

[0158] In an embodiment of the present invention, the original stroke features include a first stroke feature and a second stroke feature; the target stroke features include a first target stroke feature and a second target stroke feature; wherein the first stroke feature and the second stroke feature may be the same or different, and correspondingly, the first target stroke feature and the second target stroke feature may be the same or different.

[0159] In an optional embodiment of the present invention, the step S102 of acquiring the characteristic parameters of the first handwriting input operation according to the first handwriting data includes steps S1024 to S1025:

[0160] Step S1024: Acquire writing operation data of each sampling point in the first handwriting data according to the sampling timestamp of the sampling point in the first handwriting data, and determine the writing operation data of each sampling point as operation data of the first handwriting input operation.

[0161] Step S1025: Determine the operation data of the first handwriting input operation as the characteristic parameters of the first handwriting input operation.

[0162] In the embodiment of the present invention, the characteristic parameter includes operation data of the first handwriting input operation, and the personalized feature reflected by the characteristic parameter is specifically the writing operation feature of the first handwriting input operation.

[0163] The operation data of the first handwriting input operation includes the writing operation data of each sampling point in the first handwriting data; the writing operation data of the sampling point may include but is not limited to the pressure data of the sampling point, the tilt angle data of the sampling point, etc. The pressure data of the sampling point is the pressure data of the tip of the stylus when the electronic device obtains the sampling point, and the tilt angle data of the sampling point is the angle data of the acute angle formed between the tip of the stylus and the touch screen when the electronic device obtains the sampling point.

[0164] The pressure data of the sampling point is positively correlated with the handwriting width of the fitted handwriting; specifically, the greater the pressure data of the sampling point, the wider the handwriting width of the fitted handwriting and the thicker the line of the fitted handwriting; the smaller the pressure data of the sampling point, the narrower the handwriting width of the fitted handwriting and the thinner the line of the fitted handwriting.

[0165] The tilt angle data of the sampling point is related to the shape of the pen tip of the fitted handwriting; specifically, the smaller the tilt angle data of the sampling point, the smaller the contact area between the tip of the stylus and the touch screen, and the sharper the pen tip of the fitted handwriting; the larger the tilt angle data of the sampling point, the larger the contact area between the tip of the stylus and the touch screen, and the rounder the pen tip of the fitted handwriting.

[0166] In an optional embodiment of the present invention, the characteristic parameters include operation data of a first handwriting input operation; and step S103 of fitting the first handwriting data based on the characteristic parameters to generate fitted handwriting includes steps S1033 to S1035:

[0167] Step S1033: input the operation data and the first handwriting data into the second target model.

[0168] Step S1034: Determine handwriting rendering parameters corresponding to the first handwriting input operation according to the operation data using the second object model.

[0169] Step S1035: Using the second target model, fitting the first handwriting data according to the handwriting rendering parameters to obtain fitting handwriting.

[0170] In an embodiment of the present invention, the characteristic parameters obtained by the electronic device through step S102 include the operation data of the first handwriting input operation. In the process of fitting the first handwriting data to generate fitted handwriting based on the characteristic parameters, the electronic device can input the operation data of the first handwriting input operation and the first handwriting data into the second target model together, and use the second target model to fit the first handwriting data according to the operation data to obtain the fitted handwriting.

[0171] Before step S1033, the electronic device may construct a second target model to be trained, and train the second target model to be trained to obtain the second target model; wherein the second target model to be trained may be an unsupervised generative adversarial network model (CycleGAN).

[0172] The electronic device trains the second target model to be trained to obtain the second target model, which may specifically include steps B11 to B16:

[0173] Step B11: When a third handwriting input operation is detected, obtain third handwriting data of the third handwriting input operation.

[0174] Specifically, when the electronic device detects the third handwriting input operation, it can continuously collect the coordinate data and sampling timestamp of the sampling point corresponding to the third handwriting input operation according to a preset period, and determine the coordinate data and sampling timestamp of the sampling point as the third handwriting data of the third handwriting input operation; the third handwriting data includes the coordinate data and sampling timestamp of at least one sampling point.

[0175] The third handwriting input operation is a handwriting input operation input into the touch screen of the electronic device before the first handwriting input operation. The third original handwriting corresponding to the third handwriting input operation may be the same as or different from the first original handwriting corresponding to the first handwriting input operation. This embodiment of the present invention does not specifically limit this.

[0176] Step B12: Acquire the operation data of the third handwriting input operation.

[0177] Step B13: Obtain the paper handwriting corresponding to the third handwriting input operation.

[0178] Specifically, before step B11, at least one layer of writing paper with positioning points is covered on the touch screen of the electronic device, and the user writes on the writing paper using a stylus with a graphite pen tip; in the process of the user using the stylus with a graphite pen tip to write on the writing paper, while forming paper writing handwriting on the writing paper, the user also inputs a third handwriting input operation into the electronic device at the same time, thereby, the electronic device can obtain the paper writing handwriting corresponding to the third handwriting input operation.

[0179] Step B14, receiving a fourth instruction; the fourth instruction is used to indicate the degree to which the second target model to be trained optimizes the original handwriting corresponding to the handwriting input operation.

[0180] Step B15: Set the standard handwriting in the second target model to be trained as the paper writing handwriting, and set the degree to which the second target model to be trained optimizes the original handwriting corresponding to the handwriting input operation to the degree to which the fourth instruction indicates the optimization of the original handwriting corresponding to the handwriting input operation.

[0181] In the embodiment of the present invention, the handwriting input operation further includes a third handwriting input operation, and the original handwriting further includes a third original handwriting.

[0182] Step B16: Input the operation data of the third handwriting input operation and the third handwriting data into the second target model to be trained; based on the operation data and the third handwriting data of the third handwriting input operation, with the handwriting written on paper as the standard handwriting, train the second target model to be trained according to the degree of optimization of the original handwriting corresponding to the handwriting input operation indicated by the third instruction, until the loss value of the second target model to be trained is less than or equal to the third preset threshold, thereby obtaining the second target model.

[0183] In related technologies, there are significant differences in material properties between touchable electronic screens and traditional paper, resulting in significantly different feel when users write on paper and on touch screens. This in turn leads to significant differences between the handwriting obtained by users writing on paper and the original handwriting obtained by users writing on a touch screen and then fitted by an electronic device. The handwriting on paper and the original handwriting fitted by the electronic device are inconsistent in terms of line thickness, pen shape, etc. If the electronic device directly displays the original handwriting, the handwriting displayed by the electronic device will be distorted.

[0184] In order to solve the above problems, the embodiment of the present invention obtains the feature parameters of the electronic device through step S102, including the operation data of the first handwriting input operation, and in the process of fitting the first handwriting data to generate fitted handwriting based on the feature parameters, uses the second target model to fit the first handwriting data according to the operation data to obtain fitted handwriting, so that the writing operation characteristics of the first handwriting input operation can be retained in the fitted handwriting, thereby improving the similarity between the fitted handwriting and the handwriting written on paper, and thereby improving the personalization degree and handwriting authenticity of the fitted handwriting.

[0185] Specifically, in step S1034, the second target model can determine the handwriting width of the fitted handwriting based on the pressure data of the sampling point in the operation data, and determine the pen tip shape of the fitted handwriting based on the inclination angle data of the sampling point in the operation data, and then determine the handwriting rendering parameters of the fitted handwriting based on the handwriting width and the pen tip shape.

[0186] In step S1035, the second target model can fit the first handwriting data according to the handwriting rendering parameters, so as to render and correct the handwriting width and pen tip shape of the original handwriting obtained by fitting the first handwriting data according to the handwriting rendering parameters to obtain the fitted handwriting, thereby improving the similarity between the fitted handwriting and the handwriting written on paper.

[0187] Reference Figure 3, shows a flowchart of another handwriting generation method provided by an embodiment of the present invention, the method comprising steps C11 to C14:

[0188] Step C11: data collection.

[0189] Specifically, the data collection process specifically includes: the electronic device obtains first handwriting data of the first handwriting input operation, and obtains characteristic parameters of the first handwriting input operation based on the first handwriting data; the characteristic parameters include the operation data of the first handwriting input operation.

[0190] Step C12: Model processing.

[0191] Specifically, first, the electronic device inputs the operation data and the first handwriting data into the second object model; then, the electronic device uses the second object model to determine the handwriting rendering parameters corresponding to the first handwriting input operation according to the operation data.

[0192] Step C13: dynamic rendering.

[0193] Specifically, the electronic device uses the second target model to fit the first handwriting data according to the handwriting rendering parameters to obtain the fitted handwriting.

[0194] Step C14: real-time output.

[0195] Specifically, the electronic device displays the fitting handwriting output by the second target model through a touch screen.

[0196] In an optional embodiment of the present invention, the step S102 of acquiring the characteristic parameters of the first handwriting input operation according to the first handwriting data includes steps S1026 to S1027:

[0197] Step S1026: Calculate the local curvature value of the first original handwriting corresponding to the first handwriting input operation according to the first handwriting data.

[0198] Step S1027: Determine the local curvature value as a characteristic parameter of the first handwriting input operation.

[0199] In an embodiment of the present invention, the feature parameters acquired by the electronic device include the local curvature value of the first original handwriting corresponding to the first handwriting input operation. The electronic device can calculate the local curvature value of the first original handwriting based on the coordinate data of the sampling point in the first handwriting data through step S1026.

[0200] Specifically, in step S1026: the electronic device can calculate the curvature of the curve formed by each sampling point and at least two adjacent sampling points in front and behind according to the coordinate data of the sampling points in the first handwriting data, and obtain the local curvature value of the first original handwriting; Specifically, the electronic device can use vector operations to calculate the curvature, assuming that any sampling point is P i , the sampling points adjacent to this sampling point can be expressed as P i-2 , P i-1 , P i+1 , P i+2 , by calculating these sampling points (P i-2 , P i-1 , P i , P i+1 , P i+2 ) points, the angle and distance between the vectors formed by the points can be obtained as the sampling point P i The local curvature value, and the sampling point is P i The local curvature value of is determined as the local curvature value K of the first original handwriting i The calculation formula of the local curvature value can refer to the above formula 6, and will not be repeated here to avoid repetition.

[0201] It can be understood that the number of local curvature values ​​of the first original handwriting is at least 1.

[0202] In an optional embodiment of the present invention, step S103 of fitting the first handwriting data based on the characteristic parameters to generate fitting handwriting includes steps S1036 to S1039:

[0203] Step S1036: Determine a shaking area corresponding to the first handwriting input operation according to the local curvature value.

[0204] Step S1037: Obtain the shaking amplitude of the shaking area.

[0205] Step S1038: Determine the number of Bezier curve control points corresponding to the jitter area according to the jitter amplitude.

[0206] Step S1039: fitting the first handwriting data according to the number of Bezier curve control points corresponding to the shaking area to obtain fitting handwriting.

[0207] In an embodiment of the present invention, the feature parameters obtained by the electronic device through step S102 include the local curvature value of the first original handwriting corresponding to the first handwriting input operation; the electronic device fits the first handwriting data based on the feature parameters including the local curvature value of the first original handwriting corresponding to the first handwriting input operation, so as to avoid overfitting of the first original handwriting in the process of smoothing the first original handwriting, so that the jitter characteristics of the first handwriting input operation are retained in the generated fitting handwriting.

[0208] Specifically, in step S1036, the electronic device may compare each local curvature value calculated in step S1026 with a fourth preset threshold. If the local curvature value is greater than or equal to the fourth preset threshold, the curve corresponding to the local curvature value is used to determine the jitter region corresponding to the first handwriting input operation. The value of the fourth preset threshold can be determined based on the requirement for handwriting smoothness in actual application scenarios. For example, the fourth preset threshold may be 0.1.

[0209] In step S1037, the electronic device may calculate the standard deviation of the local curvature values ​​calculated based on each sampling point in the jitter area, and determine the standard deviation as the jitter amplitude of the jitter area:

[0210] It can be understood that, the greater the shaking amplitude of the shaking area, the more severe the shaking of the first handwriting input operation in the shaking area. In order to improve the smoothness of the first original handwriting, in step S1038, the electronic device can assign more Bezier curve control points to the shaking area; correspondingly, the smaller the shaking amplitude of the shaking area, the lighter the shaking of the first handwriting input operation in the shaking area. In order to avoid over-fitting of the first original handwriting, resulting in distortion of the generated fitting handwriting and destruction of the user's writing style, in step S1038, the electronic device can assign fewer Bezier curve control points to the shaking area.

[0211] In step S1039, the electronic device may use a Bezier curve algorithm to fit the first handwriting data according to the number of Bezier curve control points corresponding to the shaking area to obtain fitted handwriting.

[0212] The handwriting generation method provided by the embodiment of the present invention determines the jitter area corresponding to the first handwriting input operation based on the local curvature value of the first original handwriting corresponding to the first handwriting input operation in the characteristic parameters, and determines the number of Bezier curve control points corresponding to the jitter area based on the jitter amplitude of the jitter area. In the process of fitting the first handwriting data based on the number of Bezier curve control points corresponding to the jitter area, only the smoothness of the jitter area with a large jitter amplitude can be improved. While ensuring the smoothness of the fitted handwriting, the fitting degree of the fitted handwriting is further reduced, thereby improving the authenticity and personalization of the fitted handwriting.

[0213] In an optional embodiment of the present invention, the characteristic parameter includes at least one of the following:

[0214] a first stroke feature corresponding to the first handwriting input operation;

[0215] Operation data of the first handwriting input operation;

[0216] The local curvature value of the first original handwriting corresponding to the first handwriting input operation.

[0217] Specifically, when the feature parameter includes the first stroke feature corresponding to the first handwriting input operation, the electronic device may execute steps S1031 to S1032 to generate the fitted handwriting.

[0218] In a case where the feature parameter includes operation data of the first handwriting input operation, the electronic device may execute steps S1033 to S1035 to generate the fitted handwriting.

[0219] In a case where the feature parameter includes a local curvature value of the first original handwriting corresponding to the first handwriting input operation, the electronic device may execute steps S1036 to S1039 to generate the fitting handwriting.

[0220] In the case where the feature parameters include the first stroke feature and the operation data, the electronic device may simultaneously execute steps S1031 to S1032, and steps S1033 to S1035 to generate the fitting handwriting.

[0221] In the case where the feature parameters include the first stroke feature and the local curvature value, the electronic device may simultaneously execute steps S1031 to S1032, and steps S1036 to S1039 to generate the fitting handwriting.

[0222] In the case where the feature parameters include operation data and local curvature values, the electronic device may simultaneously execute steps S1033 to S1035 and steps S1036 to S1039 to generate the fitting handwriting.

[0223] In the case where the feature parameters include the first stroke feature, the operation data and the local curvature value, the electronic device may simultaneously execute steps S1031 to S1032, steps S1033 to S1035, and steps S1036 to S1039 to generate the fitting handwriting.

[0224] In summary, an embodiment of the present invention provides a method for generating handwriting, which obtains first handwriting data of the first handwriting input operation when a first handwriting input operation is detected, and obtains characteristic parameters of the first handwriting input operation based on the first handwriting data, and then fits the first handwriting data based on the characteristic parameters to generate fitted handwriting, which can improve the handwriting distortion and deformation problems caused by hand shaking during the writing process, and is conducive to improving the fluency and aesthetics of the fitted handwriting; further, an embodiment of the present invention fits the first handwriting data based on characteristic parameters that can reflect the personalized characteristics of the first handwriting input operation, which can retain the unique writing style of the first handwriting input operation in the generated fitted handwriting, avoid the mechanical feel of the fitted handwriting, and is conducive to improving the personalization of the fitted handwriting while improving the aesthetics and readability of the fitted handwriting. Reference Figure 4 , showing a comparison diagram of a first original handwriting and a fitted handwriting provided by an embodiment of the present invention, Figure 4 The comparison diagram shown is the fitting handwriting generated by the electronic device simultaneously executing steps S1031 to S1032, steps S1033 to S1035, and steps S1036 to S1039 when the feature parameters include the first stroke feature, operation data and local curvature value.

[0225] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required for the embodiments of the present invention.

[0226] Device embodiment

[0227] Reference Figure 5 , shows a logic block diagram of a handwriting generation device provided by an embodiment of the present invention, the device comprising:

[0228] A first acquisition module 501 is configured to acquire first handwriting data of a first handwriting input operation when a first handwriting input operation is detected;

[0229] The second acquisition module 502 is configured to acquire characteristic parameters of the first handwriting input operation based on the first handwriting data; the characteristic parameters are used to reflect the personalized characteristics of the first handwriting input operation;

[0230] The first fitting module 503 is used to fit the first handwriting data based on the characteristic parameters to generate fitting handwriting.

[0231] Optionally, the second acquisition module includes:

[0232] A first input submodule, configured to input the first handwriting data into a first target model;

[0233] a first acquisition submodule, configured to acquire a first stroke corresponding to the first handwriting input operation according to the first handwriting data using the first target model;

[0234] The first determining submodule is configured to extract a first stroke feature of the first stroke by using the first target model, and determine the first stroke feature as a feature parameter of the first handwriting input operation.

[0235] Optionally, the first fitting module includes:

[0236] a second acquisition submodule, configured to acquire, using the first target model and based on the first stroke feature, a first target stroke feature corresponding to the first stroke feature from a stroke feature mapping table; the stroke feature mapping table is configured to construct a mapping relationship between the original stroke feature and the target stroke feature of the handwriting input operation;

[0237] The first fitting submodule is used to fit the first handwriting data according to the first target stroke feature using the first target model to generate fitted handwriting.

[0238] Optionally, the device further comprises:

[0239] a third acquisition module, configured to acquire second handwriting data of the second handwriting input operation when a second handwriting input operation is detected;

[0240] An input module, configured to input the second handwriting data into a first target model to be trained;

[0241] a fourth acquisition module, configured to acquire a second stroke corresponding to the second handwriting input operation according to the second handwriting data using the first target model to be trained;

[0242] an extraction module, configured to extract a second stroke feature of the second stroke using the first target model to be trained;

[0243] a second fitting module, configured to fit the second handwriting data according to the second stroke feature using the first target model to be trained, to obtain at least one set of candidate strokes corresponding to the second stroke feature;

[0244] a determination module, configured to determine a target stroke corresponding to the second stroke feature from the candidate strokes;

[0245] a fifth acquisition module, configured to acquire a second target stroke feature of the target stroke using the first target model to be trained;

[0246] A construction module is used to construct a stroke feature mapping table including the second stroke feature and the second target stroke feature in the first target model to be trained to obtain the first target model.

[0247] Optionally, the first fitting module further includes:

[0248] a second input submodule, configured to input the operation data and the first handwriting data into a second target model;

[0249] a second determining submodule, configured to determine, using the second target model and based on the operation data, a handwriting rendering parameter corresponding to the first handwriting input operation;

[0250] The second fitting submodule is used to fit the first handwriting data using the second target model according to the handwriting rendering parameters to obtain the fitted handwriting.

[0251] Optionally, the second acquisition module further includes:

[0252] a calculation submodule, configured to calculate a local curvature value of a first original handwriting corresponding to the first handwriting input operation based on the first handwriting data;

[0253] The third determining submodule is configured to determine the local curvature value as a characteristic parameter of the first handwriting input operation.

[0254] Optionally, the first fitting module further includes:

[0255] a fourth determining submodule, configured to determine a shaking area corresponding to the first handwriting input operation according to the local curvature value;

[0256] A third acquisition submodule is used to obtain the shaking amplitude of the shaking area;

[0257] a fifth determining submodule, configured to determine the number of Bezier curve control points corresponding to the jitter area according to the jitter amplitude;

[0258] The third fitting submodule is configured to fit the first handwriting data according to the number of Bezier curve control points corresponding to the shaking area to obtain fitted handwriting.

[0259] Optionally, the characteristic parameter includes at least one of the following:

[0260] a first stroke feature corresponding to the first handwriting input operation;

[0261] Operation data of the first handwriting input operation;

[0262] The local curvature value of the first original handwriting corresponding to the first handwriting input operation.

[0263] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0264] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0265] Reference Figure 6 , is a structural block diagram of an electronic device for generating handwriting provided by an embodiment of the present invention. Figure 6 As shown, the electronic device includes: a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the handwriting generation method of the aforementioned embodiment.

[0266] The processor may be a CPU, a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA or other programmable device, a transistor logic device, a hardware component, or any combination thereof. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0267] The communication bus may include a path for transmitting information between the memory and the communication interface. The communication bus may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 The fact that only one line is used does not mean that there is only one bus or one type of bus.

[0268] The memory may be a ROM (Read-Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read-Only Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0269] An embodiment of the present invention further provides a computer program product, including a computer program / instruction, which can implement the handwriting generation method described above when executed by a processor.

[0270] An embodiment of the present invention further provides a non-transitory computer-readable storage medium, which, when the instructions in the storage medium are executed by a processor of an electronic device (server or terminal), enables the processor to execute the aforementioned handwriting generation method.

[0271] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0272] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0273] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems) and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0274] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a predictable manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0275] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0276] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0277] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0278] The above is a detailed introduction to the handwriting generation method, electronic device and computer program product provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A method for generating handwriting, characterized in that: The method comprises: When a first handwriting input operation is detected, obtaining first handwriting data of the first handwriting input operation; Acquire characteristic parameters of the first handwriting input operation according to the first handwriting data; the characteristic parameters are used to reflect personalized characteristics of the first handwriting input operation; Based on the characteristic parameters, the first handwriting data is fitted to generate fitted handwriting.

2. The method according to claim 1, characterized in that The acquiring, based on the first handwriting data, characteristic parameters of the first handwriting input operation includes: inputting the first handwriting data into a first target model; Obtaining a first stroke corresponding to the first handwriting input operation using the first target model according to the first handwriting data; A first stroke feature of the first stroke is extracted using the first target model, and the first stroke feature is determined as a feature parameter of the first handwriting input operation.

3. The method according to claim 2, characterized in that The step of fitting the first handwriting data based on the characteristic parameters to generate fitted handwriting includes: Obtaining, using the first target model and based on the first stroke feature, a first target stroke feature corresponding to the first stroke feature from a stroke feature mapping table; the stroke feature mapping table is used to construct a mapping relationship between the original stroke feature and the target stroke feature of the handwriting input operation; The first target model is used to fit the first handwriting data according to the first target stroke feature to generate fitted handwriting.

4. The method according to claim 3, characterized in that The method further comprises: When a second handwriting input operation is detected, obtaining second handwriting data of the second handwriting input operation; inputting the second handwriting data into a first target model to be trained; Obtaining a second stroke corresponding to the second handwriting input operation according to the second handwriting data using the first target model to be trained; extracting a second stroke feature of the second stroke by using the first target model to be trained; fitting the second handwriting data using the first target model to be trained according to the second stroke feature to obtain at least one set of candidate strokes corresponding to the second stroke feature; determining a target stroke corresponding to the second stroke feature from the candidate strokes; Acquiring a second target stroke feature of the target stroke using the first target model to be trained; A stroke feature mapping table including the second stroke feature and the second target stroke feature is constructed in the first target model to be trained to obtain a first target model.

5. The method according to claim 1, wherein The characteristic parameters include operation data of the first handwriting input operation; and fitting the first handwriting data based on the characteristic parameters to generate fitted handwriting includes: inputting the operation data and the first handwriting data into a second object model; Determining handwriting rendering parameters corresponding to the first handwriting input operation according to the operation data using the second object model; The first handwriting data is fitted using the second target model according to the handwriting rendering parameters to obtain fitted handwriting.

6. The method according to claim 1, characterized in that The acquiring, based on the first handwriting data, characteristic parameters of the first handwriting input operation includes: calculating, based on the first handwriting data, a local curvature value of the first original handwriting corresponding to the first handwriting input operation; The local curvature value is determined as a characteristic parameter of the first handwriting input operation.

7. The method according to claim 6, characterized in that The step of fitting the first handwriting data based on the characteristic parameters to generate fitted handwriting includes: determining a shaking area corresponding to the first handwriting input operation according to the local curvature value; Obtaining the shaking amplitude of the shaking area; determining the number of Bezier curve control points corresponding to the jitter area according to the jitter amplitude; The first handwriting data is fitted according to the number of Bezier curve control points corresponding to the shaking area to obtain fitted handwriting.

8. The method according to claim 1, characterized in that The characteristic parameters include at least one of the following: a first stroke feature corresponding to the first handwriting input operation; Operation data of the first handwriting input operation; The local curvature value of the first original handwriting corresponding to the first handwriting input operation.

9. An electronic device, characterized in that: The electronic device includes a processor, a memory, a communication interface and a communication bus, and the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store executable instructions, and the executable instructions enable the processor to execute the handwriting generation method as described in any one of claims 1 to 8.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the handwriting generation method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Handwriting generation method and device, equipment and storage medium

    CN113743302A

  • Handwriting input handwriting display method and device, electronic equipment and storage medium

    CN118747055A