Methods, devices, and electronic equipment for recognizing hand-drawn graphics
By obtaining the coordinate set of the hand-drawn graphic, calculating the probability and similarity of the coordinates lying on a quadratic curve, and using a classification model to identify whether the hand-drawn graphic is a quadratic curve, the problem of inaccurate recognition by conventional tools is solved, and a higher recognition accuracy is achieved.
Patent Information
- Application Number
- CN202310713797.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-15
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2043-06-15
AI Technical Summary
Conventional online drawing tools cannot accurately identify whether a hand-drawn graphic is a quadratic curve, resulting in inaccurate recognition results.
By obtaining the coordinate set of the hand-drawn graphic, calculating the probability that the coordinates lie on the quadratic curve, and using the similarity between the hand-drawn graphic and the quadratic curve as identification features, a classification model is used to determine whether the hand-drawn graphic is a quadratic curve.
It improves the accuracy of hand-drawn graphic recognition and ensures the accuracy of the recognition results.
Smart Images

Figure CN116884020B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of image recognition, and in particular relates to a method, apparatus and electronic device for recognizing hand-drawn images. Background Technology
[0002] The widespread use of touchscreens has led to the increasing use of online drawing tools such as hand-drawing software and whiteboard software.
[0003] In various scenarios, such as teaching and meetings, it's common to use online drawing tools to create quadratic curves. However, hand tremors can occur during the drawing process, resulting in shaky or jagged noise in the hand-drawn graph. Conventional online drawing tools will identify whether the hand-drawn graph is indeed a quadratic curve and correct it, so that the corrected graph can be used in teaching or meetings later.
[0004] However, conventional online drawing tools cannot accurately identify whether a hand-drawn graphic is a quadratic curve. Summary of the Invention
[0005] This application provides a method, apparatus, and electronic device for recognizing hand-drawn graphics, which can improve the accuracy of recognizing hand-drawn graphics.
[0006] In a first aspect, a method for recognizing hand-drawn graphics is provided. The method includes: obtaining a first coordinate set of the hand-drawn graphics; obtaining target features of the hand-drawn graphics based on the first coordinate set, wherein the target features include at least one of the following: the probability that the coordinates of the first coordinate set lie on a quadratic curve, and the similarity between the hand-drawn graphics and the quadratic curve; and determining whether the hand-drawn graphics are a quadratic curve based on the target features.
[0007] In this embodiment, a target feature can be obtained based on a first coordinate set of a hand-drawn graphic. The target feature is the probability that the coordinates of the first coordinate set lie on a quadratic curve and the similarity between the hand-drawn graphic and the quadratic curve. Since the feature is a related feature of the quadratic curve, and due to the increase in feature types, the accuracy of recognizing the hand-drawn graphic can be improved.
[0008] Secondly, a hand-drawn graphic recognition device is provided. The recognition device includes a processing unit, which is used to: acquire a first coordinate set of the hand-drawn graphic; obtain target features of the hand-drawn graphic based on the first coordinate set, the target features including the probability that the coordinates of the first coordinate set lie on a quadratic curve and the similarity between the hand-drawn graphic and the quadratic curve; and determine whether the hand-drawn graphic is a quadratic curve based on the target features.
[0009] Thirdly, an electronic device is provided, comprising: one or more processors; one or more memories; the one or more memories storing one or more computer programs, the one or more computer programs including instructions that, when executed by one or more processors, cause the electronic device to perform the method as described in any of the first aspects.
[0010] Fourthly, a computer-readable storage medium is provided, including computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any of the first aspects.
[0011] Fifthly, a chip is provided, comprising: a memory for storing instructions; and a processor for retrieving and executing the instructions from the memory, causing an electronic device on which the chip is mounted to perform the method as described in any of the first aspects. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 This is a schematic flowchart illustrating a method for recognizing hand-drawn graphics provided in an embodiment of this application;
[0014] Figure 2 This is an example diagram of a capacitive sensing point provided in an embodiment of this application;
[0015] Figure 3 This is an exemplary block diagram of the hand-drawn graphic recognition device provided in the embodiments of this application;
[0016] Figure 4 This is a schematic structural diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0017] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application can also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of this application with unnecessary detail. In other instances, specific technical details in various embodiments can be referred to mutually, and specific systems not described in one embodiment can be referred to in other embodiments.
[0018] It should be understood that when used in the specification of this application and the appended claims, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0019] It should also be understood that the term "and / or" used in the specification of this application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0020] References to "embodiments of this application" or "some embodiments" described in the specification of this application mean that specific features, structures, or characteristics described in connection with that embodiment are included in one or more embodiments of this application. Thus, statements such as "in other embodiments", "an embodiment of this application", "other embodiments of this application", etc. that appear at different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized.
[0021] In addition, in the description of the specification of this application and the appended claims, the terms "first", "second", "first type", "second type", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0022] The method provided by the embodiments of this application can be applied to electronic devices with touch functions such as mobile phones, tablet computers, laptop computers, netbooks, writing screens, electronic whiteboards, etc. The embodiments of this application do not impose any restrictions on the specific types of electronic devices.
[0023] The following content introduces the inventive concept of this application.
[0024] Conic sections, also known as quadratic curves, refer to the locus of points where the ratio of the distance r to a fixed point in a plane to the distance d to a fixed line is a constant e = r / d. When e > 1, it is a hyperbola; when e = 1, it is a parabola; when 0 < e < 1, it is an ellipse. Quadratic curves include ellipses (circles are special cases of ellipses), parabolas, hyperbolas, etc. The embodiments of this application do not limit the types of quadratic curves. Conventional online drawing tools cannot accurately identify whether a hand-drawn graph is a quadratic curve. Specifically, when conventional online drawing tools extract the features of a hand-drawn graph based on its position to identify whether the hand-drawn graph is a quadratic curve, the final recognition result may be inaccurate due to reasons such as the features extracted not being relevant features of quadratic curves and the single type of features extracted.
[0025] To address the aforementioned deficiencies, the inventive concept of this application is as follows:
[0026] In this embodiment, the probability that the coordinates of a hand-drawn graphic lie on a quadratic curve and the similarity between the hand-drawn graphic and the quadratic curve can be used as features for recognizing the hand-drawn graphic. Since the probability that the coordinates of a hand-drawn graphic lie on a quadratic curve and the similarity between the hand-drawn graphic and the quadratic curve are both features related to the quadratic curve, and due to the increase in feature types, the accuracy of recognizing hand-drawn graphics can be improved.
[0027] The internal implementation process of the embodiments of this application is described below with reference to the accompanying drawings.
[0028] Please refer to Figure 1 , Figure 1 This is a schematic flowchart illustrating a method for recognizing hand-drawn graphics according to an embodiment of this application. This method can be executed by an electronic device, or by a processor or chip within the electronic device; this embodiment does not impose any limitations. For ease of description, an electronic device is used as an example to illustrate the method in detail.
[0029] S21. Obtain the first coordinate set of the hand-drawn graphic.
[0030] It should be understood that hand-drawn graphics refer to graphics created by a user that can be displayed on an electronic device. For example, hand-drawn graphics can be graphics drawn by a user in some application software on an electronic device (such as whiteboard software, drawing software, etc.), or graphics drawn by a user on a peripheral device of the electronic device (such as a graphics tablet) and displayed on the electronic device.
[0031] In this embodiment of the application, the first coordinate set can indicate the position of the hand-drawn graphic on the display screen of the electronic device.
[0032] In this embodiment of the application, when the electronic device identifies whether a hand-drawn graphic is a quadratic curve, it can directly obtain the first coordinate set of the hand-drawn graphic, or it can obtain the first coordinate set of the hand-drawn graphic from the memory. This embodiment of the application does not limit the way the electronic device obtains the first coordinate set.
[0033] S22. Based on the first coordinate set, obtain the target features of the hand-drawn graphic. The target features include the probability that the coordinates of the first coordinate set lie on the quadratic curve and the similarity between the hand-drawn graphic and the quadratic curve.
[0034] The target feature in this application embodiment refers to the attribute or characteristic of a quadratic curve. Based on this attribute or characteristic, it is used to identify whether a hand-drawn graphic is a quadratic curve.
[0035] It should be understood that the probability that the coordinates of the first coordinate set lie on the conic section refers to an attribute or characteristic of the conic section. This probability can be represented by a value between 0 and 1; for example, 0.6 indicates that the probability of the coordinates of the first coordinate set lying on the conic section is 0.6. The larger the value of this characteristic, the higher the degree of overlap between the hand-drawn graphic and the conic section; the smaller the value, the lower the degree of overlap.
[0036] It can also be understood that since the intersection points of the three pairs of sides of a hexagon (including a degenerate hexagon) inscribed in a conic section are collinear, in other words, if the intersection points of the three pairs of sides of a hexagon formed by six points are collinear, then these six points are points located on the conic section.
[0037] In some embodiments of this application, the number of points in the first coordinate set located on the quadratic curve can be obtained by determining that the intersection points of the three pairs of sides of the hexagon formed by any six points in the first coordinate set are collinear. By calculating the number of points in the first coordinate set located on the quadratic curve and the total number of coordinates in the first coordinate set, the probability that the coordinates of the first coordinate set are located on the quadratic curve can be obtained.
[0038] Of course, the embodiments of this application can also determine the number of points in the first coordinate set that lie on the quadratic curve through other implementation methods to obtain the probability that the coordinates of the first coordinate set lie on the quadratic curve. The embodiments of this application do not limit this. For example, a quadratic curve can be fitted by the points in the first coordinate set to obtain the equation of the quadratic curve. Then, each coordinate of the first coordinate set is substituted into the equation to determine whether the equation is satisfied. If it is satisfied, it is determined that the coordinate lies on the quadratic curve, thereby obtaining the number of points in the first coordinate set that lie on the quadratic curve. By calculating the number of points in the first coordinate set that lie on the quadratic curve and the total number of coordinates in the first coordinate set, the probability that the coordinates of the first coordinate set lie on the quadratic curve can be obtained.
[0039] It should be understood that the similarity between the hand-drawn graphic and the quadratic curve refers to another attribute or feature of the quadratic curve. In this embodiment, the similarity between the hand-drawn graphic and the quadratic curve obtained from the coordinates of the hand-drawn graphic and the fitted curve can indicate the degree of deviation between the hand-drawn graphic and the quadratic curve, the degree of closeness between the coordinates of the first coordinate set and the coordinates of the quadratic curve, and other information. Based on this information, it can be identified whether the hand-drawn graphic is a quadratic curve.
[0040] S23. Based on the target characteristics, determine whether the hand-drawn graphic is a quadratic curve.
[0041] In this embodiment, the target features can be input into a classification model, and the output of the classification model can be used to determine whether the hand-drawn graphic is a quadratic curve. It should be understood that the classification model can include logistic regression models, Naive Bayes models, decision tree models, support vector machine models, random forest models, gradient boosting tree models, etc., and this embodiment does not limit the type of classification model.
[0042] In this embodiment, a target feature can be obtained based on a first coordinate set of a hand-drawn graphic. The target feature is the probability that the coordinates of the first coordinate set lie on a quadratic curve and the similarity between the hand-drawn graphic and the quadratic curve. Since the feature is a related feature of the quadratic curve, and due to the increase in feature types, the accuracy of recognizing the hand-drawn graphic can be improved.
[0043] In some embodiments, obtaining the probability that the coordinates of the first coordinate set of the hand-drawn graphic lie on a quadratic curve includes the following steps:
[0044] S221. Sample the first coordinate set to obtain multiple sets of first candidate sampling points.
[0045] It should be understood that sampling processing of the first coordinate set can be performed once or multiple times.
[0046] When the amount of data in the first coordinate set is large, directly calculating the probability that the coordinates of the first coordinate set lie on the quadratic curve may increase the computational load on the electronic device. Therefore, the first coordinate set can be sampled once to reduce the amount of data required to calculate the probability that the coordinates of the first coordinate set lie on the quadratic curve. At the same time, to avoid the inaccuracy of the final calculated probability that the coordinates of the first coordinate set lie on the quadratic curve due to a single sampling process, the first coordinate set can be sampled multiple times (multiple times can be understood as more than one time) to improve the accuracy of the final calculated probability that the coordinates of the first coordinate set lie on the quadratic curve. The embodiments of this application do not limit the sampling process; for example, the sampling process can be uniform sampling.
[0047] For example, the first coordinate set includes the coordinates of 100 capacitive sensing points. To reduce the computational load of the electronic device and improve the accuracy of the probability that the coordinates of the first coordinate set lie on the quadratic curve, the first coordinate set is sampled twice. The first sampling process yields 10 sets of sampling points, and the second sampling process yields 15 sets of sampling points. Each set of first candidate sampling points includes 6 sampling points. In this embodiment, the 10 sets of sampling points, 15 sets of sampling points, etc., obtained from the sampling process are referred to as multiple sets of first candidate sampling points.
[0048] S222. Screening is performed on multiple groups of first candidate sampling points to obtain multiple groups of second candidate sampling points. Each group of second candidate sampling points can form multiple pairs of opposite edges, and the multiple pairs of opposite edges are multiple groups of non-parallel opposite edges.
[0049] It should be understood that each group of first candidate sampling points may include at least six sampling points, and the embodiments of this application do not limit the number of sampling points in each group of first candidate sampling points. The embodiments of this application illustrate that each group of first candidate sampling points may include six sampling points.
[0050] Each group of second candidate sampling points can form multiple pairs of opposite edges. Multiple pairs of opposite edges can be understood as multiple non-parallel opposite edges. For example, if each group of second candidate sampling points includes six sampling points, then these six sampling points can form six edges, and these six edges can form three pairs of opposite edges. These three pairs of opposite edges of the second candidate sampling points are three pairs of non-parallel opposite edges.
[0051] In some embodiments, after obtaining multiple sets of first candidate sampling points in S221, the probability that the coordinates of the first coordinate set lie on the quadratic curve can be determined by judging whether the intersection points of the three pairs of sides of the hexagon formed by the six sampling points in each set of first candidate sampling points are collinear. For example, after obtaining 10 sets of first candidate sampling points in the first sampling process of S221, if it is determined that the intersection points of the three pairs of sides of the hexagon formed by the six sampling points in 6 sets of first candidate sampling points are collinear, then the probability that the coordinates of the determined first coordinate set lie on the quadratic curve is 0.6.
[0052] First candidate sampling points can be filtered out if any one of the three sets of opposite edges obtained from six sampling points is parallel. Since first candidate sampling points have already been filtered out from multiple sets of first candidate sampling points if any one of the three sets of opposite edges obtained from six sampling points is parallel, the remaining first candidate sampling points will not have any one of the three sets of opposite edges obtained from six sampling points parallel. The three sets of opposite edges of the six sampling points of the remaining first candidate sampling points can form an intersection point. Using the remaining first candidate sampling points to determine whether the intersection point of the three sets of opposite edges of the six sampling points in each set of first candidate sampling points is collinear can improve the accuracy of determining the probability that the coordinates of the first coordinate set are located on the quadratic curve while reducing the computational load of electronic devices. In the embodiments of this application, the remaining first candidate sampling points are referred to as multiple sets of second candidate sampling points with multiple sets of opposite edges that are not parallel.
[0053] S223. Based on multiple sets of second candidate sampling points, multiple sets of target sampling points are obtained. The multiple sets of target sampling points are points located on the quadratic curve.
[0054] It should be understood that obtaining multiple sets of target sampling points based on multiple sets of second candidate sampling points is to screen out second candidate sampling points where the intersection points of the three pairs of sides obtained from the six sampling points are collinear. In the embodiments of this application, the second candidate sampling points where the intersection points of the three pairs of sides obtained from the six sampling points are collinear are referred to as multiple sets of target sampling points.
[0055] The embodiments of this application do not limit the method for determining whether the intersection points of three pairs of sides obtained based on six sampling points are collinear.
[0056] S224. Based on multiple sets of second candidate sampling points and multiple sets of target sampling points, determine the probability that the coordinates of the first coordinate set lie on the quadratic curve.
[0057] In this embodiment of the application, when the sampling process is performed once, determining the probability that the coordinates of the first coordinate set lie on a quadratic curve includes:
[0058] The ratio of multiple sets of target sampling points to multiple sets of second candidate sampling points is determined as the probability that the coordinates of the first coordinate set lie on the quadratic curve.
[0059] In some embodiments, when the sampling process is performed multiple times, determining the probability that the coordinates of the first coordinate set lie on the quadratic curve includes:
[0060] Determine the ratio of multiple sets of target sampling points to multiple sets of second candidate sampling points; determine the ratio of the ratio of multiple sets of target sampling points to multiple sets of second candidate sampling points to the number of sampling processes i as the probability that the coordinates of the first coordinate set lie on the quadratic curve.
[0061] For example, the probability that the coordinates of the first coordinate set lie on the quadratic curve can be determined based on the following formula:
[0062]
[0063] Where P represents the ratio of the ratio of multiple sets of target sampling points to multiple sets of second candidate sampling points to the number of sampling processes i. X1, X2, ... X3 represent the ratios of multiple target sampling points to multiple second candidate sampling points, respectively. i Y1, Y2, ..., Y3 represent the number of target sampling points processed in each of the i-th sampling processes. i This represents the number of multiple sets of second candidate sampling points processed in each of the i sampling processes, where i represents the number of sampling processes and is an integer greater than or equal to 1.
[0064] In this embodiment of the application, when the amount of data in the first coordinate set is large, directly using the first coordinate set to calculate the probability that the coordinates of the first coordinate set are located on the quadratic curve may increase the computational load of the electronic device. Therefore, the first coordinate set can be sampled to reduce the amount of data required to calculate the probability that the coordinates of the first coordinate set are located on the quadratic curve.
[0065] Furthermore, the embodiments of this application can screen multiple sets of first candidate sampling points to obtain multiple sets of second candidate sampling points. The multiple pairs of opposite sides obtained by each set of second candidate sampling points are non-parallel opposite sides, which can improve the accuracy of determining multiple target sampling points, thereby improving the accuracy of determining the probability that the coordinates of the first coordinate set are located on the quadratic curve.
[0066] Furthermore, the embodiments of this application can accurately determine the probability that the coordinates of the first coordinate set lie on the quadratic curve based on multiple sets of second candidate sampling points and multiple sets of target sampling points.
[0067] The embodiments of this application can also determine the probability that the coordinates of the first coordinate set lie on the quadratic curve based on multiple sets of second candidate sampling points, multiple sets of target sampling points and the number of sampling processes i, which is more accurate than the probability that the coordinates of the first coordinate set lie on the quadratic curve determined only based on multiple sets of second candidate sampling points and multiple sets of target sampling points.
[0068] In some embodiments, in S222, multiple sets of first candidate sampling points are filtered to obtain multiple sets of second candidate sampling points with non-parallel opposite edges, based on each set of second candidate sampling points, including:
[0069] Multiple sets of first candidate sampling points are filtered to obtain multiple sets of second candidate sampling points. The multiple pairs of opposite sides of each set of second candidate sampling points are non-parallel opposite sides, and the adjacent sampling points of each set of second candidate sampling points are spaced j coordinates apart in the first coordinate set.
[0070] It should be understood that if the values of the adjacent coordinates of the six sampling points in some of the multiple sets of first candidate sampling points are similar, then the line connecting two sampling points with similar values is prone to deviation, which will make the probability that the coordinates of the final calculated first coordinate set lie on the quadratic curve inaccurate.
[0071] To improve the accuracy of calculating the probability that the coordinates of the first coordinate set lie on the quadratic curve, the first candidate sampling points with an interval of j coordinates between adjacent sampling points in the first coordinate set can be filtered out from the six sampling points. In this way, the six sampling points of the remaining first candidate sampling points are not adjacent or have different values in the first coordinate set. This can reduce the computational load of electronic equipment while ensuring that the six sampling points can be accurately identified, thereby improving the accuracy of calculating the probability that the coordinates of the first coordinate set lie on the quadratic curve.
[0072] It should be understood that when j is 0, filtering out the first candidate sample point in the first coordinate set that is j coordinates apart from the adjacent sample points in the six sample points is the same as filtering out the first candidate sample point in the first coordinate set that is also adjacent to the adjacent sample points in the six sample points.
[0073] When j is greater than 0, the first candidate sampling point in the first coordinate set that is j coordinates apart from adjacent sampling points among the six sampling points is the first candidate sampling point that is not adjacent but has similar values among the six sampling points in the first coordinate set.
[0074] In this embodiment, multiple sets of first candidate sampling points are filtered out, and first candidate sampling points that are parallel to any one of the three sets of opposite edges obtained from six sampling points are filtered out. Also, first candidate sampling points in the six sampling points that are adjacent to each other and are separated by j coordinates in the first coordinate set are filtered out. The remaining first candidate sampling points are called multiple sets of second candidate sampling points.
[0075] In some embodiments, obtaining multiple sets of first candidate sampling points includes the following steps:
[0076] S2211. Perform preprocessing operations on the first coordinate set to obtain the second coordinate set. The preprocessing operations include deduplication.
[0077] It should be understood that the preprocessing operation on the first coordinate set mainly involves deleting irrelevant data, duplicate data, smoothing noisy data, outliers, etc. in the first coordinate set. The embodiments of this application do not limit the preprocessing operation.
[0078] S2212. Sample the second coordinate set to obtain multiple sets of first candidate sampling points.
[0079] It should be understood that sampling the second coordinate set can be performed once or multiple times.
[0080] The process for each sampling step is as follows:
[0081] Six sampling points are randomly selected from the second coordinate set as a group of first candidate sampling points to obtain multiple groups of first candidate sampling points.
[0082] It is understood that random sampling methods may include simple random sampling, stratified random sampling, cluster random sampling, etc., and the embodiments of this application do not limit the random sampling method.
[0083] In this embodiment, a preprocessing operation can be performed on the first coordinate set to obtain a second coordinate set. Redundant data in the first coordinate set can be deleted to reduce the computational load of the electronic device. Furthermore, the preprocessed second coordinate set can be sampled to reduce the amount of data required to calculate the probability that the coordinates of the first coordinate set lie on the quadratic curve, while improving the accuracy of the final calculated probability that the coordinates of the first coordinate set lie on the quadratic curve.
[0084] In some embodiments, obtaining multiple sets of second candidate sampling points includes the following steps:
[0085] S2221. Obtain the index set of the first coordinate set, and perform sampling processing on the index set to obtain multiple sets of first candidate sampling points.
[0086] It should be understood that each group of first candidate sampling points may include at least six indexes corresponding to the sampling points. This application embodiment does not limit the number of sampling points or the number of indexes corresponding to the sampling points in each group of first candidate sampling points. This application embodiment illustrates this by assuming that each group of first candidate sampling points may include six indexes corresponding to the sampling points. It should also be understood that the sampling process may be one or more sampling processes.
[0087] When users draw hand-drawn graphics on a touchscreen, a large amount of coordinate data may be generated. In order to better process this large amount of coordinate data, an index can be added to each coordinate in the coordinate system in advance, so that the mapping relationship between coordinates and indexes can be obtained. When obtaining the first coordinate set, only the index set of the first coordinate set needs to be obtained. Processing the index set of the first coordinate set can improve the processing speed of electronic devices compared to directly processing the coordinate data of the first coordinate set.
[0088] For example, an index can be added to each coordinate in the coordinate system to obtain the mapping relationship between coordinates and indices:
[0089] When the x-coordinate in the coordinate system is equal to the y-coordinate, the index is 0.
[0090] When the x-coordinate is greater than the y-coordinate, the index can be calculated using the following formula:
[0091] index = 4k 2 +1+(2k+x+y).
[0092] When the x-coordinate is less than or equal to the y-coordinate, the index can be calculated using the following formula:
[0093] index = 4k 2 +1-(2k+x+y).
[0094] Where k = max(|x|,|y|), x represents the x-coordinate and y represents the y-coordinate.
[0095] For example, the mapping relationship between coordinates and indices can be referenced. Figure 2 , Figure 2 An example diagram of a capacitive touch point is shown. In this example, the capacitive touchscreen has 4 columns and 4 rows of capacitive touch sensors. These 4×4 interleaved capacitive touch sensors form a 4×4 capacitive touch point. The origin of the coordinate system is the capacitive touch point in the first row and first column. The positive direction of the X-axis is from the first column of capacitive touch points to the fourth column, and the positive direction of the Y-axis is from the first row of capacitive touch points to the fourth row. Figure 2 As shown, the index corresponding to each coordinate is calculated according to the above formula. For example, the coordinate (2,1) has an x-coordinate greater than its y-coordinate, and its corresponding index is: 4×2²+1+(2×2+2+1)=24. According to the above index calculation formula, the index set of the first coordinate set can be {0, 2, 11, 28, 27, 26, 25, 48, 47, 46, 23, 8}. The index set is sampled (e.g., twice). One sampling process yields multiple sets of first candidate sampling points (e.g., the first sampling process yields 10 sets of first candidate sampling points, and the second sampling process yields 15 sets of first candidate sampling points). Each set of first candidate sampling points includes the indices corresponding to six sampling points. For example, the index corresponding to one set of first candidate sampling points can be (0, 11, 27, 25, 47, 23), and the index corresponding to another set of first candidate sampling points can be (0, 2, 27, 25, 47, 23).
[0096] S2222. Delete any first candidate sampling point that is parallel to any one of the three pairs of opposite edges obtained from the index of the six sampling points corresponding to the first candidate sampling points in each group of first candidate sampling points, to obtain multiple groups of second candidate sampling points.
[0097] It is understandable that, in multiple sets of first candidate sampling points, the first candidate sampling point parallel to any one of the three sets of opposite edges obtained from the indices corresponding to the six sampling points in each set of first candidate sampling points can be deleted.
[0098] For example, suppose that in a group of first candidate sampling points, one group of candidate sampling points has indices (0, 11, 27, 25, 47, 23). Then, the equation for edge 1 can be obtained based on the first index 0 and the second index 11. For example, based on the first index 0, the second index 11, and the mapping relationship between coordinates and indices, the coordinates corresponding to the first index and the second index can be obtained. Based on the coordinates corresponding to the first index and the second index, the equation for edge 1 can be calculated. Based on the above method, the equation for edge 2 can be obtained based on the second index 11 and the third index 27, the equation for edge 3 can be obtained based on the third index 27 and the fourth index 25, the equation for edge 4 can be obtained based on the fourth index 25 and the fifth index 47, the equation for edge 5 can be obtained based on the fifth index 47 and the sixth index 23, and the equation for edge 6 can be obtained based on the sixth index 23 and the first index 0.
[0099] Consider edges 1 and 4 as one pair of opposite edges, edges 2 and 5 as another pair of opposite edges, and edges 3 and 6 as yet another pair of opposite edges. Determine whether each of these three pairs of opposite edges is parallel. If at least one pair of opposite edges is found to be parallel, then delete the first candidate sampling point with index (0, 11, 27, 25, 47, 23) from the multiple first candidate sampling points.
[0100] The embodiments of this application do not limit the method for determining whether the three pairs of opposite sides are parallel. For example, the slope of side 1 can be calculated based on the equation of the side, and the slope of side 4 can be calculated based on the equation of side 4. If it is determined that the slope of side 1 is equal to the slope of side 4, then side 1 and side 4 are parallel; otherwise, side 1 and side 4 are not parallel.
[0101] In this embodiment, since multiple sets of second candidate sampling points are obtained by deleting any one of the three sets of opposite edges parallel to the index of the six sampling points corresponding to each set of first candidate sampling points, multiple sets of second candidate sampling points can be obtained. Therefore, each sampling point in multiple sets of second candidate sampling points can be accurately identified, which ultimately improves the accuracy of the probability that the coordinates of the determined first coordinate set are located on the quadratic curve.
[0102] In some embodiments, S2222 further includes deleting any one of the three sets of opposite edges parallel to the first candidate sampling points obtained from the indices corresponding to the six sampling points in each set of first candidate sampling points, to obtain multiple sets of second candidate sampling points:
[0103] In multiple sets of first candidate sampling points, delete the first candidate sampling points whose adjacent indices in the indexes corresponding to the six sampling points of each first candidate sampling point are separated by j indices in the index set, and delete the first candidate sampling points that are parallel to any one of the three sets of opposite edges obtained based on the indices corresponding to the six sampling points of each first candidate sampling point, to obtain multiple sets of second candidate sampling points.
[0104] It should be understood that when deleting the first candidate sampling points from multiple groups, the adjacent indices of the six sampling points corresponding to each group of first candidate sampling points are first candidate sampling points with an interval of j in the index set, where j is an integer greater than or equal to 0.
[0105] For example, when j equals 0, assuming the index set of the first coordinate set can be {0, 2, 11, 28, 27, 26, 25, 48, 47, 46, 23, 8}, if the index of one of the multiple sets of first candidate sampling points is (0, 2, 27, 25, 47, 23), since the adjacent index (0, 2) of this set of candidate sampling points is also adjacent in the index set of the first coordinate set (with a gap of 0 in the index set), it is necessary to delete this set of candidate sampling points from the multiple sets of first candidate sampling points.
[0106] In another example, when j is greater than 0, for example, j equals 1, assuming the index set of the first coordinate set can be {7, 8, 9, 28, 27, 26, 25, 48, 47, 46, 23, 8}, if the index of one of the multiple first candidate sampling points is (7, 9, 27, 25, 47, 23), since the adjacent indices (7, 9) of this group of candidate sampling points are close in the index set of the first coordinate set (separated by 1 index in the index set), it is necessary to delete this group of candidate sampling points from the multiple first candidate sampling points.
[0107] In some embodiments, obtaining multiple sets of target sampling points includes the following steps:
[0108] S2231. Based on the six sampling points of each group of second candidate sampling points in multiple groups of second candidate sampling points, determine three groups of opposite edges.
[0109] In implementation, the three pairs of opposite edges can be determined as follows:
[0110] First, based on the six sampling points of each group of second candidate sampling points in multiple groups of second candidate sampling points, the first edge, the second edge, the third edge, the fourth edge, the fifth edge, and the sixth edge are determined. The first edge is obtained based on the first sampling point and the second sampling point, the second edge is obtained based on the second sampling point and the third sampling point, the third edge is obtained based on the third sampling point and the fourth sampling point, the fourth edge is obtained based on the fourth sampling point and the fifth sampling point, the fifth edge is obtained based on the fifth sampling point and the sixth sampling point, and the sixth edge is obtained based on the sixth sampling point and the first sampling point.
[0111] It should be understood that these six sampling points are six sampling points arranged in the sampling order within each of the multiple sets of second candidate sampling points. For example, suppose a set of second candidate sampling points is ((0, 1), (11, 13), (27, 31), (38, 41), (47, 52), (60, 61)). Then, (0, 1) is the first sampling point when sampling this set of second candidate sampling points, called the first sampling point; (11, 13) is the second sampling point when sampling this set of second candidate sampling points, called the second sampling point; and so on, to obtain these six sampling points.
[0112] After obtaining the six sampling points and their arrangement, the first, second, third, fourth, fifth, and sixth edges can be determined using the following method:
[0113] The first edge is obtained based on the second sampling point of the first sampling point. For example, based on the coordinates of the first sampling point (0, 1) and the coordinates of the second sampling point (11, 13), equation 1 of the line is calculated, which represents the first edge. The second edge is obtained based on the second and third sampling points. For example, based on the coordinates of the second sampling point (11, 13) and the coordinates of the third sampling point (27, 31), equation 2 of the line is calculated, which represents the second edge. This process is repeated to obtain six edges.
[0114] Next, determine the first, second, and third pairs of opposite edges in the three pairs of opposite edges. The first pair of opposite edges is obtained based on the first and fourth edges, the second pair of opposite edges is obtained based on the second and fifth edges, and the sixth pair of opposite edges is obtained based on the third and sixth edges.
[0115] It should be understood that three pairs of opposite edges can be determined in the following way:
[0116] Let equation 1 (the first edge) and equation 4 (the fourth edge) be the first pair of opposite edges; let equation 2 (the first edge) and equation 5 (the fifth edge) be the second pair of opposite edges; and let equation 3 (the third edge) and equation 6 (the sixth edge) be the third pair of opposite edges.
[0117] S2232. Based on the three sets of opposite edges, determine the first intersection point, the second intersection point, and the third intersection point corresponding to the three sets of opposite edges.
[0118] It should be understood that after determining the three pairs of opposite sides in S2231, the equations of the three pairs of opposite sides can be obtained. Based on the equations of each pair of opposite sides, the first intersection point, the second intersection point, and the third intersection point corresponding to the three pairs of opposite sides can be determined.
[0119] S2233. Based on the coordinates of the first intersection point, the second intersection point, and the third intersection point, determine the distances between the first and second intersection points, the distances between the second and third intersection points, and the distances between the first and third intersection points, and sort them to obtain the first distance, the second distance, and the third distance. The first distance is less than the second distance, and the second distance is less than the third distance.
[0120] In this embodiment of the application, after determining the coordinates d1 of the first intersection point, d2 of the second intersection point, and d3 of the third intersection point, d1, d2, and d3 are sorted in ascending order of their values. The distance with the smallest value is called the first distance, the distance with the largest value is called the third distance, and the distance with the middle value is called the second distance. For example, if d1 < d2 < d3, then d1 is called the first distance, d2 is called the second distance, and d3 is called the third distance.
[0121] S2234. If the ratio of the sum of the first distance and the second distance to the third distance is less than the first threshold, then the six sampling points are determined as one set of target sampling points in the multiple sets of target sampling points, so as to determine the multiple sets of target sampling points.
[0122] It should be understood that when all six coordinates of a set of target sampling points in a user-drawn hand-drawn graphic lie on a quadratic curve, the first distance, second distance, and third distance obtained based on these six coordinates satisfy the following condition: the ratio of the sum of the first distance and the second distance to the third distance is equal to 1.
[0123] In this embodiment of the application, although some coordinates in the user-drawn hand-drawn graphic are not on the quadratic curve, the errors of these coordinates relative to the quadratic curve are small. The coordinates with smaller errors relative to the quadratic curve will also be judged as coordinates on the quadratic curve. The advantage of this processing is that it can increase the number of target sampling points to better identify whether the hand-drawn graphic is a quadratic curve.
[0124] In this embodiment, when the errors of six coordinates in a set of target sampling points relative to the quadratic curve are small, the first distance, second distance, and third distance obtained based on these six coordinates satisfy the following condition: the ratio of the sum of the first distance and the second distance to the third distance is less than a first threshold. The first threshold can be a number near the integer 1, and this embodiment does not limit its value. The first threshold can be a value obtained in advance based on test data.
[0125] In this embodiment of the application, after determining the first distance, the second distance, and the third distance in multiple groups of second candidate sampling points, if the first distance, the second distance, and the third distance of one or more groups of second candidate sampling points satisfy the condition that the ratio of the sum of the first distance and the second distance to the third distance is less than a first threshold, then the one or more groups of second candidate sampling points are determined as target sampling points.
[0126] In this embodiment, the determination of six sampling points as one set of target sampling points among multiple sets is based on the fact that the ratio of the sum of the first distance and the second distance to the third distance is less than a first threshold, rather than based on the fact that the ratio of the sum of the first distance and the second distance to the third distance is equal to 1. This allows the second candidate sampling point with a smaller error relative to the quadratic curve among multiple sets of second candidate sampling points to be determined as the target sampling point, thereby increasing the number of target sampling points and better identifying whether the hand-drawn graphic is a quadratic curve.
[0127] In some embodiments, obtaining the similarity between a hand-drawn graphic and a quadratic curve includes the following steps:
[0128] S225. Fit the first coordinate set to obtain the first equation, which is used to characterize the fitted quadratic curve.
[0129] It should be understood that the coordinates of the first coordinate set can be fitted using methods such as approximating discrete data with analytical expressions or the least squares method to obtain the first equation. This application does not limit the fitting method used. For example, the process of fitting the coordinates of the first coordinate set using the least squares method to obtain the first equation can be as follows:
[0130] First, select the first equation to be fitted. The selected first equation to be fitted can be:
[0131] F(x,y)=Ax 2 +Bxy+Cy 2 +Dx+Ey+F=0.
[0132] Where F(x,y) represents the first equation to be fitted, and A, B, C, D, E and F are unknown constant terms (these constant terms are determined in the first equation obtained after fitting).
[0133] The bivariate function corresponding to the first equation to be fitted is:
[0134] F(x,y)=Ax 2 +Bxy+Cy 2 +Dx+Ey+F.
[0135] Secondly, by taking each unknown constant term as a predicted value, six sets of equations are obtained. Each set of equations can represent a quadratic curve, and the quadratic curves represented by the six sets of equations are all different. For example, taking F as a prediction, a set of equations is obtained as follows:
[0136] F = -Ax 2 -Bxy-Cy 2 -Dx-Fy.
[0137] Finally, based on the coordinates of the first coordinate set and the six sets of equations, the mean square error between the coordinates of the first coordinate set and the coordinates on the quadratic curve represented by each set of equations is calculated. The equation corresponding to the smallest mean square error among the multiple mean square errors is taken as the first equation. When calculating the mean square error between the coordinates of the first coordinate set and the coordinates on the quadratic curve represented by each set of equations, the coordinates of the first coordinate set can be normalized. This can limit the data in the first coordinate set to a certain range, thereby eliminating the adverse effects caused by outlier data.
[0138] The above method for fitting a quadratic curve is merely an illustrative example and does not constitute a limitation on the method for fitting a quadratic curve.
[0139] S226. Based on the first coordinate set and the first equation, obtain the similarity between the hand-drawn figure and the quadratic curve. The similarity between the hand-drawn figure and the quadratic curve includes at least one of the following: the degree of deviation between the hand-drawn figure and the quadratic curve, the degree of closeness between the coordinates of the first coordinate set and the coordinates of the quadratic curve, and the average change of the coordinates of the first coordinate set.
[0140] It should be understood that, based on the first coordinate set and the first equation, the mean square error between the coordinates of the first coordinate set and the coordinates in the fitted curve can be obtained. The mean square error between the coordinates of the first coordinate set and the coordinates in the fitted curve can characterize the degree of deviation between the hand-drawn graphic and the quadratic curve. In this embodiment, the degree of deviation between the hand-drawn graphic and the quadratic curve is used as the similarity between the hand-drawn graphic and the quadratic curve.
[0141] Based on the first coordinate set and the first equation, the ratio of the number of coordinates in the first coordinate set with smaller error values relative to the fitted curve to the total number of coordinates in the first coordinate set can be obtained. The ratio of the number of coordinates in the first coordinate set with smaller error values relative to the fitted curve to the total number of coordinates in the first coordinate set can characterize the degree of similarity between the coordinates in the first coordinate set and the quadratic curve. In this embodiment, the degree of similarity between the coordinates in the first coordinate set and the quadratic curve is used as the similarity between the hand-drawn graphic and the quadratic curve.
[0142] Based on the first coordinate set and the first equation, the average change in the slope of the coordinates of the first coordinate set in the tangential direction can be obtained. The average change in the coordinates of the first coordinate set in the tangential direction can characterize the average change in the coordinates of the first coordinate set. In this embodiment, the average change in the coordinates of the first coordinate set is used as the similarity between the hand-drawn graphic and the quadratic curve.
[0143] In other embodiments, based on the first coordinate set and the first equation, the variance of the average change of the slope of the coordinates of the first coordinate set in the tangent direction can be obtained. The variance of the average change of the coordinates of the first coordinate set in the tangent direction can characterize the degree of deviation between the change of each coordinate in the first coordinate set and the average change. In this embodiment, the degree of deviation between the change of each coordinate in the first coordinate set and the average change is used as the similarity between the hand-drawn graphic and the quadratic curve.
[0144] In some embodiments, obtaining the degree of deviation between a hand-drawn graphic and a quadratic curve includes the following steps:
[0145] S2261. Based on the first coordinate set and the first equation, determine the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation, and determine the gradient of each coordinate in the first coordinate set.
[0146] In this embodiment, based on the first equation obtained in S225, each coordinate in the first coordinate set is substituted into the first equation, that is, the value of each coordinate in the first coordinate set in the binary function corresponding to the first equation is determined. For example, the value of any coordinate in the first coordinate set in the binary function corresponding to the first equation can be expressed as:
[0147] F(i)=F(x i y i ).
[0148] In this embodiment of the application, the gradient of each coordinate in the first coordinate set can be determined according to the following formula:
[0149] Grad i =(Fx i Fy i ).
[0150] Among them, Grad i Fx represents the gradient of any coordinate in the first coordinate set. i Fy represents the value of the partial derivative of the bivariate function corresponding to the first equation with respect to x at any coordinate. i Let represent the value of the partial derivative of the bivariate function corresponding to the first equation with respect to y at any coordinate, where i is an integer greater than or equal to 1.
[0151] S2262. Based on the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation, the gradient of each coordinate in the first coordinate set, and the total number of coordinates in the first coordinate set, the degree of deviation between the hand-drawn graphic and the quadratic curve is obtained.
[0152] In this embodiment, obtaining the degree of deviation between the hand-drawn graphic and the quadratic curve includes calculating a first ratio based on the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation and the gradient of each coordinate in the first coordinate set; calculating the average value of the first ratio based on the first ratio and the total number of coordinates in the first coordinate set, and using the average value of the first ratio as the degree of deviation between the hand-drawn graphic and the quadratic curve. The first ratio is the ratio of the absolute value of the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation to the absolute value of the gradient of each coordinate in the first coordinate set.
[0153] In this embodiment of the application, the mean square error between the coordinates of the first coordinate set and the coordinates of the fitted curve (first equation) can be calculated based on the following formula. This mean square error can characterize the degree of deviation between the hand-drawn graphic and the quadratic curve:
[0154]
[0155] Where MSE represents the mean square error between the coordinates of the first coordinate set and the coordinates in the fitted curve, err i Let F(i) represent the first ratio, and F(i) represent the value of any coordinate in the first coordinate set within the bivariate function corresponding to the first equation. Grad i Let represent the gradient of any coordinate in the first coordinate set, and n be the total number of coordinates in the first coordinate set.
[0156] In this embodiment, based on the obtained first coordinate set, the value of each coordinate in the first coordinate set in the corresponding bivariate function of the first equation is determined by fitting the first equation, and the gradient of each coordinate in the first coordinate set is determined. Then, based on the value of each coordinate in the first coordinate set in the corresponding bivariate function of the first equation, the gradient of each coordinate in the first coordinate set, and the total number of coordinates in the first coordinate set, the degree of deviation between the hand-drawn graphic and the quadratic curve is accurately calculated.
[0157] In some other embodiments, the internal implementation process of S2262 may also include the following steps:
[0158] S22621. Determine the expansion coefficient based on the maximum and minimum values in the first type of coordinates and the maximum and minimum values in the second type of coordinates.
[0159] It should be understood that the coordinates of the first coordinate set include first-type coordinates and second-type coordinates. For example, the first coordinate set is {(0,0), (1,0), ..., (M-2,0), (M-1,0)}. The first value of each coordinate can be regarded as the first-type coordinate, and the second value of each coordinate can be regarded as the second-type coordinate.
[0160] It is understandable that the magnification factor is a parameter that can amplify the mean square error. In some cases, when a user draws two different hand-drawn graphs (assuming one is a quadratic curve and the other is a non-quadratic curve), the deviation between the hand-drawn graph and the quadratic curve is calculated by S2262. The two values obtained are very small, making it impossible to distinguish which value is based on the drawn quadratic curve and which is based on the drawn non-quadratic curve. This ultimately leads to the user's drawn quadratic curve being identified as a non-quadratic curve, or vice versa, resulting in inaccurate identification results.
[0161] To avoid the above situation, this application embodiment uses an amplification factor to amplify the degree of deviation between the hand-drawn graphic and the quadratic curve when calculating the degree of deviation, making it easier to distinguish which hand-drawn graphic the calculated degree of deviation between the hand-drawn graphic and the quadratic curve is based on, thus making the recognition result more accurate.
[0162] In this embodiment of the application, the magnification factor can be determined based on the following formula:
[0163]
[0164] Where sqratio represents the scaling factor, c1 represents the difference between the maximum and minimum values in the first type of coordinate system, and c2 represents the difference between the maximum and minimum values in the second type of coordinate system.
[0165] S22622. Based on the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation, the gradient of each coordinate in the first coordinate set, the total number of coordinates in the first coordinate set, and the expansion coefficient, the degree of deviation between the hand-drawn graphic and the quadratic curve is obtained.
[0166] For example, the mean square error between the coordinates of the first coordinate set and the coordinates of the fitted curve (first equation) can be calculated based on the following formula, which can characterize the degree of deviation between the hand-drawn graph and the quadratic curve:
[0167]
[0168] Where MSE represents the mean square error between the coordinates of the first coordinate set and the coordinates in the fitted curve, err i Let F(i) represent the error value of any coordinate in the first coordinate set relative to the fitted curve, and let F(i) represent the value of any coordinate in the first coordinate set in the bivariate function corresponding to the first equation. i Let represent the gradient of any coordinate in the first coordinate set, n be the total number of coordinates in the first coordinate set, and sqratio represent the scaling factor.
[0169] It should be noted that e in the embodiments of this application 3( 1- sqratio) This is for illustrative purposes only and does not constitute a limitation on MSE. For example, in some embodiments, its form may also be e. (1-sqratio) However, the embodiments in this application do not limit this.
[0170] In this embodiment, the amplification factor can be determined based on the maximum and minimum values in the first type of coordinates and the maximum and minimum values in the second type of coordinates. Based on the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation, the gradient of each coordinate in the first coordinate set, the total number of coordinates in the first coordinate set, and the amplification factor, the degree of deviation between the hand-drawn graphic and the quadratic curve can be obtained. This amplifies the numerical value of the degree of deviation between the hand-drawn graphic and the quadratic curve, making the final result of identifying whether the hand-drawn graphic is a quadratic curve more accurate.
[0171] In some embodiments, the degree of similarity between the coordinates of the first coordinate set and the conic section is obtained through the following steps:
[0172] S2263. Based on the first coordinate set and the first equation, determine the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation, and determine the gradient of each coordinate in the first coordinate set.
[0173] It should be understood that the implementation process of S2263 is the same as that of S2261, and will not be repeated here.
[0174] S2264. Based on the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation, and the gradient of each coordinate in the first coordinate set, determine multiple initial error values, including the error value of each coordinate in the first coordinate set relative to the fitted curve.
[0175] For example, each coordinate in the first coordinate set can be substituted into the following formula to determine multiple initial error values:
[0176]
[0177] Among them, err i Let F(i) represent the error value of any coordinate in the first coordinate set relative to the fitted curve, and let F(i) represent the value of any coordinate in the first coordinate set in the bivariate function corresponding to the first equation. i This represents the gradient of any coordinate in the first coordinate set. It should be noted that the method for calculating the error value described above is merely illustrative and should not be construed as limiting the scope of the embodiments in this application.
[0178] S2265. Based on multiple initial error values, determine multiple target error values, where each target error value is less than a second threshold.
[0179] It should be understood that multiple target error values are error values among multiple initial error values that are less than the second threshold. In other words, the number of multiple target error values is less than or equal to the number of multiple initial error values.
[0180] In this embodiment of the application, after determining multiple initial error values in S2264, each initial error value is compared with a second threshold. If the initial error value is less than the second threshold, then the initial error value is taken as the target error value, thereby obtaining multiple target error values.
[0181] In this embodiment, a pre-configured second threshold is used to measure the degree of closeness between the coordinates of the first coordinate set and the quadratic curve. The coordinates of the first coordinate set corresponding to the target error value that is less than the second threshold among multiple initial error values are closer to the quadratic curve than the coordinates of the first coordinate set corresponding to the error value that is greater than or equal to the second threshold among multiple initial error values.
[0182] In this embodiment of the application, the second threshold may be a value obtained in advance based on test data, and the specific value of the second threshold is not limited in this embodiment of the application.
[0183] S2266. Based on multiple initial error values and multiple target error values, determine the degree of closeness between the coordinates of the first coordinate set and the quadratic curve.
[0184] In this embodiment of the application, determining the closeness between the coordinates of the first coordinate set and the quadratic curve includes determining the ratio of multiple target error values to multiple initial error values as the closeness between the coordinates of the first coordinate set and the coordinates of the quadratic curve. For example, the multiple initial error values can be represented as {err1, err2, err3, err4, err5}, and the multiple target error values can be represented as {err1, err3, err4, err5}. Then, the determined closeness between the coordinates of the first coordinate set and the quadratic curve is the ratio of the number of target error values to the number of initial error values, i.e., 4 / 5 = 0.8.
[0185] In this embodiment, based on the obtained first coordinate set, the value of each coordinate in the first coordinate set in the corresponding bivariate function of the first equation is determined by fitting the first equation, and the gradient of each coordinate in the first coordinate set is also determined. Then, based on the value of each coordinate in the first coordinate set in the corresponding bivariate function of the first equation and the gradient of each coordinate in the first coordinate set, multiple initial error values are determined. Without obtaining the precise coordinates of the quadratic curve or the fitted curve, the error value can be accurately calculated. Moreover, in this embodiment, each of the multiple target error values is less than a second threshold. The second threshold can measure the degree of closeness between the coordinates of the first coordinate set and the quadratic curve. That is, the coordinates of the first coordinate set corresponding to the target error value are closer to the quadratic curve. By using multiple initial error values and multiple target error values, the degree of closeness between the coordinates of the first coordinate set and the quadratic curve can be determined more accurately.
[0186] In some embodiments, determining a plurality of initial error values includes the following steps:
[0187] S22641. Determine the expansion coefficient based on the maximum and minimum values in the first type of coordinates and the maximum and minimum values in the second type of coordinates.
[0188] It should be understood that the amplification factor is a parameter that can amplify the initial error value. After multiple initial error values are determined by S2264, if the values of these multiple initial error values are too small, resulting in the values of these multiple initial error values being too close, then when executing S2265, it is impossible to confirm which initial error value is less than the second threshold. Therefore, it is impossible to determine multiple target error values, or the number of determined multiple target error values deviates too much from the number of true target error values. This leads to inaccurate determination of the closeness between the coordinates of the first coordinate set and the quadratic curve based on multiple initial error values and multiple target error values, ultimately resulting in inaccurate recognition results for whether the hand-drawn graphic is a quadratic curve.
[0189] To avoid the above situation, the embodiments of this application use an expansion factor to expand the multiple initial error values when calculating multiple initial error values, so as to accurately determine the number of target error values and make the identification results more accurate.
[0190] The implementation process of this embodiment is the same as that of S22621, and will not be described again here.
[0191] S22642. Based on the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation, the gradient and amplification coefficient of each coordinate in the first coordinate set, determine multiple initial error values.
[0192] In this embodiment of the application, each coordinate in the first coordinate set can be substituted into the following formula to determine multiple initial error values:
[0193]
[0194] Among them, err i Let F(i) represent the error value of any coordinate in the first coordinate set relative to the fitted curve, and let F(i) represent the value of any coordinate in the first coordinate set in the bivariate function corresponding to the first equation. i sqratio represents the gradient of any coordinate in the first coordinate set.
[0195] It should be noted that e in the embodiments of this application (1-sqratio) This is for illustrative purposes only and does not constitute a limitation on MSE. For example, in some embodiments, its form may also be e. 2(1-sqratio) However, the embodiments in this application do not limit this.
[0196] In this embodiment, the amplification factor can be determined based on the maximum and minimum values in the first type of coordinates and the maximum and minimum values in the second type of coordinates. Based on the value of each coordinate in the first coordinate set in the bivariate function corresponding to the first equation, the gradient of each coordinate in the first coordinate set and the amplification factor, multiple initial error values can be determined, so that multiple initial error values can be accurately determined.
[0197] In some embodiments, obtaining the average change in coordinates of the first coordinate set includes the following steps:
[0198] S2267. Based on the first coordinate set and the first equation, determine the slope value and gradient of each coordinate in the first coordinate set.
[0199] In this embodiment of the application, the process of determining the slope value of each coordinate in the first coordinate set is as follows:
[0200] The slope value of each coordinate is the ratio of the difference between the second-type coordinates of adjacent coordinates to the difference between the first-type coordinates of adjacent coordinates. For example, the first coordinate set is {(0,0), (1,0), ..., (M-2,0), (M-1,0)}. The first value of each coordinate is considered as the first-type coordinate, and the second value of each coordinate is considered as the second-type coordinate. The slope value of coordinate (0,0) is the difference between the second-type coordinate 0 and the second-type coordinate 0 of coordinate (1,0) and the difference between the first-type coordinate 1 and the second-type coordinate 0 of coordinate (1,0).
[0201] The implementation process of determining the gradient of each coordinate in the first coordinate set based on the first coordinate set and the first equation in this embodiment has been described in other embodiments and will not be repeated here.
[0202] S2268. Based on the slope value of each coordinate, determine the first angle between each coordinate in the tangent direction and the horizontal axis of the device coordinate system.
[0203] It should be understood that the coordinates of the first coordinate set are generated based on the device coordinate system. The device coordinate system is also known as the screen coordinate system or pixel coordinate system. It is mainly used for defining pixels on the surface of a specific computer graphics display device. In most cases, each specific display device has a separate coordinate system. Taking a capacitive touchscreen display device with M×N capacitive sensing points as an example, the origin of the coordinate system is the capacitive sensing point in the first row and first column, the positive direction of the X-axis is the direction from the first column of capacitive sensing points to the Mth column of capacitive sensing points, and the positive direction of the Y-axis is the direction from the first row of capacitive sensing points to the Nth row of capacitive sensing points.
[0204] In this embodiment of the application, the slope value of each coordinate in the first coordinate set can be substituted into the following formula to determine the first angle between each coordinate in the tangent direction and the horizontal axis of the device coordinate system:
[0205] θ1 i =arctanK i .
[0206] Where, θ1 i K represents the first angle between any coordinate in the first coordinate set and the x-axis of the device coordinate system in the tangent direction. i This represents the slope value of any coordinate in the first coordinate set.
[0207] S2269. Based on the gradient of each coordinate, determine the second angle between each coordinate in the gradient direction and the horizontal axis of the device coordinate system.
[0208] In this embodiment, the gradient of each coordinate in the first coordinate system can be substituted into the following formula to determine the second angle between the gradient direction and the horizontal axis of the device coordinate system for each coordinate:
[0209]
[0210] Where, θ2 i Fx represents the second angle between any coordinate in the first coordinate set and the gradient direction and the x-axis of the device coordinate system. i Fy represents the value of the partial derivative of the bivariate function corresponding to the first equation in the gradient of any coordinate in the first coordinate system with respect to x. i Let y be the partial derivative of the bivariate function corresponding to the first equation in the gradient of any coordinate in the first coordinate system with respect to y.
[0211] S22610. Perform calculations on the first included angle and the second included angle to obtain multiple slope changes, including the slope changes of each coordinate in the first coordinate set in the tangent direction.
[0212] The process of obtaining the changes in multiple slopes can be as follows: For example, first, the first included angle θ1 i The second included angle θ2 i Transform into The values within the range are then substituted into the following formula for each first included angle and each second included angle to obtain the changes in multiple slopes:
[0213]
[0214] Among them, a i It represents the change in the tangent direction of any coordinate in the first coordinate set.
[0215] S22611. Based on the changes in multiple slopes and the total number of coordinates in the first coordinate set, determine the average change in the coordinates of the first coordinate set.
[0216] In this embodiment, the average change of coordinates in the first coordinate set is determined based on the changes in multiple slopes and the total number of coordinates in the first coordinate set, which can improve the accuracy of the determined average change of coordinates in the first coordinate set.
[0217] It should be understood that the similarity between a hand-drawn graphic and a quadratic curve includes not only the degree of deviation between the hand-drawn graphic and the quadratic curve, the closeness between the coordinates of the first coordinate set and the coordinates of the quadratic curve, and the average change of the coordinates of the first coordinate set, but also the degree of deviation between the change of each coordinate in the first coordinate set and the average change.
[0218] In some embodiments, the deviation of the change in each coordinate in the first coordinate set from the average change is achieved through the following steps:
[0219] S22612. Based on the first coordinate set and the first equation, determine the slope value and gradient of each coordinate in the first coordinate set.
[0220] The implementation process of this embodiment is the same as that of S2267, and will not be repeated here.
[0221] S22613. Based on the slope value of each coordinate, determine the first angle between each coordinate in the tangent direction and the horizontal axis of the device coordinate system.
[0222] The implementation process of this embodiment is the same as that of S2268, and will not be repeated here.
[0223] S22614. Based on the gradient of each coordinate, determine the second angle between each coordinate in the gradient direction and the horizontal axis of the device coordinate system.
[0224] The implementation process of this embodiment is the same as that of S2269, and will not be repeated here.
[0225] S22615. Perform calculations on the first included angle and the second included angle to obtain multiple slope changes, including the slope changes of each coordinate in the first coordinate set in the tangent direction.
[0226] The implementation process of this embodiment is the same as that of S22610, and will not be repeated here.
[0227] S22616. Based on the changes in multiple slopes and the total number of coordinates in the first coordinate set, determine the average change in the coordinates of the first coordinate set.
[0228] The implementation process of this embodiment is the same as that of S2211, and will not be repeated here.
[0229] S22617. Based on the changes in multiple slopes and the average change in the coordinates of the first coordinate set, determine the degree of deviation between the change in each coordinate in the first coordinate set and the average change.
[0230] In this embodiment of the application, the degree of deviation between the change in each coordinate in the first coordinate set and the average change can be determined based on the following formula:
[0231]
[0232] Among them, s 2 a represents the degree of deviation of the change in each coordinate in the first coordinate set from the average change. i This represents the change in any coordinate in the first coordinate set along the tangent direction. represents the average change in coordinates of the first coordinate set, and n represents the total number of coordinates in the first coordinate set.
[0233] In this embodiment, based on the changes in multiple slopes and the average change in coordinates of the first coordinate set, the deviation of the change in each coordinate in the first coordinate set from the average change can be determined, thereby improving the accuracy of the determined deviation of the change in each coordinate in the first coordinate set from the average change.
[0234] In the following embodiments, the following steps are used to determine whether a hand-drawn graphic is a quadratic curve.
[0235] S231. Based on the target characteristics, determine the probability that the hand-drawn graphic belongs to a quadratic curve.
[0236] In this embodiment, the target features can be input into a classification model for processing. The classification model outputs a probability, which refers to the probability that the hand-drawn graphic belongs to a quadratic curve. For example, the classification model can be a binary classification model, such as a support vector machine.
[0237] S232. If the probability that a hand-drawn graphic belongs to a quadratic curve is greater than the third threshold, then the hand-drawn graphic is determined to be a quadratic curve.
[0238] It should be understood that the third threshold is a pre-set value. The larger the pre-set third threshold, the smaller the error between the identified hand-drawn graphic and the quadratic curve; the smaller the pre-set third threshold, the larger the error between the identified hand-drawn graphic and the quadratic curve. For example, if the pre-set third threshold is 0.8, then if the probability that the hand-drawn graphic belongs to a quadratic curve is greater than 0.8 (e.g., 0.9), then the hand-drawn graphic is determined to be a quadratic curve.
[0239] S233. If the probability that a hand-drawn graphic belongs to a quadratic curve is less than or equal to the third threshold, then the hand-drawn graphic is determined not to be a quadratic curve.
[0240] For example, if the pre-set third threshold is 0.8, then if the probability that the hand-drawn graphic belongs to a quadratic curve is less than or equal to 0.8, then the hand-drawn graphic is determined not to be a quadratic curve.
[0241] In this embodiment, based on the target features, the probability that a hand-drawn graphic belongs to a quadratic curve is determined. If the probability that a hand-drawn graphic belongs to a quadratic curve is greater than a third threshold, the hand-drawn graphic is determined to be a quadratic curve. If the probability that a hand-drawn graphic belongs to a quadratic curve is less than or equal to the third threshold, the hand-drawn graphic is determined not to be a quadratic curve. This method can accurately determine whether a hand-drawn graphic is a quadratic curve.
[0242] In some embodiments, the training method for the classification model can be executed by an electronic device or server, by a processor in the electronic device or server, or by a chip in the electronic device or server; this application embodiment does not impose any limitations. Specifically, the training method for the classification model includes the following steps:
[0243] S31. Select training data, which includes first-class training data and second-class training data.
[0244] The first type of training data includes the probability that the coordinates of the hand-drawn graphic lie on a quadratic curve (based on a coordinate set where the graphic is a quadratic curve), the similarity between the graphic and the curve, and a first label for this type of data. The second type of training data includes the probability that the coordinates of the hand-drawn graphic lie on a quadratic curve (based on a coordinate set where the graphic is not a quadratic curve), the similarity between the graphic and the curve, and a second label for this type of data. Embodiments of this application can use commonly used annotation tools (such as labelimg, the NLP annotation tool BRAT) to annotate the first and second types of training data. For example, the first label can be "1", and the second label can be "-1".
[0245] S32. Train the classification model based on the training data until the classification model converges.
[0246] The classification models in this application embodiment may include logistic regression models, Naive Bayes models, decision tree models, support vector machine models, random forest models, gradient boosting tree models, etc. This application embodiment does not limit the type of classification model.
[0247] It should be understood that when training a classification model, the first and second types of training data are first input into the initial classification model to obtain the training analysis results of the initial classification model.
[0248] The global error of this training round is calculated based on the training analysis results and the standard analysis results. The training analysis results are the calculated labels obtained after inputting the training data into the classification model, while the standard analysis results are the first and second labels pre-labeled on the training data. The global error of this training round is calculated based on each training analysis result and the corresponding standard analysis result, and it is determined whether the global error meets a preset condition, such as whether the global error is less than 5%. If the global error does not meet the preset condition, the model parameters of the classification model are adjusted, and the adjusted classification model is determined as the initial classification model. Here, the preset condition can be determined during the training of the classification model. For example, the preset condition can be set as the global error being less than a specific threshold, which can be a percentage value. The smaller the specific threshold, the more stable the classification model obtained after training, and the higher the accuracy of the recognition results.
[0249] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0250] Figure 3This is an exemplary block diagram of a hand-drawn graphic recognition device 400 provided in this application embodiment. The hand-drawn graphic recognition device 400 includes a processing unit 41, which is configured to perform the following operations:
[0251] Obtain the first coordinate set of the hand-drawn graphic;
[0252] The first coordinate set is fitted to obtain the first equation, which is used to characterize the fitted quadratic curve.
[0253] Based on the first coordinate set and the first equation, the similarity between the hand-drawn graphic and the quadratic curve is obtained;
[0254] Based on the similarity between the hand-drawn figure and the quadratic curve, determine whether the hand-drawn figure is a quadratic curve.
[0255] It should be understood that the processing unit 41 can be used to perform various steps in the hand-drawn graphic recognition method in any of the above embodiments. For a detailed description, please refer to the relevant description above, which will not be repeated here.
[0256] It should be understood that the hand-drawn graphic recognition device 400 here is embodied in the form of a functional unit. The term "unit" here may refer to application-specific integrated circuits (ASICs), electronic circuits, processors (e.g., shared processors, proprietary processors, or group processors) and memory for executing one or more software or firmware programs, integrated logic circuits, and / or other suitable components that support the described functions.
[0257] Figure 4 This is a schematic structural diagram of the electronic device 500 provided in an embodiment of this application. The electronic device 500 is used to execute the corresponding steps and / or processes in the above method embodiments.
[0258] The electronic device 500 includes a processor 501 and a memory 502. The processor 501 and memory 502 communicate with each other via an internal connection. The processor 501 can implement the functions of the processing unit 41 in various possible implementations of the hand-drawn drawing recognition device 400. The memory 502 is used to store instructions, and the processor 501 is used to execute the instructions stored in the memory 502. In other words, the processor 501 can call these stored instructions to implement the functions of the processing unit 41 in the hand-drawn drawing recognition device.
[0259] Optionally, the memory 502 may include read-only memory and random access memory, and provide instructions and data to the processor. A portion of the memory may also include non-volatile random access memory. For example, the memory may also store device type information. The processor 501 may be used to execute instructions stored in the memory, and when the processor 501 executes instructions stored in the memory, the processor 501 is used to perform various steps and / or processes of the embodiments of the above-described hand-drawn graphic recognition method.
[0260] It should be understood that, in the embodiments of this application, the processor of the above-described device can be a central processing unit (CPU), which can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0261] In implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software. The steps of the method disclosed in the embodiments of this application can be directly manifested as execution by a hardware processor, or as a combination of hardware and software units within the processor. The software units can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory, and the processor executes the instructions in the memory, combining them with its hardware to complete the steps of the above method. To avoid repetition, detailed descriptions are omitted here.
[0262] This application provides a computer program product that, when run on an electronic device, causes the electronic device to execute the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar to those of the related embodiments described above, and will not be repeated here.
[0263] This application provides a readable storage medium containing computer instructions that, when executed by an electronic device, cause the electronic device to perform the technical solutions described in the above embodiments. The implementation principle and technical effects are similar and will not be repeated here.
[0264] This application provides a chip comprising: a memory for storing instructions; and a processor for retrieving and executing the instructions from the memory, causing an electronic device equipped with the chip to perform the technical solutions described in the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0265] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., high-density digital video discs (DVDs)), or semiconductor media (e.g., solid-state disks (SSDs)).
[0266] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0267] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be found in the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0268] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0269] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0270] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0271] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0272] The same or similar parts between the various embodiments in this application can be referred to mutually. In the various embodiments of this application, and in the various implementation methods / methods / implementations within each embodiment, unless otherwise specified or logically conflicting, the terminology and / or descriptions between different embodiments and between the various implementation methods / methods / implementations within each embodiment are consistent and can be mutually referenced. The technical features in different embodiments and the various implementation methods / methods / implementations within each embodiment can be combined according to their inherent logical relationships to form new embodiments, implementation methods, methods, or implementation approaches. The above-described embodiments of this application do not constitute a limitation on the scope of protection of this application.
[0273] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of protection of the claims. In conclusion, the above description is merely a preferred embodiment of the technical solution of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method of recognizing a hand-drawn figure, characterized by, The method comprises: obtaining a first coordinate set of a hand-drawn figure; obtaining a target feature of the hand-drawn figure according to the first coordinate set, the target feature comprising a probability that coordinates of the first coordinate set are located on a quadratic curve and a similarity between the hand-drawn figure and the quadratic curve; determining whether the hand-drawn figure is the quadratic curve according to the target feature. The target feature comprises the probability that coordinates of the first coordinate set are located on a quadratic curve, and the obtaining of the target feature of the hand-drawn figure according to the first coordinate set comprises: performing sampling processing on the first coordinate set to obtain a plurality of first candidate sampling points; performing screening processing on the plurality of first candidate sampling points to obtain a plurality of second candidate sampling points, each of the plurality of second candidate sampling points forming a plurality of pairs of edges, and the plurality of pairs of edges being a plurality of pairs of non-parallel edges; obtaining a plurality of target sampling points based on the plurality of second candidate sampling points, the plurality of target sampling points being points located on the quadratic curve; obtaining the probability that coordinates of the first coordinate set are located on the quadratic curve according to the plurality of second candidate sampling points and the plurality of target sampling points.
2. The identification method according to claim 1, characterized in that, Each of the plurality of second candidate sampling points comprises six sampling points, each of the plurality of second candidate sampling points forms at least three pairs of non-parallel edges, and the screening processing on the plurality of second candidate sampling points to obtain the plurality of target sampling points comprises: determining a first intersection point, a second intersection point and a third intersection point corresponding to the three pairs of non-parallel edges based on the three pairs of non-parallel edges; determining distances between the first intersection point and the second intersection point, between the second intersection point and the third intersection point, and between the first intersection point and the third intersection point based on coordinates of the first intersection point, coordinates of the second intersection point and coordinates of the third intersection point, and performing sorting processing to obtain a first distance, a second distance and a third distance, the first distance being smaller than the second distance, and the second distance being smaller than the third distance; if a ratio of a sum of the first distance and the second distance to the third distance is smaller than a first threshold value, determining that the six sampling points are a group of target sampling points in the plurality of target sampling points, so as to determine the plurality of target sampling points.
3. The identification method according to claim 1, characterized in that, The target feature comprises the similarity between the hand-drawn figure and the quadratic curve, and the obtaining of the target feature of the hand-drawn figure according to the first coordinate set comprises: performing fitting processing on the first coordinate set to obtain a first equation, the first equation being used to represent a fitted quadratic curve; obtaining the similarity between the hand-drawn figure and the quadratic curve based on the first coordinate set and the first equation, the similarity between the hand-drawn figure and the quadratic curve comprising at least one of a deviation degree between the hand-drawn figure and the quadratic curve, a closeness between coordinates of the first coordinate set and coordinates of the quadratic curve, and an average variation of coordinates of the first coordinate set.
4. The identification method according to claim 3, characterized in that, The similarity between the hand-drawn figure and the quadratic curve comprises the deviation degree between the hand-drawn figure and the quadratic curve, and the obtaining of the similarity between the hand-drawn figure and the quadratic curve based on the first coordinate set and the first equation comprises: determining a value of each coordinate in the first coordinate set in a binary function corresponding to the first equation and a gradient of each coordinate in the first coordinate set according to the first coordinate set and the first equation; calculating a first ratio value according to the value of each coordinate in the first coordinate set in the binary function corresponding to the first equation and the gradient of each coordinate in the first coordinate set, the first ratio value being a ratio of an absolute value of the value of each coordinate in the first coordinate set in the binary function corresponding to the first equation to an absolute value of the gradient of each coordinate in the first coordinate set; calculating an average value of the first ratio value according to the first ratio value and a total number of coordinates in the first coordinate set, and taking the average value of the first ratio value as a degree of deviation of the hand-drawn figure from the conic curve.
5. The identification method according to claim 3, characterized in that, The similarity of the hand-drawn figure to the conic curve includes a closeness of the coordinates in the first coordinate set to coordinates of the conic curve, the coordinates in the first coordinate set including first-type coordinates and second-type coordinates, and the similarity of the hand-drawn figure to the conic curve being obtained based on the first coordinate set and the first equation, including: determining a value of each coordinate in the first coordinate set in a binary function corresponding to the first equation and a gradient of each coordinate in the first coordinate set according to the first coordinate set and the first equation; determining an amplification coefficient based on a maximum value and a minimum value in the first-type coordinates and a maximum value and a minimum value in the second-type coordinates; determining a plurality of initial error values based on the value of each coordinate in the first coordinate set in the binary function corresponding to the first equation, the gradient of each coordinate in the first coordinate set and the amplification coefficient, the plurality of initial error values including error values of each coordinate in the first coordinate set relative to a fitting curve; determining a plurality of target error values based on the plurality of initial error values, each target error value in the plurality of target error values being less than a second threshold value; determining a closeness of the coordinates in the first coordinate set to the coordinates of the conic curve as a ratio of the plurality of target error values to the plurality of initial error values.
6. The identification method according to claim 3, characterized in that, The similarity of the hand-drawn figure to the conic curve includes an average variation amount of the coordinates in the first coordinate set, and the similarity of the hand-drawn figure to the conic curve is obtained based on the first coordinate set and the first equation, including: determining a slope value of each coordinate and a gradient of each coordinate in the first coordinate set based on the first coordinate set and the first equation; determining a first included angle between a tangent direction of each coordinate and a horizontal coordinate axis of a device coordinate system based on the slope value of each coordinate; determining a second included angle between a gradient direction of each coordinate and the horizontal coordinate axis of the device coordinate system based on the gradient of each coordinate; performing operation processing on the first included angle and the second included angle to obtain a plurality of slope variation amounts, the plurality of slope variation amounts including a slope variation amount of each coordinate in the first coordinate set in the tangent direction; and Determine an average variation amount of the coordinates of the first coordinate set based on the variation amount of the plurality of slopes and a total number of the coordinates of the first coordinate set.
7. The method according to any one of claims 1 to 6, characterized in that, The determining whether the hand-drawn figure is the conic curve based on the target features comprises: Determining a probability that the hand-drawn figure belongs to the conic curve based on the target features; In a case where the probability that the hand-drawn figure belongs to the conic curve is greater than a third threshold value, determining that the hand-drawn figure is the conic curve; In a case where the probability that the hand-drawn figure belongs to the conic curve is less than or equal to the third threshold value, determining that the hand-drawn figure is not the conic curve.
8. An apparatus for recognizing hand-drawn figures, characterized by The recognition device comprises a processing unit configured to: Obtain a first coordinate set of a hand-drawn figure; Obtain target features of the hand-drawn figure based on the first coordinate set, the target features comprising a probability that coordinates of the first coordinate set are on a conic curve and a similarity between the hand-drawn figure and the conic curve; Determine whether the hand-drawn figure is the conic curve based on the target features; The target features comprise the probability that the coordinates of the first coordinate set are on the conic curve, and the obtaining the target features of the hand-drawn figure based on the first coordinate set comprises: Perform sampling processing on the first coordinate set to obtain a plurality of first candidate sampling points; Perform screening processing on the plurality of first candidate sampling points to obtain a plurality of second candidate sampling points, each of the plurality of second candidate sampling points forming a plurality of pairs of edges, the plurality of pairs of edges being a plurality of pairs of non-parallel edges; Obtain a plurality of target sampling points based on the plurality of second candidate sampling points, the plurality of target sampling points being points on the conic curve; Obtain the probability that the coordinates of the first coordinate set are on the conic curve based on the plurality of second candidate sampling points and the plurality of target sampling points.
9. An electronic device, comprising: Comprise: One or more processors; One or more memories; The one or more memories store one or more computer programs, the one or more computer programs comprising instructions that, when executed by the one or more processors, cause the electronic device to perform the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Graph recognition processing method and device, storage medium and electronic equipment
CN113240774A
Method and device for adjusting hand-drawn graph, electronic equipment and medium
CN115601769A