Handwriting input recognition method, device, electronic device and storage medium
By extracting the matching of feature points and inclination sequences of handwriting input characters, the problem of low accuracy of handwriting input recognition in ultrasonic diagnostic instruments is solved, and compatible recognition of continuous and non-continuous writing is achieved, improving the recognition accuracy.
Patent Information
- Application Number
- CN202110750852.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-01
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2041-07-01
AI Technical Summary
In the prior art, handwriting input recognition has a problem that the recognition accuracy rate is low when writing in a single stroke on an ultrasonic diagnostic instrument.
By extracting the feature points of handwritten input characters, including the starting point, inflection point and end point, building feature lines and calculating the inclination sequence, using dynamic programming algorithms to match the inclination sequence and sample characters, and adjusting the stroke order to improve the recognition accuracy.
It realizes compatible recognition of continuous and non-continuous writing characters, and improves the accuracy of handwriting input recognition.
Smart Images

Figure CN115565187B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of ultrasonic equipment, and more specifically, to a handwriting input recognition method and device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Handwriting input methods are already widely used in consumer electronics. Adding handwriting input method functions to medical equipment such as ultrasound diagnostic instruments to enhance user experience is an indispensable part of the high-end development of medical equipment.
[0003] In the related art, due to the situation of continuous strokes when the user inputs handwriting, the recognition accuracy is low. Therefore, how to improve the accuracy of handwriting input recognition is a technical problem that needs to be solved by those skilled in the art. Summary of the Invention
[0004] The purpose of this application is to provide a handwriting input recognition method, device, electronic device and computer-readable storage medium, which improve the accuracy of handwriting input recognition.
[0005] To achieve the above objectives, the present application provides a handwriting input recognition method, comprising:
[0006] Acquire a test character, extract characteristic points of the strokes in the test character, and construct a test characteristic point sequence according to the stroke order of the test character; wherein the characteristic points of the strokes include the starting point, inflection point, and end point of the stroke;
[0007] Connecting adjacent feature points in the test feature point sequence into feature lines, calculating a test inclination angle of each feature line, and constructing a test inclination angle sequence according to the stroke order of the test character based on the test inclination angle of each feature line;
[0008] The matching distance between the test inclination sequence and the sample inclination sequence of the sample character is calculated, and the sample character corresponding to the minimum matching distance is determined as the recognition result of the test character.
[0009] The step of extracting the characteristic points of the strokes in the test character includes:
[0010] Extracting the starting and ending points of the strokes in the test character;
[0011] Extracting a trajectory point in the stroke that is farthest from a first target straight line and has a distance greater than a first preset value as an inflection point; wherein the first target straight line is a straight line passing through the starting point and the end point;
[0012] Extracting a trajectory point between the starting point and the inflection point in the stroke that is farthest from a second target straight line and greater than a first preset value as a new inflection point; wherein the second target straight line is a straight line passing through the starting point and the inflection point;
[0013] Extracting a trajectory point between adjacent inflection points in the stroke that is farthest from a third target straight line and has a distance greater than a first preset value as a new inflection point; wherein the third target straight line is a straight line passing through the adjacent inflection points;
[0014] A trajectory point between the inflection point and the end point in the stroke, the trajectory point having the farthest distance from the fourth target straight line and greater than a first preset value, is extracted as a new inflection point; wherein the fourth target straight line is a straight line passing through the inflection point and the end point.
[0015] The step of calculating the matching distance between the test tilt angle sequence and the sample tilt angle sequence of the sample character includes:
[0016] The matching distance between the test inclination sequence and the sample inclination sequence of the sample character is calculated by a dynamic programming algorithm.
[0017] The step of calculating the matching distance between the test tilt angle sequence and the sample tilt angle sequence of the sample character by a dynamic programming algorithm includes:
[0018] Calculating the absolute value of the inclination difference between the i-th test inclination angle in the test inclination angle sequence and the j-th sample inclination angle in the sample inclination angle sequence, a first matching distance between the i-1-th test inclination angle in the test inclination angle sequence and the j-1-th sample inclination angle in the sample inclination angle sequence, a second matching distance between the i-1-th test inclination angle in the test inclination angle sequence and the j-th sample inclination angle in the sample inclination angle sequence, and a third matching distance between the i-th test inclination angle in the test inclination angle sequence and the j-1-th sample inclination angle in the sample inclination angle sequence;
[0019] Determine the sum of the minimum value among the first matching distance, the second matching distance, and the third matching distance and the absolute value of the inclination difference as the matching distance between the i-th test inclination in the test inclination sequence and the i-th sample inclination in the sample inclination sequence;
[0020] The matching distance between the last test inclination angle in the test inclination angle sequence and the last sample inclination angle in the sample inclination angle sequence is determined as the matching distance between the test inclination angle sequence and the sample inclination angle sequence of the sample character.
[0021] The step of determining the sample character corresponding to the minimum matching distance as the recognition result of the test character includes:
[0022] Determine whether the minimum matching distance is less than a preset matching value;
[0023] If yes, then determining the sample character corresponding to the minimum matching distance as the recognition result of the test character;
[0024] If not, the stroke sequence of the test character is adjusted, and the step of constructing a test feature point sequence according to the stroke sequence of the test character is re-entered.
[0025] The step of adjusting the stroke order of the test character includes:
[0026] Determine a matching stroke in the sample character corresponding to a test stroke in the test character;
[0027] The stroke sequence of the test character is adjusted according to the matching result.
[0028] The step of determining a matching stroke in the sample character corresponding to a test stroke in the test character includes:
[0029] During the matching process of the current test stroke in the test character, determining whether the current sample stroke in the sample character is matched by other test strokes;
[0030] If yes, re-determine the next sample stroke in the sample character as the current sample stroke;
[0031] If not, matching the current test stroke with the current sample stroke;
[0032] If they match, determining the matching stroke corresponding to the current test stroke as the current sample stroke;
[0033] If there is no match, the next sample stroke in the sample character is re-determined as the current sample stroke.
[0034] The step of matching the current test stroke with the current sample stroke includes:
[0035] Determining whether the current test stroke and the current sample stroke meet preset conditions;
[0036] If yes, determining that the current test stroke matches the current sample stroke;
[0037] If not, it is determined that the current test stroke does not match the current sample stroke;
[0038] Among them, the preset conditions include whether the inclination difference between the current test stroke and the current sample stroke is less than a second preset value, and / or whether the position deviation between the current test stroke and the current sample stroke is less than a third preset value, and / or whether the difference in the number of inflection points between the current test stroke and the current sample stroke is less than a fourth preset value, and / or whether the difference in the maximum internal corners between the current test stroke and the current sample stroke is less than a fifth preset value, and / or whether the difference in the cumulative sum of internal corners between the current test stroke and the current sample stroke is less than a sixth preset value.
[0039] To achieve the above objectives, the present application provides a handwriting input recognition device, comprising:
[0040] A first construction module is configured to obtain a test character, extract characteristic points of the strokes in the test character, and construct a test characteristic point sequence according to the stroke sequence of the test character; wherein the characteristic points of the strokes include the starting point, inflection point, and end point of the stroke;
[0041] a second construction module, configured to connect adjacent feature points in the test feature point sequence into feature lines, calculate a test inclination angle of each feature line, and construct a test inclination angle sequence according to the stroke order of the test character based on the test inclination angle of each feature line;
[0042] The recognition module is used to calculate the matching distance between the test tilt angle sequence and the sample tilt angle sequence of the sample character, and determine the sample character corresponding to the minimum matching distance as the recognition result of the test character.
[0043] To achieve the above objectives, the present application provides an electronic device, comprising:
[0044] memory for storing computer programs;
[0045] A processor is used to implement the steps of the above-mentioned handwriting input recognition method when executing the computer program.
[0046] To achieve the above objectives, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the above-mentioned handwriting input recognition method are implemented.
[0047] From the above scheme, it can be seen that the present application provides a handwriting input recognition method, including: obtaining a test character, extracting the feature points of the strokes in the test character, and constructing a test feature point sequence according to the stroke order of the test character; wherein the feature points of the strokes include the starting point, inflection point and end point of the stroke; connecting adjacent feature points in the test feature point sequence into feature lines, calculating the test inclination angle of each feature line, and constructing a test inclination angle sequence according to the stroke order of the test character based on the test inclination angle of each feature line; calculating the matching distance between the test inclination angle sequence and the sample inclination angle sequence of the sample character, and determining the sample character corresponding to the minimum matching distance as the recognition result of the test character.
[0048] The handwriting input recognition method provided by the present application extracts feature points including the starting point, inflection point and end point of the strokes in the test character, and connects adjacent feature points into feature lines according to the stroke order of the test character. In this process, the end point of the previous stroke can be connected to the starting point of the next stroke to form a connected stroke. Regardless of whether the test character is written in connected strokes, it can be recognized, thereby achieving the compatibility of the recognition algorithm with connected and non-connected stroke characters. A test inclination sequence is constructed based on the test inclination of each feature line, and the test inclination sequence includes the connected stroke features of the test character. The test inclination sequence is compared with the sample inclination sequence of the sample character, and then determined as the recognition result of the test character. The sample inclination sequence is also constructed using the above method, that is, it also includes the connected stroke features of the sample character, which can recognize the user's connected stroke input and improve the accuracy of handwriting input recognition. The present application also discloses a handwriting input recognition device, an electronic device and a computer-readable storage medium, which can also achieve the above technical effects.
[0049] It should be understood that the foregoing general description and the following detailed description are merely illustrative and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The drawings are used to provide a further understanding of the present disclosure and constitute part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure, but do not constitute a limitation of the present disclosure. In the drawings:
[0051] Figure 1 is a flow chart of a handwriting input recognition method according to an exemplary embodiment;
[0052] Figure 2 Schematic diagram of feature points of Chinese character "写"
[0053] Figure 3 Schematic diagrams of non - connected and connected writing methods of Chinese character "又"
[0054] Figure 4 Schematic diagram of characteristic lines corresponding to non - connected and connected writing of Chinese character "又"
[0055] Figure 5 Schematic diagrams of test characters and sample characters of Chinese character "八"
[0056] Figure 6 Schematic diagram of characteristic lines of test characters and sample characters of Chinese character "八"
[0057] Figure 7 Schematic diagram of matching relationship between sample inclination sequence and test inclination sequence of Chinese character "八"
[0058] Figure 8 Flowchart of another handwriting input recognition method shown according to an exemplary embodiment
[0059] Figure 9 Flowchart of single - stroke stroke matching shown according to an exemplary embodiment
[0060] Figure 10 Structure diagram of a handwriting input recognition device shown according to an exemplary embodiment
[0061] Figure 11 Structure diagram of an electronic device shown according to an exemplary embodiment Detailed implementation manners
[0062] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope protected by the present application. In addition, in the embodiments of the present application, "first", "second", etc. are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence.
[0063] The embodiments of the present application disclose a handwriting input recognition method, which improves the accuracy of handwriting input recognition.
[0064] Refer to Figure 1 , the flowchart of a handwriting input recognition method shown according to an exemplary embodiment, as Figure 1 shown, includes:
[0065] S101: Obtain a test character, extract the feature points of the strokes in the test character, and construct a test feature point sequence according to the stroke order of the test character; wherein, the feature points of the strokes include the starting point, inflection point, and ending point of the stroke.
[0066] This embodiment can be applied to the handwritten input recognition of an ultrasonic device. In a specific implementation, collect the stroke coordinate sequence of the handwritten input test character, including the starting point and ending point of the stroke, and perform coordinate normalization scaling so that the coordinate x and y values are both within the range of 0-1 to ensure unity. According to the normalized stroke coordinate sequence, calculate the inflection points of the stroke in sequence. Store the starting point, the calculated inflection points, and the ending point of the stroke in an array sequence according to the stroke order of the test character, that is, the test feature point sequence. For the Chinese character "写", the extracted feature points are as Figure 2 shown.
[0067] As a feasible implementation manner, the trajectory point farthest from the straight line between the starting point and the ending point in the stroke can be used as the inflection point of the stroke. That is, the extracting the feature points of the strokes in the test character includes: extracting the starting point and the ending point of the strokes in the test character; extracting the trajectory point farthest from the first target straight line and greater than the first preset value in the stroke as the inflection point; wherein, the first target straight line is the straight line passing through the starting point and the ending point. It can be understood that for the case where a stroke contains multiple inflection points, an iterative operation method can be used to determine all inflection points, that is, extracting the trajectory point farthest from the second target straight line and greater than the first preset value between the starting point and the inflection point in the stroke as the new inflection point; wherein, the second target straight line is the straight line passing through the starting point and the inflection point; extracting the trajectory point farthest from the third target straight line and greater than the first preset value between adjacent inflection points in the stroke as the new inflection point; wherein, the third target straight line is the straight line passing through the adjacent inflection points; extracting the trajectory point farthest from the fourth target straight line and greater than the first preset value between the inflection point and the ending point in the stroke as the new inflection point; wherein, the fourth target straight line is the straight line passing through the inflection point and the ending point.
[0068] S102: Connect the adjacent feature points in the test feature point sequence into feature lines, calculate the test inclination angle of each feature line, and construct a test inclination angle sequence according to the stroke order of the test character based on the test inclination angle of each feature line.
[0069] In a specific implementation, connect the adjacent feature points in the test feature point sequence into feature lines. For the Chinese character "又", as Figure 3 shown, there are two writing methods, non-connected and connected, and the corresponding feature line segments are as Figure 4As shown, the feature lines corresponding to non-connected and connected strokes are identical. The inclination angle of each feature line is calculated and stored in an array sequence, i.e., a test inclination angle sequence, according to the stroke order of the test character. The test inclination angle sequence can be understood as the character features of the test character, including the connected stroke features of the test character, which are subsequently used for matching calculations with the sample inclination angle sequence of the sample character.
[0070] Specifically, the inclination angle calculation formula is:
[0071] angle=arctan(last.y-first.y) / (last.x-first.x)) / π×180;
[0072] The starting point and end point of the feature line are (first.x, first.y) and (last.x, last.y), respectively, and angle is the inclination of the feature line.
[0073] S103: Calculating the matching distance between the test tilt angle sequence and the sample tilt angle sequence of the sample character, and determining the sample character corresponding to the minimum matching distance as the recognition result of the test character.
[0074] In this step, a matching operation is performed on the test tilt sequence of the test character and the sample tilt sequence of the sample character, and the matching distance is output. It should be noted that the sample tilt sequence is constructed in the same manner as the test tilt sequence, that is, the sample tilt sequence also includes the connected stroke features of the sample character, and the connected stroke features in the test character can be matched to achieve the recognition of the connected stroke character. Furthermore, the test character is matched with all the sample characters in the sample set in sequence, and the sample character corresponding to the minimum matching distance is determined as the recognition result of the test character.
[0075] In a specific implementation, the matching distance between the test tilt sequence and the sample tilt sequence is the cumulative sum of the corresponding tilt differences, that is, the cumulative tilt difference. For example, if the sample tilt sequence is arc1[0-m] and the test tilt sequence is arc2[0-m], then the matching distance is
[0076] However, due to the irregularity of writing, the number of inflection points of the test character is fluctuating, resulting in redundant inflection points in the strokes, which in turn causes uncertainty in the number of inflection angles in the test inflection angle sequence, and the number of elements in the test inflection angle sequence is not equal to the number of elements in the sample inflection angle sequence. As a preferred embodiment, the calculation of the matching distance between the test inflection angle sequence and the sample inflection angle sequence of the sample character includes: calculating the matching distance between the test inflection angle sequence and the sample inflection angle sequence of the sample character by a dynamic programming algorithm. In the specific implementation, the idea of dynamic programming is introduced, that is, the historical value is combined with the current value to determine the best correspondence between the test inflection angle sequence and the sample inflection angle sequence. The elements in the test inflection angle sequence and the sample inflection angle sequence can be one-to-one, one-to-many or many-to-one, and the constraint condition is that the cumulative difference in inflection angles is minimized, that is, the matching distance between the last test inflection angle in the test inflection angle sequence and the last sample inflection angle in the sample inflection angle sequence is minimized.
[0077] Specifically, the dynamic programming algorithm is used to calculate the matching distance between the test tilt angle sequence and the sample tilt angle sequence of the sample character, including: calculating the absolute value of the tilt angle difference between the i-th test tilt angle in the test tilt angle sequence and the j-th sample tilt angle in the sample tilt angle sequence, the first matching distance between the i-1th test tilt angle in the test tilt angle sequence and the j-1th sample tilt angle in the sample tilt angle sequence, the second matching distance between the i-1th test tilt angle in the test tilt angle sequence and the j-th sample tilt angle in the sample tilt angle sequence, the absolute value of the tilt angle difference ... the third matching distance between the i-th test inclination angle and the j-1-th sample inclination angle in the sample inclination angle sequence; determining the sum of the minimum value of the first matching distance, the second matching distance and the third matching distance and the absolute value of the inclination difference as the matching distance between the i-th test inclination angle in the test inclination angle sequence and the i-th sample inclination angle in the sample inclination angle sequence; determining the matching distance between the last test inclination angle in the test inclination angle sequence and the last sample inclination angle in the sample inclination angle sequence as the matching distance between the test inclination angle sequence and the sample inclination angle sequence of the sample character.
[0078] If the sample inclination sequence is arc1[0-m] and the test inclination sequence is arc2[0-n], the dynamic programming formula is as follows:
[0079] dp(i,j)=local_distance(i,j)+min{dp(i-1,j-1),dp(i-1,j),dp(i,j-1)}
[0080] where local_distance(i, j) = abs(arc1[i] - arc2[j]), dp(i, j) is the best matching distance between the inclination angle sequences of arc1[0~i] and arc2[0~j], dp(i - 1, j - 1) is the best matching distance between the inclination angle sequences of arc1[0~i - 1] and arc2[0~j - 1], dp(i - 1, j) is the best matching distance between the inclination angle sequences of arc1[0~i - 1] and arc2[0~j], and dp(i, j - 1) is the best matching distance between the inclination angle sequences of arc1[0~i] and arc2[0~j - 1].
[0081] If the sequences of arc1[0 - i] and arc2[0 - j] match, then arc1[i] must match the inclination angle of arc2[j]. Otherwise, the matching relationship will cross, and the inclination angle difference between them is local_distance(i, j). If the minimum value is dp(i - 1, j - 1), it means that arc1[i] only matches arc2[j]. If the minimum value is dp(i - 1, j), it means that arc2[j] matches arc1[i] and arc1[i - 1]. If the minimum value is dp(i, j - 1), it means that arc1[i] matches arc2[j] and arc2[j - 1].
[0082] Taking the Chinese character "八" as an example, as Figure 5 shown, the left side is the test character, and the right side is the sample character. The characteristic lines of the test character and the sample character are as Figure 6 shown. Taking the upper left corner in the pixel plane as the origin, the positive direction of the X-axis is to the right, and the positive direction of the Y-axis is downward. The inclination angle sequences are calculated as follows:
[0083] Sample inclination angle sequence: arc[i] = {105, -60, 60}, 0 ≤ i ≤ 2;
[0084] Test inclination angle sequence: arc[j] = {98, 126, -58, 80, 55}, 0 ≤ j ≤ 4;
[0085] First, calculate the difference between each element in the sample inclination angle sequence and each element in the test inclination angle sequence to obtain the inclination angle sequence difference table, as shown in Table 1:
[0086] Table 1
[0087]
[0088] Among them, according to the dynamic programming formula for calculation, dp(i, j) is shown in Table 2. Among them, the row and column data of i = -1 and j = -1 are added for calculation convenience and do not represent the actual inclination angle. X represents the maximum value.
[0089] Table 2
[0090]
[0091] The dynamic programming algorithm is to calculate the minimum cumulative tilt angle difference between (0,0) and (2,4). According to the dynamic programming formula, the matching distance between the sample character and the test character is dist = dp(2,4) = 55. Figure 7 As shown, the matching relationship between the final sample tilt sequence and the test tilt sequence is: (i=0, j=0), (i=0, j=1), (i=1, j=2), (i=2, j=3), (i=2, j=4).
[0092] It should be noted that for Table 2, it is only necessary to calculate dp(2,4) according to the dynamic programming formula to obtain the matching distance between the sample character and the test character. However, in the specific calculation process, the search for the minimum dp value starts from the upper left corner of the table and moves to the right, bottom, and lower right, until the search reaches the lower right corner of the table. That is, first calculate dp(0,0), then search to the right, bottom, and lower right of dp(0,0), that is, calculate dp(0,1), dp(1,0), and dp(1,1), and the minimum value is dp(0,1). Then search for the minimum value in the right, bottom, and lower right directions of dp(0,1), that is, determine the minimum value among dp(0,2), dp(1,1), and dp(1,2), and so on until dp(2,4) is calculated.
[0093] The handwriting input recognition method provided by the embodiment of the present application extracts feature points including the starting point, inflection point and end point of the strokes in the test character, and connects adjacent feature points into feature lines according to the stroke order of the test character. In this process, the end point of the previous stroke can be connected to the starting point of the next stroke to form a connected stroke. Regardless of whether the test character is written in connected strokes, it can be recognized, thereby achieving the compatibility of the recognition algorithm with connected and non-connected characters. A test inclination sequence is constructed based on the test inclination of each feature line, and the test inclination sequence includes the connected stroke features of the test character. The test inclination sequence is compared with the sample inclination sequence of the sample character, and then determined as the recognition result of the test character. The sample inclination sequence is also constructed using the above method, that is, it also includes the connected stroke features of the sample character, which can recognize the user's connected input and improve the accuracy of handwriting input recognition.
[0094] The embodiment of the present application discloses a handwriting input recognition method. Compared with the previous embodiment, this embodiment further explains and optimizes the technical solution. Specifically:
[0095] See also Figure 8, a flowchart of another handwriting input recognition method according to an exemplary embodiment is shown, such as Figure 8 As shown, including:
[0096] S201: Acquire a test character and extract feature points of strokes in the test character;
[0097] S202: Constructing a test feature point sequence according to the stroke sequence of the test character; wherein the feature points of the strokes include the starting point, inflection point and end point of the strokes;
[0098] S203: Connecting adjacent feature points in the test feature point sequence into feature lines, calculating a test inclination angle of each feature line, and constructing a test inclination angle sequence according to the stroke order of the test character based on the test inclination angle of each feature line;
[0099] S204: Calculating a matching distance between the test tilt angle sequence and a sample tilt angle sequence of a sample character;
[0100] S205: Determine whether the minimum matching distance is less than a preset matching value; if so, proceed to S206; if not, proceed to S207;
[0101] It should be noted that if the sample character and the test character are the same character, but some strokes of the test character are misordered during handwriting input, the order of the test angles in the test angle sequence will be misordered, which will in turn cause a large matching distance between the sample character and the test character, affecting the recognition results. Therefore, this embodiment requires adjusting the stroke order of the test character in this case.
[0102] In a specific implementation, a determination is made as to whether the minimum matching distance is less than a preset matching value. If so, the stroke order of the test character is correct and the sample character corresponding to the minimum matching distance is successfully matched, and the sample character is determined as the matching result for the test character. If not, the stroke order of the test character may be disordered, and the stroke order of the test character needs to be adjusted.
[0103] S206: Determine the sample character corresponding to the minimum matching distance as the recognition result of the test character;
[0104] S207: Adjust the stroke order of the test character and re-enter S202.
[0105] In a specific implementation, a sample character having the same number of strokes as the test character can be selected, and the strokes in the test character can be matched with the strokes in the sample character, that is, the matching strokes in the sample character corresponding to the test strokes in the test character are determined, and the stroke order of the test character is adjusted according to the matching result, and S202 is re-entered to recalculate the matching distance.
[0106] Taking the Chinese character '二' as an example, if the user first writes the horizontal stroke at the bottom and then the horizontal stroke at the top, the stroke order needs to be adjusted. The first test stroke (i.e., the bottom horizontal stroke) in the test character '二' is sequentially matched with each stroke of the current sample character. The stroke order of the test character is adjusted according to the matching result, that is, the stroke order of the upper and lower horizontal strokes of the test character '二' is exchanged.
[0107] As a preferred implementation manner, matching the current test stroke with the current sample stroke includes: determining whether the current test stroke and the current sample stroke meet a preset condition; if so, determining that the current test stroke matches the current sample stroke; if not, determining that the current test stroke does not match the current sample stroke; wherein, the preset condition includes whether the inclination angle difference between the current test stroke and the current sample stroke is less than a second preset value, and / or whether the position deviation between the current test stroke and the current sample stroke is less than a third preset value, and / or whether the inflection point number difference between the current test stroke and the current sample stroke is less than a fourth preset value, and / or whether the internal maximum corner difference between the current test stroke and the current sample stroke is less than a fifth preset value, and / or whether the difference in the cumulative sum of internal corners between the current test stroke and the current sample stroke is less than a sixth preset value. In a specific implementation, the preset condition can be set according to the actual required matching accuracy, and the preset condition can include any one or several of the above, for example, in the single matching mode as Figure 9 shown, if the current test stroke and the current sample stroke simultaneously meet all the above conditions, it is determined that the current test stroke matches the current sample stroke.
[0108] It should be noted that during the stroke matching process, since the stroke matching relationship can only be one-to-one, the sample strokes with established matching relationships need to be ignored. That is, determining the matching stroke in the sample character corresponding to the test stroke in the test character includes: during the matching process of the current test stroke in the test character, determining whether the current sample stroke in the sample character has been matched by other test strokes; if so, re-determining the next sample stroke in the sample character as the current sample stroke; if not, matching the current test stroke with the current sample stroke; if they match, determining the matching stroke corresponding to the current test stroke as the current sample stroke; if they do not match, re-determining the next sample stroke in the sample character as the current sample stroke. For example, if the bottom horizontal stroke of the sample character '二' has been matched by the bottom horizontal stroke in the test character, it is not allowed to match it to the upper horizontal stroke in the test character again.
[0109] If a test stroke does not find a corresponding matching stroke in the current sample character, it means that the current sample character does not match the test character, and the stroke matching operation between the test character and the current sample character is exited.
[0110] All sample characters in the sample set whose number of strokes is the same as that of the test character are traversed in sequence, and the test strokes in the test character are matched with the sample strokes in the sample characters in sequence. The matching distances between all sample characters whose number of strokes is the same as that of the test character and the test character are recalculated, and the sample character corresponding to the minimum matching distance is determined as the recognition result of the test character.
[0111] It can be seen that this embodiment determines the correct stroke order of the test character by matching the test strokes in the test character with the sample strokes in the sample character, and adjusts the test inclination sequence corresponding to the test character accordingly, thereby improving the accuracy of handwriting input recognition.
[0112] A handwriting input recognition device provided in an embodiment of the present application is introduced below. The handwriting input recognition device described below and the handwriting input recognition method described above can be referenced to each other.
[0113] See also Figure 10 , according to an exemplary embodiment, a structural diagram of a handwriting input recognition device is shown, such as Figure 10 Shown, including:
[0114] The first construction module 100 is configured to obtain a test character, extract characteristic points of the strokes in the test character, and construct a test characteristic point sequence according to the stroke sequence of the test character; wherein the characteristic points of the strokes include the starting point, inflection point, and end point of the stroke;
[0115] A second construction module 200 is configured to connect adjacent feature points in the test feature point sequence into feature lines, calculate a test inclination angle of each feature line, and construct a test inclination angle sequence according to the stroke order of the test character based on the test inclination angle of each feature line;
[0116] The recognition module 300 is configured to calculate a matching distance between the test tilt angle sequence and a sample tilt angle sequence of a sample character, and determine the sample character corresponding to the minimum matching distance as a recognition result of the test character.
[0117] The handwriting input recognition device provided by the embodiment of the present application extracts feature points including the starting point, inflection point and end point of the strokes in the test character, and connects adjacent feature points into feature lines according to the stroke order of the test character. In this process, the end point of the previous stroke can be connected to the starting point of the next stroke to form a connected stroke. Regardless of whether the test character is written in connected strokes, it can be recognized, thereby achieving the compatibility of the recognition algorithm with connected and non-connected characters. A test inclination sequence is constructed based on the test inclination of each feature line, and the test inclination sequence includes the connected stroke features of the test character. The test inclination sequence is compared with the sample inclination sequence of the sample character, and then determined as the recognition result of the test character. The sample inclination sequence is also constructed using the above method, that is, it also includes the connected stroke features of the sample character, which can recognize the user's connected stroke input and improve the accuracy of handwriting input recognition.
[0118] Based on the above embodiment, as a preferred implementation, the first building module 100 includes:
[0119] Get submodule, used to get test characters;
[0120] A first extraction submodule, configured to extract the starting and ending points of the strokes in the test character;
[0121] A second extraction submodule is configured to extract, as an inflection point, a trajectory point in the stroke that is the farthest from a first target straight line and is greater than a first preset value; wherein the first target straight line is a straight line passing through the starting point and the end point;
[0122] a third extraction submodule, configured to extract, as a new inflection point, a trajectory point between the starting point and the inflection point in the stroke that is farthest from a second target straight line and greater than a first preset value; wherein the second target straight line is a straight line passing through the starting point and the inflection point;
[0123] a fourth extraction submodule, configured to extract, as a new inflection point, a trajectory point between adjacent inflection points in the stroke that is furthest from a third target straight line and has a distance greater than a first preset value; wherein the third target straight line is a straight line passing through the adjacent inflection points;
[0124] a fifth extraction submodule, configured to extract as a new inflection point a trajectory point between the inflection point and the end point in the stroke that is farthest from a fourth target straight line and is greater than a first preset value; wherein the fourth target straight line is a straight line passing through the inflection point and the end point;
[0125] The construction submodule is used to construct a test feature point sequence according to the stroke sequence of the test character.
[0126] Based on the above embodiments, as a preferred implementation, the recognition module 300 is specifically a module that calculates the matching distance between the test inclination sequence and the sample inclination sequence of the sample character through a dynamic programming algorithm, and determines the sample character corresponding to the minimum matching distance as the recognition result of the test character.
[0127] Based on the above embodiment, as a preferred implementation, the identification module 300 includes:
[0128] a calculation submodule, configured to calculate an absolute value of a tilt angle difference between an i-th test tilt angle in the test tilt angle sequence and a j-th sample tilt angle in the sample tilt angle sequence, a first matching distance between an i-1-th test tilt angle in the test tilt angle sequence and a j-1-th sample tilt angle in the sample tilt angle sequence, a second matching distance between an i-1-th test tilt angle in the test tilt angle sequence and a j-th sample tilt angle in the sample tilt angle sequence, and a third matching distance between an i-th test tilt angle in the test tilt angle sequence and a j-1-th sample tilt angle in the sample tilt angle sequence;
[0129] a first determining submodule, configured to determine the sum of the minimum value among the first matching distance, the second matching distance, and the third matching distance and the absolute value of the inclination difference as the matching distance between the i-th test inclination in the test inclination sequence and the i-th sample inclination in the sample inclination sequence;
[0130] A second determining submodule is configured to determine a matching distance between the last test inclination angle in the test inclination angle sequence and the last sample inclination angle in the sample inclination angle sequence as a matching distance between the test inclination angle sequence and the sample inclination angle sequence of the sample character;
[0131] The third determining submodule is configured to determine the sample character corresponding to the minimum matching distance as the recognition result of the test character.
[0132] Based on the above embodiment, as a preferred implementation manner, the third determination submodule includes:
[0133] A judging unit, configured to judge whether the minimum matching distance is less than a preset matching value; if so, the workflow of the determining unit is started; if not, the workflow of the adjusting unit is started;
[0134] a determination unit, configured to determine the sample character corresponding to the minimum matching distance as the recognition result of the test character;
[0135] The adjusting unit is used to adjust the stroke sequence of the test character and restart the workflow of the construction submodule.
[0136] Based on the above embodiment, as a preferred implementation, the adjustment unit is specifically a unit that determines the matching strokes of the test strokes in the test character corresponding to the matching strokes in the sample character, and adjusts the stroke order of the test character according to the matching result.
[0137] Based on the above embodiment, as a preferred implementation manner, the adjustment unit includes:
[0138] a judging subunit, configured to judge whether the current sample stroke in the sample character is matched by other test strokes during the matching process of the current test stroke in the test character; if so, start the workflow of the first determining subunit; if not, start the workflow of the matching subunit;
[0139] A first determining subunit, configured to re-determine the next sample stroke in the sample character as the current sample stroke;
[0140] a matching subunit, configured to match the current test stroke with the current sample stroke;
[0141] a second determining subunit, configured to determine, when the current test stroke matches the current sample stroke, a matching stroke corresponding to the current test stroke as the current sample stroke;
[0142] a third determining subunit, configured to re-determine the next sample stroke in the sample character as the current sample stroke when the current test stroke matches the current sample stroke;
[0143] The adjusting subunit is used to adjust the stroke sequence of the test character according to the matching result.
[0144] On the basis of the above embodiment, as a preferred implementation manner, the matching subunit is specifically a subunit for determining whether the current test stroke and the current sample stroke meet a preset condition; if so, determining that the current test stroke matches the current sample stroke; if not, determining that the current test stroke does not match the current sample stroke; wherein the preset condition includes whether the inclination difference between the current test stroke and the current sample stroke is less than a second preset value, and / or whether the position deviation between the current test stroke and the current sample stroke is less than a third preset value, and / or whether the difference in the number of inflection points between the current test stroke and the current sample stroke is less than a fourth preset value, and / or whether the difference in the internal maximum corners between the current test stroke and the current sample stroke is less than a fifth preset value, and / or whether the difference in the cumulative sum of internal corners between the current test stroke and the current sample stroke is less than a sixth preset value.
[0145] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0146] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present application, the embodiment of the present application further provides an electronic device, Figure 11 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 11 As shown, the electronic equipment includes:
[0147] Communication interface 1, capable of exchanging information with other devices such as network devices;
[0148] The processor 2 is connected to the communication interface 1 to implement information exchange with other devices and is used to execute the handwriting input recognition method provided by one or more of the above technical solutions when running a computer program. The computer program is stored in the memory 3.
[0149] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 11 Various buses are labeled as bus system 4.
[0150] The memory 3 in the embodiment of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.
[0151] It is understood that the memory 3 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a magnetic disk memory or a magnetic tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM).The memory 2 described in the embodiments of the present application is intended to include but is not limited to these and any other suitable types of memory.
[0152] The method disclosed in the above-mentioned embodiment of the present application can be applied to processor 2 or implemented by processor 2. Processor 2 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above-mentioned method can be completed by the integrated logic circuit of the hardware in processor 2 or instructions in the form of software. The above-mentioned processor 2 can be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 2 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in memory 3. Processor 2 reads the program in memory 3 and completes the steps of the above-mentioned method in combination with its hardware.
[0153] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present application are implemented. For the sake of brevity, they are not repeated here.
[0154] In an exemplary embodiment, the present application also provides a storage medium, namely, a computer storage medium, specifically a computer-readable storage medium, such as a memory 3 storing a computer program. The computer program can be executed by a processor 2 to perform the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0155] Those skilled in the art will understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: mobile storage devices, ROM, RAM, disks or optical disks, etc. Various media that can store program codes.
[0156] Alternatively, if the above-mentioned integrated sub-module of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
[0157] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A handwriting input recognition method, characterized in that: include: Acquire a test character, extract characteristic points of the strokes in the test character, and construct a test characteristic point sequence according to the stroke order of the test character; wherein the characteristic points of the strokes include the starting point, inflection point, and end point of the stroke; Connecting adjacent feature points in the test feature point sequence into feature lines, calculating a test inclination angle of each feature line, and constructing a test inclination angle sequence according to the stroke order of the test character based on the test inclination angle of each feature line; Calculating the matching distance between the test inclination sequence and the sample inclination sequence of the sample character, and determining the sample character corresponding to the minimum matching distance as the recognition result of the test character; The step of calculating the matching distance between the test tilt angle sequence and the sample tilt angle sequence of the sample character includes: Calculating the matching distance between the test inclination sequence and the sample inclination sequence of the sample character by a dynamic programming algorithm; The step of calculating the matching distance between the test tilt angle sequence and the sample tilt angle sequence of the sample character by a dynamic programming algorithm includes: Calculating the absolute value of the inclination difference between the i-th test inclination angle in the test inclination angle sequence and the j-th sample inclination angle in the sample inclination angle sequence, a first matching distance between the i-1-th test inclination angle in the test inclination angle sequence and the j-1-th sample inclination angle in the sample inclination angle sequence, a second matching distance between the i-1-th test inclination angle in the test inclination angle sequence and the j-th sample inclination angle in the sample inclination angle sequence, and a third matching distance between the i-th test inclination angle in the test inclination angle sequence and the j-1-th sample inclination angle in the sample inclination angle sequence; Determine the sum of the minimum value among the first matching distance, the second matching distance, and the third matching distance and the absolute value of the inclination difference as the matching distance between the i-th test inclination in the test inclination sequence and the i-th sample inclination in the sample inclination sequence; The matching distance between the last test inclination angle in the test inclination angle sequence and the last sample inclination angle in the sample inclination angle sequence is determined as the matching distance between the test inclination angle sequence and the sample inclination angle sequence of the sample character.
2. The handwriting input recognition method according to claim 1, characterized in that: The step of extracting characteristic points of strokes in the test character comprises: Extracting the starting and ending points of the strokes in the test character; Extracting a trajectory point in the stroke that is farthest from a first target straight line and has a distance greater than a first preset value as an inflection point; wherein the first target straight line is a straight line passing through the starting point and the end point; Extracting a trajectory point between the starting point and the inflection point in the stroke that is farthest from a second target straight line and greater than a first preset value as a new inflection point; wherein the second target straight line is a straight line passing through the starting point and the inflection point; Extracting a trajectory point between adjacent inflection points in the stroke that is farthest from a third target straight line and has a distance greater than a first preset value as a new inflection point; wherein the third target straight line is a straight line passing through the adjacent inflection points; A trajectory point between the inflection point and the end point in the stroke, the trajectory point having the farthest distance from the fourth target straight line and greater than a first preset value, is extracted as a new inflection point; wherein the fourth target straight line is a straight line passing through the inflection point and the end point.
3. The handwriting input recognition method according to claim 1, characterized in that: The step of determining the sample character corresponding to the minimum matching distance as the recognition result of the test character includes: Determine whether the minimum matching distance is less than a preset matching value; If yes, determining the sample character corresponding to the minimum matching distance as the recognition result of the test character; If not, the stroke sequence of the test character is adjusted, and the step of constructing a test feature point sequence according to the stroke sequence of the test character is re-entered.
4. The handwriting input recognition method according to claim 3, characterized in that: Adjusting the stroke order of the test character includes: Determine a matching stroke in the sample character corresponding to a test stroke in the test character; The stroke sequence of the test character is adjusted according to the matching result.
5. The handwriting input recognition method according to claim 4, characterized in that: Determining a matching stroke in the sample character corresponding to the test stroke in the test character includes: During the matching process of the current test stroke in the test character, determining whether the current sample stroke in the sample character is matched by other test strokes; If yes, re-determine the next sample stroke in the sample character as the current sample stroke; If not, matching the current test stroke with the current sample stroke; If they match, determining the matching stroke corresponding to the current test stroke as the current sample stroke; If there is no match, the next sample stroke in the sample character is re-determined as the current sample stroke.
6. The handwriting input recognition method according to claim 5, characterized in that: Matching the current test stroke with the current sample stroke includes: Determining whether the current test stroke and the current sample stroke meet preset conditions; If yes, determining that the current test stroke matches the current sample stroke; If not, it is determined that the current test stroke does not match the current sample stroke; Among them, the preset conditions include whether the inclination difference between the current test stroke and the current sample stroke is less than a second preset value, and / or whether the position deviation between the current test stroke and the current sample stroke is less than a third preset value, and / or whether the difference in the number of inflection points between the current test stroke and the current sample stroke is less than a fourth preset value, and / or whether the difference in the maximum internal corners between the current test stroke and the current sample stroke is less than a fifth preset value, and / or whether the difference in the cumulative sum of internal corners between the current test stroke and the current sample stroke is less than a sixth preset value.
7. A handwriting input recognition device, characterized in that: include: A first construction module is configured to obtain a test character, extract characteristic points of the strokes in the test character, and construct a test characteristic point sequence according to the stroke sequence of the test character; wherein the characteristic points of the strokes include the starting point, inflection point, and end point of the stroke; a second construction module, configured to connect adjacent feature points in the test feature point sequence into feature lines, calculate a test inclination angle of each feature line, and construct a test inclination angle sequence according to the stroke order of the test character based on the test inclination angle of each feature line; a recognition module, configured to calculate a matching distance between the test inclination sequence and a sample inclination sequence of a sample character, and determine the sample character corresponding to the minimum matching distance as a recognition result of the test character; The recognition module is specifically a module that calculates the matching distance between the test inclination sequence and the sample inclination sequence of the sample character through a dynamic programming algorithm, and determines the sample character corresponding to the minimum matching distance as the recognition result of the test character; Wherein, the identification module includes: a calculation submodule, configured to calculate an absolute value of a tilt angle difference between an i-th test tilt angle in the test tilt angle sequence and a j-th sample tilt angle in the sample tilt angle sequence, a first matching distance between an i-1-th test tilt angle in the test tilt angle sequence and a j-1-th sample tilt angle in the sample tilt angle sequence, a second matching distance between an i-1-th test tilt angle in the test tilt angle sequence and a j-th sample tilt angle in the sample tilt angle sequence, and a third matching distance between an i-th test tilt angle in the test tilt angle sequence and a j-1-th sample tilt angle in the sample tilt angle sequence; a first determining submodule, configured to determine the sum of the minimum value among the first matching distance, the second matching distance, and the third matching distance and the absolute value of the inclination difference as the matching distance between the i-th test inclination in the test inclination sequence and the i-th sample inclination in the sample inclination sequence; A second determining submodule is configured to determine a matching distance between the last test inclination angle in the test inclination angle sequence and the last sample inclination angle in the sample inclination angle sequence as a matching distance between the test inclination angle sequence and the sample inclination angle sequence of the sample character; The third determining submodule is configured to determine the sample character corresponding to the minimum matching distance as the recognition result of the test character.
8. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the handwriting input recognition method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the handwriting input recognition method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for recognizing Chinese hand-written phrase
CN101299236A
Method and apparatus for assessing standard fulfillment of character writing
CN102609735A