WO2023206257A1 - 手写笔迹生成方法、装置、计算机设备和可读介质 - Google Patents

手写笔迹生成方法、装置、计算机设备和可读介质 Download PDF

Info

Publication number
WO2023206257A1
WO2023206257A1 PCT/CN2022/089957 CN2022089957W WO2023206257A1 WO 2023206257 A1 WO2023206257 A1 WO 2023206257A1 CN 2022089957 W CN2022089957 W CN 2022089957W WO 2023206257 A1 WO2023206257 A1 WO 2023206257A1
Authority
WO
WIPO (PCT)
Prior art keywords
handwriting
interpolation point
width
brush
interpolation
Prior art date
Application number
PCT/CN2022/089957
Other languages
English (en)
French (fr)
Inventor
吴艳红
Original Assignee
京东方科技集团股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 京东方科技集团股份有限公司 filed Critical 京东方科技集团股份有限公司
Priority to CN202280001034.5A priority Critical patent/CN117321636A/zh
Priority to PCT/CN2022/089957 priority patent/WO2023206257A1/zh
Publication of WO2023206257A1 publication Critical patent/WO2023206257A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
    • G06F3/0488Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/80Creating or modifying a manually drawn or painted image using a manual input device, e.g. mouse, light pen, direction keys on keyboard

Definitions

  • the invention belongs to the field of computer application technology, and specifically relates to a handwriting generation method, device, computer equipment and readable media.
  • the present invention aims to solve at least one of the technical problems existing in the prior art and provide a handwriting generation method, device, computer equipment and readable medium capable of user-defined effects.
  • inventions of the present invention provide a method for generating handwriting.
  • the handwriting includes at least one handwriting segment formed using a brush, wherein each handwriting segment is generated in the following manner:
  • the brush parameters are determined according to the pen shape parameters selected by the user, or the brush parameters are brush parameters set by the user, and the brush parameters at least include the shape or pattern of the brush element;
  • the handwriting width at the position of the interpolation point is determined according to the brush parameters, and a handwriting corresponding to the handwriting trajectory curve is generated according to the brush parameters and the handwriting width.
  • embodiments of the present invention also provide a handwriting generation device, including a parameter acquisition module, a trajectory generation module, an interpolation point determination module, a handwriting width determination module and a handwriting generation module.
  • the parameter acquisition module is used to obtain the handwriting Brush parameters, the brush parameters are determined according to the pen shape parameters selected by the user, or the brush parameters are brush parameters set by the user, and the brush parameters at least include the shape or pattern of the brush elements;
  • the trajectory generation module is used to obtain sampling points of the handwriting trajectory, and generate a handwriting trajectory curve according to the sampling points, where the handwriting trajectory is the trajectory of one trajectory segment in the handwriting segment;
  • the interpolation point determination module is used to determine the position of the interpolation point on the handwriting trajectory curve, wherein the arc lengths between any two adjacent interpolation points on the handwriting trajectory curve are the same;
  • the handwriting width determination module is configured to determine the handwriting width at the position of the interpolation point according to the brush parameters
  • the handwriting generation module is configured to generate handwriting corresponding to the handwriting trajectory curve according to the brush parameters and the handwriting width.
  • an embodiment of the present invention further provides a computer device, including:
  • processors one or more processors
  • a storage device on which one or more programs are stored
  • the one or more processors When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the handwriting generation method as described above.
  • embodiments of the present invention also provide a computer-readable medium on which a computer program is stored, wherein when the program is executed, the handwriting generation method as described above is implemented.
  • Figure 1 is a schematic flow chart of a handwriting generation method according to an embodiment of the present invention
  • Figure 2a is a schematic diagram of second-order Bezier curve generation according to an embodiment of the present invention.
  • Figure 2b is a schematic diagram of equal arc length interpolation according to an embodiment of the present invention.
  • Figure 3 is a schematic diagram of various types of pen shape parameters according to the embodiment of the present invention.
  • Figure 4a is a comparison diagram of the effects of handwriting in the prior art and handwriting with a thick brush according to the embodiment of the present invention
  • Figure 4b is a comparison diagram of the effects of handwriting in the prior art and handwriting with a fine brush according to the embodiment of the present invention
  • Figure 5 is a schematic flowchart 1 of determining the position of the interpolation point according to the embodiment of the present invention.
  • Figure 6 is a schematic flowchart of adjusting handwriting width according to an embodiment of the present invention.
  • Figure 7a is a rendering of handwriting with a thick brush corresponding to different ⁇ according to the embodiment of the present invention.
  • Figure 7b is a rendering of handwriting with a fine brush corresponding to different ⁇ according to the embodiment of the present invention.
  • Figure 8 is a schematic flowchart 2 of determining the handwriting width of the interpolation point position according to the embodiment of the present invention.
  • Figure 9 is a schematic flowchart of determining the adjustment coefficient corresponding to the interpolation point according to the embodiment of the present invention.
  • Figure 10 is a schematic flow chart 2 of a handwriting generation method according to an embodiment of the present invention.
  • Figure 11 is a schematic diagram of the discrete effect of the embodiment of the present invention.
  • Figure 12 is a schematic flowchart of determining the position of a discrete point corresponding to an interpolation point according to an embodiment of the present invention
  • Figure 13 is a schematic diagram of determining the position of discrete points according to an embodiment of the present invention.
  • Figure 14 is a schematic diagram of handwriting effects corresponding to different rotation angles ⁇ in the pencil shape according to the embodiment of the present invention.
  • Figure 15 is a schematic diagram of the handwriting effects of various pen shapes according to the embodiment of the present invention.
  • Figure 16 is a schematic structural diagram of a handwriting generation device according to an embodiment of the present invention.
  • Figure 17 is a schematic second structural diagram of a handwriting generation device according to an embodiment of the present invention.
  • Embodiments of the present invention provide a method for generating handwriting.
  • the handwriting includes at least one handwriting segment formed using a brush.
  • the handwriting segment may be a touch track of a user using a brush on a touch screen of a terminal device.
  • the steps to generate each handwriting segment include:
  • Step 1 Obtain brush parameters.
  • the brush parameters are determined according to the pen shape parameters selected by the user, or the brush parameters are the brush parameters set by the user.
  • the brush parameters at least include the shape or pattern of the brush element.
  • the brush parameters can be set by the user.
  • the mapping relationship between the pen shape parameters and the brush parameters can be set in advance.
  • the corresponding brush parameters can be determined according to the pen shape parameters selected by the user.
  • a custom brush library can be established in advance, and the user selects brush parameters in the brush library.
  • the brush parameters can also be set in the form of a vector image uploaded by the user.
  • the brush element refers to the smallest display unit of the brush.
  • the shape of the brush element can be a circle, a four-pointed star, a cross, a gear shape, etc.
  • the pattern of the brush element can be a user-defined pattern. For example, butterfly patterns, flower patterns, etc.
  • Step 2 Obtain the sampling points of the handwriting trajectory, and generate the handwriting trajectory curve based on the sampling points.
  • the handwriting trajectory is the trajectory of one trajectory segment in the handwriting segment.
  • the handwriting trajectory formed by using a brush is sparsely sampled to obtain sampling points, and a Bezier curve algorithm is used to generate a handwriting trajectory curve based on the sampling points.
  • the handwriting trajectory curve can also be a preset trajectory curve for handwriting smoothing processing, such as a Bezier curve; however, in the specific handwriting drawing process, sampling points need to be obtained to obtain the specific handwriting trajectory.
  • Curve for example, a specific Bezier curve can be generated based on the acquired sampling points as control points of the Bezier curve; but it should be noted that the specific Bezier curve generated does not have to be displayed on the screen, but Used for subsequent calculation of interpolation points.
  • Bezier curves are widely used in graphic design and path planning.
  • the shape of a Bezier curve is determined by control points.
  • n control points generate a Bezier curve of order (n-1).
  • Bezier curves can be generated recursively. Er curve.
  • the second-order Bezier curve has three non-collinear control points P0, P1, and P2.
  • the formula of the second-order Bezier curve is formula (1):
  • C 2 is P0
  • t is the parameter ratio of the Bezier curve, t ⁇ [0,1].
  • the second-order Bezier curve algorithm is used as an example to generate a handwriting trajectory curve. Therefore, three sampling points are used as control points.
  • obtaining the sampling points of the handwriting trajectory and generating the handwriting trajectory curve according to the Bezier curve algorithm includes: obtaining three sampling points of the handwriting trajectory, and using the Bezier curve algorithm to generate the handwriting based on the three sampling points.
  • the first handwriting trajectory curve is a handwriting trajectory curve generated using the Bezier curve algorithm based on the three sampling points of the first group.
  • the first included angle is with the middle sampling point of the first group as the vertex and the center phase of the first group.
  • the line connecting two adjacent sampling points is the angle formed by the sides.
  • the second handwriting trajectory curve is a handwriting trajectory curve generated using the Bezier curve algorithm based on the three sampling points of the second group.
  • the second included angle is with the middle sampling point of the second group as the vertex and the middle sampling point of the second group.
  • the line connecting two adjacent sampling points is the angle formed by the sides.
  • the three sampling points are P0, P1, and P2.
  • P1 as the vertex
  • P0P1 and P2P1 as the sides
  • an included angle is formed.
  • the larger the included angle the greater the second-order Bezier curve.
  • the longer the arc length of the Er curve the greater the number of interpolation points selected along that arc length.
  • Step 3 Determine the position of the interpolation point on the handwriting trajectory curve, where the arc lengths between any two adjacent interpolation points on the handwriting trajectory curve are the same.
  • an iterative algorithm can be used to perform equal arc length interpolation on the handwriting trajectory curve. After interpolation, the arc lengths between two adjacent interpolation points on the handwriting trajectory curve are the same. It should be noted that the same arc length mentioned here can be understood as the arc length ⁇ between the interpolation points is basically the same. Considering that absolute equality is an ideal state, and the subsequent arc length calculation involves approximation and arc length convergence As well as the iterative calculation method, the equal arc length interpolation mentioned here is not absolutely equal arc length, but the error of the arc length is within a certain range. In some embodiments, this error range may be 20% or 30%.
  • the arc length between two adjacent interpolation points on the handwriting trajectory curve is ⁇ .
  • the arc length ⁇ between the interpolation points is the arc length between the first interpolation point and the first sampling point on the handwriting trajectory curve. .
  • equal arc length interpolation is performed on the handwriting trajectory curve to obtain the position of each interpolation point.
  • each interpolation point is evenly distributed on the entire handwriting trajectory curve.
  • the equal arc length interpolation method can avoid the overlap of multiple interpolation points at the corners of the handwriting trajectory curve when the curvature radius is small. The authenticity of the handwriting generated based on the brush parameters and the handwriting width at the interpolation point position is better, thereby improving Presentation effect.
  • Step 4 Determine the handwriting width at the position of the interpolation point according to the brush parameters, and generate handwriting corresponding to the handwriting trajectory curve according to the brush parameters and the handwriting width.
  • the brush parameters are different, and accordingly the width of the handwriting formed by the brush is also different.
  • the handwriting width at each interpolation point position in the handwriting trajectory curve is determined based on the brush parameters, and the handwriting is generated based on the brush parameters and handwriting width, thereby realizing the presentation of handwriting with user-defined effects.
  • Different types of brush parameters correspond to different handwriting widths, and the resulting handwriting effects are also different.
  • the brush parameters are determined by the pen shape parameters selected by the user or selected by the user. After the handwriting trajectory curve is generated and the interpolation point position in the handwriting trajectory curve is determined, the obtained interpolation point is determined according to the brush parameters.
  • the handwriting width at the position and generates handwriting corresponding to the handwriting trajectory curve based on the brush parameters and the handwriting width at the interpolation point position.
  • the handwriting has line width and user-defined personalized handwriting effects, which can meet user customization needs.
  • the brush parameters may also include at least one of the following: the spacing of the brush elements, the diameter of the brush elements, and the rotation angle ⁇ of the brush elements.
  • the pen shape parameters include a first type of pen shape parameter and a second type of pen shape parameter
  • the first type of pen shape parameter includes a first subtype of pen shape parameter and a second subtype of pen shape parameter.
  • the pen shape parameters of the first subtype are thick brushes
  • the pen shape parameters of the second subtype are fine brushes
  • the pen shape parameters of the second type may include hard pens, pencils, markers, etc.
  • Figure 3 provides the brush parameters and writing effects under various pen shape parameters.
  • the spacing T of the brush elements is related to the diameter d of the brush elements.
  • the maximum value of the spacing T of the brush elements is based on the brush
  • the diameter d and pen shape parameters of the element are determined. For example, for hard pens, markers, thick brushes, and fine brushes, the spacing between brush elements is T ⁇ 0.1d. For pencil shapes, the spacing between brush elements is T ⁇ d.
  • the handwriting width corresponding to the first type of pen shape parameters such as hard pens, pencils, markers, etc. always remains unchanged.
  • the handwriting width of thick brush pens decreases as the writing speed increases
  • the writing width of fine brush pens i.e., the second sub-type of pen shape parameters
  • the stroke width of the subtype's pen shape parameter increases with writing speed.
  • the handwriting width of the handwriting in the prior art does not change and cannot reflect the characteristics of the pen shape.
  • the writing speed is relatively slow in the starting stage and the bending position of the stroke.
  • the handwriting width at the corresponding position is wider, and the writing speed is relatively high during the writing process, while the handwriting width at the corresponding position is narrow, which can reflect the pen shape characteristics of a thick brush.
  • the handwriting width of the handwriting in the prior art remains unchanged and cannot reflect the characteristics of the pen shape.
  • the writing speed is faster at positions A and C, and the handwriting is The width is wider, the writing speed at position B is slower, and the handwriting width is narrower, which can reflect the pen shape characteristics of a fine brush.
  • handwriting effect parameters can also be superimposed at the interpolation point position.
  • the handwriting effect parameters can include color, transparency, etc. It should be noted that for the pen shape of a marker, transparency must be superimposed to form handwriting with a marker effect.
  • determining the position of the interpolation point on the handwriting trajectory curve includes the following steps: determining the position of the interpolation point on the handwriting trajectory curve according to the diameter of the brush element and the spacing of the brush elements.
  • the arc length ⁇ between the interpolation points is determined, and the position of the interpolation point on the handwriting trajectory curve is determined based on the arc length ⁇ between the interpolation points, where the arc length ⁇ between the interpolation points can be based on the diameter of the brush element.
  • the spacing between brush elements is determined.
  • the arc length ⁇ between interpolation points can be determined by formula (2):
  • M is the coefficient and d is the diameter of the brush element.
  • the coefficient M is determined according to the spacing T of the brush elements. If the spacing T of the brush elements is smaller, the coefficient M is smaller; if the spacing T of the brush elements is larger, the coefficient M is larger.
  • determining the handwriting width at the position of the interpolation point according to the brush parameters includes the following steps:
  • Step 41 Determine the position of the first interpolation point, the position of at least one intermediate interpolation point, and the position of the last interpolation point on the handwriting trajectory curve.
  • the handwritten trajectory curve as a second-order Bezier curve there is one intermediate interpolation point, and the positions of the three interpolation points are determined in this step.
  • the first interpolation point M0, the middle interpolation point M1 and the last interpolation point M2 on the handwriting trajectory curve are determined, among which the position of the first interpolation point M0 is (x0, y0), the position of the middle interpolation point M1 is (x1, y1), and the position of the last interpolation point M2 is (x2, y2).
  • Step 42 Determine the handwriting width at the first interpolation point position, the handwriting width at each intermediate interpolation point position, and the handwriting width at the last interpolation point position.
  • the handwriting width D0 at the first interpolation point M0, the handwriting width D1 at the middle interpolation point M1, and the handwriting width D2 at the last interpolation point M2 are determined respectively.
  • Step 43 through interpolation, determine the handwriting width at each interpolation point between the first interpolation point and the first intermediate interpolation point based on the handwriting width at the first interpolation point and the first intermediate interpolation point, and Based on the handwriting width at the last intermediate interpolation point position and the handwriting width at the last interpolation point position, determine the handwriting width at each interpolation point position between the last intermediate interpolation point and the last interpolation point.
  • interpolation is used to determine the handwriting width at each interpolation point position between the interpolation points corresponding to two adjacent handwriting widths. That is to say, the entire handwriting trajectory curve is divided into two segments using the first interpolation point M0, the middle interpolation point M1 and the last interpolation point M2, namely the handwriting trajectory curve segment M0M1 and the handwriting trajectory curve segment M1M2, respectively at M0M1 and M1M2.
  • the handwriting width of each interpolation point position between M0 and M1 and the handwriting width of each interpolation point position between M1 and M2 are determined by interpolation.
  • step 41 it is determined in step 41 that there are multiple intermediate interpolation points M1x between the first interpolation point M0 and the last interpolation point M2, and the handwriting width D1x at the position of each intermediate interpolation point M1x is determined in step 42, In this step, it is also necessary to determine the handwriting width at each interpolation point position between the two adjacent intermediate interpolation points M1 (x-1) and M1 x through interpolation.
  • linear interpolation is used to determine the handwriting width of each interpolation point between the first interpolation point and the first intermediate interpolation point and the handwriting width of each interpolation point between the last intermediate interpolation point and the last interpolation point.
  • Handwriting width is used to determine the handwriting width at each interpolation point in the middle of the handwriting trajectory curve.
  • the thick brush is Adjust the handwriting width of the thick and fine brushes, and limit the handwriting widths of the thick and fine brushes to a certain value range.
  • the handwriting width at the first interpolation point position determines the handwriting width at each interpolation point position between the first interpolation point and the first intermediate interpolation point, and according to the order of each intermediate interpolation point and each
  • the handwriting width at the middle interpolation point position determines the handwriting width at each interpolation point position between two adjacent middle interpolation points, and determines the last middle interpolation point position based on the handwriting width at the last middle interpolation point position and the handwriting width at the last interpolation point position.
  • the handwriting generation method also includes the following steps:
  • Step 42' determine the numerical range of the handwriting width according to the first type of pen shape parameters, the preset standard width and the preset speed change weight.
  • the first type of pen shape parameters includes the first subtype of pen shape parameters (thick brush) and the second subtype of pen shape parameters (fine brush).
  • the numerical range of the handwriting width corresponding to the thick brush is the same as the numerical range of the handwriting width corresponding to the fine brush. Differently, the numerical range is determined based on the preset standard width D and the preset speed change weight ⁇ .
  • Step 43' within the numerical range, determine the handwriting width at the first interpolation point position, the handwriting width at each intermediate interpolation point position, and the handwriting width at the last interpolation point position.
  • the width of the handwriting that exceeds the value range will be adjusted to within the value range. That is to say, the handwriting width smaller than the lower limit of the numerical range is adjusted to the lower limit of the numerical range, and the handwriting width greater than the upper limit of the numerical range is adjusted to the upper limit of the numerical range.
  • the speed change weight ⁇ is less than 1 and greater than 0; if the first stroke parameter is a stroke parameter of the second subtype (That is, fine brush), then the speed change weight ⁇ is less than 0 and greater than -1. Therefore, the numerical range of the handwriting width of the first subtype of the pen shape parameter (i.e., the thick brush) is [(1- ⁇ )*D, D], and the numerical range of the handwriting width of the second subtype of the pen shape parameter (i.e., the fine brush) The range is [(1+ ⁇ )*D, D].
  • Table 1 The relevant parameter settings of coarse and fine brushes are shown in Table 1:
  • Figure 7a shows the effect of thick brush handwriting corresponding to different ⁇ .
  • the greater the absolute value of the speed change weight ⁇ the smaller the minimum handwriting width, and the more obvious the change in handwriting width.
  • Figure 7b shows the effect of fine-brush handwriting corresponding to different ⁇ .
  • the greater the absolute value of the speed change weight ⁇ the smaller the minimum handwriting width, and the more obvious the change in handwriting width.
  • the steps to determine the handwriting width at the interpolation point include:
  • Step 81 Determine the adjustment coefficient corresponding to the interpolation point.
  • the interpolation point mentioned in this step is one of the first interpolation point M0, each intermediate interpolation point M1x, and the last interpolation point M2. Different interpolation points have different adjustment coefficients.
  • Step 82 Determine the handwriting width at the interpolation point position based on the adjustment coefficient and the handwriting width at the previous interpolation point position of the interpolation point.
  • the adjustment coefficient of the current interpolation point is used to adjust the handwriting width at the previous interpolation point position to obtain the handwriting width at the current interpolation point position.
  • the previous interpolation point is the first interpolation point M0; if the current interpolation point is the last interpolation point M2, then the intermediate interpolation point is Intermediate interpolation point M1.
  • the handwriting width at the interpolation point position can be calculated according to formula (3):
  • D t is the handwriting width at the interpolation point position
  • D t-1 is the handwriting width at the previous interpolation point position of the interpolation point
  • k t is the adjustment coefficient corresponding to the interpolation point.
  • determining the adjustment coefficient corresponding to the interpolation point includes the following steps:
  • Step 181 Calculate the writing speed of the interpolation point based on the writing stage of the handwriting trajectory curve and the position of the interpolation point in the handwriting trajectory curve.
  • the writing stage of the handwriting trajectory curve includes the following four stages: stage 1 is the starting stage, stage 2 is the finishing stage, stage 3 is the stage including starting and finishing, and stage 0 is the intermediate stage, which does not include starting. It does not include collecting pens.
  • stage 1 is the starting stage
  • stage 2 is the finishing stage
  • stage 3 is the stage including starting and finishing
  • stage 0 is the intermediate stage, which does not include starting. It does not include collecting pens.
  • stage 1 is the starting stage
  • stage 2 is the finishing stage
  • stage 3 is the stage including starting and finishing
  • stage 0 is the intermediate stage, which does not include starting. It does not include collecting pens.
  • stage 0 is the intermediate stage, which does not include starting. It does not include collecting pens.
  • the position of the interpolation point in the handwriting trajectory curve refers to whether the interpolation point is the first interpolation point in the handwriting trajectory curve.
  • Step 182 Calculate the adjustment coefficient corresponding to the interpolation point based on the speed change weight ⁇ , the preset reference writing speed v' and the writing speed of the interpolation point.
  • the handwriting width D t at the interpolation point position changes with the writing speed, and the reference writing speed is v'.
  • the current handwriting width D t will become thinner, that is, the handwriting D t-1 at the previous interpolation point position is multiplied by the adjustment coefficient k t , and k t ⁇ 1, get the current handwriting width D t .
  • the current handwriting width D t will become thicker. That is to say, the handwriting D t-1 at the previous interpolation point position is multiplied by the adjustment coefficient k t , and kt >1, get the current handwriting width D t .
  • the adjustment coefficient is inversely proportional to the value of the exponential function of the natural number e. Since the exponential function of the natural number e has the above-mentioned changing characteristics of the adjustment coefficient kt, when the independent variable of the exponential function is a positive number, the value of the exponential function is greater than 1 and the value of kt is less than 1. When the independent variable of the exponential function is a negative number, the value of the exponential function is less than 1 and the value of kt is greater than 1. Therefore, the calculation formula (4) of the adjustment coefficient kt corresponding to the interpolation point is:
  • vt is the writing speed of the interpolation point
  • v' is the preset reference writing speed
  • is the speed change weight, when the pen shape parameter is a thick brush, 0 ⁇ 1, when the pen shape parameter is a fine brush, -1 ⁇ 0.
  • the absolute value of ⁇ is used to control the rate of change of the adjustment coefficient kt. The greater the absolute value of ⁇ , the more drastic the change in the adjustment coefficient kt, and accordingly, the change in the handwriting width is more obvious; the smaller the absolute value of ⁇ , the more drastic the change in the adjustment coefficient kt. The slower, correspondingly, the smaller the change in handwriting width.
  • the handwriting width D t at the interpolation point position changes with the writing speed, and the reference writing speed is v'.
  • the current writing speed vt > the reference writing speed v' the current handwriting width D t will become thicker; when the current writing speed vt ⁇ the reference writing speed v', the current handwriting width D t will become thinner.
  • the calculation formula of the adjustment coefficient kt corresponding to the interpolation point is also formula (4), except that the value of the speed change weight ⁇ is -1 ⁇ 0.
  • calculating the writing speed of the interpolation point according to the writing stage of the handwriting trajectory curve and the position of the interpolation point in the handwriting trajectory curve includes:
  • the writing speed of the interpolation point is calculated based on the position and time of the interpolation point and the position and time of the previous interpolation point. That is to say, the writing speed of the middle interpolation point and the last interpolation point in the handwriting trajectory curve has nothing to do with the writing stage of the handwriting trajectory curve to which the interpolation point belongs, but is based on the sum of the positions of the interpolation point and its previous interpolation point. Calculate the writing speed of this interpolation point at all times.
  • the interpolation point In response to the handwriting trajectory curve being in the closing stage (stage 2) or the intermediate stage (stage 0) and the interpolation point is the first interpolation point in the handwriting trajectory curve, according to the position and time of the interpolation point and the middle interpolation point of the previous trajectory segment The position and time are used to calculate the writing speed of the interpolation point. That is to say, the first interpolation point in the handwriting trajectory curve in the non-start phase coincides with the last interpolation point in the previous trajectory segment, and its writing speed can be calculated according to the calculation method of the writing speed of the last interpolation point in the previous trajectory segment.
  • the time of the interpolation point is based on the sampling time of the sampling point corresponding to the interpolation point.
  • the sampling times t0, t1, and t2 corresponding to the three sampling points P0, P1, and P2 are respectively used as the time of the first interpolation point M0 in the handwriting trajectory curve and the handwriting trajectory curve.
  • determining the handwriting width at the interpolation point position based on the adjustment coefficient and the handwriting width at the previous interpolation point position of the interpolation point includes the following steps: in response to the handwriting trajectory curve being in the starting stage ( Stage 1) or the stage including the start and end of the pen (stage 3) and the interpolation point is the first interpolation point in the handwriting trajectory curve, the handwriting width at the interpolation point position is determined according to the adjustment coefficient and the initial handwriting width Dlast, where the initial handwriting width Dlast Determined based on the first type of pen shape parameters.
  • the handwriting width at the previous interpolation point position of the interpolation point D t- 1 initial handwriting width Dlast, and the initial handwriting width Dlast is different for the stroke shape of a thick brush pen and that of a fine brush pen.
  • the initial handwriting width of the thick brush pen > the initial handwriting width of the fine brush pen.
  • the initial handwriting width Dlast is the standard width D; if the pen shape parameter is a thin brush, the initial handwriting width Dlast is (1+ ⁇ ) times the standard width Width D.
  • the initial handwriting width Dlast corresponding to different speed change weights ⁇ is the same, which is the standard width D.
  • the initial handwriting width Dlast corresponding to different speed change weights ⁇ is different. The greater the absolute value of the speed change weight ⁇ , the smaller the initial handwriting width Dlast.
  • the handwriting width at each interpolation point position may not be determined by linear interpolation, but in accordance with the order of each interpolation point on the handwriting trajectory curve, according to the above formula (3) and formula (4), adjust the handwriting width of the previous interpolation point in turn, and calculate the handwriting width of the current interpolation point.
  • this method of calculating the handwriting width at each interpolation point position is more complex and time-consuming than calculating the handwriting width at the interpolation point position using linear interpolation.
  • the collection times of the three sampling points P0, P1, and P2 of this sampling are t0, t1, and t2 respectively.
  • the above three sampling points P0, P1, and P2 are used to generate the handwriting trajectory curve in Figure 2b, and Determine the position of each interpolation point on the handwriting trajectory curve.
  • the position of the first interpolation point M0 is (x0, y0)
  • the position of the middle interpolation point M1 is (x1, y1)
  • the position of the last interpolation point M2 is (x2, y2).
  • the speed of the first interpolation point M0 is v0
  • (x 1 ', y 1 ') is the position coordinate of the middle interpolation point of the previous trajectory segment
  • (x 2 ', y 2 ') is the position coordinate of the last interpolation point of the previous trajectory segment, and is also the current trajectory
  • the speed of the intermediate interpolation point M1 is v1
  • the speed of the last interpolation point M2 is v2
  • the adjustment coefficient k0 of the first interpolation point M0 and the intermediate interpolation point are respectively calculated according to formula (4)
  • Linear interpolation is performed based on the handwriting width D0 of the first interpolation point M0 and the handwriting width D1 of the intermediate interpolation point M1 to obtain the handwriting width of each interpolation point between the first interpolation point M0 and the intermediate interpolation point M1.
  • the handwriting width D1 at the position and the handwriting width D2 at the last interpolation point M2 are linearly interpolated to obtain the handwriting width at each interpolation point between the intermediate interpolation point M1 and the last interpolation point M2.
  • the brush parameters when the brush parameters are brush parameters set by the user, the brush parameters may also include a dispersion S.
  • the dispersion S is used to reflect the degree to which the position of the interpolation point deviates from the handwriting trajectory curve.
  • the handwriting generation method may also include the following steps:
  • Step 3’ Determine the position of the discrete point P’n corresponding to the interpolation point Pn according to the degree of dispersion S, and update the position of the interpolation point Pn according to the position of the discrete point P’n.
  • Figure 11 shows the effect of the interpolation point deviating from the handwriting trajectory curve under a certain degree of dispersion.
  • the points on the handwriting trajectory curve are the determined interpolation points, and each point outside the handwriting trajectory curve is the discrete point corresponding to the corresponding interpolation point.
  • step 4 after the position of the discrete point P'n is determined, the position of the discrete point P'n is used to update the position of the interpolation point Pn.
  • step 4 handwriting is generated based on the brush parameters and the handwriting width at the interpolation point position corresponding to the discrete point P’n. In this way, the obtained handwriting is closer to the real handwriting effect.
  • the step of determining the position of the discrete point corresponding to the interpolation point includes:
  • Step 31' calculate the first slope Kn of the line connecting the interpolation point Pn and the next interpolation point Pn+1 of the interpolation point, and calculate the second slope K'n of the first straight line based on the first slope Kn.
  • the first The straight line is perpendicular to the connecting line and passes through the interpolation point Pn.
  • the fourth interpolation point is Pn+1, and the position of the interpolation point Pn is (x n , y n ),
  • the position of the interpolation point Pn+1 is (x n+1 , y n+1 ).
  • the slope of the line connecting the interpolation point Pn and the interpolation point Pn+1 is the first slope Kn
  • the first straight line passing through the interpolation point Pn is perpendicular to the connecting line
  • the slope of the first straight line is the second slope K'n
  • Step 32' Calculate the discrete distance dn of the interpolation point Pn according to the discrete distance adjustment parameter and the dispersion degree S, and the discrete distance adjustment parameter changes periodically.
  • the discrete distance adjustment parameter is determined based on the ordering of the interpolation points Pn on the handwriting trajectory curve.
  • the order n of the interpolation point Pn on the handwriting trajectory curve refers to the interpolation point of the interpolation point Pn on the handwriting trajectory curve.
  • a pseudo-random angle ⁇ is randomly selected in the range of [0, 2 ⁇ ], and based on the trigonometric function of ⁇ and the ordering of the interpolation point Pn on the handwritten trajectory curve, the discrete distance adjustment parameter is calculated.
  • the parameter is sin(n* ⁇ ).
  • the sine function is used as an example for explanation. It should be noted that other trigonometric functions can also be used to calculate the discrete distance dn.
  • the discrete distance dn refers to the distance between the discrete point P’n and the interpolation point Pn.
  • the discrete distance can be calculated according to the following formula (5):
  • n represents the sequence number of the interpolation point on the handwriting trajectory curve.
  • Step 33’ determine the position of the discrete point P’n corresponding to the interpolation point Pn based on the discrete distance dn, the position of the interpolation point Pn and the second slope K’n, where the discrete point P’n is located on the first straight line.
  • the position of the discrete point P'n (x' n , y' n ) can be obtained by solving the system of equations (6).
  • the system of equations (6) is as follows:
  • the brush parameters may also include the rotation angle ⁇ of the brush element.
  • the rotation angle ⁇ of the brush element is the angle difference between two adjacent brush elements, and any two adjacent brush elements The angle difference between them is the same, ⁇ /4 ⁇ 3 ⁇ /4.
  • the brush elements of the pencil are rotated to simulate the effect of an irregular pencil handwriting trajectory.
  • Figure 14 is a schematic diagram of handwriting effects corresponding to different rotation angles ⁇ in the pencil shape. As shown in Figure 14, each brush element rotates counterclockwise in sequence.
  • T d
  • the brush parameters may also include the initial rotation angle ⁇ 0 of the brush element.
  • the initial rotation angle ⁇ 0 of the brush element is the rotation angle of the brush element at the first interpolation point position in the handwriting trajectory curve. That is to say, a pseudo-random angle ⁇ 0 is randomly selected as the rotation angle of the first interpolation point position.
  • the initial rotation angle ⁇ 0 may also be 0, that is, the first brush element does not rotate, and each brush element after the second brush element rotates according to the rotation angle ⁇ .
  • equal arc length interpolation is used to select interpolation points, and handwriting is generated according to the brush parameters and the handwriting width at the interpolation point position, which can achieve personalized and diversified handwriting effects.
  • the left side of Figure 15 shows the handwriting effects of five preset pen shapes.
  • the right side of Figure 15 shows the custom brush parameters.
  • the user can select the shape or pattern of the brush elements, the spacing of the brush elements, the diameter of the brush elements, the rotation angle, dispersion, and speed change of the brush elements as needed. Weights and other parameters can be used to customize personalized handwriting effects.
  • the handwriting corresponding to various pen shapes can truly restore the corresponding pen shape characteristics. For thick and fine brush pen shapes, the handwriting width can also change with the change of writing speed, and the display effect is extremely realistic.
  • the handwriting generation method provided by the embodiment of the present invention selects interpolation points according to equal arc length interpolation, and performs map painting at the interpolation point positions, which can simulate handwriting styles of various pen shapes on the drawing board.
  • Embodiments of the present invention can be applied in the fields of painting screens and electronic blackboards, and can also be applied in the field of large-size (generally more than 50 inches) intelligent displays such as conference whiteboards and teaching whiteboards.
  • the handwriting generation method provided by the embodiment of the present invention can not only present handwriting in a variety of preset stroke shapes, but also select corresponding brush parameters from the system's customized library to achieve user-defined effects. Upload the vector image yourself, and then customize the brush design, design the width of the brush elements, the spacing of the brush elements, the rotation angle, discreteness, speed transformation weight, etc. of the brush elements.
  • the handwriting generation scheme provided by the embodiment of the present invention can greatly simplify the handwriting generation process, the steps are simple to implement, and can meet user customization needs.
  • the handwriting generation device includes a parameter acquisition module 101, a trajectory generation module 102, an interpolation point determination module 103, a handwriting width
  • the determination module 104 and the handwriting generation module 105, the parameter acquisition module 101 is used to obtain the brush parameters, the brush parameters are determined according to the stroke parameters selected by the user, or the brush parameters are the brush parameters set by the user,
  • the brush parameters at least include the shape or pattern of the brush elements.
  • the trajectory generation module 102 is configured to obtain sampling points of the handwriting trajectory, and generate a handwriting trajectory curve according to the sampling points, where the handwriting trajectory is the trajectory of one trajectory segment among the handwriting segments.
  • the interpolation point determination module 103 is used to determine the position of the interpolation point on the handwriting trajectory curve, where the arc lengths between any two adjacent interpolation points on the handwriting trajectory curve are the same.
  • the handwriting width determination module 104 is configured to determine the handwriting width at the position of the interpolation point according to the brush parameters.
  • the handwriting generation module 105 is configured to generate handwriting corresponding to the handwriting trajectory curve according to the brush parameters and the handwriting width.
  • the pen shape parameter is a first type of pen shape parameter; the handwriting width determination module 104 is used to determine the position of the first interpolation point, the position of at least one intermediate interpolation point and the last one on the handwriting trajectory curve.
  • the position of the interpolation point determine the handwriting width at the first interpolation point position, the handwriting width at each of the intermediate interpolation point positions, and the handwriting width at the last interpolation point position; through interpolation, according to the first interpolation point position
  • the handwriting width and the handwriting width at the first intermediate interpolation point position determine the handwriting width at each interpolation point position between the first interpolation point and the first intermediate interpolation point, and the handwriting width according to the last intermediate interpolation point position.
  • the handwriting width and the handwriting width at the last interpolation point position determine the handwriting width at each interpolation point position between the last intermediate interpolation point and the last interpolation point.
  • the handwriting width determination module 104 is configured to determine, through linear interpolation, the handwriting width at each interpolation point position between the first interpolation point and the first intermediate interpolation point, and the handwriting width of two adjacent interpolation points. The handwriting width at each interpolation point position between the intermediate interpolation points and the handwriting width at each interpolation point position between the last intermediate interpolation point and the last interpolation point.
  • the handwriting width determination module 104 is further configured to determine the handwriting width at the first interpolation point position, the handwriting width at each of the intermediate interpolation point positions, and the handwriting width at the last interpolation point position. , through interpolation, determine each interpolation value between the first interpolation point and the first intermediate interpolation point according to the handwriting width at the first interpolation point position and the handwriting width at the first intermediate interpolation point position.
  • the handwriting width at each point position, and the handwriting width at each interpolation point position between two adjacent intermediate interpolation points is determined according to the order of each intermediate interpolation point and the handwriting width at each said intermediate interpolation point position, and according to the last The handwriting width at an intermediate interpolation point position and the handwriting width at the last interpolation point position, before determining the handwriting width at each interpolation point position between the last intermediate interpolation point and the last interpolation point, according to the first A type of pen shape parameter, a preset standard width D and a preset speed change weight ⁇ determine the numerical range of the handwriting width; within the numerical range, determine the handwriting width at the first interpolation point position, each of the intermediate The handwriting width at the interpolation point position and the handwriting width at the last interpolation point position.
  • the first type of stroke parameter includes a first subtype of stroke parameter and a second subtype of stroke parameter. If the first stroke parameter is a first subtype of stroke parameter, then the The speed change weight ⁇ is less than 1 and greater than 0; if the first stroke parameter is a stroke parameter of the second subtype, the speed change weight ⁇ is less than 0 and greater than -1;
  • the numerical range of the handwriting width of the stroke parameter of the first subtype is [(1- ⁇ )*D, D]
  • the numerical range of the stroke width of the stroke parameter of the second subtype is [(1+ ⁇ ) *D,D].
  • the handwriting width determination module 104 is configured to determine the interpolation point position for one of the first interpolation point, each of the intermediate interpolation points, and the last interpolation point in the following manner.
  • the handwriting width determine the adjustment coefficient corresponding to the interpolation point; determine the handwriting width at the interpolation point position based on the adjustment coefficient and the handwriting width at the previous interpolation point position of the interpolation point.
  • the handwriting width determination module 104 is configured to calculate the writing speed of the interpolation point according to the writing stage of the handwriting trajectory curve and the position of the interpolation point in the handwriting trajectory curve; according to The adjustment coefficient corresponding to the interpolation point is calculated using the speed change weight, the preset reference writing speed and the writing speed of the interpolation point.
  • the handwriting width determination module 104 is configured to, in response to the handwriting trajectory curve being in a writing starting stage or including a writing starting and ending stage and the interpolation point being the first interpolation point in the handwriting trajectory curve, The writing speed of the above interpolation point is zero.
  • the handwriting width determination module 104 is configured to respond to the handwriting trajectory curve being in a starting stage or a stage including starting and closing stages or in a closing stage or in an intermediate stage and the interpolation point is the For a non-first interpolation point in the handwriting trajectory curve, the writing speed of the interpolation point is calculated based on the position and time of the interpolation point and the position and time of the previous interpolation point.
  • the handwriting width determination module 104 is configured to, in response to the handwriting trajectory curve being in the closing stage or the intermediate stage and the interpolation point being the first interpolation point in the handwriting trajectory curve, based on the interpolation point The writing speed of the interpolation point is calculated based on the position and time of the intermediate interpolation point of the previous trajectory segment.
  • the time of the interpolation point is based on the sampling time of the sampling point corresponding to the interpolation point.
  • the handwriting width determination module 104 is configured to, in response to the handwriting trajectory curve being in a writing starting stage or including a writing starting and ending stage and the interpolation point being the first interpolation point in the handwriting trajectory curve, according to The adjustment coefficient and the initial handwriting width determine the handwriting width at the interpolation point position, and the initial handwriting width is determined according to the first type of stroke parameters.
  • the brush parameters when the brush parameters are brush parameters set by the user, the brush parameters include a dispersion S.
  • the handwriting generation device also includes an interpolation point position update module 106.
  • the interpolation point position update module 106 is used to, after the interpolation point determination module 103 determines the position of the interpolation point on the handwriting trajectory curve, Before the handwriting generation module 105 generates handwriting corresponding to the handwriting trajectory curve according to the brush parameters and the handwriting width, the position of the discrete point P'n corresponding to the interpolation point Pn is determined based on the discreteness S, And update the position of the interpolation point Pn according to the position of the discrete point P'n.
  • the interpolation point position update module 106 is configured to, for an interpolation point, determine the position of the discrete point corresponding to the interpolation point in the following manner: calculate the interpolation point Pn and the next interpolation value of the interpolation point The first slope Kn of the connecting line between points Pn+1, and the second slope K'n of the first straight line is calculated based on the first slope Kn, the first straight line is perpendicular to the connecting line and has gone through the interpolation point Pn; calculate the discrete distance dn of the interpolation point Pn according to the discrete distance adjustment parameter and the dispersion degree S, and the discrete distance adjustment parameter changes periodically; according to the discrete distance dn, the position of the interpolation point Pn and The second slope K'n determines the position of the discrete point P'n corresponding to the interpolation point Pn, where the discrete point P'n is located on the first straight line.
  • the discrete distance adjustment parameter is determined based on the ordering of the interpolation points Pn on the handwriting trajectory curve.
  • the brush parameters also include the rotation angle ⁇ of the brush element.
  • the rotation angle ⁇ of the brush element is the angle difference between two adjacent brush elements, and any two adjacent brush elements The angle difference between brush elements is the same, ⁇ /4 ⁇ 3 ⁇ /4.
  • the brush parameters also include an initial rotation angle ⁇ 0 of the brush element.
  • the initial rotation angle ⁇ 0 of the brush element is the first interpolation point position of the brush element in the handwriting trajectory curve. of rotation angle.
  • the brush parameters further include at least one of the following: a spacing between brush elements and a diameter of a brush element; the interpolation point determination module 103 is configured to, according to the diameter of the brush element and the diameter of the brush element, The spacing of brush elements determines the position of the interpolation point on the handwriting trajectory curve.
  • the maximum value of the spacing of the brush elements is determined according to the diameter of the brush element and the pen shape parameter.
  • An embodiment of the present invention also provides a computer device.
  • the computer device includes: one or more processors and a storage device; wherein one or more programs are stored on the storage device.
  • the one or more programs are used by the above-mentioned one When executed by or multiple processors, the above one or more processors implement the handwriting generation method as provided in the foregoing embodiments.
  • Embodiments of the present invention also provide a computer-readable medium on which a computer program is stored, wherein when the computer program is executed, the handwriting generation method as provided in the foregoing embodiments is implemented.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • User Interface Of Digital Computer (AREA)
  • Processing Or Creating Images (AREA)

Abstract

本发明提供一种手写笔迹生成方法,属于计算机应用技术领域,其可解决现有的书写笔迹无法满足用户需求的问题。手写笔迹包括利用笔刷形成的至少一个笔迹段,其中,每个笔迹段通过以下方式生成:获取笔刷参数,笔刷参数根据用户选择的笔形参数确定或者为用户设定的笔刷参数;获取手写轨迹的采样点,根据采样点生成手写轨迹曲线;确定手写轨迹曲线上插值点的位置,手写轨迹曲线上任意两相邻插值点之间的弧长相同;根据笔刷参数确定插值点的位置的笔迹宽度,并根据笔刷参数和笔迹宽度生成手写笔迹。该手写笔迹具有线宽和用户自定义的个性化笔迹效果,能够满足用户自定义需求。本发明还提供一种手写笔迹生成装置、计算机设备和可读介质。

Description

手写笔迹生成方法、装置、计算机设备和可读介质 技术领域
本发明属于计算机应用技术领域,具体涉及一种手写笔迹生成方法、装置、计算机设备和可读介质。
背景技术
在智慧教育、商务办公、智能医疗等领域,电子交互白板等设备作为一种便捷的工具,对信息的交互与共享产生了极其重要的作用。但是,目前的手写笔迹生成方案无法满足用户自定义需求,设备的手写笔笔迹的生成效果制约着产品用户体验的瓶颈。
发明内容
本发明旨在至少解决现有技术中存在的技术问题之一,提供一种能够有用户自定义效果的手写笔迹生成方法、装置、计算机设备和可读介质。
第一方面,本发明实施例提供一种手写笔迹生成方法,所述手写笔迹包括利用笔刷形成的至少一个笔迹段,其中,每个笔迹段通过以下方式生成:
获取笔刷参数,所述笔刷参数根据用户选择的笔形参数确定,或者,所述笔刷参数为用户设定的笔刷参数,所述笔刷参数至少包括笔刷元素的形状或图案;
获取手写轨迹的采样点,根据所述采样点生成手写轨迹曲线,所述手写轨迹为所述笔迹段中一个轨迹段的轨迹;
确定所述手写轨迹曲线上插值点的位置,其中,所述手写轨迹曲线上任意两相邻插值点之间的弧长相同;
根据所述笔刷参数确定所述插值点的位置的笔迹宽度,并根据所述笔刷参数和所述笔迹宽度生成与所述手写轨迹曲线对应的手写笔迹。
第二方面,本发明实施例还提供一种手写笔迹生成装置,包括参数获取模块、轨迹生成模块、插值点确定模块、笔迹宽度确定模块和笔迹生成模块,所述参数获取模块用于,获取笔刷参数,所述笔刷参数根据用户选择的笔形 参数确定,或者,所述笔刷参数为用户设定的笔刷参数,所述笔刷参数至少包括笔刷元素的形状或图案;
所述轨迹生成模块用于,获取手写轨迹的采样点,根据所述采样点生成手写轨迹曲线,所述手写轨迹为所述笔迹段中一个轨迹段的轨迹;
所述插值点确定模块用于,确定所述手写轨迹曲线上插值点的位置,其中,所述手写轨迹曲线上任意两相邻插值点之间的弧长相同;
所述笔迹宽度确定模块用于,根据所述笔刷参数确定所述插值点的位置的笔迹宽度;
所述笔迹生成模块用于,根据所述笔刷参数和所述笔迹宽度生成与所述手写轨迹曲线对应的手写笔迹。
第三方面,本发明实施例还提供一种计算机设备,包括:
一个或多个处理器;
存储装置,其上存储有一个或多个程序;
当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现如前所述的手写笔迹生成方法。
第四方面,本发明实施例还提供一种计算机可读介质,其上存储有计算机程序,其中,所述程序被执行时实现如前所述的手写笔迹生成方法。
附图说明
图1为本发明实施例的手写笔迹生成方法流程示意图一;
图2a为本发明实施例的二阶贝塞尔曲线生成示意图;
图2b为本发明实施例的等弧长插值的示意图;
图3为本发明实施例的各类型笔形参数的示意图;
图4a为现有技术的手写笔迹与本发明实施例的粗毛笔手写笔迹的效果对比图;
图4b为现有技术的手写笔迹与本发明实施例的细毛笔手写笔迹的效果对比图;
图5为本发明实施例的确定插值点位置的流程示意图一;
图6为本发明实施例的调整笔迹宽度的流程示意图;
图7a为本发明实施例的不同λ对应的粗毛笔手写笔迹的效果图;
图7b为本发明实施例的不同λ对应的细毛笔手写笔迹的效果图;
图8为本发明实施例的确定插值点位置的笔迹宽度的流程示意图二;
图9为本发明实施例的确定插值点对应的调整系数的流程示意图;
图10为本发明实施例的手写笔迹生成方法流程示意图二;
图11为本发明实施例的离散效果示意图;
图12为本发明实施例的确定插值点对应的离散点位置的流程示意图;
图13为本发明实施例的确定离散点位置的示意图;
图14为本发明实施例的铅笔笔形中不同旋转角度θ对应的手写笔迹效果示意图;
图15为本发明实施例的各种笔形的手写笔迹效果示意图;
图16为本发明实施例的手写笔迹生成装置的结构示意图一;
图17为本发明实施例的手写笔迹生成装置的结构示意图二。
具体实施方式
为使本领域技术人员更好地理解本发明/实用新型的技术方案,下面结合附图和具体实施方式对本发明/实用新型作进一步详细描述。
除非另外定义,本公开使用的技术术语或者科学术语应当为本公开所属领域内具有一般技能的人士所理解的通常意义。本公开中使用的“第一”、“第二”以及类似的词语并不表示任何顺序、数量或者重要性,而只是用来区分不同的组成部分。同样,“一个”、“一”或者“该”等类似词语也不表示数量限制,而是表示存在至少一个。“包括”或者“包含”等类似的词语意指出现该词前面的元件或者物件涵盖出现在该词后面列举的元件或者物件及其等同,而不排除其他元件或者物件。“连接”或者“相连”等类似的词语并非限定于物理的或者机械的连接,而是可以包括电性的连接,不管是直接的还是间接的。“上”、“下”、“左”、“右”等仅用于表示相对位置关系,当被描述对象的绝对 位置改变后,则该相对位置关系也可能相应地改变。
本发明实施例提供一种手写笔迹生成方法,所述手写笔迹包括利用笔刷形成的至少一个笔迹段,笔迹段可以是用户利用笔刷在终端设备触控屏上的触控轨迹。如图1所示,生成每个笔迹段的步骤包括:
步骤1,获取笔刷参数,笔刷参数根据用户选择的笔形参数确定,或者,笔刷参数为用户设定的笔刷参数,笔刷参数至少包括笔刷元素的形状或图案。
笔刷参数可以由用户设定,在一些实施例中,可以预先设置笔形参数与笔刷参数的映射关系,在这种情况下,根据用户选择的笔形参数可以确定出相应的笔刷参数。在一些实施例中,可以预先建立自定义笔刷图库,由用户在笔刷图库中选择笔刷参数。在一些实施例中,也可以通过由用户上传矢量图的形式设定笔刷参数。
笔刷元素是指笔刷的最小显示单元,示例性的,笔刷元素的形状可以为圆形、四角星形、十字形,齿轮形等,笔刷元素的图案可以是用户自定义的图案,例如蝴蝶图案、花朵图案等。
步骤2,获取手写轨迹的采样点,根据采样点生成手写轨迹曲线,手写轨迹为笔迹段中一个轨迹段的轨迹。
在一些实施例中,对利用笔刷形成的手写轨迹进行稀疏采样以获取采样点,并根据采样点利用贝塞尔曲线算法生成手写轨迹曲线。需要说明的是,所述手写轨迹曲线也可以是预置的用于笔迹平滑处理的轨迹曲线,例如贝塞尔曲线;但在具体的笔迹绘制过程中,需要获取采样点才能得到具体的手写轨迹曲线,例如根据获取的采样点作为贝塞尔曲线的控制点,才能生成一条具体的贝塞尔曲线;但需要说明的是,生成的具体贝塞尔曲线并非一定要显示在屏幕上,而是用于后续插值点的计算。
贝塞尔曲线在图形设计和路径规划中应用广泛,贝塞尔曲线由控制点决定曲线形状,n个控制点生成(n-1)阶的贝塞尔曲线,可以通过递归的方式生成贝塞尔曲线。
以二阶贝塞尔曲线为例,如图2a所示,二阶贝塞尔曲线有三个不共线的控制点P0,P1,P2,二阶贝塞尔曲线公式为公式(1):
C 2(t)=(1-t) 2P 0+2t(1-t)P 1+t 2P 2                   (1)
其中,C 2即为P0”,t为贝塞尔曲线的参数比例,t∈[0,1]。
在本发明实施例中,采用二阶贝塞尔曲线算法生成手写轨迹曲线为例,因此,将三个采样点作为控制点。
在一些实施例中,所述获取手写轨迹的采样点,根据贝塞尔曲线算法生成手写轨迹曲线,包括:获取手写轨迹的三个采样点,根据三个采样点利用贝塞尔曲线算法生成手写轨迹曲线,其中,以中间的采样点为顶点且以相邻两个采样点的连线为边形成夹角,即三个采样点不共线。
在第一夹角大于第二夹角的情况下,第一手写轨迹曲线上的插值点的数量大于第二手写轨迹曲线上的插值点的数量。第一手写轨迹曲线为根据第一组的三个采样点利用贝塞尔曲线算法生成的手写轨迹曲线,第一夹角为以第一组的中间的采样点为顶点且以第一组中相邻两个采样点的连线为边形成的夹角。第二手写轨迹曲线为根据第二组的三个采样点利用贝塞尔曲线算法生成的手写轨迹曲线,第二夹角为以第二组的中间的采样点为顶点且以第二组中相邻两个采样点的连线为边形成的夹角。
结合图2a所示,针对二阶贝塞尔曲线而言,三个采样点为P0,P1,P2,以P1为顶点、P0P1和P2P1为边形成夹角,夹角越大,二阶贝塞尔曲线的弧长越长,在该弧长上选取的插值点的数量就越多。
步骤3,确定手写轨迹曲线上插值点的位置,其中,手写轨迹曲线上任意两相邻插值点之间的弧长相同。
在本发明实施例中,可以利用迭代算法对手写轨迹曲线进行等弧长插值,插值后手写轨迹曲线上相邻两插值点之间的弧长相同。需要说明的是,这里所说的弧长相同可以理解为插值点间的弧长τ基本相同,考虑到绝对的相等是一种理想的状态,并且后续的弧长计算涉及到了近似、弧长收敛以及迭代的计算方法,导致这里所说的等弧长插值并非绝对的等弧长,而是弧长的误差在一定范围之内。在一些实施例中,该误差范围可以为20%或30%。手写轨迹曲线上相邻两插值点之间的弧长为τ,对于首个插值点而言,插值点间的弧长τ为首个插值点与手写轨迹曲线上首个采样点之间的弧长。
采用贝塞尔曲线算法生成手写轨迹曲线后,在手写轨迹曲线上进行等弧长插值,得到各个插值点的位置。如图2b所示,各插值点在整个手写轨迹曲线上均匀分布。采用等弧长插值方式,可以避免曲率半径较小时手写轨迹曲线拐弯处出现多个插值点重合的情况,根据笔刷参数和插值点位置的笔迹宽度生成的手写笔迹的真实度较好,从而提高呈现效果。
步骤4,根据笔刷参数确定插值点的位置的笔迹宽度,并根据笔刷参数和笔迹宽度生成与手写轨迹曲线对应的手写笔迹。
笔刷参数不同,相应的理由该笔刷形成的手写笔迹的笔迹宽度也不同。在本步骤中,根据笔刷参数分别确定手写轨迹曲线中各个插值点位置的笔迹宽度,并根据笔刷参数和笔迹宽度生成手写笔迹,从而实现用户自定义效果的手写笔迹的呈现。不同类型的笔刷参数对应的笔迹宽度不同,由此得到的笔迹效果也不同。
在本发明实施例中,笔刷参数由用户选择的笔形参数确定或者由用户选择,在生成手写轨迹曲线并确定出手写轨迹曲线中的插值点位置之后,根据笔刷参数确定得到的插值点的位置的笔迹宽度,并根据笔刷参数和插值点位置的笔迹宽度生成与手写轨迹曲线对应的手写笔迹,该手写笔迹具有线宽和用户自定义的个性化笔迹效果,能够满足用户自定义需求。
在一些实施例中,笔刷参数还可以包括以下至少之一:笔刷元素的间距、笔刷元素的直径、笔刷元素的旋转角度θ。
在一些实施例中,笔形参数包括第一类型的笔形参数和第二类型的笔形参数,第一类型的笔形参数包括第一子类型的笔形参数和第二子类型的笔形参数。在本发明实施例中,第一子类型的笔形参数为粗毛笔,第二子类型的笔形参数为细毛笔,第二类型的笔形参数可以包括硬笔、铅笔、马克笔等。
图3提供了各种笔形参数下的笔刷参数和书写效果,如图3所示,笔刷元素的间距T与笔刷元素的直径d相关,笔刷元素的间距T的最大值根据笔刷元素的直径d和笔形参数确定。例如,对于硬笔、马克笔、粗毛笔、细毛笔笔形而言,笔刷元素的间距T<0.1d,对于铅笔笔形而言,笔刷元素的间距T<d。硬笔、铅笔、马克笔等第一类型的笔形参数对应的笔迹宽度始终不变,粗毛笔(即第一子类型的笔形参数)的笔迹宽度随书写速度增加而减小,细毛笔(即第二子类型的笔形参数)的笔迹宽度随书写速度增加而增加。
如图4a所示,现有技术中手写笔迹的笔迹宽度不变,无法体现出笔形特征,而在本发明的粗毛笔的手写笔迹中,在起笔阶段以及笔画弯折位置,书写速度相对较小,相应位置的笔迹宽度较宽,在行笔过程中书写速度相对较大,相应位置的笔迹宽度较窄,从而能够体现出粗毛笔的笔形特征。如图4b所示,现有技术中的手写笔迹的笔迹宽度不变,无法体现出笔形特征,而在本发明的细毛笔的手写笔迹中,在位置A和位置C处书写速度较快,笔 迹宽度较宽,在位置B处书写速度较慢,笔迹宽度较窄,从而能够体现出细毛笔的笔形特征。
在一些实施例中,在根据笔刷参数和笔迹宽度生成与手写轨迹曲线对应的手写笔迹的过程中,还可以在插值点位置叠加笔迹效果参数,笔迹效果参数可以包括颜色、透明度等。需要说明的是,针对马克笔的笔形,必须叠加透明度才能形成马克笔效果的手写笔迹。
在一些实施例中,所述确定手写轨迹曲线上插值点的位置(即步骤3),包括以下步骤:根据笔刷元素的直径和笔刷元素的间距确定手写轨迹曲线上插值点的位置。
在一些实施例中,确定插值点间的弧长τ,并根据插值点间的弧长τ确定手写轨迹曲线上插值点的位置,其中,插值点间的弧长τ可以根据笔刷元素的直径和笔刷元素的间距确定。
在一些实施例中,可以通过公式(2)确定插值点间的弧长τ:
τ=M*d                                          (2)
其中,M为系数,d为笔刷元素的直径。
在一些实施例中,系数M根据笔刷元素的间距T确定,若笔刷元素的间距T越小,则系数M越小;若笔刷元素的间距T越大,则系数M越大。
在一些实施例中,在笔形参数为第一类型的笔形参数的情况下,如图5所示,所述根据笔刷参数确定插值点的位置的笔迹宽度(即步骤4),包括以下步骤:
步骤41,确定手写轨迹曲线上首个插值点的位置、至少一个中间插值点的位置和最后一个插值点的位置。
在本发明实施例中,以手写轨迹曲线为二阶贝塞尔曲线为例,中间插值点为一个,在本步骤中确定三个插值点的位置。在确定出如图2b所示的手写轨迹曲线上各插值点的位置之后,确定手写轨迹曲线上首个插值点M0、中间插值点M1和最后一个插值点M2,其中首个插值点M0的位置为(x0,y0),中间插值点M1的位置为(x1,y1),最后一个插值点M2的位置为(x2,y2)。
步骤42,确定首个插值点位置的笔迹宽度、各中间插值点位置的笔迹宽度和最后一个插值点位置的笔迹宽度。
在本步骤中,分别确定首个插值点M0位置的笔迹宽度D0、中间插值点M1位置的笔迹宽度D1和最后一个插值点M2位置的笔迹宽度D2。
步骤43,通过插值的方式,根据首个插值点位置的笔迹宽度和首个中间插值点位置的笔迹宽度,确定首个插值点与首个中间插值点之间各插值点位置的笔迹宽度,以及根据最后一个中间插值点位置的笔迹宽度和最后一个插值点位置的笔迹宽度,确定最后一个中间插值点与最后一个插值点之间各插值点位置的笔迹宽度。
在本步骤中,针对步骤42中确定出的各插值点位置的笔迹宽度,采用插值方式分别确定其中相邻两个笔迹宽度对应的插值点之间的各个插值点位置的笔迹宽度。也就是说,利用上述首个插值点M0、中间插值点M1和最后一个插值点M2将整个手写轨迹曲线划分为2段,即手写轨迹曲线段M0M1和手写轨迹曲线段M1M2,分别在M0M1和M1M2上通过插值的方式确定M0到M1之间的各插值点位置的笔迹宽度以及M1到M2之间的各插值点位置的笔迹宽度。
需要说明的是,如果在步骤41中确定出首个插值点M0与最后一个插值点M2之间有多个中间插值点M1x,在步骤42中确定出各个中间插值点M1x位置的笔迹宽度D1x,则在本步骤中,还需分别通过插值方式确定相邻两个中间插值点M1 (x-1)和M1 x之间的各个插值点位置的笔迹宽度。
在一些实施例中,通过线性插值的方式,确定首个插值点与首个中间插值点之间各插值点位置的笔迹宽度和最后一个中间插值点与最后一个插值点之间各插值点位置的笔迹宽度。利用线性插值的方式确定手写轨迹曲线中间各插值点位置的笔迹宽度,可以简化算法复杂度,提高手写笔迹的生成速度。
为了避免粗毛笔和细毛笔的笔迹宽度过大导致的手写笔迹失真现象或者笔迹宽度过小导致的笔划断开现象,保证手写笔迹的真实度和完整性,在本发明实施例中,对粗毛笔和细毛笔的笔迹宽度进行调整,将粗毛笔和细毛笔的笔迹宽度限定在一定的数值范围之内。
因此,在一些实施例中,在确定首个插值点位置的笔迹宽度、各中间插值点位置的笔迹宽度和最后一个插值点位置的笔迹宽度(即步骤42)之后,在通过插值的方式,根据首个插值点位置的笔迹宽度和首个中间插值点位置 的笔迹宽度,确定首个插值点与首个中间插值点之间各插值点位置的笔迹宽度,以及根据各中间插值点的顺序和各中间插值点位置的笔迹宽度分别确定相邻两中间插值点之间各插值点位置的笔迹宽度,以及根据最后一个中间插值点位置的笔迹宽度和最后一个插值点位置的笔迹宽度,确定最后一个中间插值点与最后一个插值点之间各插值点位置的笔迹宽度(即步骤43)之前,如图6所示,所述手写笔迹生成方法还包括以下步骤:
步骤42’,根据第一类型的笔形参数、预设的标准宽度和预设的速度变化权重确定笔迹宽度的数值范围。
第一类型的笔形参数包括第一子类型的笔形参数(粗毛笔)和第二子类型的笔形参数(细毛笔),粗毛笔对应的笔迹宽度的数值范围与细毛笔对应的笔迹宽度的数值范围不同,所述数值范围根据预设的标准宽度D和预设的速度变化权重λ确定。
步骤43’,在数值范围内,确定首个插值点位置的笔迹宽度、各中间插值点位置的笔迹宽度和最后一个插值点位置的笔迹宽度。
在本步骤中,若首个插值点M0位置的笔迹宽度D0、各中间插值点M1x位置的笔迹宽度D1x和最后一个插值点M2位置的笔迹宽度D2中的任意一个或多个超出相应第一笔形参数对应的数值范围,则将超出该数值范围的笔迹宽度调整到该数值范围之内。也就是说,将小于该数值范围下限的笔迹宽度调整为该数值范围的下限,将大于该数值范围上限的笔迹宽度调整为该数值范围的上限。
在一些实施例中,若第一笔形参数为第一子类型的笔形参数(即粗毛笔),则速度变化权重λ小于1且大于0;若第一笔形参数为第二子类型的笔形参数(即细毛笔),则速度变化权重λ小于0且大于-1。因此,第一子类型的笔形参数(即粗毛笔)的笔迹宽度的数值范围为[(1-λ)*D,D],第二子类型的笔形参数(即细毛笔)的笔迹宽度的数值范围为[(1+λ)*D,D]。粗毛笔和细毛笔的相关参数设置如表1所示:
表1
Figure PCTCN2022089957-appb-000001
图7a示出了不同λ对应的粗毛笔手写笔迹的效果,如图7a所示,针对粗毛笔的笔形,速度变化权重λ的绝对值越大,最小笔迹宽度越小,笔迹宽度变化越明显。
图7b示出了不同λ对应的细毛笔手写笔迹的效果。如图7b所示,针对细毛笔的笔形,速度变化权重λ的绝对值越大,最小笔迹宽度也越小,笔迹宽度变化越明显。
在一些实施例中,如图8所示,在笔形参数为第一笔形参数(即粗毛笔或细毛笔)的情况下,针对首个插值点M0、各中间插值点M1x和最后一个插值点M2中的一个插值点,确定插值点位置的笔迹宽度的步骤包括:
步骤81,确定插值点对应的调整系数。
本步骤中所说的插值点为首个插值点M0、各中间插值点M1x和最后一个插值点M2中的一个,不同的插值点具有不同的调整系数。
步骤82,根据调整系数和所述插值点的前一插值点位置的笔迹宽度,确定所述插值点位置的笔迹宽度。
在本步骤中,利用当前插值点的调整系数对前一插值点位置的笔迹宽度进行调整,得到当前插值点位置的笔迹宽度。以中间插值点为一个(即M1)为例,若当前插值点为中间插值点M1,则前一插值点为首个插值点M0;若当前插值点为最后一个插值点M2,则中间插值点为中间插值点M1。可以根据公式(3)计算插值点位置的笔迹宽度:
D t=k t*D t-1                                       (3)
其中,D t为插值点位置的笔迹宽度,D t-1为插值点的前一插值点位置的笔迹宽度,k t为插值点对应的调整系数。
在一些实施例中,如图9所示,所述确定插值点对应的调整系数(即步骤81),包括以下步骤:
步骤181,根据手写轨迹曲线所处的书写阶段和插值点在手写轨迹曲线中的位置,计算插值点的书写速度。
手写轨迹曲线所处的书写阶段包括以下四个阶段:阶段1为起笔阶段,阶段2为收笔阶段,阶段3为包括起笔和收笔的阶段,阶段0为中间阶段,中间阶段既不包括起笔又不包括收笔。可以针对上述四个阶段分别进行标记,每次采样生成的手写轨迹曲线只属于上述四个阶段中的一个。
插值点在手写轨迹曲线中的位置是指插值点是否为手写轨迹曲线中的首个插值点。
步骤182,根据速度变化权重λ、预设的基准书写速度v’和插值点的书写速度,计算插值点对应的调整系数。
以粗毛笔笔形为例,在利用粗毛笔笔形的笔刷形成手写笔迹的情况下,在书写过程中,插值点位置的笔迹宽度D t随书写速度变化而变化,基准书写速度为v’。当当前的书写速度vt>基准书写速度v’时,当前的笔迹宽度D t就会变细,也就是说,将前一个插值点位置的笔迹D t-1乘以调整系数k t,且k t<1,得到当前的笔迹宽度D t。当当前的书写速度vt<基准书写速度v’时,当前的笔迹宽度D t就会变粗,也就是说,将前一个插值点位置的笔迹D t-1乘以调整系数k t,且kt>1,得到当前的笔迹宽度D t
为此,本发明实施例建立一个笔迹宽度与书写速度之间的函数关系。调整系数与自然数e的指数函数的值成反比,由于自然数e的指数函数具有上述调整系数kt变化的特性,当指数函数的自变量为正数时,指数函数的值大于1,kt的值小于1,当指数函数的自变量为负数时,指数函数的值小于1,kt的值大于1。因此,插值点对应的调整系数kt的计算公式(4):
Figure PCTCN2022089957-appb-000002
其中,vt为插值点的书写速度,v’为预设的基准书写速度,λ为速度变 化权重,当笔形参数为粗毛笔时,0<λ<1,当笔形参数为细毛笔时,-1<λ<0。λ的绝对值用于控制调整系数kt的变化速率,λ的绝对值越大,调整系数kt变化越剧烈,相应的,笔迹宽度的变化越明显;λ的绝对值越小,调整系数kt变化越缓慢,相应的,笔迹宽度的变化越微小。
针对细毛笔笔形,在书写过程中,插值点位置的笔迹宽度D t随书写速度变化而变化,基准书写速度为v’。当当前的书写速度vt>基准书写速度v’时,当前的笔迹宽度D t就会变粗;当当前的书写速度vt<基准书写速度v’时,当前的笔迹宽度D t就会变细。在笔形参数为细毛笔笔形的情况下,插值点对应的调整系数kt的计算公式也为公式(4),只不过其中的速度变化权重λ取值为-1<λ<0。
在一些实施例中,所述根据手写轨迹曲线所处的书写阶段和插值点在手写轨迹曲线中的位置,计算插值点的书写速度(即步骤181),包括:
响应于手写轨迹曲线处于起笔阶段(阶段1)或者包括起笔和收笔的阶段(阶段3)且插值点为手写轨迹曲线中首个插值点,则插值点的书写速度v0为零,即v0=0。
响应于手写轨迹曲线处于起笔阶段(阶段1)或者处于包括起笔和收笔的阶段(阶段3)或者处于收笔阶段(过程2)或者处于中间阶段(过程0)且插值点为手写轨迹曲线中非首个插值点,根据插值点的位置及时刻和前一插值点的位置及时刻计算插值点的书写速度。也就是说,手写轨迹曲线中的中间插值点和最后一个插值点的书写速度与该插值点所属手写轨迹曲线所处的书写阶段无关,而是根据该插值点和其前一插值点的位置和时刻计算该插值点的书写速度。
响应于手写轨迹曲线处于收笔阶段(阶段2)或者中间阶段(阶段0)且插值点为手写轨迹曲线中首个插值点,根据插值点的位置及时刻和前一轨迹段的中间插值点的位置及时刻计算插值点的书写速度。也就是说,非起笔阶段的手写轨迹曲线中首个插值点与前一个轨迹段中最后一个插值点重合, 其书写速度可以按照前一轨迹段中最后一个插值点的书写速度的计算方式计算。
在一些实施例中,插值点的时刻根据与插值点对应的采样点的采样时刻。以二阶贝塞尔曲线的手写轨迹曲线为例,将三个采样点P0,P1,P2对应的采样时刻t0,t1,t2分别作为手写轨迹曲线中首个插值点M0的时刻、手写轨迹曲线中中间插值点M1的时刻、手写轨迹曲线中最后一个插值点M2的时刻。
在一些实施例中,所述根据调整系数和插值点的前一插值点位置的笔迹宽度,确定插值点位置的笔迹宽度(即步骤82),包括以下步骤:响应于手写轨迹曲线处于起笔阶段(阶段1)或者包括起笔和收笔的阶段(阶段3)且插值点为手写轨迹曲线中首个插值点,根据调整系数和初始笔迹宽度Dlast确定插值点位置的笔迹宽度,其中,初始笔迹宽度Dlast根据第一类型的笔形参数确定。也就是说,针对包括起笔阶段的手写轨迹曲线中的首个插值点,在利用公式(3)计算该插值点位置的笔迹宽度时,该插值点的前一插值点位置的笔迹宽度D t-1=初始笔迹宽度Dlast,而针对粗毛笔的笔形和细毛笔的笔形,其初始笔迹宽度Dlast不同。
由于粗毛笔的笔迹宽度随书写速度增加而减小,细毛笔的笔迹宽度随书写速度增加而增加,因此,粗毛笔的初始笔迹宽度>细毛笔的初始笔迹宽度。在一些实施例中,如表1所示,若笔形参数为粗毛笔,则初始笔迹宽度Dlast为标准宽度D;若笔形参数为细毛笔,则初始笔迹宽度Dlast为(1+λ)倍的标准宽度D。
结合表1和图7a所示,针对粗毛笔的笔形,不同速度变化权重λ对应的初始笔迹宽度Dlast相同,均为标准宽度D。结合表1和图7b所示,针对细毛笔的笔形,不同速度变化权重λ对应的初始笔迹宽度Dlast不同,速度变化权重λ的绝对值越大,初始笔迹宽度Dlast越小。
需要说明的是,在本发明另一实施例中,也可以不采用线性插值的方式 确定各个插值点位置的笔迹宽度,而是按照手写轨迹曲线上各插值点的顺序,根据上述公式(3)和公式(4),依次对前一插值点的笔迹宽度进行调整,计算得到当前插值点的笔迹宽度。本领域技术人员可知,这种计算各个插值点位置的笔迹宽度的方式相较于利用线性插值的方式计算插值点位置的笔迹宽度,更为复杂,耗时较长。
为清楚说明本发明实施例的方案,以下结合图2a和图2b,对通过线性插值方式确定各插值点的笔迹宽度的过程进行详细说明。
如图2a所示,本次采样的三个采样点P0、P1、P2的采集时刻分别为t0、t1、t2,利用上述三个采样点P0、P1、P2生成图2b的手写轨迹曲线,并确定该手写轨迹曲线上的各个插值点的位置。将首个插值点M0的时刻赋值为t0,将中间插值点M1的时刻赋值为M1,将最后一个插值点M2的时刻赋值为t2。首个插值点M0的位置为(x0,y0),中间插值点M1的位置为(x1,y1),最后一个插值点M2的位置为(x2,y2)。
若该手写轨迹曲线处于起笔阶段(阶段1)或者包括起笔和收笔的阶段(阶段3),则首个插值点M0的速度为v0,v0=0;中间插值点M1的速度为v1,
Figure PCTCN2022089957-appb-000003
最后一个插值点M2的速度为v2,
Figure PCTCN2022089957-appb-000004
若该手写轨迹曲线处于收笔阶段(阶段2)或者中间阶段(阶段0),则首个插值点M0的速度为v0,
Figure PCTCN2022089957-appb-000005
其中,(x 1’,y 1’)为前一轨迹段的中间插值点的位置坐标,(x 2’,y 2’)为前一轨迹段的最后一个插值点的位置坐标,也是当前轨迹段的首个插值点M0的位置坐标。中间插值点M1的速度为v1,
Figure PCTCN2022089957-appb-000006
最后一个插值点M2的速度为v2,
Figure PCTCN2022089957-appb-000007
在计算得到首个插值点M0的速度v0、中间插值点M1的速度v1和最后一个插值点M2的速度v2之后,根据公式(4)分别计算首个插值点M0 的调整系数k0、中间插值点M1的调整系数k1和最后一个插值点M2的调整系数k2,其中,当v0=0时,k0=1。
根据公式(3)分别计算首个插值点M0的笔迹宽度D0、中间插值点M1位置的笔迹宽度D1和最后一个插值点M2位置的笔迹宽度D2,其中,D0=k0*Dlast,D1=k1*D0,D2=k2*D1。若该手写轨迹曲线处于起笔阶段(阶段1)或者包括起笔和收笔的阶段(阶段3),则在粗毛笔笔形的情况下,Dlast=D(D为标准宽度),在细毛笔笔形的情况下,Dlast=(1+λ)*D。
确定笔迹宽度的数值范围,若首个插值点M0的笔迹宽度D0、中间插值点M1位置的笔迹宽度D1和最后一个插值点M2位置的笔迹宽度D2中有超出该数值范围的笔迹宽度,对其进行调整,以保证上述3个插值点位置的笔迹宽度均在该数值范围之内。
根据首个插值点M0的笔迹宽度D0和中间插值点M1位置的笔迹宽度D1进行线性插值,得到首个插值点M0和中间插值点M1之间的各插值点的笔迹宽度,根据中间插值点M2位置的笔迹宽度D1和最后一个插值点M2位置的笔迹宽度D2进行线性插值,得到中间插值点M1和最后一个插值点M2之间的各插值点的笔迹宽度。
在一些实施例中,在笔刷参数为用户设定的笔刷参数的情况下,笔刷参数还可以包括离散度S,离散度S用于反映插值点的位置偏离手写轨迹曲线的程度。相应的,如图10所示,在确定手写轨迹曲线上插值点的位置(即步骤3)之后、在根据笔刷参数和笔迹宽度生成与手写轨迹曲线对应的手写笔迹(即步骤4)之前,所述手写笔迹生成方法还可以包括以下步骤:
步骤3’,根据离散度S确定插值点Pn对应的离散点P’n的位置,并根据离散点P’n的位置更新插值点Pn的位置。
图11示出了某个离散度下插值点偏离手写轨迹曲线的效果。如图11所示,手写轨迹曲线上的点为确定出的插值点,手写轨迹曲线之外的各个点为相应插值点对应的离散点。
在本步骤中,在确定出离散点P’n的位置之后,利用离散点P’n的位置更新插值点Pn的位置。在后续步骤4中,根据笔刷参数和离散点P’n对应的插值点位置的笔迹宽度生成手写笔迹,这样,得到的手写笔迹更接近真实的手写效果。
在一些实施例中,结合图12和图13所示,针对一个插值点,确定插值点对应的离散点的位置的步骤包括:
步骤31’,计算插值点Pn和插值点的下一个插值点Pn+1之间连线的第一斜率Kn,并根据第一斜率Kn计算第一直线的第二斜率K’n,第一直线与所述连线垂直且经过所述插值点Pn。
如图13所示,以图13所示的手写轨迹曲线中的第三个插值点Pn为例,第四个插值点为Pn+1,插值点Pn的位置为(x n,y n),插值点Pn+1的位置为(x n+1,y n+1)。插值点Pn与插值点Pn+1之间的连线的斜率为第一斜率Kn,
Figure PCTCN2022089957-appb-000008
经过插值点Pn的第一直线与该连线垂直,第一直线的斜率为第二斜率K’n,
Figure PCTCN2022089957-appb-000009
步骤32’,根据离散距离调整参数和离散度S,计算插值点Pn的离散距离dn,离散距离调整参数周期变化。
在一些实施例中,离散距离调整参数根据插值点Pn在手写轨迹曲线上的排序确定。插值点Pn在手写轨迹曲线上的排序n是指插值点Pn在手写轨迹曲线上的第几个插值点。
在本步骤中,在[0,2π]的范围内根据随机选取一个伪随机角度α,并根据α的三角函数和插值点Pn在手写轨迹曲线上的排序,计算离散距离调整参数,离散距离调整参数为sin(n*α)。在本发明实施例中,以正弦函数为例进行说明,需要说明的是,也可以利用其他三角函数计算离散距离dn。
离散距离dn是指离散点P’n与插值点Pn之间的距离。可以根据以下公式(5)计算离散距离:
dn=S*sin(n*α)                              (5)
其中,n表示手写轨迹曲线上插值点的序号。
步骤33’,根据离散距离dn、插值点Pn的位置和第二斜率K’n,确定插值点Pn对应的离散点P’n的位置,其中,离散点P’n位于第一直线上。
假设离散点P’n的位置为(x’ n,y’ n),那么离散距离
Figure PCTCN2022089957-appb-000010
在本步骤中,根据步骤32’计算得到的dn值,求解方程组(6),可以得到离散点P’n的位置(x’ n,y’ n)。方程组(6)如下:
Figure PCTCN2022089957-appb-000011
如图13所示,当dn<0时,离散点P’n在插值点Pn的左边,即x′ n<x n;当dn>0时,离散点P’n在插值点Pn的右边,即x′ n>x n
在一些实施例中,笔刷参数还可以包括笔刷元素的旋转角度θ,笔刷元素的旋转角度θ为相邻两个笔刷元素之间的角度差,且任意相邻两个笔刷元素之间的角度差相同,π/4≤θ≤3π/4。
以铅笔的笔形实现手写轨迹为例,在生成手写轨迹的过程中,对铅笔的笔刷元素进行旋转,模拟出不规则的铅笔手写轨迹效果。本发明实施例在
Figure PCTCN2022089957-appb-000012
的旋转角度范围内随机选取一个伪随机角度θ,作为相邻两个笔刷元素之间的角度差,即每个笔刷元素均相对于前一个笔刷元素旋转角度θ,也就是说,θ n=θ n-1+θ。
图14为铅笔笔形中不同旋转角度θ对应的手写笔迹效果示意图。如图14所示,各笔刷元素依次逆时针旋转,其中,第一行为θ=π/4、笔刷元素的间距为1.5倍笔刷元素的直径(即T=1.5d)的手写笔迹效果;第二行为θ=π/4、笔刷元素的间距为1倍笔刷元素的直径(即T=d)的手写笔迹效果;第三行为θ=π/4、笔刷元素的间距为0.8倍笔刷元素的直径(即T=0.8d)的手写笔迹效果;第四行为θ=π/2、笔刷元素的间距为0.8倍笔刷元素的直径(即T=0.8d)的手写笔迹效果。
在一些实施例中,笔刷参数还可以包括笔刷元素的初始旋转角度θ 0,笔刷元素的初始旋转角度θ 0为笔刷元素在手写轨迹曲线中首个插值点位置的旋转角度。也就是说,随机选取一个伪随机角度θ 0,作为首个插值点位置的旋转角度,笔刷元素的旋转角度θ可以与笔刷元素的初始旋转角度θ 0相同或不同,在本发明实施例中,如图14所示,θ=θ 0。在一些实施例中,初始旋转角度θ 0也可以为0,即第一个笔刷元素不旋转,第二个笔刷元素之后的各个笔刷元素按照旋转角度θ旋转。
在本发明实施例中,采用等弧长插值选取插值点,并根据笔刷参数和插值点位置的笔迹宽度生成手写笔迹,能够实现个性化、多样化的手写笔迹效果。图15左侧显示了五种预设笔形的手写笔迹效果。图15的右侧显示了自定义笔刷参数,用户可根据需要选择笔刷元素的形状或图案、笔刷元素的间距、笔刷元素的直径、笔刷元素的旋转角度、离散度、速度变化权重等参数,可以自定义出个性化的手写笔迹效果。各种笔形对应的手写笔迹能够真实还原相应的笔形特征,针对粗毛笔和细毛笔笔形,手写笔迹的笔迹宽度还能够随书写速度变化而变化,显示效果极为逼真。
本发明实施例提供的手写笔迹生成方法,按照等弧长插值的方式选取插值点,在插值点位置进行贴图绘画,可以模拟画板上各种笔形的笔迹样式。本发明实施例可以应用在绘画屏、电子板报领域,还可以应用在如会议白板、教学白板等大尺寸(一般50寸以上)的智能显示领域。
本发明实施例提供的手写笔迹生成方法,既可以呈现多种预设笔形的手写笔迹,也可以从系统自定义的图库中选择相应的笔刷参数实现用户自定义效果的手写笔迹,也可以用户自行上传矢量图,然后进行自定义笔刷设计,设计笔刷元素的笔迹宽度、笔刷元素的间距、笔刷元素的旋转角度、离散度、速度变换权值等。本发明实施例提供的手写笔迹生成方案,可以极大简化手写笔迹生成过程,步骤实现简单,能够满足用户自定义需求。
基于相同的技术构思,本发明实施例还提供一种手写笔迹生成装置,如图16所示,所述手写笔迹生成装置包括参数获取模块101、轨迹生成模块102、插值点确定模块103、笔迹宽度确定模块104和笔迹生成模块105,参数获取模块101用于,获取笔刷参数,所述笔刷参数根据用户选择的笔形参数确定,或者,所述笔刷参数为用户设定的笔刷参数,所述笔刷参数至少包括笔刷元素的形状或图案。
轨迹生成模块102用于,获取手写轨迹的采样点,根据所述采样点生成手写轨迹曲线,所述手写轨迹为所述笔迹段中一个轨迹段的轨迹。
插值点确定模块103用于,确定所述手写轨迹曲线上插值点的位置,其中,所述手写轨迹曲线上任意两相邻插值点之间的弧长相同。
笔迹宽度确定模块104用于,根据所述笔刷参数确定所述插值点的位置的笔迹宽度。
笔迹生成模块105用于,根据所述笔刷参数和所述笔迹宽度生成与所述手写轨迹曲线对应的手写笔迹。
在一些实施例中,所述笔形参数为第一类型的笔形参数;笔迹宽度确定模块104用于,确定所述手写轨迹曲线上首个插值点的位置、至少一个中间插值点的位置和最后一个插值点的位置;确定所述首个插值点位置的笔迹宽度、各所述中间插值点位置的笔迹宽度和最后一个插值点位置的笔迹宽度;通过插值的方式,根据所述首个插值点位置的笔迹宽度和首个所述中间插值点位置的笔迹宽度,确定所述首个插值点与首个所述中间插值点之间各插值点位置的笔迹宽度,以及根据最后一个中间插值点位置的笔迹宽度和所述最后一个插值点位置的笔迹宽度,确定最后一个所述中间插值点与所述最后一个插值点之间各插值点位置的笔迹宽度。
在一些实施例中,笔迹宽度确定模块104用于,通过线性插值的方式,确定所述首个插值点与首个所述中间插值点之间各插值点位置的笔迹宽度、相邻两所述中间插值点之间各插值点位置的笔迹宽度和最后一个所述中间 插值点与所述最后一个插值点之间各插值点位置的笔迹宽度。
在一些实施例中,笔迹宽度确定模块104还用于,在确定所述首个插值点位置的笔迹宽度、各所述中间插值点位置的笔迹宽度和所述最后一个插值点位置的笔迹宽度之后,在通过插值的方式,根据所述首个插值点位置的笔迹宽度和首个所述中间插值点位置的笔迹宽度,确定所述首个插值点与首个所述中间插值点之间各插值点位置的笔迹宽度,以及根据各所述中间插值点的顺序和各所述中间插值点位置的笔迹宽度分别确定相邻两所述中间插值点之间各插值点位置的笔迹宽度,以及根据最后一个中间插值点位置的笔迹宽度和所述最后一个插值点位置的笔迹宽度,确定最后一个所述中间插值点与所述最后一个插值点之间各插值点位置的笔迹宽度之前,根据所述第一类型的笔形参数、预设的标准宽度D和预设的速度变化权重λ确定笔迹宽度的数值范围;在所述数值范围内,确定所述首个插值点位置的笔迹宽度、各所述中间插值点位置的笔迹宽度和所述最后一个插值点位置的笔迹宽度。
在一些实施例中,所述第一类型的笔形参数包括第一子类型的笔形参数和第二子类型的笔形参数,若所述第一笔形参数为第一子类型的笔形参数,则所述速度变化权重λ小于1且大于0;若所述第一笔形参数为第二子类型的笔形参数,则所述速度变化权重λ小于0且大于-1;
所述第一子类型的笔形参数的笔迹宽度的数值范围为[(1-λ)*D,D],所述第二子类型的笔形参数的笔迹宽度的数值范围为[(1+λ)*D,D]。
在一些实施例中,笔迹宽度确定模块104用于,针对所述首个插值点、各所述中间插值点和所述最后一个插值点中的一个插值点,通过以下方式确定所述插值点位置的笔迹宽度:确定所述插值点对应的调整系数;根据所述调整系数和所述插值点的前一插值点位置的笔迹宽度,确定所述插值点位置的笔迹宽度。
在一些实施例中,笔迹宽度确定模块104用于,根据所述手写轨迹曲线所处的书写阶段和所述插值点在所述手写轨迹曲线中的位置,计算所述插值 点的书写速度;根据所述速度变化权重、预设的基准书写速度和所述插值点的书写速度,计算所述插值点对应的调整系数。
在一些实施例中,笔迹宽度确定模块104用于,响应于所述手写轨迹曲线处于起笔阶段或者包括起笔和收笔的阶段且所述插值点为所述手写轨迹曲线中首个插值点,所述插值点的书写速度为零。
在一些实施例中,笔迹宽度确定模块104用于,响应于所述手写轨迹曲线处于起笔阶段或者处于包括起笔和收笔的阶段或者处于收笔阶段或者处于中间阶段且所述插值点为所述手写轨迹曲线中非首个插值点,根据所述插值点的位置及时刻和前一插值点的位置及时刻计算所述插值点的书写速度。
在一些实施例中,笔迹宽度确定模块104用于,响应于所述手写轨迹曲线处于收笔阶段或者中间阶段且所述插值点为所述手写轨迹曲线中首个插值点,根据所述插值点的位置及时刻和前一轨迹段的中间插值点的位置及时刻计算所述插值点的书写速度。
在一些实施例中,插值点的时刻根据与所述插值点对应的所述采样点的采样时刻。
在一些实施例中,笔迹宽度确定模块104用于,响应于所述手写轨迹曲线处于起笔阶段或者包括起笔和收笔的阶段且所述插值点为所述手写轨迹曲线中首个插值点,根据所述调整系数和初始笔迹宽度确定所述插值点位置的笔迹宽度,所述初始笔迹宽度根据所述第一类型的笔形参数确定。
在一些实施例中,在所述笔刷参数为用户设定的笔刷参数的情况下,所述笔刷参数包括离散度S。如图17所示,所述手写笔迹生成装置还包括插值点位置更新模块106,插值点位置更新模块106用于,在插值点确定模块103确定所述手写轨迹曲线上插值点的位置之后、在笔迹生成模块105根据所述笔刷参数和所述笔迹宽度生成与所述手写轨迹曲线对应的手写笔迹之前,根据所述离散度S确定所述插值点Pn对应的离散点P’n的位置,并根据所述离散点P’n的位置更新所述插值点Pn的位置。
在一些实施例中,插值点位置更新模块106用于,针对一个插值点,采用以下方式确定所述插值点对应的离散点的位置:计算所述插值点Pn和所述插值点的下一个插值点Pn+1之间连线的第一斜率Kn,并根据第一斜率Kn计算第一直线的第二斜率K’n,所述第一直线与所述连线垂直且经过所述插值点Pn;根据离散距离调整参数和所述离散度S,计算所述插值点Pn的离散距离dn,所述离散距离调整参数周期变化;根据所述离散距离dn、所述插值点Pn的位置和所述第二斜率K’n,确定所述插值点Pn对应的离散点P’n的位置,其中,所述离散点P’n位于所述第一直线上。
在一些实施例中,所述离散距离调整参数根据所述插值点Pn在所述手写轨迹曲线上的排序确定。
在一些实施例中,所述笔刷参数还包括笔刷元素的旋转角度θ,所述笔刷元素的旋转角度θ为相邻两个笔刷元素之间的角度差,且任意相邻两个笔刷元素之间的角度差相同,π/4≤θ≤3π/4。
在一些实施例中,所述笔刷参数还包括笔刷元素的初始旋转角度θ 0,所述笔刷元素的初始旋转角度θ 0为笔刷元素在所述手写轨迹曲线中首个插值点位置的旋转角度。
在一些实施例中,所述笔刷参数还包括以下至少之一:笔刷元素的间距、笔刷元素的直径;插值点确定模块103用于,根据所述笔刷元素的直径和所述笔刷元素的间距确定所述手写轨迹曲线上插值点的位置。
在一些实施例中,所述笔刷元素的间距的最大值根据所述笔刷元素的直径和所述笔形参数确定。
本发明实施例还提供了一种计算机设备,该计算机设备包括:一个或多个处理器以及存储装置;其中,存储装置上存储有一个或多个程序,当上述一个或多个程序被上述一个或多个处理器执行时,使得上述一个或多个处理器实现如前述各实施例所提供的手写笔迹生成方法。
本发明实施例还提供了一种计算机可读介质,其上存储有计算机程序, 其中,该计算机程序被执行时实现如前述各实施例所提供的手写笔迹生成方法。
可以理解的是,以上实施方式仅仅是为了说明本发明/实用新型的原理而采用的示例性实施方式,然而本发明/实用新型并不局限于此。对于本领域内的普通技术人员而言,在不脱离本发明/实用新型的精神和实质的情况下,可以做出各种变型和改进,这些变型和改进也视为本发明/实用新型的保护范围。

Claims (22)

  1. 一种手写笔迹生成方法,其特征在于,所述手写笔迹包括利用笔刷形成的至少一个笔迹段,其中,每个笔迹段通过以下方式生成:
    获取笔刷参数,所述笔刷参数根据用户选择的笔形参数确定,或者,所述笔刷参数为用户设定的笔刷参数,所述笔刷参数至少包括笔刷元素的形状或图案;
    获取手写轨迹的采样点,根据所述采样点生成手写轨迹曲线,所述手写轨迹为所述笔迹段中一个轨迹段的轨迹;
    确定所述手写轨迹曲线上插值点的位置,其中,所述手写轨迹曲线上任意两相邻插值点之间的弧长相同;
    根据所述笔刷参数确定所述插值点的位置的笔迹宽度,并根据所述笔刷参数和所述笔迹宽度生成与所述手写轨迹曲线对应的手写笔迹。
  2. 如权利要求1所述的方法,其特征在于,所述笔形参数为第一类型的笔形参数;所述根据所述笔刷参数确定所述插值点的位置的笔迹宽度,包括:
    确定所述手写轨迹曲线上首个插值点的位置、至少一个中间插值点的位置和最后一个插值点的位置;
    确定所述首个插值点位置的笔迹宽度、各所述中间插值点位置的笔迹宽度和最后一个插值点位置的笔迹宽度;
    通过插值的方式,根据所述首个插值点位置的笔迹宽度和首个所述中间插值点位置的笔迹宽度,确定所述首个插值点与首个所述中间插值点之间各插值点位置的笔迹宽度,以及根据最后一个中间插值点位置的笔迹宽度和所述最后一个插值点位置的笔迹宽度,确定最后一个所述中间插值点与所述最后一个插值点之间各插值点位置的笔迹宽度。
  3. 如权利要求2所述的方法,其特征在于,通过线性插值的方式,确定所述首个插值点与首个所述中间插值点之间各插值点位置的笔迹宽度和最后一个所述中间插值点与所述最后一个插值点之间各插值点位置的笔迹宽度。
  4. 如权利要求2所述的方法,其特征在于,在确定所述首个插值点位置的笔迹宽度、各所述中间插值点位置的笔迹宽度和所述最后一个插值点位置的笔迹宽度之后,在通过插值的方式,根据所述首个插值点位置的笔迹宽度和首个所述中间插值点位置的笔迹宽度,确定所述首个插值点与首个所述中间插值点之间各插值点位置的笔迹宽度,以及根据最后一个中间插值点位置的笔迹宽度和所述最后一个插值点位置的笔迹宽度,确定最后一个所述中间插值点与所述最后一个插值点之间各插值点位置的笔迹宽度之前,还包括:
    根据所述第一类型的笔形参数、预设的标准宽度D和预设的速度变化权重λ确定笔迹宽度的数值范围;
    在所述数值范围内,确定所述首个插值点位置的笔迹宽度、各所述中间插值点位置的笔迹宽度和所述最后一个插值点位置的笔迹宽度。
  5. 如权利要求4所述的方法,其特征在于,所述第一类型的笔形参数包括第一子类型的笔形参数和第二子类型的笔形参数,若所述第一笔形参数为第一子类型的笔形参数,则所述速度变化权重λ小于1且大于0;若所述第一笔形参数为第二子类型的笔形参数,则所述速度变化权重λ小于0且大于-1;
    所述第一子类型的笔形参数的笔迹宽度的数值范围为[(1-λ)*D,D],所述第二子类型的笔形参数的笔迹宽度的数值范围为[(1+λ)*D,D]。
  6. 如权利要求4所述的方法,其特征在于,针对所述首个插值点、各所述中间插值点和所述最后一个插值点中的一个插值点,通过以下方式确定所述插值点位置的笔迹宽度:
    确定所述插值点对应的调整系数;
    根据所述调整系数和所述插值点的前一插值点位置的笔迹宽度,确定所述插值点位置的笔迹宽度。
  7. 如权利要求6所述的方法,其特征在于,所述确定所述插值点对应的调整系数,包括:
    根据所述手写轨迹曲线所处的书写阶段和所述插值点在所述手写轨迹 曲线中的位置,计算所述插值点的书写速度;
    根据所述速度变化权重、预设的基准书写速度和所述插值点的书写速度,计算所述插值点对应的调整系数。
  8. 如权利要求7所述的方法,其特征在于,所述根据所述手写轨迹曲线所处的书写阶段和所述插值点在所述手写轨迹曲线中的位置,计算所述插值点的书写速度,包括:
    响应于所述手写轨迹曲线处于起笔阶段或者包括起笔和收笔的阶段且所述插值点为所述手写轨迹曲线中首个插值点,所述插值点的书写速度为零。
  9. 如权利要求7所述的方法,其特征在于,所述根据所述手写轨迹曲线所处的书写阶段和所述插值点在所述手写轨迹曲线中的位置,计算所述插值点的书写速度,包括:
    响应于所述手写轨迹曲线处于起笔阶段或者处于包括起笔和收笔的阶段或者处于收笔阶段或者处于中间阶段且所述插值点为所述手写轨迹曲线中非首个插值点,根据所述插值点的位置及时刻和前一插值点的位置及时刻计算所述插值点的书写速度。
  10. 如权利要求7所述的方法,其特征在于,所述根据所述手写轨迹曲线所处的书写阶段和所述插值点在所述手写轨迹曲线中的位置,计算所述插值点的书写速度,包括:
    响应于所述手写轨迹曲线处于收笔阶段或者中间阶段且所述插值点为所述手写轨迹曲线中首个插值点,根据所述插值点的位置及时刻和前一轨迹段的中间插值点的位置及时刻计算所述插值点的书写速度。
  11. 如权利要求9或10任一项所述的方法,其特征在于,插值点的时刻根据与所述插值点对应的所述采样点的采样时刻。
  12. 如权利要求6所述的方法,其特征在于,根据所述调整系数和所述插值点的前一插值点位置的笔迹宽度,确定所述插值点位置的笔迹宽度,包括:
    响应于所述手写轨迹曲线处于起笔阶段或者包括起笔和收笔的阶段且所述插值点为所述手写轨迹曲线中首个插值点,根据所述调整系数和初始笔迹宽度确定所述插值点位置的笔迹宽度,所述初始笔迹宽度根据所述第一类型的笔形参数确定。
  13. 如权利要求1-10、12任一项所述的方法,其特征在于,在所述笔刷参数为用户设定的笔刷参数的情况下,所述笔刷参数包括离散度S;在确定所述手写轨迹曲线上插值点的位置之后、在根据所述笔刷参数和所述笔迹宽度生成与所述手写轨迹曲线对应的手写笔迹之前,还包括:
    根据所述离散度S确定所述插值点Pn对应的离散点P’n的位置,并根据所述离散点P’n的位置更新所述插值点Pn的位置。
  14. 如权利要求13所述的方法,其特征在于,针对一个插值点,采用以下方式确定所述插值点对应的离散点的位置:
    计算所述插值点Pn和所述插值点的下一个插值点Pn+1之间连线的第一斜率Kn,并根据第一斜率Kn计算第一直线的第二斜率K’n,所述第一直线与所述连线垂直且经过所述插值点Pn;
    根据离散距离调整参数和所述离散度S,计算所述插值点Pn的离散距离dn,所述离散距离调整参数周期变化;
    根据所述离散距离dn、所述插值点Pn的位置和所述第二斜率K’n,确定所述插值点Pn对应的离散点P’n的位置,其中,所述离散点P’n位于所述第一直线上。
  15. 如权利要求14所述的方法,其特征在于,所述离散距离调整参数根据所述插值点Pn在所述手写轨迹曲线上的排序确定。
  16. 如权利要求1-10、12任一项所述的方法,其特征在于,所述笔刷参数还包括笔刷元素的旋转角度θ,所述笔刷元素的旋转角度θ为相邻两个笔刷元素之间的角度差,且任意相邻两个笔刷元素之间的角度差相同,π/4≤θ≤3π/4。
  17. 如权利要求16所述的方法,其特征在于,所述笔刷参数还包括笔刷元素的初始旋转角度θ 0,所述笔刷元素的初始旋转角度θ 0为笔刷元素在所述手写轨迹曲线中首个插值点位置的旋转角度。
  18. 如权利要求1-10、12任一项所述的方法,其特征在于,所述笔刷参数还包括以下至少之一:笔刷元素的间距、笔刷元素的直径;
    所述确定所述手写轨迹曲线上插值点的位置,包括:
    根据所述笔刷元素的直径和所述笔刷元素的间距确定所述手写轨迹曲线上插值点的位置。
  19. 如权利要求18所述的方法,其特征在于,所述笔刷元素的间距的最大值根据所述笔刷元素的直径和所述笔形参数确定。
  20. 一种手写笔迹生成装置,其特征在于,包括参数获取模块、轨迹生成模块、插值点确定模块、笔迹宽度确定模块和笔迹生成模块,所述参数获取模块用于,获取笔刷参数,所述笔刷参数根据用户选择的笔形参数确定,或者,所述笔刷参数为用户设定的笔刷参数,所述笔刷参数至少包括笔刷元素的形状或图案;
    所述轨迹生成模块用于,获取手写轨迹的采样点,根据所述采样点生成手写轨迹曲线,所述手写轨迹为所述笔迹段中一个轨迹段的轨迹;
    所述插值点确定模块用于,确定所述手写轨迹曲线上插值点的位置,其中,所述手写轨迹曲线上任意两相邻插值点之间的弧长相同;
    所述笔迹宽度确定模块用于,根据所述笔刷参数确定所述插值点的位置的笔迹宽度;
    所述笔迹生成模块用于,根据所述笔刷参数和所述笔迹宽度生成与所述手写轨迹曲线对应的手写笔迹。
  21. 一种计算机设备,包括:
    一个或多个处理器;
    存储装置,其上存储有一个或多个程序;
    当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个 或多个处理器实现如权利要求1-19任一项所述的手写笔迹生成方法。
  22. 一种计算机可读介质,其上存储有计算机程序,其中,所述程序被执行时实现如权利要求1-19任一项所述的手写笔迹生成方法。
PCT/CN2022/089957 2022-04-28 2022-04-28 手写笔迹生成方法、装置、计算机设备和可读介质 WO2023206257A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202280001034.5A CN117321636A (zh) 2022-04-28 2022-04-28 手写笔迹生成方法、装置、计算机设备和可读介质
PCT/CN2022/089957 WO2023206257A1 (zh) 2022-04-28 2022-04-28 手写笔迹生成方法、装置、计算机设备和可读介质

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2022/089957 WO2023206257A1 (zh) 2022-04-28 2022-04-28 手写笔迹生成方法、装置、计算机设备和可读介质

Publications (1)

Publication Number Publication Date
WO2023206257A1 true WO2023206257A1 (zh) 2023-11-02

Family

ID=88516787

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/089957 WO2023206257A1 (zh) 2022-04-28 2022-04-28 手写笔迹生成方法、装置、计算机设备和可读介质

Country Status (2)

Country Link
CN (1) CN117321636A (zh)
WO (1) WO2023206257A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101014735B1 (ko) * 2010-01-15 2011-02-14 김도영 판서 기능 제공 장치
CN102521858A (zh) * 2011-11-28 2012-06-27 北京盛世宣合信息科技有限公司 电子毛笔书写笔迹生成方法
CN103310474A (zh) * 2013-06-08 2013-09-18 深圳市经纬科技有限公司 一种手写原笔迹的实现方法及系统
CN105225260A (zh) * 2015-09-25 2016-01-06 中国电子科技集团公司第三十二研究所 一种手写原笔迹实现方法
CN112102434A (zh) * 2020-09-22 2020-12-18 深圳市皓丽智能科技有限公司 一种笔迹绘制方法、装置及设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101014735B1 (ko) * 2010-01-15 2011-02-14 김도영 판서 기능 제공 장치
CN102521858A (zh) * 2011-11-28 2012-06-27 北京盛世宣合信息科技有限公司 电子毛笔书写笔迹生成方法
CN103310474A (zh) * 2013-06-08 2013-09-18 深圳市经纬科技有限公司 一种手写原笔迹的实现方法及系统
CN105225260A (zh) * 2015-09-25 2016-01-06 中国电子科技集团公司第三十二研究所 一种手写原笔迹实现方法
CN112102434A (zh) * 2020-09-22 2020-12-18 深圳市皓丽智能科技有限公司 一种笔迹绘制方法、装置及设备

Also Published As

Publication number Publication date
CN117321636A (zh) 2023-12-29

Similar Documents

Publication Publication Date Title
CN103310474B (zh) 一种手写原笔迹的实现方法及系统
CN109284059A (zh) 笔迹绘制方法、装置、交互智能平板和存储介质
US11475617B2 (en) Path-constrained drawing with visual properties based on drawing tool
WO2021218445A1 (zh) 笔迹处理方法、笔迹处理装置、存储介质
CN109101171A (zh) 一种在触摸屏设备中生成滑动轨迹的方法
CN107230239A (zh) 图形绘制方法、装置及设备
CN109564496B (zh) 交互式显示叠覆系统及相关方法
AU2017200441B2 (en) Curve editing using splines of non-uniformly scaled curves of cubic variation of curvature
CN107248192A (zh) 立体图形绘制方法、装置、设备及存储介质
CN107797752A (zh) 书写笔迹的呈现方法及装置、交互智能平板及存储介质
CN110221722A (zh) 图片处理方法、电子设备及存储介质
CN109032190A (zh) 云台转向控制方法、装置、电子设备及存储介质
CN105701849B (zh) 一种模拟圆规实现绘制圆的方法
US20160054879A1 (en) Portable electronic devices and methods for operating user interfaces
WO2023206257A1 (zh) 手写笔迹生成方法、装置、计算机设备和可读介质
CN113589999A (zh) 笔迹处理方法、笔迹处理装置、非瞬时性存储介质
WO2015062176A1 (zh) 多点触控的多媒体球幕演示仪及其多点触控方法
WO2021218448A1 (zh) 笔迹形成方法、笔迹形成装置及电子设备
WO2023115312A1 (zh) 手写笔迹生成方法、装置、计算机设备和可读介质
US11900568B2 (en) Writing trajectory processing method, touch control device, writing system and storage medium
WO2020132863A1 (zh) 续笔方法与显示终端
CN108829326A (zh) 文字修改方法、设备及存储介质
WO2022062570A1 (zh) 图像处理方法和装置
US20240143159A1 (en) Electronic whiteboard system and operation method thereof
TW201006417A (en) Method of transforming media on digital photo frame

Legal Events

Date Code Title Description
WWE Wipo information: entry into national phase

Ref document number: 202280001034.5

Country of ref document: CN

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22939109

Country of ref document: EP

Kind code of ref document: A1