A handwriting scoring method and computer device based on deep learning
Through deep learning technology, automatic scoring of handwritten texts is realized, which solves the subjectivity and efficiency problems of existing handwritten calligraphy scoring methods and provides an efficient and accurate scoring scheme.
Patent Information
- Application Number
- CN202410658681.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-05-27
AI Technical Summary
Existing handwriting calligraphy scoring methods rely on subjective evaluation, lack objectivity and efficiency, and are particularly time-consuming and labor-intensive when evaluating a large number of exercises.
Using a handwriting scoring method based on deep learning, by obtaining handwritten text images, character recognition, standard word search, text splitting and multi-dimensional scoring are performed to accurately split and score the strokes and segments of handwritten text.
Automatic handwritten text scoring is realized, improving the accuracy and efficiency of scoring, and ensuring the reliability and objectivity of scoring.
Smart Images

Figure CN118247786B
Abstract
Description
Technical Field
[0001] The present application relates to the field of scoring methods, and in particular, to a handwriting scoring method and computer device based on deep learning. Background Art
[0002] At present, in the process of learning handwritten calligraphy, the quality of handwritten calligraphy works tends to reflect the judge's subjective views on the works. The evaluation of handwritten works obtained in this way is not objective and fair. Moreover, when teachers are faced with a large number of exercises, it will consume a lot of time and energy to evaluate them one by one. Summary of the invention
[0003] The embodiments of the present application provide a handwriting scoring method, device and computer equipment based on deep learning.
[0004] In a first aspect, an embodiment of the present application provides a handwriting scoring method based on deep learning, comprising:
[0005] Acquire a first image, wherein the first image includes an image of handwritten text, and the handwritten text includes at least one handwritten character;
[0006] Inputting the first image into a text recognition model to obtain text information corresponding to the handwritten text;
[0007] Searching for a corresponding standard character in a database according to the text information, and obtaining a standard character-related image corresponding to the standard character, wherein the standard character-related image includes at least one of the following: a standard character image corresponding to the standard character, a stroke image corresponding to each stroke of the standard character, and a segment image of each segment of a complex stroke in each stroke of the standard character;
[0008] Inputting the first image and the standard character related image into a text segmentation model to obtain at least one text segmentation image, each of which corresponds to a stroke or a segment of a character in the handwritten text;
[0009] According to the standard word related images, scoring each of the text segmentation images in at least one dimension of length, angle and arc;
[0010] The score of the handwritten text is determined according to the score of each of the text segmentation images.
[0011] Optionally, inputting the first image into a text recognition model to obtain text information corresponding to the handwritten text includes:
[0012] Inputting the first image into an image preprocessing module to obtain a text binary image corresponding to the handwritten text;
[0013] Inputting the text binary image into a text recognition model to obtain text information corresponding to the handwritten text;
[0014] Wherein, the standard word image is a binary image.
[0015] Optionally, the text segmentation model includes a stroke segmentation module, and the step of inputting the first image and the standard character related image into the text segmentation model to obtain at least one text segmentation image includes:
[0016] Stacking the first image and the standard character image with the stroke images corresponding to the strokes of the standard character to obtain at least one three-channel image;
[0017] The at least one three-channel image is input into the stroke segmentation module to obtain a handwritten stroke image corresponding to each stroke in the handwritten text.
[0018] Optionally, the text segmentation model further includes a stroke segmentation module, and the step of inputting the first image and the standard character related image into the text segmentation model to obtain at least one text segmentation image includes:
[0019] stacking a complex stroke image corresponding to a first complex stroke in the handwritten stroke image and at least one stroke segment image corresponding to the first complex stroke into a multi-channel image;
[0020] The multi-channel image is input into the segment segmentation module to obtain a handwritten segment image corresponding to each segment in the first complex stroke.
[0021] Optionally, scoring each of the text segmentation images in at least one dimension of length, angle and arc according to the standard word related image includes:
[0022] For one of the text segmentation images, performing contour extraction on the text segmentation image to obtain a contour boundary corresponding to the text segmentation image;
[0023] Determine the coordinates of the circumscribed rectangular frame according to the outline boundary;
[0024] Cropping the text segmentation image according to the coordinates of the circumscribed rectangular frame to obtain a cropped first segmentation image;
[0025] Compare the width and height of each of the first split images with the stroke image or the stroke segment image corresponding to the first split image, align the side with the smaller width or height difference, and scale the other side to obtain the aligned target split image;
[0026] According to the standard word related image, the target split image is scored in at least one dimension of length, angle and arc.
[0027] Optionally, scoring the target split image in at least one dimension of length, angle and arc includes:
[0028] Performing straight line fitting according to the contour boundary of the target split image to determine the horizontal line angle corresponding to the stroke or segment corresponding to the target split image;
[0029] Rotating the target split image to be horizontal to obtain a process split image;
[0030] The process split image is divided into at least one segment along a horizontal line, and the inscribed circle of each segment is obtained according to a distance transformation algorithm;
[0031] If the inscribed circle cannot be obtained, it will be merged with the next segment to obtain the merged inscribed circle;
[0032] The centers of all the inscribed circles are taken as the characteristic key points of the target segmented image;
[0033] In the angle dimension and / or the arc dimension, the target split image is scored according to the feature key points.
[0034] Optionally, in the length dimension, the target split image is scored, including:
[0035] The score of the target split image in the length dimension is determined according to the following formula:
[0036] ;
[0037] in, represents the score of the target split image in the length dimension, represents the length of the target split image, represents the length of the stroke image corresponding to the target split image, Indicates the minimum length rating, A hyperparameter used to adjust the tolerance of the scores along the length dimension.
[0038] Optionally, in the angle dimension and / or the radian dimension, scoring the target split image according to the feature key points includes:
[0039] According to the least square method, the characteristic key points are fitted with a straight line to obtain a first angle;
[0040] Correcting the horizontal line angle according to the first angle to obtain a corrected angle;
[0041] The score of the target split image in the angle dimension is determined according to the following formula:
[0042] ;
[0043] in, represents the score of the target split image in the angle dimension, represents the angle difference between the correction angle corresponding to the target split image and the angle corresponding to the stroke image or the stroke segment image, Indicates the preset angle tolerance threshold, Indicates the minimum angle score;
[0044] and / or,
[0045] Determine a first arc and a second arc, wherein the first arc is an angle formed by three of the feature key points in the first feature key point group, and the second arc is an angle formed by three of the feature key points in the second feature key point group, wherein the first feature key point group includes at least one of two feature key points with the highest and lowest ordinates among the feature key points, and the second feature key point group includes the other three feature key points among the feature key points excluding the first feature key point group;
[0046] Determining a first weight of the first arc and a second weight of the second arc according to a ratio of distances between feature key points in the first feature key point group and the second feature key point group;
[0047] The score of the target split image in the arc dimension is determined according to the following formula:
[0048] ;
[0049] in, represents the score of the target split image in the radian dimension, represents the first weight, represents the second weight, represents the xth radian, Indicates the radian tolerance threshold corresponding to the xth radian, represents the angle difference between the xth arc corresponding to the target split image and the xth arc corresponding to the stroke image or the stroke segment image corresponding to the target split image, Indicates the guaranteed arc score corresponding to the xth arc.
[0050] Optionally, determining the score of the handwritten text according to the score of each of the text segmentation images includes:
[0051] For one of the text segmentation images, determining a segmentation image score corresponding to the text segmentation image according to the weights corresponding to the length dimension, the angle dimension and the radian dimension, respectively, and the scores of the text segmentation image in the length dimension, the angle dimension and the radian dimension;
[0052] Determine the score corresponding to the handwritten text according to the weight corresponding to each of the text segmentation images and the segmentation image score corresponding to each of the text segmentation images;
[0053] The weight corresponding to the text segmentation image is positively correlated with the complexity of the strokes or segments corresponding to the text segmentation image.
[0054] In a second aspect, an embodiment of the present application provides a computer device, comprising a processor and a non-volatile memory storing computer instructions, wherein when the computer instructions are executed by the processor, the computer device executes the deep learning-based handwriting scoring method described in the first aspect.
[0055] The technical solution provided by the embodiments of the present invention may include the following beneficial effects: first, text recognition is performed on the acquired first image to obtain corresponding text information, then the corresponding standard character related images are searched in the database, and then the handwritten text in the first image is segmented based on the standard character related images to obtain text segmentation images corresponding to each stroke or segment, and further scoring is performed in multiple dimensions based on the text segmentation images and the standard character related images, and finally the score of the handwritten text is obtained by combining the score of each text segmentation image. With such a design, each stroke or segment in the handwritten text can be accurately segmented based on the standard character image, and a more accurate handwritten text score can be obtained by analyzing each stroke or segment, thereby realizing automated handwritten character scoring and ensuring reliability, and effectively improving the efficiency and accuracy of handwritten text scoring. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0057] Figure 1 A schematic diagram of the steps of a handwriting scoring method based on deep learning provided in an embodiment of the present application;
[0058] Figure 2 A schematic diagram of a process of obtaining a handwritten stroke image provided in an embodiment of the present application;
[0059] Figure 3 A schematic diagram of a process of obtaining a handwritten pen segment image provided in an embodiment of the present application;
[0060] Figure 4 A schematic diagram of the structure of a computer device provided for the implementation of this application. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0062] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0063] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0064] Furthermore, the terms “first”, “second”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0065] In the description of this application, it should also be noted that, unless otherwise clearly specified and limited, the terms such as "setting" and "connection" should be understood in a broad sense. For example, "connection" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be the internal connection of two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0066] In the process of implementing the present application, the inventor discovered that the prior art only takes precautions based on inherent rules, and the defensive effect is not ideal.
[0067] In response to the above problems, an abnormal network traffic detection method is provided in an embodiment of the present application.
[0068] The specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings.
[0069] Please see attached Figure 1 , Figure 1A schematic flow chart of a method for detecting abnormal network traffic provided in an embodiment of the present application. The method can be implemented by a computer device as the main body. The steps of the above-mentioned method for scoring handwriting based on deep learning include:
[0070] Step S101: Acquire a first image, wherein the first image includes an image of handwritten text, and the handwritten text includes at least one handwritten character.
[0071] The first image may be, for example, a scanned image of a handwritten text, or an image obtained by photographing the handwritten text with a camera.
[0072] Step S102: input the first image into a text recognition model to obtain text information corresponding to the handwritten text.
[0073] The text recognition model may be a pre-trained model, which can be used to recognize text in an image.
[0074] Step S103: searching a database for a corresponding standard character according to the text information to obtain a standard character-related image corresponding to the standard character.
[0075] The standard character-related images include at least one of the following: a standard character image corresponding to the standard character, a stroke image corresponding to each stroke of the standard character, and a segment image of each segment of a complex stroke in each stroke of the standard character.
[0076] It is understandable that the database may pre-store images related to standard characters corresponding to various characters, and the closer the handwritten characters are to the standard characters, the higher the score of the handwritten characters will be.
[0077] The standard character-related images may include an image of the entire standard character, an image of each stroke obtained by splitting the standard character, and an image of each stroke segment obtained by splitting a complex stroke.
[0078] Step S104: input the text image and the standard character related image into a text segmentation model to obtain at least one text segmentation image.
[0079] Each of the text segmentation images corresponds to a stroke or a segment of a character in the handwritten text.
[0080] Among them, the text segmentation model can be a pre-trained artificial intelligence model based on deep learning, which can segment the text image based on standard character-related images to obtain images of the strokes of each character in the text image and / or images of each stroke segment in a complex stroke.
[0081] Step S105 : scoring each of the text segmentation images in at least one dimension of length, angle and arc according to the standard character related images.
[0082] It is understandable that the score corresponding to the text segmentation image is positively correlated with the similarity between the text segmentation image and the standard character related image. The score range can be 0-100, and those skilled in the art can adjust the range according to actual needs, for example, it can be 0-1, and the embodiments of the present disclosure do not limit the specific value.
[0083] Step S106: Determine the score of the handwritten text according to the score of each of the text segmentation images.
[0084] In some embodiments, different weight coefficients may be set for each stroke of a handwritten text or handwritten word, and the total score of the handwritten text may be the weighted sum of the scores of each stroke. Alternatively, different weight coefficients may also be set for each segment of a complex stroke, and the score of a complex stroke is the weighted sum of the scores of each segment.
[0085] In the disclosed embodiment, text recognition is first performed on the acquired first image to obtain corresponding text information, and then the corresponding standard character-related images are searched in the database, and then the handwritten text in the first image is segmented based on the standard character-related images to obtain text segmentation images corresponding to each stroke or segment, and further scores are performed in multiple dimensions based on the text segmentation images and the standard character-related images, and finally the score of the handwritten text is obtained by combining the score of each text segmentation image. With such a design, each stroke or segment in the handwritten text can be accurately segmented based on the standard character image, and a more accurate handwritten text score can be obtained by analyzing each stroke or segment, thereby realizing automated handwritten character scoring and ensuring reliability, and effectively improving the efficiency and accuracy of handwritten text scoring.
[0086] In some embodiments, inputting the first image into a text recognition model to obtain text information corresponding to the handwritten text includes:
[0087] The first image is input into an image preprocessing module to obtain a text binarization image corresponding to the handwritten text; the text binarization image is input into a text recognition model to obtain text information corresponding to the handwritten text; wherein the standard character image is a binarization image.
[0088] By adopting the above solution, by binarizing the first image, the amount of calculation can be effectively reduced while ensuring the reliability of the scoring.
[0089] In some embodiments, the text splitting model includes a stroke splitting module. Inputting the first image and the standard character-related image into the text splitting model to obtain at least one text splitting image includes:
[0090] Stacking the first image and the standard character-related image with the stroke images corresponding to each stroke of the standard character to obtain at least one three-channel image; inputting the at least one three-channel image into the stroke splitting module to obtain the handwritten stroke images corresponding to each stroke in the handwritten text.
[0091] Optionally, the text binary image and the standard character image can also be stacked with the stroke images corresponding to each stroke of the standard character to obtain at least one three-channel image.
[0092] Among them, the process of inputting multiple three-channel images into the stroke splitting module and obtaining at least one handwritten stroke image can be as Figure 2 shown. Referring to Figure 2 , in the three-channel image, channel A can be the stroke image, channel B can be the text binary image, and channel C can be the standard character image. Among them, the handwritten character "家" has 10 strokes, the number of three-channel images can also be 10, and the number of handwritten stroke images split by the stroke splitting module can be 10, corresponding to each stroke of "家" in the first image respectively.
[0093] In some embodiments, the text splitting model further includes a pen segment splitting module. Inputting the text binary image and the standard character-related image into the text splitting model to obtain at least one text splitting image includes:
[0094] Stacking the complex stroke image corresponding to the first complex stroke in the handwritten stroke image with at least one pen segment image corresponding to the first complex stroke into a multi-channel image;
[0095] Inputting the multi-channel image into the pen segment splitting module to obtain the handwritten pen segment images corresponding to each pen segment in the first complex stroke.
[0096] Among them, the process of inputting the multi-channel image into the pen segment splitting module and obtaining the handwritten pen segment images corresponding to each pen segment can be as Figure 3 shown. Referring to Figure 3 , in the multi-channel image input into the pen segment splitting module, channel 5 can be the complex stroke image of a handwritten complex stroke, channel 6 can be the stroke image of the standard character corresponding to the complex stroke, and channels 1-4 can be the four pen segments of the complex stroke respectively. After inputting the multi-channel image into the pen segment splitting module, the handwritten pen segment images corresponding to each pen segment of the handwritten stroke in the complex stroke image can be obtained.
[0097] In some embodiments, scoring each of the text segmentation images in at least one dimension of length, angle, and arc includes:
[0098] Perform contour extraction on each of the text segmentation images to obtain a contour boundary corresponding to each of the text segmentation images; determine the coordinates of the circumscribed rectangular frame according to the contour boundary; crop each of the text segmentation images according to the circumscribed rectangular frame coordinates to obtain a cropped first segmentation image; compare the width and height of each of the first segmentation images with the corresponding stroke image or the stroke segment image, align the side with the smaller difference in width or height, and scale the other side to obtain an aligned target segmentation image; score the target segmentation image in at least one dimension of length, angle and radian.
[0099] By adopting the above scheme, before scoring each split text image, each text split image is first aligned, which can further improve the confidence of the handwritten text score.
[0100] In some embodiments, scoring the target segmented image in at least one dimension of length, angle, and arc includes:
[0101] For a target segmented image, straight line fitting is performed according to the contour boundary of the target segmented image to determine the horizontal line angle corresponding to the strokes or segments corresponding to the target segmented image; the target segmented image is rotated to horizontal to obtain a process segmented image; the process segmented image is divided into at least one segment along the horizontal line, and the inscribed circle of each segment is respectively obtained according to the distance transformation algorithm; if the inscribed circle fails to be obtained, it is fused with the next segment to obtain the fused inscribed circle; the centers of all the obtained inscribed circles are used as the characteristic key points of the target segmented image; and the target segmented image is scored in the angle dimension and / or the radian dimension according to the characteristic key points.
[0102] Specifically, the least squares method can be used to perform the first straight line fitting according to the contour boundary to obtain the angle between the stroke and the horizontal line, and the stroke image can be rotated to the horizontal according to the angle; secondly, the stroke is divided into several segments along the horizontal line and the inscribed circle of each segment is obtained according to the distance transformation algorithm. If the inscribed circle fails, it is merged with the next segment to continue to obtain the inscribed circle; the centers of all the inscribed circles obtained are used as the characteristic key points of the stroke or segment.
[0103] The specific implementation of straight line fitting based on the contour boundary of the image can be found in the implementation in the related art, and the embodiments of the present disclosure will not be elaborated on this.
[0104] In some embodiments, scoring the target split image in the length dimension includes:
[0105] The score of the target split image in the length dimension is determined according to the following formula:
[0106] ;
[0107] in, represents the score of the target split image in the length dimension, represents the length of the target split image, represents the length of the stroke image corresponding to the target split image, Indicates the minimum length rating, is a hyperparameter used to adjust the tolerance of the scores along the length dimension.
[0108] In the above embodiment, through the above disclosure, the score of the strokes of the handwritten text can be accurately determined, that is, the length similarity between the strokes of the handwritten text and the strokes of the corresponding standard characters, and the device can be used to calculate the score of the strokes of the handwritten text. as well as The value of can effectively ensure the robustness of the score.
[0109] In some embodiments, in the angle dimension, scoring the target split image according to the feature key points includes:
[0110] According to the least squares method, the feature key points are fitted with a straight line to obtain a first angle; the horizontal line angle is corrected according to the first angle to obtain a corrected angle; and the score of the target split image in the angle dimension is determined according to the following formula:
[0111] ;
[0112] in, represents the score of the target split image in the angle dimension, represents the angle difference between the correction angle corresponding to the target split image and the angle corresponding to the stroke image or the stroke segment image, Indicates the preset angle tolerance threshold, Indicates the minimum angle score;
[0113] By adopting the above scheme, the feature key points can be fitted with a second straight line, and the angle of the first straight line fitting can be corrected according to the obtained angle, further ensuring the accuracy of the scoring of the angle dimension.
[0114] In some embodiments, in the arc dimension, scoring the target split image according to the feature key points includes:
[0115] Determine a first arc and a second arc, wherein the first arc is an angle formed by three of the feature key points in the first feature key point group, and the second arc is an angle formed by three of the feature key points in the second feature key point group, wherein the first feature key point group includes at least one of two feature key points with the highest and lowest ordinates among the feature key points, and the second feature key point group includes the other three feature key points among the feature key points excluding the first feature key point group;
[0116] Determining a first weight of the first arc and a second weight of the second arc according to a ratio of distances between feature key points in the first feature key point group and the second feature key point group;
[0117] The score of the target split image in the arc dimension is determined according to the following formula:
[0118] ;
[0119] in, represents the score of the target split image in the radian dimension, represents the first weight, represents the second weight, represents the xth radian, Indicates the radian tolerance threshold corresponding to the xth radian, represents the angle difference between the xth arc corresponding to the target split image and the xth arc corresponding to the stroke image or the stroke segment image corresponding to the target split image, Indicates the guaranteed arc score corresponding to the xth arc.
[0120] Optionally, the process of determining the first arc and the second arc may specifically include: (1) obtaining the lowest point and the highest point of the vertical coordinate among the feature key points; (2) taking the above two points as the center, traversing the left and right key points in both directions to obtain the minimum angle formed by the three points; (3) taking the smaller value of the lowest point angle and the highest point angle as the first arc of the handwritten stroke (i.e., the first arc); (4) repeating operations 1-3 with the remaining key points as the area to obtain the second arc (i.e., the second arc).
[0121] The weight between two arcs is calculated according to the ratio of the distances between the three points of the angle they form, that is, the farther the distance, the greater the weight.
[0122] In some embodiments, determining the score of the handwritten text according to the score of each of the text segmentation images includes:
[0123] For a text-segmented image, a split image score corresponding to the text-segmented image is determined according to the weights corresponding to the length dimension, the angle dimension and the radian dimension respectively, and the scores of the text-segmented image in the length dimension, the angle dimension and the radian dimension; a score corresponding to the handwritten text is determined according to the weight corresponding to each of the text-segmented images and the split image score corresponding to each of the text-segmented images; wherein the weight corresponding to the text-segmented image is positively correlated with the complexity of the strokes or segments corresponding to the text-segmented image.
[0124] Different weight coefficients may be set for the length, angle and radian of each stroke type, and the stroke score of a simple stroke or a stroke segment is the weighted sum of the length score, the angle score and the radian score.
[0125] In some embodiments, the handwriting scoring method based on deep learning may specifically include the following steps:
[0126] S1, transfer the handwritten image to the image preprocessing module.
[0127] S2, in the image preprocessing module, the handwritten image is first binarized to obtain a text binarization image; then it is input into the text classifier for text recognition; the recognized text will search the database for the prior information of the corresponding standard characters, including the binarization image of the standard characters, the binarization image of each stroke of the standard characters, and the binarization image of each stroke segment in the complex strokes.
[0128] S2.1, the stroke segment described in S2 refers to decomposing a complex stroke into multiple segments according to its trend, such as a horizontal stroke, which can be decomposed into two stroke segments: a horizontal stroke and a horizontal stroke.
[0129] S3, stack the handwritten binary image, the standard character binary image and the first stroke binary image of the standard character in the channel dimension to form a three-channel image; the remaining stroke operations are consistent with the first stroke, forming a total of N three-channel images equal to the number of strokes of the text, forming a batch, and inputting them into the pre-trained stroke splitting module. The stroke splitting module encodes and decodes the input image and outputs the binary images of each stroke of the handwritten character.
[0130] S4, if there are complex strokes in the handwritten strokes, further process the complex strokes. Stack the binary images of the complex strokes of the handwritten characters, the binary images of the complex strokes of the standard characters, and the binary images of each segment of the complex strokes of the standard characters in the channel dimension to form a multi-channel image. The pre-trained segment splitting module receives the above multi-channel image, and after encoding and decoding the image, outputs the binary images of each segment of the complex strokes of the handwritten characters. After this step, the complex strokes can be decomposed into multiple segments, and the segments can be regarded as equivalent to simple strokes.
[0131] S5, the split strokes and pen segments enter the stroke alignment module to eliminate the interference of the whole character size on the stroke dimension evaluation. First, the binary image of the handwritten strokes and pen segments is extracted to determine the contour boundary, and then the coordinates of the circumscribed rectangular frame are calculated to crop the handwritten strokes and pen segments; the width and height of the cropped image are compared with the width and height of the image of the corresponding strokes of the standard character, and the side with the smaller difference (width or height) is taken for alignment, and the other side is scaled according to the original aspect ratio of the handwritten stroke image to obtain the aligned binary images of the handwritten strokes and pen segments.
[0132] S6, for a single stroke or a binary image of a stroke segment, firstly, the least square method is used to perform the first straight line fitting according to the contour value to obtain the angle between the stroke and the horizontal line, and the stroke image is rotated to the horizontal according to the angle; secondly, the stroke is divided into several segments along the horizontal line and the inscribed circle of each segment is calculated according to the distance transformation algorithm. If the calculation fails, it is merged with the next segment to continue to calculate the inscribed circle; the centers of all the inscribed circles calculated are used as the characteristic key points of the stroke or the stroke segment for the calculation of the angle and radian of the text.
[0133] S7, the evaluation of handwritten strokes or segments is divided into three dimensions: length, angle and arc.
[0134] S7.1, the length of a handwritten character stroke is defined as the length of the stroke in the horizontal direction when the stroke is placed horizontally in S6, denoted as , the standard character stroke length is recorded as , the handwriting stroke length score calculation formula is as follows:
[0135] ;
[0136] in, To adjust the score tolerance hyperparameter, To guarantee the bottom score.
[0137] S7.2, perform a second straight line fitting on the stroke feature key points obtained in S6 according to the least squares method, and correct the angle of the first straight line fitting according to the obtained angle. The handwritten stroke angle is defined as the corrected angle, and the handwritten stroke angle score calculation formula is as follows:
[0138] ;
[0139] in, is the difference between the stroke angle of handwritten characters and the stroke angle of standard characters. is the angle tolerance threshold, To guarantee the bottom score.
[0140] S7.3, the method for obtaining the curvature of a handwritten stroke is as follows: (1) Obtain the lowest and highest points of the vertical coordinates among the key points of the stroke features; (2) With the above two points as the center, traverse the left and right key points to obtain the minimum angle formed by the three points; (3) Take the smaller value of the angle between the lowest point and the highest point as the first curvature of the handwritten stroke; (4) Repeat operations 1-3 with the remaining key points as the area to obtain the second curvature. (5) The weight between the two curvatures is calculated according to the ratio of the distances between the three points of the angle formed, that is, the farther the distance, the greater the weight. The formula for calculating the score of a single curvature is as follows, and the total score of the stroke curvature is the weighted sum of the two curvature scores:
[0141] ;
[0142] in, is the difference between the curvature of the handwritten stroke and the curvature of the standard stroke. is the angle tolerance threshold, To guarantee the bottom score.
[0143] S8, different weight coefficients are set for the length, angle and radian of each stroke type, and the stroke score of a simple stroke or a stroke segment is the weighted sum of the length score, the angle score and the radian score. Different weight coefficients are set for each stroke segment of a complex stroke, and the score of the complex stroke is the weighted sum of the scores of each stroke segment. Different weight coefficients are set for each stroke of a character, and the total stroke score of the character is the weighted sum of the scores of each stroke.
[0144] The basic model of the stroke splitting module in S9 and S3 is U-Net, and the activation function in the model is changed to the leakyReLU function, which is expressed as follows, where Take 0.01:
[0145] ;
[0146] The loss function of the model is the cross entropy loss function, where x is the pixel position, is the probability that the current position corresponds to the stroke of the handwritten character, is the weight value:
[0147] ;
[0148] During the model training process, the pre-annotated binary image of handwritten strokes is used as the true label. The standard character binary image, the standard character stroke binary image and the handwritten character binary image are stacked in the channel dimension to form a three-channel image as the input of the model. After the encoding and decoding process of the model, a stroke probability map of the same size as the input image is output. The loss of the current iteration of the model is calculated through the probability map and used to adjust the model parameters.
[0149] S10, the training process of the stroke segmentation module described in S4 is similar to that described in S9, the difference is that the stroke segmentation module uses the labeled handwritten stroke binary image as the true label, the input image is modified into the standard character stroke binary image, the standard character stroke binary image and the handwritten stroke binary image are stacked in the channel dimension to form a seven-channel image, the number of complex strokes does not exceed five, and if it is insufficient, the channel is filled with blank images.
[0150] In the above embodiment, one or more of the above steps can be used to split the handwritten characters into strokes and segments, and perform multi-dimensional evaluation to obtain a handwritten character stroke score. Not only can each handwritten character be accurately disassembled in order of strokes, but also complex stroke problems can be decomposed into simple strokes through the segment splitting module for detailed analysis. The accuracy and reliability of the automated handwritten text scoring can be effectively guaranteed.
[0151] In another aspect of the present application, an embodiment of the present invention provides a computer device 100, the computer device 100 includes a processor 112 and a non-volatile memory storing computer instructions, when the computer instructions are executed by the processor, the computer device 100 executes the aforementioned handwriting scoring method based on deep learning. Figure 4 As shown, Figure 4 A structural block diagram of a computer device provided for an embodiment of the present disclosure. The computer device 100 includes a memory 111, a processor 112, and a communication unit 113, wherein the memory 111 stores computer instructions 110. When the computer instructions 110 are executed by the processor 112, the computer device 100 executes the aforementioned deep learning-based handwriting scoring method. The present application is described with reference to a flowchart and / or block diagram of a deep learning-based handwriting scoring method, device (system), and computer program product according to an embodiment of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0152] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0153] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0154] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
Claims
1. A handwriting scoring method based on deep learning, characterized in that: include: Acquire a first image, wherein the first image includes an image of handwritten text, and the handwritten text includes at least one handwritten character; Inputting the first image into a text recognition model to obtain text information corresponding to the handwritten text; Searching for a corresponding standard character in a database according to the text information, and obtaining a standard character-related image corresponding to the standard character, wherein the standard character-related image includes at least one of the following: a standard character image corresponding to the standard character, a stroke image corresponding to each stroke of the standard character, and a segment image of each segment of a complex stroke in each stroke of the standard character; Inputting the first image and the standard character related image into a text segmentation model to obtain at least one text segmentation image, each of which corresponds to a stroke or a segment of a character in the handwritten text; According to the standard word related images, scoring each of the text segmentation images in at least one dimension of length, angle and arc; Determining a score of the handwritten text according to the score of each of the text segmentation images; The step of scoring each of the text segmentation images in at least one dimension of length, angle and arc according to the standard word related images includes: For one of the text segmentation images, performing contour extraction on the text segmentation image to obtain a contour boundary corresponding to the text segmentation image; Determine the coordinates of the circumscribed rectangular frame according to the outline boundary; Cropping the text segmentation image according to the coordinates of the circumscribed rectangular frame to obtain a cropped first segmentation image; Compare the width and height of each of the first split images with the stroke image or the stroke segment image corresponding to the first split image, align the side with the smaller width or height difference, and scale the other side to obtain the aligned target split image; According to the standard word-related image, scoring the target split image in at least one dimension of length, angle and arc; In the length dimension, the target split image is scored, including: The score of the target split image in the length dimension is determined according to the following formula: ; in, represents the score of the target split image in the length dimension, represents the length of the target split image, represents the length of the stroke image corresponding to the target split image, Indicates the minimum length rating, is a hyperparameter used to adjust the tolerance of the scores along the length dimension.
2. The method according to claim 1, characterized in that The step of inputting the first image into a text recognition model to obtain text information corresponding to the handwritten text includes: Inputting the first image into an image preprocessing module to obtain a text binary image corresponding to the handwritten text; Inputting the text binary image into a text recognition model to obtain text information corresponding to the handwritten text; Wherein, the standard word image is a binary image.
3. The method according to claim 1, characterized in that The text segmentation model includes a stroke segmentation module, and the first image and the standard character related image are input into the text segmentation model to obtain at least one text segmentation image, including: Stacking the first image and the standard character image with the stroke images corresponding to the strokes of the standard character to obtain at least one three-channel image; The at least one three-channel image is input into the stroke segmentation module to obtain a handwritten stroke image corresponding to each stroke in the handwritten text.
4. The method according to claim 3, characterized in that The text segmentation model further includes a stroke segmentation module, wherein the first image and the standard character related image are input into the text segmentation model to obtain at least one text segmentation image, including: stacking a complex stroke image corresponding to a first complex stroke in the handwritten stroke image and at least one stroke segment image corresponding to the first complex stroke into a multi-channel image; The multi-channel image is input into the segment segmentation module to obtain a handwritten segment image corresponding to each segment in the first complex stroke.
5. The method according to claim 1, characterized in that The scoring of the target split image in at least one dimension of length, angle and arc includes: Performing straight line fitting according to the contour boundary of the target split image to determine the horizontal line angle corresponding to the stroke or segment corresponding to the target split image; Rotating the target split image to be horizontal to obtain a process split image; The process split image is divided into at least one segment along a horizontal line, and the inscribed circle of each segment is obtained according to a distance transformation algorithm; If the inscribed circle cannot be obtained, it will be merged with the next segment to obtain the merged inscribed circle; The centers of all the inscribed circles are taken as the characteristic key points of the target segmented image; In the angle dimension and / or the arc dimension, the target split image is scored according to the feature key points.
6. The method according to claim 5, characterized in that Scoring the target split image in the angle dimension and / or the arc dimension according to the feature key points includes: According to the least square method, the characteristic key points are fitted with a straight line to obtain a first angle; Correcting the horizontal line angle according to the first angle to obtain a corrected angle; The score of the target split image in the angle dimension is determined according to the following formula: ; in, represents the score of the target split image in the angle dimension, represents the angle difference between the correction angle corresponding to the target split image and the angle corresponding to the stroke image or the stroke segment image, Indicates the preset angle tolerance threshold, Indicates the minimum angle score; and / or, Determine a first arc and a second arc, wherein the first arc is an angle formed by three of the feature key points in the first feature key point group, and the second arc is an angle formed by three of the feature key points in the second feature key point group, wherein the first feature key point group includes at least one of two feature key points with the highest and lowest ordinates among the feature key points, and the second feature key point group includes the other three feature key points among the feature key points excluding the first feature key point group; Determining a first weight of the first arc and a second weight of the second arc according to a ratio of distances between feature key points in the first feature key point group and the second feature key point group; The score of the target split image in the arc dimension is determined according to the following formula: ; in, represents the score of the target split image in the radian dimension, represents the first weight, represents the second weight, represents the xth radian, Indicates the radian tolerance threshold corresponding to the xth radian, represents the angle difference between the xth arc corresponding to the target split image and the xth arc corresponding to the stroke image or the stroke segment image corresponding to the target split image, Indicates the guaranteed arc score corresponding to the xth arc.
7. The method according to claim 1, characterized in that Determining the score of the handwritten text according to the score of each of the text segmentation images includes: For one of the text segmentation images, determining a segmentation image score corresponding to the text segmentation image according to the weights corresponding to the length dimension, the angle dimension and the radian dimension, respectively, and the scores of the text segmentation image in the length dimension, the angle dimension and the radian dimension; Determine the score corresponding to the handwritten text according to the weight corresponding to each of the text segmentation images and the segmentation image score corresponding to each of the text segmentation images; The weight corresponding to the text segmentation image is positively correlated with the complexity of the strokes or segments corresponding to the text segmentation image.
8. A computer device, characterized in that: The computer device includes a processor and a non-volatile memory storing computer instructions. When the computer instructions are executed by the processor, the computer device executes the handwriting scoring method based on deep learning according to any one of claims 1 to 7.
