Handwritten pen stroke evaluation method, electronic device and storage medium
By extracting the fluctuation characteristics of the stylus on the electronic device in segments, the problem of the inability to accurately evaluate the stylus performance in the prior art is solved, and intelligent evaluation and improvement of testing efficiency are achieved.
Patent Information
- Application Number
- CN202411413328.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-10-11
AI Technical Summary
The prior art lacks effective methods to evaluate the performance of stylus marking on electronic devices, resulting in the inability to accurately judge the stylus marking quality of stylus.
By obtaining the scribing segments written by the stylus, performing segment processing, extracting the fluctuation characteristics of each sub-line segment, and evaluating the scribing segments based on these features, and obtaining a total score.
The intelligent evaluation of the stylus markings of the stylus has been realized, and the accuracy and testing efficiency of the stylus marking performance of the stylus on electronic devices are improved.
Smart Images

Figure CN119091448B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of graphics processing, and in particular to a handwritten stroke evaluation method, electronic device and storage medium. Background Art
[0002] As user demands increase, the functions of electronic devices become more and more powerful. In order to meet user demands, many electronic devices support writing operations with a stylus.
[0003] When the stylus is used to operate on an electronic device, the sensor on the electronic device detects the contact position of the stylus and generates a corresponding graphic based on the contact position of the stylus. However, since the distribution of sensors on electronic devices is regional, when the stylus is used to operate, the landing position of the stylus will be affected by the holding posture and environmental noise, etc. The landing position of the stylus is corrected by the algorithm in the electronic device, causing the landing position to be close to the sensor with the strongest induction, which ultimately causes wavy lines to appear when the stylus is used to draw lines. At present, due to the lack of an evaluation method for stylus line drawing on electronic devices, it is impossible to more accurately judge the performance of stylus line drawing on electronic devices. Summary of the invention
[0004] The present application provides a method for evaluating a line drawn by a stylus pen, an electronic device, and a storage medium, which can more accurately determine the performance of a line drawn by a stylus pen on an electronic device.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, the present application provides a handwritten stroke evaluation method, comprising:
[0007] Acquire a first picture, wherein the first picture contains a solid line segment written by a stylus;
[0008] Segmenting the solid line segment to obtain sub-segments of the solid line segment;
[0009] Extracting the fluctuation characteristics of each of the sub-segments;
[0010] The solid line segment is evaluated according to the fluctuation characteristics of each sub-line segment to obtain a total score of the solid line segment.
[0011] In the present application, the solid line segment written by the stylus pen is first segmented to obtain each sub-segment, and the solid line segment is evaluated according to the fluctuation characteristics of the sub-segment to obtain the total score of the solid line segment. The present application provides an automated evaluation method for stylus strokes, which makes up for the problem that the performance of stylus strokes on electronic devices cannot be accurately judged due to the lack of an evaluation method for stylus strokes; in addition, the present application can automatically evaluate the effect of stylus strokes, thereby improving the test efficiency of stylus strokes.
[0012] As another implementation of the first aspect, segmenting the solid line segment to obtain sub-segments of the solid line segment includes:
[0013] Performing line fitting on the solid line segment to obtain a first fitting line segment of the solid line segment, wherein the first fitting line segment does not contain abnormal wavy lines;
[0014] Based on the intersection of the first fitting line segment and the solid line segment, each sub-segment into which the solid line segment is divided by the first fitting line segment is determined.
[0015] In the present application, the solid line segment is fitted, and the first fitted line segment obtained is the ideal line segment written by the stylus under ideal conditions. The solid line segment is segmented using the ideal line segment, and abnormal wavy lines in the solid line segment can be found, making the segmentation of the solid line segment more reasonable.
[0016] As another implementation of the first aspect, performing line fitting on the solid line segment to obtain a first fitted line segment of the solid line segment includes:
[0017] Performing grayscale processing on the first picture to obtain a grayscale image of the first picture;
[0018] Binarizing the grayscale image to obtain a binary image of the first image;
[0019] Extracting the line trajectory of the solid line segment according to the pixel value of each pixel point in the binary image;
[0020] Performing line fitting on the line-drawing trajectory to obtain a first fitting line segment of the solid line segment;
[0021] Correspondingly, the determining, based on the intersection of the first fitting line segment and the solid line segment, the sub-segments into which the solid line segment is divided by the first fitting line segment includes:
[0022] Based on the intersection of the first fitting line segment and the scribing trajectory, the sub-line segments into which the scribing trajectory is divided by the first fitting line segment are determined.
[0023] In the present application, since the pixel values of the pixels of the solid line segment are different from the pixel values of the pixels of the unlined part, the line trajectory of the solid line segment can be quickly and accurately extracted based on the pixel values of each pixel in the solid line segment and the pixel values of the unlined part.
[0024] As another implementation of the first aspect, performing line fitting on the line trajectory to obtain a first fitting line segment of the solid line segment includes:
[0025] Identifying the line type of the solid line segment;
[0026] Determining, according to the line type, a regression model used when performing line fitting on the line trajectory;
[0027] The determined regression model and the least square method are used to perform line fitting on the line-drawing trajectory to obtain a first fitting line segment of the solid line segment.
[0028] In the present application, since there are different types of line strokes for solid line segments, in order to obtain fitted line segments more accurately, the regression model to be used can be determined according to the line stroke type, and then the solid line segments can be fitted according to the required regression model, so that the final fitted line segments are more matched with the solid line segments and the fitted line segments are more accurate.
[0029] As another implementation of the first aspect, the line types include oblique lines, straight lines, wavy lines, broken lines, and arc lines;
[0030] The regression models matched by the oblique lines, the straight lines and the broken lines are all univariate linear regression models, the regression model matched by the wavy lines is a nonlinear regression model, and the regression model matched by the arc lines is a high-dimensional nonlinear regression model.
[0031] As another implementation of the first aspect, the fluctuation characteristic includes at least one of a fluctuation length, a fluctuation amplitude, and a fluctuation degree.
[0032] In the present application, the fluctuation length, fluctuation amplitude and fluctuation degree can all be used to evaluate the effect of handwritten strokes. Therefore, the fluctuation feature can select at least one of the fluctuation length, fluctuation amplitude and fluctuation degree, and then the solid stroke segment can be evaluated according to the fluctuation feature.
[0033] As another implementation of the first aspect, when the fluctuation feature includes the fluctuation length, the fluctuation amplitude, and the fluctuation degree, extracting the fluctuation feature of each sub-segment includes:
[0034] Determine the length of each of the sub-segments, where the length of the sub-segment is the fluctuation length of the sub-segment;
[0035] Calculating the distance between each pixel point in the sub-line segment and the first fitting line segment to obtain the maximum distance between the sub-line segment and the first fitting line segment, where the maximum distance between the sub-line segment and the first fitting line segment is the fluctuation amplitude of the sub-line segment;
[0036] Based on the distance between each pixel point in the sub-line segment and the first fitting line segment and the number of pixels in the sub-line segment, the variance of the distance between each pixel point in the sub-line segment and the first fitting line segment is calculated, and the variance of the distance between each pixel point in the sub-line segment and the first fitting line segment is the fluctuation degree of the sub-line segment.
[0037] In the present application, the length of the sub-segment is taken as the fluctuation length; the maximum distance between the sub-segment and the first fitting segment is taken as the fluctuation amplitude, which can reflect the maximum difference between the sub-segment and the first fitting segment; the variance of the distance between each pixel point in the sub-segment and the first fitting segment can reflect the degree of fluctuation of the sub-segment along the first fitting segment, therefore, the variance of the distance between each pixel point in the sub-segment and the first fitting segment can be taken as the fluctuation degree.
[0038] As another implementation of the first aspect, the step of evaluating the solid line segment according to the fluctuation characteristics of each of the sub-line segments to obtain a total score of the solid line segment includes:
[0039] Evaluate each of the sub-segments according to the fluctuation characteristics of each of the sub-segments to obtain a sub-score for each of the sub-segments;
[0040] Based on the sub-score of each of the sub-segments, a total score of the solid line segment is obtained.
[0041] In the present application, each sub-segment is first evaluated to obtain a sub-score of the sub-segment, and then the total score of the solid line segment is obtained according to the sub-score of the sub-segment. The solid line segment is evaluated in segments, so that the evaluation of the solid line segment is more detailed. In addition, the evaluation of the sub-segment is simpler and faster than the evaluation of the entire solid line segment. Therefore, the sub-segment is evaluated first, and then the solid line segment is evaluated according to the evaluation of the sub-segment, so that the score of the solid line segment can be obtained more quickly and accurately.
[0042] As another implementation of the first aspect, each sub-segment is evaluated according to the fluctuation characteristics of each sub-segment to obtain a sub-score of each sub-segment, including:
[0043] The fluctuation characteristics of the sub-segments are input into the trained sub-segment scoring model to obtain the sub-score of each sub-segment, wherein the sub-segment scoring model is constructed based on a Bayesian network model.
[0044] In the present application, the sub-segment scoring model is used to evaluate the sub-segments, which can quickly and automatically complete the evaluation of the sub-segments; and because the sub-segment scoring model is a trained model, the sub-segment scores obtained using the trained sub-segment scoring model are more accurate.
[0045] As another implementation of the first aspect, obtaining a total score of the solid line segment based on the sub-score of each sub-segment includes:
[0046] Calculate a revised score of each of the sub-segments based on the sub-score of each of the sub-segments and the proportion of each of the sub-segments in the solid line segment;
[0047] Based on the revised score of each of the sub-line segments, a total score of the solid line segment is obtained.
[0048] In the present application, the proportion of the score of the sub-segment in the score of the entire solid-struck line segment can be obtained through the sub-score of each sub-segment and the proportion of each sub-segment in the solid-struck line segment, and then the total score of the entire solid-struck line segment can be obtained based on the sub-scores of all the sub-segments.
[0049] As another implementation of the first aspect, determining, based on the intersection of the first fitting line segment and the scribing trajectory, the sub-segments into which the scribing trajectory is divided by the first fitting line segment includes:
[0050] Based on the intersection of the first fitting line segment and the stroke trajectory, the line segments into which the stroke trajectory is divided by the first fitting line segment are obtained, the first line segment and the last line segment in the stroke trajectory divided by the first fitting line segment are second line segments, the line segments except the second line segments in the line segments are recorded as first line segments, and each of the first line segments is a sub-segment of the solid stroke segment;
[0051] Determine the number of intersections between each of the second line segments and the first fitting line segment;
[0052] If there is a third line segment in the second line segment, determining the maximum deviation degree of the third line segment relative to the first fitting line segment, wherein the third line segment is a second line segment having an intersection point with the first fitting line segment;
[0053] Correcting the third line segment according to the maximum deviation degree to obtain a fourth line segment;
[0054] Determine the fourth line segment as a sub-segment of the solid line segment;
[0055] If there is a fifth line segment in the second line segment, and there are at least two intersection points between the fifth line segment and the first fitting line segment, the fifth line segment is determined as a sub-segment of the solid line segment.
[0056] In the present application, since the first line segment and the last line segment are often special, the first line segment and the last line segment may both have an intersection with the first fitting line segment; and due to writing habits, there may be pauses in the first line segment and the last line segment, resulting in inaccurate evaluation of the first line segment and the last line segment. Therefore, when determining the first line segment and the last line segment on the actual line segment, it is necessary to correct them according to the maximum deviation degree to obtain a more accurate first line segment and the last line segment.
[0057] As another implementation of the first aspect, the third line segment is corrected according to the maximum deviation degree to obtain a fourth line segment, including:
[0058] If the maximum deviation is greater than a preset threshold, a preset number of consecutive pixel points in the third line segment are deleted to obtain a fourth line segment, wherein if the third line segment whose maximum deviation is greater than the preset threshold is the first line segment, a preset number of pixel points are deleted starting from the first pixel point of the first line segment; if the third line segment whose maximum deviation is greater than the preset threshold is the last line segment, a preset number of pixel points are deleted starting from the last pixel point of the last line segment;
[0059] If the maximum deviation degree is less than or equal to the preset threshold, the third line segment is determined as the fourth line segment.
[0060] In the present application, if the maximum deviation degree is greater than the preset threshold, it indicates that there is a pause in the third line segment, and the pause part needs to be deleted to make the final evaluation of the third line segment more accurate and avoid evaluation errors caused by the pause.
[0061] As another implementation of the first aspect, after the third line segment is corrected according to the maximum deviation degree to obtain the fourth line segment, the method further includes:
[0062] determining a length of the fourth line segment;
[0063] If the length of the fourth line segment is less than a preset length, determining the fourth line segment as a sub-segment of the solid line segment;
[0064] If the length of the fourth line segment is greater than or equal to the preset length, performing line fitting on the fourth line segment to obtain a second fitting line segment of the fourth line segment;
[0065] Based on the intersection point between the second fitting line segment and the fourth line segment, each line segment into which the fourth line segment is divided by the second fitting line segment is determined as a sub-segment of the solid line segment.
[0066] In the present application, if the length of the fourth line segment is greater than or equal to the preset length, it means that the fourth line segment is relatively long, and people's subjective feeling of its fluctuation is weak. In order to evaluate the fourth line segment more accurately, the fourth line segment can be segmented again to obtain sub-segments of the fourth line segment. By evaluating the sub-segments of the fourth line segment, a more accurate evaluation of the fourth line segment can be obtained.
[0067] As another implementation of the first aspect, the solid line segment is evaluated according to the fluctuation characteristics of each sub-line segment to obtain a total score of the solid line segment, including:
[0068] If there is a sixth line segment in the sub-line segments of the solid line segment, and the sixth line segment is the fourth line segment whose length is less than the preset length, the fluctuation feature of the sixth line segment is input into the trained first scoring model to obtain a sub-score of the sixth line segment;
[0069] Inputting the fluctuation characteristics of the seventh line segment in the sub-line segments into the trained sub-line segment scoring model to obtain the sub-score of the seventh line segment, wherein the seventh line segment is a sub-line segment in the sub-line segments except the sixth line segment, the first scoring model and the sub-line segment scoring model are different scoring models, and both the first scoring model and the sub-line segment scoring model are constructed based on a Bayesian network model;
[0070] Based on the sub-score of each of the sub-segments, a total score of the solid line segment is obtained.
[0071] In the present application, the fourth line segment whose length is less than the preset length is relatively small, and the user has a stronger subjective feeling about its fluctuation. The sub-segments are evaluated according to different situations, and the fourth line segment whose length is less than the preset length is evaluated separately, so that the total score of the solid line segment finally obtained can be more accurate.
[0072] In a second aspect, an electronic device is provided, comprising a processor, wherein the processor is used to run a computer program stored in a memory to implement any method of the first aspect of the present application.
[0073] In a third aspect, a chip system is provided, including a processor, wherein the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement any method of the first aspect of the present application.
[0074] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, the method of any one of the first aspects of the present application is implemented.
[0075] In a fifth aspect, the present application provides a computer program product, which, when executed on a device, enables the device to execute any one of the methods in the first aspect of the present application.
[0076] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0078] Figure 2 A schematic diagram of a user holding a stylus pen and writing on an electronic device provided in an embodiment of the present application;
[0079] Figure 3 A schematic diagram of the structure of the writing pen landing point on the touch panel and the detection point of the electronic device provided in the embodiment of the present application;
[0080] Figure 4 A schematic diagram of a wavy line appearing on a straight line drawn by a stylus provided in an embodiment of the present application;
[0081] Figure 5 A flowchart of a method for constructing a database provided in an embodiment of the present application;
[0082] Figure 6 A schematic diagram showing the types of lines written by a stylus provided in an embodiment of the present application;
[0083] Figure 7 A schematic diagram of the positional relationship between the actual line segments and the ideal line segments provided in the embodiment of the present application;
[0084] Figure 8 A schematic diagram of a feature extraction method according to an embodiment of the present invention;
[0085] Fig. 9 A schematic diagram of a boundary track of an oblique line provided in an embodiment of the present application;
[0086] Fig.10 A schematic diagram of fitting an ideal line segment according to pixel points on a diagonal line provided in an embodiment of the present application;
[0087] Fig.11 A schematic diagram showing sub-segments divided by an ideal line segment into a solid line segment provided in an embodiment of the present application;
[0088] Fig.12 A flowchart of a model training method provided in an embodiment of the present application;
[0089] Fig.13 A schematic diagram of the structure of the Bayesian network model provided in the embodiment of the present application;
[0090] Fig.14A schematic diagram of a flow chart of a handwriting stroke evaluation method provided in an embodiment of the present application;
[0091] Fig.15 A schematic diagram showing that the ideal line segment provided in the embodiment of the present application has only one intersection with the last sub-line segment;
[0092] Fig.16 A schematic diagram of a flow chart of another handwriting stroke evaluation method provided in an embodiment of the present application;
[0093] Fig.17 A schematic diagram of a handwritten pen stroke having a pen tip in an embodiment of the present application;
[0094] Fig.18 A schematic diagram of the structure of a handwritten stroke evaluation method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0095] In the following description, specific details such as specific system structures and technologies are provided for illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application can also be implemented in other embodiments without these specific details.
[0096] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0097] It should also be understood that in the embodiments of the present application, "one or more" refers to one, two or more than two; "and / or" describes the association relationship of associated objects, indicating that three relationships may exist; for example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B may be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0098] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", "fourth", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0099] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0100] The handwriting stroke evaluation method provided in the embodiment of the present application can be applied to electronic devices such as tablet computers, mobile phones, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc. The embodiment of the present application does not limit the specific type of electronic devices.
[0101] Figure 1 The schematic diagram of the structure of an electronic device is shown. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a touch sensor 180K, etc.
[0102] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0103] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0104] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0105] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0106] The internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
[0107] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from the wired charger through the USB interface 130 .
[0108] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160.
[0109] In some other embodiments, the power management module 141 may also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 may also be disposed in the same device.
[0110] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0111] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0112] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1.
[0113] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0114] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. A capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure based on the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the intensity of the touch operation based on the pressure sensor 180A. The electronic device 100 can also calculate the position of the touch based on the detection signal of the pressure sensor 180A.
[0115] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0116] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0117] The display screen 194 is used to display images, videos, etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.
[0118] The embodiment of the present application does not particularly limit the specific structure of the execution subject of the method for evaluating a handwritten stroke line, as long as the code of the method for evaluating a handwritten stroke line according to the embodiment of the present application can be run to perform processing according to the method for evaluating a handwritten stroke line provided by the embodiment of the present application. For example, the execution subject of the method for evaluating a handwritten stroke line provided by the embodiment of the present application can be a functional module in an electronic device that can call and execute a program, or a processing device applied to an electronic device, such as a chip.
[0119] As the needs of users increase, the functions of electronic devices are becoming more and more powerful. To facilitate users in drawing lines, making marks, drawing pictures, etc. on electronic devices, the application of a stylus on electronic devices has been realized. Since the stylus is more accurate and convenient than fingers when writing on an electronic device, the stylus is becoming more and more popular among users.
[0120] In actual use, the user holds the stylus and moves it on the display screen of the electronic device. The electronic device senses the contact position of the stylus through a sensor, determines the movement trajectory of the stylus according to the contact position of the stylus, and then the electronic device displays the line segment drawn by the stylus. As Figure 2 shown, the user holds the stylus and draws a "rice" character pattern and a broken line on the electronic device.
[0121] When using a stylus to draw a line on an electronic device, restricted by the size and structure of the sensors in the electronic device, there are gaps between the sensors in the electronic device, and the sensors cannot be arranged closely. When using the stylus for operation, the landing position of the stylus will be affected by the holding posture and environmental noise, etc. The landing position of the stylus is corrected by the algorithm in the electronic device, resulting in the landing position being close to the sensor with the strongest induction amount, causing the reported position of the electronic device to deviate from the actual contact position of the stylus. In this case, when the user uses the stylus to draw a line, due to the deviation between the reported position and the contact position, wavy lines will appear on the line segment drawn by the stylus displayed by the electronic device, and the writing experience is poor.
[0122] As an example, as Figure 3 shown in the touch panel, point A on the touch panel is the landing position of the stylus, that is, the contact position; point B is the reported position generated by the electronic device according to the landing position of the stylus after detecting the landing position of the stylus. The reported position of the electronic device deviates from the actual landing position of the stylus. If the user is drawing a straight line, due to the deviation of the reported position, wavy lines will appear on the drawn straight line, as Figure 4 shown.
[0123] Regarding the problem of abnormal wavy lines appearing when using a stylus to draw a line, currently, developers mostly observe the image drawn by the stylus manually, and then determine the frequency and length of the abnormal wavy lines, etc. According to the observed results, the method of identifying the position of the stylus in the electronic device is optimized, thereby improving the performance of the electronic device.
[0124] However, the method of manually judging the line-drawing performance of the stylus is not accurate enough, resulting in poor optimization effect and low efficiency of the performance of the electronic device. Therefore, developing an intelligent evaluation method for stylus line drawing is the current main task.
[0125] In view of this, an evaluation method for the lines drawn by a stylus is provided in an embodiment of the present application. By extracting the line segments drawn by the stylus, segmenting the extracted line segments to obtain sub-line segments, and extracting features of each sub-line segment to obtain the fluctuation features of the sub-line segments, where the fluctuation features include one or more of the fluctuation length, fluctuation amplitude, and fluctuation degree of the sub-line segments, and the fluctuation degree can be characterized by calculating the variance. According to the fluctuation features of each sub-line segment, the trained evaluation model is used to evaluate each sub-line segment to obtain the score of each sub-line segment. Finally, according to the scores of each sub-line segment, the total score of the line segment drawn by the stylus is calculated. Through the present application, the intelligent evaluation of the line segment drawn by the stylus is realized, and the evaluation efficiency of the line segment drawn by the stylus is improved.
[0126] Next, before introducing the evaluation method for the lines drawn by the stylus in the present application, a method for creating the evaluation model used in the present application will be introduced first.
[0127] Specifically, the creation process of the evaluation model mainly includes database construction, feature extraction of the lines, and model training.
[0128] As Figure 5 shown, the method for database construction will be introduced first.
[0129] S11. Obtain the line segments drawn by the stylus, and extract the line types of the line segments drawn by the stylus from the line segments drawn by the stylus.
[0130] In this embodiment, since all graphics are composed of line segments, the graphics drawn by the stylus can be regarded as the line segments drawn by the stylus.
[0131] Specifically, obtain multiple pictures on which there are graphics generated after a user and / or a manipulator hold a stylus to perform a first operation on an electronic device. The first operation can be a writing operation, a drawing operation, a line-drawing operation, etc., and the graphics drawn by the stylus can be line segments, characters, pictures, etc.
[0132] Classify the graphics on the pictures and find that all the graphics can be composed of one or more of diagonal lines, straight lines, arcs, broken lines, and wavy lines. As Figure 6 shown, the shapes of diagonal lines, straight lines, arcs, broken lines, and wavy lines are shown in the figure. Therefore, the line types of the stylus can include diagonal lines, straight lines, arcs, broken lines, and wavy lines.
[0133] As an example, when a user uses a stylus to write the character "米" on an electronic device, the character "米" is composed of straight lines and diagonal lines.
[0134] S12. Determine the sensitive factors that trigger the problem of abnormal wavy lines when the stylus writes.
[0135] Specifically, through research on a large number of stylus strokes, it is found that different writing habits of users using the stylus and different structures of the touch panel of the electronic device will affect the shape of the stylus stroke. Therefore, by analyzing and comparing abnormal wavy lines in different scenarios, sensitive factors that trigger abnormal wavy lines when using the stylus for writing can be obtained.
[0136] Specifically, the sensitive factors may include: the holding angle of the stylus, the stroke speed, the pen-down pressure, the stroke angle, the accessory film, and the charging interference of the electronic device. Among them, the stroke angle generally refers to the oblique stroke. The accessory film can include a tempered film and a common film. The common film mainly includes a polyester resin film and a polyurethane film. The main material of the tempered film is glass.
[0137] As an example, the shapes of the abnormal wavy lines obtained when the user holds the stylus at an angle of 45° for stroking and when the user holds the stylus at an angle of 90° for stroking are different.
[0138] S13. Based on the sensitive factors and the stroke types, use the stylus to make strokes to obtain multiple sample pictures, and there are line segments drawn by the stylus in the sample pictures.
[0139] In this embodiment, the sample pictures can be pictures obtained by a user or a manipulator using the stylus to make strokes on the electronic device based on different sensitive factors. The graphics in the sample pictures cover all stroke types.
[0140] When constructing the database, the holding angle can be set to 90°, 45°, 60°, etc. The stroke speed can be set to 5 mm / s, 10 mm / s, 20 mm / s, 30 mm / s, etc. The pen-down pressure can be set to 1 N, 2 N, 3 N, etc. The stroke angle can be 10°, 40°, 60°, etc.
[0141] As an example, the user holds the stylus so that the angle between the stylus and the electronic device is 45°, and uses the stylus to draw a circle on the electronic device to obtain a sample picture. The user holds the stylus so that the angle between the stylus and the electronic device is 90°, and uses the stylus to draw a circle on the electronic device to obtain a sample picture. The user holds the stylus so that the angle between the stylus and the electronic device is 45°, and uses the stylus to write the character "米" on the electronic device to obtain a sample picture. The user holds the stylus so that the angle between the stylus and the electronic device is 60°, and uses the stylus to draw a simple sketch of a puppy on the electronic device to obtain a sample picture.
[0142] S14. Store the sample pictures to generate a database.
[0143] In this embodiment, the database is used for subsequent model training.
[0144] In this embodiment, a full-scenario database is constructed based on sensitive factors and line types, so that all types of line segments and line scenes can be covered during subsequent model training, making the trained evaluation model applicable to all scenes.
[0145] Next, the feature extraction of the line is described based on the constructed database. For the sake of convenience, this application takes the oblique line segment drawn by the stylus as an example for description. For straight lines, arcs, broken lines and wavy lines, the description of the oblique line can be referred to, and will not be repeated in this application.
[0146] In some embodiments, in an ideal state, when a handwriting pen is used to draw an oblique line, there should be no wavy lines on the oblique line drawn, but a completely straight line segment. However, due to the error of the electronic device in detecting the actual contact point of the handwriting pen, an abnormal wavy line appears on the oblique line when the handwriting pen is used to draw an oblique line. After research, it is found that the abnormal wavy line on the oblique line fluctuates up and down along the straight oblique line (ideal line segment) in the ideal state, and the part of the oblique line without abnormal wavy lines coincides with the ideal line segment, such as Figure 7 As shown; therefore, after extracting the ideal line segment of the oblique line (solid line segment) drawn by the stylus, the fluctuation degree of the abnormal wave line can be determined according to the ideal line segment.
[0147] Based on the fluctuation characteristics of the above-mentioned wave lines, the feature extraction method is set as follows: extract the solid line segments drawn by the stylus in the sample image; perform line fitting on the solid line segments to obtain fitted line segments, which are ideal line segments when no abnormal wave lines appear in the solid line segments; segment the solid line segments based on the fitted line segments to obtain sub-segments of the solid line segments; perform feature extraction on each sub-segment to obtain the fluctuation characteristics of each sub-segment.
[0148] The following is a detailed description of the feature extraction method. Figure 8 shown.
[0149] S21, obtaining a sample image.
[0150] S22, extracting the trajectory of the solid line segment in the sample image to obtain the boundary trajectory of the solid line segment.
[0151] In this embodiment, since the thickness of the line can be selected when the handwriting pen draws the line, the solid line segment drawn by the handwriting pen has a certain width or thickness. When extracting the trajectory of the solid line segment, in order to more realistically and accurately reflect the trajectory of the solid line segment, the trajectory of the boundary line of the solid line segment can be extracted to obtain the boundary trajectory of the solid line segment. For oblique lines, the boundary trajectory can be an upper boundary trajectory and a lower boundary trajectory. In this application, the upper boundary trajectory of the oblique line is extracted as an example for explanation. In actual use, the lower boundary trajectory can also be used.
[0152] Specifically, the trajectory extraction method includes:
[0153] Step 1: Convert the sample image into a grayscale image to obtain the grayscale value of each pixel in the sample image.
[0154] Step 2: Binarize the grayscale image of the sample image according to the grayscale value of each pixel to obtain a binary image of the sample image.
[0155] Specifically, the pixel values of the pixels in the grayscale image whose grayscale values are greater than the preset threshold are set to 255, and the pixel values of the pixels whose grayscale values are less than the preset threshold are set to 0, so as to obtain a binary image. It should be noted that 255 and 0 are both examples, and in actual use, other parameters can also be set, which are not limited here.
[0156] Step 3: extract the boundary of the solid line segment according to the pixel value of each pixel point in the binary image to obtain the boundary trajectory of the solid line segment.
[0157] Specifically, when extracting the upper boundary trajectory of the oblique line, traverse each column of pixels in the binary image from top to bottom, find the first pixel with a pixel value of 255 in each column, and record the first pixel with a pixel value of 255 in each column as the first pixel. All the first pixels found constitute the upper boundary trajectory of the solid line segment. If the lower boundary trajectory is needed, it is necessary to find the last pixel with a pixel value of 255 in each column, record the last pixel with a pixel value of 255 in each column as the second pixel, and all the second pixels constitute the lower boundary trajectory of the solid line segment.
[0158] As an example, Fig. 9 As shown in the figure, an oblique line drawn with a handwritten stroke is shown, in which there are abnormal wavy lines. Trajectory extraction is performed on the oblique line to obtain an upper boundary trajectory and a lower boundary trajectory of the oblique line.
[0159] When extracting straight lines (such as Figure 6 When extracting the upper boundary track of the straight line shown in FIG. 1 , the boundary track of the horizontal line in the straight line can be first extracted according to the method for extracting the boundary track of the oblique line. For the vertical line in the straight line, each row of pixels can be traversed from left to right to obtain the boundary track of the vertical line. The boundary track of the horizontal line and the boundary track of the vertical line constitute the boundary track of the straight line.
[0160] for Figure 6 The boundary tracks of the wavy lines and broken lines drawn by the handwriting pen shown in can be extracted according to the method for extracting the boundary tracks of straight lines. The wavy lines and broken lines are segmented and the boundary tracks of each segment are extracted. The details will not be repeated here.
[0161] for Figure 6 The outer boundary trajectory of the arc drawn by the stylus shown in the figure can divide the circle from the middle into two identical upper and lower semicircles. For the upper semicircle: extract the boundary trajectory according to the above-mentioned boundary trajectory extraction method of the oblique line. For the lower semicircle: traverse each column of pixels from bottom to top, find the first pixel with a pixel value of 255, and obtain the boundary trajectory of the lower semicircle.
[0162] S23, performing line fitting based on the boundary trajectory of the solid line segment to obtain an ideal line segment of the solid line segment.
[0163] In this embodiment, the ideal line segment of the solid line segment is a line segment drawn by the stylus in an ideal state, wherein the ideal state is a state where there is no deviation in the contact position of the stylus detected by the electronic device and there is no abnormal wavy line in the solid line segment.
[0164] Specifically, the ideal position of each pixel point in the boundary trajectory of the solid line segment is determined, and the ideal position of each pixel point in the boundary trajectory of the solid line segment constitutes an ideal line segment of the solid line segment.
[0165] In one embodiment, based on the boundary trajectory of the solid line segment, the line fitting is performed using the least square method to obtain the ideal line segment of the solid line segment.
[0166] The principle of the least squares method is to find the best function matching for the data by minimizing the sum of squares of errors so that the sum of squares of errors between the obtained data and the actual data is minimized.
[0167] Specifically, when the solid line segment is an oblique line, the method for obtaining the ideal line segment of the solid line segment includes:
[0168] The initial regression model of the oblique line is obtained, and the value of the first parameter in the initial regression model is unknown. The value of the first parameter in the regression model of the oblique line is calculated using the least squares method. The first parameter is input into the initial regression model of the oblique line to obtain the target regression model. Using the target regression model, the ideal position of each track point (or pixel point) in the boundary track of the solid line segment is obtained, and the ideal positions of all track points constitute the ideal line segment of the solid line segment.
[0169] In this embodiment, the initial regression model with diagonal lines is a univariate linear regression model, specifically, ,in, is the ideal position of each track point in the boundary track of the solid line segment to be determined; and is the first parameter; is the actual position of each track point in the boundary track of the solid line segment.
[0170] The formula for the least squares method is: , is the sum of squares of the errors between the observed and predicted values; is the observed value, that is, the actual position of each trajectory point in the boundary trajectory of the solid line segment; is the predicted value, that is, the ideal position of each track point in the boundary track of the solid line segment, . is a random error. For example, Fig.10 As shown, the points in the figure are trajectory points on the boundary trajectory, and the oblique lines in the figure are ideal line segments fitted according to the least squares method.
[0171] Based on the least squares formula and the univariate linear regression model, the solution equation for the first parameter is obtained:
[0172] ;
[0173] in, The sum of squares of the errors between the observed value and the predicted value is minimized; m is the total number of trajectory points (pixel points) in the boundary trajectory of the solid line segment.
[0174] After derivation, and The values are:
[0175] ;
[0176] .
[0177] It should be noted that different types of line drawing use different regression models when performing line drawing fitting.
[0178] When the solid line segment is a straight line, the regression model is a univariate linear regression model.
[0179] When the solid line segment is a wavy line, the regression model is a nonlinear regression model. For example, the nonlinear regression model may be a Gaussian iteration model.
[0180] When the solid line segment is a broken line, segmented fitting is required, and the regression model of each segment is a univariate linear regression model.
[0181] When the solid line segment is an arc, the regression model is a high-dimensional nonlinear equations regression model. For example, the high-dimensional nonlinear equations regression model is a Lagrangian model or a Gauss-Newton iterative model.
[0182] S24, determining a plurality of sub-segments into which the actual line segment is divided by the ideal line segment, and calculating the fluctuation characteristics of each sub-segment.
[0183] In this embodiment, since the abnormal wavy line fluctuates up and down along the ideal line segment, there is an intersection between the ideal line segment and the abnormal wavy line. Since there is an intersection between the ideal line segment and the abnormal wavy line, the ideal line segment can divide the solid line segment into multiple sub-line segments. Specifically, the continuous overlapping part of the solid line segment with the ideal line segment is a sub-line segment; the solid line segment between two adjacent intersections of the ideal line segment and the solid line segment is a sub-line segment.
[0184] As an example, Fig.11 As shown in the figure, there is no abnormal wavy line in sub-segment 1 of the solid line segment, and sub-segment 1 completely overlaps with the ideal line segment. Sub-segment 2 of the solid line segment is an abnormal wavy line, and there are two intersections between sub-segment 2 and the ideal line segment. Sub-segment 3 of the solid line segment is an abnormal wavy line, and there are two intersections between sub-segment 3 and the ideal line segment. There is no abnormal wavy line in sub-segment 4 of the solid line segment, and sub-segment 4 completely overlaps with the ideal line segment.
[0185] In this embodiment, the method for determining the fluctuation characteristics of abnormal wave lines is specifically as follows: a large number of line segments drawn by a handwriting pen are collected, abnormal wave lines appearing in the line segments are extracted, and by comparing different abnormal wave lines, it can be concluded that different abnormal wave lines have different fluctuation amplitudes, fluctuation lengths, fluctuation positions in the line segments, and the number of fluctuations appearing in the line segments. Therefore, the fluctuation amplitude, fluctuation length, fluctuation position, fluctuation number, fluctuation degree, etc. can be used as fluctuation characteristics of abnormal wave lines.
[0186] When calculating the fluctuation characteristics of a sub-segment, the present application needs to calculate at least one of the fluctuation length, fluctuation amplitude and fluctuation degree of the sub-segment.
[0187] The fluctuation length of a sub-segment is the length of the straight line between the two endpoints of the sub-segment.
[0188] The fluctuation amplitude of a sub-segment is the maximum distance between the sub-segment and the corresponding ideal segment.
[0189] The fluctuation degree of the sub-line segment represents the degree of deviation between the actual line segment and the ideal line segment. Therefore, the fluctuation degree can be obtained by calculating the variance of the distance between the pixel point in the actual line segment and the ideal line segment. The calculation formula of the fluctuation degree is:
[0190] , is the variance between the ideal line segment and the actual line segment; is the number of pixels in the sub-segment; is the fluctuation amplitude of each pixel in the sub-segment, that is, the distance between the pixel in the sub-segment and the ideal segment; is the average of the fluctuation amplitudes of all pixels in the sub-segment. It can be seen that the fluctuation degree of the sub-segment can be calculated by the fluctuation amplitude and fluctuation length of each pixel.
[0191] As an example, see Fig.11 , the figure shows the characterization method of the fluctuation length and fluctuation amplitude of sub-segment 3.
[0192] From this point on, the feature extraction part of the line drawing is finished.
[0193] After the line feature extraction is performed, the model training is performed based on the fluctuation characteristics of the extracted sub-line segments.
[0194] In one possible implementation, a Bayesian network model is constructed based on the fluctuation characteristics of the sub-segments; a functional relationship between the fluctuation characteristics of the sub-segments and the sub-segment scoring model is determined based on the Bayesian network model; the sub-segment scoring model is trained to obtain a trained sub-segment scoring model. Each sub-segment is evaluated using the trained sub-segment scoring model to obtain a sub-score for each sub-segment. The sub-score of each sub-segment is used to calculate the total score of the segment actually drawn by the stylus.
[0195] Specifically, see Fig.12 , the model training process includes:
[0196] S31, constructing a Bayesian network model based on the fluctuation characteristics of the sub-segments, and determining the variable nodes and directed edges in the Bayesian network model.
[0197] The Bayesian network model is composed of nodes representing variables and directed edges connecting these nodes; variable nodes represent random variables, and directed edges between nodes represent the relationship between nodes (from parent nodes to their child nodes). Conditional probabilities are used to express the strength of relationships, and prior probabilities are used to express information for nodes without parents. The Bayesian network model can be recorded as G=(I, E), where I is the set of all nodes and E is the set of all directed edges.
[0198] In this application, the sub-score of the sub-segment is calculated based on the fluctuation length L, fluctuation amplitude D and fluctuation degree V of the sub-segment; the total score of the solid line segment is calculated based on the sub-score of each sub-segment; based on this, the application is associated with the Bayesian network model to obtain Fig.13 The Bayesian network model shown in , where L(i) is the fluctuation length of the i-th sub-segment; D(i) is the fluctuation amplitude of the i-th sub-segment; V(i) is the fluctuation degree of the i-th sub-segment; s(i) is the sub-score of the i-th sub-segment; S is the total score of the solid line segment; and f is the sub-segment scoring model.
[0199] Depend on Fig.13 From the Bayesian network model in, we can get: There are four variable nodes in this application, namely, fluctuation length L(i), fluctuation amplitude D(i), fluctuation degree V(i) and sub-segment sub-score s(i).
[0200] Among them, the sub-score s(i) is calculated by the fluctuation length L(i), the fluctuation amplitude D(i) and the fluctuation degree V(i); the fluctuation degree V(i) is calculated based on the fluctuation length L(i) and the fluctuation amplitude D(i).
[0201] From the above relationship, it can be seen that the four variable nodes can form five directed edges, namely: L(i)→V(i), D(i)→V(i), V(i)→s(i), L(i)→s(i), D(i)→s(i), s(i) is the parent node, L(i), V(i) and D(i) are all child nodes.
[0202] S32, based on the variable nodes and directed edges in the Bayesian network model, determine the functional relationship between the fluctuation characteristics of the sub-segment and the sub-score of the sub-segment; the functional relationship between the fluctuation characteristics of the sub-segment and the sub-score of the sub-segment is the sub-segment scoring model.
[0203] Specifically, the joint probability distribution of each node in the Bayesian network model is:
[0204] ;
[0205] in, is the joint probability distribution of each node; is the number of child nodes; For child nodes, for The parent node of for The probability of a node, The sub-score s(i) representing the i-th sub-segment; Characterizes the variance of the i-th sub-segment; is the wave length; Fluctuation range; For one with Related functions, used according to Calculating sub-scores , that is Fig.13 The factor node f in .
[0206] After reasoning, it is found that the larger the variance of the sub-segment, the greater the user's subjective feeling of the abnormal wave line. The larger the fluctuation amplitude of the sub-segment, the greater the user's subjective feeling of the abnormal wave line. The longer the fluctuation length of the sub-segment, the smaller the user's subjective feeling of the abnormal wave line. Therefore, based on the user's subjective feeling, the feeling evaluation of the abnormal wave line with L(i), V(i) and D(i) is established .
[0207] In order to simplify the relationship between L(i), V(i) and D(i), the disorder factor θ is introduced and θ is used to represent the relationship between L(i), V(i) and D(i). The joint probability distribution becomes ; and is the model parameter to be determined (the parameter that needs to be determined for model training), and we get and Then the relationship between L(i), V(i) and D(i) can be obtained; for The compensation value of θ is the parameter related to L(i), V(i) and D(i). and and Related, and Model parameters to be determined in the sub-segment scoring model.
[0208] S33, training the sub-segment scoring model according to the fluctuation characteristics of the sub-segments to obtain a trained sub-segment scoring model.
[0209] In this embodiment, during the first training, the model parameters ( and ) is assigned an initial value, the fluctuation characteristics of the sub-segment are input into the sub-segment scoring model to train the sub-segment scoring model, and the first expected value of the sub-score of the sub-segment is obtained; the model parameters are corrected according to the first expected value of the sub-score, and the sub-segment scoring model after the first training is obtained. During the second training, the fluctuation characteristics of the sub-segment are input into the sub-segment scoring model to train the sub-segment scoring model, and the second expected value of the sub-score of the sub-segment is obtained; the model parameters are corrected according to the second expected value of the sub-score, and the sub-segment scoring model after the second training is obtained. Continue to train the sub-segment scoring model according to the above process until the preset number of training times is reached, or until the sub-segment scoring model converges, and the model parameters ( and ), and the final trained sub-segment scoring model is also obtained.
[0210] In one possible implementation, the Expectation-Maximum (EM) algorithm may be used to train the sub-segment scoring model.
[0211] Specifically, in the first step, the model parameters in the sub-segment scoring model ( and ) is assigned an initial value. The second step, step E (expectation step), inputs the fluctuation characteristics of the sub-segment into the sub-segment scoring model to obtain the expected value of the sub-segment sub-score (observation variable), that is, to calculate the posterior probability distribution of the observation variable ,in, is a hidden variable ; is the observed variable s(i); is the model parameter and The third step is the M step (maximum step). When the sub-score is the expected value calculated in the second step, the maximum likelihood estimation algorithm is used to calculate the maximized parameters of the model parameters and obtain the new model parameters (new parameter estimates). . Step 4: Use the model parameters obtained in step 3 to update the sub-segment scoring model to obtain the sub-segment scoring model with updated parameters. Repeat steps 2 and 3 to continue training the sub-segment scoring model with updated parameters until the sub-segment scoring model converges, that is, the change in the parameter estimation value of the sub-segment scoring model is very small, and obtain the final model parameters. Input the final model parameters into the sub-segment scoring model to obtain the final trained sub-segment scoring model.
[0212] From then on, the training of the sub-segment scoring model in the evaluation model is completed. It should be noted that the sub-segment scoring model can also be a neural network model or a model designed using other algorithms, which is not limited here.
[0213] S34, constructing a calculation model for the total score of the solid line segments of the sub-scores to obtain a total score model.
[0214] In this embodiment, the calculation process of the total score model is to calculate the revised score of each sub-segment based on the sub-score of each sub-segment and the proportion of each sub-segment in the solid line segment; based on the revised score of each sub-segment, the total score of the solid line segment is obtained.
[0215] The overall scoring model includes: ,in, is the total score of the solid line segment; is the total number of sub-segments; is the sub-score of the ith sub-segment; is the total length of the solid dashed line segments; is the length of the i-th sub-segment.
[0216] In summary, the evaluation model can include a sub-segment scoring model and an overall scoring model.
[0217] After the trained evaluation model is obtained, the solid line segments drawn by the stylus pen can be evaluated based on the trained evaluation model, and the evaluation results can be output.
[0218] Next, if Fig.14 As shown, combined with the trained evaluation model, the handwritten stroke line evaluation method proposed in this application is introduced in detail.
[0219] S101, obtaining a first picture, wherein the first picture contains a solid line segment written by a stylus pen.
[0220] In this embodiment, the first picture is a picture generated after the stylus pen writes on the electronic device, so the first picture can be a picture in the electronic device. There can be one or more solid line segments in the first picture.
[0221] S102, segmenting the solid line segment to obtain sub-segments of the solid line segment.
[0222] In this embodiment, the solid line segment is segmented according to a preset rule, and the preset rule includes: dividing a continuous line segment without abnormal wavy lines into a segment; dividing each abnormal wave into a segment. Alternatively, the solid line segment is divided into preset equal parts, and each segment is a sub-line segment.
[0223] Alternatively, the solid line segment is fitted to obtain an ideal line segment (first fitted line segment) of the solid line segment; and based on the intersection of the first fitted line segment and the solid line segment, each sub-segment into which the solid line segment is divided by the first fitted line segment is determined.
[0224] S103, calculating the fluctuation characteristics of each sub-segment.
[0225] In this embodiment, the fluctuation characteristics include at least one of fluctuation length, fluctuation amplitude and fluctuation degree.
[0226] In one implementation, two endpoints of the sub-line segment are connected to obtain a straight line with the two endpoints of the sub-line segment as endpoints. According to the positional relationship between the sub-line segment and the corresponding straight line, the fluctuation characteristics of the sub-line segment are obtained.
[0227] S104: Determine the total score of the solid line segments in the first image according to the fluctuation characteristics of each sub-line segment.
[0228] In one implementation, the method for calculating the total score may include:
[0229] The average value of the fluctuation characteristics of each sub-segment is calculated, and the total score of the solid line segment in the first picture is obtained according to the average value of the fluctuation characteristics.
[0230] Specifically, the average of the fluctuation amplitudes of each sub-segment is calculated to obtain the average fluctuation amplitude.
[0231] Calculate the average of the fluctuation lengths of each sub-segment to obtain the average fluctuation length.
[0232] Calculate the average of the fluctuation levels of each sub-segment to obtain the average fluctuation level.
[0233] The mean value of the fluctuation amplitude, the mean value of the fluctuation length and the mean value of the fluctuation degree are input into the score calculation model to obtain the total score of the solid line segment in the first picture. The score calculation model can be a neural network model or the like.
[0234] Alternatively, calculate the product of the mean fluctuation amplitude and the first coefficient to obtain the first value; calculate the product of the mean fluctuation length and the second coefficient to obtain the second value; calculate the product of the mean fluctuation degree and the third coefficient to obtain the third value; calculate the sum of the first value, the second value and the third value to obtain the sum value; look up the score corresponding to the sum value in a pre-stored table, and determine the score corresponding to the sum value as the total score of the solid line segment in the first picture.
[0235] In one implementation, the method for calculating the total score may further include:
[0236] Based on the fluctuation characteristics of the sub-line segments, a sub-score of each sub-line segment is calculated. Based on the sub-score of each sub-line segment, a total score of the solid line segments in the first image is calculated.
[0237] Specifically, the sub-score determination method includes:
[0238] The fluctuation characteristics of the sub-segments are input into the trained sub-segment scoring model to obtain the sub-score of each sub-segment.
[0239] Alternatively, a table is looked up according to the fluctuation characteristics of the sub-segment to obtain the sub-score corresponding to the fluctuation characteristics of the sub-segment, and the corresponding relationship between each fluctuation characteristic and the sub-score is pre-stored. When the sub-score is determined by looking up the table according to the fluctuation characteristics of the sub-segment, the sub-score of the sub-segment can be obtained by looking up the table using one or more of the fluctuation length, fluctuation amplitude and fluctuation degree.
[0240] Specifically, the method for determining the total score includes:
[0241] The total score of the solid line segment may be the sum of each sub-score.
[0242] Alternatively, each sub-score is multiplied by a scoring coefficient to obtain a modified score for each sub-score. The modified scores of all sub-segments are added together to obtain a total score for the solid line segment. The scoring coefficient is a preset fixed value.
[0243] Or, using the above total score model Calculate the total score of the solid line segments.
[0244] It should be noted that after the total score of the solid line segments is obtained, the performance of the electronic device can be evaluated based on the total score of the line segments drawn by the stylus pen, and the performance of the electronic device can be optimized.
[0245] In an achievable manner, the handwriting stroke evaluation method may further include:
[0246] S201, obtaining a first picture.
[0247] S202 , extracting trajectories of solid line segments in the first image to obtain boundary trajectories (line trajectories) of the solid line segments.
[0248] In this embodiment, the description of step S202 refers to the description of step S22 , which will not be repeated here.
[0249] In this embodiment, when extracting the boundary track, an edge detection algorithm may also be used to extract the boundary track.
[0250] S203 , performing line fitting based on the boundary trajectory of the solid line segment and the line segment type of the solid line segment to obtain an ideal line segment (a first fitting line segment) of the solid line segment.
[0251] In this embodiment, the description of step S203 refers to the description of step S23 above, which will not be repeated here.
[0252] S204: Divide the solid line segment into a plurality of sub-segments according to the intersection points between the ideal line segment of the solid line segment and the solid line segment.
[0253] S205, calculating the fluctuation characteristics of each sub-segment.
[0254] In one implementation, the fluctuation characteristics of each sub-segment are calculated according to the positional relationship between the solid line segment and the ideal line segment. For details, please refer to the description of step S24 above, which will not be repeated here.
[0255] S206: Determine the total score of the solid line segments in the first image according to the fluctuation characteristics of each sub-line segment.
[0256] In this embodiment, the description of step S206 refers to the description of step S104 , which will not be repeated here.
[0257] In practical applications, the beginning and the end of a solid line segment are often quite special. In order to more accurately obtain the total score of the solid line segment, the beginning and the end areas of the solid line segment may be processed separately.
[0258] Specifically, if the solid line segment is segmented into sub-segments using an ideal line segment, the first sub-segment (first line segment) and the last sub-segment (last line segment) of the solid line segment have at least two intersections with the ideal line segment, which means that the ideal line segment can divide the first sub-segment and the last sub-segment into closed intervals. The sub-segment scoring model after the above training can be used to obtain the sub-segment scores of the first sub-segment and the last sub-segment.
[0259] If abnormal wavy lines appear at the beginning and end of a solid line segment, when the solid line segment is segmented into sub-segments using an ideal line segment, it often happens that the first and last sub-segments of the solid line segment have only one intersection with the ideal line segment, that is, the ideal line segment cannot divide the first and last sub-segments into closed intervals, such as Fig.15 As shown, there is only one intersection between the ideal line segment and the last sub-line segment. In this case, the sub-score of the sub-line segment can be obtained by the following method.
[0260] like Fig.16 Specifically, the method of the present application may further include:
[0261] S301, obtaining a first picture.
[0262] S302 , extracting trajectories of solid line segments in the first image to obtain boundary trajectories (line trajectories) of the solid line segments.
[0263] S303 , performing line fitting based on the boundary trajectory of the solid line segment and the line segment type of the solid line segment to obtain an ideal line segment (a first fitting line segment) of the solid line segment.
[0264] S304, dividing the solid line segment into a plurality of line segments according to the intersection of the ideal line segment of the solid line segment and the solid line segment, wherein the first line segment is the first line segment, the last line segment is the last line segment, and each line segment except the first line segment and the last line segment (each line segment except the first line segment and the last line segment is the first line segment) is a sub-segment of the solid line segment.
[0265] S305, determining whether each second line segment in the solid line segment has an intersection with the ideal line segment, and recording the first line segment and the last line segment as the second line segment.
[0266] In this embodiment, whether the first line segment is divided into closed intervals by the ideal line segment is determined by the number of intersections between the first line segment and the ideal line segment. If the first line segment and the ideal line segment have two intersections, it is determined that the first line segment is divided into closed intervals by the ideal line segment; if the first line segment and the ideal line segment have one intersection, it is determined that the first line segment is not divided into closed intervals by the ideal line segment.
[0267] The relationship between the tail line segment and the ideal line segment is the same and will not be repeated here.
[0268] S306: If the second line segment has at least two intersection points with the ideal line segment (the ideal line segment having two intersection points with the ideal line segment is recorded as the fifth line segment), the second line segment is determined as a sub-segment of the solid line segment.
[0269] S307, if the second line segment has an intersection with the ideal line segment (the second line segment having an intersection with the ideal line segment is recorded as the third line segment), calculate the distance between the pixel point in the second line segment and the ideal line, and determine whether the maximum distance (maximum deviation degree) is greater than the preset distance.
[0270] In this embodiment, in order to reduce calculation, the distance between the pixel point of the first area in the second line segment and the ideal line can be calculated. When the second line segment is the first line segment, the first area is the starting area of the first line segment; when the target line segment is the last line segment, the first area is the ending area of the last line segment.
[0271] In this embodiment, when writing with a stylus pen, there may be pauses or pen tip operations at the start and end positions of the line segment, such as Fig.17 As shown. Due to the presence of pauses or pen stroke operations, the pixel values of the pixels at the start and end positions of the line segment may have a sudden change, that is, the distance (degree of deviation) between the pixel points at the start and end positions and the ideal line will suddenly increase. If there is a sudden change in the pixel values of the pixel points at the start and end positions of the line segment, when calculating the fluctuation characteristics or sub-scores of the first and last line segments, this sudden change will be misjudged as a wavy line with large fluctuations, which will ultimately lead to inaccurate evaluation of the actual line segment. Therefore, in order to improve the accuracy of the evaluation of the actual line segment, it is necessary to first determine whether there is a sudden change in the first and last line segments.
[0272] S308: If the maximum distance between the pixel point and the ideal line is greater than a preset distance, a preset number of pixel points in the second line segment are discarded to obtain a corrected line segment (a fourth line segment) corresponding to the second line segment.
[0273] In this embodiment, pixels with a larger degree of deviation often appear in the first two or three pixels, or the last two or three pixels of the solid line segment. Therefore, the preset number can be set as needed. For example, the preset number can be set to 5, 6, etc., and there is no limitation here.
[0274] Specifically, if the second line segment is the first line segment, a preset number of pixels in the first line segment are discarded starting from the first pixel; if the second line segment is the last line segment, a preset number of pixels in the last line segment are discarded starting from the last pixel.
[0275] In this embodiment, when there is a sudden change at the beginning and end of a solid line segment, a preset number of pixels are discarded to reduce the sudden change at the beginning and end of the solid line segment, making the calculated fluctuation characteristics or sub-scores of the first and last line segments more accurate.
[0276] S309: If the maximum distance is less than or equal to the preset distance, the second line segment is not corrected, and the second stroke is directly used as the corrected line segment (the fourth line segment).
[0277] S310, calculating the length of the correction line segment.
[0278] Specifically, the distance between the starting point and the ending point of the correction line segment is measured to obtain the length of the correction line segment.
[0279] S311: If the length of the corrected line segment is less than a preset length, the corrected line segment is recorded as a sub-segment of the solid line segment.
[0280] In this embodiment, the preset length can be set as needed. For example, the preset length can be set to 100 pixels, which is not limited here.
[0281] S312: If the length of the correction line segment is greater than or equal to the preset length, a separate line fitting is performed on the correction line segment to obtain a fitting line segment (a second fitting line segment) of the correction line segment.
[0282] In this embodiment, if the length of the correction line segment is greater than or equal to the preset length, it means that the length of the correction line segment is relatively long, and the user's subjective feeling of the abnormal wave line is relatively weak, and the correction line segment can be individually drawn and fitted.
[0283] S313, obtaining a sub-segment of the correction line segment according to the intersection of the fitting line segment of the correction line segment and the correction line segment, where the sub-segment of the correction line segment is a sub-segment of the solid line segment.
[0284] S314, calculating the fluctuation characteristics of each sub-segment of the solid line segment, and obtaining a sub-score of each sub-segment according to the fluctuation characteristics of each sub-segment.
[0285] In this embodiment, if step S309 exists, for the corrected line segment whose length is less than the preset length (the corrected line segment whose length is less than the preset length is the sixth line segment), based on the fluctuation characteristics of the corrected line segment whose length is less than the preset length, the trained head and tail scoring model (first scoring model) is used to score the corrected line segment whose length is less than the preset length to obtain a sub-score of the corrected line segment whose length is less than the preset length.
[0286] If the length of the correction line segment is less than the preset length, it means that the length of the correction line segment is relatively small, the fluctuation of the correction line segment is more obvious when observed with the naked eye, and the subjective feeling is relatively strong. This type of correction line segment can use the trained head-to-tail scoring model alone to calculate the sub-score of the correction line segment. The head-to-tail scoring model can be a model constructed using a Bayesian model. The head-to-tail scoring model is trained to update the parameters in the head-to-tail scoring model to obtain the trained head-to-tail scoring model. Specifically, the process of training the head-to-tail scoring model please refer to the above-mentioned process of training the sub-segment scoring model, which will not be repeated here.
[0287] In this embodiment, for the sub-segments other than the corrected segment in step S309 (the sub-segments other than the corrected segment in step S309 are recorded as the seventh segment), the sub-scores of the sub-segments are obtained using the trained sub-segment scoring model.
[0288] S315, obtaining the total score of the solid line segment according to the sub-scores of the sub-segments.
[0289] In one implementation, after the corrected line segment is obtained in step S307, the corrected line segment is recorded as a sub-line segment, and the total score of the solid line segment is calculated through the above steps S205 and S206.
[0290] In summary, the handwriting stroke evaluation method proposed in this application can also refer to Fig.18 The process shown.
[0291] Specifically, refer to Fig.18 , the evaluation method may also include:
[0292] Get the first picture after writing with the stylus.
[0293] A line trajectory of a solid line segment drawn by a stylus in the first image is extracted to obtain an upper boundary trajectory of the solid line segment.
[0294] Identify the stroke type of the solid stroke segment, and determine the regression model to be used for stroke fitting according to the stroke type.
[0295] Using the regression model, the upper boundary trajectory is fitted to obtain the fitting line segment (ideal line segment).
[0296] Based on the intersection of the fitting line segment and the upper boundary track, the upper boundary track is segmented to determine the sub-segments into which the upper boundary track is divided by the fitting line segment.
[0297] Extract the fluctuation length, fluctuation amplitude and fluctuation degree (using variance to characterize the fluctuation degree) of each sub-segment.
[0298] The fluctuation length, fluctuation amplitude and fluctuation degree of the sub-segment are input into the trained sub-segment scoring model to obtain the sub-segment sub-score. Alternatively, the first sub-segment and the last sub-segment are scored respectively to obtain the sub-score of the first sub-segment and the sub-score of the last sub-segment; the remaining sub-segments (except the first sub-segment and the last sub-segment) are scored to obtain the sub-scores of the remaining sub-segments.
[0299] The total score of the solid line segment is obtained according to the sub-scores of the sub-segments.
[0300] In this application, the naming methods of first, second, etc. are used to distinguish the same type of information in different embodiments, or the same type of information in the same embodiment. Although the numbers of the same type of information are different, it does not mean that the content (or value) of the same type of information must be different. In actual applications, although the same type of information has different numbers, the content (or value) may be the same.
[0301] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean 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 the present application.
[0302] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0303] The embodiment of the present application also provides a computer program product. When the computer program product is executed on a first device, the first device can implement the steps in the above-mentioned method embodiments.
[0304] If the integrated unit is implemented in the form of 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, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the first device, a recording medium, a computer memory, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0305] The embodiment of the present application also provides a chip system, the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the steps of any method embodiment of the present application. The chip system can be a single chip or a chip module composed of multiple chips.
[0306] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0307] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0308] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for evaluating handwritten pen strokes, characterized in that: include: Acquire a first picture, wherein the first picture contains a solid line segment written by a stylus; Segmenting the solid line segment to obtain sub-segments of the solid line segment; The step of segmenting the solid line segment to obtain sub-segments of the solid line segment includes: Performing line fitting on the solid line segment to obtain a first fitting line segment of the solid line segment, wherein the first fitting line segment does not contain abnormal wavy lines; Determine, based on the intersection of the first fitting line segment and the solid line segment, each sub-segment into which the solid line segment is divided by the first fitting line segment; The performing line fitting on the solid line segment to obtain a first fitting line segment of the solid line segment includes: Performing grayscale processing on the first picture to obtain a grayscale image of the first picture; Binarizing the grayscale image to obtain a binary image of the first image; Extracting the line trajectory of the solid line segment according to the pixel value of each pixel point in the binary image; Performing line fitting on the line-drawing trajectory to obtain a first fitting line segment of the solid line segment; Correspondingly, the determining, based on the intersection of the first fitting line segment and the solid line segment, the sub-segments into which the solid line segment is divided by the first fitting line segment includes: Based on the intersection of the first fitting line segment and the stroke trajectory, determining each sub-segment into which the stroke trajectory is divided by the first fitting line segment; The determining, based on the intersection of the first fitting line segment and the stroke trajectory, the sub-segments into which the stroke trajectory is divided by the first fitting line segment comprises: Based on the intersection of the first fitting line segment and the stroke trajectory, the line segments into which the stroke trajectory is divided by the first fitting line segment are obtained, the first line segment and the last line segment into which the stroke trajectory is divided by the first fitting line segment are second line segments, the line segments into which the stroke trajectory is divided by the first fitting line segment except the second line segment are recorded as first line segments, and each of the first line segments is a sub-segment of the solid stroke segment; Determine the number of intersections between each of the second line segments and the first fitting line segment; If there is a third line segment in the second line segment, determining the maximum deviation degree of the third line segment relative to the first fitting line segment, wherein the third line segment is a second line segment having an intersection point with the first fitting line segment; Correcting the third line segment according to the maximum deviation degree to obtain a fourth line segment; Determine the fourth line segment as a sub-segment of the solid line segment; If there is a fifth line segment in the second line segment, and there are at least two intersection points between the fifth line segment and the first fitting line segment, the fifth line segment is determined as a sub-segment of the solid line segment; Extracting the fluctuation characteristics of each of the sub-segments; The solid line segment is evaluated according to the fluctuation characteristics of each sub-line segment to obtain a total score of the solid line segment.
2. The method according to claim 1, characterized in that The performing line fitting on the line-drawing trajectory to obtain a first fitting line segment of the solid line segment includes: Identifying the line type of the solid line segment; Determining, according to the line type, a regression model used when performing line fitting on the line trajectory; The determined regression model and the least square method are used to perform line fitting on the line-drawing trajectory to obtain a first fitting line segment of the solid line segment.
3. The method according to claim 2, characterized in that The types of strokes include oblique strokes, straight strokes, wavy lines, broken lines and arcs; The regression models matched by the oblique lines, the straight lines and the broken lines are all univariate linear regression models, the regression model matched by the wavy lines is a nonlinear regression model, and the regression model matched by the arc lines is a high-dimensional nonlinear regression model.
4. The method according to claim 1, characterized in that The fluctuation characteristics include at least one of fluctuation length, fluctuation amplitude and fluctuation degree.
5. The method according to claim 1, characterized in that When the fluctuation feature includes the fluctuation length, the fluctuation amplitude and the fluctuation degree, extracting the fluctuation feature of each sub-segment includes: Determine the length of each of the sub-segments, where the length of the sub-segment is the fluctuation length of the sub-segment; Calculating the distance between each pixel point in the sub-line segment and the first fitting line segment to obtain the maximum distance between the sub-line segment and the first fitting line segment, where the maximum distance between the sub-line segment and the first fitting line segment is the fluctuation amplitude of the sub-line segment; Based on the distance between each pixel point in the sub-line segment and the first fitting line segment, and the number of pixels in the sub-line segment, the variance of the distance between each pixel point in the sub-line segment and the first fitting line segment is calculated, and the variance of the distance between each pixel point in the sub-line segment and the first fitting line segment is the fluctuation degree of the sub-line segment.
6. The method according to any one of claims 1 to 5, characterized in that: The step of evaluating the solid line segment according to the fluctuation characteristics of each sub-line segment to obtain a total score of the solid line segment includes: Evaluate each of the sub-segments according to the fluctuation characteristics of each of the sub-segments to obtain a sub-score for each of the sub-segments; Based on the sub-score of each of the sub-segments, a total score of the solid line segment is obtained.
7. The method according to claim 6, characterized in that The step of evaluating each sub-segment according to the fluctuation characteristics of each sub-segment to obtain a sub-score for each sub-segment includes: The fluctuation characteristics of the sub-segments are input into the trained sub-segment scoring model to obtain the sub-score of each sub-segment, wherein the sub-segment scoring model is constructed based on a Bayesian network model.
8. The method according to claim 6, characterized in that The obtaining of the total score of the solid line segment based on the sub-score of each sub-segment comprises: Calculate a revised score of each of the sub-segments based on the sub-score of each of the sub-segments and the proportion of each of the sub-segments in the solid line segment; Based on the revised score of each of the sub-line segments, a total score of the solid line segment is obtained.
9. The method according to claim 1, characterized in that The step of correcting the third line segment according to the maximum deviation degree to obtain a fourth line segment includes: If the maximum deviation is greater than a preset threshold, a preset number of consecutive pixel points in the third line segment are deleted to obtain a fourth line segment, wherein if the third line segment whose maximum deviation is greater than the preset threshold is the first line segment, a preset number of pixel points are deleted starting from the first pixel point of the first line segment; if the third line segment whose maximum deviation is greater than the preset threshold is the last line segment, a preset number of pixel points are deleted starting from the last pixel point of the last line segment; If the maximum deviation degree is less than or equal to the preset threshold, the third line segment is determined as the fourth line segment.
10. The method according to claim 1 or 9, characterized in that: After the third line segment is corrected according to the maximum deviation degree to obtain a fourth line segment, the method further includes: determining a length of the fourth line segment; If the length of the fourth line segment is less than a preset length, determining the fourth line segment as a sub-segment of the solid line segment; If the length of the fourth line segment is greater than or equal to the preset length, performing line fitting on the fourth line segment to obtain a second fitting line segment of the fourth line segment; Based on the intersection point between the second fitting line segment and the fourth line segment, each line segment into which the fourth line segment is divided by the second fitting line segment is determined as a sub-segment of the solid line segment.
11. The method according to claim 10, characterized in that The step of evaluating the solid line segment according to the fluctuation characteristics of each sub-line segment to obtain a total score of the solid line segment includes: If there is a sixth line segment in the sub-line segments of the solid line segment, and the sixth line segment is the fourth line segment whose length is less than the preset length, the fluctuation feature of the sixth line segment is input into the trained first scoring model to obtain a sub-score of the sixth line segment; Inputting the fluctuation characteristics of the seventh line segment in the sub-line segments into the trained sub-line segment scoring model to obtain the sub-score of the seventh line segment, wherein the seventh line segment is a sub-line segment in the sub-line segments except the sixth line segment, the first scoring model and the sub-line segment scoring model are different scoring models, and both the first scoring model and the sub-line segment scoring model are constructed based on a Bayesian network model; Based on the sub-score of each of the sub-segments, a total score of the solid line segment is obtained.
12. An electronic device, characterized in that: The electronic device comprises a processor, and the processor is used to run a computer program stored in a memory, so that the electronic device implements the method according to any one of claims 1 to 11.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, the method according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
Intelligent handwritten Chinese character flat measurement algorithm
CN112016419A