Handwriting rendering method and device, terminal equipment and storage medium

By combining adaptive sampling and Kalman filter prediction with data compression, the latency and accuracy issues of handwriting rendering in touch interaction devices are solved, achieving a balance between handwriting detail and smoothness, and improving the user's writing experience.

CN122431585APending Publication Date: 2026-07-21WUHAN FENGQI INNOVATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
WUHAN FENGQI INNOVATION TECHNOLOGY CO LTD
Filing Date
2026-03-17
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

In touch-interactive devices, existing technologies struggle to efficiently process touch point data while preserving handwriting details, improve the accuracy of handwriting direction prediction, and reduce rendering latency, resulting in insufficient writing smoothness and responsiveness.

Method used

By adaptively sampling to select necessary sampling points, using Kalman filtering to predict handwriting points, and compressing the data when the amount of data is too large, combined with a smoothing algorithm for handwriting rendering, the handwriting details and smoothness are ensured.

Benefits of technology

It effectively improves the accuracy of handwriting direction prediction, reduces rendering latency, enhances writing smoothness and responsiveness, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122431585A_ABST
    Figure CN122431585A_ABST
Patent Text Reader

Abstract

The application is suitable for the technical field of intelligent terminals, and provides a handwriting rendering method and device, a terminal device and a storage medium. The method comprises the following steps: acquiring a sampling point of a user touch input; adaptively sampling the sampling point according to the moving speed of a touch tool, and adding a determined current reserved sampling point to a to-be-drawn sequence; predicting a next-time handwriting point based on the current reserved sampling point and Kalman filtering, and adding the predicted handwriting point to the to-be-drawn sequence; when the length of the to-be-drawn sequence exceeds a preset threshold, compressing the to-be-drawn sequence by using a data compression algorithm to obtain a target sampling point sequence; and performing handwriting rendering based on the target sampling point sequence. The application can efficiently process touch point data while guaranteeing handwriting details, improve the accuracy of handwriting trend prediction, reduce rendering delay, and thus enhance the smoothness and hand-following property of writing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart terminal technology, and in particular to a handwriting rendering method, apparatus, terminal device, and storage medium. Background Technology

[0002] In touch-interactive devices such as electronic whiteboards, tablets, and touch-screen laptops, the smoothness and accuracy of handwriting rendering are key factors affecting the user's writing experience. The core of this process is to convert the user's touch input location information into visually recognizable continuous handwriting to recreate a realistic writing experience. In practical applications, handwriting rendering relies on the collection and processing of user touch sampling points. After organizing and optimizing these sampling points, the rendering output meets the user's needs for daily writing, drawing, and other scenarios.

[0003] With the increase in touch sampling rate and the continuous improvement of users' requirements for writing experience, handwriting rendering faces the challenge of balancing data processing volume and real-time performance: high sampling rate brings denser touch points, which helps to restore writing details, but also increases the computational burden of subsequent processing. At the same time, when writing quickly or when the writing direction changes drastically (such as turning), how to accurately predict the direction of the handwriting and avoid rendering lagging behind touch input has become a challenge to improve writing smoothness.

[0004] Therefore, how to efficiently process touch point data while preserving handwriting details, improve the accuracy of handwriting direction prediction, and reduce rendering latency, thereby enhancing the smoothness and responsiveness of writing, is a problem that needs to be considered. Summary of the Invention

[0005] This application provides a handwriting rendering method, apparatus, terminal device, and storage medium, which can efficiently process touch point data while ensuring handwriting details, improve the accuracy of handwriting direction prediction, and reduce rendering latency, thereby enhancing the smoothness and responsiveness of writing.

[0006] In a first aspect, embodiments of this application provide a handwriting rendering method, including: Acquire sampling points of user touch input; Based on the movement speed of the touch tool, the sampling points are adaptively sampled, and the determined currently retained sampling points are added to the drawing sequence; Based on the currently retained sampling points and Kalman filtering, predict the handwriting points at the next moment, and add the predicted handwriting points to the sequence to be drawn; When the length of the sequence to be drawn exceeds a preset threshold, a data compression algorithm is used to compress the sequence to be drawn to obtain the target sampling point sequence; Handwriting rendering is performed based on the target sampling point sequence.

[0007] In one possible implementation of the first aspect, adaptively sampling the sampling points based on the movement speed of the touch tool includes: The movement speed of the touch tool is obtained, wherein the movement speed is the instantaneous speed between the sampling point and the previous retained sampling point; A dynamic distance threshold is determined based on the instantaneous velocity, and the dynamic distance threshold is positively correlated with the instantaneous velocity; Calculate the interval distance between the sampling point and the previous retained sampling point; If the interval distance is greater than the dynamic distance threshold, the sampling point is retained.

[0008] In one possible implementation of the first aspect, predicting the handwriting point at the next time step based on the currently retained sampling point and Kalman filtering includes: Based on the optimal state estimate and error covariance matrix of the previous time step, a set of Sigma points are generated through unscented transformation; Each Sigma point is propagated through a pre-defined nonlinear process model to obtain the propagated set of Sigma points; Calculate the prior state estimate and the prior error covariance matrix based on the propagated Sigma point set; The propagated Sigma point set is transformed using a preset nonlinear observation model to obtain the observed Sigma point set; Based on the observed Sigma point set, calculate the predicted observed values, the observed covariance matrix, and the cross-covariance matrix between the state and the observed values; Calculate the Kalman gain based on the observation covariance matrix and the cross-covariance matrix; By combining the predicted observations with the actual observations of the currently retained sampling points, the prior state estimate is updated using the Kalman gain to obtain the optimal state estimate at the current time. The optimal state estimate at the current moment is substituted into the preset nonlinear process model, and the state estimate at the next moment is extrapolated to obtain the state estimate at the next moment. The coordinates are extracted from the state estimate at the next moment as predicted handwriting points.

[0009] In one possible implementation of the first aspect, before predicting the handwriting point at the next time step based on the currently retained sampling point and the Kalman filter, the unscented Kalman filter is initialized, including: Initialize the state vector, which is a six-dimensional vector including the current position coordinates, the current velocity component, and the current acceleration component. The coordinates of the first sampling point are used as the current position coordinates, and the velocity and acceleration components are initialized to zero. Initialize the error covariance matrix, the process noise covariance matrix, and the observation noise covariance matrix. The error covariance matrix, the process noise covariance matrix, and the observation noise covariance matrix are all diagonal matrices, and their diagonal elements are preset values.

[0010] In one possible implementation of the first aspect, the step of compressing the sequence to be drawn using a data compression algorithm to obtain a target sampling point sequence includes: Using the current time as the endpoint, select the N points in the sequence to be drawn that are closest to the current time to form a sliding window, where N is the preset sliding window length; Recursive compression is performed on the point set within the sliding window. The recursive compression includes: connecting the first point and the last point within the sliding window to form a baseline segment; calculating the vertical distance from each intermediate point within the sliding window to the baseline segment; determining the maximum vertical distance and its corresponding maximum distance point; if the maximum vertical distance is less than a preset compression tolerance, discarding all intermediate points within the sliding window and retaining only the first point and the last point; if the maximum vertical distance is greater than or equal to the preset compression tolerance, dividing the point set within the sliding window into two sub-parts using the maximum distance point as the dividing point, and repeating the recursive compression for each sub-part until the maximum vertical distance of all sub-parts is less than the preset compression tolerance. All points that were not discarded were retained in sequence as the compression result, resulting in the target sampling point sequence.

[0011] In one possible implementation of the first aspect, the handwriting rendering based on the target sampling point sequence includes: The target sampling point sequence is smoothly fitted using a preset smoothing algorithm.

[0012] In one possible implementation of the first aspect, after performing handwriting rendering based on the target sampling point sequence, the method further includes: If a pen lift event is detected, the rendering of the current handwriting will end; If no pen lift event is detected, return to the step of obtaining the sampling point of user touch input and continue processing the next sampling point.

[0013] Secondly, embodiments of this application provide a handwriting rendering apparatus, including: An adaptive sampling unit is used to acquire sampling points of user touch input; based on the movement speed of the touch tool, the sampling points are adaptively sampled, and the determined currently retained sampling points are added to the drawing sequence; The handwriting prediction unit is used to predict the handwriting points at the next moment based on the currently retained sampling points and Kalman filtering, and add the predicted handwriting points to the sequence to be drawn. The sampling compression unit is used to compress the sequence to be drawn using a data compression algorithm when the length of the sequence to be drawn exceeds a preset threshold, so as to obtain a target sampling point sequence. The handwriting rendering unit is used to perform handwriting rendering based on the target sampling point sequence.

[0014] Thirdly, embodiments of this application provide a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the handwriting rendering method as described in the first aspect above.

[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the handwriting rendering method as described in the first aspect above.

[0016] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, causes the terminal device to execute the handwriting rendering method described in the first aspect above.

[0017] In this embodiment, by acquiring the sampling points of the user's touch input and adaptively sampling these points, necessary sampling points can be selected and retained according to the actual writing situation. While avoiding sampling point redundancy, key handwriting details such as pen strokes are effectively preserved, achieving an initial balance between handwriting details and data processing efficiency. Then, based on the currently retained sampling points and the unscented Kalman filter, the handwriting points at the next moment are predicted, and the predicted handwriting points are added to the drawing sequence. This allows for advance prediction of handwriting direction, effectively compensating for the time difference between touch input and rendering, reducing handwriting lag and breakage, and significantly improving the accuracy of handwriting direction prediction. When the length of the drawing sequence exceeds a preset threshold, a data compression algorithm is used to compress it to obtain the target sampling point sequence, further eliminating redundant data, reducing the load on data processing and rendering, achieving efficient processing of touch point data, and avoiding rendering delays caused by excessive data volume. Finally, handwriting rendering is performed based on the target sampling point sequence, ensuring that the rendered handwriting retains key details and has good smoothness, effectively improving the responsiveness of writing. This proposed solution can efficiently process touch point data while preserving handwriting details, improve the accuracy of handwriting direction prediction, and reduce rendering latency, effectively enhancing the smoothness and responsiveness of the writing process and improving the user's writing experience. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart illustrating the implementation of the handwriting rendering method provided in this application embodiment; Figure 2 This is a flowchart illustrating a specific implementation of adaptive sampling in the handwriting rendering method provided in this application embodiment; Figure 3 This is a flowchart illustrating a specific implementation of step S103 in the handwriting rendering method provided in this application embodiment; Figure 4 This is a flowchart illustrating a specific implementation of the handwriting rendering method provided in this application for obtaining a target sampling point sequence; Figure 5 This is a flowchart illustrating a specific implementation of recursive compression in the handwriting rendering method provided in this application embodiment; Figure 6 This is a flowchart illustrating a specific implementation of pen-lifting event handling in the handwriting rendering method provided in this application embodiment; Figure 7 This is a structural block diagram of the handwriting rendering device provided in the embodiments of this application; Figure 8 This is a schematic diagram of the terminal device provided in the embodiments of this application. Detailed Implementation

[0020] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0021] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0022] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0023] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0024] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0025] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0026] By way of example and not limitation, the handwriting rendering method provided in this application is applicable to various types of terminal devices that need to perform handwriting rendering. Specific terminal devices may include mobile phones, tablets, electronic whiteboards, wearable devices, laptops, ultra-mobile personal computers (UMPCs), desktop computers, smart interactive screens, and servers, etc. This application does not impose any restrictions on the specific type of terminal device.

[0027] Figure 1 The implementation flow of the handwriting rendering method provided in this application embodiment is illustrated. The method flow includes steps S101 to S105. The specific implementation principle of each step is as follows: Step S101: Obtain the sampling points of the user's touch input.

[0028] A sampling point refers to a basic data point that reflects the position of the user's pen tip, collected in real time by the touch interaction device when the user performs a writing operation. In touch interaction devices such as electronic whiteboards, tablets, or touch laptops, when a user uses a touch tool (such as a finger or stylus) to write or draw on the screen, the touch sensor built into the touch interaction device collects the position information of the touch tool in contact with the screen at fixed time intervals. In one possible implementation, each sampling point includes two-dimensional coordinate information (x, y) and the timestamp information t when the point was collected.

[0029] Sampling points are the basic elements that constitute the handwriting trajectory. By acquiring sampling points, the original input signals are provided for the entire handwriting rendering process.

[0030] Step S102: Based on the movement speed of the touch tool, adaptively sample the sampling points and add the determined currently retained sampling points to the drawing sequence.

[0031] Touch tools refer to the tools used by users for handwriting input, including but not limited to styluses, fingers, and other tools that can effectively interact with touch devices. Their movement directly determines the distribution of sampling points and the direction of handwriting. Currently retained sampling points are those that, after adaptive sampling processing, are determined to retain handwriting details and do not require removal. The drawing sequence is a collection of sampling points to be processed for subsequent prediction, compression, and rendering. It uses an ordered storage method, storing the currently retained sampling points sequentially according to their acquisition time. Adding the currently retained sampling points to the drawing sequence provides an ordered set of processing objects for subsequent handwriting point prediction based on these points, ensuring the consistency and accuracy of the prediction process.

[0032] Because touch sensors typically sample at a relatively high fixed frequency, when the user writes slowly, a large number of redundant dots with very close spatial distances are generated; while when the writing speed is fast, the spacing between dots increases.

[0033] To balance the relationship between data volume and the preservation of handwriting details, this application embodiment adaptively samples the sampling points based on the movement speed of the touch tool. Adaptive sampling dynamically adjusts the retention rules of sampling points according to the movement speed of the user's pen tip or finger during writing, selecting sampling points that can reflect key handwriting features and eliminating redundant samples. The sampling point retention rules are related to the movement speed of the touch tool, enabling dynamic adjustment of the sampling density.

[0034] As one possible implementation of this application Figure 2 The following is a detailed description of a specific implementation flow of adaptive sampling in the handwriting rendering method provided in this application embodiment: A1: Obtain the movement speed of the touch tool, where the movement speed is the instantaneous speed between the sampling point and the previous retained sampling point. The previous retained sampling point refers to the sampling point that was determined to be retained after the previous adaptive sampling judgment and used as the benchmark for subsequent sampling point judgments. It serves as the reference benchmark for the current sampling point, ensuring the continuity of sampling interval judgments.

[0035] In one possible implementation, the coordinate difference between the current sampling point and the previous retained sampling point is calculated along with the acquisition time difference. The instantaneous speed is obtained based on the ratio of this coordinate difference to the acquisition time difference. The instantaneous rate at which the touch tool moves between two adjacent sampling points (the current sampling point and the previous retained sampling point) can intuitively reflect the speed of the user's writing.

[0036] A2: Determine the dynamic distance threshold based on the instantaneous velocity, wherein the dynamic distance threshold is positively correlated with the instantaneous velocity.

[0037] The dynamic distance threshold is a critical distance value used to determine whether the current sampling point needs to be retained. It is positively correlated with the instantaneous speed. That is, the faster the instantaneous speed, the larger the dynamic distance threshold, and the slower the instantaneous speed, the smaller the dynamic distance threshold. This enables the sampling density to be dynamically adjusted according to the writing speed.

[0038] In one possible implementation, the dynamic distance threshold is determined according to the following calculation formula (1). : (1) Where v is the instantaneous velocity, that is, the velocity at the current sampling point; D max The preset maximum threshold is used to limit the upper limit of the dynamic distance threshold and avoid the loss of handwriting details due to excessively large sampling intervals; D min The preset minimum threshold is used to limit the lower limit of the dynamic distance threshold and avoid sampling point redundancy caused by excessively small sampling intervals; The preset speed coefficient is used to adjust the degree of influence of instantaneous speed on the dynamic distance threshold.

[0039] For example, D max The value can be 4, the D min The value can be 0.3. The value can be 0.14, which is a reasonable value that has been tested and verified to ensure the rationality of the dynamic distance threshold and to balance handwriting details and data processing efficiency.

[0040] A3: Calculate the distance between the sampling point and the previous retained sampling point.

[0041] Interval distance refers to the straight-line distance between a sampling point and the previous retained sampling point, reflecting the spatial positional difference between the two sampling points. This interval distance can be calculated using the formula for the distance between two points in space, that is, by calculating the straight-line distance based on the coordinate data of the two sampling points.

[0042] A4: If the interval distance is greater than the dynamic distance threshold, then the sampling point is retained. Retaining a sampling point means determining the current sampling point as the currently retained sampling point, which will be added to the sequence to be drawn later.

[0043] In one possible implementation, if the interval distance is less than or equal to the dynamic distance threshold, the sampling point is skipped, that is, the sampling point is directly discarded to avoid it becoming redundant data and thus increasing the subsequent data processing load.

[0044] For example, if the interval distance If the sampling point is retained, then the interval distance is... This determines whether to skip the sampling point.

[0045] Adaptive sampling refers to dynamically adjusting the retention strategy for sampling points based on the movement speed of the touch tool. In this embodiment, adaptive filtering of sampling points is achieved by comparing the interval distance with a dynamic distance threshold. When the touch tool moves quickly, the dynamic distance threshold is larger, the sampling interval automatically increases, and only points with larger intervals are retained, while dense and redundant sampling points are eliminated, reducing the subsequent data processing load. When the movement speed is slow, the dynamic distance threshold is smaller, the sampling interval automatically decreases, and more sampling points with smaller intervals are retained, effectively preserving the detailed features of handwriting (such as pen strokes or jitter), achieving a preliminary balance between handwriting details and data processing efficiency.

[0046] Step S103: Based on the currently retained sampling points and Kalman filtering, predict the handwriting points at the next moment and add the predicted handwriting points to the sequence to be drawn.

[0047] Kalman filtering is a recursive filtering algorithm used for system state estimation, capable of estimating the system state from noisy observation data. In the embodiments of this application, an unscented Kalman filter is preferably used, which is an extension of Kalman filtering.

[0048] The unscented Kalman filter (UKF) is a filtering algorithm used for state estimation of nonlinear systems. By predicting the next position of handwriting using the UKF, the inherent time delay between touch input and screen rendering can be compensated for. The predicted handwriting point is the predicted touch position of the user's handwriting tool at the next moment, which, together with the currently retained sampling points, constitutes the complete data of the sequence to be drawn. The sequence to be drawn further stores the predicted handwriting points, achieving unified management of the currently retained sampling points and the predicted handwriting points. In this embodiment, the nonlinear prediction advantage of the UKF, combined with the actual data of the currently retained sampling points, accurately predicts the handwriting point at the next moment, anticipates the handwriting direction in advance, effectively compensates for the time difference between touch input and handwriting rendering, and reduces handwriting lag and breaks.

[0049] In one possible implementation, the unscented Kalman filter is initialized before predicting handwriting points based on the filter to establish its initial state and initial uncertainties. This initialization process includes initializing the state vector, as well as initializing the error covariance matrix, process noise covariance matrix, and observation noise covariance matrix.

[0050] First, initialize the state vector, which is a six-dimensional vector including the current position coordinates, the current velocity component, and the current acceleration component. The coordinates of the first sampling point are used as the current position coordinates, and the velocity and acceleration components are initialized to zero.

[0051] For example, the state vector can be represented as ,in, and These represent the position coordinates of the sampling point on the x-axis and y-axis, respectively. and These represent the velocity components of the sampling point on the x-axis and y-axis, respectively. and These represent the acceleration components of the sampling point on the x-axis and y-axis, respectively. At the initialization moment, i.e., when processing the first acquired sampling point, the coordinates of this first sampling point are used as the current position coordinates in the state vector. Since the writing action has just begun, the movement speed and acceleration of the touch tool have not yet been established; therefore, both the current speed component and the current acceleration component are initialized to zero. For example, let the coordinates of the first sampling point be (...). , If ), then the initialized state vector is: .

[0052] Initializing the state vector provides a reasonable starting point for the motion state of the unscented Kalman filter, enabling the filter to track the handwriting motion from the initial moment.

[0053] Next, the error covariance matrix is ​​initialized. The error covariance matrix is ​​used to describe the uncertainty of the state vector estimation. In this embodiment, the error covariance matrix is ​​initialized as a diagonal matrix, with its diagonal elements being preset values. For example, this error covariance matrix... It can be expressed as the following formula (2): (2) in, and These represent the uncertainties in estimating the x and y coordinates, respectively. and These represent the uncertainties in estimating the x-axis velocity and the y-axis velocity, respectively. and These represent the uncertainties in the estimation of x-axis acceleration and y-axis acceleration, respectively.

[0054] Considering the initial state is relatively vague, especially the significant uncertainty in velocity and acceleration, one possible implementation is to set the diagonal elements of the error covariance matrix as follows: , , , , , ,Right now: .

[0055] The purpose of initializing the error covariance matrix is ​​to quantify the uncertainty of the filter's initial state, providing a basis for subsequent Kalman gain calculation and state update.

[0056] Furthermore, the process noise covariance matrix is ​​initialized. The process noise covariance matrix describes the uncertainties present in the motion model (i.e., the state transition process), such as user jitter or changes in intent during writing. In this embodiment, the process noise covariance matrix is ​​initialized as a diagonal matrix, with its diagonal elements being preset values. This process noise covariance matrix... It can be expressed as the following formula (3): (3) in, and These represent the process noise at the position coordinates, and These represent process noise at different speeds. and These represent process noise in acceleration, respectively.

[0057] Considering that position measurement is relatively accurate during the writing process, while acceleration changes are the most drastic and uncertain, one possible implementation is to set the diagonal elements of the process noise covariance matrix as follows: , , , , , ,Right now: .

[0058] The purpose of initializing the noise covariance matrix is ​​to introduce an expectation of model uncertainty into the filter, so that the filter can adapt to the deviation between the actual writing process and the ideal uniform acceleration model.

[0059] Finally, the observation noise covariance matrix is ​​initialized. The observation noise covariance matrix describes the uncertainty or noise present in the sensor observations (i.e., the coordinates of the acquired sampling points). In this embodiment, the observation noise covariance matrix is ​​initialized as a diagonal matrix, with its diagonal elements being preset values. Since the only observable quantity is the coordinates of the sampling points, the observation noise covariance matrix... As a two-dimensional matrix, it can be represented as follows (4): (4) in, and These represent the observation noise at the x and y coordinates, respectively.

[0060] Considering that the sampling point coordinates of interactive whiteboards and other touch-screen devices typically have high precision, one possible implementation is to set the diagonal elements of the observation noise covariance matrix as follows: , That is: R=diag([1,1]).

[0061] The purpose of initializing the observation noise covariance matrix is ​​to quantify the reliability of sensor measurements, so that the filter can reasonably weigh the weights between the predicted and actual observations during the update phase.

[0062] In this embodiment, an initial state vector and matrices describing uncertainty are established by initializing the unscented Kalman filter: the error covariance matrix, the process noise covariance matrix, and the observation noise covariance matrix. The state vector provides motion parameters for subsequent predictions, the error covariance matrix reflects the confidence level of the initial state, the process noise covariance matrix reserves adjustment space for model non-idealities, and the observation noise covariance matrix reflects the sensor's measurement accuracy. These initialization parameters collectively constitute the starting point for the filter's recursive operation, ensuring that the filter can iteratively optimize the estimation of handwriting motion state as new currently retained sampling points are continuously input in subsequent processing, thereby achieving accurate prediction of future handwriting points.

[0063] As one possible implementation of this application Figure 3 A specific implementation flow of step S103 in the handwriting rendering method provided in this application embodiment is shown below: B1: Based on the optimal state estimate and error covariance matrix from the previous time step, a set of Sigma points is generated through an unscented transformation. Sigma points are sampling points with defined weights generated through the unscented transformation.

[0064] In unscented Kalman filters, an unscented transform is needed to approximate the probability distribution of the state vector. In this embodiment, the optimal estimate of the handwriting motion state at the previous time step is first obtained, i.e., the optimal state estimate at the previous time step. and the error covariance matrix describing the uncertainty of this estimate. ,based on and A set of Sigma points is generated through an unscented transformation. The number of Sigma points is determined by the dimension L of the state vector, resulting in a total of 2L+1 points. The generation method of the Sigma points ensures that the sample mean and sample covariance of these points are consistent with... and By maintaining consistency, the main statistical characteristics of the original continuous distribution are captured using a discrete set of points.

[0065] In one possible implementation, when generating Sigma points, firstly... Cholesky decomposition yields the square root matrix. : Where λ is the scaling parameter calculated from the filter parameters α and κ, then a set of 2L+1 Sigma points are generated according to the following equation (5). : (5) Where x is the optimal state estimate at the previous time step. Let represent the i-th column vector of the square root matrix S. When i=0, it is the state vector itself. When i=1 to L, it is the state vector plus the corresponding column vector of matrix S. When i=L+1 to 2L, it is the state vector minus the corresponding column vector of S.

[0066] For the initial case, substitute... , Obtain the initial Sigma point. For non-initial cases, substitute... , Obtain the k-th Sigma point.

[0067] Sigma points are generated through unscented transformation, and discrete sampling points are used to approximate the nonlinear probability distribution of the state vector, thus avoiding linearization errors.

[0068] B2: Propagate each Sigma point through a preset nonlinear process model to obtain the propagated Sigma point set.

[0069] Propagating each Sigma point through a preset nonlinear process model means substituting each generated Sigma point into the preset nonlinear process model to calculate the state of each Sigma point at the next time step, i.e., the propagated Sigma point, and obtaining a new set of points, i.e., the propagated Sigma point set, which contains 2L+1 propagated Sigma points.

[0070] In one possible implementation, the preset nonlinear process model is shown in equation (6): (6) in, Let be the state vector of the previous time step (i.e., the Sigma point), and Δt be the time interval between the previous time step and the current time step. , These are the x-axis and y-axis coordinates of the previous moment. , The x-axis and y-axis velocities at the previous moment. , These represent the x-axis and y-axis accelerations at the previous moment. The Sigma point after propagation. The calculation formula is: ,in This is the i-th Sigma point generated in step B1. The propagated Sigma point is a six-dimensional state vector.

[0071] The preset nonlinear process model is a mathematical equation describing the evolution of handwriting motion over time. Based on a dynamic model of the writing process, it describes the changing patterns of the touch tool's motion state. This preset nonlinear process model accurately reflects the recursive relationships between coordinates, velocity, and acceleration in the state vector, closely matching the actual motion characteristics of the touch tool during handwriting and avoiding the inability of linear models to adapt to abrupt changes in handwriting direction. By propagating the preset nonlinear process model to each Sigma point, the changing process of the touch tool's motion state is simulated, transforming discrete Sigma points into sampling points that reflect the state at the next moment.

[0072] B3: Calculate the prior state estimate and prior error covariance matrix based on the propagated Sigma point set.

[0073] After obtaining the propagated Sigma point set, the prior state estimate of the system at the next moment is calculated based on the propagated Sigma points and their corresponding weights in the Sigma point set. The prior state estimate is a six-dimensional vector with the same structure as the state vector, containing parameters such as coordinates, velocity, and acceleration, which is used to preliminarily predict the motion state of the touch tool at the current moment.

[0074] One possible implementation involves weighted summation of the propagated Sigma point set to obtain the prior state estimate. As shown in equation (7): (7) in, The weights used to calculate the mean for the i-th Sigma point are as follows (8): (8) The weighted dispersion of these propagated Sigma points around the prior state estimate is calculated to obtain the prior error covariance matrix. As shown in equation (9): (9) in, The process noise covariance matrix is... The weights used to calculate the covariance for the i-th Sigma point are as follows (10): (10) By calculating the prior state estimate and the prior error covariance matrix, a new Gaussian distribution is reconstructed from a set of discrete post-propagation sample points, thus completing the prediction of the system state.

[0075] B4: The propagated Sigma point set is transformed using a preset nonlinear observation model to obtain the observed Sigma point set.

[0076] Transforming the propagated Sigma point set using a pre-defined nonlinear observation model involves substituting each propagated Sigma point into the pre-defined nonlinear observation model, extracting its position coordinate parameters, and obtaining the corresponding observation value. The observation Sigma point set refers to the collection of all transformed observation values. Each observation Sigma point is a two-dimensional vector (containing only x-axis and y-axis coordinates), and its number is the same as the propagated Sigma point set (2L+1).

[0077] In one possible implementation, the preset nonlinear process model is shown in equation (11): (11) Where x is the propagated Sigma point (a six-dimensional state vector), and h(x) is the observation transformation function. For observation noise (default value is 0) The resulting observation z is a two-dimensional vector containing only x-axis and y-axis coordinates. (Observation Sigma point) The calculation formula is: ,in Let Σ be the i-th propagated Sigma point obtained in step B2.

[0078] The preset nonlinear observation model is used to convert the propagated Sigma points into observable parameters (position coordinates). It represents a linear observation relationship, extracting only the x-axis and y-axis coordinates from the state vector as observation values. The preset nonlinear observation model describes the mapping relationship between the system state and sensor observations. By using this model, the six-dimensional propagated Sigma points are converted into two-dimensional observed Sigma points, aligning with the actual observation capabilities of touch devices and extracting directly observable position coordinate parameters.

[0079] B5: Based on the observed Sigma point set, calculate the predicted observed values, the observed covariance matrix, and the cross-covariance matrix between the state and the observed values.

[0080] Predicted observations represent the sampling point locations that are most likely to be observed at the next time step, based on the current model prediction.

[0081] In one possible implementation, the predicted observations are obtained by weighted summation of the observed Sigma point set as shown in equation (12). : (12) The observation covariance matrix is ​​determined according to the following equation (13). : (13) The observation covariance matrix reflects the uncertainty of the model's prediction of the observed values, where To observe the noise covariance matrix; According to the following equation (14), the cross-covariance matrix of state and observation is... : (14) The cross-covariance matrix quantifies the correlation between state prediction error and observation prediction error.

[0082] B6: Calculate the Kalman gain based on the observation covariance matrix and the cross-covariance matrix.

[0083] Kalman gain is a core parameter in an unscented Kalman filter used to balance the weights of prior state estimates and actual observations. It reflects whether the prior state estimate or the actual observation should be trusted first when updating the state. The larger the Kalman gain, the more reliable the actual observation; the smaller the Kalman gain, the more reliable the prior state estimate.

[0084] In one possible implementation, the Kalman gain is calculated according to the following equation (15). : (15) By calculating the Kalman gain, the weight ratio of prior state estimates and actual observations in state updates is determined, thereby ensuring that state updates can balance the rationality of prior predictions and the accuracy of actual observations, and reduce prediction errors.

[0085] B7: Combining the predicted observations with the actual observations of the currently retained sampling points, the prior state estimate is updated using the Kalman gain to obtain the optimal state estimate at the current time.

[0086] Use the coordinates of the currently retained sampling point as the actual observation value at the current moment. Using the calculated Kalman gain Combined with predicted observations The prior state estimate obtained in step B3 Make corrections to obtain the optimal state estimate for the current time step. : , This indicates the difference between actual observations and model predictions.

[0087] Simultaneously, the error covariance matrix needs to be updated: ,in Let be the prior error covariance matrix. To observe the covariance matrix, Let be the transpose of the Kalman gain. The updated error covariance matrix is ​​used to generate the Sigma point at the next time step.

[0088] By combining the predicted observations with the actual observations of the currently retained sampling points, the prior state estimate is corrected using Kalman gain, eliminating errors in the prior estimate and ensuring that the state estimate accurately matches the actual motion state of the touch tool, thereby further improving the accuracy of handwriting point prediction.

[0089] B8: Substitute the optimal state estimate at the current moment into the preset nonlinear process model, extrapolate to obtain the state estimate at the next moment, and extract the coordinates from the state estimate at the next moment as predicted handwriting points.

[0090] In one possible implementation, the state estimate for the next time step is extrapolated according to the following equation (16). : (16) in, The optimal state estimate at the current moment, f(x), is the preset nonlinear process model in step B2, Δt is the time interval between the current moment and the next moment, and the predicted handwriting points are the first two parameters in the state estimate for the next moment, i.e. (x-axis coordinate) and (y-axis coordinate), extract it and add it to the sequence to be drawn.

[0091] By extrapolating to obtain the state estimate of the next moment and extracting the predicted handwriting points, the direction of the handwriting can be predicted in advance. Adding the predicted handwriting points to the drawing sequence can make up for the time difference between touch input and handwriting rendering, reduce handwriting lag and breakage, improve the smoothness and responsiveness of writing, and provide complete data to be processed for subsequent data compression and handwriting rendering, ensuring the continuity of the entire handwriting rendering process.

[0092] Step S104: When the length of the sequence to be drawn exceeds a preset threshold, the sequence to be drawn is compressed using a data compression algorithm to obtain the target sampling point sequence.

[0093] The preset threshold refers to a pre-defined critical value for the length of the sequence to be drawn. In one possible implementation, its value can be determined based on the rendering performance of the touch interaction device, the user's writing speed, and other practical scenarios.

[0094] The target sampling point sequence refers to the set of sampling points that have been processed by the data compression algorithm, after which redundant sampling points have been removed and only key handwriting feature points have been retained. It is the direct processing object for subsequent handwriting rendering.

[0095] Data compression algorithms are used to remove redundant sampling points from a sequence to be drawn while retaining key handwriting features. The data compression algorithm used in this application embodiment can reduce the number of sampling points and lower the data processing load without affecting the handwriting reproduction accuracy.

[0096] In one possible implementation, the data compression algorithm is specifically the Douglas-Puk algorithm.

[0097] For example, with a preset threshold of 12, when the total number of currently retained sampling points and predicted handwriting points stored in the sequence to be drawn reaches 13, the data compression algorithm is triggered. The data compression algorithm processes the 13 sampling points in the sequence to be drawn, removing duplicate and redundant sampling points, and retaining only the sampling points that can completely reflect the direction of the handwriting and key details. If 8 sampling points are obtained after the data compression algorithm, the set of these 8 sampling points is the target sampling point sequence. Its data volume is reduced compared to the sequence to be drawn, and the key features of the handwriting are completely preserved.

[0098] In this embodiment, a data compression process is triggered based on a preset threshold to avoid excessive data processing and rendering load caused by an excessively long sequence length. Furthermore, a data compression algorithm is used to remove redundant sampling points, which can achieve efficient processing of touch point data, reduce the computational pressure of subsequent handwriting rendering, and at the same time retain key handwriting feature points to ensure that the handwriting rendered in the subsequent process can restore the real writing details, thereby further balancing data processing efficiency and handwriting restoration accuracy.

[0099] As one possible implementation of this application Figure 4 A specific implementation flow of step S104 in the handwriting rendering method provided in this application embodiment is shown below: C1: Using the current time as the endpoint, select the N points in the sequence to be drawn that are closest to the current time to form a sliding window, where N is a preset sliding window length. For example, N can be 12, meaning 12 points form the sliding window.

[0100] The sequence to be drawn is a dynamically growing queue, containing retained sampling points and predicted handwriting points based on these retained sampling points. To effectively manage the continuously accumulating data, this embodiment employs a sliding window mechanism to locally compress the newly generated points. Specifically, taking the current processing time as the endpoint, N consecutive points are selected from the end of the sequence to be drawn backwards, and the points within the sliding window are dynamically updated as the current time changes.

[0101] By selecting the N most recent points to form a sliding window, the range of data compression is limited, ensuring that the compression process only targets the latest sampling points that are related to the direction of the handwriting. This avoids invalid compression of earlier irrelevant sampling points, which not only improves the efficiency of data compression but also ensures that the compression process fits the current direction of the handwriting, preventing the loss of key details of the handwriting due to an excessively large compression range.

[0102] C2: Perform recursive compression on the point set within the sliding window. For example... Figure 5 As shown, the recursive compression includes: C21: Connect the first and last points within the sliding window to form a baseline segment.

[0103] The first point refers to the earliest point to enter the sliding window in chronological order, while the last point refers to the most recently added point in chronological order. Both are key feature points within the sliding window, reflecting the overall direction of the handwriting. The baseline segment is the straight line connecting the first and last points, visually reflecting the overall trend of the handwriting within the sliding window and providing a reference standard for filtering redundant points.

[0104] C22: Calculate the vertical distance from each midpoint within the sliding window to the baseline segment, and determine the maximum vertical distance and its corresponding maximum distance point.

[0105] Intermediate points refer to all sampling points within the sliding window, excluding the first and last points. The distribution density of intermediate points reflects the redundancy of the sequence to be drawn. After establishing the baseline segment, all intermediate points within the sliding window located between the first and last points are traversed. For each intermediate point, its vertical distance to the baseline segment is calculated. This vertical distance is the shortest distance from each intermediate point to the baseline segment, quantifying the contribution of that intermediate point to the curve shape. The larger the vertical distance, the greater the curvature of the curve at that intermediate point, and the more important that intermediate point is for maintaining the original shape of the handwriting, thus requiring preservation. After calculating the vertical distances of all intermediate points, the one with the largest vertical distance is found, and the intermediate point that generates this maximum distance is recorded as the maximum distance point.

[0106] C23: If the maximum vertical distance is less than the preset compression tolerance, then discard all intermediate points within the sliding window and retain only the first point and the last point.

[0107] The preset compression tolerance is a pre-defined threshold for controlling the degree of compression, representing the allowable range of simplification errors. If the maximum vertical distance is less than the preset compression tolerance, it indicates that the deviation of all intermediate points within the sliding window from the baseline segment is within an acceptable error range. That is, the presence or absence of these intermediate points has minimal impact on the overall shape of the handwriting curve. In this case, to maximize data simplification, all intermediate points within the sliding window except for the first and last points can be discarded, retaining only the first and last points as representatives of this curve. In one possible implementation, the preset compression tolerance can be set to 0.8.

[0108] C24: If the maximum vertical distance is greater than or equal to the preset compression tolerance, then the point set in the sliding window is divided into two sub-parts using the maximum distance point as the dividing point, and the recursive compression is repeated for each sub-part until the maximum vertical distance of all sub-parts is less than the preset compression tolerance.

[0109] If the maximum vertical distance is greater than or equal to the preset compression tolerance, it indicates that at least one point (i.e., the maximum distance point) contributes to the curve shape beyond the acceptable error range and cannot be simply discarded. In this case, the maximum distance point needs to be retained, and the current sliding window point set should be divided into two independent sub-parts using the maximum distance point as the boundary: one sub-part is the point set from the first point of the window to the maximum distance point, and the other sub-part is the point set from the maximum distance point to the last point of the window.

[0110] After segmentation, for each newly generated sub-part, the entire recursive compression process starting from step C21 is executed independently and repeatedly (i.e., reconnecting the beginning and end points of the sub-part to form a baseline segment, calculating the vertical distance between intermediate points, comparing tolerances, and deciding whether to discard or segment again). This process is continuously recursively performed until the maximum vertical distance within all sub-parts during recursive processing is less than the preset compression tolerance. Through the divide-and-conquer strategy, feature points that play a decisive role in the curve shape are precisely preserved, while flat areas are simplified, thereby achieving a balance between shape preservation and compression overall.

[0111] C3: Retain all the points that were not discarded in order as the compression result to obtain the target sampling point sequence.

[0112] After one or more rounds of recursive compression, the original set of points within the sliding window is simplified into a set of retained points. These retained points include the first and last points of the window, as well as all maximum distance points retained as segmentation points during the recursive process because their maximum vertical distance is greater than or equal to the preset compression tolerance. In this embodiment, these points are arranged strictly according to their chronological order in the original sequence to be drawn, forming a new point sequence with fewer points, namely the target sampling point sequence, providing a data foundation for efficient and smooth handwriting rendering.

[0113] Step S105: Perform handwriting rendering based on the target sampling point sequence.

[0114] Handwriting rendering is the process of converting a sequence of target sampling points into visually recognizable continuous handwriting. Specifically, based on the positional information of each sampling point in the target sampling point sequence, discrete sampling points are connected into continuous, smooth lines using methods such as curve fitting, ultimately displayed on the touchscreen interface. The target sampling point sequence, as the processing object for handwriting rendering, undergoes data compression and optimization while retaining key handwriting features, ensuring an efficient and accurate rendering process.

[0115] In one possible implementation, the target sampling point sequence is smoothly fitted using a preset smoothing algorithm. This preset smoothing algorithm can be a Bézier curve or a B-spline, or any other smoothing algorithm; no limitation is made in this embodiment. For example, Bézier curves or B-spline curves are used to interpolate or approximate discrete target sampling points to generate a smooth curve path, which is then ultimately used to draw an ink effect on the screen.

[0116] As one possible implementation of this application Figure 6 The following is a detailed implementation flow of pen-lifting event handling in the handwriting rendering method provided in this application embodiment: D1: If a pen lift event is detected, the rendering of the current handwriting ends.

[0117] D2: If no pen lift event is detected, return to the step of obtaining the sampling point of user touch input and continue processing the next sampling point.

[0118] A pen-lift event refers to an event in which a user stops touch input. Specifically, it occurs when the touch tool (stylus, finger, etc.) separates from the touch surface of the touch device, causing the touch device to be unable to continue collecting valid sampling points. The pen-lift event directly reflects the user's intention to terminate the current writing operation and is a key indicator for distinguishing different continuous handwriting segments.

[0119] The current handwriting refers to the continuous writing trajectory formed by the user through touch input from the moment the pen touches the touch surface to the moment the pen is lifted (the moment the pen leaves the touch surface). It consists of a series of continuous current retained sampling points, predicted handwriting points and target sampling points, and is a complete writing unit (such as a Chinese character, a letter, or a line segment).

[0120] In one possible implementation, when a pen lift event is detected, the rendering operation of the target sampling point sequence corresponding to the current handwriting is stopped, completing the visual presentation of the current continuous handwriting. If no pen lift event is detected, it indicates that the touch tool is still in contact with the screen and the user is continuing to write in the current stroke. At this time, the current handwriting rendering process is not yet complete, and it is necessary to continue receiving and processing subsequent inputs to ensure that the handwriting rendering remains synchronized with the user's real-time writing action, thereby forming a smooth and uninterrupted writing trajectory.

[0121] As can be seen from the above, in this embodiment, by acquiring the sampling points of the user's touch input and adaptively sampling these sampling points, necessary sampling points can be selected and retained according to the actual writing situation. While avoiding sampling point redundancy, key handwriting details such as pen strokes are effectively preserved, achieving a preliminary balance between handwriting details and data processing efficiency. Then, based on the currently retained sampling points and the unscented Kalman filter, the handwriting points at the next moment are predicted, and the predicted handwriting points are added to the drawing sequence. This allows for advance prediction of handwriting direction, effectively compensating for the time difference between touch input and rendering, reducing handwriting lag and breakage, and significantly improving the accuracy of handwriting direction prediction. When the length of the drawing sequence exceeds a preset threshold, a data compression algorithm is used to compress it to obtain the target sampling point sequence, further eliminating redundant data, reducing the load on data processing and rendering, achieving efficient processing of touch point data, and avoiding rendering delays caused by excessive data volume. Finally, handwriting rendering is performed based on the target sampling point sequence, ensuring that the rendered handwriting retains key details and has good smoothness, effectively improving the responsiveness of writing. This proposed solution can efficiently process touch point data while preserving handwriting details, improve the accuracy of handwriting direction prediction, and reduce rendering latency, effectively enhancing the smoothness and responsiveness of the writing process and improving the user's writing experience.

[0122] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0123] Corresponding to the handwriting rendering method described in the above embodiments, Figure 7 A structural block diagram of the handwriting rendering apparatus provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.

[0124] Reference Figure 7 The handwriting rendering device includes: an adaptive sampling unit 71, a handwriting prediction unit 72, a sampling compression unit 73, and a handwriting rendering unit 74, wherein: The adaptive sampling unit 71 is used to acquire sampling points of user touch input; according to the movement speed of the touch tool, the sampling points are adaptively sampled, and the determined currently retained sampling points are added to the drawing sequence; The handwriting prediction unit 72 is used to predict the handwriting point at the next moment based on the currently retained sampling point and Kalman filtering, and add the predicted handwriting point to the sequence to be drawn. The sampling compression unit 73 is used to compress the sequence to be drawn using a data compression algorithm when the length of the sequence to be drawn exceeds a preset threshold, so as to obtain a target sampling point sequence. The handwriting rendering unit 74 is used to perform handwriting rendering based on the target sampling point sequence.

[0125] As one possible implementation of this application, the adaptive sampling unit 71 includes: A speed acquisition module is used to acquire the movement speed of the touch tool, wherein the movement speed is the instantaneous speed between the sampling point and the previous retained sampling point; A dynamic threshold determination module is used to determine a dynamic distance threshold based on the instantaneous velocity, wherein the dynamic distance threshold is positively correlated with the instantaneous velocity; An interval distance determination module is used to calculate the interval distance between the sampling point and the previous retained sampling point; The sampling module is used to retain the sampling point if the interval distance is greater than the dynamic distance threshold.

[0126] As one possible implementation of this application, the handwriting prediction unit 72 is specifically used for: Based on the optimal state estimate and error covariance matrix of the previous time step, a set of Sigma points are generated through unscented transformation; Each Sigma point is propagated through a pre-defined nonlinear process model to obtain the propagated set of Sigma points; Calculate the prior state estimate and the prior error covariance matrix based on the propagated Sigma point set; The propagated Sigma point set is transformed using a preset nonlinear observation model to obtain the observed Sigma point set; Based on the observed Sigma point set, calculate the predicted observed values, the observed covariance matrix, and the cross-covariance matrix between the state and the observed values; Calculate the Kalman gain based on the observation covariance matrix and the cross-covariance matrix; By combining the predicted observations with the actual observations of the currently retained sampling points, the prior state estimate is updated using the Kalman gain to obtain the optimal state estimate at the current time. The optimal state estimate at the current moment is substituted into the preset nonlinear process model, and the state estimate at the next moment is extrapolated to obtain the state estimate at the next moment. The coordinates are extracted from the state estimate at the next moment as predicted handwriting points.

[0127] As one possible implementation of this application, the handwriting rendering device further includes an initialization unit, configured to: initialize an unscented Kalman filter, including: Initialize the state vector, which is a six-dimensional vector including the current position coordinates, the current velocity component, and the current acceleration component. The coordinates of the first sampling point are used as the current position coordinates, and the velocity and acceleration components are initialized to zero. Initialize the error covariance matrix, the process noise covariance matrix, and the observation noise covariance matrix. The error covariance matrix, the process noise covariance matrix, and the observation noise covariance matrix are all diagonal matrices, and their diagonal elements are preset values.

[0128] As one possible implementation of this application, the sampling compression unit 73 is specifically used for: Using the current time as the endpoint, select the N points in the sequence to be drawn that are closest to the current time to form a sliding window, where N is the preset sliding window length; Recursive compression is performed on the point set within the sliding window. The recursive compression includes: connecting the first point and the last point within the sliding window to form a baseline segment; calculating the vertical distance from each intermediate point within the sliding window to the baseline segment; determining the maximum vertical distance and its corresponding maximum distance point; if the maximum vertical distance is less than a preset compression tolerance, discarding all intermediate points within the sliding window and retaining only the first point and the last point; if the maximum vertical distance is greater than or equal to the preset compression tolerance, dividing the point set within the sliding window into two sub-parts using the maximum distance point as the dividing point, and repeating the recursive compression for each sub-part until the maximum vertical distance of all sub-parts is less than the preset compression tolerance. All points that were not discarded were retained in sequence as the compression result, resulting in the target sampling point sequence.

[0129] As one possible implementation of this application, the handwriting rendering unit 74 is specifically used for: The target sampling point sequence is smoothly fitted using a preset smoothing algorithm.

[0130] As one possible implementation of this application, the handwriting rendering device further includes: The pen-lifting detection processing unit is used to end the rendering of the current handwriting if a pen-lifting event is detected; if no pen-lifting event is detected, it returns to the step of obtaining the sampling point of the user touch input and continues to process the next sampling point.

[0131] As can be seen from the above, in this embodiment, by acquiring the sampling points of the user's touch input and adaptively sampling these sampling points, necessary sampling points can be selected and retained according to the actual writing situation. While avoiding sampling point redundancy, key handwriting details such as pen strokes are effectively preserved, achieving a preliminary balance between handwriting details and data processing efficiency. Then, based on the currently retained sampling points and the unscented Kalman filter, the handwriting points at the next moment are predicted, and the predicted handwriting points are added to the drawing sequence. This allows for advance prediction of handwriting direction, effectively compensating for the time difference between touch input and rendering, reducing handwriting lag and breakage, and significantly improving the accuracy of handwriting direction prediction. When the length of the drawing sequence exceeds a preset threshold, a data compression algorithm is used to compress it to obtain the target sampling point sequence, further eliminating redundant data, reducing the load on data processing and rendering, achieving efficient processing of touch point data, and avoiding rendering delays caused by excessive data volume. Finally, handwriting rendering is performed based on the target sampling point sequence, ensuring that the rendered handwriting retains key details and has good smoothness, effectively improving the responsiveness of writing. This proposed solution can efficiently process touch point data while preserving handwriting details, improve the accuracy of handwriting direction prediction, and reduce rendering latency, effectively enhancing the smoothness and responsiveness of the writing process and improving the user's writing experience.

[0132] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0133] This application embodiment also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements... Figures 1 to 6 The steps of any handwriting rendering method are represented.

[0134] This application embodiment also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements... Figures 1 to 6 The steps of any handwriting rendering method are represented.

[0135] This application also provides a computer program product that, when run on a terminal device, causes the terminal device to execute the implementation of... Figures 1 to 6 The steps of any handwriting rendering method are represented.

[0136] Figure 8 This is a schematic diagram of a terminal device provided in an embodiment of this application. For example... Figure 8As shown, the terminal device 8 in this embodiment includes: a processor 80, a memory 81, and a computer program 82 stored in the memory 81 and executable on the processor 80. When the processor 80 executes the computer program 82, it implements the steps in the various handwriting rendering method embodiments described above, for example... Figure 1 Steps S101 to S105 are shown. Alternatively, when the processor 80 executes the computer program 82, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 7 The functions of units 71 to 74 are shown.

[0137] For example, the computer program 82 may be divided into one or more modules / units, which are stored in the memory 81 and executed by the processor 80 to complete this application. The one or more modules / units may be a series of computer-readable instruction segments capable of performing a specific function, which describe the execution process of the computer program 82 in the terminal device 8.

[0138] The terminal device 8 may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will understand that... Figure 8 This is merely an example of terminal device 8 and does not constitute a limitation on terminal device 8. It may include more or fewer components than shown, or combine certain components, or different components. For example, terminal device 8 may also include input / output devices, network access devices, buses, etc.

[0139] The processor 80 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0140] The memory 81 can be an internal storage unit of the terminal device 8, such as a hard disk or memory of the terminal device 8. The memory 81 can also be an external storage device of the terminal device 8, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal device 8. Furthermore, the memory 81 can include both internal and external storage units of the terminal device 8. The memory 81 is used to store the computer program and other programs and data required by the terminal device. The memory 81 can also be used to temporarily store data that has been output or will be output.

[0141] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0142] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0143] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a device / terminal equipment, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.

[0144] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0145] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A handwriting rendering method, characterized in that, include: Acquire sampling points of user touch input; Based on the movement speed of the touch tool, the sampling points are adaptively sampled, and the determined currently retained sampling points are added to the drawing sequence; Based on the currently retained sampling points and Kalman filtering, predict the handwriting points at the next moment, and add the predicted handwriting points to the sequence to be drawn; When the length of the sequence to be drawn exceeds a preset threshold, a data compression algorithm is used to compress the sequence to be drawn to obtain the target sampling point sequence; Handwriting rendering is performed based on the target sampling point sequence.

2. The method according to claim 1, characterized in that, The step of adaptively sampling the sampling points based on the movement speed of the touch tool includes: The movement speed of the touch tool is obtained, wherein the movement speed is the instantaneous speed between the sampling point and the previous retained sampling point; A dynamic distance threshold is determined based on the instantaneous velocity, and the dynamic distance threshold is positively correlated with the instantaneous velocity; Calculate the interval distance between the sampling point and the previous retained sampling point; If the interval distance is greater than the dynamic distance threshold, the sampling point is retained.

3. The method according to claim 1, characterized in that, The prediction of the handwriting points at the next time step based on the currently retained sampling points and Kalman filtering includes: Based on the optimal state estimate and error covariance matrix of the previous time step, a set of Sigma points are generated through unscented transformation; Each Sigma point is propagated through a pre-defined nonlinear process model to obtain the propagated set of Sigma points; Calculate the prior state estimate and the prior error covariance matrix based on the propagated Sigma point set; The propagated Sigma point set is transformed using a preset nonlinear observation model to obtain the observed Sigma point set; Based on the observed Sigma point set, calculate the predicted observed values, the observed covariance matrix, and the cross-covariance matrix between the state and the observed values; Calculate the Kalman gain based on the observation covariance matrix and the cross-covariance matrix; By combining the predicted observations with the actual observations of the currently retained sampling points, the prior state estimate is updated using the Kalman gain to obtain the optimal state estimate at the current time. The optimal state estimate at the current moment is substituted into the preset nonlinear process model, and the state estimate at the next moment is extrapolated to obtain the state estimate at the next moment. The coordinates are extracted from the state estimate at the next moment as predicted handwriting points.

4. The method according to claim 3, characterized in that, Before predicting the handwriting point at the next time step based on the currently retained sampling points and the Kalman filter, the unscented Kalman filter is initialized, including: Initialize the state vector, which is a six-dimensional vector including the current position coordinates, the current velocity component, and the current acceleration component. The coordinates of the first sampling point are used as the current position coordinates, and the velocity and acceleration components are initialized to zero. Initialize the error covariance matrix, the process noise covariance matrix, and the observation noise covariance matrix. The error covariance matrix, the process noise covariance matrix, and the observation noise covariance matrix are all diagonal matrices, and their diagonal elements are preset values.

5. The method according to claim 1, characterized in that, The step of compressing the sequence to be drawn using a data compression algorithm to obtain the target sampling point sequence includes: Using the current time as the endpoint, select the N points in the sequence to be drawn that are closest to the current time to form a sliding window, where N is the preset sliding window length; Recursive compression is performed on the point set within the sliding window. The recursive compression includes: connecting the first point and the last point within the sliding window to form a baseline segment; calculating the vertical distance from each intermediate point within the sliding window to the baseline segment; determining the maximum vertical distance and its corresponding maximum distance point; if the maximum vertical distance is less than a preset compression tolerance, discarding all intermediate points within the sliding window and retaining only the first point and the last point; if the maximum vertical distance is greater than or equal to the preset compression tolerance, dividing the point set within the sliding window into two sub-parts using the maximum distance point as the dividing point, and repeating the recursive compression for each sub-part until the maximum vertical distance of all sub-parts is less than the preset compression tolerance. All points that were not discarded were retained in sequence as the compression result, resulting in the target sampling point sequence.

6. The method according to claim 1, characterized in that, The handwriting rendering based on the target sampling point sequence includes: The target sampling point sequence is smoothly fitted using a preset smoothing algorithm.

7. The method according to any one of claims 1 to 6, characterized in that, After performing handwriting rendering based on the target sampling point sequence, the method further includes: If a pen lift event is detected, the rendering of the current handwriting will end; If no pen lift event is detected, return to the step of obtaining the sampling point of user touch input and continue processing the next sampling point.

8. A handwriting rendering device, characterized in that, include: An adaptive sampling unit is used to acquire sampling points of user touch input; Based on the movement speed of the touch tool, the sampling points are adaptively sampled, and the determined currently retained sampling points are added to the drawing sequence; The handwriting prediction unit is used to predict the handwriting points at the next moment based on the currently retained sampling points and Kalman filtering, and add the predicted handwriting points to the sequence to be drawn. The sampling compression unit is used to compress the sequence to be drawn using a data compression algorithm when the length of the sequence to be drawn exceeds a preset threshold, so as to obtain a target sampling point sequence. The handwriting rendering unit is used to perform handwriting rendering based on the target sampling point sequence.

9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the handwriting rendering method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the handwriting rendering method as described in any one of claims 1 to 7.