Graphic recognition method and device, storage medium and electronic device
By obtaining and analyzing the graph screenshots and trajectory points on the operation interface, a more detailed graph category is identified, which solves the problem of low recognition accuracy caused by the single graphic recognition dimension in the prior art, and achieves more accurate graph recognition.
Patent Information
- Application Number
- CN202111124598.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-24
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2041-09-24
AI Technical Summary
In the prior art, the graphic recognition dimensions are single, resulting in low recognition accuracy and the inability to accurately identify some graphics drawn by users.
By obtaining screenshots of candidate graphics drawn on the operation interface and drawing a trajectory point set, the first-level graphic category is determined based on the screenshot, and the second-level graphic category is identified from the subcategory in combination with the drawn trajectory point set, and the fitted target figure is displayed in the operation interface.
The accuracy of the graphic recognition results is improved and the problem of low recognition accuracy caused by a single recognition dimension is overcome.
Smart Images

Figure CN113869308B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular, to a graphic recognition method, an apparatus, a storage medium, and an electronic device. Background Art
[0002] Nowadays, many designers have started to directly use the drawing software in a tablet computer to complete drawing, which is more conducive to designers completing drawing tasks anytime and anywhere. However, the number of graphics supported in the canvas function provided by existing drawing software is too small. Among them, different from the operation habits of most users, many graphics only support single-dimensional recognition settings.
[0003] That is to say, the graphic recognition method provided by the prior art has the problem that the recognition dimension is relatively single, so that some graphics drawn by users cannot be accurately recognized.
[0004] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention
[0005] Embodiments of the present invention provide a graphic recognition method, an apparatus, a storage medium, and an electronic device to at least solve the technical problem of low recognition accuracy caused by a single recognition dimension.
[0006] According to one aspect of the embodiments of the present invention, a graphic recognition method is provided, including: obtaining a screenshot of a candidate graphic currently drawn on an operation interface, and a set of drawing trajectory points of the candidate graphic; determining a first-level graphic category to which the candidate graphic belongs based on the screenshot; identifying a second-level graphic category from sub-categories of the first-level graphic category based on the set of drawing trajectory points; and displaying a target graphic fitted according to the second-level graphic category in the operation interface.
[0007] According to another aspect of the embodiments of the present invention, a graphic recognition apparatus is further provided, including: an obtaining unit, configured to obtain a screenshot of a candidate graphic currently drawn on an operation interface, and a set of drawing trajectory points of the candidate graphic; a determining unit, configured to determine a first-level graphic category to which the candidate graphic belongs based on the screenshot; an identifying unit, configured to identify a second-level graphic category from sub-categories of the first-level graphic category based on the set of drawing trajectory points; and a displaying unit, configured to display a target graphic fitted according to the second-level graphic category in the operation interface.
[0008] According to still another aspect of the embodiments of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program is configured to execute the above graphic recognition method when running.
[0009] According to another aspect of the embodiments of the present invention, an electronic device is further provided, which includes a memory and a processor. A computer program is stored in the memory, and the processor is configured to execute the above-mentioned graphic recognition method through the computer program.
[0010] In the embodiments of the present invention, a screenshot of a candidate graphic drawn on the operation interface currently and a set of drawing trajectory points of the candidate graphic are obtained. After determining the first-level graphic category to which the candidate graphic belongs based on the screenshot, the set of drawing trajectory points is further analyzed in combination to further determine the second-level graphic category corresponding to the candidate graphic, so as to fit the target graphic to be displayed based on the second-level graphic category. That is to say, making different sub-categories based on the set of drawing trajectory points on the operation interface is beneficial to more accurately identify the drawn graphic, achieving the effect of improving the accuracy of the recognition result, and thus overcoming the problem of low accuracy of the graphic recognition result in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:
[0012] Figure 1 is a flowchart of an optional graphic recognition method according to an embodiment of the present invention;
[0013] Figure 2 is a schematic diagram of the effect of an optional graphic recognition method according to an embodiment of the present invention;
[0014] Figure 3 is a schematic diagram of the effect of another optional graphic recognition method according to an embodiment of the present invention;
[0015] Figure 4 is a schematic structural diagram of an optional graphic recognition device according to an embodiment of the present invention;
[0016] Figure 5 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0017] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0018] It should be noted that the terms "first", "second", etc. in the description, claims and above-mentioned drawings of the present invention are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily limit to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0019] According to one aspect of the embodiments of the present invention, a graphic recognition method is provided, as Figure 1 shown, the method includes:
[0020] S102, obtaining a screenshot of a candidate graphic drawn on the operation interface currently, and a set of drawing trajectory points of the candidate graphic;
[0021] S104, determining a first-level graphic category to which the candidate graphic belongs based on the screenshot;
[0022] S106, identifying a second-level graphic category from sub-categories of the first-level graphic category based on the set of drawing trajectory points;
[0023] S108, displaying a target graphic fitted according to the second-level graphic category on the operation interface.
[0024] Optionally, in this embodiment, the above graphic recognition method can be but is not limited to being applied in a graphic drawing tool software application. When a user draws a graphic on a canvas provided by the tool software, an image of the currently drawn graphic (which can be called a screenshot) can be intercepted, and a set of drawing trajectory points generated during the drawing process can be retained. A classification model is used to identify and classify the category of the graphic in the screenshot. After confirming the category, further analysis is carried out in combination with the set of trajectory points to determine specific graphic parameters corresponding to the graphic, and the generated graphic is displayed on the canvas according to the specific parameters.
[0025] It should be noted that the above first-level graphic category can be but is not limited to being a major category of graphic classification, such as: straight line category, broken line category, rectangle category, polygon category, circle category, ellipse category, arrowed category, etc. And the above second-level graphic category can be but is not limited to being a minor category of graphic classification. Taking the rectangle category as an example, it can include: parallelogram, square, rectangle, rhombus, etc. Here as an example, the second-level graphic category can also include but is not limited to: heart shape, five-pointed star, right-angled single-sided arrow, right-angled double-sided arrow, straight-line double-sided arrow, arc double-sided arrow, etc., and this embodiment does not make any limitation thereto.
[0026] Optionally, in this embodiment, the above classification model may but is not limited to adopt a lightweight neural network classification algorithm, which is mainly applied to mobile terminals and embedded devices for easy direct calling. For example, MobileNet_V2.
[0027] Through the embodiment provided by this application, when drawing a graph on the operation interface, a screenshot of the candidate graph to be drawn and its drawing trajectory point set can be obtained. The classification model is used to identify and classify the category of the candidate graph in the above screenshot. After confirming the first-level graph category, the drawing trajectory point set is further analyzed to further determine the second-level graph category corresponding to the candidate graph, so as to fit the target graph to be displayed based on the second-level graph category. That is to say, it is no longer limited to the recognition and classification results of the large categories for graph drawing, but the drawing trajectory point set will be combined to further refine the categories, which is beneficial to more accurately identify the drawn graph, achieving the effect of improving the accuracy of the recognition result, and further overcoming the problem of low accuracy of graph recognition results in the related art.
[0028] As an optional solution, determining the first-level graph category to which the candidate graph belongs based on the screenshot includes:
[0029] S1, using the classification model to classify the screenshot to obtain a classification result, where the classification model is a neural network model for identifying the category of the graph displayed in the screenshot;
[0030] S2, determining the first-level graph category according to the classification result.
[0031] Optionally, in this embodiment, the training preparation process of the above classification model may but is not limited to include the following: pre-annotating the sample data in advance to obtain sample graphs with classification labels; then preprocessing the above sample graphs, such as data cleaning and augmentation (equal-proportion scaling and filling, rotation, etc.). Further, in order to prevent uneven distribution of the categories of the sample graphs, the quantity statistics can be performed for each category, and each category is respectively expanded to 100,000 to establish a training data set, a test data set, and a validation data set (8:1:1).
[0032] The initial classification model is trained using the training data set obtained based on the above process until the preset training convergence condition is reached, and the model function that reaches the convergence condition currently is determined as the function in the classification model to be applied. Then, the screenshot is classified and recognized based on the classification model to determine the large category it belongs to. Here, the total number of large categories can be 11 categories, such as rectangles, circles, straight lines, etc.
[0033] Through the embodiments provided in this application, a classification model is used to initially classify the screenshots to initially screen the recognition results of the candidate graphics, so as to more quickly and efficiently determine the fine classification results subsequently, thereby achieving the purpose of improving the efficiency of graphic recognition.
[0034] As an alternative solution, using a classification model to classify the screenshots, the classification results obtained include:
[0035] S1, adjust the input size of the screenshot to the target size, where the size information of the target size includes: the display length of the screenshot, the display width of the screenshot, and the display color value of the screenshot;
[0036] S2, input the screenshot under the target size into the classification model to obtain the classification result, where the application format of the model framework used in the classification model is a format that allows to be called by a mobile device or an embedded device.
[0037] Optionally, in this embodiment, the classification algorithm adopted in the above classification model can but is not limited to adopting MobileNet_V2. MobileNet_V2 is a lightweight neural network classification algorithm, which is a network constructed based on depthwise separable convolution. It splits the standard convolution into two operations: depthwise convolution and pointwise convolution. Different from the standard convolution, for the standard convolution, its convolution kernel is used on all input channels, while depthwise convolution uses different convolution kernels for each input channel, that is, one convolution kernel corresponds to one input channel, so depthwise convolution is an operation at the depth level. And pointwise convolution is actually ordinary convolution, except that it uses a 1x1 convolution kernel.
[0038] In addition, MobileNetV2 is mainly applied to the mobile side. After the training is completed, the model is converted into a tflite model using the tensorflow framework. The model in tflite format can be directly called by mobile and embedded devices. Finally, the test accuracy rate can reach more than 99%, the model size is 607k, and the time taken to process a single image is about 200ms.
[0039] Optionally, in this embodiment, before the above screenshot is input into the classification model for classification, the size of the screenshot can but is not limited to be adjusted first to make it suitable for the data processing process inside the current classification model. For example, the target size can but is not limited to be set to 224*224*3, that is, 224 pixels for both length and width, and the color value is RGB.
[0040] Through the embodiments provided in this application, by pre-adjusting the size of the screenshot to make it suitable for the processing mode of the model framework in the classification model, the problem of inaccurate recognition caused by inconsistent sizes is avoided. Thus, the accuracy of the classification results of the classification model is improved.
[0041] As an alternative solution, identifying the second-level graphic category from the sub-categories of the first-level graphic category based on the drawn trajectory point set includes:
[0042] S1. Perform feature recognition on the drawn trajectory point set to obtain graphic fitting parameters;
[0043] S2. Determine the second-level graphic category from the sub-categories of the first-level graphic category according to the graphic fitting parameters.
[0044] Optionally, in this embodiment, the above graphic fitting parameters can be but are not limited to the parameters used to fit the drawn graphic. For example, when the four corner points of a quadrilateral are known, the quadrilateral can be drawn, and the coordinates of the four corner points can be used as the graphic fitting parameters (also called key parameters) of the quadrilateral. For another example, the graphic fitting parameters of a circle can include the center and radius, etc. The graphic fitting parameters of an ellipse can include the major and minor semi-axes, the center point, and the rotation angle. Here is an example, and this embodiment does not make any limitations in this regard. After determining the second-level graphic category based on the above graphic fitting parameters, the corresponding target graphic can be drawn based on the above graphic fitting parameters, and the drawing result can be referred to Figures 2 - 3 as shown.
[0045] For example, in the case where the first-level graphic category to which the candidate graphic belongs is identified as an ellipse based on the screenshot in the classification model, the least squares method is used to fit the drawn trajectory point set of the ellipse to obtain the information of the major and minor semi-axes, the center point, and the rotation angle of the fitted ellipse. Judge the ratio of the major and minor semi-axes, major axis: minor axis < 1.2, then judge that the graphic in the screenshot is a circle, and return the circle parameters, such as the center (center point), radius (the sum of the major and minor semi-axes divided by 2); major axis: minor axis is greater than or equal to 1.2, then judge that the graphic in the screenshot is an ellipse, and return the ellipse parameters, such as the major and minor semi-axes, the center point, and the rotation angle.
[0046] Specifically, the following examples are used for illustration:
[0047] 1. The recognition process of a rectangle can be as follows:
[0048] Finding the convex hull based on the drawn trajectory point set (the definition of the convex hull is as follows: a subset S (corresponding to a figure) of the plane is called "convex", where the convex hull trajectory refers to that in the trajectory point set, if and only if for any two points p, s ∈ S, the line segment ps completely belongs to S, thus obtaining the corner points of the convex hull. If the number of corner points is not equal to 4, an error is reported;
[0049] Obtaining the area area of the figure based on the corner points; obtaining the minimum bounding rectangle (rectangle center, length and width, rotation angle) of the figure based on the point set, and calculating the area minAreaRect_area of this rectangle; calculating the value rate of area / minAreaRect_area;
[0050] Calculating the number num of the four corners of the figure that are close to 90 degrees (80 - 100 degrees) based on the four corner points;
[0051] If rate > 0.7 and num > 2, it can be judged as a rectangle (rectangle / square). At the same time, calculate the aspect ratio of the bounding rectangle. If the aspect ratio of width to length belongs to (0.8, 1.2), it is a square, otherwise it is a rectangle; if rate < 0.9 and num = 0, it can be judged as a parallelogram; otherwise, an error is reported.
[0052] If it is determined as a square - like figure based on the figure fitting parameters, the side length is (length + width) / 2, the center point is the center point of the bounding rectangle, and the rotation angle is the rotation angle of the bounding rectangle; then draw a square on the operation interface.
[0053] If it is determined as a rectangle - like figure based on the figure fitting parameters, the length, width, center point, and rotation angle are the same as those of the minimum bounding rectangle; then draw a rectangle on the operation interface.
[0054] If it is determined as a parallelogram - like figure based on the figure fitting parameters, determine the exact position of the fourth corner point according to the first three corner points, calculate the rotation angle of the parallelogram, and convert to obtain the coordinates of the four corner points after rotation; connect the four corner points pairwise to draw the parallelogram.
[0055] II. The recognition process of the arc can be as follows:
[0056] Among them, the key parameters for recognizing this type of figure include: the first and last two points, and the arc control points.
[0057] Obtaining the first and last two points based on the drawn trajectory point set, calculating the point in the point set that is farthest from the line connecting the first and last two points, which is the farthest point of the arc, and obtaining the control points from the farthest point according to the Bezier curve formula; based on the positional relationships of the above - mentioned points, identifying the figure fitting parameters for the arc - like figure. Then draw the arc according to the positional coordinates of the above - mentioned points.
[0058] III. The recognition process of the line can be as follows:
[0059] Among them, the key parameters for identifying this type of graph include: the two intersection points of the straight line and the canvas.
[0060] According to the cv2.fitLine() function and the trajectory drawing point set, to fit the vector representation (cosk, sink) of the slope k of the straight line and the coordinates (x, y) of a point on the straight line;
[0061] According to the slope k, the coordinates of a point (x, y), and the size of the input graph, calculate the two intersection points of the straight line and the canvas boundary, and draw the straight line according to the intersection points, where the input graph size limits the canvas size to prevent the straight line from being drawn out of bounds.
[0062] IV. The recognition process of a circle can be as follows:
[0063] Use the least squares method to fit an ellipse according to the drawn trajectory point set to obtain its center point, the lengths of the major and minor axes, and the rotation angle, calculate the ratio of the major axis to the minor axis, if it belongs to the range of (0.8, 1.2), it is recorded as a circle, otherwise it is recorded as an ellipse.
[0064] The key parameters for subdivision recognition include: the center point, the major axis distance, the minor axis distance, and the rotation angle.
[0065] If it is determined to be an ellipse-like graph based on the graph fitting parameters, then draw an ellipse according to the center point, the lengths of the major and minor axes, and the rotation angle;
[0066] If it is determined to be a circle-like graph based on the graph fitting parameters, then determine the radius as (major axis + minor axis) / 4, and draw a circle according to the center point and the radius.
[0067] V. Triangle
[0068] Among them, the key parameters for identifying this type of graph include: three vertices.
[0069] Use the cv2.minEnclosingTriangle() function to obtain the best enclosing triangle of the graph, return the coordinates of the three vertices, and draw a triangle after connecting them pairwise.
[0070] VI. One-sided arrow of a straight line
[0071] Among them, the key parameters for identifying this type of graph include: the two points at the head and tail of the straight line, the position of the arrowhead vertex, and the direction of the single arrow.
[0072] Calculate the included angles of the vectors formed by every two points in the drawn trajectory point set; traverse the entire point set, and the point with the largest included angle is the arrowhead vertex. Save the point set between the starting point and the arrowhead vertex as the main trunk of the straight line, and the method of fitting the straight line can refer to the above straight line fitting process.
[0073] VII. One-sided arrow of an arc
[0074] Among them, the key parameters for identifying this type of graphic include: the two end points of the arc, the arc control points, the vertex position of the arrow, and the direction of the single arrow.
[0075] Calculate the included angle of the vectors formed by every two points in the drawn trajectory point set, traverse the entire point set, and the point with the largest included angle is the vertex of the arrow. Save the point set between the starting point and the vertex of the arrow as the main body of the arc. The method for fitting the arc can refer to the above arc fitting process.
[0076] Through the embodiments provided in this application, combined with the drawn trajectory point set, feature recognition is performed on the candidate graphics in the screenshot to determine the specific parameters for fitting this type of graphic, so as to accurately draw the target graphic of this type based on the specific parameters, and further ensure the accuracy of the graphic drawing result.
[0077] As an alternative solution, feature recognition is performed on the drawn trajectory point set, and the obtained graphic fitting parameters include:
[0078] S1. When identifying the convex hull trajectory from the drawn trajectory point set, obtain the graphic corner points of the convex hull trajectory;
[0079] S2. When the total number of the graphic corner points reaches N, determine the position coordinates of the graphic corner points as the graphic fitting parameters for fitting and generating an N-sided polygon graphic.
[0080] Optionally, in this embodiment, the value of N can be 4 or 5. Among them, when N = 4, the N-sided polygon can be a quadrilateral, and further determine whether it belongs to a square or a parallelogram according to its side length or included angle, etc. When N = 5, the N-sided polygon can be a pentagon or a pentagram, etc.
[0081] For example, taking the drawing of a rectangle as an example, find the convex hull according to the drawn trajectory point set. Among them, the above convex hull trajectory refers to that for any two points p, s ∈ S in the trajectory point set, the line segment ps completely belongs to S, so as to obtain the corner points of the convex hull. If the number of corner points is not equal to 4, an error is reported; if the number of corner points is equal to 4, further determine which type of quadrilateral it is.
[0082] For another example, taking the drawing of a pentagram as an example, the key parameters for identifying this type of graphic include: five vertices. Find and identify the convex hull trajectory (which can be simply referred to as the convex hull) in the drawn trajectory point set, obtain the graphic corner points. If the total number of the obtained graphic corner points is not five, an error is reported; if there are five corner points, determine the position coordinates of the above corner points as the graphic fitting parameters of the pentagram, and connect the lines pairwise based on the above position coordinates to draw the pentagram.
[0083] As an alternative solution, feature extraction is performed on the drawn trajectory point set, and the obtained graphic fitting parameters include:
[0084] S1. Determine the straight line fitted from the drawn trajectory point set as the center line;
[0085] S2. Fit the minimum circumscribed triangle of the candidate figure from the drawn trajectory point set;
[0086] S3. Determine the intersection points between the three side line segments corresponding to the minimum circumscribed triangle and the center line;
[0087] S4. Sort the distances between the midpoint positions of the three side line segments and the intersection points;
[0088] S5. Determine the side line segment corresponding to the minimum distance as the side line segment located at the top of the heart shape;
[0089] S6. Determine the heart shape direction parameter and heart shape size parameter calculated based on the side line segment located at the top of the heart shape as the figure fitting parameters for fitting and generating the heart shape-like figure.
[0090] It should be noted that the key parameters for identifying this type of figure include: the heart shape groove and the two points at the tail that determine the direction.
[0091] Fit a straight line according to the drawn trajectory point set, that is, fit the center line of the heart shape; fit the minimum circumscribed triangle of the figure according to the point set to obtain the coordinates of the three vertices of the triangle; obtain three side line segments from the three vertices, calculate the midpoints of the three side lines, calculate the intersection points of the three side lines and the center line, sort the distances between the three midpoints and the intersection points, and the side line corresponding to the smallest distance is the side line at the top of the heart shape. Among them, the above-mentioned minimum circumscribed triangle refers to the closed figure obtained by fitting the connection lines surrounding the trajectory point set.
[0092] According to the midpoint of the side line at the top of the heart shape and the vertex opposite the side line (the bottom of the heart shape), the connection line of the two points can determine the direction and size of the heart shape. Then, determine the above-mentioned heart shape direction parameter and heart shape size parameter as the figure fitting parameters of the heart shape-like figure, and draw the heart shape.
[0093] As an optional solution, perform feature extraction on the drawn trajectory point set, and the obtained figure fitting parameters include:
[0094] S1. Calculate the included angles between the vectors formed by any two points in the drawn trajectory point set to obtain multiple included angles;
[0095] S2. Traverse the drawn trajectory point set, and determine the point corresponding to the largest included angle among the multiple included angles as the arrowhead vertex;
[0096] S3. Determine the point set between the first position at the starting end of the trajectory and the arrowhead vertex as the right-angled main trunk;
[0097] S4. Determine the position coordinates of each point on the right-angled backbone and the position coordinates of the arrowhead vertex as the graphic fitting parameters for fitting and generating a right-angled single-sided arrow-like graphic.
[0098] It should be noted that the key parameters for identifying this type of graphic include: the two points at the head and tail of the right angle, the turning point, the position of the arrowhead vertex, and the direction of the single arrow.
[0099] Calculate the included angles of the vectors formed by each pair of points in the drawn trajectory point set; traverse the entire point set, and the point with the largest included angle is the arrowhead vertex. Save the point set between the starting point and the arrowhead vertex as the right-angled backbone. The method for fitting a right angle can refer to the above-mentioned right-angle fitting process. Then, determine the position coordinates of the above-mentioned starting point and arrowhead vertex as the graphic fitting parameters of the right-angled single-sided arrow, and draw this graphic.
[0100] Among them, the above-mentioned head and tail positions can be, but are not limited to, the positions of the two endpoints in the trajectory point set. Here, the head position and the tail position are relative, and their positions can be interchanged, and this type is not limited.
[0101] As an optional solution, perform feature extraction on the drawn trajectory point set, and the obtained graphic fitting parameters include:
[0102] S1. Obtain the first position coordinate of the head position located at the starting end of the trajectory and the second position coordinate of the tail position located at the end of the trajectory according to the drawn trajectory point set;
[0103] S2. Determine the position coordinates of the point with the farthest perpendicular distance from the connecting line in the drawn trajectory point set as the position coordinates of the farthest point of the arc. Among them, the connecting line is the connecting line between the first position coordinate and the second position coordinate. Determine the position coordinates of the point with the farthest distance from the connecting line between the first position coordinate and the second position coordinate in the drawn trajectory point set as the position coordinates of the turning point;
[0104] S3. Convert the position coordinates of the farthest point into the position coordinates of the control point;
[0105] S4. Determine the first position coordinate, the second position coordinate, and the position coordinates of the control point as the graphic fitting parameters for fitting and generating a polyline-like graphic.
[0106] Optionally, the shape of the Bezier curve is determined by the starting point, the ending point, and the control point. When the starting point and the ending point positions are determined, adjusting the position of the control point will obtain Bezier curves of different shapes. For example, a first-order Bezier curve has only a starting point and an ending point, without a control point. Higher-order Bezier curves can generate different curves, and the control point will be used to determine the curvature of the curve.
[0107] It should be noted that the key parameters for identifying this polyline-like graphic include: the two head and tail points, and the arc control point.
[0108] According to the drawn trajectory point set, obtain the coordinates of the first and last points (i.e., the first position coordinates corresponding to the first position and the second position coordinates corresponding to the last position), connect the first and last points, and calculate the point in the point set that is farthest from the vertical distance of the above connection line, which is the position coordinates of the farthest point on the arc. According to the Bezier curve formula, convert the position coordinates of the above farthest point into the position coordinates of the control points.
[0109] Then, fit a broken line according to the above first position coordinates, second position markers, and the position coordinates of the control points.
[0110] As an alternative solution, perform feature extraction on the drawn trajectory point set to obtain graphic fitting parameters including:
[0111] S1. Determine the candidate angle according to the first position coordinates, second position coordinates, and the position coordinates of the control points;
[0112] S2. Perform right-angle correction on the candidate angle to obtain the corrected point position coordinates;
[0113] S3. Determine the corrected point position coordinates as the graphic fitting parameters for fitting and generating a right-angle type graphic.
[0114] It should be noted that in this embodiment, the above right-angle correction may, but is not limited to, correcting the included angle between two lines to obtain a 90-degree right angle. For example, assuming that the candidate angle is an angle close to 90 degrees such as 89 degrees or 92 degrees, the right-angle correction can be completed through the above right-angle correction method. For example, taking one side between the first position coordinates and the position coordinates of the control points as a reference, or taking one side between the second position coordinates and the position coordinates of the control points as a reference, find the corresponding foot of the perpendicular and perpendicular line, and use the parallel line parallel to the ground and the perpendicular line perpendicular to the ground to complete the 90-degree right-angle correction.
[0115] As an alternative solution, before determining the candidate angle according to the first position coordinates, second position coordinates, and the position coordinates of the control points, it further includes:
[0116] S1. Perform line detection on the drawn trajectory point set to obtain the detection result;
[0117] S2. Merge multiple line segments in the detection result, and determine the two line segments with the largest length after merging as the right-angle sides;
[0118] S3. Determine the turning point based on the foot of the perpendicular of the right-angle side;
[0119] S4. Determine the first position coordinates and the second position coordinates in the direction extended in the opposite direction of the foot of the perpendicular along the right-angle side.
[0120] It should be noted that the above-mentioned right-angled sides are two mutually perpendicular sides, and the foot of the perpendicular is the turning point of the right angle. Therefore, after extending respectively in the opposite direction of the foot of the perpendicular (i.e., the direction opposite to the direction pointing to the foot of the perpendicular), the coordinates of the starting position and the ending position can be obtained.
[0121] As an alternative solution, after performing right-angle correction on the candidate angle to obtain the corrected point position coordinates, it further includes:
[0122] S1, counting the first number of points around the first position coordinate and the second number of points around the second position coordinate;
[0123] S2, determining the arrowhead vertex according to the first number of points and the second number of points;
[0124] S3, determining the corrected point position coordinates and the position coordinates of the arrowhead vertex as the graphic fitting parameters for fitting and generating a right-angled double-sided arrow-like graphic.
[0125] It should be noted that the key parameters for identifying this type of graphic include: the right-angle turning point, the two points at the head and tail of the right angle, and the arrowhead vertex.
[0126] In this embodiment, the Hough transform is performed on the graphic to detect line segments and merge the line segments; after merging, the two sides with the largest length are selected as the right-angled sides; the foot of the perpendicular is obtained according to the two right-angled sides to get the turning point; the intersection points of the right-angled side line segments extending in the opposite direction of the foot of the perpendicular and the border are the two points at the head and tail; the angles of the two right-angled sides are calculated according to the three-point coordinates of the two points at the head and tail and the turning point, and right-angle correction is performed according to the angles to obtain regular turning point coordinates; the number of black dots around the two points at the head and tail is counted, and the one with more dots is the arrowhead vertex; straight line segments are drawn according to the pairwise connection of the three points, and the out-of-bounds points exceeding the canvas are processed; the arrow is drawn according to the arrow position.
[0127] Among them, the number of points around the head and tail positions can be used, but is not limited to, representing the density of the points drawn in the area with the head position or the tail position as the center point and a predetermined length as the radius, so as to determine whether there is an arrowhead vertex.
[0128] As an alternative solution, feature extraction is performed on the drawn trajectory point set, and the graphic fitting parameters obtained include:
[0129] S1, when the drawn trajectory point set includes two subsets, calculating the lengths of two line segments based on the two subsets, and determining the line segment with the largest length among the two line segments as the arc main body;
[0130] S2, determining the arrowhead vertex according to the number of points around the two endpoints of the arc main body;
[0131] S3, determining the position coordinates of the two endpoints of the arc main body and the position coordinates of the arrowhead vertex as the graphic fitting parameters for fitting and generating an arc double-sided arrow-like graphic.
[0132] It should be noted that the key parameters for identifying this type of graphic include: three control points with directions, and the last control point is the arrow tip.
[0133] In this embodiment, the above graphic can be but is not limited to being defined as a two-stroke graphic, one stroke being the main arc and the other being the arrow. The trajectory points of the two strokes will be saved in files such as txt respectively. By calculating the lengths of the line segments of the two subsets of the point sets (that is, the two subsets in the drawing trajectory point set), the curve with the longer length is taken as the main arc of the arc. Then, according to the algorithm process of the above arc, three control points are calculated for the main arc of the arc; the arithmetic mean point of the arrow part is calculated, and the point with the shorter distance between the two end points of the arc and the arithmetic mean point of the arrow is the arrow tip. Among them, the number of surrounding points can be but is not limited to the circular area drawn with a certain radius centered on the points at the head and tail positions respectively, and is determined as the periodic number of points.
[0134] As an alternative solution, feature extraction is performed on the drawing trajectory point set, and the graphic fitting parameters obtained include:
[0135] S1, use the first preset function to perform linear fitting on the drawing trajectory point set to obtain the slope of the candidate line after fitting and the position coordinates of the target point on the candidate line;
[0136] S2, according to the slope of the candidate line, the position coordinates of the target point, and the size of the graphic of the drawing trajectory points, calculate the intersection position coordinates of the two intersections of the line and the canvas boundary;
[0137] S3, determine the intersection position coordinates as the graphic fitting parameters for fitting and generating a line-type graphic.
[0138] It should be noted that the key parameters for identifying this type of graphic include: the two intersections of the line and the canvas.
[0139] In this embodiment, according to the cv2.fitLine() function and the vector representation (cosk, sink) of the slope k of the line fitted by the point set and the coordinates (x, y) of a point on the line; according to the slope and the coordinates of a point, and the size of the input graphic, calculate the two intersections of the line and the canvas boundary, and draw the line according to the intersections, where the size of the input graphic limits the size of the canvas to prevent the line from being drawn out of bounds.
[0140] As an alternative solution, feature extraction is performed on the drawing trajectory point set, and the graphic fitting parameters obtained include:
[0141] S1, obtain the distances from each trajectory point in the drawing trajectory point set to the candidate line;
[0142] S2, determine the multiple trajectory points with distances greater than the threshold as reference points;
[0143] S3. Calculate the average value of the distances corresponding to each reference point.
[0144] S4. Determine the reference distances from each of the two endpoints of the candidate line to the target position, where the target position is the position corresponding to the average value of the distances.
[0145] S5. Determine the endpoint corresponding to the minimum value of the reference distances as the arrow tip.
[0146] S6. Determine the position coordinates of the endpoints and the position coordinates of the arrow tip as the graphic fitting parameters for fitting and generating a double-sided arrow graphic of a line.
[0147] It should be noted that the key parameters for identifying this type of graphic include: the two intersection points of the line and the canvas, and the arrow tip.
[0148] In this embodiment, according to the cv2.fitLine() function and the vector representation (cosk, sink) of the slope k of the line fitted by the point set and the coordinates (x, y) of a point on the line; according to the slope and the coordinates of a point, and the size of the input graphic to calculate the two intersection points of the line and the canvas boundary, and draw the line according to the intersection points, where the size of the input graphic limits the size of the canvas to prevent the line from being drawn out of bounds; then, find the five points farthest from the line in the point set, calculate the average of the five points to get the farthest average point, judge the distances between the two endpoints of the line and the farthest average point, and the smaller one is the arrow tip; draw the double-sided arrow of the line according to the arrow tip.
[0149] Among them, the above-mentioned farthest reference distance can, but is not limited to, selecting the endpoints corresponding to the first N distance values after sorting the distances from largest to smallest.
[0150] As an optional solution, perform feature extraction on the drawn trajectory point set, and the obtained graphic fitting parameters include:
[0151] S1. Fit the drawn trajectory point set using the least squares method to obtain a fitted ellipse.
[0152] S2. Obtain the position coordinates of the center point of the fitted ellipse, the lengths of the major and minor axes, and the rotation angle.
[0153] S3. Calculate the ratio between the lengths of the major and minor axes. Among them, when the ratio is within the target numerical range, determine that the fitted ellipse is a circle; when the ratio exceeds the target numerical range, determine that the fitted ellipse is an ellipse.
[0154] S4. Determine the ratio as the graphic fitting parameter for fitting and generating a circular graphic.
[0155] Fit an ellipse to the point set using the least squares method to obtain its center point, the lengths of the major and minor axes, and the rotation angle. Calculate the ratio of the major axis to the minor axis. If it is within (0.8, 1.2), it is recorded as a circle; otherwise, it is recorded as an ellipse.
[0156] It should be noted that the key parameters for identifying this type of graphic include: the center point, the distance of the major axis, the distance of the minor axis, and the rotation angle. If it is an ellipse, draw the ellipse according to the center point, the major and minor axes, and the rotation angle. If it is a circle, the radius is (major axis + minor axis) / 4, and draw the circle according to the center point and the radius.
[0157] As an alternative solution, perform feature extraction on the drawn trajectory point set to obtain graphic fitting parameters including:
[0158] S1. Use the second preset function to calculate the vertex coordinates of the three vertices of the circumscribed triangle of the drawn trajectory point set;
[0159] S2. Determine the vertex coordinates of the three vertices as the graphic fitting parameters for fitting and generating a triangle-like graphic.
[0160] It should be noted that the key parameters for identifying this type of graphic include: the three vertices.
[0161] In this embodiment, the best circumscribed triangle of the graphic is obtained by the cv2.minEnclosingTriangle() function, and the coordinates of the three vertices are returned, and the triangle is drawn by connecting the two points pairwise.
[0162] It should be noted that the key parameters for identifying this type of graphic include: the two intersection points of the straight line and the canvas, and the arrow vertex.
[0163] It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present invention.
[0164] According to another aspect of the embodiments of the present invention, there is also provided a graphic recognition device for implementing the above graphic recognition method. As Figure 4 shown, the device includes:
[0165] An acquisition unit 402, which acquires a screenshot of the candidate graphic currently drawn on the operation interface, as well as the drawn trajectory point set of the candidate graphic;
[0166] A determination unit 404, which determines the first-level graphic category to which the candidate graphic belongs based on the screenshot;
[0167] An identification unit 406, configured to identify a second-level graphic category from sub-categories of a first-level graphic category based on a set of drawn trajectory points;
[0168] A display unit 408, configured to display a target graphic fitted according to the second-level graphic category in an operation interface.
[0169] In this embodiment, for the implementation examples to be achieved by each unit module in the above graphic recognition device, reference may be made to the above method embodiments, which will not be elaborated here.
[0170] According to another aspect of the embodiments of the present invention, there is also provided an electronic device for implementing the above graphic recognition method, as Figure 5 shown. The electronic device includes a memory 502 and a processor 504. A computer program is stored in the memory 502, and the processor 504 is configured to execute the steps in any one of the above method embodiments through the computer program.
[0171] Optionally, in this embodiment, the above electronic device may be at least one network device among multiple network devices in a computer network.
[0172] Optionally, in this embodiment, the above processor may be configured to execute the following steps through a computer program:
[0173] S1, obtaining a screenshot of a candidate graphic currently drawn on an operation interface, and a set of drawn trajectory points of the candidate graphic;
[0174] S2, determining a first-level graphic category to which the candidate graphic belongs based on the screenshot;
[0175] S3, identifying a second-level graphic category from sub-categories of the first-level graphic category based on the set of drawn trajectory points;
[0176] S4, displaying a target graphic fitted according to the second-level graphic category in the operation interface.
[0177] Optionally, those of ordinary skill in the art can understand that Figure 5 the structure shown is only schematic. The electronic device may also be a terminal device such as a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, and a Mobile Internet Device (MID), a PAD, etc. Figure 5 It does not limit the structure of the above electronic device. For example, the electronic device may further include more or fewer components (such as a network interface, etc.) than those shown in Figure 5 , or have a different configuration from that shown in Figure 5 .
[0178] Among them, the memory 502 can be used to store software programs and modules, such as the program instructions / modules corresponding to the graphic recognition method and device in the embodiments of the present invention. The processor 504 executes various functional applications and data processing by running the software programs and modules stored in the memory 502, that is, implements the above-mentioned graphic recognition method. The memory 502 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 502 may further include a memory remotely disposed relative to the processor 504, and these remote memories can be connected to the terminal through a network. Examples of the above network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof. Among them, the memory 502 can specifically but not limitedly be used to store information such as graphic fitting parameters of each graphic. As an example, as Figure 5 shown, the above-mentioned memory 502 may include, but is not limited to, the acquisition unit 402, determination unit 404, recognition unit 406, and display unit 408 in the above-mentioned graphic recognition device. In addition, it may also include, but is not limited to, other module units in the above-mentioned graphic recognition device, which will not be elaborated in this example.
[0179] Optionally, the above-mentioned transmission device 506 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one instance, the transmission device 506 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers through a network cable, so as to communicate with the Internet or local area network. In one instance, the transmission device 506 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0180] In addition, the above-mentioned electronic device further includes: a display 508, which is used to display the above-mentioned drawn candidate graphic and the finally corrected target graphic; and a connection bus 510, which is used to connect each module component in the above-mentioned electronic device.
[0181] In other embodiments, the above-mentioned terminal device or server may be a node in a distributed system. Among them, the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes through network communication. Among them, the nodes can form a peer-to-peer (P2P, Peer To Peer) network, and any form of computing device, such as servers, terminals and other electronic devices, can become a node in the blockchain system by joining the peer-to-peer network.
[0182] According to one aspect of the present application, there is provided a computer program product or a computer program. The computer program product or the computer program includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned graphic recognition method. Among them, the computer program is configured to execute the steps in any one of the above method embodiments when running.
[0183] Optionally, in this embodiment, the above-mentioned computer-readable storage medium may be configured to store a computer program for executing the following steps:
[0184] S1. Obtain a screenshot of a candidate graphic currently drawn on the operation interface, and a set of drawing trajectory points of the candidate graphic;
[0185] S2. Determine the first-level graphic category to which the candidate graphic belongs based on the screenshot;
[0186] S3. Identify the second-level graphic category from the sub-categories of the first-level graphic category based on the set of drawing trajectory points;
[0187] S4. Display a target graphic fitted according to the second-level graphic category in the operation interface.
[0188] Optionally, in this embodiment, those of ordinary skill in the art can understand that all or part of the steps in the above various methods can be completed by a program instructing the relevant hardware of the terminal device. The program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.
[0189] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments.
[0190] If the integrated unit in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in the above-mentioned computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention.
[0191] In the above embodiments of the present invention, the descriptions of the respective embodiments each have their own emphasis. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0192] In several embodiments provided by the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of the units or modules can be in an electrical or other form.
[0193] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0194] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0195] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A method for graphic recognition, characterized in that, Including: Obtain a screenshot of the candidate graph currently drawn on the operation interface, and the set of drawing trajectory points of the candidate graph; Use a classification model to determine the first-level graph category to which the candidate graph belongs based on the screenshot; Identify the second-level graph category from the sub-categories of the first-level graph category based on the set of drawing trajectory points; Display the target graph fitted according to the second-level graph category in the operation interface; Wherein, identifying the second-level graph category from the sub-categories of the first-level graph category based on the set of drawing trajectory points includes: Perform feature recognition on the set of drawing trajectory points to obtain graph fitting parameters; Determine the second-level graph category from the sub-categories of the first-level graph category according to the graph fitting parameters; The graph fitting parameters are parameters for fitting and drawing a graph, and different graph categories correspond to different graph fitting parameters.
2. The method according to claim 1, characterized in that, Determining the first-level graph category to which the candidate graph belongs based on the screenshot includes: Use a classification model to classify the screenshot to obtain a classification result, wherein the classification model is a neural network model for identifying the category of the graph displayed in the screenshot; Determine the first-level graph category according to the classification result.
3. The method according to claim 2, characterized in that, Using a classification model to classify the screenshot to obtain a classification result includes: Adjust the input size of the screenshot to a target size, wherein the size information of the target size includes: the display length of the screenshot, the display width of the screenshot, and the display color value of the screenshot; Input the screenshot under the target size into the classification model to obtain the classification result, wherein the application format of the model framework used in the classification model is a format that allows to be called by a mobile device or an embedded device.
4. The method according to claim 1, characterized in that, Performing feature recognition on the set of drawing trajectory points to obtain graph fitting parameters includes: In the case of identifying a convex hull trajectory from the set of drawing trajectory points, obtain the graph corner points of the convex hull trajectory; When the total number of the graph corner points reaches N, determine the position coordinates of the graph corner points as the graph fitting parameters for fitting and generating an N-sided polygon-like graph.
5. The method according to claim 1, characterized in that, Performing feature extraction on the set of drawing trajectory points to obtain graph fitting parameters includes: Determine the straight line fitted according to the set of drawing trajectory points as the center line; Fit the minimum circumscribed triangle of the candidate graph according to the set of drawing trajectory points; Determine the intersection points between the three side line segments corresponding to the minimum circumscribed triangle and the center line; Sort the distances between the midpoint positions of the three side line segments and the intersection points; Determine the side line segment corresponding to the minimum distance as the side line segment at the top of the heart shape; Determine the heart shape direction parameter and the heart shape size parameter calculated based on the side line segment at the top of the heart shape as the graph fitting parameters for fitting and generating a heart shape-like graph.
6. The method according to claim 1, characterized in that, Performing feature extraction on the set of drawing trajectory points to obtain graph fitting parameters includes: Calculate the included angles between vectors formed by any two points in the set of drawing trajectory points to obtain a plurality of included angles; Traverse the set of drawing trajectory points, and determine the point corresponding to the largest included angle among the plurality of included angles as the arrowhead vertex; Determine the set of points between the head position at the starting end of the trajectory and the arrowhead vertex as the right-angled main trunk; Determine the position coordinates of each point on the right-angled main trunk and the position coordinates of the arrowhead vertex as the graphic fitting parameters for fitting and generating a right-angled single-sided arrow-like graphic.
7. The method according to claim 1, characterized in that, Perform feature extraction on the drawn trajectory point set, and the obtained graphic fitting parameters include: Obtain the first position coordinate of the head position located at the starting end of the trajectory and the second position coordinate of the tail position located at the ending end of the trajectory according to the drawn trajectory point set; Determine the position coordinates of the point with the farthest perpendicular distance from the relative connection line in the drawn trajectory point set as the position coordinates of the farthest point on the arc, where the connection line is the connection line between the first position coordinate and the second position coordinate; Convert the position coordinates of the farthest point into the position coordinates of the control point; Determine the first position coordinate, the second position coordinate, and the position coordinates of the control point as the graphic fitting parameters for fitting and generating a polyline-like graphic.
8. The method according to claim 7, wherein Perform feature extraction on the drawn trajectory point set, and the obtained graphic fitting parameters include: Determine the candidate angle according to the first position coordinate, the second position coordinate, and the position coordinates of the control point; Perform right-angle correction on the candidate angle to obtain the corrected point position coordinates; Determine the corrected point position coordinates as the graphic fitting parameters for fitting and generating a right-angled-like graphic.
9. The method according to claim 8, wherein Before determining the candidate angle according to the first position coordinate, the second position coordinate, and the position coordinates of the control point, it further includes: Perform line detection on the drawn trajectory point set to obtain the detection result; Merge multiple line segments in the detection result, and determine the two line segments with the largest length after merging as the right-angled sides; Determine the turning point based on the foot of the perpendicular of the right-angled side; Determine the first position coordinate and the second position coordinate in the direction after the right-angled side extends along the opposite direction of the foot of the perpendicular.
10. The method according to claim 9, wherein After performing right-angle correction on the candidate angle to obtain the corrected point position coordinates, it further includes: Count the first number of points around the first position coordinate and the second number of points around the second position coordinate; Determine the arrowhead vertex according to the first number of points and the second number of points; Determine the corrected point position coordinates and the position coordinates of the arrowhead vertex as the graphic fitting parameters for fitting and generating a right-angled double-sided arrow-like graphic.
11. The method according to claim 1, wherein Perform feature extraction on the drawn trajectory point set, and the obtained graphic fitting parameters include: In the case where the drawn trajectory point set includes two subsets, calculate the lengths of two line segments based on the two subsets, and determine the line segment with the largest length among the two line segments as the arc main body; Determine the arrowhead vertex according to the number of points around the two endpoints of the arc main body; Determine the position coordinates of the two endpoints of the arc main body and the position coordinates of the arrowhead vertex as the graphic fitting parameters for fitting and generating an arc double-sided arrow-like graphic.
12. The method according to claim 1, wherein Perform feature extraction on the drawn trajectory point set, and the obtained graphic fitting parameters include: Use a first preset function to perform linear fitting on the drawn trajectory point set to obtain the slope of the candidate line after fitting and the position coordinates of the target point on the candidate line; According to the slope of the candidate line, the position coordinates of the target point, and the graphic size of the drawn trajectory point, calculate the intersection position coordinates of the two intersections of the line and the canvas boundary; Determine the intersection position coordinates as the graphic fitting parameters for fitting and generating a line-shaped graphic; 13. The method according to claim 12, wherein Feature extraction is performed on the drawn trajectory point set, and the obtained graphic fitting parameters include: Obtain the distances from each trajectory point in the drawn trajectory point set to the candidate line; Determine multiple trajectory points with distances greater than the threshold as reference points; Calculate the average value of the distances corresponding to the respective reference points; Determine the reference distances from the two endpoints of the candidate line to the target position respectively, where the target position is the position corresponding to the average value of the distances; Determine the endpoint corresponding to the minimum value of the reference distance as the arrow tip; Determine the position coordinates of the endpoint and the position coordinates of the arrow tip as the graphic fitting parameters for fitting and generating a line double-arrow-shaped graphic; 14. The method according to claim 1, wherein Feature extraction is performed on the drawn trajectory point set, and the obtained graphic fitting parameters include: Perform fitting on the drawn trajectory point set using the least squares method to obtain a fitted ellipse; Obtain the position coordinates of the center point of the fitted ellipse, the lengths of the major and minor axes, and the rotation angle; Calculate the ratio between the major and minor axes. In the case where the ratio is within the target numerical range, determine the fitted ellipse as a circle; in the case where the ratio exceeds the target numerical range, determine the fitted ellipse as an ellipse; Determine the ratio as the graphic fitting parameter for fitting and generating a circular-shaped graphic; 15. According to the method described in claim 1, characterized in that, Feature extraction is performed on the drawn trajectory point set, and the obtained graphic fitting parameters include: Use a second preset function to calculate the vertex coordinates of the three vertices of the circumscribed triangle of the drawn trajectory point set; Determine the vertex coordinates of the three vertices as the graphic fitting parameters for fitting and generating a triangle-shaped graphic; 16. A graphic recognition device, characterized in that, Include: An acquisition unit for acquiring a screenshot of a candidate graphic currently drawn on the operation interface and the drawn trajectory point set of the candidate graphic; A determination unit for determining the first-level graphic category to which the candidate graphic belongs based on the screenshot using a classification model; An identification unit for identifying the second-level graphic category from the sub-categories of the first-level graphic category based on the drawn trajectory point set; A display unit for displaying the target graphic fitted according to the second-level graphic category in the operation interface; Among them, identifying the second-level graphic category from the sub-categories of the first-level graphic category based on the drawn trajectory point set includes: Perform feature recognition on the drawn trajectory point set to obtain graphic fitting parameters; Determine the second-level graphic category from the sub-categories of the first-level graphic category according to the graphic fitting parameters; The graphic fitting parameters are parameters for fitting and drawing a graphic, and different graphic categories correspond to different graphic fitting parameters.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when running, executes the method described in any one of claims 1 to 15.
18. An electronic device, including a memory and a processor, characterized in that, A computer program is stored in the memory, and the processor is configured to execute the method described in any one of claims 1 to 15 through the computer program.
Citation Information
Patent Citations
Method and device for identifying and editing freehand sketch
CN104424473A
Normalizing method and system of hand drawing geometric figures
CN105719328A
Image recognition and neural network model training method, device and system
CN110188641A
Graph recognition processing method and device, storage medium and electronic equipment
CN113240774A