Method, device, computer device and storage medium for graphics processing

By acquiring and processing the path data of user-drawn geometric shapes, calculating the minimum distance and correcting them, the problem of non-standard hand-drawn shapes is solved, and automatic correction and efficient generation of standard shapes are achieved.

CN119784900BActive Publication Date: 2025-10-24NEW H3C INTELLIGENCE TERMINAL CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411866364.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-10-24
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

In scenarios such as remote meetings and teaching, user-drawn geometric shapes are often non-standard and unattractive, and existing technologies are unable to effectively correct them.

Method used

By acquiring the original path data, performing point supplementation to generate extended path data, calculating the minimum distance between the extended points, determining the closure of the figure based on the distance, and correcting and standardizing the path data to generate a standard figure.

Benefits of technology

It enables automatic correction of user-drawn graphics, simplifies the operation process, improves drawing efficiency, and ensures that the generated graphics are standardized and aesthetically pleasing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119784900B_ABST
    Figure CN119784900B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of data processing, and discloses a graphics processing method and device, a computer device and a storage medium. The method comprises the following steps: acquiring original path data of an original graphics; performing point supplementing processing on the original path data to generate extension path data of an extension graphics; determining the minimum distance between two extension points according to the coordinate data of the extension points in the extension path data; in the case that the minimum distance is less than a first preset distance, determining that the original graphics is closed, taking the two extension points corresponding to the minimum distance as a starting point and an ending point of a corrected graphics, and generating correction path data of the corrected graphics; in the case that the minimum distance is greater than the first preset distance, determining that the original graphics is not closed, and taking the original path data or the extension path data as correction path data of the corrected graphics; and generating standard path data of a standard graphics based on the correction path data. The application simplifies user drawing operation and can guarantee the correction effect of the graphics.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular to a method and device for processing graphics, a computer device and a storage medium. BACKGROUND

[0002] In a remote conference, teaching or the like, a user (for example, a teacher or a student) can manually draw a geometric figure (commonly including a straight line, an angle, a triangle, a square, a rectangle, a parallelogram, a trapezoid, an ellipse, a circle or the like) needed to be displayed on an electronic screen (for example, an electronic whiteboard or the like). However, the manually drawn figure is prone to be non-standard and not beautiful. SUMMARY

[0003] Therefore, the present application provides a method and device for processing graphics, a computer device and a storage medium to solve the problem of non-standard manually drawn figures.

[0004] In a first aspect, the present application provides a method for processing graphics, comprising:

[0005] obtaining original path data of an original figure; the original path data comprising coordinate data of a plurality of original points;

[0006] performing point supplementing processing on the original path data to generate extended path data of an extended figure; the extended path data comprising coordinate data of a plurality of extended points, the extended points comprising the original points and the supplement points obtained through the point supplementing processing;

[0007] determining a minimum distance between two extended points according to the coordinate data of the extended points in the extended path data;

[0008] in a case where the minimum distance is less than a first preset distance, determining that the original figure is closed, and taking the two extended points corresponding to the minimum distance as a starting point and an ending point of a corrected figure to generate corrected path data of the corrected figure;

[0009] in a case where the minimum distance is greater than the first preset distance, determining that the original figure is not closed, and taking the original path data or the extended path data as corrected path data of a corrected figure;

[0010] performing standardization processing on the corrected path data to determine standard path data used to generate and display a standard figure.

[0011] In a second aspect, the present application provides a device for processing graphics, comprising:

[0012] an obtaining module configured to obtain original path data of an original figure; the original path data comprising coordinate data of a plurality of original points;

[0013] The supplement point processing module is configured to perform supplement point processing on the original path data to generate extended path data of an extended graph, wherein the extended path data comprises coordinate data of a plurality of extended points, and the extended points comprise the original points and supplement points obtained through supplement point processing.

[0014] The distance calculation module is configured to determine a minimum distance between two extended points according to the coordinate data of the extended points in the extended path data.

[0015] The correction module is configured to determine that the original graph is closed when the minimum distance is less than a first preset distance, and to determine two extended points corresponding to the minimum distance as a starting point and an ending point of a corrected graph to generate corrected path data of the corrected graph; and to determine that the original graph is not closed when the minimum distance is greater than the first preset distance, and to use the original path data or the extended path data as corrected path data of the corrected graph.

[0016] The standardization module is configured to perform standardization processing on the corrected path data to determine standard path data used to generate and display a standard graph.

[0017] In a third aspect, the present application provides a computer device, comprising a memory and a processor, the memory and the processor are communicatively connected with each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the method for processing a graph according to the first aspect or any one of the corresponding embodiments thereof.

[0018] In a fourth aspect, the present application provides a computer readable storage medium, which stores computer instructions, and the computer instructions are used to make a computer execute the method for processing a graph according to the first aspect or any one of the corresponding embodiments thereof.

[0019] In a fifth aspect, the present application provides a computer program product, which comprises computer instructions, and the computer instructions are used to make a computer execute the method for processing a graph according to the first aspect or any one of the corresponding embodiments thereof.

[0020] The present application automatically corrects an original graph into a more standardized standard graph through correction and standardization processing on original path data collected when a user draws a graph, so that the user can simply and quickly draw a standard geometric graph without repeatedly adjusting, thereby simplifying the user drawing operation and improving the drawing efficiency. The original path data is first subjected to supplement point processing, the graph is corrected based on the data after supplement point processing, and redundant lines are removed, so that the correction effect of the graph can be ensured and the standard graph generated due to hand-drawing problems can be avoided in subsequent standardization processing. BRIEF DESCRIPTION OF DRAWINGS

[0021] In order to make the technical solutions in the specific embodiments or related art of the present application clearer, the accompanying drawings needed in the specific embodiments or related art description will be briefly introduced. Obviously, the accompanying drawings in the following description are some embodiments of the present application, and other accompanying drawings can be obtained by those skilled in the art without any creative effort on the basis of these accompanying drawings.

[0022] Figure 1 is a flowchart of a method of graphic processing according to an embodiment of the present application;

[0023] Figure 2 is a schematic diagram of an original graphic when a user draws a square by hand according to an embodiment of the present application;

[0024] Figure 3 is a schematic diagram of correction of an extended graphic according to an embodiment of the present application;

[0025] Figure 4 is a flowchart of a processing procedure of graphic correction based on different systems according to an embodiment of the present application;

[0026] Figure 5 is a flowchart of another method of graphic processing according to an embodiment of the present application;

[0027] Figure 6 is a schematic diagram of a supplement point process according to an embodiment of the present application;

[0028] Figure 7 is a schematic diagram of traversal processing of an extended graphic according to an embodiment of the present application;

[0029] Figure 8 is a schematic diagram of a contraction process according to an embodiment of the present application;

[0030] Figure 9 is another schematic diagram of a contraction process according to an embodiment of the present application;

[0031] Figure 10 is a schematic diagram of a merging process according to an embodiment of the present application;

[0032] Figure 11 is a schematic diagram of a process of generating a standard ellipse according to an embodiment of the present application;

[0033] Figure 12 is a schematic diagram of slope correction of an angle graphic according to an embodiment of the present application;

[0034] Figure 13 is a schematic diagram of a head-tail closure process according to an embodiment of the present application;

[0035] Figure 14 is a diagram for correcting a square according to an embodiment of the present application;

[0036] Figure 15 is a diagram for correcting a parallelogram and a trapezoid according to an embodiment of the present application;

[0037] Figure 16 is a structural block diagram of an apparatus for graphic processing according to an embodiment of the present application;

[0038] Figure 17 is a hardware structure diagram of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION

[0039] To make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0040] Skia is an open-source two-dimensional graphics library, which is widely used in graphic rendering and is a cross-platform graphics library supporting multiple operating systems. It is a 2D graphics rendering engine of the system core, responsible for processing almost all graphic drawing tasks, including user interface, animation, text, image, etc. When a user draws a graphic by hand, the Path class provided by the system SDK (Software Development Kit) can be used to record data and draw. In essence, the Path class is implemented by SkPath under the hood, and SkPath can be obtained through reflection.

[0041] For example, when a user draws a geometric figure by hand on an electronic screen through a mouse, a stylus, a finger, etc., the Path class can be used to record the drawing path data of the figure. The data usually exists in the form of a series of point coordinates, which are arranged in time sequence, and the coordinate data of the points represents the path passed by the user's finger or stylus on the electronic screen. These coordinate data are the basis for the electronic screen to recognize and reconstruct the user's hand-drawn figure.

[0042] In order to correct the user's hand-drawn figure, the figure can be standardized based on the characteristics of the user's hand-drawn figure, so as to generate a standard figure. For example, a user's hand-drawn figure similar to a circle is standardized as a standard circle, so that the user can draw a standard figure in a hand-drawing manner. However, due to the complexity of the hand-drawn figure, especially at the end of the drawn line, deviations are prone to occur, which affects the subsequent correction effect.

[0043] The method for processing a graph provided by the embodiment of the present application first performs point supplementing on the collected data, preliminarily corrects the graph based on the data after the point supplementing, and removes the redundant lines, so that the abnormal standard graph caused by the hand-drawing problem can be avoided during the subsequent standardization processing, and the correction effect of the graph can be ensured.

[0044] According to the embodiment of the present application, a method for processing a graph is provided, and it should be noted that the steps shown in the flowchart can be executed in a computer system such as a group of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0045] In the embodiment, a method for processing a graph is provided, which can be applied to a device capable of collecting drawing path data, such as an electronic whiteboard, and can also be applied to a server for uniformly controlling the electronic whiteboard and the like, and the server corrects the graph based on the path data uploaded by the electronic whiteboard to generate a standard graph. Figure 1 The flowchart of the method for processing a graph according to the embodiment of the present application is shown in FIG. 1, which includes the following steps. Figure 1 The flowchart of the method for processing a graph according to the embodiment of the present application is shown in FIG. 1, which includes the following steps.

[0046] In step S101, the original path data of the original graph is obtained, and the original path data includes the coordinate data of a plurality of original points.

[0047] As described above, when a user draws an original geometric graph on an electronic screen by using a mouse, a stylus, a finger, or the like, the Path class can be used to record the drawing path data of the graph. For the convenience of description, the graph drawn by the user is referred to as an original graph, and the recorded drawing path data is referred to as original path data.

[0048] The original path data includes a series of coordinate data of points arranged in time sequence, and the points are referred to as original points.

[0049] Figure 2 A schematic diagram of the original graph when the user draws a square is shown, and the graph corresponds to a drawing path, and the points on the drawing path are original points, and the position of the original point can be determined based on the coordinate data of the original point.

[0050] In this embodiment, since the user may draw a single stroke or multiple strokes when drawing a figure, the original path data can include data of a single stroke or data of multiple strokes, i.e., multiple paths are combined as one path to form the original path data. For example, for two paths, if the start point or the end point of one path is close to one of the start points or the end points of the other path (e.g., the distance between them is less than a preset value), the two paths can be integrated as one path.

[0051] In step S102, the original path data is supplemented to generate extended path data of the extended figure; the extended path data includes coordinate data of multiple extended points, and the extended points include original points and supplemented points obtained through the supplementing.

[0052] In this embodiment, the original figure drawn by hand is not standard, and there can be problems such as not being strictly closed or having extra lines due to intersection, which need to be corrected. The number and density of original points in the original path data are related to the speed of drawing by the user, the sampling frequency of the electronic screen, and the like, which can result in a relatively long distance between some original points. To ensure the correction effect in the subsequent steps, the original path data is supplemented in this embodiment.

[0053] Specifically, through the supplementing of the original path data, a new point can be inserted between two adjacent original points, which is referred to as a "supplemented point" in the subsequent steps. Both the original points and the inserted supplemented points are extended points, and thus path data including coordinate data of multiple extended points, i.e., extended path data, is generated. For example, coordinate data of the supplemented points in the original path data is added to generate the extended path data.

[0054] It can be understood that the extended points are more in number than the original points, and can more accurately represent the shape of the figure.

[0055] In step S103, the minimum distance between two extended points is determined according to the coordinate data of the extended points in the extended path data.

[0056] In this embodiment, the extended path data includes multiple extended points, and the distance between any two extended points can be determined, which is calculated based on the coordinate data of the two extended points. For example, the coordinate data of one extended point is (x1, y1), and the coordinate data of the other extended point is (x2, y2), and the distance d between the two extended points is:

[0057]

[0058] By comparing the sizes of the distances d, the minimum distance can be determined.

[0059] In the case where misjudgment is caused by a small distance between two adjacent extension points, the distance between two non-adjacent extension points can be determined, and the minimum distance can be determined from these distances.

[0060] Generally, a threshold can be set. If the number of extension points between two extension points exceeds the threshold, the distance between the two extension points is calculated. Otherwise, the distance between the two extension points is not calculated, minimizing the impact of adjacent extension points. This threshold can be a preset value, such as 10 or 20; alternatively, the threshold can be a number corresponding to a certain proportion of the total number of extension points (e.g., 2 / 3). This threshold, determined based on the proportion, can accommodate graphics of varying sizes.

[0061] The minimum distance between the extended points is used to determine whether there is a closed position in the extended shape. If this minimum distance is less than a preset distance threshold (i.e., the first preset distance described below), the extended shape is considered to have a closed position and is a closed image, and the original shape is also closed. For example, if the number threshold is 2 / 3 of the total number of extended points, if the minimum distance between the extended points is less than the distance threshold, it can be said that most of the paths in the shape are closed. Otherwise, the shape may be a random sketch by the user, in which case there is no closed position.

[0062] Step S104, when the minimum distance is less than the first preset distance, determine that the original figure is closed, and use the two extension points corresponding to the minimum distance as the first and last points of the corrected figure to generate corrected path data of the corrected figure; the corrected path data includes coordinate data of multiple correction points.

[0063] In this embodiment, a distance threshold for determining whether a graphic is closed is pre-set, and this threshold is used as a first preset distance. By comparing the minimum distance with the first preset distance, whether the graphic is closed can be determined. The first preset distance can be set based on business needs, for example, it can be set according to pixels, such as setting the first preset distance to 30px; or it can be dynamically set according to the number of expansion points to improve the recognition rate when processing paths of different sizes.

[0064] Specifically, if the minimum distance is less than the first preset distance, it means that the two extension points are close to each other, so it can be determined that the original figure (or the extended figure) is closed, for example, the original figure is a circle, a square, etc.; on the contrary, if the minimum distance is greater than the first preset distance, it can be considered that the original figure (or the extended figure) is not closed, for example, the original figure is a line segment, or an angle figure composed of two line segments, etc.

[0065] If the original graph is closed, the two extension points corresponding to the minimum distance are taken as the start point and the end point.

[0066] The graph formed by the start point and the end point is called a modified graph, and the path data corresponding to the modified graph is called modified path data, which includes coordinate data of multiple modified points. It can be understood that, on the basis of the extension graph, the extension points before the start point are deleted, and the extension points after the end point are deleted, so that the modified graph is obtained. Correspondingly, for the extension path data, the coordinate data of the extension points before the start point are deleted, and the coordinate data of the extension points after the end point are deleted, and the remaining extension points (including the start point and the end point) are all modified points, so that the modified path data is obtained.

[0067] Figure 3 A schematic diagram of modifying the extension graph is shown. As shown in Figure 3 , by deleting the start and end extension points in the extension graph, a modified graph without redundant points can be generated.

[0068] In step S105, if the minimum distance is greater than the first preset distance, it is determined that the original graph is not closed, and the original path data or the extension path data is taken as the modified path data of the modified graph.

[0069] In this embodiment, if the original graph (or the extension graph) is not closed, it can be considered that the extension graph does not have redundant lines, and the modification can not be performed, and the original graph or the extension graph is directly taken as the modified graph, that is, the original path data or the extension path data is taken as the modified path data of the modified graph.

[0070] In step S106, the modified path data is standardized to determine standard path data used to generate and display a standard graph.

[0071] In this embodiment, as described above, whether the graph is closed or not, the modified path data corresponding to the modified graph can be determined, which includes coordinate data of multiple modified points, and then the modified path data is standardized to correct the modified graph to a standard graph, so that the standard path data of the standard graph can be determined; and the electronic screen and other devices can generate and display the corresponding standard graph based on the standard path data. As shown in Figure 3 , a user-drawn rectangular graph can be corrected to a standard rectangle.

[0072] Since Skia supports multiple operating systems, the modification and standardization process provided in this embodiment can be combined with Skia, so that cross-platform docking can be better achieved. Figure 4The processing flow diagram for correcting a figure based on different systems is shown. Taking the Android system as an example, a user draws a geometric figure on an electronic screen, uses the Path class provided by the Android system to connect the drawn path data, and then obtains SkPath data through reflection. The SkPath data can be used as original path data, and is corrected and standardized based on the method provided in the embodiment, so as to obtain a corrected standard figure. After the correction is completed, the interface is refreshed to draw the Path path, and the corrected standard figure is immediately displayed on the interface.

[0073] The method for processing a figure provided in the embodiment corrects and standardizes the original path data collected when a user draws a figure, automatically corrects the original figure into a more standardized standard figure, and enables the user to simply and quickly draw a standard geometric figure without repeatedly adjusting the figure, thereby simplifying the user drawing operation and improving the drawing efficiency. The original path data is first subjected to point supplementing processing, the figure is corrected based on the data after the point supplementing processing, and redundant lines are removed, so that the subsequent standardization processing can avoid the abnormal standard figure generated due to the hand-drawing problem, and the correction effect of the figure can be ensured.

[0074] In the embodiment, another method for processing a figure is provided, which can be applied to a device capable of collecting drawing path data, such as an electronic whiteboard, and can also be applied to a server for uniformly controlling the electronic whiteboard and the like. The server corrects a figure based on the path data uploaded by the electronic whiteboard to generate a standard figure. Figure 5 The flowchart of the method for processing a figure according to the embodiment of the application is shown in FIG. 1, which includes the following steps. Figure 5 The flowchart of the method for processing a figure according to the embodiment of the application is shown in FIG. 1, which includes the following steps.

[0075] In step S501, original path data of an original figure is obtained. The original path data includes coordinate data of a plurality of original points.

[0076] For details, refer to step S101 of the embodiment shown in FIG. 1, which will not be repeated here. Figure 1 For details, refer to step S101 of the embodiment shown in FIG. 1, which will not be repeated here.

[0077] In step S502, the original path data is subjected to point supplementing processing to generate extended path data of an extended figure. The extended path data includes coordinate data of a plurality of extended points, and the extended points include the original points and the supplement points obtained through the point supplementing processing.

[0078] For details, refer to step S102 of the embodiment shown in FIG. 1, which will not be repeated here. Figure 1 For details, refer to step S102 of the embodiment shown in FIG. 1, which will not be repeated here.

[0079] In some optional embodiments, the above step S502 of “subjecting the original path data to point supplementing processing” can specifically include the following step a1.

[0080] Step a1: for two adjacent original points, when the distance between the two adjacent original points is greater than a second preset distance, insert at least one supplementary point between the two adjacent original points according to a preset supplementary point spacing; the supplementary point spacing is less than or equal to the second preset distance.

[0081] In this embodiment, a distance for determining whether a point needs to be supplemented can be preset, that is, a second preset distance. The second preset distance can be set according to actual needs. The shorter the second preset distance, the higher the accuracy. For example, it can be set to 5px.

[0082] Traverse the original points, for example, in chronological order, and determine whether the distance between two adjacent original points is greater than the second preset distance. If the distance between the two adjacent original points is greater than the second preset distance, it means that the distance between the two original points is large. In order to improve the accuracy of subsequent corrections, it is necessary to fill in the points.

[0083] Specifically, a patching point spacing can be set, and corresponding patching points can be inserted according to the patching point spacing so that the distance between the original point and an adjacent patching point, or the distance between two adjacent patching points, does not exceed the patching point spacing. The patching point spacing is less than or equal to the second preset distance. Generally, the two can be equal, that is, a single distance value can be set.

[0084] Figure 6 A schematic diagram of the point filling process is shown in Figure 6 As shown, the black circles in the original figure are the original points, and the black curves are hand-drawn curves. The original points can be connected using Bezier. Then, using the interval length between the patch points as the interval, the patch points are inserted using a linear transition. Once the patch points are complete, all the patch points and the original points form new path data, which is called the extended path data.

[0085] In this embodiment, the original points are supplemented according to the preset supplementary point spacing, and the spacing between points can be shortened as needed, thereby improving data accuracy and facilitating more accurate subsequent corrections.

[0086] Step S503: determining the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data.

[0087] Specifically, the above step S503 of “determining the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data” includes steps S5031 and S5032 .

[0088] Step S5031 : taking the extension points as the first points on which a query operation needs to be performed in sequence according to the drawing order, and performing the query operation on the first points until an end condition is met.

[0089] In this embodiment, the extended path data is a sequence formed by multiple extension points, and the extension points in the sequence are arranged in chronological order. For the sequence formed by the extension points, a forward order from the first to the last or a forward order from the last to the first can be taken as the drawing order, that is, the drawing order can be a forward order when a user draws a figure, or can be a reverse order corresponding to the drawing of the figure, and this embodiment does not limit this.

[0090] In order to facilitate description, the first extension point is referred to as a starting point, and the last extension point is referred to as a terminal point.

[0091] In this embodiment, starting from the starting point, a preset query operation is performed for each extension point as needed until an end condition is met, and then the query operation is no longer needed to be performed. In order to facilitate description, the extension point performing the query operation is referred to as a first point, and it can be understood that the initial first point is the starting point. In addition, the end condition corresponding to the first point is referred to as a first end condition.

[0092] The query operation specifically includes: taking other extension points after the first point as second points, and respectively determining distances between the first point and each second point; and taking a minimum value of the distances between the first point and each second point as a to-be-determined distance determined by this query operation.

[0093] In this embodiment, for each first point, other extension points located after the first point can be determined based on the drawing order, and these other extension points are referred to as second points for the convenience of description. Based on this, distances between the first point and the second points are determined, and a minimum value of the distances is taken out, which is the to-be-determined distance determined by this query operation. That is, for each first point, a corresponding to-be-determined distance can be determined.

[0094] For example, the query operation specifically includes: starting from the terminal point, taking the extension points as the second points in an order opposite to the drawing order, and determining distances between each second point and the first point until a second end condition is met; and taking a minimum value of the distances between each second point and the first point as the to-be-determined distance determined by this query operation.

[0095] In this embodiment, in order to find a closure point that makes the figure closed, or an intersection point of the figure, a forward-to-backward traversal manner of the extension points is adopted, and each time the traversal is performed from back to front. Based on the double traversal, the two extension points closest to each other are quickly and accurately found.

[0096] Specifically, for each extension point, a corresponding index (serial number) is set in the drawing order. If the number of the extension points is size, the indexes of the extension points can be 1, 2, 3, …, size in turn, wherein the extension point with the index of 1 is the starting point, and the extension point with the index of size is the terminal point.

[0097] Firstly, the extension point 1 is taken as the first point, and a query operation is performed, i.e., starting from the extension point size (the terminal point), each extension point is taken as the second point in the order of the extension point size, the extension point size-1, and the extension point size-2, and the distance between the first point and the second point is determined, i.e., the distance between the extension point 1 and the extension point size, the distance between the extension point 1 and the extension point size-1, the distance between the extension point 1 and the extension point size-2, and the like are sequentially calculated.

[0098] When the second ending condition is met, the distance between the second point and the first point is no longer calculated, and the minimum value in the distances determined in the current query operation is taken out, which is the pending distance. For example, if the distance between the extension point 1 and the extension point size-2 is the minimum, the distance between the extension point 1 and the extension point size-2 is the pending distance.

[0099] Similarly, the extension point after the extension point 1 is taken as the new first point, i.e., the extension point 2 is taken as the new first point, and the query operation is performed again, i.e., the distance between the extension point 2 and the extension point size, the distance between the extension point 2 and the extension point size-1, the distance between the extension point 2 and the extension point size-2, and the like are sequentially calculated until the second ending condition is met, and the pending distance in the current time is determined. For example, the distance between the extension point 2 and the extension point size-1 is the minimum, and the distance between the extension point 2 and the extension point size-1 is the pending distance.

[0100] Then, the extension point 3, the extension point 4, and the like can also be taken as the new first point, and the query operation is performed. When the first ending condition is met, the entire traversal process is ended. Through multiple query operations, the minimum distance between multiple first points and corresponding extension points, i.e., the pending distance, can be determined.

[0101] In step S5032, the minimum value in the pending distances determined by all the query operations is taken as the minimum distance between the two extension points.

[0102] In the embodiment, as described above, each query operation can determine a pending distance, which is the minimum distance between the corresponding first point and other extension points. Further, the minimum value is selected from the pending distances, which is the minimum distance that can be determined by all the extension points.

[0103] Alternatively, two ending conditions can be set based on the number of extension points. Specifically, the first ending condition is met in a case where the number of extension points between the first point and the terminal point is less than or equal to a preset number; and the second point is another extension point after the first point and having a number of extension points greater than or equal to the preset number between the first point and the second point. The preset number is the minimum number indicating the closure of the graph.

[0104] In this embodiment, if the original figure is a closed figure, the proportion pl of the path length of the closed figure to the total path length can be set to be greater than a minimum value MIN PL, which can be adjusted as needed, for example, MIN PL = 3 / 5. The proportion pl can describe the effective closed range, and if pl is too small, it is considered that the effective closed range does not constitute a closed figure. Since the extension points in the extended figure are generated based on the insertion of the supplement points, the distance between each extension point is relatively close, and for the convenience of calculation, the length of the corresponding path is represented by the number of extension points, so that the calculation of the proportion pl can be simplified to the calculation of the number of extension points in the closed figure divided by the total number of extension points.

[0105] For example, if the path between two extension points is closed (the two extension points are closed points or intersection points), the number of other extension points spaced between the two extension points should be no less than: the total number of extension points * MIN PL; as above, the total number of extension points is size, then the number of extension points between the two extension points ≥ size * MIN PL.

[0106] Correspondingly, the minimum number representing the closure of the figure, i.e. the preset number, can be set as size * MIN PL.

[0107] When performing traversal, the first end condition is set to judge whether the number of extension points between the first point and the termination point is less than or equal to the preset number, and if it is less than or equal to the preset number, it means that the distance between the first point and the termination point is relatively close at this time, and even if the distance between them is small, it cannot be considered as a closed point that makes the figure closed.

[0108] And when determining the second point, only the other extension points with the number of extension points greater than or equal to the preset number between the first point are taken as the second point, i.e. the extension points with a relatively close distance from the first point are not taken as the second point, which not only reduces the calculation amount, but also ensures that the calculated pending distance or minimum distance can accurately represent whether the figure is closed.

[0109] Similarly, the second end condition is set to judge whether the number of extension points between the second point and the first point is less than or equal to the preset number, and if it is less than or equal to the preset number, it means that the distance between the second point and the first point at this time is relatively close, and even if the distance between them is small, it cannot be considered as a closed point that makes the figure closed, so the loop can be ended.

[0110] Figure 7 A schematic diagram of the traversal processing of the extended figure is shown. As shown in Figure 7 The extended figure includes a plurality of extension points, and the figure has intersections, and the extension points at the intersections can be taken as closed points, i.e. the first point and the tail point of the modified figure.

[0111] As shown Figure 7 in the figure, the total number of extension points is size, and their indexes are 1, 2, 3, …, size in sequence. For the first point, traverse from the front to the back, and take extension points 1, 2, 3, etc. as the first point in sequence. And for a certain first point, also traverse from the back to the front, that is, take extension points size, size - 1, size - 2 as the second point in sequence. Let the index of the first point be first_index and the index of the second point be last_index, then the number of extension points between the first point and the second point is pl_ds = last_index - first_index. And based on the above setting of MIN_PL, the preset number is MIN_PL * size, so it is required that pl_ds ≥ MIN_PL * size. If pl_ds < MIN_PL * size, then the second end condition is satisfied and this query operation ends. In other words, during each query operation, if the index of the first point is first_index, then the index of the second point cannot be less than first_index + MIN_PL * size.

[0112] As shown Figure 7 in the lower right corner, if the index of the first point first_index = 1, then the index of the second point last_index traversed to is 1 + pl_ds, and it is necessary to ensure that pl_ds ≥ MIN_PL * size.

[0113] For any first point and second point, calculate the distance d between them. Figure 7 shows the distance d between extension point 1 and extension point size. Among them, it can be compared with the set first preset distance. If d is less than this first preset distance, then the first point and the second point may be able to be closed and connected; and so on until the second end condition is satisfied, and the indexes of the two extension points with the smallest distance d are found, that is, first_index and last_inedx.

[0114] Similarly, after each query operation is completed, the number of extension points between the first point and the termination point can be determined, and this number is size - first_index. If size - first_index < MIN_PL * size, then the first end condition is satisfied and the traversal process ends.

[0115] In the embodiment, the indexes of the two extension points corresponding to the pending distance determined by each round of query operation can be stored, and the extension points corresponding to the minimum distance are found after the traversal ends; or, a variable for storing the indexes of the two extension points can be set, and the variable is updated when the pending distance determined by the current query operation is smaller than the pending distance stored in the variable, and the variable is kept unchanged when the pending distance determined by the current query operation is larger. After the traversal ends, the two indexes recorded in the variable are the indexes of the two extension points corresponding to the minimum distance, and the two extension points are the start point and the end point of the modified graph, so that the corresponding modified graph is generated. For details, please refer to the step S104 of the embodiment shown in Figure 7

[0116] It should be noted that in the first end condition and the second end condition in the embodiment, "the number of extension points is less than or equal to the preset number" includes three cases, i.e., the number of extension points < the preset number, or the number of extension points = the preset number, or the number of extension points ≤ the preset number. It can be understood that when the end condition is set as "the number of extension points < the preset number", when the number of extension points = the preset number, the traversal still needs to be performed, i.e., the related query operation needs to be performed. When the end condition is set as "the number of extension points ≤ the preset number", when the number of extension points = the preset number, the corresponding end condition is met at this time, so the query operation does not need to be performed.

[0117] In the embodiment, the two-layer traversal from front to back and from back to front can ensure the accuracy of the query result. In addition, the first end condition and the second end condition are set by using the minimum number representing the closure of the graph, which can reduce the processing amount while ensuring that the finally determined modified graph meets the closure standard, can effectively exclude the interference of adjacent extension points, and can accurately find the start point and the end point of the modified graph.

[0118] In step S504, in the case where the minimum distance is less than the first preset distance, it is determined that the original graph is closed, and the two extension points corresponding to the minimum distance are taken as the start point and the end point of the modified graph, and the modified path data of the modified graph is generated. The modified path data includes coordinate data of a plurality of modified points.

[0119] For details, please refer to the step S104 of the embodiment shown in Figure 1 The step S104 of the embodiment shown in will not be repeated here.

[0120] In step S505, in the case where the minimum distance is greater than the first preset distance, it is determined that the original graph is not closed, and the original path data or the extension path data is taken as the modified path data of the modified graph.

[0121] For details, please refer to the step S105 of the embodiment shown in Figure 1 The step S105 of the embodiment shown in will not be repeated here.

[0122] ​Step S506, the modified path data is standardized to determine the standard path data for generating and displaying the standard graph.

[0123] For details, please refer to Figure 1 Step S106 of the embodiment shown, which will not be described here.

[0124] In some optional embodiments, the step S506 "standardizing the modified path data to determine the standard path data for generating and displaying the standard graph" can include steps b1 to b2.

[0125] Step b1, the modified path data is contracted to determine the feature points related to the graph features in the modified path data, and to generate the feature path data of the feature graph; the feature path data includes the coordinate data of the feature points.

[0126] Step b2, the feature path data is standardized to generate the standard path data of the standard graph.

[0127] In this embodiment, there may be modified points in the modified path data that are not related to the graph features, especially in the process of the aforementioned supplementary point processing. By contracting the modified path data, the modified points unrelated to the graph features are deleted, and the remaining modified points related to the graph features are taken as feature points to generate the feature path data of the corresponding feature graph; the feature path data includes the coordinate data of the feature points. It can be understood that the feature points are also a kind of extension points, so deleting the useless coordinate data in the modified path data can obtain the feature path data. Subsequent standardization processing based on a small number of feature points can reduce the processing amount of the operation and improve the processing efficiency.

[0128] Specifically, the role of the contraction processing is to straighten the curve that is almost a straight line into a straight line, and the method is to discard the curved points.

[0129] Figure 8 A process diagram of the contraction processing is shown. As shown in Figure 8 The modified graph includes three modified points (black circles represent modified points); for the three consecutive modified points, the included angle (angle a in Figure 8 ) or the offset angle (i.e. 180°-a) of the three modified points is determined; if the included angle is greater than a preset angle (e.g. 160°), or the offset angle is less than a preset angle (e.g. 20°), it is considered that the three modified points are a straight line, and the middle modified point is not related to the graph features, so it can be discarded, and the final feature graph is shown in Figure 8 .

[0130] Figure 9 Another process diagram of the contraction processing is shown. As shown in Figure 9As shown, the modified graph includes six modified points, and first, the first, second, and third modified points are judged to see if the included angle meets the discard condition. At this time, it meets the condition, and the second modified point is discarded. Then, the third, fourth, and fifth modified points are judged, and they do not meet the discard condition, so they are retained. The subsequent three modified points are not processed, but enter the next round of contraction processing.

[0131] In the second round of contraction processing, the first, second, and third modified points (i.e., the first, third, and fourth modified points before) meet the discard condition, and the second modified point is discarded. Then, the third, fourth, and fifth (i.e., the fourth, fifth, and sixth modified points before) are judged, and they also meet the discard condition, so the fourth modified point is discarded. The final generated feature graph is shown in Figure 9

[0132] After determining the feature path data of the feature graph, a small amount of feature points can be used for standardization processing, which can greatly reduce the data amount of standardization processing.

[0133] When the hand-drawing speed is slow, such as when turning, or when there is slight shaking during hand-drawing, the modified points will be relatively dense, and according to the above contraction processing, these close points will be retained. To reduce the influence of shaking, adjacent modified points can be merged. Specifically, the contraction processing in step b1 above also includes a merging process, and only the merged modified points can be used as feature points related to the feature of the graph.

[0134] The merging process can specifically include: after the contraction processing of the modified path data, determining the retained effective points, which are also a kind of modified points; then judging whether the distance between the adjacent two effective points is less than a preset minimum merging distance. The minimum merging distance can be set to an appropriate value according to business needs, such as 30px. In the case where the distance between the adjacent two effective points is less than the minimum merging distance, the effective point in the former time or the effective point in the latter time is deleted.

[0135] Among them, the effective point in the former time or the effective point in the latter time needs to be deleted all the time, so that a plurality of continuous effective points with close distances can be cleaned up, and finally only one effective point is retained. After the merging process, the points close to the turn or the slight shaking will be further optimized to form a straight line.

[0136] Figure 10 A schematic diagram of the merging process is shown. The left half is the graph after the contraction processing, and the right half is the graph generated after the merging process. This graph can be used as the feature graph.

[0137] Optionally, the above step b2 "standardization processing of the feature path data to generate standard path data of the standard graph" can specifically include steps b21 to b22.​

[0138] Step b21, in the case of the original graph being closed, determining the graph category of the original graph according to the feature path data.

[0139] In this embodiment, the graph category of the original graph can be determined in combination with whether the graph is closed. Specifically, if the original graph is not closed, the graph category of the original graph can include a line segment, an angle, etc.; if the original graph is closed, the graph category of the original graph can include a triangle, a square, a rectangle, a parallelogram, a trapezoid, an ellipse, a circle, etc., which can be distinguished based on the characteristics of various graph categories, and the manner of identifying the graph category is not limited in this embodiment.

[0140] For example, after the shrinkage processing, the number of feature points in the ellipse and the circle is generally more, while the number of feature points in the triangle and the rectangle is less, so the number of feature points can be used to preliminarily distinguish whether the original graph is an ellipse or a circle closed curve; further, if the original graph is an ellipse or a circle, whether the distance between each feature point and the center is uniformly distributed can be used to determine whether the original graph is a circle or an ellipse.

[0141] For example, if the original graph is an ellipse or a circle, the center of the feature graph can be determined, and the distance variance VR of each feature point to the center can be determined, when VR is less than a boundary value VE, it is considered that all points are uniformly distributed, and it is approximately a circle, that is, the original graph is a circle. On the contrary, if VR is greater than VE, it is an ellipse. The set value of VE is set according to business debugging, such as 40, or different values can be set according to the size of the distance mean, so as to give different error range limits for different large circles.

[0142] Step b22, according to the graph category of the original graph, performing corresponding standardization processing on the feature path data to generate standard path data of the standard graph.

[0143] In this embodiment, after the graph category of the original graph is determined, the standardization processing can be performed based on the characteristics of the graph category, so as to generate a standard graph.

[0144] Optionally, the above step b22 “according to the graph category of the original graph, performing corresponding standardization processing on the feature path data to generate standard path data of the standard graph” can include the following steps b221 to b225.

[0145] Step b221, in the case of the original graph being closed and the graph category of the original graph being an ellipse, determining the coordinate data of the first center point of the feature graph according to the coordinate data of the feature points in the feature path data.

[0146] Step b222, according to the coordinate data of the feature points and the first center point, the distance between the first center point and each feature point is calculated, and the feature point corresponding to the maximum distance is taken as the first long axis point.

[0147] Step b223, the distance between the other feature points and the long axis line is determined, and the other feature point corresponding to the minimum distance is taken as the second long axis point; the long axis line is a straight line determined by the first center point and the first long axis point, and the distance between the first long axis point and the second long axis point is the long axis length.

[0148] Step b224, the midpoint between the first long axis point and the second long axis point is taken as the second center point, and the minimum value of the distance between the second center point and each feature point is determined, and twice the minimum value is taken as the short axis length.

[0149] Step b225, taking the second center point as the center of the standard ellipse graph, the coordinate data of the standard points located on the standard ellipse graph is determined according to the long axis length and the short axis length, and the standard path data of the standard graph is generated.

[0150] In this embodiment, if the original graph is closed and the graph category of the original graph is an ellipse, a standard ellipse needs to be generated, and by determining the long axis and the short axis, a standard ellipse can be finally determined.

[0151] Figure 11 The process diagram of generating a standard ellipse is shown. As shown in Figure 11 For the original graph, after correction processing such as shrinkage, a feature graph including a plurality of feature points can be obtained, and the coordinate data of the first center point of the feature graph can be determined according to the coordinate data of each feature point in the feature path data, Figure 11 Point O represents the first center point. For example, the mean value of the x coordinates of each feature point is taken as the x coordinate of point O, and the mean value of the y coordinates of each feature point is taken as the y coordinate of point O.

[0152] The coordinate data of each feature point is traversed, the distance between the first center point O and each feature point is calculated, so that the feature point farthest from the first center point O coordinate can be found, which is one point of the long axis of the ellipse, called the first long axis point, Figure 11 Point A represents the first long axis point.

[0153] Taking the AO straight line as the long axis line, the feature point closest to the long axis line is found, which is the other point of the long axis, i.e. the second long axis point, Figure 11 Point B represents the second long axis point. The distance between the first long axis point A and the second long axis point B, i.e. the long axis length of the ellipse, should be greater than the distance from the first long axis point A to the first center point O.

[0154] Then, the center point of the ellipse is re-determined, that is, the midpoint between the first major axis point A and the second major axis point B is used as the second center point. Figure 11 The second center point is represented by point C. By re-determining the center point, the subsequently generated ellipse is made closer to the user's hand-drawn figure.

[0155] After determining the second center point C, the distance between the second center point C and each feature point can be determined, and the minimum value is selected. The minor axis length is determined based on the minimum value, for example, twice the minimum value is used as the minor axis length. Figure 11 Let point Q represent the feature point closest to the second center point C. The distance between it and the second center point C is r. Then the length of the minor axis of the ellipse can be set to 2r. Finally, according to the equation of the line and the distance r, the coordinates of the two endpoints of the minor axis are calculated. Figure 12 E and F represent the endpoints of the two minor axes.

[0156] At this point, the major axis AB, minor axis EF, and midpoint C of the ellipse have all been calculated and recorded. The ellipse can be constructed based on these data in subsequent construction.

[0157] Similarly, the above-mentioned step b22 "performs corresponding standardization processing on the feature path data according to the graphic category of the original graphic to generate standard path data of the standard graphic" may also include: when the original graphic is closed and the graphic category of the original graphic is a circle, determines the coordinate data of the third center point of the feature graphic according to the coordinate data of the feature points in the feature path data; takes the average of the distances between each feature point and the third center point as the radius of the circle; takes the third center point as the center of the standard circular graphic, determines the coordinate data of the standard points located on the standard circular graphic according to the radius of the circle, and generates standard path data of the standard graphic.

[0158] In this embodiment, if the original figure is a circle, it is only necessary to determine the center and radius of the circle. Finally, based on the coordinates of the center and the radius, the standard path data of the standard figure can be generated.

[0159] In addition, for non-closed figures or closed figures that are not curves, slope correction can be performed during the standardization process. Specifically, the above step b2 "standardizing the characteristic path data to generate standard path data for the standard figure" can also include step b23.

[0160] Step b23: When the original figure is not closed, the line segment between two adjacent feature points in the feature path data is used as the line segment to be processed, and the slope correction processing is performed on the line segment to be processed to determine the coordinate data of the corrected feature point; the corrected feature point is used as the standard point on the standard figure to generate the standard path data of the standard figure.

[0161] In this embodiment, if the original figure is not closed, it can be a line segment or an angle; since it is difficult to draw a horizontal or vertical line segment completely horizontally or vertically, this embodiment corrects the slope to correct the horizontal line segment in the feature figure to a line segment with a slope of 0 and correct the vertical line segment in the feature figure to a line segment with a slope of infinity. The feature points after slope correction are the corrected feature points, and the standard path data corresponding to the standard line segment or angle can be determined based on these corrected feature points.

[0162] For example, the number of line segments of the feature figure can be determined. When the number of line segments is 1, the type is recorded as a straight line. When the number of line segments is 2, the type is recorded as an angle. When the number of line segments is greater than 2, the type is recorded as a non-circular shape. After recording, the above slope correction process is performed.

[0163] The step b23 of "performing slope correction on the to-be-processed line segment" can include steps b231 to b233.

[0164] In step b231, the slope corresponding to the first feature point and the second feature point at the two ends of the to-be-processed line segment is determined.

[0165] In step b232, when the absolute value of the slope is less than a first preset value, the y-coordinate of the second feature point is updated to the y-coordinate of the first feature point.

[0166] In step b233, when the absolute value of the slope is greater than a second preset value, the x-coordinate of the second feature point is updated to the x-coordinate of the first feature point; the second preset value is greater than the first preset value.

[0167] In this embodiment, the two feature points at the two ends of the to-be-processed line segment are referred to as the first feature point and the second feature point, and the corresponding slope K can be determined based on the coordinates of the first feature point and the second feature point. The slope is also the slope of the to-be-processed line segment.

[0168] When the absolute value of the slope K is <h_rate, the to-be-processed line segment is considered to be horizontal, and the straight line horizontal correction is performed. The correction method is to modify the y-coordinate of the second feature point to be consistent with the y-coordinate of the first feature point. h_rate is a first preset value set as required, such as 0.15.

[0169] When the absolute value of the slope K is >v_rate, the to-be-processed line segment is considered to be vertical, and the straight line vertical correction is performed. The correction method is to modify the x-coordinate of the second feature point to be consistent with the x-coordinate of the first feature point. v_rate is a second preset value set as required, such as 3.0.

[0170] Figure 12A schematic diagram of performing slope correction on an angle graph is shown. Figure 13 As shown, points A and B are the first feature point and the second feature point respectively, and the slope between them meets the conditions for horizontal correction. The vertical coordinate of point B can be modified so that the corrected line segment AB is horizontal and its slope is 0.

[0171] It will be appreciated that in step b23 above, if the original figure is not closed, it can be directly determined that the original figure is a line segment or angle, etc., which can be slope-corrected. Alternatively, if the original figure is not closed, the figure category of the original figure can be further determined based on the characteristic path data to determine whether the original figure is a line segment or angle, etc.

[0172] For example, we can determine the path based on the number of feature points in the feature path data. If there are two feature points, the original shape is a line segment; if there are three feature points, the original shape is an angle. If there are many feature points, the original shape may be an arc shape such as a semicircle, and slope correction is not required for circular shapes.

[0173] The above-mentioned step b22 "performing corresponding standardization processing on the characteristic path data according to the graphic category of the original graphic to generate standard path data of the standard graphic" may also include the following steps b226 to b227.

[0174] Step b226, when the original figure is closed and the figure category of the original figure is a non-circular figure, the line segment between two adjacent feature points in the feature path data is used as the line segment to be processed, and the slope correction processing is performed on the line segment to be processed to determine the coordinate data of the corrected feature point.

[0175] Step b227, when the beginning and end of the correction feature points are different, determine the first straight line based on the beginning point of the correction feature point and the adjacent correction feature points, determine the second straight line based on the end point of the correction feature point and the adjacent correction feature points, determine the intersection of the first straight line and the second straight line, update the coordinate data of the beginning point of the correction feature point and the end point of the correction feature point to the coordinate data corresponding to the intersection, and generate standard path data of the standard figure.

[0176] In this embodiment, if the original figure is closed but the figure type of the original figure is non-circular, that is, the original figure is not a circle or an ellipse, for example, the original figure may be a polygon such as a triangle, square, or trapezoid. Slope correction can also be performed on this original figure, for example, based on the method described in steps b231 to b233 above, which will not be further described here.

[0177] But after the slope correction, it is possible to cause the original closed figure to no longer be closed, that is, the first point and the tail point of the slope-corrected corrected feature points are different. The embodiment also performs closing processing on the slope-corrected corrected feature points.

[0178] Specifically, after the slope correction, a plurality of corrected feature points can be determined, wherein the first corrected feature point is the head point of the corrected feature points, and the last corrected feature point is the tail point of the corrected feature points. Based on the head point of the corrected feature points and the corrected feature points adjacent to the head point, a straight line, that is, a first straight line, can be determined. Similarly, based on the tail point of the corrected feature points and the corrected feature points adjacent to the tail point, a straight line, that is, a second straight line, can also be determined. At this time, the intersection of the first straight line and the second straight line can be calculated, and the intersection is taken as a new head point and tail point, that is, the coordinate data of the head point of the corrected feature points and the tail point of the corrected feature points is updated to the coordinate data corresponding to the intersection, so that the standard figure corresponding to the finally obtained standard path data is a closed figure.

[0179] Figure 13 A process diagram of head-tail closing is shown. As shown in Figure 13 the left half thereof shows two possible situations after slope correction that cause the figure to not be completely closed, that is, a gap can exist, or an extra line can exist. Taking the existence of a gap as an example, as shown in Figure 14 the right half thereof, a first straight line AB is determined according to the head point A of the corrected feature points and the adjacent corrected feature point B, a second straight line CD is determined according to the tail point C of the corrected feature points and the adjacent corrected feature point D, and then the intersection O of the first straight line AB and the second straight line CD is determined, and the coordinate data of the head point A of the corrected feature points and the tail point C of the corrected feature points is updated to the coordinate data corresponding to the intersection O, thereby obtaining a standard figure.

[0180] It should be noted that, since a triangle has particularity, it is impossible to have two horizontal or two vertical line segments, so after the triangle is corrected once, the next correction cannot be the same again; for example, after horizontal correction, the next correction is not allowed to be horizontal correction, but can be vertical correction.

[0181] In addition, optionally, if the original figure is a square, the above step b2 “standardization processing on the feature path data to generate standard path data of a standard figure” can further include the following process.

[0182] In the case where the original figure is closed and the category of the original figure is a square, after the slope correction in step b226 and the head-tail merging processing in step b227, if the processed figure is not a square, the long side length RL and the short side length RS of the processed figure are determined.

[0183] Take one of the corrected feature points as the first reference point, and take the remaining three corrected feature points in turn as the second reference point, the third reference point and the fourth reference point in a counterclockwise or clockwise direction. And determine the amplitude Δd that needs to be adjusted, and Δd = RL - RS.

[0184] And the correction of the figure is divided into enlargement processing and reduction processing. When the enlargement processing is performed, the horizontal coordinate (short side horizontal) or the vertical coordinate (short side vertical) of one corrected feature point corresponding to the short side is increased by the amplitude Δd. When the reduction processing is performed, the horizontal coordinate (short side horizontal) or the vertical coordinate (short side vertical) of one corrected feature point corresponding to the long side is reduced by the amplitude Δd.

[0185] As shown in the left half part of FIG. 4, take the first reference point A as an example, if the first reference point A and the second reference point B are in the horizontal direction: Figure 14

[0186] As shown in the right half part of FIG. 4, take the first reference point A as an example, if the first reference point A and the second reference point B are in the vertical direction: Figure 14

[0187] When r2 > r1, if x1 > x0, modify x1 = x1 + Δd, x2 = x2 + Δd; if x1 < x0, modify x1 = x1 - Δd, x2 = x2 - Δd, or modify the coordinates of the first reference point A.

[0188] When r2 < r1, if y2 > y1, modify y2 = y2 + Δd, y3 = y3 + Δd; if y2 < y1, modify y2 = y2 - Δd, y3 = y3 - Δd, or modify the coordinates of the fourth reference point D.

[0189] As shown in the left half part of FIG. 4, take the first reference point A as an example, if the first reference point A and the second reference point B are in the horizontal direction: Figure 15

[0190] When r2 > r1, if y1 > y0, modify y1 = y1 + Δd, y2 = y2 + Δd; if y1 < y0, modify y1 = y1 - Δd, y2 = y2 - Δd.

[0191] When r2 < r1, if x2 > x1, modify x2 = x2 + Δd, x3 = x3 + Δd; if x2 < x1, modify x2 = x2 - Δd, x3 = x3 - Δd.

[0192] In addition, if the original figure is a parallelogram or a trapezoid, after the slope correction and the head-tail closing processing, the parallelogram or the trapezoid can also be further corrected.

[0193] Specifically, as shown in FIG. 5, take the first reference point A as an example, if the first reference point A and the second reference point B are in the horizontal direction: Figure 15 ​​​As shown in the left half, for a parallelogram, the slope k of a side AD is calculated, and the distance of AD is r4; for the other side of point B, a line segment with slope k and length r4 is calculated, and the new coordinates of point C are calculated. After correction, the connection is reconnected, and a more parallel figure is obtained, and the figure type is recorded as a parallelogram.

[0194] As shown in the left half, for a parallelogram, the slope k of a side AD is calculated, and the distance of AD is r4; for the other side of point B, a line segment with slope k and length r4 is calculated, and the new coordinates of point C are calculated. After correction, the connection is reconnected, and a more parallel figure is obtained, and the figure type is recorded as a parallelogram. Figure 16 As shown in the right half, for a trapezoid, the slope k of a parallel side AB is calculated, and the distance of the other parallel side CD is r3. A line segment with slope k and length r3 is calculated through point C, and the new coordinates of point D are calculated. After correction, the connection is reconnected, and a more standard trapezoid is obtained, and the figure type is recorded as a trapezoid.

[0195] The figure processing method provided in the embodiment can effectively and quickly identify and correct a hand-drawn basic figure, supports common figures such as a circle, an ellipse, a triangle, a square, a rectangle, a parallelogram, an angle, and a straight line, has fast identification speed and good performance, can immediately correct and display after hand-drawing, and has good user experience. The method can also be combined with an open source figure library Skia, and cross-platform use can be easily realized.

[0196] In the embodiment, a figure processing apparatus is also provided, which is used to implement the above-described embodiments and preferred embodiments, and will not be described again. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementation of hardware, or a combination of software and hardware, is also possible and contemplated.

[0197] The embodiment provides a figure processing apparatus, as shown in the figure, Figure 17 The apparatus includes:

[0198] The acquisition module 1601 is configured to acquire original path data of an original figure, and the original path data includes coordinate data of a plurality of original points.

[0199] The point supplement processing module 1602 is configured to perform point supplement processing on the original path data to generate extended path data of an extended figure, and the extended path data includes coordinate data of a plurality of extended points, and the extended points include the original points and supplement points obtained through point supplement processing.

[0200] The distance calculation module 1603 is configured to determine the minimum distance between two extended points according to the coordinate data of each extended point in the extended path data.

[0201] The correction module 1604 is configured to: in a case where the minimum distance is less than a first preset distance, determine that the original graph is closed, and take two extension points corresponding to the minimum distance as a start point and an end point of a corrected graph, and generate corrected path data of the corrected graph; in a case where the minimum distance is greater than the first preset distance, determine that the original graph is not closed, and take the original path data or the extension path data as the corrected path data of the corrected graph.

[0202] The standardization module 1605 is configured to perform standardization processing on the corrected path data, and determine standard path data used to generate and display a standard graph.

[0203] In some optional embodiments, the point supplementing module 1602 performs point supplementing processing on the original path data, including:

[0204] In a case where a distance between two adjacent original points is greater than a second preset distance, at least one supplement point is inserted between the two adjacent original points according to a preset supplement point interval, and the supplement point interval is less than or equal to the second preset distance.

[0205] In some optional embodiments, the distance calculation module 1603 determines the minimum distance between two extension points according to coordinate data of each extension point in the extension path data, including:

[0206] The extension points are sequentially taken as a first point that needs to perform a query operation according to a drawing order, and the query operation is performed on the first point until a termination condition is met;

[0207] A minimum value in distances determined by all the query operations is taken as the minimum distance between the two extension points;

[0208] The query operation includes:

[0209] Distances between the first point and each second point are determined respectively, and the second point is another extension point after the first point;

[0210] A minimum value in the distances between the first point and each second point is taken as a tentative distance determined by the query operation.

[0211] In some optional embodiments, the termination condition is met in a case where a number of extension points between the first point and a last extension point is less than or equal to a preset number;

[0212] The second point is another extension point after the first point, and a number of extension points between the second point and the first point is greater than or equal to a preset number.

[0213] In some optional embodiments, the standardization module 1605 standardizes the modified path data to determine standard path data for generating and displaying a standard graph, including:

[0214] contracting the modified path data, determining feature points in the modified path data related to a graph feature, and generating feature path data of a feature graph; the feature path data includes coordinate data of the feature points;

[0215] standardizing the feature path data to generate standard path data of a standard graph.

[0216] In some optional embodiments, the standardization module 1605 standardizes the feature path data to generate standard path data of a standard graph, including:

[0217] In the case that the original graph is closed, determining a graph category of the original graph according to the feature path data;

[0218] According to the graph category of the original graph, performing corresponding standardization processing on the feature path data to generate standard path data of a standard graph.

[0219] In some optional embodiments, the standardization module 1605 performs corresponding standardization processing on the feature path data according to the graph category of the original graph to generate standard path data of a standard graph, including:

[0220] In the case that the original graph is closed and the graph category of the original graph is an ellipse, determining coordinate data of a first center point of the feature graph according to coordinate data of the feature points in the feature path data;

[0221] According to the coordinate data of the feature points and the first center point, calculating distances between the first center point and each of the feature points, and taking a feature point corresponding to a maximum distance as a first major axis point;

[0222] determining distances between other feature points and a major axis line, and taking an other feature point corresponding to a minimum distance as a second major axis point; the major axis line is a straight line determined by the first center point and the first major axis point, and a distance between the first major axis point and the second major axis point is a major axis length;

[0223] taking a midpoint between the first major axis point and the second major axis point as a second center point, and determining a minimum value of distances between the second center point and each of the feature points, and taking twice the minimum value as a minor axis length;

[0224] The second center point is taken as a center of a standard ellipse pattern, and coordinates of a standard point on the standard ellipse pattern are determined according to the long axis length and the short axis length, and standard path data of the standard pattern is generated.

[0225] In some optional embodiments, the standardization module 1605 performs corresponding standardization processing on the feature path data according to the pattern category of the original pattern, to generate standard path data of a standard pattern, including:

[0226] In a case where the original pattern is closed and the pattern category of the original pattern is a non-circle pattern, a line segment between two adjacent feature points in the feature path data is taken as a to-be-processed line segment, and slope correction processing is performed on the to-be-processed line segment, to determine coordinate data of a corrected feature point.

[0227] In a case where the first point and the second point of the corrected feature point are different, a first straight line is determined according to the first point of the corrected feature point and an adjacent corrected feature point, a second straight line is determined according to the second point of the corrected feature point and an adjacent corrected feature point, an intersection of the first straight line and the second straight line is determined, coordinate data of the first point of the corrected feature point and the second point of the corrected feature point are updated to coordinate data corresponding to the intersection, and standard path data of the standard pattern is generated.

[0228] In some optional embodiments, the standardization module 1605 performs standardization processing on the feature path data to generate standard path data of a standard pattern, and further includes:

[0229] In a case where the original pattern is not closed, a line segment between two adjacent feature points in the feature path data is taken as a to-be-processed line segment, and slope correction processing is performed on the to-be-processed line segment, to determine coordinate data of a corrected feature point.

[0230] The corrected feature point is taken as a standard point on a standard pattern, and standard path data of the standard pattern is generated.

[0231] In some optional embodiments, the standardization module 1605 performs slope correction processing on the to-be-processed line segment, including:

[0232] For a first feature point and a second feature point at two ends of the to-be-processed line segment, slopes corresponding to the first feature point and the second feature point are determined.

[0233] In a case where an absolute value of the slope is less than a first preset value, a vertical coordinate of the second feature point is updated to a vertical coordinate of the first feature point.

[0234] When the absolute value of the slope is greater than a second preset value, the horizontal coordinate of the second feature point is updated to the horizontal coordinate of the first feature point; the second preset value is greater than the first preset value.

[0235] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0236] The graphics processing device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, including a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0237] The embodiment of the present invention also provides a computer device having the above Figure 17 The graphics processing device shown.

[0238] See also Figure 17 , Figure 17 is a structural diagram of a computer device provided by an optional embodiment of the present invention, such as Figure 17 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components utilize different buses to communicate with each other and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of a GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Equally, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). ​ A processor 10 is taken as an example.

[0239] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.

[0240] The memory 20 stores instructions that can be executed by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0241] The memory 20 can include a program storage area and a data storage area. The program storage area can store an operating system, application programs required for at least one function, etc. The data storage area can store data created according to the use of the computer device, etc. The memory 20 can include a high-speed random access memory, and can also include a non-transitory memory such as at least one disk storage device, a flash memory device, or other non-transitory solid state memory device. In some alternative embodiments, the memory 20 can optionally include memory that is remotely located with respect to the processor 10, and that can be connected to the computer device through a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communications network, and combinations thereof.

[0242] The memory 20 can include a volatile memory, such as a random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid state memory device. The memory 20 can also include a combination of the above-mentioned types of memory.

[0243] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.

[0244] The embodiments of the present application also provide a computer readable storage medium. The above-mentioned method according to the embodiments of the present application can be implemented in hardware, firmware, or recorded in a storage medium, or stored in a remote storage medium or a non-transitory machine readable storage medium and downloaded through network and stored in a local storage medium, so that the method described herein can be processed by such software on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, or a solid state disk, etc. Further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that the computer, the processor, the microprocessor controller, or the programmable hardware includes a storage component that can store or receive software or computer code, when the software or computer code is accessed and executed by the computer, the processor, or the hardware, the method shown in the above embodiments is implemented.

[0245] Part of the present application can be applied as a computer program product, for example, computer program instructions, when executed by a computer, through the operation of the computer, the method and / or technical solutions according to the present application can be called or provided. Those skilled in the art should understand that the form of computer program instructions in computer readable medium includes but is not limited to source file, executable file, installation package file and the like, and accordingly, the way of computer program instructions executed by computer includes but is not limited to: the computer directly executes the instructions, or the computer compiles the instructions and then executes the corresponding compiled program, or the computer reads and executes the instructions, or the computer reads and installs the instructions and then executes the corresponding installed program. Here, the computer readable medium can be any available computer readable storage medium or communication medium accessible to the computer.

[0246] Although the embodiments of the present application are described in conjunction with the drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present application, and such modifications and changes should be covered within the protection scope of the present application.

Claims

1. A method of graphics processing, the method comprising: The method comprises: acquiring original path data of an original graph; the original path data comprises coordinate data of a plurality of original points; performing point supplement processing on the original path data to generate extended path data of an extended graph; the extended path data comprises coordinate data of a plurality of extended points, the extended points comprising the original points and supplement points obtained through the point supplement processing; determining a minimum distance between two extended points according to coordinate data of each of the extended points in the extended path data; the number of extended points between the two extended points exceeds a number threshold; in a case where the minimum distance is less than a first preset distance, determining that the original graph is closed, and taking the two extended points corresponding to the minimum distance as a start point and an end point of a corrected graph to generate corrected path data of the corrected graph; in a case where the minimum distance is greater than the first preset distance, determining that the original graph is not closed, and taking the original path data or the extended path data as corrected path data of a corrected graph; performing standardization processing on the corrected path data to determine standard path data used to generate and display a standard graph; wherein the point supplement processing on the original path data comprises: for two adjacent original points, in a case where a distance between the two adjacent original points is greater than a second preset distance, inserting at least one supplement point between the two adjacent original points according to a preset supplement point spacing; the supplement point spacing is less than or equal to the second preset distance.

2. The method of claim 1, wherein, The determination of the minimum distance between two extended points according to the coordinate data of each of the extended points in the extended path data comprises: sequentially taking an extended point as a first point on which a query operation needs to be performed according to a drawing order, and performing the query operation on the first point until a termination condition is met; taking a minimum value among distances determined by all the query operations as the minimum distance between the two extended points; wherein the query operation comprises: determining distances between the first point and each second point respectively; the second point is another extended point after the first point; taking a minimum value among the distances between the first point and each second point as a tentative distance determined by the query operation.

3. The method of claim 2, wherein: the termination condition is met in a case where the number of extended points between the first point and a last extended point is less than or equal to a preset number; the second point is another extended point after the first point and having a number of extended points between the first point and the second point greater than or equal to the preset number; the preset number is a minimum number indicating closure of a graph.

4. The method of claim 1, wherein, The standardization processing on the corrected path data to determine the standard path data used to generate and display a standard graph comprises: performing contraction processing on the corrected path data to determine feature points related to a graph feature in the corrected path data, and generating feature path data of a feature graph; the feature path data comprises coordinate data of the feature points; performing standardization processing on the feature path data to generate the standard path data of the standard graph.

5. The method of claim 4, wherein, The standardization processing on the feature path data comprises: In the case that the original graph is closed, determining a graph category of the original graph according to the feature path data; According to the graph category of the original graph, performing corresponding standardization processing on the feature path data to generate the standard path data of the standard graph.

6. The method of claim 5, wherein, The standardization processing on the feature path data comprises: In the case that the graph category of the original graph is an ellipse, determining coordinate data of a first center point of the feature graph according to coordinate data of the feature points in the feature path data; According to the coordinate data of the feature points and the first center point, calculating distances between the first center point and each of the feature points, and taking a feature point corresponding to a maximum distance as a first long axis point; Determining distances between other feature points and a long axis line, and taking an other feature point corresponding to a minimum distance as a second long axis point; the long axis line is a straight line determined by the first center point and the first long axis point, and a distance between the first long axis point and the second long axis point is a long axis length; Taking a midpoint between the first long axis point and the second long axis point as a second center point, determining a minimum value of distances between the second center point and each of the feature points, and taking double of the minimum value as a short axis length; Taking the second center point as a center of a standard ellipse graph, determining coordinate data of a standard point on the standard ellipse graph according to the long axis length and the short axis length, and generating the standard path data of the standard graph.

7. The method of claim 5, wherein, The standardization processing on the feature path data comprises: In the case that the graph category of the original graph is a non-circular graph, taking a line segment between two adjacent feature points in the feature path data as a to-be-processed line segment, and performing slope correction processing on the to-be-processed line segment to determine coordinate data of a corrected feature point; In the case that a head point of the corrected feature point is different from a tail point of the corrected feature point, determining a first straight line according to the head point of the corrected feature point and an adjacent corrected feature point, determining a second straight line according to the tail point of the corrected feature point and an adjacent corrected feature point, determining an intersection point of the first straight line and the second straight line, updating coordinate data of the head point of the corrected feature point and the tail point of the corrected feature point to coordinate data corresponding to the intersection point, and generating the standard path data of the standard graph.

8. The method of claim 5, wherein, The standardization processing on the feature path data further comprises: In the case that the original graph is not closed, taking a line segment between two adjacent feature points in the feature path data as a to-be-processed line segment, and performing slope correction processing on the to-be-processed line segment to determine coordinate data of a corrected feature point; Taking the corrected feature point as a standard point on a standard graph, and generating the standard path data of the standard graph.

9. The method according to claim 7 or 8, characterized in that The slope correction processing on the to-be-processed line segment comprises: For the first feature point and the second feature point at two ends of the to-be-processed line segment, a slope corresponding to the first feature point and the second feature point is determined; In a case where an absolute value of the slope is less than a first preset value, a longitudinal coordinate of the second feature point is updated as a longitudinal coordinate of the first feature point; In a case where the absolute value of the slope is greater than a second preset value, a transverse coordinate of the second feature point is updated as a transverse coordinate of the first feature point; the second preset value is greater than the first preset value.

10. A graphics processing device, characterized in that: The device comprises: An acquisition module is configured to acquire original path data of an original graph; the original path data comprises coordinate data of a plurality of original points; A point supplementing module is configured to perform point supplementing on the original path data to generate extended path data of an extended graph; the extended path data comprises coordinate data of a plurality of extended points, the extended points comprising the original points and supplement points obtained through point supplementing; A distance calculation module is configured to determine a minimum distance between two extended points according to coordinate data of the extended points in the extended path data; the number of extended points spaced between the two extended points exceeds a number threshold; A correction module is configured to, in a case where the minimum distance is less than a first preset distance, determine that the original graph is closed, and determine the two extended points corresponding to the minimum distance as a start point and an end point of a corrected graph to generate corrected path data of the corrected graph; in a case where the minimum distance is greater than the first preset distance, determine that the original graph is not closed, and use the original path data or the extended path data as corrected path data of a corrected graph; A standardization module is configured to perform standardization processing on the corrected path data to determine standard path data used to generate and display a standard graph; The point supplementing on the original path data comprises: For two adjacent original points, in a case where a distance between the two adjacent original points is greater than a second preset distance, at least one supplement point is inserted between the two adjacent original points according to a preset supplement point spacing; the supplement point spacing is less than or equal to the second preset distance.

11. A computer device, comprising: Comprise: A memory and a processor, which are communicatively connected with each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the method for processing a graph according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to make a computer execute the method for processing a graph according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Mask pattern correction method

    CN103376644A

  • Method and equipment for erasing writing path

    CN106325737A