Graph processing method and device, computer equipment and storage medium
By filling in points and correcting the original path data of hand-drawn graphics, the problem of hand-drawn graphics is solved, and automatic correction is realized as standard graphics is realized, which simplifies user operations and improves efficiency.
Patent Information
- Application Number
- CN202411866364.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-12-17
AI Technical Summary
Hand-drawn graphics are prone to problems of non-standardness, and are not beautiful enough, and it is difficult to automatically correct as standard graphics.
By obtaining the original path data of the original figure, performing point-complement processing to generate extension path data, determining the minimum distance between extension points, correcting the figure and standardizing the process to generate standard path data.
It realizes automatic correction of hand-drawn graphics, generates more standardized graphics, simplifies user drawing operations, and improves drawing efficiency.
Smart Images

Figure CN119784900A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, computer equipment and storage medium for graphics processing. Background Art
[0002] In scenarios such as remote conferencing and teaching, users (for example, teachers or students) can manually draw the geometric figures that need to be displayed on an electronic screen (such as an electronic whiteboard, etc.) (commonly including: straight lines, angles, triangles, squares, rectangles, parallelograms, trapezoids, ellipses, circles, etc.), but the figures drawn by hand are prone to non-standard problems and are not beautiful enough. Summary of the invention
[0003] In view of this, the present invention provides a method, apparatus, computer equipment and storage medium for processing graphics to solve the problem of non-standard hand-drawn graphics.
[0004] In a first aspect, the present invention provides a method for graphics processing, comprising:
[0005] Acquire original path data of an original graphic; the original path data includes coordinate data of a plurality of original points;
[0006] Performing point-filling processing on the original path data to generate extended path data of the extended graph; the extended path data includes coordinate data of a plurality of extended points, and the extended points include the original points and supplementary points obtained by the point-filling processing;
[0007] Determine the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data;
[0008] In the case where the minimum distance is less than the first preset distance, determining that the original figure is closed, and using the two extension points corresponding to the minimum distance as the first point and the last point of the corrected figure to generate corrected path data of the corrected figure;
[0009] In the case where the minimum distance is greater than a first preset distance, determining that the original graph is not closed, and using the original path data or the extended path data as corrected path data of the corrected graph;
[0010] The corrected path data is standardized to determine standard path data for generating and displaying a standard graph.
[0011] In a second aspect, the present invention provides a graphics processing device, comprising:
[0012] An acquisition module, used to acquire original path data of an original graphic; the original path data includes coordinate data of a plurality of original points;
[0013] A point-adding processing module is used to perform point-adding processing on the original path data to generate extended path data of the extended graph; the extended path data includes coordinate data of a plurality of extended points, and the extended points include the original points and the supplementary points obtained by the point-adding processing;
[0014] A distance calculation module, used to determine the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data;
[0015] A correction module, configured to determine that the original figure is closed when the minimum distance is less than a first preset distance, and use the two extended points corresponding to the minimum distance as the first point and the last point of the corrected figure to generate corrected path data of the corrected figure; and determine that the original figure is not closed when the minimum distance is greater than the first preset distance, and use the original path data or the extended path data as the corrected path data of the corrected figure;
[0016] The standardization module is used to perform standardization processing on the corrected path data and determine standard path data for generating and displaying a standard graphic.
[0017] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the graphics processing method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0018] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the graphics processing method of the first aspect or any corresponding embodiment thereof.
[0019] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the graphics processing method of the first aspect or any corresponding embodiment thereof.
[0020] The present invention corrects and standardizes the original path data collected when the user draws the graphics, automatically corrects the original graphics to a more standardized standard graphics, and the user can draw a standard geometric figure simply and quickly without the need for repeated adjustments by the user, thereby simplifying the user's drawing operation and improving the drawing efficiency. The original path data is firstly processed with points, and the graphics are corrected based on the data after the point-filling processing, and redundant lines are removed, so that the subsequent standardization processing can avoid the abnormality of the generated standard graphics due to hand-drawing problems, and the correction effect of the graphics can be guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 is a flowchart of a method for graphics processing according to an embodiment of the present invention;
[0023] Figure 2 is a schematic diagram of an original graphic when a user draws a square according to an embodiment of the present invention;
[0024] Figure 3 is a schematic diagram of correcting an extended graph according to an embodiment of the present invention;
[0025] Figure 4 is a processing flow chart for realizing image correction based on different systems according to an embodiment of the present invention;
[0026] Figure 5 is a flowchart of another method for graphics processing according to an embodiment of the present invention;
[0027] Figure 6 is a schematic diagram of a point filling process according to an embodiment of the present invention;
[0028] Figure 7 is a schematic diagram of performing traversal processing on an extended graph according to an embodiment of the present invention;
[0029] Figure 8 is a schematic diagram of a shrinking process according to an embodiment of the present invention;
[0030] Fig. 9 is another schematic diagram of a shrinking process according to an embodiment of the present invention;
[0031] Fig.10 is a schematic diagram of a merging process according to an embodiment of the present invention;
[0032] Fig.11 is a schematic diagram of a process for generating a standard ellipse according to an embodiment of the present invention;
[0033] Fig.12 is a schematic diagram of performing slope correction on an angle graph according to an embodiment of the present invention;
[0034] Fig.13 is a schematic diagram of a process of end-to-end closure according to an embodiment of the present invention;
[0035] Fig.14 is a schematic diagram of correcting a square according to an embodiment of the present invention;
[0036] Fig.15 is a schematic diagram of correcting a parallelogram and a trapezoid according to an embodiment of the present invention;
[0037] Fig.16 is a structural block diagram of a device for graphics processing according to an embodiment of the present invention;
[0038] Fig.17 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0040] Skia is an open source 2D graphics library, which is widely used in graphics rendering. It is a cross-platform graphics library that supports multiple operating systems. It is the core 2D graphics rendering engine of the system and is responsible for handling almost all graphics drawing tasks, including user interface, animation, text, image, etc. When users draw graphics by hand, they can also use the Path class provided by the system SDK (Software Development Kit) to record data and draw. In fact, the underlying implementation of the Path class is also implemented using Skia's SkPath, which can be obtained through reflection.
[0041] For example, when a user draws a geometric figure on an electronic screen by hand using a mouse, stylus, or finger, the Path class can be used to record the drawing path data of the figure. This data is usually in the form of a series of point coordinates, which are arranged in chronological order. The coordinate data of these points represent the path that the user moves his 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 hand-drawn graphics of the user, the graphics can be standardized based on the characteristics of the hand-drawn graphics of the user, so that a standard graphics can be generated; for example, a circle-like graphic drawn by the user can be standardized into a standard circle, so that the user can draw a standard graphic by hand. However, since the hand-drawn graphics are more complicated, especially at the end of the drawn lines, deviations are prone to occur, which affects the subsequent correction effect.
[0043] A method for graphics processing provided by an embodiment of the present invention first performs point-filling processing on the collected data, and then performs preliminary correction on the graphics based on the data after the point-filling processing to remove redundant lines, thereby ensuring that the generated standard graphics are avoidable due to hand-drawing problems during subsequent standardization processing, thereby ensuring the correction effect of the graphics.
[0044] According to an embodiment of the present invention, an embodiment of a method for graphics processing is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a 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 this embodiment, a method for graphics processing is provided, which can be applied to devices capable of collecting and drawing path data, such as electronic whiteboards, and can also be applied to servers that perform unified control of devices such as electronic whiteboards. The server performs graphics correction based on the path data uploaded by the electronic whiteboard to generate a standard graphics. Figure 1 is a flowchart of a method for graphics processing according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps.
[0046] Step S101, obtaining original path data of an original graphic; the original path data includes coordinate data of a plurality of original points.
[0047] As mentioned above, when a user draws a primitive geometric figure on an electronic screen by hand using a mouse, stylus, finger, etc., the Path class can be used to record the drawing path data of the figure. For the convenience of distinguishing descriptions, the figure drawn by the user is called the primitive figure, and the recorded drawing path data is called the primitive path data.
[0048] The original path data includes coordinate data of a series of points arranged in time sequence, and the points are called original points.
[0049] Figure 2 A schematic diagram of an original graphic when a user draws a square by hand is shown. The graphic corresponds to a drawing path. The points on the drawing path are the original points. 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 graphic with a single stroke or multiple strokes, the original path data may include data of a single path or data of multiple paths, that is, the arrays of multiple paths are combined into one path to form the original path data. For example, for two consecutive paths, if the starting point or end point of one path is close to a point in the starting point or end point of the other path (for example, the distance between the two is less than a preset value), it can be considered that the two paths can be integrated into one path.
[0051] Step S102, performing point-filling processing on the original path data to generate extended path data of the extended graph; the extended path data includes coordinate data of a plurality of extended points, and the extended points include original points and supplementary points obtained by the point-filling processing.
[0052] In this embodiment, since the original hand-drawn graphics are not standard, there may be problems such as not strictly closed or redundant lines due to intersections, which need to be corrected. The number and density of original points in the original path data are related to the user's drawing speed, the sampling frequency of the electronic screen, etc., resulting in the distance between some original points being relatively far; in order to ensure the subsequent correction effect, this embodiment first performs point filling processing on the original path data.
[0053] Specifically, by performing point-adding processing on the original path data, a new point can be inserted between two adjacent original points. Such a point is subsequently referred to as a "add-on point". Both the original point and the inserted add-on point are used as extension points, thereby generating path data including coordinate data of multiple extension points, i.e., extended path data. For example, the coordinate data of the newly added add-on point can be added to the original path data, thereby generating extended path data.
[0054] It can be understood that the extended points are points with a greater number than the original points and are more capable of accurately representing the shape of the graphic.
[0055] Step S103: determining the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data.
[0056] In this embodiment, the extended path data includes multiple extended points. For any two extended points, the distance between the two extended points can be determined. The distance is calculated based on the coordinate data of the two extended points. For example, the coordinate data of an extended point is (x 1 ,y 1 ), the coordinate data of another extension point is (x 2 ,y 2 ), then the distance d between the two extension points is:
[0057]
[0058] By comparing the sizes of various distances d, the minimum distance among them can be determined.
[0059] In the case where the 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] In general, a quantity threshold can be set. If the number of expansion points between two expansion points exceeds the quantity threshold, the distance between the two expansion points is calculated. Otherwise, the distance between the two expansion points does not need to be calculated, so as to minimize the influence of adjacent expansion points. The quantity threshold can be a preset fixed value, such as 10, 20, etc.; or, the number corresponding to a certain proportion (such as 2 / 3) of the total number of expansion points can be used as the quantity threshold. The quantity threshold determined based on the proportion can adapt to graphics of different sizes.
[0061] The minimum distance between the extension points is used to determine whether there is a closed position in the extended figure; if the minimum distance is less than a preset distance threshold (i.e., the first preset distance described below), it can be considered that the extended figure has a closed position, it is a closed image, and the original figure is also closed accordingly. For example, the number threshold is 2 / 3 of the total number of extension points. If the minimum distance between the extension points is less than the distance threshold, it can be said that most of the paths in the figure are closed. Otherwise, it may be a figure that the user draws casually, and there is no closed position at this time.
[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 point and the last point 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 the threshold is used as the first preset distance. By comparing the size relationship between the minimum distance and the first preset distance, it can be determined whether the graphic is closed. The first preset distance can be set based on business needs, for example, it can be set according to pixel points, for example, the first preset distance is set to 30px; or, the first preset distance can be dynamically set according to the number of extension points to meet the needs of processing paths of different sizes and improve the recognition rate.
[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, 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, 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] Among them, if the original figure is closed, the two extension points corresponding to the minimum distance are taken as the first point and the last point; it can be understood that the extension point with the earlier time among the two extension points is the first point, and the extension point with the later time is the last point.
[0066] The graph formed by the first point and the last point is called a correction graph, and the path data corresponding to the correction graph is the correction path data, which includes the coordinate data of multiple correction points. It can be understood that, on the basis of the extended graph, the extended points before the first point and the extended points after the last point are deleted to obtain the correction graph; accordingly, for the extended path data, the coordinate data of the extended points before the first point are deleted, and the coordinate data of the extended points after the last point are deleted, and the remaining extended points (including the first point and the last point) are all correction points, thereby obtaining the correction path data.
[0067] Figure 3 A schematic diagram of correcting the extended graph is shown. Figure 3 As shown, by deleting the redundant extension points at the beginning and end of the extended graph, a modified graph without redundant points can be generated.
[0068] Step S105: when the minimum distance is greater than the first preset distance, it is determined that the original figure is not closed, and the original path data or the extended path data is used as the corrected path data of the corrected figure.
[0069] In this embodiment, if the original graphic (or extended graphic) is not closed, it can be considered that the extended graphic does not have any redundant lines, and no correction is required. The original graphic or extended graphic can be directly used as the corrected graphic, that is, the original path data or the extended path data is used as the corrected path data of the corrected graphic.
[0070] Step S106, standardizing the corrected path data to determine standard path data for generating and displaying a standard graph.
[0071] In this embodiment, as described above, regardless of whether the figure is closed or not, the correction path data corresponding to the correction figure can be determined, and the correction path data includes the coordinate data of multiple correction points. Then, standardization processing is performed based on the correction path data to correct the correction figure to a figure that meets the standard, that is, a standard figure, so that the standard path data of the standard figure can be determined; electronic screens and other devices can generate and display the corresponding standard figure based on the standard path data. Figure 3 As shown, the rectangular figure hand-drawn by the user can be corrected into a standard rectangle.
[0072] Since Skia supports multiple operating systems, the correction and standardization process provided in this embodiment can be combined with Skia, so that cross-platform docking can be better achieved. Figure 4 The processing flow chart for implementing graphic correction based on different systems is shown. Taking the Android system as an example, a user draws a geometric figure on the electronic screen, uses the Path class provided by the Android system to connect and obtain the drawing path data, and then obtains the SkPath data through reflection. The SkPath data can be used as the original path data, and is corrected and standardized based on the method provided in this embodiment, and finally a corrected standard figure is obtained. After the correction is completed, the interface is refreshed to draw the Path path, and the interface immediately displays the corrected standard figure.
[0073] The graphics processing method provided in this embodiment corrects and standardizes the original path data collected when the user draws the graphics, and automatically corrects the original graphics to a more standardized standard graphics. The user can draw a standard geometric figure simply and quickly without the need for repeated adjustments by the user, which simplifies the user's drawing operation and improves the drawing efficiency. The original path data is firstly processed with points, and the graphics are corrected based on the data after the point-filling processing, and redundant lines are removed, so that the subsequent standardization processing can avoid abnormalities in the generated standard graphics due to hand-drawing problems, and the correction effect of the graphics can be guaranteed.
[0074] In this embodiment, another method of graphics processing is provided, which can be applied to devices capable of collecting and drawing path data, such as electronic whiteboards, and can also be applied to servers that perform unified control of devices such as electronic whiteboards. The server performs graphics correction based on the path data uploaded by the electronic whiteboard to generate a standard graphics. Figure 5 is a flowchart of a method for graphics processing according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps.
[0075] Step S501, obtaining original path data of an original graphic; the original path data includes coordinate data of a plurality of original points.
[0076] For details, please see Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0077] Step S502, performing point-filling processing on the original path data to generate extended path data of the extended graph; the extended path data includes coordinate data of a plurality of extended points, and the extended points include original points and supplementary points obtained by the point-filling processing.
[0078] For details, please see Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0079] In some optional implementations, the above step S502 of "adding points to the original path data" may specifically include the following steps a1.
[0080] Step a1, for two adjacent original points, when the distance between the two adjacent original points is greater than the second preset distance, at least one supplementary point is inserted between the two adjacent original points according to the 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, traverse in chronological order, and determine whether the distance between two adjacent original points is greater than the second preset distance. If the distance between 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 patch point spacing may be set, and corresponding patch points may be inserted according to the patch point spacing, so that the distance between the original point and an adjacent patch point, or the distance between two adjacent patch points, does not exceed the patch point spacing. The patch point spacing is less than or equal to the second preset distance, and generally, the two may be equal, that is, one distance value may be set.
[0084] Figure 6 A schematic diagram of the point filling process is shown in FIG. Figure 6 As shown in the figure, the black circle in the original figure is the original point, and the black curve is a hand-drawn curve. The original points can be connected by Bezier, and then the filling points are inserted in a linear transition manner with the filling point spacing as the interval length. When the filling points are completed, all the filling points and the original points form new path data, that is, the extended path data.
[0085] In this embodiment, the original points are supplemented according to the preset supplementary point spacing, and the spacing between the points can be shortened as needed, thereby improving data accuracy and facilitating more accurate correction later.
[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 in sequence as the first points on which a query operation needs to be performed in accordance with 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 extended points, and the extended points in the sequence are arranged in chronological order. For the sequence formed by the extended points, the positive order from the first to the last, or the positive order from the last to the first, can be used as the drawing order, that is, the drawing order can be the forward order when the user draws the graphics, or it can be the reverse order corresponding to the drawing of the graphics, which is not limited in this embodiment.
[0090] For the convenience of description, the first extension point is called the starting point, and the last extension point is called the ending point.
[0091] In this embodiment, starting from the starting point, the preset query operation is performed on demand for each extension point until the end condition is met, and then the query operation is no longer required. In order to facilitate the distinction and description, the extension point where the query operation is performed is called the first point. It can be understood that the initial first point is the starting point; and the end condition corresponding to the first point is called the first end condition.
[0092] The query operation specifically includes: taking other extended points after the first point as second points, and determining the distance between the first point and each second point respectively; taking the minimum value of the distance between the first point and each second point as the pending 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. For ease of description, these other extension points are referred to as second points. Based on this, the distance between the first point and the second point is determined, and the minimum value is taken out. The minimum value is the pending distance determined by this query operation. That is, for each first point, the corresponding pending distance can be determined.
[0094] For example, the query operation specifically includes: starting from the end point, in the order opposite to the drawing order, taking the extension points as the second points in turn, and determining the distance between each second point and the first point until the second end condition is met; taking the minimum value of the distance between each second point and the first point as the pending distance determined by this query operation.
[0095] In this embodiment, in order to find the closing point that makes the figure closed, or the intersection of the figure, the expansion points are traversed from front to back, and each traversal is also traversed from back to front, so that the two expansion points closest to each other are found quickly and accurately based on the double traversal.
[0096] Specifically, according to the drawing order, a corresponding index (serial number) is set for each extension point in turn; if the number of extension points is size, the indexes of these extension points can be 1, 2, 3, ..., size in turn, where the extension point with an index of 1 is the starting point, and the extension point with an index of size is the ending point.
[0097] First, take extension point 1 as the first point and perform a query operation, that is, starting from extension point size (end point), in the order of extension point size, extension point size-1, and extension point size-2, take each extension point as the second point and determine the distance between it and the first point, that is, calculate the distance between extension point 1 and extension point size, the distance between extension point 1 and extension point size-1, the distance between extension point 1 and extension point size-2, and so on.
[0098] When the second end condition is met, the distance between the second point and the first point is no longer calculated, and the minimum value of the distances determined by this query operation is taken out, and the minimum value is the distance to be determined. For example, if the distance between extension point 1 and extension point size-2 is the smallest, the distance to be determined is the distance between extension point 1 and extension point size-2.
[0099] Similarly, the extension point after extension point 1 is taken as the new first point, that is, extension point 2 is taken as the new first point, and the query operation is performed again, that is, the distance between extension point 2 and extension point size, the distance between extension point 2 and extension point size-1, the distance between extension point 2 and extension point size-2, etc. are calculated in sequence until the second end condition is met and the pending distance of this time is determined. For example, if the distance between extension point 2 and extension point size-1 is the smallest, the pending distance is the distance between extension point 2 and extension point size-1.
[0100] Afterwards, extension point 3, extension point 4, etc. can also be used as new first points, and query operations are performed. When the first end condition is met, the entire traversal process ends. Through multiple query operations, the minimum distance between multiple first points and corresponding extension points can be determined, that is, the to-be-determined distance.
[0101] Step S5032: taking the minimum value of the pending distances determined by all query operations as the minimum distance between two extension points.
[0102] In this 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 these pending distances, and the minimum value is the minimum distance that can be determined by all extension points.
[0103] Optionally, two end conditions can be set based on the number of extension points. Specifically, the first end condition is satisfied when the number of extension points between the first point and the end point is less than or equal to a preset number; and the second point is another extension point after the first point and the number of extension points between the second point and the end point is greater than or equal to a preset number. The preset number is the minimum number indicating that the graphic is closed.
[0104] In this embodiment, if the original figure is a closed figure, the ratio pl of the path length of the closed figure to the total path length can be set to be greater than the minimum value MIN_PL, and the minimum value MIN_PL can be adjusted as needed, for example, MIN_PL = 3 / 5. The ratio pl can describe the effective closed range. If pl is too small, it is considered that the closed effective range does not constitute a closed figure. Since the extension points in the extended figure are generated based on the insertion of supplementary points, the distances between the extension points are relatively close. 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 ratio pl can be simplified to 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), then the number of other extension points between the two extension points should not be 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] Accordingly, the minimum number of closed graphs, i.e. the preset number, can be set to size*MIN_PL.
[0107] When traversing, the first end condition is set to determine whether the number of extension points between the first point and the end point is less than or equal to the preset number. If it is less than or equal to the preset number, it means that the distance between the first point and the end point is relatively close at this time. Even if the distance between the two is small, it cannot be regarded as a closing point that makes the figure closed.
[0108] Moreover, when determining the second point, only other extension points whose number of extension points between the first point and the first point is greater than or equal to the preset number are used as the second point, that is, there is no need to use the extension point that is closer to the first point as the second point. This can not only reduce the amount of calculation, but also ensure that the calculated unknown distance or minimum distance can accurately indicate whether the figure is closed.
[0109] Similarly, the second end condition is set to determine whether the number of extension points between the second point and the first point is less than or equal to the preset number. If it is less than or equal to the preset number, it means that the distance between the second point at this time and the first point at this time is closer. Even if the distance between the two is small, it cannot be regarded as a closing point that makes the figure closed, so the loop can be ended.
[0110] Figure 7 Shows a schematic diagram of traversing an extended graph. As Figure 7 shown, the extended graph includes multiple extended points, and there are intersections in the graph. The extended points at the intersections can be used as closing points, that is, the starting point and the ending point of the corrected graph.
[0111] As Figure 7 shown, the total number of extended points is size, and their indices are 1, 2, 3, …, size in sequence. For the first point, traverse from front to back, and take the extended points 1, 2, 3, etc. as the first point in sequence. And, for a certain first point, also traverse from back to front, that is, take the extended 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 extended 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. It is required that pl_ds ≥ MIN_PL * size. If pl_ds < MIN_PL * size, 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, the index of the second point cannot be less than first_index + MIN_PL * size.
[0112] As Figure 7 described in the lower right corner, if the index of the first point first_index = 1, then the index of the second point last_index = 1 + pl_ds traversed, 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 the two. Figure 7 Shows the distance d between extended point 1 and extended point size. Among them, it can be compared with the set first preset distance. If d is less than the first preset distance, 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 indices of the two extended points with the smallest example d, that is, first_index and last_inedx, are found.
[0114] Similarly, after each query operation is completed, the number of extended points between the first point and the termination point can be determined. This number is size - first_index. If size - first_index < MIN_PL * size, the first end condition is satisfied, and the traversal process ends.
[0115] The indexes of the two extension points corresponding to the pending distance determined by each round of query operations can be saved, and the extension point corresponding to the minimum distance can be found after the traversal is completed; or, a variable for saving the indexes of the two extension points can be set. When the pending distance determined by this query operation is less than the pending distance stored in the variable, the variable is updated. If the pending distance determined by this query operation is greater, the variable remains unchanged. After the traversal is completed, the two indexes recorded in the variable are the indexes of the two extension points corresponding to the minimum distance. These two extension points are the first and last points of the corrected graph, thereby generating the corresponding corrected graph. For details, see Figure 7 shown.
[0116] It should be noted that in the first end condition and the second end condition of this embodiment, "the number of extension points is less than or equal to the preset number" includes three situations, namely: 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 to "the number of extension points < the preset number", when the number of extension points = the preset number, it is still necessary to traverse, that is, it is necessary to perform related query operations. When the end condition is set to "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 there is no need to perform query operations.
[0117] In this embodiment, the accuracy of the query result can be guaranteed by using two layers of traversal, from front to back and from back to front. In addition, the first end condition and the second end condition are set by using the minimum number of closed graphs, which can reduce the processing amount while ensuring that the final corrected graph meets the closed standard, effectively eliminate the interference of adjacent extension points, and accurately find the first and last points of the corrected graph.
[0118] Step S504, 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 point and the last point of the corrected figure to generate corrected path data of the corrected figure; the corrected path data includes coordinate data of multiple correction points.
[0119] For details, please see Figure 1 Step S104 of the illustrated embodiment will not be described in detail here.
[0120] Step S505: when the minimum distance is greater than the first preset distance, it is determined that the original figure is not closed, and the original path data or the extended path data is used as the corrected path data of the corrected figure.
[0121] For details, please see Figure 1 Step S105 of the illustrated embodiment will not be described in detail here.
[0122] Step S506, standardizing the corrected path data to determine standard path data for generating and displaying a standard graph.
[0123] For details, please see Figure 1 Step S106 of the illustrated embodiment will not be described in detail here.
[0124] In some optional implementations, the above step S506 of "standardizing the corrected path data to determine standard path data for generating and displaying a standard graphic" may include steps b1 to b2.
[0125] Step b1, performing shrinkage processing on the corrected path data, determining feature points in the corrected path data related to the graphic features, and generating feature path data of the feature graphic; the feature path data includes coordinate data of the feature points.
[0126] Step b2, standardizing the characteristic path data to generate standard path data of a standard graphic.
[0127] In this embodiment, there may be correction points in the correction path data that are not related to the graphic features, especially in the aforementioned process of point filling. By shrinking the correction path data, the correction points that are not related to the graphic features are deleted, and the remaining correction points related to the graphic features are used as feature points to generate feature path data of the corresponding feature graphic; the feature path data includes the coordinate data of the feature points. It can be understood that the feature point is also a kind of extension point, so the feature path data can be obtained by deleting the useless coordinate data in the correction path data. Subsequent standardization based on a small number of feature points can reduce the amount of computation and improve processing efficiency.
[0128] Specifically, the role of the shrinkage process is to linearize a nearly straight curve into a straight line by discarding the curved points.
[0129] Figure 8 A schematic diagram of the shrinking process is shown in FIG. Figure 8 As shown, the correction graph includes three correction points (black circles represent correction points); for three consecutive correction points, determine the angle between the three correction points ( Figure 8 If the angle is greater than the preset angle (e.g. 160°), or the offset angle is less than the preset angle (e.g. 20°), the three correction points are considered to be a straight line, and the middle correction point is irrelevant to the graphic features, so it can be discarded, and the final feature graphic is generated as follows: Figure 8 shown.
[0130] Fig. 9 Another schematic diagram of the shrinking process is shown in FIG. Fig. 9As shown, the correction graph includes six correction points. First, the 1st, 2nd, and 3rd correction points are judged whether the angle meets the discarding condition. If it does, the 2nd correction point is selected. Then the 3rd, 4th, and 5th correction points are judged. They do not meet the discarding condition, so they are retained. If there are less than three correction points, they will not be processed and will enter the next round of shrinking processing.
[0131] In the second round of shrinkage processing, the 1st, 2nd, and 3rd correction points (i.e., the 1st, 3rd, and 4th correction points before) meet the discarding condition, so the 2nd correction point is discarded. Then the 3rd, 4th, and 5th (i.e., the 4th, 5th, and 6th correction points before) are judged and they also meet the discarding condition, so the 4th correction point is discarded. The final feature graph is as follows: Fig. 9 shown.
[0132] After determining the characteristic path data of the characteristic graph, a small number of characteristic points can be used for standardization processing, which can greatly reduce the amount of data for standardization processing.
[0133] Among them, when the hand-drawing speed is slow, such as when turning, or the hand-drawing is slightly shaken, the correction points will be dense. According to the above shrinking process, these closer points will be retained; in order to reduce the impact of shaking, adjacent correction points can be merged. Specifically, the shrinking process in the above step b1 also includes merging processing, and the merged correction points can be used as feature points related to the graphic features.
[0134] The merging process may specifically include: after shrinking the corrected path data, determining the retained valid points, which are also a type of correction points; and then determining whether the distance between two adjacent valid points is less than a preset minimum merging distance, which may be set to a suitable value according to business needs, such as 30px. If the distance between two adjacent valid points is less than the minimum merging distance, the valid point with the earlier time is deleted, or the valid point with the later time is deleted.
[0135] Among them, it is necessary to always delete the valid points with earlier time, or always delete the valid points with later time, so as to clean up multiple consecutive valid points with close distance, and finally keep only one valid point. After merging, the points with closer turning points or those with closer points due to partial jitter will be further optimized to form straight lines.
[0136] Fig.10 A schematic diagram of the merging process is shown, wherein the left half is a graph after the shrinking process, and the other half is a graph generated after the merging process, which can be used as a characteristic graph.
[0137] Optionally, the above step b2 of "standardizing the characteristic path data to generate standard path data of a standard graphic" may specifically include steps b21 to b22.
[0138] Step b21, when the original graphic is closed, determine the graphic category of the original graphic according to the characteristic path data.
[0139] In this embodiment, the graphic category of the original graphic can be determined in combination with whether the graphic is closed. Specifically, if the original graphic is not closed, its graphic category may include line segments, angles, etc.; if the original graphic is closed, its graphic category may include triangles, squares, rectangles, parallelograms, trapezoids, ellipses, circles, etc., and can be distinguished based on the characteristics of various graphic categories. This embodiment does not limit the method of identifying graphic categories.
[0140] For example, after the shrinkage process, the number of feature points in ellipses and circles is generally larger, while the number of feature points in triangles, rectangles, etc. is smaller. Therefore, based on the number of feature points, it is possible to preliminarily distinguish whether the original figure is a curved closed figure such as an ellipse or a circle; further, if the original figure is an ellipse or a circle, it is possible to determine whether the original figure is a circle or an ellipse based on whether the distances between each feature point and the center are evenly distributed.
[0141] For example, if the original figure is an ellipse or a circle, the center of the feature figure can be determined, and the distance variance VR from each feature point to the center can be determined. When VR is less than the boundary value VE, it is considered that all points are evenly distributed and approximately a circle, that is, the original figure is a circle. On the contrary, if VR is greater than VE, it is an ellipse. Among them, the setting value of VE is set according to the business debugging, such as 40, or different values can be set according to the size of the distance mean, so that different error range limits are given for circles of different sizes.
[0142] Step b22, performing corresponding standardization processing on the characteristic path data according to the graphic category of the original graphic, and generating standard path data of the standard graphic.
[0143] In this embodiment, after the graphic category of the original graphic is determined, targeted standardization processing can be performed based on the characteristics of the graphic category, so that a standard graphic can be generated.
[0144] Optionally, the above step b22 "perform 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 include the following steps b221 to b225.
[0145] Step b221, when the original figure is closed and the figure category of the original figure is an ellipse, the coordinate data of the first center point of the characteristic figure is determined according to the coordinate data of the characteristic point in the characteristic path data.
[0146] Step b222, based on the coordinate data of the feature points and the first center point, calculate the distance between the first center point and each feature point, and take the feature point corresponding to the largest distance as the first major axis point.
[0147] Step b223, determine the distance between other feature points and the long axis, and use the other feature points corresponding to the smallest distance as the second long axis point; the long axis 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, taking the midpoint between the first major axis point and the second major axis point as the second center point, determining the minimum value of the distance between the second center point and each feature point, and taking twice the minimum value as the minor axis length.
[0149] Step b225, taking the second center point as the center of the standard elliptical figure, determining the coordinate data of the standard point on the standard elliptical figure according to the major axis length and the minor axis length, and generating the standard path data of the standard figure.
[0150] In this embodiment, if the original figure is closed and the figure category of the original figure is an ellipse, a standard ellipse needs to be generated. In this embodiment, the standard ellipse can be finally determined by determining the major axis and the minor axis.
[0151] Fig.11 Figure 2 shows a schematic diagram of the process of generating a standard ellipse. Fig.11 As shown, for the original figure, after correction processing such as shrinkage, a characteristic figure can be obtained, which includes multiple characteristic points. The coordinate data of the first center point of the characteristic figure can be determined according to the coordinate data of each characteristic point in the characteristic path data. Fig.11 The first center point is represented by point O. For example, the average value of the x coordinates of each feature point is used as the x coordinate of point O, and the average value of the y coordinates of each feature point is used as the y coordinate of point O.
[0152] Traverse the coordinate data of each feature point and calculate the distance between the first center point O and each feature point, so as to find the feature point farthest from the first center point O. This feature point is a point on the major axis of the ellipse, called the first major axis point. Fig.11 Point A represents the first major axis point.
[0153] Take the AO line as the long axis and find the feature point closest to the long axis. This feature point is another point of the long axis, that is, the second long axis point. Fig.11 The second major axis point is represented by point B. The distance between the first major axis point A and the second major axis point B is the major axis length of the ellipse; the major axis length should exceed the distance from the first major 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. Fig.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, and the minor axis length is determined based on the minimum value, for example, twice the minimum value is used as the minor axis length. Fig.11 Point Q represents 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 straight line equation and the distance r, the coordinates of the two endpoints of the minor axis are calculated. Fig.11 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 "perform 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, determine 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; take the average of the distances between each feature point and the third center point as the radius of the circle; take the third center point as the center of the standard circular graphic, determine the coordinate data of the standard points on the standard circular graphic according to the radius of the circle, and generate 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, optionally, for a non-closed figure or a closed figure that is not a curve, a slope correction may be performed during the standardization process. Specifically, the above step b2 "standardizing the characteristic path data to generate standard path data of a standard figure" may 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 graph is not closed, it may be a line segment or an angle. Since it is difficult to draw a perfectly horizontal or vertical line segment by hand, in this embodiment, through slope correction, the horizontal line segments in the feature graph can be corrected to line segments with a slope of 0, and the vertical line segments in the feature graph can be corrected to line segments with an infinite slope. The feature points after slope correction are the corrected feature points, and based on these corrected feature points, the standard path data corresponding to the standard line segment or angle can be determined.
[0162] For example, the number of line segments of the feature graph can be determined. When the number of line segments is 1, the record type is a straight line. When the number of line segments is 2, it is recorded as an angle type. When the number of line segments is greater than 2, it is recorded as a non-circular type. After the recording, the above slope correction process is executed.
[0163] Among them, the above step b23, "Perform slope correction processing on the line segment to be processed", can specifically include steps b231 to b233.
[0164] Step b231, for the first feature point and the second feature point at both ends of the line segment to be processed, determine the slopes corresponding to the first feature point and the second feature point.
[0165] Step b232, when the absolute value of the slope is less than the first preset value, update the ordinate of the second feature point to the ordinate of the first feature point.
[0166] Step b233, when the absolute value of the slope is greater than the second preset value, update the abscissa of the second feature point to the abscissa 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 both ends of the line segment to be processed are called the first feature point and the second feature point. The corresponding slope K can be determined based on the coordinates of the first feature point and the second feature point, and this slope is also the slope of the line segment to be processed.
[0168] When the absolute value of the slope K < h_rate, it is considered that the line segment to be processed is horizontal, and straight line horizontal correction is performed. The correction method is: modify the ordinate (i.e., the y coordinate) of the second feature point and make it the same as the ordinate of the first feature point. Here, h_rate is the first preset value set as required, such as set to 0.15, etc.
[0169] When the absolute value of the slope K > v_rate, it is considered that the line segment to be processed is vertical, and straight line vertical correction is performed. The correction method is: modify the abscissa (i.e., the x coordinate) of the second feature point and make it the same as the abscissa of the first feature point. v_rate is the second preset value set as required, such as set to 3.0, etc.
[0170] Fig.12A schematic diagram of performing slope correction on an angle graph is shown. Fig.12 As shown, points A and B are the first feature point and the second feature point respectively, and the slope between them meets the condition of 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 can be understood that in the above step b23, if the original figure is not closed, it can be directly determined that the original figure is a line segment or an 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 according to the characteristic path data to determine whether the original figure is a line segment or an angle, etc.
[0172] For example, the judgment can be made based on the number of feature points in the feature path data. If the number of feature points is two, the original figure is a line segment; if the number of feature points is three, the original figure is an angle. If the number of feature points is large, the original figure may be an arc figure such as a semicircle, and the slope correction may not be performed on the arc figure.
[0173] The above step b22 "perform 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 according to the beginning point of the correction feature point and the adjacent correction feature points, determine the second straight line according to 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 category of the original figure is a non-circular figure, that is, the original figure is not a circle or an ellipse, for example, the original figure can be a polygon such as a triangle, a square, a trapezoid, etc. For the original figure, the slope correction can also be performed, for example, the slope correction can be performed based on the method shown in the above steps b231 to b233, which will not be repeated here.
[0177] However, after the slope correction is performed, the originally closed original figure may no longer be closed, that is, the positions of the first point and the last point after the slope correction are different. This embodiment also performs closing processing on the corrected feature points after the slope correction.
[0178] Specifically, after the slope correction is performed, a plurality of correction feature points can be determined, wherein the first correction feature point is the first point of the correction feature point, and the last correction feature point is the last point of the correction feature point. Based on the first point of the correction feature point and the correction feature points adjacent to the first point, a straight line, namely the first straight line, can be determined; similarly, based on the last point of the correction feature point and the correction feature points adjacent to the last point, a straight line, namely the 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 can be used as the new first point and last point, that is, the coordinate data of the first point of the positive feature point and the last point of the correction feature point are updated to the coordinate data corresponding to the intersection, so that the standard figure corresponding to the standard path data finally obtained is a closed figure.
[0179] Fig.13 A schematic diagram of the process of end-to-end closure is shown. Fig.13 As shown in the figure, the left half shows two possible situations in which the figure is not completely closed after the slope correction, that is, there may be gaps or extra lines. Fig.13 As shown in the right half, the first straight line AB is determined according to the first point A of the correction feature point and the adjacent correction feature point B, the second straight line CD is determined according to the last point C of the correction feature point and the adjacent correction 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 first point A of the correction feature point and the last point C of the correction feature point are updated to the coordinate data corresponding to the intersection O, so as to obtain a standard figure.
[0180] It should be noted that due to the special nature of a triangle, it is impossible for it to have two horizontal or two vertical line segments. Therefore, after a triangle is corrected once, it cannot be corrected again the next time. For example, after a horizontal correction, horizontal correction is not allowed the next time, but vertical correction is allowed.
[0181] In addition, optionally, if the original graphic is a square, the above step b2 "standardizing the characteristic path data to generate standard path data of the standard graphic" may also include the following process.
[0182] When the original figure is closed and the figure category of the original figure is a square, after the slope correction in step b226 and the head and 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 along the counterclockwise or clockwise direction, take the remaining three corrected feature points as the second reference point, the third reference point, and the fourth reference point in sequence. Also, determine the adjustment amplitude Δd, and Δd = RL - RS.
[0184] Moreover, divide the correction of the graph into magnification processing and reduction processing. When performing magnification processing, increase the abscissa (when the short side is horizontal) or ordinate (when the short side is vertical) of one corrected feature point corresponding to the short side by this amplitude Δd. When performing reduction processing, decrease the abscissa (when the short side is horizontal) or ordinate (when the short side is vertical) of one corrected feature point corresponding to the long side by this amplitude Δd.
[0185] As Fig.14 shown, let the coordinates of the first reference point A be (x0, y0), the coordinates of the second reference point B be (x1, y1), the coordinates of the third reference point C be (x2, y2), and the coordinates of the fourth reference point D be (x3, y3).
[0186] As Fig.14 shown in the left half, taking magnification processing as an example, if the first reference point A and the second reference point B are in the horizontal direction:
[0187] When r2 > r1, such as x1 > x0, modify x1 = x1 + Δd, x2 = x2 + Δd; if x1 < x0, you can modify x1 = x1 - Δd, x2 = x2 - Δd, or modify the coordinates of the first reference point A.
[0188] When r2 < r1, such as y2 > y1, modify y2 = y2 + Δd, y3 = y3 + Δd; if y2 < y1, you can modify y2 = y2 - Δd, y3 = y3 - Δd, or modify the coordinates of the fourth reference point D.
[0189] As Fig.14 shown in the right half, if the first reference point A and the second reference point B are in the vertical direction:
[0190] When r2 > r1, such as y1 > y0, modify y1 = y1 + Δd, y2 = y2 + Δd; if y1 < y0, you can modify y1 = y1 - Δd, y2 = y2 - Δd.
[0191] When r2 < r1, such as x2 > x1, modify x2 = x2 + Δd, x3 = x3 + Δd; if x2 < x1, you can modify x2 = x2 - Δd, x3 = x3 - Δd.
[0192] In addition, if the original graph is a parallelogram or a trapezoid, after slope correction and end - to - end closing processing, the parallelogram or trapezoid can also be further corrected.
[0193] Specifically, as Fig.15As shown in the left half, for a parallelogram, we can calculate the slope k of the straight line of one side AD, and the distance between AD and point B is r4; for the other side point B, we can find the line segment with slope k and length r4, and calculate the new coordinates of point C. After the correction is completed and reconnected, a more parallel figure will be obtained, and the figure type is recorded as a parallelogram.
[0194] like Fig.15 As shown in the right half, for a trapezoid, calculate the slope k of a straight line of one parallel side AB, and the distance of the other parallel side CD is r3. Through point C, find a line segment with slope k and length r3, and calculate the new coordinates of point D. After the correction is completed and reconnected, a more standardized trapezoid will be obtained, and the graphic type is recorded as a trapezoid.
[0195] The graphics processing method provided in this embodiment can effectively and quickly recognize and correct hand-drawn basic graphics, support common circles, ellipses, triangles, squares, rectangles, parallelograms, angles, straight lines and other graphics, with fast recognition speed and good performance. After hand-drawing, the display can be corrected immediately, and the user experience is good. The method can also be combined with the open source graphics library Skia, which can be easily used across platforms.
[0196] In this embodiment, a device for graphics processing is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0197] This embodiment provides a graphics processing device, such as Fig.16 As shown, including:
[0198] The acquisition module 1601 is used to acquire the original path data of the original graph; the original path data includes the coordinate data of a plurality of original points;
[0199] A point-adding processing module 1602 is used to perform point-adding processing on the original path data to generate extended path data of an extended graph; the extended path data includes coordinate data of a plurality of extended points, and the extended points include the original points and the supplementary points obtained by the point-adding processing;
[0200] The distance calculation module 1603 is used to determine the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data;
[0201] The correction module 1604 is used to determine that the original figure is closed when the minimum distance is less than the first preset distance, and use the two extended points corresponding to the minimum distance as the first point and the last point of the corrected figure to generate the corrected path data of the corrected figure; when the minimum distance is greater than the first preset distance, determine that the original figure is not closed, and use the original path data or the extended path data as the corrected path data of the corrected figure;
[0202] The standardization module 1605 is used to perform standardization processing on the corrected path data to determine standard path data for generating and displaying a standard graph.
[0203] In some optional implementations, the point-adding processing module 1602 performs point-adding processing on the original path data, including:
[0204] For two adjacent original points, when the distance between the two adjacent original points is greater than a second preset distance, at least one supplementary point is inserted 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.
[0205] In some optional implementations, the distance calculation module 1603 determines the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data, including:
[0206] The extended points are sequentially used as the first points that need to be queried in the order of drawing, and the query operation is performed on the first points until an end condition is met;
[0207] The minimum value of the undetermined distances determined by all the query operations is used as the minimum distance between the two extension points;
[0208] The query operation includes:
[0209] Determine the distance between the first point and each second point respectively; the second point is other extension points after the first point;
[0210] The minimum value of the distances between the first point and each second point is used as the pending distance determined by this query operation.
[0211] In some optional implementations, the end condition is satisfied when the number of extension points between the first point and the last extension point is less than or equal to a preset number;
[0212] The second point is another extension point that is after the first point and has a number of extension points between the second point and the first point that is greater than or equal to a preset number.
[0213] In some optional implementations, the standardization module 1605 performs standardization processing on the corrected path data to determine standard path data for generating and displaying a standard graphic, including:
[0214] Performing shrinkage processing on the corrected path data, determining feature points in the corrected path data related to the graphic features, and generating feature path data of the feature graphic; the feature path data includes coordinate data of the feature points;
[0215] The characteristic path data is standardized to generate standard path data of a standard graphic.
[0216] In some optional implementations, the standardization module 1605 performs standardization processing on the characteristic path data to generate standard path data of a standard graphic, including:
[0217] In the case where the original graphic is closed, determining the graphic category of the original graphic according to the characteristic path data;
[0218] According to the graphic category of the original graphic, the characteristic path data is subjected to corresponding standardization processing to generate standard path data of a standard graphic.
[0219] In some optional implementations, the standardization module 1605 performs corresponding standardization processing on the characteristic path data according to the graphic category of the original graphic to generate standard path data of a standard graphic, including:
[0220] When the original figure is closed and the figure category of the original figure is an ellipse, determining the coordinate data of a first center point of the characteristic figure according to the coordinate data of the characteristic point in the characteristic path data;
[0221] Calculate the distance between the first center point and each of the feature points according to the coordinate data of the feature point and the first center point, and use the feature point corresponding to the largest distance as the first major axis point;
[0222] Determine the distance between other feature points and the long axis, and use the other feature point corresponding to the smallest distance as the second long axis point; the long axis 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;
[0223] Taking the midpoint between the first major axis point and the second major axis point as the second center point, determining the minimum value of the distance between the second center point and each feature point, and taking twice the minimum value as the minor axis length;
[0224] The second center point is taken as the center of the standard elliptical figure, and the coordinate data of the standard point located on the standard elliptical figure is determined according to the major axis length and the minor axis length to generate the standard path data of the standard figure.
[0225] In some optional implementations, the standardization module 1605 performs corresponding standardization processing on the characteristic path data according to the graphic category of the original graphic to generate standard path data of a standard graphic, including:
[0226] When the original figure is closed and the figure category of the original figure is a non-circular figure, a line segment between two adjacent feature points in the feature path data is used as a line segment to be processed, and a slope correction process is performed on the line segment to be processed to determine the coordinate data of the corrected feature point;
[0227] When the beginning and end of the correction feature points are different, the first straight line is determined according to the beginning point of the correction feature point and the adjacent correction feature points, and the second straight line is determined according to the end point of the correction feature point and the adjacent correction feature points, and the intersection of the first straight line and the second straight line is determined, and the coordinate data of the beginning point of the correction feature point and the end point of the correction feature point are updated to the coordinate data corresponding to the intersection, so as to generate the standard path data of the standard figure.
[0228] In some optional implementations, the standardization module 1605 performs standardization processing on the characteristic path data to generate standard path data of a standard graphic, and further includes:
[0229] In the case where the original figure is not closed, a line segment between two adjacent feature points in the feature path data is used as a line segment to be processed, and a slope correction process is performed on the line segment to be processed to determine coordinate data of the corrected feature point;
[0230] The corrected feature points are used as standard points on the standard graph to generate standard path data of the standard graph.
[0231] In some optional implementations, the standardization module 1605 performs slope correction processing on the line segment to be processed, including:
[0232] For a first feature point and a second feature point at two ends of the line segment to be processed, determining slopes corresponding to the first feature point and the second feature point;
[0233] When the absolute value of the slope is less than a first preset value, updating the ordinate of the second feature point to the ordinate 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; and 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 Fig.17 The graphics processing device shown.
[0238] See also Fig.17 , Fig.17 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig.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 are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the 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. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.17 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 a dedicated 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 executable 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 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0242] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0243] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0244] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or 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 a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0245] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0246] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations should all be included in the protection scope of the present invention.
Claims
1. A method for graphics processing, characterized in that: The method comprises: Acquire original path data of an original graphic; the original path data includes coordinate data of a plurality of original points; Performing point-filling processing on the original path data to generate extended path data of the extended graph; the extended path data includes coordinate data of a plurality of extended points, and the extended points include the original points and supplementary points obtained by the point-filling processing; Determine the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data; In the case where the minimum distance is less than the first preset distance, determining that the original figure is closed, and using the two extension points corresponding to the minimum distance as the first point and the last point of the corrected figure to generate corrected path data of the corrected figure; In the case where the minimum distance is greater than a first preset distance, determining that the original graph is not closed, and using the original path data or the extended path data as corrected path data of the corrected graph; The corrected path data is standardized to determine standard path data for generating and displaying a standard graph.
2. The method according to claim 1, characterized in that The step of performing point-adding processing on the original path data includes: For two adjacent original points, when the distance between the two adjacent original points is greater than a second preset distance, at least one supplementary point is inserted 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.
3. The method according to claim 1, characterized in that The step of determining the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data comprises: The extended points are sequentially used as the first points that need to be queried in the order of drawing, and the query operation is performed on the first points until an end condition is met; The minimum value of the undetermined distances determined by all the query operations is used as the minimum distance between the two extension points; The query operation includes: Determine the distance between the first point and each second point respectively; the second point is other extension points after the first point; The minimum value of the distances between the first point and each second point is used as the pending distance determined by this query operation.
4. The method according to claim 3, characterized in that When the number of extension points between the first point and the last extension point is less than or equal to a preset number, the end condition is satisfied; The second point is another extension point that is after the first point and has a number of extension points between the second point and the first point that is greater than or equal to a preset number; The preset number is the minimum number indicating that the graphic is closed.
5. The method according to claim 1, characterized in that The step of standardizing the corrected path data to determine standard path data for generating and displaying a standard graphic includes: Performing shrinkage processing on the corrected path data, determining feature points in the corrected path data related to the graphic features, and generating feature path data of the feature graphic; the feature path data includes coordinate data of the feature points; The characteristic path data is standardized to generate standard path data of a standard graphic.
6. The method according to claim 5, characterized in that The step of performing standardization processing on the characteristic path data to generate standard path data of a standard graph includes: In the case where the original graphic is closed, determining the graphic category of the original graphic according to the characteristic path data; According to the graphic category of the original graphic, the characteristic path data is subjected to corresponding standardization processing to generate standard path data of a standard graphic.
7. The method according to claim 6, characterized in that The step of performing corresponding standardization processing on the characteristic path data according to the graphic category of the original graphic to generate standard path data of a standard graphic includes: In a case where the graphic category of the original graphic is an ellipse, determining the coordinate data of a first center point of the characteristic graphic according to the coordinate data of the characteristic point in the characteristic path data; Calculate the distance between the first center point and each of the feature points according to the coordinate data of the feature point and the first center point, and use the feature point corresponding to the largest distance as the first major axis point; Determine the distance between other feature points and the long axis, and use the other feature point corresponding to the smallest distance as the second long axis point; the long axis 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; Taking the midpoint between the first major axis point and the second major axis point as the second center point, determining the minimum value of the distance between the second center point and each feature point, and taking twice the minimum value as the minor axis length; The second center point is taken as the center of the standard elliptical figure, and the coordinate data of the standard point located on the standard elliptical figure is determined according to the major axis length and the minor axis length to generate the standard path data of the standard figure.
8. The method according to claim 6, characterized in that The step of performing corresponding standardization processing on the characteristic path data according to the graphic category of the original graphic to generate standard path data of a standard graphic includes: In the case where the graphic category of the original graphic is a non-circular graphic, a line segment between two adjacent feature points in the feature path data is used as a line segment to be processed, and a slope correction process is performed on the line segment to be processed to determine coordinate data of the corrected feature point; When the beginning and end of the correction feature points are different, the first straight line is determined according to the beginning point of the correction feature point and the adjacent correction feature points, and the second straight line is determined according to the end point of the correction feature point and the adjacent correction feature points, and the intersection of the first straight line and the second straight line is determined, and the coordinate data of the beginning point of the correction feature point and the end point of the correction feature point are updated to the coordinate data corresponding to the intersection, so as to generate the standard path data of the standard figure.
9. The method according to claim 6, characterized in that The step of standardizing the characteristic path data to generate standard path data of a standard graph further includes: In the case where the original figure is not closed, a line segment between two adjacent feature points in the feature path data is used as a line segment to be processed, and a slope correction process is performed on the line segment to be processed to determine coordinate data of the corrected feature point; The corrected feature points are used as standard points on the standard graph to generate standard path data of the standard graph.
10. The method according to claim 8 or 9, characterized in that: The step of performing slope correction processing on the line segment to be processed comprises: For a first feature point and a second feature point at both ends of the line segment to be processed, determining slopes corresponding to the first feature point and the second feature point; When the absolute value of the slope is less than a first preset value, updating the ordinate of the second feature point to the ordinate of the first feature point; 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; and the second preset value is greater than the first preset value.
11. A graphics processing device, characterized in that: The device comprises: An acquisition module, used to acquire original path data of an original graphic; the original path data includes coordinate data of a plurality of original points; A point-adding processing module is used to perform point-adding processing on the original path data to generate extended path data of the extended graph; the extended path data includes coordinate data of a plurality of extended points, and the extended points include the original points and the supplementary points obtained by the point-adding processing; A distance calculation module, used to determine the minimum distance between two extension points according to the coordinate data of each extension point in the extension path data; A correction module, configured to determine that the original figure is closed when the minimum distance is less than a first preset distance, and use the two extended points corresponding to the minimum distance as the first point and the last point of the corrected figure to generate corrected path data of the corrected figure; and determine that the original figure is not closed when the minimum distance is greater than the first preset distance, and use the original path data or the extended path data as the corrected path data of the corrected figure; The standardization module is used to perform standardization processing on the corrected path data and determine standard path data for generating and displaying a standard graphic.
12. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for graphics processing according to any one of claims 1 to 10 by executing the computer instructions.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the graphics processing method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Mask pattern correction method
CN103376644A
Method and equipment for erasing writing path
CN106325737A
Filling method and filling device for vector patterns
CN107146268A
Positioning method and device, electronic equipment and storage medium
CN117073677A
Graph processing method and device, electronic equipment and computer readable storage medium
CN117274426A