Text bending degree determination method and device, electronic equipment and storage medium
By calculating the curvature parameters of the connected components of text to determine the curvature of a single assignment image, fast and accurate curvature recognition and differential correction are achieved. This solves the problems of low recognition accuracy and low processing efficiency caused by distortion of single assignment images, and improves the accuracy and speed of the automatic grading system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING XUEDIRUANJIAN DEVELOPMENT CO LTD
- Filing Date
- 2026-03-26
- Publication Date
- 2026-07-03
AI Technical Summary
In existing technologies, the bending distortion of single-question images leads to a decrease in the accuracy of text recognition. Furthermore, the uniform bending correction model is inefficient and cannot achieve differentiated processing, affecting the accuracy and efficiency of automatic grading.
By identifying the connected components of text in the target text image, calculating the area curvature, boundary curvature curvature, and region variance, the curvature parameters of the text and image are obtained. Combined with preset rules, the curvature of the image is judged, and the individual images that need to be corrected are selected and differentiated correction is performed.
It improves the accuracy of text curvature recognition and image processing efficiency, reduces system processing time, and enhances the accuracy and efficiency of automatic correction.
Smart Images

Figure CN122336729A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for determining text curvature. Background Technology
[0002] In the development of educational informatization and intelligent homework correction technology, machine vision-based automatic single-question homework correction systems are gradually replacing traditional manual correction methods and are widely used in daily teaching, examinations, and assessments due to their high efficiency and accuracy. The core process of automatic single-question homework correction is to first segment the homework image containing multiple questions into individual questions, then perform text recognition, feature extraction, and comparison with standard answers on the segmented single-question images, and finally complete the correction and scoring.
[0003] In actual task data collection, due to factors such as paper material, writing pressure, binding method, and the accuracy of scanning / capturing equipment, segmented individual question images often exhibit varying degrees of bending distortion. This bending distortion causes key features such as text lines and question borders in the individual question image to deviate from the ideal horizontal or vertical baseline, thereby reducing the accuracy of text recognition, interfering with the effectiveness of feature extraction, and ultimately affecting the accuracy of automatic grading results. To address the grading error problem caused by bending distortion in individual question images, existing technologies typically employ a uniform bending correction model to perform indiscriminate correction processing on all segmented individual question images. However, this indiscriminate global correction scheme suffers from low processing efficiency and the inability to achieve differentiated processing. Summary of the Invention
[0004] To overcome the problems existing in related technologies, this specification provides a method, apparatus, electronic device and storage medium for determining text curvature. This solution aims to quickly and accurately identify whether the text in each individual image is curved.
[0005] According to a first aspect of the embodiments of this specification, a method for determining text curvature is provided, the method comprising: Identify at least one connected text component in a target text image; For each text connected component, the area curvature, boundary curvature, and region variance are calculated to obtain the text curvature parameters corresponding to each text connected component and / or the image curvature parameters corresponding to the target text image. The text bending result of the target text image is determined based on the preset bending degree judgment rules, as well as the text bending parameters and / or image bending parameters.
[0006] In one possible implementation, identifying at least one connected text component in the target text image includes: The target text image is preprocessed, and at least one candidate connected component is identified; Filter illegal text from at least one candidate connected component; In response to the existence of candidate connected components that pass the filter, the candidate connected components that pass the filter are determined to be literal connected components.
[0007] In one possible implementation, area curvature, boundary curvature curvature, and region variance are calculated for each text connected component to obtain the text curvature parameters corresponding to each text connected component, and / or the image curvature parameters corresponding to the target text image, including: For each connected component of a text element, calculate the area of the corresponding foreground pixel. When the area of the foreground pixel corresponding to the text connected component is greater than the area threshold, the area curvature, boundary curvature, and region variance of the text connected component are calculated respectively to obtain the first parameter, second parameter, and third parameter of each text connected component as the corresponding text curvature parameter. The mean values of the first, second, and third parameters of the text connected components whose foreground pixel area is greater than the area threshold are calculated respectively to obtain the image curvature parameters corresponding to the target text image.
[0008] In one possible implementation, the area curvature, boundary curvature, and region variance of each connected text component are calculated to obtain the first, second, and third parameters corresponding to each connected text component as the corresponding text curvature parameters, including: Calculate the area of the minimum bounding rectangle of a connected literal region; The area curvature calculation result is determined as the first parameter based on the ratio of the foreground pixel area corresponding to each text connected component to the area of the minimum bounding rectangle.
[0009] In one possible implementation, the area curvature, boundary curvature, and region variance of each connected text component are calculated to obtain the first, second, and third parameters corresponding to each connected text component as the corresponding text curvature parameters, including: Calculate the curvature of every three adjacent contour points in the connected text region, and sum them to obtain the boundary curvature. Calculate the perimeter of the text region in the minimum bounding quadrilateral of the connected text region; The boundary curvature is calculated and its ratio to the perimeter of the text region to obtain the boundary curvature bending degree calculation result as the second parameter.
[0010] In one possible implementation, the area curvature, boundary curvature, and region variance of each connected text component are calculated to obtain the first, second, and third parameters corresponding to each connected text component as the corresponding text curvature parameters, including: Calculate the variance of the ordinates of all contour points in the text connected domain, and use the calculated regional variance as the third parameter.
[0011] In one possible implementation, the text bending result of the target text image is determined according to a preset bending degree judgment rule, as well as text bending parameters and / or image bending parameters, including: If the second bending parameter is greater than the first threshold and the third bending parameter is greater than the second threshold, the text bending result of the target text image is determined to be bent; and / or, If the number of first parameters greater than the third threshold is greater than the fourth threshold, and the third bending parameter is greater than the second threshold, the text bending result of the target text image is determined to be bent.
[0012] In one possible implementation, identifying at least one connected text component in the target text image includes: In response to the absence of a candidate connected component that passes the filter, each candidate connected component is determined to be a literal connected component.
[0013] In one possible implementation, area curvature, boundary curvature curvature, and region variance are calculated for each text connected component to obtain the text curvature parameters corresponding to each text connected component, and / or the image curvature parameters corresponding to the target text image, including: For each text connected component, calculate the ratio of the foreground pixel area to the minimum bounding rectangle area to obtain the first parameter of the text connected component; Calculate the curvature of every three adjacent contour points and obtain a list of curvatures as the fourth parameter of the text connected component; Calculate the variance of the ordinates of all contour points to obtain the third parameter of the text connected component; The text curvature parameters corresponding to each text connected component are determined based on the first, fourth, and third parameters of the text connected component.
[0014] In one possible implementation, the text bending result of the target text image is determined according to a preset bending degree judgment rule, as well as text bending parameters and / or image bending parameters, including: Determine the corresponding connected component curvature state based on the text curvature parameters of each connected component. Calculate the ratio of the number of connected components with curved states to the total number of connected components in the text. If the ratio is greater than the fifth threshold, the text bending result of the text image is determined to be bent.
[0015] In one possible implementation, the bending state of the corresponding connected components is determined based on the bending parameters of each connected component, including: A predetermined number of curvatures are randomly sampled as the target curvature in the fourth parameter of the connected component of the text. The bending feature parameters are determined based on the target curvature, the first parameter, and the third parameter corresponding to the text connected component. The bending feature parameters are input into the trained decision tree model to determine the bending state and obtain the corresponding bending state of the connected component.
[0016] According to a second aspect of the embodiments of this specification, a text curvature determination apparatus is provided, the apparatus comprising: The connected component recognition module is used to identify at least one text connected component in the target text image; The bending parameter calculation module is used to calculate the area bending degree, boundary curvature bending degree, and region variance for each text connected component, so as to obtain the text bending parameters corresponding to each text connected component and / or the image bending parameters corresponding to the target text image. The bending result judgment module is used to determine the text bending result of the target text image according to the preset bending degree judgment rules, as well as the text bending parameters and / or image bending parameters.
[0017] In one possible implementation, the connected component identification module is further used for: The target text image is preprocessed, and at least one candidate connected component is identified; Filter illegal text from at least one candidate connected component; In response to the existence of candidate connected components that pass the filter, the candidate connected components that pass the filter are determined to be literal connected components.
[0018] In one possible implementation, the bending parameter calculation module is further used for: For each connected component of a text element, calculate the area of the corresponding foreground pixel. When the area of the foreground pixel corresponding to the text connected component is greater than the area threshold, the area curvature, boundary curvature, and region variance of the text connected component are calculated respectively to obtain the first parameter, second parameter, and third parameter of each text connected component as the corresponding text curvature parameter. The mean values of the first, second, and third parameters of the text connected components whose foreground pixel area is greater than the area threshold are calculated respectively to obtain the image curvature parameters corresponding to the target text image.
[0019] In one possible implementation, the bending parameter calculation module is further used for: Calculate the area of the minimum bounding rectangle of a connected literal region; The area curvature calculation result is determined as the first parameter based on the ratio of the foreground pixel area corresponding to each text connected component to the area of the minimum bounding rectangle.
[0020] In one possible implementation, the bending parameter calculation module is further used for: Calculate the curvature of every three adjacent contour points in the connected text region, and sum them to obtain the boundary curvature. Calculate the perimeter of the text region in the minimum bounding quadrilateral of the connected text region; The boundary curvature is calculated and its ratio to the perimeter of the text region to obtain the boundary curvature bending degree calculation result as the second parameter.
[0021] In one possible implementation, the bending parameter calculation module is further used for: Calculate the variance of the ordinates of all contour points in the text connected domain, and use the calculated regional variance as the third parameter.
[0022] In one possible implementation, the bending result determination module is further used for: If the second bending parameter is greater than the first threshold and the third bending parameter is greater than the second threshold, the text bending result of the target text image is determined to be bent; and / or, If the number of first parameters greater than the third threshold is greater than the fourth threshold, and the third bending parameter is greater than the second threshold, the text bending result of the target text image is determined to be bent.
[0023] In one possible implementation, the connected component identification module is further used for: In response to the absence of a candidate connected component that passes the filter, each candidate connected component is determined to be a literal connected component.
[0024] In one possible implementation, the bending parameter calculation module is further used for: For each text connected component, calculate the ratio of the foreground pixel area to the minimum bounding rectangle area to obtain the first parameter of the text connected component; Calculate the curvature of every three adjacent contour points and obtain a list of curvatures as the fourth parameter of the text connected component; Calculate the variance of the ordinates of all contour points to obtain the third parameter of the text connected component; The text curvature parameters corresponding to each text connected component are determined based on the first, fourth, and third parameters of the text connected component.
[0025] In one possible implementation, the bending result determination module is further used for: Determine the corresponding connected component curvature state based on the text curvature parameters of each connected component. Calculate the ratio of the number of connected components with curved states to the total number of connected components in the text. If the ratio is greater than the fifth threshold, the text bending result of the text image is determined to be bent.
[0026] In one possible implementation, the bending result determination module is further used for: A predetermined number of curvatures are randomly sampled as the target curvature in the fourth parameter of the connected component of the text. The bending feature parameters are determined based on the target curvature, the first parameter, and the third parameter corresponding to the text connected component. The bending feature parameters are input into the trained decision tree model to determine the bending state and obtain the corresponding bending state of the connected component.
[0027] According to a third aspect of the embodiments of this specification, an electronic device is provided, the electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the operations performed by the text curvature determination method described in the first aspect above.
[0028] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which a program is stored, the program being executed by a processor of the operations performed by the text curvature determination method described in the first aspect above.
[0029] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, the computer program product including a computer program that, when executed by a processor, performs the operations performed by the text curvature determination method described in the first aspect above.
[0030] The technical solutions provided in the embodiments of this specification may include the following beneficial effects: This application uses three different parameters—area curvature calculation, boundary curvature curvature calculation, and region variance calculation—to characterize curvature, enabling a comprehensive and accurate assessment of the curvature of each text connected region through multi-dimensional parameters. Furthermore, by combining text curvature parameters with image curvature parameters, the application assesses curvature results from both microscopic and macroscopic perspectives, improving the accuracy of judging text curvature in images.
[0031] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0032] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this specification and, together with the description, serve to explain the principles of this specification.
[0033] Figure 1 A flowchart illustrating a method for determining text curvature according to an embodiment of this application is shown. Figure 2 This diagram illustrates a method for determining text curvature based on different strategies according to an embodiment of this application. Figure 3 A schematic diagram illustrating a method for determining text bending parameters according to an embodiment of this application is shown; Figure 4 A schematic diagram of a text curvature determination device according to an embodiment of this application is shown; Figure 5 A schematic diagram of the structure of an electronic device according to an embodiment of this application is shown. Detailed Implementation
[0034] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification as detailed herein.
[0035] The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “described,” and “the” as used herein are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0036] It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0037] In this embodiment, the text curvature determination method can be executed by any type of electronic device, including but not limited to mobile phones, wearable devices (such as smartwatches, smart bracelets, smart glasses, etc.), tablets, laptops, in-vehicle terminals, PCs (Personal Computers), etc. The function implemented by this method can be achieved by a processor in the electronic device calling program code. Of course, the program code can be stored in a computer storage medium. Therefore, the electronic device includes at least a processor and a storage medium.
[0038] The text curvature determination method of this application can be used in any application scenario that requires text curvature recognition in an image. For example, this application embodiment can be applied to application scenarios where captured text images are processed uniformly during document digitization and archive management. Alternatively, it can also be applied to application scenarios where text in environmental images is processed and recognized in autonomous driving and intelligent transportation scenarios.
[0039] In the development of educational informatization and intelligent homework correction technology, machine vision-based automatic single-question homework correction systems are gradually replacing traditional manual correction methods and are widely used in daily teaching, examinations, and assessments due to their high efficiency and accuracy. The core process of automatic single-question homework correction is to first segment the homework image containing multiple questions into individual questions, then perform text recognition, feature extraction, and comparison with standard answers on the segmented single-question images, and finally complete the correction and scoring.
[0040] In actual task data collection, due to factors such as paper material, writing pressure, binding method, and the accuracy of scanning / capturing equipment, segmented individual question images often exhibit varying degrees of bending distortion. This bending distortion causes key features such as text lines and question borders in the individual question image to deviate from the ideal horizontal or vertical baseline, thereby reducing the accuracy of text recognition, interfering with the effectiveness of feature extraction, and ultimately affecting the accuracy of automatic grading results. To address the grading error problem caused by bending distortion in individual question images, existing technologies typically employ a uniform bending correction model to perform indiscriminate correction processing on all segmented individual question images. However, this indiscriminate global correction scheme has significant technical drawbacks: Low processing efficiency: In actual homework grading scenarios, many individual problem images are actually in a state of no curvature or very low curvature, and do not require any correction processing. If the curvature correction model is executed on all individual problem images, it will generate a lot of meaningless computational overhead, significantly increasing the processing time of the entire grading system and reducing the real-time performance of grading progress. This problem is particularly prominent in scenarios of large-scale batch grading of homework.
[0041] The inability to achieve differentiated processing is a significant drawback: different individual images exhibit distinct curvature types (e.g., left-hand curvature, right-hand curvature, wavy curvature) and degrees of curvature, resulting in varying optimal correction strategies. A uniform correction model employs fixed algorithm parameters and processing logic, failing to adapt to individual images with varying curvature characteristics. This not only hinders the achievement of ideal correction results but may also lead to overprocessing of originally uncurved images, causing new image distortions and further impacting grading accuracy.
[0042] Therefore, how to quickly and accurately determine the curvature of each single-question image in the single-question assignment grading process, select the single-question images that need to be corrected, and match the corresponding differentiated correction strategies for single-question images with different curvature characteristics, so as to reduce the system processing time and improve the overall grading efficiency while ensuring grading accuracy, has become an urgent problem to be solved in the scenario of automatic assignment grading.
[0043] Therefore, the technical problem solved by the embodiments of this application is how to quickly and accurately identify the curvature of text in an image, thereby improving image processing efficiency in the corresponding application scenarios.
[0044] The text curvature determination scheme of this application embodiment will be described in detail below with reference to the accompanying drawings.
[0045] Figure 1 A flowchart illustrating a method for determining text curvature according to an embodiment of this application is shown. Figure 1 As shown, the text curvature determination method of this application embodiment may include the following steps S10-S30.
[0046] For ease of description, the text curvature determination method of this application embodiment is described using an electronic device as the execution subject. It should be understood that the execution subject of this application embodiment can also be a processor or chip in an electronic device, and this application embodiment does not impose any limitations.
[0047] Step S10: Identify at least one connected text component in the target text image.
[0048] In one possible implementation, an electronic device acquires a target text image for which text curvature determination is required. This target text image includes text content. After acquiring the target text image, the electronic device uses the text curvature determination method of this application to determine whether the text in the target text image exhibits overall curvature. The content of the target text image varies depending on the application scenario. For example, in the field of intelligent homework grading, the target text image can be a single-question image obtained by segmenting a homework image, including a question and its corresponding answer. In the field of autonomous driving, the target text image can be an environmental image obtained by capturing objects including text, such as road signs, around the vehicle.
[0049] Optionally, the target text image acquired by the electronic device can be obtained through an image acquisition device or through user upload. After acquiring the target text image, the electronic device can identify at least one connected component of characters in the target text image. A connected component of characters is a group of pixel regions composed of closely spaced characters in the target text image.
[0050] In some embodiments, after acquiring the target text image, the electronic device can directly convert the target text image into a binary image of text lines, and then calculate the connected component blocks of the text lines in the image based on the binary image of the text lines, and output each connected component block directly as the text connected component.
[0051] In other embodiments, after acquiring the target text image, the electronic device may preprocess the target text image and identify at least one candidate connected component. Then, illegal text filtering is performed on the at least one candidate connected component. Based on the filtering results, at least one text connected component is then determined to eliminate some text interference, thereby improving the accuracy of the curvature judgment result.
[0052] Optionally, preprocessing methods may include scaling the target text image to a fixed size and image data standardization. After image preprocessing, the electronic device can input the preprocessed target text image into a trained text detection model, which outputs probability maps of text lines. The probability maps of each text line are then binarized to obtain a binary map of the text lines in the user image. Connected component blocks are further calculated based on the binary text line maps to obtain multiple candidate connected components. This text detection model can be a DBne model, but other models can also be used in practical applications.
[0053] In some embodiments, the illegal text in this application is irregular text, such as handwritten text, which can interfere with the accuracy of the curvature recognition result and therefore needs to be removed beforehand. The electronic device can, after determining multiple candidate connected components, traverse each candidate connected component and calculate the projection of the corresponding candidate connected component block in the horizontal coordinate direction, and then calculate the average projection value based on the projection of each candidate connected component in the horizontal coordinate direction. Further, the electronic device checks whether there is a horizontal coordinate projection in the image that is greater than N times the average projection value. If so, it determines that the text candidate connected component corresponding to that projection is invalid illegal text and needs to be removed. In practical applications, a preset number N can be set based on the detection effect of the text detection model.
[0054] After the electronic device completes the filtering of illegal text from candidate connected components, it can determine the text connected components in the target text image based on the filtering results. Specifically, when there are candidate connected components that pass the filtering, the electronic device can determine these candidate connected components as text connected components. In this case, the obtained text connected components remove interfering content such as handwritten text, preventing illegal text content from interfering with the detection of text line curvature due to its association with normal text lines, thus improving the accuracy of subsequent detection results.
[0055] In other embodiments, there may be cases where all candidate connected components contain illegal content. To avoid the inability to perform curvature detection in such cases, the electronic device can determine each candidate connected component as a text connected component even when no filtered candidate connected components exist. Curvature detection is then performed using a different curvature detection method than that used for the text connected components corresponding to the filtered legal text, ensuring detection of any type of target text image and improving the applicability of this solution.
[0056] Figure 2 This diagram illustrates a method for determining text curvature based on different strategies according to an embodiment of this application. For example... Figure 2 As shown, after acquiring the target text image, the electronic device first preprocesses the image and identifies the text region to extract at least one candidate connected component. Then, it performs illegal text filtering on the extracted candidate connected components and determines whether any candidate connected components pass the illegal text filtering. If a candidate connected component passes the illegal text filtering, the electronic device can determine that the filtered candidate connected component is a text connected component and execute a first bending judgment strategy based on the text connected components whose current content is legal text. If no candidate connected component passes the illegal text filtering, the electronic device can determine that all candidate connected components are text connected components and execute a second bending judgment strategy based on the text connected components whose current content is illegal text.
[0057] Based on this text connectivity extraction method, the embodiments of this application can ensure the accuracy of the curvature recognition results by filtering illegal text. Furthermore, in special cases, a second curvature judgment strategy can be used as a fallback solution for curvature recognition, improving the applicability of this solution.
[0058] Step S20: Calculate the area curvature, boundary curvature curvature, and region variance for each of the text connected components to obtain the text curvature parameters corresponding to each text connected component and / or the image curvature parameters corresponding to the target text image.
[0059] In one possible implementation, after determining at least one connected text component in the target text image, the electronic device can perform area curvature calculation, boundary curvature curvature calculation, and region variance calculation on each connected text component to obtain the text curvature parameter corresponding to each connected text component and / or the image curvature parameter corresponding to the target text image.
[0060] In some embodiments, when the electronic device determines that the text connected components are text connected components filtered through illegal text, the text curvature parameters corresponding to each text connected component can be specifically determined by calculating area curvature, boundary curvature curvature, and region variance. These text curvature parameters are used to characterize the local curvature features of the corresponding text connected components. Furthermore, based on the determined text curvature parameters corresponding to the text connected components, the image curvature parameters corresponding to the target text image are further determined. These image curvature parameters are used to characterize the overall curvature features of the target text image.
[0061] Figure 3 This diagram illustrates a method for determining text bending parameters according to an embodiment of this application. Figure 3 As shown in the embodiment of this application, after determining the connected text components that have passed the illegal text filtering, the electronic device can first calculate the corresponding foreground pixel area S1 for each connected text component. Then, if the foreground pixel area S1 corresponding to the connected text component is greater than a preset area threshold S0, the electronic device performs area curvature calculation, boundary curvature curvature calculation, and region variance calculation on the connected text component to obtain the first parameter, second parameter, and third parameter corresponding to each connected text component as the corresponding text curvature parameter. Correspondingly, if the foreground pixel area S1 corresponding to the connected text component is less than or equal to the corresponding area threshold S0, the electronic device can directly skip parameter calculation and remove the connected text component or directly determine that the text curvature parameter corresponding to the connected text component is empty.
[0062] Optionally, each text connected region is a region surrounded by multiple boundary contour points, and the large foreground pixel area calculated by the electronic device is the area inside the region surrounded by all the contour points of the corresponding text connected region.
[0063] Furthermore, after the electronic device calculates the first, second, and third parameters corresponding to the connected components of text whose foreground pixel area is greater than a preset area threshold, it calculates the mean values of the first, second, and third parameters corresponding to the connected components of text whose foreground pixel area is greater than the area threshold, and obtains the image curvature parameters corresponding to the target text image.
[0064] Based on the aforementioned technical features, the embodiments of this application essentially perform a second filtering of the connected components of the text during the calculation of text curvature parameters. This filtering method skips connected components with excessively small areas, avoiding complex calculations on a large number of meaningless blocks. Especially when there is a large amount of small-area noise in the image, it can significantly reduce the computational burden. At the same time, it also avoids oversensitivity of small-area connected components, which could generate extreme values and interfere with the overall curvature judgment.
[0065] In some embodiments, the process by which the electronic device calculates the first parameter of each text connected component can be as follows: calculate the area of the minimum bounding rectangle of the text connected component, and then determine the area curvature calculation result as the first parameter based on the ratio of the foreground pixel area corresponding to each text connected component to the area of the minimum bounding rectangle. That is, the electronic device can calculate the foreground pixel area S1 and the minimum bounding rectangle area S2 of the text connected component, and calculate S1 / S2 to obtain the first parameter.
[0066] In some embodiments, the electronic device can calculate the second parameter of each text connected component by calculating the curvature of every three adjacent contour points of the text connected component and summing them to obtain the boundary curvature sum. The perimeter of the text region of the smallest circumscribed quadrilateral of the text connected component is calculated. The ratio of the boundary curvature sum to the text region perimeter is calculated to obtain the boundary curvature curvature calculation result as the second parameter. That is, the electronic device can sequentially obtain every three adjacent contour points on the boundary of the text connected component, calculate the curvature from the left point to the middle point and then to the right point based on the coordinates of the obtained points, finally calculate the sum of all curvatures of the text connected component to obtain the boundary curvature sum Q1, and further calculate the ratio of the boundary curvature sum Q1 to the text region perimeter L1 of the smallest circumscribed quadrilateral, Q1 / L1, to obtain the second parameter.
[0067] In some embodiments, the process of calculating the third parameter of each text connected region by the electronic device can be to calculate the variance of the ordinates of all contour points in the text connected region and obtain the regional variance calculation result as the third parameter.
[0068] In another possible implementation, when the electronic device determines that a connected text component has not passed the illegal text filtering, the text curvature parameters corresponding to each connected text component can be specifically determined through area curvature calculation, boundary curvature calculation, and region variance calculation. These text curvature parameters are used to characterize the local curvature features of the corresponding connected text component. Optionally, the text curvature features determined by the electronic device for connected text components that have not passed the illegal text filtering differ from the text curvature features determined for connected text components that have passed the illegal text filtering.
[0069] In some embodiments, the electronic device can calculate the ratio of the foreground pixel area to the minimum bounding rectangle area for each text connected component to obtain the first parameter of the text connected component. The curvature rate of every three adjacent contour points is calculated to obtain a curvature rate list as the fourth parameter of the text connected component. The variance of the ordinates of all contour points is calculated to obtain the third parameter of the text connected component. The text curvature parameter corresponding to each text connected component is determined based on the first, fourth, and third parameters. The method for calculating the first parameter, curvature rate, and third parameter is the same as when determining the text curvature features for text connected components filtered for illegal text, and will not be repeated here.
[0070] Based on the aforementioned method for determining text curvature parameters, this embodiment of the application can comprehensively judge using three parameters: area curvature, boundary curvature curvature, and regional variance. This allows for multi-feature complementarity in subsequent curvature judgment, reducing misjudgments. Simultaneously, it effectively combats computational noise, adaptively identifies various text curvature conditions, and enhances the robustness of this solution.
[0071] Step S30: Determine the text bending result of the target text image according to the preset curvature judgment rules, the text bending parameters and / or the image bending parameters.
[0072] In one possible implementation, after determining the text curvature parameters of each text connected component and / or the image curvature parameters of the target text image based on at least one text connected component, the electronic device can perform text curvature recognition on the target text image based on the determined curvature parameters to obtain the text curvature result.
[0073] In some embodiments, the preset curvature determination rules differ for different types of text connected components. Specifically, when a text connected component passes through illegal text filtering, the curvature determination rule may include determining that the text curvature result of the target text image is curved if both the second curvature parameter and the third curvature parameter are greater than the second threshold. And / or, determining that the text curvature result of the target text image is curved if the number of first parameters greater than the third threshold is greater than the fourth threshold, and the third curvature parameter is greater than the second threshold.
[0074] In other words, if the average second parameter of the connected text components is greater than the first threshold, and the average second parameter is greater than the second threshold, then text curvature within the current target text image can be determined. Similarly, if the number of connected text components with a first parameter greater than the third threshold is greater than the fourth threshold, and the average second parameter is greater than the second threshold, then text curvature within the current target text image can also be determined.
[0075] In other embodiments, when a text connected component passes through illegal text filtering, the curvature determination rule may include determining the corresponding connected component curvature state based on the text curvature parameters of each connected component. The corresponding connected component curvature state is calculated as the ratio of the number of curved text connected components to the total number of text connected components. If the ratio is greater than a fifth threshold, the text curvature result of the text image is determined to be curved.
[0076] Optionally, the process by which the electronic device determines the bending state of each connected component by determining the bending parameters of the text components can be as follows: A preset number of bending rates are randomly sampled from the fourth parameter of the text connected component as target bending rates. Bending feature parameters are determined based on the target bending rate, the first parameter, and the third parameter corresponding to the text connected component. These bending feature parameters are then input into the trained decision tree model to determine the bending state, thereby obtaining the corresponding bending state of the connected component.
[0077] For example, embodiments of this application can determine the text curvature parameters of connected components containing invalid text. Then, elements included in the fourth parameter are randomly sampled, collecting N element values. These N+2 dimensional features, along with the first and second parameters, form the curvature feature parameters. These N+2 dimensional curvature feature parameters are input into a trained decision tree model for calculation to determine whether the current connected component is curved. Then, the results for all connected components are summarized, and the curvature probability is obtained by dividing the number of curved connected components by the total number of connected components. Further, it is determined whether the curvature probability is greater than a preset fifth threshold. If it is greater than the fifth threshold, the text in the current target text image is determined to be curved; otherwise, the text is determined to be normal.
[0078] Based on the aforementioned technical features, the embodiments of this application significantly improve the processing efficiency and accuracy of the bending recognition process. Specifically, by fusing multi-dimensional bending parameters, the limitations of single features being susceptible to noise and tilt interference are effectively overcome, enabling reliable differentiation of bending of different degrees and types. This enhances the robustness and adaptability of the system, allowing it to handle both regular valid text lines and exception handling mechanisms for completely invalid text lines. Finally, the embodiments of this application also provide precise basis for corresponding application scenarios. For example, in homework grading scenarios, while ensuring the accuracy of homework grading, it reduces the overall system time, achieving a balance between efficiency and quality.
[0079] Corresponding to the embodiments of the foregoing methods, this specification also provides embodiments of the apparatus and the electronic devices to which it is applied.
[0080] See Figure 4 , Figure 4 A schematic diagram of a text curvature determination device according to an embodiment of this application is shown, such as... Figure 4As shown, the text curvature determination device in this embodiment includes: Connectivity identification module 40 is used to identify at least one text connectivity component in the target text image; The bending parameter calculation module 41 is used to calculate the area bending degree, boundary curvature bending degree and region variance for each text connected component, so as to obtain the text bending parameters corresponding to each text connected component and / or the image bending parameters corresponding to the target text image. The bending result judgment module 42 is used to determine the text bending result of the target text image according to the preset bending degree judgment rules, as well as the text bending parameters and / or image bending parameters.
[0081] In one possible implementation, the connected component identification module 40 is further used for: The target text image is preprocessed, and at least one candidate connected component is identified; Filter illegal text from at least one candidate connected component; In response to the existence of candidate connected components that pass the filter, the candidate connected components that pass the filter are determined to be literal connected components.
[0082] In one possible implementation, the bending parameter calculation module 41 is further used for: For each connected component of a text element, calculate the area of the corresponding foreground pixel. When the area of the foreground pixel corresponding to the text connected component is greater than the area threshold, the area curvature, boundary curvature, and region variance of the text connected component are calculated respectively to obtain the first parameter, second parameter, and third parameter of each text connected component as the corresponding text curvature parameter. The mean values of the first, second, and third parameters of the text connected components whose foreground pixel area is greater than the area threshold are calculated respectively to obtain the image curvature parameters corresponding to the target text image.
[0083] In one possible implementation, the bending parameter calculation module 41 is further used for: Calculate the area of the minimum bounding rectangle of a connected literal region; The area curvature calculation result is determined as the first parameter based on the ratio of the foreground pixel area corresponding to each text connected component to the area of the minimum bounding rectangle.
[0084] In one possible implementation, the bending parameter calculation module 41 is further used for: Calculate the curvature of every three adjacent contour points in the connected text region, and sum them to obtain the boundary curvature. Calculate the perimeter of the text region in the minimum bounding quadrilateral of the connected text region; The boundary curvature is calculated and its ratio to the perimeter of the text region to obtain the boundary curvature bending degree calculation result as the second parameter.
[0085] In one possible implementation, the bending parameter calculation module 41 is further used for: Calculate the variance of the ordinates of all contour points in the text connected domain, and use the calculated regional variance as the third parameter.
[0086] In one possible implementation, the bending result determination module 42 is further used for: If the second bending parameter is greater than the first threshold and the third bending parameter is greater than the second threshold, the text bending result of the target text image is determined to be bent; and / or, If the number of first parameters greater than the third threshold is greater than the fourth threshold, and the third bending parameter is greater than the second threshold, the text bending result of the target text image is determined to be bent.
[0087] In one possible implementation, the connected component identification module 40 is further used for: In response to the absence of a candidate connected component that passes the filter, each candidate connected component is determined to be a literal connected component.
[0088] In one possible implementation, the bending parameter calculation module 41 is further used for: For each text connected component, calculate the ratio of the foreground pixel area to the minimum bounding rectangle area to obtain the first parameter of the text connected component; Calculate the curvature of every three adjacent contour points and obtain a list of curvatures as the fourth parameter of the text connected component; Calculate the variance of the ordinates of all contour points to obtain the third parameter of the text connected component; The text curvature parameters corresponding to each text connected component are determined based on the first, fourth, and third parameters of the text connected component.
[0089] In one possible implementation, the bending result determination module 42 is further used for: Determine the corresponding connected component curvature state based on the text curvature parameters of each connected component. Calculate the ratio of the number of connected components with curved states to the total number of connected components in the text. If the ratio is greater than the fifth threshold, the text bending result of the text image is determined to be bent.
[0090] In one possible implementation, the bending result determination module 42 is further used for: A predetermined number of curvatures are randomly sampled as the target curvature in the fourth parameter of the connected component of the text. The bending feature parameters are determined based on the target curvature, the first parameter, and the third parameter corresponding to the text connected component. The bending feature parameters are input into the trained decision tree model to determine the bending state and obtain the corresponding bending state of the connected component.
[0091] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0092] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0093] This specification also provides an electronic device, see [link to documentation] Figure 5 , Figure 5 A schematic diagram of the structure of an electronic device according to an embodiment of this application is shown. Figure 5 As shown, the electronic device includes a processor 510, a memory 520, and a network interface 530. The memory 520 stores computer instructions that can run on the processor 510. The processor 510 is used to implement the text curvature determination method provided in any embodiment of this specification when executing the computer instructions. The network interface 530 is used to implement input / output functions. In many possible implementations, the electronic device may also include other hardware, which is not limited in this specification.
[0094] This specification also provides a computer-readable storage medium, which can take many forms, such as RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (e.g., hard disk drives), solid-state drives, any type of storage disk (e.g., optical discs, DVDs), or similar storage media, or combinations thereof. Specifically, the computer-readable medium can also be paper or other suitable media capable of printing programs. A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the text curvature determination method provided in any embodiment of this specification.
[0095] This specification also provides a computer program product, including a computer program that, when executed by a processor, implements the text curvature determination method provided in any embodiment of this specification.
[0096] Those skilled in the art will understand that one or more embodiments of this specification can be provided as methods, apparatus, electronic devices, computer-readable storage media, or computer program products. Therefore, one or more embodiments of this specification can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification can take the form of a computer program product implemented on one or more computer-readable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-readable program code.
[0097] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments corresponding to electronic devices are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0098] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of this specification. In some cases, the actions or steps described in this specification may be performed in a different order than those shown in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0099] The embodiments of the subject matter and functional operation described in this specification can be implemented in the following ways: digital electronic circuits, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this specification and their structural equivalents, or combinations thereof. Embodiments of the subject matter described in this specification can be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible, non-transitory program carrier for execution by a data processing device or for controlling the operation of a data processing device. Alternatively or additionally, the program instructions can be encoded on artificially generated propagation signals, such as machine-generated electrical, optical, or electromagnetic signals, which are generated to encode information and transmit it to a suitable receiving device for execution by a text curvature determination device. The computer storage medium can be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or combinations thereof.
[0100] The processing and logic flow described in this specification can be executed by one or more programmable computers that execute one or more computer programs to perform corresponding functions by operating on input data and generating output. The processing and logic flow can also be executed by dedicated logic circuitry—such as FPGAs (Field-Programmable Gate Arrays) or ASICs (Application-Specific Integrated Circuits), and the device can also be implemented as dedicated logic circuitry.
[0101] Suitable computers for executing computer programs include, for example, general-purpose and / or special-purpose microprocessors, or any other type of central processing unit. Typically, the central processing unit receives instructions and data from read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Typically, a computer will also include one or more mass storage devices for storing data, such as disks, magneto-optical disks, or optical disks, or the computer will be operatively coupled to such mass storage devices to receive data from or transfer data to them, or both. However, a computer is not required to have such devices. Furthermore, a computer can be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name a few.
[0102] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks. Processors and memory may be supplemented by or incorporated into dedicated logic circuitry.
[0103] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.
[0104] Similarly, although the operations are depicted in a specific order in the accompanying drawings, this should not be construed as requiring these operations to be performed in the specific order shown or sequentially, or requiring all illustrated operations to be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.
[0105] Therefore, specific embodiments of the subject matter have been described. Other embodiments are within the scope of this specification. In some cases, the actions described herein may be performed in a different order and still achieve the desired result. Furthermore, the processes depicted in the accompanying drawings are not necessarily shown in a specific order or sequence to achieve the desired result. In some implementations, multitasking and parallel processing may be advantageous.
[0106] Other embodiments of this specification will readily occur to those skilled in the art upon consideration of the specification and practice of the invention claimed herein. This specification is intended to cover any variations, uses, or adaptations that follow the general principles of this specification and include common knowledge or customary techniques in the art not claimed herein. That is, this specification is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
[0107] The above description is merely an optional embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification shall be included within the scope of protection of this specification.
Claims
1. A method for determining text curvature, characterized in that, The method includes: Identify at least one connected text component in a target text image; For each of the text connected components, the area curvature, boundary curvature, and region variance are calculated to obtain the text curvature parameters corresponding to each text connected component and / or the image curvature parameters corresponding to the target text image. The text bending result of the target text image is determined according to the preset curvature judgment rules, as well as the text bending parameters and / or the image bending parameters.
2. The method according to claim 1, characterized in that, The identification of at least one connected component in the target text image includes: The target text image is preprocessed, and at least one candidate connected component is identified; Illegal text filtering is performed on the at least one candidate connected component; In response to the existence of candidate connected components that pass the filter, the candidate connected components that pass the filter are determined to be literal connected components.
3. The method according to claim 2, characterized in that, The step of calculating the area curvature, boundary curvature curvature, and region variance for each of the text connected components to obtain the text curvature parameters corresponding to each text connected component, and / or the image curvature parameters corresponding to the target text image, includes: For each of the text connected components, calculate the corresponding foreground pixel area; When the area of the foreground pixel corresponding to the text connected region is greater than the area threshold, the area curvature, boundary curvature, and region variance are calculated for the text connected region to obtain the first parameter, second parameter, and third parameter corresponding to each text connected region as the corresponding text curvature parameter. The mean values of the first, second, and third parameters corresponding to the text connected components whose foreground pixel area is greater than the area threshold are calculated respectively to obtain the image curvature parameters corresponding to the target text image.
4. The method according to claim 3, characterized in that, For each of the connected text components, area curvature, boundary curvature, and region variance are calculated to obtain the first, second, and third parameters corresponding to each connected text component as the corresponding text curvature parameters, including: Calculate the area of the minimum bounding rectangle of the connected text component; The area curvature calculation result is determined as the first parameter based on the ratio of the foreground pixel area corresponding to each of the text connected components to the area of the minimum bounding rectangle.
5. The method according to claim 3, characterized in that, For each of the connected text components, area curvature, boundary curvature, and region variance are calculated to obtain the first, second, and third parameters corresponding to each connected text component as the corresponding text curvature parameters, including: Calculate the curvature of every three adjacent contour points of the text connected region, and sum them to obtain the boundary curvature. Calculate the perimeter of the text region of the minimum bounding quadrilateral of the text connected component; The boundary curvature is calculated as a ratio to the perimeter of the text region to obtain the boundary curvature bending degree calculation result, which is used as the second parameter.
6. The method according to claim 3, characterized in that, For each of the connected text components, area curvature, boundary curvature, and region variance are calculated to obtain the first, second, and third parameters corresponding to each connected text component as the corresponding text curvature parameters, including: Calculate the variance of the ordinates of all contour points in the text connected domain, and use the calculated result of the region variance as the third parameter.
7. The method according to claim 3, characterized in that, The step of determining the text curvature result of the target text image according to the preset curvature judgment rule, and the text curvature parameters and / or the image curvature parameters includes: If the second bending parameter is greater than the first threshold and the third bending parameter is greater than the second threshold, the text bending result of the target text image is determined to be bent; and / or, If the number of the first parameters that are greater than the third threshold is greater than the fourth threshold, and the third bending parameter is greater than the second threshold, then the text bending result of the target text image is determined to be bent.
8. The method according to claim 2, characterized in that, The identification of at least one connected component in the target text image includes: In response to the absence of a candidate connected component that passes the filter, each candidate connected component is determined to be a literal connected component.
9. The method according to claim 8, characterized in that, The step of calculating the area curvature, boundary curvature curvature, and region variance for each of the text connected components to obtain the text curvature parameters corresponding to each text connected component, and / or the image curvature parameters corresponding to the target text image, includes: For each of the text connected components, the ratio of the foreground pixel area to the minimum bounding rectangle area is calculated to obtain the first parameter of the text connected component; Calculate the curvature of every three adjacent contour points to obtain a list of curvatures as the fourth parameter of the text connected domain; Calculate the variance of the ordinates of all the contour points to obtain the third parameter of the text connected component; The text curvature parameter corresponding to each text connected component is determined based on the first, fourth, and third parameters of the text connected component.
10. The method according to claim 9, characterized in that, The step of determining the text curvature result of the target text image according to the preset curvature judgment rule, and the text curvature parameters and / or the image curvature parameters includes: The corresponding connected component bending state is determined based on the text bending parameters of each of the aforementioned connected components. Calculate the ratio of the number of connected components with curved states to the total number of connected components in the text. If the ratio is greater than the fifth threshold, the text bending result of the text image is determined to be bent.
11. The method according to claim 10, characterized in that, The step of determining the corresponding connected component curvature state based on the text curvature parameters of each of the text connected components includes: A predetermined number of curvatures are randomly sampled as the target curvature for the fourth parameter of the connected text domain. The bending feature parameters are determined based on the target curvature, the first parameter, and the third parameter corresponding to the text connected component. The bending feature parameters are input into the trained decision tree model to determine the bending state and obtain the corresponding connected component bending state.
12. A device for determining the curvature of text, characterized in that, The device includes: The connected component recognition module is used to identify at least one text connected component in the target text image; The bending parameter calculation module is used to calculate the area bending degree, boundary curvature bending degree and region variance for each of the text connected components, so as to obtain the text bending parameters corresponding to each text connected component and / or the image bending parameters corresponding to the target text image. The bending result judgment module is used to determine the text bending result of the target text image according to the preset bending degree judgment rules, as well as the text bending parameters and / or the image bending parameters.
13. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the operations performed by the text curvature determination method as described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program that is executed by a processor as described in any one of claims 1 to 11, the method for determining text curvature.