Method, device and medium for obtaining handwriting track
By performing key point detection and trajectory optimization on handwritten video frames, the problems of high cost and low accuracy in handwritten trajectory acquisition are solved, enabling high-accuracy trajectory acquisition and real-time analysis in real writing and drawing scenarios.
Patent Information
- Application Number
- CN202311301890.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-09
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2043-10-09
AI Technical Summary
In existing technologies, methods for obtaining handwriting trajectories are costly and have low accuracy, making them particularly unsuitable for real writing and drawing scenarios. Furthermore, algorithms based on video processing lack sufficient accuracy.
By acquiring video frames recording the handwriting process, the location of handwriting trajectory points is determined using a key point detection model, and the trajectory sequence is optimized based on trajectory optimization parameters, including trajectory segmentation and deduplication, to improve the accuracy of trajectory acquisition.
It improves the accuracy of handwriting trajectory acquisition, enabling real-time analysis of user behavior in real writing and drawing scenarios, providing more detailed guidance, and enhancing the user experience.
Smart Images

Figure CN117253241B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, and particularly relates to a handwriting trajectory acquisition method and device, equipment and medium. BACKGROUND
[0002] In recent years, methods based on computer vision technology to assist people in learning and working emerge in an endless stream, especially in the field of trajectory analysis such as writing and drawing, and the handwriting trajectory is acquired for analysis.
[0003] The handwriting trajectory can be acquired through a handwriting digitizer, an electronic screen or a pen with a sensor, which has a high cost and cannot be used in real writing, drawing and other scenarios. In order to solve the cost problem, the related art acquires the handwriting trajectory by processing a video during handwriting through an algorithm, but the accuracy of this method is low. SUMMARY
[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a handwriting trajectory acquisition method, device, equipment and medium.
[0005] According to an aspect of the present disclosure, a handwriting trajectory acquisition method is provided, comprising:
[0006] acquiring a to-be-processed video, wherein the to-be-processed video is a video recording a handwriting process, and the to-be-processed video comprises a plurality of video frames;
[0007] determining positions of handwriting trajectory points in the plurality of video frames to obtain positions of a plurality of handwriting trajectory points;
[0008] optimizing a trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on trajectory optimization parameters;
[0009] determining at least one handwriting trajectory based on the trajectory sequence after optimization.
[0010] According to another aspect of the present disclosure, a handwriting trajectory acquisition device is provided, comprising:
[0011] an acquisition module configured to acquire a to-be-processed video, wherein the to-be-processed video is a video recording a handwriting process, and the to-be-processed video comprises a plurality of video frames;
[0012] a position module configured to determine positions of handwriting trajectory points in the plurality of video frames to obtain positions of a plurality of handwriting trajectory points;
[0013] an optimization module configured to optimize a trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on trajectory optimization parameters;
[0014] a trajectory module configured to determine at least one handwriting trajectory based on the optimized trajectory sequence.
[0015] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory storing a program, wherein the program comprises instructions that, when executed by the processor, cause the processor to perform the handwriting trajectory acquisition method.
[0016] According to another aspect of the present disclosure, a computer-readable storage medium is provided, which stores a computer program for performing the handwriting trajectory acquisition method.
[0017] The handwriting trajectory acquisition method and device provided in the embodiments of the present disclosure acquire a to-be-processed video, wherein the to-be-processed video is a video recording a handwriting process, and the to-be-processed video comprises a plurality of video frames; the positions of handwriting trajectory points in the plurality of video frames are determined to obtain the positions of the plurality of handwriting trajectory points; a trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points is optimized based on trajectory optimization parameters; and at least one handwriting trajectory is determined based on the optimized trajectory sequence. By using the above technical solution, the positions of the plurality of handwriting trajectory points are obtained by identifying each video frame of the to-be-processed video recording the handwriting process, and then the trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points can be optimized according to the pre-set trajectory optimization parameters, and then at least one handwriting trajectory corresponding to the to-be-processed video is obtained based on the optimized trajectory. Due to the setting of the trajectory optimization parameters, the optimization of the trajectory sequence can effectively improve the accuracy of handwriting trajectory acquisition.
[0018] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present disclosure, nor is it used to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and serve to explain the principles of the present disclosure, together with the description.
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0021] Figure 1 A flowchart of a handwriting trajectory acquisition method provided in the embodiments of the present disclosure;
[0022] Figure 2 Another flowchart of a method for obtaining a handwriting trajectory is provided for an embodiment of the present disclosure.
[0023] Figure 3 A structural diagram of a handwriting trajectory obtaining apparatus is provided for an embodiment of the present disclosure.
[0024] Figure 4 A structural diagram of an electronic device is provided for an embodiment of the present disclosure. DETAILED DESCRIPTION
[0025] Embodiments of the present disclosure will be described in more detail with reference to the drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather the embodiments are provided so that the present disclosure can be more thoroughly and completely understood. It should be understood that the drawings of the present disclosure are for exemplary purposes only and are not intended to limit the scope of protection of the present disclosure.
[0026] It should be understood that each step described in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0027] The term “comprising” and variations thereof as used in the present disclosure are open-ended, that is, “including but not limited to”. The term “based on” is “based, at least in part, on”. The term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one additional embodiment”; the term “some embodiments” means “at least some embodiments”. Related definitions of other terms will be given in the description below. It should be noted that the concepts of “first”, “second”, etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and do not limit the order or interdependence of the functions performed by these devices, modules or units.
[0028] It should be noted that the modification of “one”, “multiple” mentioned in the present disclosure is illustrative rather than limiting, and those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as “one or more”.
[0029] In order to more clearly understand the above-mentioned purposes, features and advantages of the present disclosure, the solutions of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0030] In recent years, numerous methods based on computer vision technology have emerged to assist people in learning and working, especially in trajectory analysis in fields such as writing and drawing, where handwriting trajectories are acquired and analyzed. While some applications can analyze static images captured by the user, in many scenarios, user behavior is continuous and contains temporal information. Analyzing this information can better determine user behavior and improve user experience. For example, in a dictation scenario, if the algorithm only analyzes the image of the written character, it can determine whether the user wrote it correctly, but it cannot determine whether the stroke order was correct. Similarly, when a user draws in front of a camera (the camera captures the drawing area), capturing the trajectory of the pen tip allows for real-time analysis and interaction during the drawing process, providing more detailed and accurate guidance. Compared to analyzing only static artwork, incorporating trajectory information yields richer information about user behavior.
[0031] Admittedly, the aforementioned handwriting trajectory can be obtained using a graphics tablet, electronic screen, or a pen with sensors. However, firstly, graphics tablets increase the user's costs, and prolonged screen time for writing or drawing can negatively impact eyesight. Furthermore, neither graphics tablets nor electronic screens provide a truly immersive writing experience. In drawing scenarios, graphics tablets and electronic screens cannot utilize real inks, and the same applies to calligraphy. In other words, acquiring handwriting trajectories is unsuitable for real writing and drawing scenarios. To address the cost issue, related technologies use algorithms to process video footage of the handwriting process to obtain handwriting trajectories, but this method has relatively low accuracy.
[0032] To improve at least one of the above problems, this disclosure provides a method, apparatus, device, and medium for acquiring handwritten trajectories, which will be described below for ease of understanding.
[0033] Figure 1 This is a flowchart illustrating a method for acquiring handwritten trajectories according to an embodiment of the present disclosure. This method can be executed by a handwritten trajectories acquisition device, which can be implemented in software and / or hardware, and is generally integrated into an electronic device. Figure 1 As shown, the method includes:
[0034] Step 101: Obtain the video to be processed, which is a video recording the handwriting process and includes multiple video frames.
[0035] The to-be-processed video can be any video recording a handwriting process and requiring handwriting trajectory acquisition for subsequent analysis. The handwriting process can be a process in which a user writes or draws by using a handwriting tool. The handwriting tool is not limited in the embodiments of the present disclosure. For example, the handwriting tool can be a finger, a pen, a brush, a neutral pen, or various types of pens.
[0036] A video frame can be the smallest unit constituting a video and can be extracted from the to-be-processed video. That is, the to-be-processed video can be obtained by extracting a plurality of video frames.
[0037] In step 102, the positions of the handwriting trajectory points in the plurality of video frames are determined, and the positions of the plurality of handwriting trajectory points are obtained.
[0038] The handwriting trajectory point can be a touch point of the handwriting tool of the user in the video frame. The touch point can form one or more trajectories along with the handwriting process. For example, when the handwriting tool is a brush, the handwriting trajectory point can be a touch point of the brush tip in the video.
[0039] In some embodiments, determining the positions of the handwriting trajectory points in the plurality of video frames to obtain the positions of the plurality of handwriting trajectory points can include inputting the plurality of video frames into a key point detection model for detection to obtain the positions of the plurality of handwriting trajectory points. The key point detection model can be a model for detecting the positions of the handwriting trajectory points in the video frame. Specifically, a deep learning model can be used. For example, the key point detection model can use CenterNet.
[0040] The handwriting trajectory acquisition device can input each video frame of the to-be-processed video into the key point detection model for detection. When a handwriting trajectory point first appears in the detection result, the current video frame is recorded as the first valid video frame. The valid video frame contains a handwriting trajectory point. The position of the handwriting trajectory point corresponding to the valid video frame, that is, the coordinates of the handwriting trajectory point, is output. One valid video frame corresponds to the position of one handwriting trajectory point.
[0041] In step 103, the trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points is optimized based on trajectory optimization parameters.
[0042] The handwriting trajectory can be a trajectory formed by a handwriting process in the to-be-processed video. In the embodiments of the present disclosure, the positions of the handwriting trajectory points are arranged in a sequence to obtain a handwriting trajectory. That is, a handwriting trajectory can be represented by the positions of at least one handwriting trajectory point in a sequence. The trajectory sequence can include the positions of at least one handwriting trajectory point. One trajectory sequence corresponds to one handwriting trajectory. The positions of multiple handwriting trajectory points can correspond to one or more trajectory sequences. When the trajectory sequence is one, it includes the positions of all handwriting trajectory points. The positions of the handwriting trajectory points in the trajectory sequence are sorted according to the time sequence of the video frames corresponding to the handwriting trajectory points in the to-be-processed video.
[0043] The trajectory optimization parameter can be understood as a parameter that is set in advance and used to optimize the handwriting trajectory in the handwriting trajectory determination process. In the embodiments of the present disclosure, the trajectory optimization parameter can include a first distance threshold, a second distance threshold, and / or a preset pixel threshold. The first distance threshold and the preset pixel threshold can be two thresholds used to determine whether to end the writing of the previous handwriting trajectory and start the writing of the next handwriting trajectory. That is, the first distance threshold and the preset pixel threshold are used to determine whether the trajectory segmentation condition is met. The second distance threshold can be a threshold used to determine whether two handwriting trajectory points overlap. The first distance threshold and the second distance threshold can be set according to the distance between the positions of two handwriting trajectory points. The first distance threshold is greater than the second distance threshold. The preset pixel threshold can be set according to the average value of the pixels in a range. The specific values of the first distance threshold, the second distance threshold, and the preset pixel threshold can be set according to actual conditions, and the specific values are not limited.
[0044] In some embodiments, the optimization processing can include trajectory segmentation processing. The optimization processing on the trajectory sequence corresponding to the positions of the multiple handwriting trajectory points based on the trajectory optimization parameter can include: performing trajectory segmentation detection on the position of each handwriting trajectory point based on the trajectory optimization parameter; and performing trajectory segmentation on the trajectory sequence based on the trajectory segmentation detection result to obtain the trajectory sequence after the optimization processing. The trajectory segmentation detection can be used to detect whether the current handwriting tool is lifted, that is, to determine whether to start writing the next handwriting trajectory.
[0045] Optionally, the trajectory optimization parameter includes a preset pixel threshold. The trajectory segmentation detection on the position of each handwriting trajectory point based on the trajectory optimization parameter can include: for any handwriting trajectory point, in response to determining that the average value of the pixels in the preset range around the previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold, determining that the position of the handwriting trajectory point meets the trajectory segmentation condition. The trajectory segmentation condition can be a specific representation that the current handwriting tool is lifted to start writing the next handwriting trajectory. If the trajectory segmentation condition is met, it means that the trajectory is segmented to start the next handwriting trajectory. If the trajectory segmentation condition is not met, it means that the trajectory is not segmented.
[0046] The preset range can be a preset pixel area range, and the preset range can be different when the handwriting tool is different. For example, when the handwriting tool is a pen, the preset range can be a 5*5 pixel area range. Specifically, when the trajectory optimization parameter only includes the preset pixel threshold, the handwriting trajectory acquisition device can determine the pixel values of all pixel points in the preset range around the previous handwriting trajectory point of the handwriting trajectory point when performing trajectory segmentation detection on the position of each handwriting trajectory point. Then, the average pixel value of all pixel points in the preset range can be determined, and the average pixel value is compared with the preset pixel threshold. If the average pixel value is greater than the preset pixel threshold, it is determined that there is no handwriting trajectory around the previous handwriting trajectory point, that is, it is determined that the handwriting tool is lifted to start writing a new handwriting trajectory, and the trajectory segmentation detection result of the position of the handwriting trajectory point meets the trajectory segmentation condition. If the average pixel value is less than or equal to the preset pixel threshold, it is determined that there is handwriting trajectory around the previous handwriting trajectory point, that is, the trajectory segmentation detection result of the position of the handwriting trajectory point does not meet the trajectory segmentation condition.
[0047] In the above scheme, whether the average pixel value in the preset range around the previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold is used to determine whether the to-be-processed trajectory point meets the trajectory segmentation condition. In fact, whether there is handwriting around a handwriting trajectory point is used to determine whether the tip of the handwriting tool has been lifted or just landed and has not started writing. Since there is no handwriting around, it is determined that the handwriting tool has been lifted. When it is determined that the handwriting tool is lifted, it is determined that the position of the handwriting trajectory point meets the trajectory segmentation condition, that is, the handwriting trajectory point is the initial trajectory point of a new handwriting trajectory. By adding the judgment of whether the position of the handwriting trajectory point meets the trajectory segmentation condition, the problem that two or more handwriting trajectories are misjudged as one handwriting trajectory is avoided, and the accuracy of handwriting trajectory acquisition is improved.
[0048] Optionally, when the trajectory optimization parameter only includes the first distance threshold, based on the trajectory optimization parameter, the trajectory segmentation detection on the position of each handwriting trajectory point includes: for any handwriting trajectory point, if the distance between the position of the handwriting trajectory point and the position of the last handwriting trajectory point in the trajectory sequence is greater than the first distance threshold, it is determined that the position of the handwriting trajectory point meets the trajectory segmentation condition; otherwise, it is determined that the position of the handwriting trajectory point does not meet the trajectory segmentation condition.
[0049] The handwriting trajectory obtaining apparatus can extract, for the position of any handwriting trajectory point, a handwriting trajectory point ranked last in the handwriting trajectory sequence, which can be a handwriting trajectory point added last in the handwriting trajectory sequence in sequence, and determine whether the distance between the handwriting trajectory point and the position of the handwriting trajectory point ranked last satisfies the first distance threshold. If yes, the handwriting trajectory point is determined to satisfy the handwriting trajectory segmentation condition; otherwise, the handwriting trajectory point is determined to not satisfy the handwriting trajectory segmentation condition. The distance between the positions of the two handwriting trajectory points is the Euclidean distance.
[0050] In the above scheme, the handwriting trajectory point and the handwriting trajectory point ranked last in the handwriting trajectory sequence are compared in terms of the distance between their positions and the first distance threshold to determine whether the handwriting trajectory point satisfies the handwriting trajectory segmentation condition. When the distance is greater than the first distance threshold, it can be considered that a new handwriting trajectory is started, and when the distance is less than or equal to the first distance threshold, it can be considered that the current handwriting trajectory is still being performed. This can avoid the problem of misjudging two or more handwriting trajectories as one handwriting trajectory to some extent, thereby improving the accuracy of handwriting trajectory acquisition.
[0051] Optionally, the trajectory optimization parameters include a first distance threshold and a preset pixel threshold. Based on the trajectory optimization parameters, the handwriting trajectory segmentation detection is performed on the position of each handwriting trajectory point, including: for any handwriting trajectory point, if the distance between the handwriting trajectory point and the position of the handwriting trajectory point ranked last in the handwriting trajectory sequence is greater than the first distance threshold, the handwriting trajectory point is determined to satisfy the handwriting trajectory segmentation condition; or if the distance between the handwriting trajectory point and the position of the handwriting trajectory point ranked last in the handwriting trajectory sequence is less than or equal to the first distance threshold and the average value of the pixels in the preset range around the previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold, the handwriting trajectory point is determined to satisfy the handwriting trajectory segmentation condition.
[0052] When the trajectory optimization parameter comprises the first distance threshold and the preset pixel threshold, the handwriting trajectory acquisition device determines, for a position of any handwriting trajectory point, whether a distance between the position of the handwriting trajectory point and a position of a handwriting trajectory point ranked last in the trajectory sequence is greater than the first distance threshold. If yes, it is determined that the trajectory segmentation detection result of the position of the handwriting trajectory point satisfies the trajectory segmentation condition. If the distance between the position of the handwriting trajectory point and the position of the handwriting trajectory point ranked last in the trajectory sequence is less than or equal to the first distance threshold, it is determined whether an average value of pixels in a preset range around a previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold. If yes, it is determined that the trajectory segmentation detection result of the position of the handwriting trajectory point satisfies the trajectory segmentation condition. If the distance between the position of the handwriting trajectory point and the position of the handwriting trajectory point ranked last in the trajectory sequence is less than or equal to the first distance threshold, and it is determined that the average value of the pixels in the preset range around the previous handwriting trajectory point of the handwriting trajectory point is less than the preset pixel threshold, it is determined that the trajectory segmentation detection result of the position of the handwriting trajectory point satisfies the trajectory segmentation condition.
[0053] In the above scheme, when the trajectory optimization parameter comprises the first distance threshold and the preset pixel threshold, whether the position of the handwriting trajectory point satisfies the trajectory segmentation condition is determined by distance comparison and handwriting trajectory point surrounding pixel determination, which further improves the accuracy of the determination of whether to start a new handwriting trajectory, and effectively improves the accuracy of subsequent handwriting trajectory acquisition.
[0054] Optionally, the trajectory segmentation of the trajectory sequence based on the trajectory segmentation detection result to obtain the trajectory sequence after optimization processing can comprise: determining the trajectory sequence as a to-be-processed sequence; for a position of any handwriting trajectory point in the to-be-processed sequence: if the position of the handwriting trajectory point satisfies the trajectory segmentation condition, adding the position of the handwriting trajectory point and positions of handwriting trajectory points after the handwriting trajectory point to a next trajectory sequence, and updating the next trajectory sequence as a new to-be-processed trajectory sequence to continue processing; if the position of the handwriting trajectory point does not satisfy the trajectory segmentation condition, adding the position of the handwriting trajectory point to a target trajectory sequence; until the handwriting trajectory points are processed completely, obtaining at least one target trajectory sequence, wherein each to-be-processed sequence corresponds to a target trajectory sequence.
[0055] The next trajectory sequence is a newly constructed trajectory sequence relative to the to-be-processed sequence. The target trajectory sequence can be a final determined trajectory sequence. The handwriting trajectory acquisition device can determine a trajectory sequence including positions of all handwriting trajectory points as the to-be-processed sequence; then the handwriting trajectory points in the to-be-processed sequence can be processed in sequence according to the order of the handwriting trajectory points. For the position of any handwriting trajectory point, if the position of the handwriting trajectory point meets the trajectory segmentation condition, the next trajectory sequence can be constructed to add the position of the handwriting trajectory point and the positions of handwriting trajectory points after the handwriting trajectory point to the next trajectory sequence, and the next trajectory sequence is updated as a new to-be-processed trajectory sequence to continue processing; if the position of the handwriting trajectory point does not meet the trajectory segmentation condition, the target trajectory sequence is constructed and the position of the handwriting trajectory point is added to the target trajectory sequence. The above steps are repeatedly performed for each to-be-processed sequence and the position of each handwriting trajectory point until the positions of all handwriting trajectory points are processed, at least one target trajectory sequence is obtained, one to-be-processed sequence can correspond to one target trajectory sequence, and the at least one target trajectory sequence is a trajectory sequence after trajectory optimization processing.
[0056] In step 104, at least one handwriting trajectory is determined based on the trajectory sequence after optimization processing.
[0057] After the handwriting trajectory acquisition device optimizes the trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on the trajectory optimization parameter, the trajectory sequence after optimization processing is obtained, the trajectory sequence after optimization processing includes at least one target trajectory sequence, and a corresponding handwriting trajectory is obtained based on the positions of the handwriting trajectory points included in each target trajectory sequence arranged in the time sequence of the above to-be-processed video according to the corresponding video frame. At least one handwriting trajectory can be obtained.
[0058] In summary, the handwriting trajectory acquisition method provided by the embodiments of the present disclosure includes the following steps: obtaining a to-be-processed video, wherein the to-be-processed video is a video recording a handwriting process, and the to-be-processed video includes a plurality of video frames; determining positions of handwriting trajectory points in the plurality of video frames to obtain a plurality of handwriting trajectory point positions; optimizing a trajectory sequence corresponding to the plurality of handwriting trajectory point positions based on a trajectory optimization parameter; and determining at least one handwriting trajectory based on the trajectory sequence after optimization processing. By using the above technical solution, the positions of a plurality of handwriting trajectory points are obtained by identifying each video frame of the to-be-processed video recording the handwriting process, then the trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points is optimized according to the pre-set trajectory optimization parameter, and then at least one handwriting trajectory corresponding to the to-be-processed video is obtained based on the trajectory after optimization processing. Due to the setting of the trajectory optimization parameter, the accuracy of handwriting trajectory acquisition can be effectively improved by optimizing the trajectory sequence.
[0059] For example, Figure 2Another flowchart of the handwriting trajectory acquisition method provided by the embodiments of the present disclosure is shown in FIG. 13. In a possible implementation, when the optimization processing includes the de-duplication processing, and the trajectory optimization parameter includes a second distance threshold, the optimization processing on the trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on the trajectory optimization parameter can include: performing the de-duplication processing on the trajectory sequence based on the second distance threshold, and taking the de-duplicated trajectory sequence as the trajectory sequence after the optimization processing. Figure 2 As shown in FIG. 13, in a possible implementation, when the optimization processing includes the de-duplication processing, and the trajectory optimization parameter includes a second distance threshold, the optimization processing on the trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on the trajectory optimization parameter can include: performing the de-duplication processing on the trajectory sequence based on the second distance threshold, and taking the de-duplicated trajectory sequence as the trajectory sequence after the optimization processing.
[0060] Step 201: If the distance between the positions of the adjacent handwriting trajectory points in the trajectory sequence is less than the second distance threshold, it is determined that the adjacent handwriting trajectory points are two to-be-de-duplicated trajectory points.
[0061] The de-duplication processing can be a processing of deleting one of two handwriting trajectory points with a smaller position change amplitude in the trajectory sequence, that is, a processing of removing the duplicated handwriting trajectory points in the trajectory sequence. The second distance threshold can be a threshold for judging whether two handwriting trajectory points are overlapped, that is, a threshold for judging whether the distance between the positions of two handwriting trajectory points is small, and the specific value can be set according to the actual situation.
[0062] The adjacent handwriting trajectory points can include two handwriting trajectory points adjacent in front and back in the trajectory sequence, and the positions of the handwriting trajectory points in the trajectory sequence are sorted in the time order of the video frames corresponding to the handwriting trajectory points in the to-be-processed video. The to-be-de-duplicated trajectory points can be the handwriting trajectory points that need to be de-duplicated.
[0063] The handwriting trajectory acquisition device can extract a plurality of adjacent handwriting trajectory points in the trajectory sequence, each adjacent handwriting trajectory point including two handwriting trajectory points adjacent in position, denoted as a first handwriting trajectory point and a second handwriting trajectory point, for each adjacent handwriting trajectory point, determine the distance between the positions of the first handwriting trajectory point and the second handwriting trajectory, which is the Euclidean distance, and then compare the distance with the second distance threshold. If the distance is less than the second distance threshold, it is determined that the first handwriting trajectory point and the second handwriting trajectory point are two to-be-de-duplicated trajectory points, and then step 202 can be performed. If the distance between the positions of the adjacent handwriting trajectory points is less than the second distance threshold, neither of the two handwriting trajectory points of the adjacent handwriting trajectory point belongs to the to-be-de-duplicated trajectory points, and no de-duplication processing is performed.
[0064] Step 202: De-duplicate the positions of the two to-be-de-duplicated trajectory points based on a preset de-duplication rule.
[0065] The preset deduplication rule can be a specific rule for selecting and deleting the to-be-deduplicated trajectory points, which can be set according to actual conditions. For example, the preset deduplication rule can be set to delete any one of the two to-be-deduplicated trajectory points.
[0066] In some embodiments, based on the preset deduplication rule, deduplicating the positions of the two to-be-deduplicated trajectory points can include: if the two to-be-deduplicated trajectory points include a handwriting trajectory point that is first in order or last in order in the trajectory sequence, deleting the position of the other to-be-deduplicated trajectory point except the handwriting trajectory point that is first in order or last in order; if the two to-be-deduplicated trajectory points do not include a handwriting trajectory point that is first in order and last in order in the trajectory sequence, determining a first distance between the position of a first handwriting trajectory point and the position of a previous handwriting trajectory point of the first handwriting trajectory point, and a second distance between the position of a second handwriting trajectory point and the position of a next handwriting trajectory point of the second handwriting trajectory point; when the first distance is greater than or equal to the second distance, deleting the position of the second handwriting trajectory point; and when the first distance is less than the second distance, deleting the position of the first handwriting trajectory point.
[0067] The preset deduplication rule can be a specific rule for selecting and deleting the to-be-deduplicated trajectory points, which can be set according to actual conditions. For example, the preset deduplication rule can be set to delete any one of the two to-be-deduplicated trajectory points.
[0068] Assuming that the two adjacent handwriting trajectory points before and after are denoted as q1 and q2, the de-duplication process can include: (1) if q1 is the first handwriting trajectory point in the trajectory sequence, i.e., the first sorted handwriting trajectory point, q1 is retained, and the position of q2 is removed from the trajectory sequence; if q1 is not the first sorted handwriting trajectory point in the trajectory sequence, and q2 is the last handwriting trajectory point in the current trajectory sequence, i.e., the last sorted handwriting trajectory point, q2 is retained, and the position of q1 is removed from the trajectory sequence; (2) if q1 and q2 do not meet (1), i.e., neither q1 nor q2 is at the two ends of the trajectory sequence, the Euclidean distance between q1 and the handwriting trajectory point before q1 is calculated and denoted as d1, and the Euclidean distance between q2 and the handwriting trajectory point after q2 is calculated and denoted as d2; (3) if d2≤d1, the position of q2 is removed from the trajectory sequence, and if d2>d1, the position of q1 is removed from the current trajectory sequence.
[0069] The handwriting trajectory obtaining apparatus performs the above de-duplication processing on all adjacent handwriting trajectory points in the trajectory sequence to obtain a de-duplicated trajectory sequence, determines the de-duplicated trajectory sequence as an optimized trajectory sequence, and then determines at least one handwriting trajectory based on the optimized trajectory sequence.
[0070] When a user writes, the handwriting tool may stay at a certain position for a period of time, and the position of the handwriting trajectory point in the video frame obtained during this period of time changes in a small range. However, the existence of these noise points in the trajectory sequence will affect subsequent analysis. Therefore, in the embodiments of the present disclosure, a de-duplication operation can be added to the obtained at least one trajectory sequence to delete repeated handwriting trajectory points, thereby achieving de-noising and standardization processing of the at least one trajectory sequence, further improving the accuracy of handwriting trajectory acquisition, and obtaining more accurate analysis results in subsequent applications.
[0071] In some embodiments, the handwriting trajectory obtaining method can further include: determining the first distance threshold and the second distance threshold in the trajectory optimization parameter based on the video acquisition frame rate of the to-be-processed video and the writing speed, wherein determining the first distance threshold and the second distance threshold in the trajectory optimization parameter based on the video acquisition frame rate of the to-be-processed video and the writing speed includes: determining the quotient of the maximum value of the writing speed and the video acquisition frame rate as the first distance threshold; and determining the quotient of the minimum value of the writing speed and the video acquisition frame rate as the second distance threshold.
[0072] The video acquisition frame rate can be the number of video frames acquired in a unit of time corresponding to the to-be-processed video. The writing speed can include a maximum writing speed and a minimum writing speed of the handwriting process obtained by statistical analysis on the to-be-processed video, and the unit can be the number of pixels moved per second. In the embodiment of the present disclosure, the handwriting trajectory acquisition apparatus acquires the video acquisition frame rate and the writing speed of the to-be-processed video, and then the first distance threshold can be set as the quotient of the maximum value of the writing speed and the video acquisition frame rate, and the second distance threshold can be set as the quotient of the minimum value of the writing speed and the video acquisition frame rate. Assuming that the video acquisition frame rate is represented as Z, the maximum value of the writing speed is represented as c1, and the minimum value of the writing speed is represented as c2, the first distance threshold is represented as M, M = c1 / z, and the second distance threshold is represented as N, N = c2 / z. It can be understood that the above-mentioned manner of determining the first distance threshold and the second distance threshold according to the video acquisition frame rate and the writing speed is only an example, and is not limited.
[0073] In the above scheme, the first distance threshold and the second distance threshold in the trajectory optimization parameter are determined based on the video acquisition frame rate of the to-be-processed video and the writing speed of the user, so that the setting of the two trajectory optimization parameters is more accurate, and is strongly related to the video acquisition frame rate and the writing speed, thereby improving the accuracy of subsequent handwriting trajectory acquisition.
[0074] Corresponding to the handwriting trajectory acquisition method, the embodiment of the present disclosure also provides a handwriting trajectory acquisition apparatus,
[0075] Figure 3 A structural schematic diagram of a handwriting trajectory acquisition apparatus provided by the embodiment of the present disclosure is shown in the figure. The apparatus can be realized by software and / or hardware, and can be generally integrated in an electronic device. As shown in the figure, Figure 3 The handwriting trajectory acquisition apparatus 300 includes:
[0076] The acquisition module 301 is configured to acquire a to-be-processed video, wherein the to-be-processed video is a video recording a handwriting process, and the to-be-processed video includes a plurality of video frames.
[0077] The position module 302 is configured to determine the positions of handwriting trajectory points in the plurality of video frames to obtain the positions of a plurality of handwriting trajectory points.
[0078] The optimization module 303 is configured to perform optimization processing on a trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on trajectory optimization parameters.
[0079] The trajectory module 304 is configured to determine at least one handwriting trajectory based on the trajectory sequence after the optimization processing.
[0080] In the above device, the positions of the plurality of handwriting trajectory points are identified from each video frame of the to-be-processed video recording the handwriting process, and then the trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points is subjected to optimization processing according to the pre-set trajectory optimization parameter, and at least one handwriting trajectory corresponding to the to-be-processed video is obtained based on the trajectory after the optimization processing. Due to the setting of the trajectory optimization parameter, the optimization processing of the trajectory sequence can effectively improve the accuracy of obtaining the handwriting trajectory.
[0081] In some embodiments, the positions of the handwriting trajectory points in the trajectory sequence are sorted according to the time sequence of the video frames corresponding to each handwriting trajectory point in the to-be-processed video, and the optimization processing includes trajectory segmentation processing, and the optimization module 303 includes:
[0082] a detection unit configured to detect trajectory segmentation of each handwriting trajectory point based on the trajectory optimization parameter;
[0083] a segmentation unit configured to perform trajectory segmentation on the trajectory sequence based on the trajectory segmentation detection result to obtain the trajectory sequence after the optimization processing.
[0084] In some embodiments, the trajectory optimization parameter includes a preset pixel threshold, and the detection unit is configured to:
[0085] for any position of a handwriting trajectory point, in response to determining that the average value of the pixels within the preset range around the previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold, it is determined that the position of the handwriting trajectory point satisfies the trajectory segmentation condition.
[0086] In some embodiments, the trajectory optimization parameter includes a first distance threshold and a preset pixel threshold, and the detection unit is configured to:
[0087] for any position of a handwriting trajectory point, if the distance between the position of the handwriting trajectory point and the position of the last handwriting trajectory point in the trajectory sequence is greater than the first distance threshold, it is determined that the position of the handwriting trajectory point satisfies the trajectory segmentation condition;
[0088] or, if the distance between the position of the handwriting trajectory point and the position of the last handwriting trajectory point in the trajectory sequence is less than or equal to the first distance threshold and the average value of the pixels within the preset range around the previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold, it is determined that the position of the handwriting trajectory point satisfies the trajectory segmentation condition.
[0089] In some embodiments, the segmentation unit is configured to:
[0090] determine the trajectory sequence as a to-be-processed sequence;
[0091] for any position of a handwriting trajectory point in the to-be-processed sequence:
[0092] If the position of the handwriting trajectory point satisfies the trajectory splitting condition, the position of the handwriting trajectory point and the positions of handwriting trajectory points after the handwriting trajectory point are added to a next trajectory sequence, and the next trajectory sequence is updated as a new to-be-processed trajectory sequence to return to continue processing;
[0093] If the position of the handwriting trajectory point does not satisfy the trajectory splitting condition, the position of the handwriting trajectory point is added to the target trajectory sequence.
[0094] Until the plurality of handwriting trajectory points are processed, at least one target trajectory sequence is obtained, wherein each to-be-processed sequence corresponds to a target trajectory sequence.
[0095] In some embodiments, the optimization processing includes a deduplication processing, and the optimization module 303 is configured to:
[0096] deduplicate the trajectory sequence based on the second distance threshold, and take the deduplicated trajectory sequence as the trajectory sequence after the optimization processing,
[0097] The deduplicating the trajectory sequence based on the second distance threshold, and taking the deduplicated trajectory sequence as the trajectory sequence after the optimization processing, includes:
[0098] If the distance between the positions of the adjacent handwriting trajectory points in the trajectory sequence is less than the second distance threshold, the adjacent handwriting trajectory points are determined as two to-be-deduplicated trajectory points.
[0099] Based on a preset deduplication rule, the positions of the two to-be-deduplicated trajectory points are deduplicated.
[0100] In some embodiments, the optimization module 303 is configured to:
[0101] If the two to-be-deduplicated trajectory points include the handwriting trajectory point with the first or the last order in the trajectory sequence, the position of the other to-be-deduplicated trajectory point except the handwriting trajectory point with the first or the last order is deleted.
[0102] If the two to-be-deduplicated trajectory points do not include the handwriting trajectory point with the first or the last order in the trajectory sequence, a first distance between the position of the first handwriting trajectory point and the position of the previous handwriting trajectory point, and a second distance between the position of the second handwriting trajectory point and the position of the next handwriting trajectory point are determined.
[0103] When the first distance is greater than or equal to the second distance, the position of the second handwriting trajectory point is deleted.
[0104] when the first distance is less than the second distance, deleting the position of the first handwriting trajectory point.
[0105] In some embodiments, the apparatus further includes a threshold module configured to:
[0106] determine, based on a video capture frame rate and a writing speed of the video to be processed, a first distance threshold and a second distance threshold in the trajectory optimization parameters,
[0107] wherein determining, based on a video capture frame rate and a writing speed of the video to be processed, a first distance threshold and a second distance threshold in the trajectory optimization parameters includes:
[0108] determining a quotient of a maximum value of the writing speed and the video capture frame rate as the first distance threshold;
[0109] determining a quotient of a minimum value of the writing speed and the video capture frame rate as the second distance threshold.
[0110] The handwriting trajectory acquisition apparatus provided by the embodiments of the present disclosure can perform the handwriting trajectory acquisition method provided by any of the embodiments of the present disclosure, and has the corresponding function modules and beneficial effects of performing the method.
[0111] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the apparatus embodiments described above can refer to the corresponding process in the method embodiments, which will not be described here.
[0112] The names of the messages or information exchanged between the plurality of apparatuses in the embodiments of the present disclosure are only for illustrative purposes, and are not used to limit the scope of the messages or information.
[0113] The exemplary embodiments of the present disclosure further provide an electronic device, including at least one processor, and a memory connected with the at least one processor in communication. The memory stores a computer program capable of being executed by the at least one processor, and the computer program, when executed by the at least one processor, is configured to cause the electronic device to perform the method according to the embodiments of the present disclosure.
[0114] The exemplary embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is configured to cause the computer to perform the method according to the embodiments of the present disclosure.
[0115] The exemplary embodiments of the present disclosure further provide a computer program product, including a computer program, wherein the computer program, when executed by a processor of a computer, is configured to cause the computer to perform the method according to the embodiments of the present disclosure.
[0116] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this disclosure. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0117] Furthermore, embodiments of this disclosure can also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform the XYZ method provided in embodiments of this disclosure. The computer-readable storage medium can be any combination of one or more readable media. A readable medium can be a readable signal medium or a readable storage medium. A readable storage medium can be, for example, including but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0118] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. (Reference) Figure 4 The present invention describes a structural block diagram of an electronic device 400 that can serve as a server or client of the present disclosure, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0119] like Figure 4As shown, the electronic device 400 includes a computing unit 401 that can perform various appropriate actions and processes in accordance with a computer program stored in a read-only memory (ROM) 402 or a computer program loaded into a random access memory (RAM) 403 from a storage unit 408. In the RAM 403, various programs and data required for the operation of the electronic device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0120] A plurality of components in the electronic device 400 are connected to the I / O interface 405, including an input unit 406, an output unit 407, the storage unit 408, and a communication unit 409. The input unit 406 can be any type of device that can input information to the electronic device 400, and can receive inputted numerical or character information, as well as generate key signal inputs related to user settings and / or function controls of the electronic device. The output unit 407 can be any type of device that can present information, and can include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 408 can include, but is not limited to, a magnetic disk, an optical disk. The communication unit 409 allows the electronic device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth™ device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0121] The computing unit 401 can be various general and / or special purpose processing components having processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 401 performs the various methods and processes described above. For example, in some embodiments, the methods of obtaining a handwriting trajectory can each be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 408. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 400 via the ROM 402 and / or the communication unit 409. In some embodiments, the computing unit 401 can be configured to perform the methods of obtaining a handwriting trajectory by any other appropriate means, such as by means of firmware.
[0122] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or block diagrams. The program code can be embodied entirely on a machine, partially on a machine, fully on a machine, partially on a machine and partially on a remote machine, or fully on a remote machine or server.
[0123] In the context of the present disclosure, a machine-readable medium can be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of a processor, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0124] As used in the present disclosure, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus and / or device (e.g., magnetic discs, optical disks, memory, Programmable Logic Devices (PLDs)) used to provide machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal that can be used to provide machine instructions and / or data to a programmable processor.
[0125] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0126] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0127] The computer system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
[0128] It should be noted that, in this document, the terms "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these entities or operations to be in any specific order or relationship. Also, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the phrase "comprising a... " does not exclude the existence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0129] The above description is that of current embodiments of the disclosure. Various alterations and modifications will become apparent to those of ordinary skill in the art from the foregoing description, taking in account the teachings of the preceding description. Further, the generic principles defined herein can be applied to other embodiments without the use of the specific descriptive materials presented in this disclosure. Therefore, no limitation is intended or should be implied therefrom. It will be appreciated that those skilled in the art, on consideration of this disclosure, will be able to devise numerous embodiments that, although not explicitly described herein, embody the principles of the disclosure and are within its spirit and scope.
Claims
1. A method for obtaining a handwriting trajectory, comprising: obtaining a to-be-processed video, wherein the to-be-processed video is a video recording a handwriting process, and the to-be-processed video comprises a plurality of video frames; determining positions of handwriting trajectory points in the plurality of video frames to obtain positions of a plurality of handwriting trajectory points; performing optimization processing on a trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on trajectory optimization parameters, wherein the optimization processing comprises trajectory segmentation processing, and the trajectory segmentation processing comprises: performing trajectory segmentation detection on the position of each handwriting trajectory point based on the trajectory optimization parameters, wherein the trajectory optimization parameters comprise a preset pixel threshold, and the trajectory segmentation detection comprises: for any position of a handwriting trajectory point, in response to determining that an average value of pixels within a preset range around a previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold, determining that the position of the handwriting trajectory point satisfies a trajectory segmentation condition; performing trajectory segmentation on the trajectory sequence based on a trajectory segmentation detection result to obtain an optimized trajectory sequence; and determining at least one handwriting trajectory based on the optimized trajectory sequence.
2. The handwriting trajectory acquisition method of claim 1, wherein, The positions of the handwriting trajectory points in the trajectory sequence are sorted in a time sequence of video frames corresponding to the handwriting trajectory points in the to-be-processed video.
3. The handwriting trajectory acquisition method of claim 1, wherein, The trajectory optimization parameters comprise a first distance threshold and a preset pixel threshold, and the performing trajectory segmentation detection on the position of each handwriting trajectory point based on the trajectory optimization parameters comprises: for any position of a handwriting trajectory point, if a distance between the position of the handwriting trajectory point and a position of a handwriting trajectory point ranked first in reverse order in the trajectory sequence is greater than the first distance threshold, determining that the position of the handwriting trajectory point satisfies a trajectory segmentation condition; or if the distance between the position of the handwriting trajectory point and the position of the handwriting trajectory point ranked first in reverse order in the trajectory sequence is less than or equal to the first distance threshold and an average value of pixels within a preset range around a previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold, determining that the position of the handwriting trajectory point satisfies a trajectory segmentation condition. The performing trajectory segmentation on the trajectory sequence based on a trajectory segmentation detection result to obtain an optimized trajectory sequence comprises:
4. The handwriting trajectory acquisition method of claim 1, wherein, determining the trajectory sequence as a to-be-processed sequence; for any position of a handwriting trajectory point in the to-be-processed sequence: if the position of the handwriting trajectory point satisfies a trajectory segmentation condition, adding the position of the handwriting trajectory point and positions of handwriting trajectory points after the handwriting trajectory point to a next trajectory sequence, and updating the next trajectory sequence as a new to-be-processed trajectory sequence to continue processing; if the position of the handwriting trajectory point does not satisfy a trajectory segmentation condition, adding the position of the handwriting trajectory point to a target trajectory sequence; until the plurality of handwriting trajectory points are processed, at least one target trajectory sequence is obtained, and each to-be-processed sequence corresponds to a target trajectory sequence. The optimization processing comprises a de-duplication processing, and the trajectory optimization parameters comprise a second distance threshold, and the performing optimization processing on a trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on trajectory optimization parameters comprises:
5. The method of acquiring a handwriting trajectory according to any one of claims 1 to 4, wherein, perform deduplication processing on the trajectory sequence based on the second distance threshold, and take the trajectory sequence after deduplication as the trajectory sequence after optimization processing, wherein the deduplication processing on the trajectory sequence based on the second distance threshold, and taking the trajectory sequence after deduplication as the trajectory sequence after optimization processing, comprises: if the distance between the positions of two adjacent handwritten trajectory points in the trajectory sequence is less than the second distance threshold, determining that the two adjacent handwritten trajectory points are two trajectory points to be deduplicated; performing deduplication on the positions of the two trajectory points to be deduplicated based on a preset deduplication rule.
6. The handwriting trajectory acquisition method of claim 5, wherein, The deduplication on the positions of the two trajectory points to be deduplicated based on the preset deduplication rule comprises: if the two trajectory points to be deduplicated include a handwritten trajectory point with the first or last order in the trajectory sequence, deleting the position of the other trajectory point to be deduplicated except the handwritten trajectory point with the first or last order; if the two trajectory points to be deduplicated do not include a handwritten trajectory point with the first or last order in the trajectory sequence, determining a first distance between the position of a first handwritten trajectory point and the position of a previous handwritten trajectory point, and a second distance between the position of a second handwritten trajectory point and the position of a next handwritten trajectory point; when the first distance is greater than or equal to the second distance, deleting the position of the second handwritten trajectory point; when the first distance is less than the second distance, deleting the position of the first handwritten trajectory point.
7. The method of acquiring a handwriting trajectory according to any one of claims 1 to 4, wherein, The method further comprises: determining the first distance threshold and the second distance threshold in the trajectory optimization parameter based on the video capture frame rate and the writing speed of the video to be processed, wherein the determination of the first distance threshold and the second distance threshold in the trajectory optimization parameter based on the video capture frame rate and the writing speed of the video to be processed comprises: determining the quotient of the maximum value of the writing speed and the video capture frame rate as the first distance threshold; determining the quotient of the minimum value of the writing speed and the video capture frame rate as the second distance threshold.
8. A handwriting trajectory acquisition device, comprising: an acquisition module configured to acquire a video to be processed, wherein the video to be processed is a video recording a handwriting process, and the video to be processed comprises a plurality of video frames; a position module configured to determine the positions of handwritten trajectory points in the plurality of video frames to obtain the positions of a plurality of handwritten trajectory points. An optimization module is configured to perform an optimization process on the trajectory sequence corresponding to the positions of the plurality of handwriting trajectory points based on trajectory optimization parameters; the optimization process comprises a trajectory segmentation process, and the optimization module comprises: a detection unit configured to perform trajectory segmentation detection on the position of each handwriting trajectory point based on the trajectory optimization parameters, wherein the trajectory optimization parameters comprise a preset pixel threshold, and the detection unit is configured to: for the position of any handwriting trajectory point, in response to determining that the average value of the pixels within a preset range around the previous handwriting trajectory point of the handwriting trajectory point is greater than the preset pixel threshold, determine that the position of the handwriting trajectory point satisfies a trajectory segmentation condition; and a segmentation unit configured to perform trajectory segmentation on the trajectory sequence based on the trajectory segmentation detection result to obtain an optimized trajectory sequence; A trajectory module is configured to determine at least one handwriting trajectory based on the optimized trajectory sequence.
9. An electronic device, comprising: a processor; and a memory storing programs, wherein the programs include instructions that, when executed by the processor, cause the processor to perform the handwriting trajectory acquisition method according to any one of claims 1-7.
10. A computer-readable storage medium, the storage medium storing a computer program, the computer program being configured to perform the handwriting trajectory acquisition method according to any one of claims 1-7.
Citation Information
Patent Citations
An air handwriting recognition system and method based on machine vision
CN109033954A
Handwritten text recognition method, device and system, handwritten text search method and system and computer readable storage medium
CN115461792A
Freehand-drawn track recognition method, electronic equipment and storage medium
CN116416633A