Line drawing sampling and rendering method and apparatus

By temporally sorting the pixel information of lines drawn on touch devices and calculating the centroid of a sliding window, combined with curvature thinning processing, the difficulties of sampling and rendering lines drawn with a capacitive pen are solved, achieving efficient drawing point compression and information retention.

CN118131941BActive Publication Date: 2025-10-17REALSEE (BEIJING) TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410302963.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-15
Publication Date
2025-10-17
Estimated Expiration
2044-03-15

AI Technical Summary

Technical Problem

When using a capacitive stylus to draw lines on an electronic device, existing technologies have difficulty effectively sampling and rendering the lines. Especially when constructing three-dimensional shapes, the points generated by the original hardware device are too dense to be directly used to construct spline-extended objects.

Method used

By sorting the pixel information of lines drawn on the screen by a touch device in time, drawing points at preset time intervals are extracted, and the center of gravity is calculated using a sliding window. The number of drawing points is reduced and the structural distribution is preserved through curvature thinning and angle processing.

Benefits of technology

This method achieves effective compression of the number of drawing points, preserves the structural distribution of the drawing points, avoids information loss caused by reducing the number of points, and improves the sampling and rendering efficiency of drawing lines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118131941B_ABST
    Figure CN118131941B_ABST
Patent Text Reader

Abstract

The embodiment of the present disclosure discloses a sampling and rendering method and device for drawing a line, wherein the sampling method for drawing a line comprises: based on pixel information corresponding to a line drawn by a touch device on a screen, time sorting the pixel information to obtain a first sampling set; wherein the first sampling set comprises a plurality of drawing points corresponding to the line; drawing points in the first sampling set are extracted according to a preset time interval to obtain a second sampling set; wherein the number of drawing points included in the second sampling set is less than or equal to the number of drawing points included in the first sampling set; the drawing points in the second sampling set are processed by sliding based on a sliding window of a preset length, and the barycenter of a plurality of pixel points in a window corresponding to each sliding is calculated to obtain a third sampling set; and based on the third sampling set, a target sampling set corresponding to the line is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to data processing technology, and particularly to a line drawing sampling and rendering method and device. BACKGROUND

[0002] When a user uses an external device such as a capacitive pen to draw a line on an electronic device, a dense line point set can be sampled. When a three-dimensional technology such as webgl is used, if a surface of various shapes is to be constructed, the sampling points need to be used, and the line cannot be directly sampled based on an image. Purely based on a pixel image, it is difficult to sample a line because there is no equation description in the pixel. Pure free drawing also faces the problem of not being easy to sample. The points generated by the original hardware device are very dense, and usually thousands or even ten thousand points (depending on the hardware itself) cannot be directly used to construct a spline line stretched object. SUMMARY

[0003] To solve the above technical problems, the present disclosure is proposed. Embodiments of the present disclosure provide a line drawing sampling and rendering method and device.

[0004] According to an aspect of an embodiment of the present disclosure, a line drawing sampling method is provided, comprising:

[0005] Based on pixel information corresponding to a line drawn on a screen by a touch device, a first sampling set is obtained by sorting the pixel information according to time; wherein the first sampling set includes a plurality of drawing points corresponding to the line;

[0006] Drawing points in the first sampling set are extracted according to a preset time interval to obtain a second sampling set; wherein the number of drawing points included in the second sampling set is less than or equal to the number of drawing points included in the first sampling set;

[0007] The drawing points in the second sampling set are processed by a sliding window of a preset length, and a plurality of barycentric points in a window corresponding to each sliding are calculated to obtain a third sampling set; wherein the third sampling set includes a plurality of barycentric points;

[0008] Based on the third sampling set, a target sampling set corresponding to the line is obtained.

[0009] Optionally, the target sampling set corresponding to the line is obtained based on the third sampling set, comprising:

[0010] A plurality of line segments are formed based on a plurality of drawing points included in the third sampling set, and curvature abstraction is performed on the third sampling set based on the included angles between the plurality of line segments to obtain a fourth sampling set;

[0011] Obtaining a target sampling set corresponding to the line based on the fourth sampling set.

[0012] Optionally, the third sampling set is subjected to curvature sampling based on included angles between a plurality of line segments formed by a plurality of drawing points included in the third sampling set, to obtain a fourth sampling set, including:

[0013] The third sampling set is segmented to obtain a plurality of subsets; each of the subsets includes three consecutive drawing points;

[0014] The three drawing points in each of the subsets are fitted into two line segments, and an included angle between the two line segments is determined;

[0015] According to the relationship between the included angle and a first preset angle, n drawing points are deleted from the third sampling set to obtain a fourth sampling set; wherein n is an integer greater than or equal to 0.

[0016] Optionally, the third sampling set is subjected to curvature sampling based on included angles between a plurality of line segments formed by a plurality of drawing points included in the third sampling set, to obtain a fourth sampling set, including:

[0017] In response to the included angle being greater than the first preset angle, three consecutive drawing points corresponding to the included angle are recorded to the fourth sampling set;

[0018] In response to the included angle being less than or equal to the first preset angle, the middle drawing point of the three consecutive drawing points corresponding to the included angle is deleted, and the other two drawing points are recorded to the fourth sampling set.

[0019] Optionally, the third sampling set is subjected to curvature sampling based on included angles between a plurality of line segments formed by a plurality of drawing points included in the third sampling set, to obtain a fourth sampling set, including:

[0020] The fourth sampling set is subjected to drawing point deletion processing based on a sum of part of the included angles corresponding to the plurality of line segments, to obtain the target sampling set.

[0021] Optionally, the third sampling set is subjected to curvature sampling based on included angles between a plurality of line segments formed by a plurality of drawing points included in the third sampling set, to obtain a fourth sampling set, including:

[0022] According to the order of the drawing points in the third sampling set, the order between the plurality of subsets is determined;

[0023] The sum of the included angles corresponding to every m consecutive subsets is determined in order;

[0024] Determine whether to perform drawing point deletion on the fourth sampling set based on a relationship between a sum of m included angles and a second preset angle, to obtain a target sampling set; wherein m is an integer greater than 1.

[0025] Optionally, the sequentially determining a sum of m included angles corresponding to each of the m consecutive subsets comprises:

[0026] Determining a positive or negative of the included angle based on a direction of the included angle;

[0027] Accumulating the included angle according to the positive or negative of the m included angles, to obtain the sum of the m included angles.

[0028] Optionally, the determining whether to perform drawing point deletion on the fourth sampling set based on a relationship between a sum of m included angles and a second preset angle, to obtain a target sampling set comprises:

[0029] In response to the sum of the m included angles being less than or equal to the second preset angle, recording two edge drawing points in a subset corresponding to the m included angles into the target sampling set, and deleting all other drawing points;

[0030] In response to the sum of the m included angles being greater than the second preset angle, recording a drawing point corresponding to each of the m included angles in the fourth sampling set into the target sampling set.

[0031] Optionally, the recording the two edge drawing points in the subset corresponding to the m included angles into the target sampling set comprises:

[0032] Performing a least square line segment fitting on all drawing points in the subset corresponding to the m included angles, to obtain a fitting line segment;

[0033] Recording two end points of the fitting line segment as the two edge drawing points into the target sampling set.

[0034] Optionally, the obtaining the first sampling set by sorting the pixel information corresponding to the line drawn by the touch device on the screen according to time comprises:

[0035] Obtaining position information of a plurality of the drawing points of the touch device on the screen according to a preset monitoring speed; wherein a time difference between each two of the drawing points is an inverse of the preset monitoring speed;

[0036] In response to the number of the drawing points reaching a preset number, obtaining the pixel information based on the preset monitoring speed, the plurality of position information, and time information corresponding to each of the position information;

[0037] Sort the drawing points corresponding to the pixel information according to the time information, to obtain the first sampling set.

[0038] According to another aspect of the embodiments of the present disclosure, a rendering method is provided, comprising:

[0039] Based on the plurality of drawing points included in the target sampling set obtained by the line drawing sampling method according to any of the above embodiments, the spline line length, the spline line curvature, and the spline line vertex coordinates are determined, to obtain spline line information;

[0040] Based on the spline line information and the length information perpendicular to the spline line direction, a display grid is determined, wherein the coordinate conversion relationship between the virtual space coordinate system and the texture map uv coordinate system is determined;

[0041] An uv coordinate set of the to-be-displayed information in the uv coordinate system is obtained;

[0042] Based on the uv coordinate set and the coordinate conversion relationship, a virtual coordinate set of the to-be-displayed information in the virtual space coordinate system is determined;

[0043] Based on the virtual coordinate set and the display grid, the to-be-displayed information is rendered in the virtual space, to obtain a rendering image.

[0044] According to still another aspect of the embodiments of the present disclosure, a line drawing sampling device is provided, comprising:

[0045] A line sampling module is configured to sort pixel information corresponding to a line drawn on a screen by a touch device according to time, to obtain a first sampling set; wherein the first sampling set includes a plurality of drawing points corresponding to the line.

[0046] An interval extraction module is configured to extract drawing points in the first sampling set according to a preset time interval, to obtain a second sampling set; wherein the number of drawing points included in the second sampling set is less than or equal to the number of drawing points included in the first sampling set.

[0047] A sliding processing module is configured to perform sliding processing on the drawing points in the second sampling set based on a sliding window of a preset length, to obtain a third sampling set by calculating a barycenter of a plurality of pixel points in each sliding window; wherein the third sampling set includes a plurality of barycenters.

[0048] A target sampling module is configured to obtain a target sampling set corresponding to the line based on the third sampling set.

[0049] Optionally, the target sampling module comprises:

[0050] a curvature thinning unit, configured to form a plurality of line segments based on a plurality of drawing points included in the third sampling set, perform curvature thinning on the third sampling set based on included angles between the plurality of line segments to obtain a fourth sampling set;

[0051] a sampling set unit, configured to obtain a target sampling set corresponding to the line based on the fourth sampling set.

[0052] Optionally, the curvature thinning unit is specifically configured to divide the third sampling set to obtain a plurality of subsets, each of the subsets including three continuous drawing points, fit the three drawing points in each of the subsets as two line segments to determine an included angle between the two line segments, and delete n drawing points from the third sampling set according to a relationship between the included angle and a first preset angle to obtain a fourth sampling set, where n is an integer greater than or equal to 0.

[0053] Optionally, when the curvature thinning unit deletes n drawing points from the third sampling set according to a relationship between the included angle and a first preset angle to obtain a fourth sampling set, the curvature thinning unit is configured to, in response to the included angle being greater than the first preset angle, record three continuous drawing points corresponding to the included angle to the fourth sampling set, and in response to the included angle being less than or equal to the first preset angle, delete a middle drawing point from the three continuous drawing points corresponding to the included angle and record the other two drawing points to the fourth sampling set.

[0054] Optionally, the sampling set unit is specifically configured to perform drawing point deletion processing on the fourth sampling set based on a sum of part of the plurality of included angles corresponding to the plurality of line segments to obtain the target sampling set.

[0055] Optionally, the sampling set unit is further configured to determine an order between the plurality of subsets according to an order of drawing points in the third sampling set, determine a sum of included angles corresponding to each m continuous subsets in sequence, and determine whether to perform drawing point deletion on the fourth sampling set based on a relationship between the sum of m included angles and a second preset angle to obtain a target sampling set, where m is an integer greater than 1.

[0056] Optionally, when the sampling set unit determines a sum of included angles corresponding to each m continuous subsets in sequence, the sampling set unit is configured to determine a positive or negative of the included angle based on a direction of the included angle, and accumulate the included angles according to the positive or negative of the m included angles to obtain the sum of the m included angles.

[0057] Optionally, the sampling set unit, when recording the two edge drawing points in the subset corresponding to the m included angles into the target sampling set, is configured to: perform least square line segment fitting on all the drawing points in the subset corresponding to the m included angles to obtain a fitting line segment; and record the two end points of the fitting line segment into the target sampling set as the two edge drawing points.

[0058] Optionally, the sampling set unit, when recording the two edge drawing points in the subset corresponding to the m included angles into the target sampling set, is configured to: perform least square line segment fitting on all the drawing points in the subset corresponding to the m included angles to obtain a fitting line segment; and record the two end points of the fitting line segment into the target sampling set as the two edge drawing points.

[0059] Optionally, the line sampling module is specifically configured to: acquire position information of a plurality of the drawing points of the touch device on the screen according to a preset monitoring speed, wherein a time difference between every two of the drawing points is an inverse of the preset monitoring speed; and in response to the number of the drawing points reaching a preset number, obtain the pixel information based on the preset monitoring speed, the plurality of the position information, and time information corresponding to each of the position information; and sort the drawing points corresponding to the pixel information according to the time information to obtain the first sampling set.

[0060] According to still another aspect of the embodiments of the present disclosure, a rendering device is provided, comprising:

[0061] a spline line information module configured to determine spline line length, spline line curvature, and spline line vertex coordinates based on a plurality of drawing points included in the target sampling set obtained by the sampling method of the drawing line, to obtain spline line information;

[0062] a display grid determination module configured to determine a display grid based on selected spline line information and length information perpendicular to a direction of the spline line, and a coordinate conversion relationship between a virtual space coordinate system and a texture map uv coordinate system;

[0063] a uv coordinate set acquisition module configured to acquire a uv coordinate set of to-be-displayed information in a uv coordinate system;

[0064] a virtual coordinate set determination module configured to determine a virtual coordinate set of the to-be-displayed information in the virtual space coordinate system based on the uv coordinate set and the coordinate conversion relationship;

[0065] The rendering module is configured to render the information to be displayed in a virtual space based on the set of virtual coordinates and the display grid, to obtain a rendering image.

[0066] According to a further aspect of the embodiments of the present disclosure, an electronic device is provided, comprising:

[0067] a memory configured to store a computer program product;

[0068] a processor configured to execute the computer program product stored in the memory, and the computer program product, when executed, implements the method of any of the above embodiments.

[0069] According to a further aspect of the embodiments of the present disclosure, a computer readable storage medium is provided, having stored thereon computer program instructions, which, when executed by a processor, implement the method of any of the above embodiments.

[0070] According to a further aspect of the embodiments of the present disclosure, a computer program product is provided, comprising computer program instructions, which, when executed by a processor, implement the method of any of the above embodiments.

[0071] According to the sampling and rendering method and device for drawing a line provided by the above embodiments of the present disclosure, based on the pixel information corresponding to the line drawn on the screen by the touch device, a first sampling set is obtained by sorting the pixel information according to time; wherein the first sampling set includes a plurality of drawing points corresponding to the line; drawing points in the first sampling set are extracted according to a preset time interval to obtain a second sampling set; wherein the number of drawing points included in the second sampling set is less than or equal to the number of drawing points included in the first sampling set; the drawing points in the second sampling set are processed by sliding based on a sliding window of a preset length, and the barycenter of a plurality of pixel points in the window corresponding to each sliding is calculated to obtain a third sampling set; wherein the third sampling set includes a plurality of barycenters; based on the third sampling set, a target sampling set corresponding to the line is obtained; the initial compression processing of the number of drawing points is realized by time thinning in this embodiment; and by calculating the barycenter in the local window, the structure distribution of the drawing points is retained on the basis of further reducing the drawing points, the number of drawing points in the target sampling set processed by this embodiment is greatly reduced compared with the original drawing line, and the structure distribution of the drawing points is retained, thereby avoiding the problem of losing distribution information due to the reduction of the number of drawing points.

[0072] The technical solutions of the present disclosure will be further described in detail below with reference to the drawings and embodiments. BRIEF DESCRIPTION OF DRAWINGS

[0073] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0074] The present disclosure can be more clearly understood and appreciated from the following detailed description, taken in conjunction with the following drawings of which:

[0075] Figure 1 is a flowchart of a sampling method for drawing a line according to an example embodiment of the present disclosure;

[0076] Figure 2 is a flowchart of a sampling method for drawing a line according to an example embodiment of the present disclosure; Figure 1 is a flowchart of step 1081 in the embodiment shown in FIG. 1 1 according to an example embodiment of the present disclosure;

[0077] Figure 3 is a flowchart of a sampling method for drawing a line according to an example embodiment of the present disclosure; Figure 2 is a flowchart of step 1081 in the embodiment shown in FIG. 1 1 according to an example embodiment of the present disclosure;

[0078] Figure 4 is a flowchart of a sampling method for drawing a line according to an example embodiment of the present disclosure; Figure 2 is a flowchart of step 1082 in the embodiment shown in FIG. 1 1 according to an example embodiment of the present disclosure;

[0079] Figure 5 is a flowchart of a rendering method according to an example embodiment of the present disclosure;

[0080] Figure 6 is a schematic diagram showing a grid in a virtual space coordinate system in an example of the present disclosure;

[0081] Figure 7 is a structural schematic diagram of a sampling device for drawing a line according to an example embodiment of the present disclosure;

[0082] Figure 8 is a structural schematic diagram of a rendering device according to an example embodiment of the present disclosure;

[0083] Figure 9 FIG. 1 1 illustrates a block diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0084] Hereinafter, example embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, and are not all the embodiments of the present disclosure. It should be understood that the present disclosure is not limited to the described example embodiments.

[0085] It should be noted that: unless otherwise specified, the relative arrangement, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present disclosure.

[0086] Those skilled in the art can understand that the terms "first", "second" and the like in the embodiments of the present disclosure are only used to distinguish different steps, devices or modules, and do not represent any specific technical meaning, nor represent the inherent logical sequence between them.

[0087] It should also be understood that in the embodiments of the present disclosure, "multiple" can mean two or more, and "at least one" can mean one, two or more.

[0088] It should also be understood that for any component, data or structure mentioned in the embodiments of the present disclosure, it can be understood as one or more in general, without explicit limitation or in the context of the opposite indication.

[0089] In addition, the term "and / or" in the present disclosure is only a description of the association relationship between the associated objects, which means that there can be three relationships, for example, A and / or B can represent the existence of A alone, the existence of A and B together, and the existence of B alone. In addition, the character " / " in the present disclosure generally represents an "or" relationship between the front and rear associated objects. The data referred to in the present disclosure can include unstructured data such as text, images, video, etc., and can also be structured data.

[0090] It should also be understood that the description of the embodiments of the present disclosure focuses on the differences between the embodiments, and the same or similar parts can be referred to each other, and for the sake of brevity, will not be repeated.

[0091] At the same time, it should be understood that in order to facilitate the description, the size of each part shown in the drawings is not drawn according to the actual proportional relationship.

[0092] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way limiting to the disclosure and its application or uses.

[0093] Techniques, methods, and devices known to those of ordinary skill in the relevant art can not be discussed in detail, but should be considered part of the specification where appropriate.

[0094] It should be noted that similar reference numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further discussed in subsequent drawings.

[0095] The disclosed embodiments can be applied to terminal devices, computer systems, servers, and other electronic devices, which can operate with many other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with terminal devices, computer systems, servers, and other electronic devices include, but are not limited to, personal computers, server computers, thin clients, thick clients, hand-held or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, minicomputers, mainframe computers, and distributed cloud computing technology environments that include any of the above systems, and the like.

[0096] The terminal devices, computer systems, servers, and other electronic devices can be described in the general context of computer system-executable instructions, such as program modules, being executed by the computer system. Generally, program modules can include routines, programs, objects, components, logic, data structures, and the like, which perform particular tasks or implement particular abstract data types. The computer system / server can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules can be located in local or remote computer system storage media including storage devices.

[0097] Exemplary method

[0098] Figure 1 is a flowchart of a sampling method for drawing a line provided by an exemplary embodiment of the present disclosure. The present embodiment can be applied to electronic devices such as touch screen devices, as shown in Figure 1 The present embodiment includes the following steps:

[0099] In step 102, based on the pixel information corresponding to the line drawn on the screen by the touch device, the pixel information is sorted by time to obtain a first sampling set.

[0100] The first sampling set includes a plurality of drawing points corresponding to the line. The pixel information can include pixel position information (represented by coordinates), drawing time information, speed information, and the like. The pixel information corresponding to the line can be stored in the form of a pixel array, in which each element corresponds to the position information of a drawing point. Alternatively, each drawing point can be described based on the coordinates on the screen.

[0101] In this embodiment, the touch device can be a capacitive pen, a touch pen, or the like device capable of line drawing. Of course, the touch device can also be a user's finger or the like body part. The user draws a line by moving the touch device on the screen; this embodiment can implement real-time drawing point sampling or non-real-time drawing point sampling. When the drawing points are sampled in real time, the pixel length corresponding to the line drawn by the user is accumulated, for example, during the user's drawing process, as long as the capacitive pen touches the screen, a drawing event of the canvas is triggered, and the two-dimensional plane position of the capacitive pen on the device screen when the user draws can be obtained from the callback function of the event. Usually, the length and width of the canvas are the resolution of the screen, and are recorded as (x, y).

[0102] In step 104, the drawing points in the first sampling set are extracted according to a preset time interval to obtain a second sampling set.

[0103] In the second sampling set, the number of drawing points is less than or equal to the number of drawing points in the first sampling set.

[0104] In an embodiment, the line drawn by the touch device on the screen is very dense in the first sampling set obtained by direct sampling, and there are a large number of redundancies, which are not convenient to process. This embodiment first reduces the number of drawing points through thinning preprocessing; optionally, when the touch device draws, it is assumed that the drawing speed is relatively uniform, and therefore, the thinning is first performed in time sequence, and one drawing point is extracted every preset time interval, for example, the first sampling set is thinned to 1 / 5 (only an example, and can be any multiple, for example, 1 / 4, 1 / 6, or the like) of the original to obtain the second sampling set. In another embodiment, when it is assumed that the drawing speed is relatively uniform, the multiple drawing points can be directly thinned at intervals, that is, one drawing point is taken as a drawing point in the second sampling set every preset number (for example, 5, 6, or the like) of drawing points.

[0105] In step 106, the drawing points in the second sampling set are processed by sliding based on a preset length sliding window, the barycenter of multiple pixel points in the window corresponding to each sliding is calculated to obtain a third sampling set.

[0106] In the third sampling set, multiple barycenters are included.

[0107] In this embodiment, the preset length can be determined according to an actual application scenario or an empirical value; optionally, the length of the sliding window is determined according to the number of drawing points contained in the first sampling set, and the greater the number of drawing points contained in the first sampling set, the greater the preset length, for example, when the number of drawing points contained in the first sampling set is about 10,000, the preset length can be set to 50 points. The determination of the barycentric point can be based on the calculation method of the barycentric point in the prior art, for example, taking the preset length of 50 points as an example, the coordinates of the barycentric point on the x-axis and the y-axis are determined based on the following formula (1) and formula (2):

[0108]

[0109]

[0110] wherein, k x represents the coordinate of the barycentric point k on the x-axis; k y represents the coordinate of the barycentric point k on the y-axis; s xi represents the coordinate of the i-th drawing point in the sliding window on the x-axis; s yi represents the coordinate of the i-th drawing point in the sliding window on the y-axis; since the preset length is 50, the value of i is 1 to 50.

[0111] In step 108, the target sampling set corresponding to the line is obtained based on the third sampling set.

[0112] In this embodiment, the barycentric point of the sliding window is calculated instead of the geometric center, because the barycenter can better represent the distribution of the drawing points, and the geometric center is greatly affected by outliers. If the geometric center point is taken as the drawing point in the third sampling set, the distribution information of the drawing points will be lost. In this embodiment, the local uniformization processing is realized by calculating the barycentric point, and the distribution information of the drawing points is retained on the premise of compressing the number of drawing points.

[0113] The method for sampling and rendering a line provided by the embodiment of the present disclosure comprises the following steps: based on pixel information corresponding to a line drawn on a screen by a touch device, a first sampling set is obtained by sorting the pixel information according to time; wherein the first sampling set comprises a plurality of drawing points corresponding to the line; a second sampling set is obtained by extracting the drawing points in the first sampling set according to a preset time interval; wherein the number of drawing points in the second sampling set is less than or equal to the number of drawing points in the first sampling set; a plurality of drawing points in the second sampling set are processed by a sliding window of a preset length, a plurality of barycentric points in a window corresponding to each sliding are calculated, and a third sampling set is obtained; wherein the third sampling set comprises a plurality of barycentric points; based on the third sampling set, a target sampling set corresponding to the line is obtained; the embodiment realizes initial compression processing of the number of drawing points by time thinning; and by calculating the barycentric points in the local window, the structure distribution of the drawing points is retained on the basis of further reducing the drawing points, the number of drawing points in the target sampling set processed by the embodiment is greatly reduced compared with the original drawing line, and the structure distribution of the drawing points is retained, thereby avoiding the problem of losing distribution information due to the reduction of the number of drawing points.

[0114] As shown in the above Figure 2 embodiment, on the basis of the above Figure 1 embodiment, step 108 can comprise the following steps:

[0115] Step 1081, based on the plurality of drawing points comprised in the third sampling set, a plurality of line segments are constituted, the third sampling set is processed by curvature thinning based on the included angles between the plurality of line segments, and a fourth sampling set is obtained.

[0116] Optionally, each two adjacent drawing points in the plurality of drawing points can be connected by a line in sequence (time sequence), that is, a plurality of line segments can be obtained, and the angle between each two adjacent line segments is determined as the above-mentioned included angle; or, each 3 drawing points in the plurality of drawing points are divided into a subset in sequence (time sequence), the first point in the subset is connected with the other two points respectively, two line segments are obtained, and the angle between the two line segments is determined as the above-mentioned included angle.

[0117] Step 1082, based on the fourth sampling set, a target sampling set corresponding to the line is obtained.

[0118] Optionally, based on the sum of part of the plurality of included angles corresponding to the plurality of line segments, the drawing points in the fourth sampling set are deleted, and a target sampling set is obtained.

[0119] Optionally, the shape of the local line can be understood macroscopically by the sum of the partial angles, and when the plurality of line segments are approximately a straight line macroscopically, a plurality of drawing points therefrom can be deleted, and when the plurality of line segments are approximately an arc line macroscopically (with a large curvature), the drawing points deleted from the third sampling set to the fourth sampling set can be recovered, for example, p2 in the above example is recovered, that is, the drawing points p1, p2 and p3 are all recorded in the target sampling set.

[0120] In the embodiment, a plurality of line segments are constructed by a plurality of drawing points, and the angles between the plurality of line segments (for example, the angles between each two adjacent line segments, and a plurality of angles are formed by the plurality of line segments corresponding to each point as a vertex) are determined, and the curvature between two line segments can be determined by the angles, and the changes of a plurality of points are recorded continuously according to the change of the curvature in the embodiment, so that the local order is ensured.

[0121] As shown in the above Figure 3 based on the embodiment shown in the above Figure 2 , step 1081 can include the following steps:

[0122] Step 301, the third sampling set is segmented to obtain a plurality of subsets.

[0123] Each subset includes three consecutive drawing points.

[0124] Step 302, the three drawing points in each subset are fitted into two line segments, and the angle between the two line segments is determined.

[0125] Optionally, the third sampling set is divided into a plurality of subsets according to time sequence, and each subset includes three consecutive drawing points, for example, a subset includes three consecutive drawing points p1, p2 and p3 in sequence; in an embodiment, based on the three drawing points, two line segments p1p2 and p1p3 are determined, and since the two line segments have a common vertex p1, the angle between the line segment p1p2 and the line segment p1p3 can be determined by the coordinate information of the three drawing points, the smaller the angle, the smaller the curvature of the three drawing points, and in particular, when the angle is 0 degrees, it indicates that the three drawing points p1, p2 and p3 are on the same straight line, and the larger the angle, the greater the curvature of the drawing points. In another embodiment, based on the three drawing points, two line segments p1p2 and p2p3 are determined, and at this time, the two line segments have a common vertex p2, the angle between the line segment p1p2 and the line segment p2p3 can be determined by the coordinate information of the three drawing points, the larger the angle, the smaller the curvature of the three drawing points, and in particular, when the angle is 180 degrees, it indicates that the three drawing points p1, p2 and p3 are on the same straight line, and the smaller the angle, the greater the curvature of the drawing points.

[0126] Step 303, according to the relationship between the included angle and the first preset angle, deleting n drawing points from the third sampling set to obtain a fourth sampling set.

[0127] Wherein, n is an integer greater than or equal to 0.

[0128] In this embodiment, optionally, the greater the included angle, the greater the curvature of the drawing point, a smaller first preset angle (for example, 10 degrees, 15 degrees, etc.) can be set, and in response to the included angle being greater than the first preset angle (at this time, it indicates that the curvature of the three drawing points is greater), the three continuous drawing points corresponding to the included angle are recorded to the fourth sampling set; in response to the included angle being less than or equal to the first preset angle (at this time, it can be approximately considered that the three drawing points are on the same straight line), the middle drawing point of the three continuous drawing points corresponding to the included angle is deleted, and the other two drawing points are recorded to the fourth sampling set (for example, deleting p2 in the above example, and recording p1 and p3 to the fourth sampling set), to further reduce the drawing points.

[0129] And for the greater the included angle, the smaller the curvature of the three drawing points, a larger first preset angle (for example, 170 degrees, 165 degrees, etc.) can be set, and in response to the included angle being less than the first preset angle (at this time, it indicates that the curvature of the three drawing points is greater), the three continuous drawing points corresponding to the included angle are recorded to the fourth sampling set; in response to the included angle being greater than or equal to the first preset angle (at this time, it can be approximately considered that the three drawing points are on the same straight line), the middle drawing point of the three continuous drawing points corresponding to the included angle is deleted, and the other two drawing points are recorded to the fourth sampling set (for example, deleting p2 in the above example, and recording p1 and p3 to the fourth sampling set), to further reduce the drawing points.

[0130] This embodiment further thins the drawing points according to the curvature, wherein considering that the description of a line segment only needs 2 end points, and the description of a curve is better the denser, therefore, the thinning degree of a line segment with large curvature is small, and the thinning degree of a position with small curvature is relatively large; the thinning based on the curvature ensures the distribution characteristics of the drawing points under the premise of thinning.

[0131] As Figure 4 shown in the above Figure 2 On the basis of the embodiment shown in the above, step 1082 comprises the following steps:

[0132] Step 401, determining the order between the plurality of subsets according to the order of the drawing points in the third sampling set.

[0133] In order to determine the macro curvature, the order between the plurality of subsets needs to be determined, and this embodiment determines the arrangement order between the plurality of subsets based on the order of the drawing points in the third sampling set (ordering according to the drawing time).

[0134] In step 402, the sum of the angles corresponding to each of the m continuous subsets is determined in sequence.

[0135] The positive and negative of the angle is determined based on the direction of the angle; for example, in response to the angle being in a clockwise direction, the angle is determined to be positive; in response to the angle being in a counterclockwise direction, the angle is determined to be negative; the angles are accumulated according to the positive and negative of the m angles to obtain the sum of the m angles.

[0136] In this embodiment, since the curvature of a large number of drawing points in the macroscopic view is to be measured, the sum of the m angles corresponding to the m continuous subsets is determined, and when the angle is determined based on two line segments, there is an order. In this embodiment, when the angle is determined to be in a clockwise direction, the angle is determined to be positive, and when the angle is determined to be in a counterclockwise direction, the angle is determined to be negative. At this time, the cumulative sum is performed, the positive and negative angles can be offset, and the small fluctuations in the m continuous subsets can be offset.

[0137] In step 403, based on the relationship between the sum of the m angles and the second preset angle, it is determined whether to delete the drawing points in the fourth sampling set to obtain a target sampling set.

[0138] In the above embodiment, m is an integer greater than 1.

[0139] Optionally, in one example, in the case that the larger the angle, the greater the curvature of the drawing point, the second preset angle is a smaller angle value, for example, 10 degrees, 15 degrees, etc. At this time, in response to the sum of the m angles being less than or equal to the second preset angle (macroscopic curvature change is smaller), the two edge drawing points in the subset corresponding to the m angles are recorded into the target sampling set, and all other drawing points are deleted; in response to the sum of the m angles being greater than the second preset angle (macroscopic curvature change is larger), the drawing points in the fourth sampling set corresponding to each of the m angles are recorded into the target sampling set.

[0140] In the process of obtaining the fourth sampling set from the third sampling set, the curvature of every three continuous drawing points is judged, which belongs to small-range curvature thinning, and ensures local straight line order. Although the accuracy of small-range curvature judgment can be improved, there are some special cases, for example, a large arc, which is small in curvature change in small-range curvature judgment, but has large curvature when observed from a large range. At this time, thinning according to small-range curvature will lead to macroscopic distribution difference, and the distribution information in the original drawing points will be lost in the target sampling set. Therefore, the embodiment proposes a large-range curvature identification relative to small-range curvature thinning. For example, when m is 7, the range includes 7*3=21 drawing points, and the corresponding included angle includes 7; by calculating the sum of m included angles, when the sum is less than or equal to a second preset angle (which can be set according to the actual application scene, and is usually small, for example, 10 degrees, 15 degrees, etc.), it is indicated that the large-range curvature is also small. At this time, the least square line segment fitting is performed on all drawing points (for example, 21 drawing points) in the subset corresponding to the m included angles, to obtain a fitting line segment; and the two end points of the fitting line segment are recorded as two edge drawing points in the target sampling set. That is, when the large-range curvature is small, all drawing points in the large range are considered to be approximately a straight line, and the straight line can be represented by two end points. Therefore, only two drawing points in the large range are retained. When the sum of the m included angles is greater than the second preset angle, it is indicated that the large-range curvature is large, and the 2m drawing points in the fourth sampling set corresponding to the m included angles are recorded in the target sampling set.

[0141] In some optional embodiments, step 102 can be obtained according to the line drawn by the user in real time, which can include:

[0142] According to the preset monitoring speed, the position information of the plurality of drawing points of the touch device on the screen is obtained; wherein the time difference between every two drawing points is the inverse of the preset monitoring speed.

[0143] Optionally, the preset monitoring speed can be set according to the actual application scene, for example, 1000 times / s, etc., that is, a drawing point of the touch device on the screen is obtained every 0.001 seconds.

[0144] In response to the number of drawing points reaching the preset number, the pixel information is obtained based on the preset monitoring speed, the plurality of position information and the time information corresponding to each position information.

[0145] For real-time sampling of the drawn line, since it takes time to draw the line, and the object to be sparsely sampled needs to have a certain number of drawing points, therefore, when the number of drawing points reaches a preset number, the pixel information in the form of a pixel array is obtained, the preset number can be determined according to the actual application scenario, for example, 10000 points; after the number of drawing points reaches the preset number, the position information corresponding to the plurality of drawing points is obtained, which can be represented by the coordinates (including x-axis coordinate and y-axis coordinate) of the drawing point on the screen, and in order to sort the drawing points, the corresponding time information is obtained when each drawing point is obtained.

[0146] The drawing points corresponding to the pixel information are sorted according to the time information to obtain a first sampling set.

[0147] Based on the time information corresponding to each drawing point, the drawing points are sorted according to time, and a first sampling set is obtained.

[0148] In an optional example, the sampling length is set to 5 pixel distances, and the point where the user starts to draw is taken as the starting point, which is first included in the drawing point queue, then the current position of the capacitive pen on the screen is obtained at a monitoring speed of 1000 times per second, and it is generally considered that under a relatively normal drawing speed of the user, the moving pixel distance of the capacitive pen in the process of 0.001 seconds is usually not more than 1, and this monitoring rate is sufficient to obtain a large number of drawing points describing the drawn line for subsequent sparse sampling.

[0149] The sampling method of the drawn line provided by the above embodiments of the application can be applied to three-dimensional technologies such as webgl, for example, when constructing surfaces of various shapes, the drawing points in the target sampling set can be used to achieve the construction.

[0150] Figure 5 is a flowchart of a rendering method provided by an exemplary embodiment of the present disclosure. As shown in Figure 5 The rendering method comprises:

[0151] In step 502, based on the plurality of drawing points included in the target sampling set obtained by the sampling method of the drawn line, the spline line length, the spline line curvature and the spline line vertex coordinates are determined to obtain the spline line information.

[0152] In this embodiment, a target sampling set can be obtained based on the sampling method for drawing lines provided in any of the above embodiments. Based on the drawing points thinned out by the above sampling method for drawing lines, the position information of each drawing point in the target sampling set can be obtained. Based on the position information and the line segment information fitted during the thinning process, the spline length can be obtained. Based on the curvature calculation of the drawing points during the thinning process, the spline curvature can be obtained, or the spline curvature can be calculated based on the position information of each drawing point. Moreover, based on the drawing points in the target sampling set sorted by time, the first and last drawing points can be determined, and the position information of the first and last drawing points is the spline vertex coordinates.

[0153] Step 504 : Determine a display grid based on the spline information and the length information perpendicular to the spline direction, including a coordinate conversion relationship between the virtual space coordinate system and the texture map UV coordinate system.

[0154] Figure 6 This is a schematic diagram showing a grid in a virtual space coordinate system in an example of the present disclosure. Figure 6 As shown, the user selects spline S1. The spline information for spline S1 includes its virtual space coordinate length, curvature, the coordinates of vertices A1 and An, and the coordinate transformation between the virtual space coordinate system and the uv coordinate system. In this example, the length perpendicular to the spline direction is the distance Depth between spline S1 and spline S2.

[0155] Spline S2 can be obtained by translating spline S1 by Depth in a direction perpendicular to the spline, and then a display mesh is formed based on spline S1 and spline S2. The vertices of the display mesh include A1, A2, An, and An+1.

[0156] It should be noted that the selected spline may also be the spline S2, and the spline S1 is obtained by translating the spline S2 by Depth in a direction perpendicular to the spline.

[0157] Step 506: Obtain a set of uv coordinates of the information to be displayed in the uv coordinate system.

[0158] The information to be displayed may include an image to be displayed provided by a user, and in this case, a set of uv coordinates of all pixels of the image to be displayed in a uv coordinate system is obtained.

[0159] Step 508: Determine a virtual coordinate set of the information to be displayed in the virtual space coordinate system based on the uv coordinate set and the coordinate conversion relationship.

[0160] For any uv coordinate in the uv coordinate set, it is converted into a virtual coordinate in the virtual space coordinate system through the coordinate transformation relationship.

[0161] All uv coordinates in the uv coordinate set are traversed, and all virtual coordinates corresponding to the uv coordinates can be obtained by the above manner. A virtual coordinate set of the to-be-displayed information in the virtual space coordinate system is composed of all virtual coordinates corresponding to the uv coordinates.

[0162] At step 510, the to-be-displayed information is rendered in the virtual space based on the virtual coordinate set and the display grid, and a rendering image is obtained.

[0163] The display grid is placed in the virtual space. The area of the display grid in the virtual space is set as a rendering area. A rendering coordinate set in the rendering area is determined according to the virtual coordinate set, and each coordinate point in the rendering position rendering coordinate set is rendered based on a given rendering color, and a rendering image is obtained.

[0164] Any one of the sampling or rendering methods for drawing a line provided in the embodiments of the present disclosure can be executed by any appropriate device with data processing capability, including but not limited to: terminal devices and servers, etc. Alternatively, any one of the sampling or rendering methods for drawing a line provided in the embodiments of the present disclosure can be executed by a processor, such as a processor executing any one of the sampling or rendering methods for drawing a line mentioned in the embodiments of the present disclosure by calling corresponding instructions stored in a memory. Details are not described hereinafter.

[0165] Exemplary apparatus

[0166] Figure 7 is a structural schematic diagram of a sampling device for drawing a line provided in an exemplary embodiment of the present disclosure. As shown in Figure 7 the device provided in the present embodiment includes:

[0167] The line sampling module 71 is configured to obtain a first sampling set by sorting pixel information corresponding to a line drawn on a screen by a touch device according to time.

[0168] The first sampling set includes a plurality of drawing points corresponding to the line.

[0169] The interval extraction module 72 is configured to extract drawing points in the first sampling set according to a preset time interval to obtain a second sampling set.

[0170] The number of drawing points included in the second sampling set is less than or equal to the number of drawing points included in the first sampling set.

[0171] The sliding processing module 73 is configured to perform sliding processing on the drawing points in the second sampling set based on a sliding window of a preset length, and calculate a barycenter point of a plurality of pixel points in each sliding window to obtain a third sampling set.

[0172] The third sampling set includes a plurality of barycenter points.

[0173] a target sampling set corresponding to the line is obtained based on the third sampling set.

[0174] The sampling and rendering device for drawing a line provided by the embodiments of the present disclosure obtains a first sampling set by sorting pixel information corresponding to a line drawn on a screen by a touch device according to time; wherein the first sampling set includes a plurality of drawing points corresponding to the line; a second sampling set is obtained by extracting drawing points in the first sampling set according to a preset time interval; wherein the number of drawing points included in the second sampling set is less than or equal to the number of drawing points included in the first sampling set; a third sampling set is obtained by performing sliding processing on the drawing points in the second sampling set based on a sliding window of a preset length, and calculating a barycenter of a plurality of pixels in a window corresponding to each sliding to obtain a barycenter; wherein the third sampling set includes a plurality of barycenters; a target sampling set corresponding to the line is obtained based on the third sampling set; the embodiments of the present disclosure realize initial compression processing of the number of drawing points by time thinning; and by calculating the barycenter in the local window, the structure distribution of the drawing points is retained on the basis of further reducing the drawing points, the number of drawing points in the target sampling set processed by the embodiments of the present disclosure is greatly reduced compared with the original drawing line, and the structure distribution of the drawing points is retained, thereby avoiding the problem of losing distribution information due to the reduction of the number of drawing points.

[0175] In some optional embodiments, the target sampling module 74 includes:

[0176] The curvature thinning unit is configured to: form a plurality of line segments based on the plurality of drawing points included in the third sampling set; and perform curvature thinning on the third sampling set based on included angles between the plurality of line segments to obtain a fourth sampling set.

[0177] The sampling set unit is configured to: obtain a target sampling set corresponding to the line based on the fourth sampling set.

[0178] Optionally, the curvature thinning unit is specifically configured to: divide the third sampling set to obtain a plurality of subsets, each of which includes three consecutive drawing points; fit the three drawing points in each subset as two line segments to determine an included angle between the two line segments; and delete n drawing points from the third sampling set according to a relationship between the included angle and a first preset angle to obtain the fourth sampling set; wherein n is an integer greater than or equal to 0.

[0179] Optionally, the curvature thinning unit, when deleting n drawing points from the third sampling set according to a relationship between the included angle and the first preset angle to obtain the fourth sampling set, is configured to: in response to the included angle being greater than the first preset angle, record three continuous drawing points corresponding to the included angle into the fourth sampling set; and in response to the included angle being less than or equal to the first preset angle, delete a middle drawing point among the three continuous drawing points corresponding to the included angle, and record the other two drawing points into the fourth sampling set.

[0180] In some optional embodiments, the sampling set unit is specifically configured to perform drawing point deletion processing on the fourth sampling set based on a sum of part of the included angles corresponding to the plurality of line segments, to obtain the target sampling set.

[0181] Optionally, the sampling set unit is further configured to: determine an order among the plurality of subsets according to an order of the drawing points in the third sampling set; determine a sum of the included angles corresponding to each m continuous subsets in sequence; determine whether to perform drawing point deletion on the fourth sampling set based on a relationship between the sum of the m included angles and the second preset angle, to obtain the target sampling set; and wherein m is an integer greater than 1.

[0182] Optionally, when the sampling set unit determines the sum of the included angles corresponding to each m continuous subsets in sequence, it is configured to: determine a positive or negative of the included angle based on a direction of the included angle; and accumulate the included angles according to the positive or negative of the included angles, to obtain the sum of the m included angles.

[0183] Optionally, when the sampling set unit determines whether to perform drawing point deletion on the fourth sampling set based on a relationship between the sum of the m included angles and the second preset angle, to obtain the target sampling set, it is configured to: in response to the sum of the m included angles being less than or equal to the second preset angle, record two edge drawing points in the subset corresponding to the m included angles into the target sampling set, and delete all other drawing points; and in response to the sum of the m included angles being greater than the second preset angle, record the drawing points in the fourth sampling set corresponding to each of the m included angles into the target sampling set.

[0184] Optionally, when the sampling set unit records the two edge drawing points in the subset corresponding to the m included angles into the target sampling set, it is configured to: perform least squares line segment fitting on all the drawing points in the subset corresponding to the m included angles, to obtain a fitting line segment; and record two end points of the fitting line segment as the two edge drawing points into the target sampling set.

[0185] In some optional embodiments, the line sampling module 71 is specifically configured to acquire position information of a plurality of drawing points of the touch device on the screen according to a preset monitoring speed; wherein a time difference between each two drawing points is an inverse of the preset monitoring speed; in response to the number of the drawing points reaching a preset number, pixel information is obtained based on the preset monitoring speed, the plurality of position information and time information corresponding to each position information; the drawing points corresponding to the pixel information are sorted according to the time information, and a first sampling set is obtained.

[0186] Figure 8 is a structural schematic diagram of a rendering device provided by an example embodiment of the present disclosure. As shown in Figure 8 , the rendering device provided by the present embodiment includes:

[0187] The spline line information module 81 is configured to determine spline line length, spline line curvature and spline line vertex coordinates based on a plurality of drawing points included in the target sampling set obtained by the sampling method of drawing a line according to any of the above embodiments, and obtain spline line information.

[0188] The display grid determination module 82 is configured to determine a display grid based on selected spline line information and length information perpendicular to the direction of the spline line, and a coordinate conversion relationship between a virtual space coordinate system and a texture map uv coordinate system.

[0189] The uv coordinate set acquisition module 83 is configured to acquire a uv coordinate set of the to-be-displayed information in the uv coordinate system.

[0190] The virtual coordinate set determination module 84 is configured to determine a virtual coordinate set of the to-be-displayed information in the virtual space coordinate system based on the uv coordinate set and the coordinate conversion relationship.

[0191] The rendering module 85 is configured to render the to-be-displayed information in a virtual space based on the virtual coordinate set and the display grid, and obtain a rendering image.

[0192] Exemplary electronic device

[0193] Next, the electronic device according to the embodiments of the present disclosure will be described with reference to Figure 9 . The electronic device can be either or both of the first device and the second device, or a single device independent of them, which can communicate with the first device and the second device to receive the collected input signals therefrom.

[0194] Figure 9 FIG. 1 illustrates a block diagram of an electronic device according to an embodiment of the present disclosure.

[0195] As shown in Figure 9 , the electronic device includes one or more processors and a memory.

[0196] The processor can be a central processing unit (CPU) or other form of processing unit having data processing and / or instruction execution capabilities and can control other components in the electronic device to perform desired functions.

[0197] The memory can store one or more computer program products, which can include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory, for example, can include random access memory (RAM), cache memory, and / or the like. The non-volatile memory, for example, can include read-only memory (ROM), hard disk, flash memory, and / or the like. One or more computer program products can be stored on the computer-readable storage media, and the processor can execute the computer program products to implement the sampling or rendering method of drawing lines and / or other desired functions of various embodiments of the present disclosure described above.

[0198] In one example, the electronic device can further include an input device and an output device, which are interconnected through a bus system and / or other forms of connection mechanisms (not shown).

[0199] In addition, the input device can further include, for example, a keyboard, a mouse, and / or the like.

[0200] The output device can output various information, including determined distance information, direction information, and / or the like, to the outside. The output device can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and / or the like.

[0201] Of course, in order to simplify, Figure 9 Only some of the components related to the present disclosure among the electronic device are illustrated in FIG. 1, and components such as a bus, an input / output interface, and / or the like are omitted. In addition to this, the electronic device can further include any other appropriate components according to a specific application.

[0202] In addition to the above-described method and device, embodiments of the present disclosure can be a computer program product including computer program instructions that, when executed by a processor, cause the processor to perform steps of the sampling or rendering method of drawing lines according to various embodiments of the present disclosure described in the above parts of the specification.

[0203] The computer program product can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server.

[0204] Furthermore, embodiments of the present disclosure can also be a computer readable storage medium, having stored thereon computer program instructions which, when executed by a processor, cause the processor to perform the steps described in the foregoing disclosure of the present disclosure for the sampling or rendering method of drawing a line according to various embodiments of the present disclosure.

[0205] The computer readable storage medium can be any combination of one or more computer readable media. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0206] The above describes the basic principles of the present disclosure in combination with specific embodiments, but it should be noted that the advantages, benefits, effects and the like mentioned in the present disclosure are only examples and are not limiting, and these advantages, benefits, effects and the like cannot be considered as the must-have of each embodiment of the present disclosure. In addition, the above specific details are only for the purpose of example and understanding, and the above details do not limit the present disclosure to the above specific details.

[0207] Each embodiment in the present specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts between each embodiment can be understood by mutual reference. For system embodiments, since they are basically corresponding to method embodiments, the description is relatively simple, and the relevant parts can be understood by referring to the part of the method embodiment.

[0208] The block diagrams of devices, apparatuses, equipment, systems referred to in this disclosure are merely illustrative examples and are not intended to require or imply that the connection, arrangement, configuration must be as shown in the block diagrams. These devices, apparatuses, equipment, systems can be connected, arranged, configured in any manner as will be appreciated by those skilled in the art. Words such as "include," "contain," "have," and the like are open-ended words that are intended to mean "including but not limited to," and are to be taken in their broadest context. The words "or" and "and" as used herein are intended to mean "and / or," and are to be taken in their broadest context unless the context clearly indicates otherwise. The word "such as" as used herein is intended to mean "such as but not limited to," and is to be taken in its broadest context.

[0209] The methods and apparatuses of this disclosure can be implemented in a number of ways. For example, the methods and apparatuses of this disclosure can be implemented using software, hardware, firmware, or any combination of these methods and apparatuses. The above described order of steps for the methods is merely illustrative, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, the disclosure can also be implemented as a program recorded in a recording medium, which includes machine readable instructions for implementing the methods according to the disclosure. Thus, the disclosure also covers a recording medium storing a program for executing the methods according to the disclosure.

[0210] It is also important to note that the devices, equipment and methods of this disclosure can be split and / or recombined into various components or steps. These splits and / or recombination should be considered as equivalent to this disclosure.

[0211] The above description of the disclosed aspects is given for illustrative purposes and not intended to limit the scope or applicability of the disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the generic principles defined herein can be applied to other aspects without departing from the scope of the disclosure. Thus, the present disclosure is not intended to be limited to the aspects shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0212] The above description has been given for the purpose of illustration and description. Furthermore, this description does not purport to limit the embodiments of the disclosure to the form disclosed herein. Although several example aspects and embodiments have been discussed above, those of ordinary skill in the art will appreciate a variety of modifications, alternatives, permutations, additions, and sub-combinations that fall within the scope of the disclosure.

Claims

1. A sampling method for drawing lines, characterized in that: include: Based on pixel information corresponding to a line drawn on the screen by the touch device, the pixel information is sorted according to time to obtain a first sampling set; wherein the first sampling set includes multiple drawing points corresponding to the line; Extracting the drawing points from the first sampling set at a preset time interval to obtain a second sampling set; wherein the number of drawing points included in the second sampling set is less than or equal to the number of drawing points included in the first sampling set; Sliding the drawing points in the second sampling set based on a sliding window of a preset length, and finding the centroid of a plurality of pixel points in the window corresponding to each sliding, to obtain a third sampling set; wherein the third sampling set includes a plurality of centroids; Based on the third sampling set, obtaining a target sampling set corresponding to the line; Obtaining a target sampling set corresponding to the line based on the third sampling set includes: forming a plurality of line segments based on a plurality of drawing points included in the third sampling set, performing curvature extraction on the third sampling set based on angles between the plurality of line segments to obtain a fourth sampling set; and obtaining a target sampling set corresponding to the line based on the fourth sampling set; The method further comprises: forming a plurality of line segments based on a plurality of drawing points included in the third sampling set, and performing curvature extraction on the third sampling set based on angles between the plurality of line segments to obtain a fourth sampling set. Segmenting the third sampling set to obtain a plurality of subsets; wherein each subset includes three consecutive drawing points; Fitting the three plotted points in each of the subsets into two line segments, and determining the angle between the two line segments; According to the relationship between the included angle and the first preset angle, n plotting points are deleted from the third sampling set to obtain a fourth sampling set; wherein n is an integer greater than or equal to 0.

2. The method according to claim 1, characterized in that The step of deleting n plotting points from the third sampling set according to the relationship between the included angle and the first preset angle to obtain a fourth sampling set includes: In response to the included angle being greater than the first preset angle, recording three consecutive drawing points corresponding to the included angle into the fourth sampling set; In response to the included angle being less than or equal to the first preset angle, a middle drawing point among three consecutive drawing points corresponding to the included angle is deleted, and the other two drawing points are recorded in the fourth sampling set.

3. The method according to claim 1, characterized in that The obtaining, based on the fourth sampling set, a target sampling set corresponding to the line includes: Based on the sum of some included angles among the multiple included angles corresponding to the multiple line segments, the drawing points in progress of the fourth sampling set are deleted to obtain the target sampling set.

4. The method according to claim 3, characterized in that The deleting of the drawing points in progress on the fourth sampling set based on the sum of some of the multiple angles corresponding to the multiple line segments to obtain the target sampling set includes: determining an order among the plurality of subsets according to an order of drawing points in the third sampling set; Determine in sequence the sum of the angles corresponding to each of m consecutive subsets; Based on the relationship between the sum of the m included angles and the second preset angle, it is determined whether to delete the drawing points of the fourth sampling set to obtain a target sampling set; wherein m is an integer greater than 1.

5. The method according to claim 4, characterized in that The sequentially determining the sum of the angles corresponding to each of the m consecutive subsets includes: determining whether the angle is positive or negative based on the direction of the angle; The m angles are accumulated according to their positive and negative values ​​to obtain the sum of the m angles.

6. The method according to claim 4, characterized in that The determining whether to delete drawing points from the fourth sampling set based on the relationship between the sum of the m included angles and the second preset angle to obtain a target sampling set includes: In response to the sum of the m included angles being less than or equal to the second preset angle, recording two edge drawing points in the subset corresponding to the m included angles into the target sampling set, and deleting all other drawing points; In response to the sum of the m angles being greater than the second preset angle, a drawing point in the fourth sampling set corresponding to each of the m angles is recorded in the target sampling set.

7. The method according to claim 6, characterized in that The step of recording two edge drawing points in the subset corresponding to the m angles into the target sampling set includes: Performing least squares line segment fitting on all the plotted points in the subset corresponding to the m angles to obtain a fitted line segment; The two endpoints of the fitting line segment are recorded in the target sampling set as the two edge drawing points.

8. The method according to any one of claims 1 to 7, characterized in that: The step of obtaining a first sampling set by sorting pixel information corresponding to a line drawn on the screen by the touch device according to time includes: Acquiring position information of a plurality of drawing points on the screen of the touch device according to a preset monitoring speed; wherein the time difference between each two drawing points is the inverse of the preset monitoring speed; In response to the number of the drawing points reaching a preset number, obtaining the pixel information based on the preset monitoring speed, the plurality of position information and time information corresponding to each piece of the position information; The drawing points corresponding to the pixel information are sorted according to the time information to obtain the first sampling set.

9. A rendering method, characterized in that: include: Determine the spline length, the spline curvature, and the spline vertex coordinates based on the plurality of drawing points included in the target sampling set obtained by the sampling method for drawing a line according to any one of claims 1 to 8, and obtain spline information; Determine a display grid based on the spline information and the length information perpendicular to the spline direction, wherein the coordinate conversion relationship between the virtual space coordinate system and the texture map UV coordinate system; Get the uv coordinate set of the information to be displayed in the uv coordinate system; Determining a virtual coordinate set of the information to be displayed in the virtual space coordinate system based on the UV coordinate set and the coordinate conversion relationship; Based on the virtual coordinate set and the display grid, the information to be displayed is rendered in a virtual space to obtain a rendered image.

10. A sampling device for drawing lines, characterized in that: include: A line sampling module, configured to, based on pixel information corresponding to a line drawn on the screen by the touch device, sort the pixel information by time to obtain a first sampling set; wherein the first sampling set includes a plurality of drawing points corresponding to the line; an interval extraction module, configured to extract the drawing points in the first sampling set at a preset time interval to obtain a second sampling set; wherein the number of drawing points included in the second sampling set is less than or equal to the number of drawing points included in the first sampling set; a sliding processing module, configured to perform sliding processing on the drawing points in the second sampling set based on a sliding window of a preset length, and to calculate a centroid point for a plurality of pixel points within the window corresponding to each sliding operation, to obtain a third sampling set; wherein the third sampling set includes a plurality of centroid points; A target sampling module for obtaining a target sampling set corresponding to the line based on the third sampling set; The target sampling module includes: a curvature thinning unit, configured to construct a plurality of line segments based on a plurality of drawing points included in the third sampling set, and perform curvature thinning on the third sampling set based on angles between the plurality of line segments to obtain a fourth sampling set; a sampling set unit, configured to obtain a target sampling set corresponding to the line based on the fourth sampling set; The curvature thinning unit is specifically configured to segment the third sampling set to obtain multiple subsets, each of which includes three consecutive drawing points; fit the three drawing points in each subset into two line segments; and determine the angle between the two line segments; based on the relationship between the angle and a first preset angle, delete n drawing points from the third sampling set to obtain a fourth sampling set; wherein n is an integer greater than or equal to 0.

11. A rendering device, characterized in that: include: A spline information module, configured to determine a spline length, a spline curvature, and spline vertex coordinates based on a plurality of drawing points included in a target sampling set obtained by the line drawing sampling method according to any one of claims 1 to 8, thereby obtaining spline information; a display grid determination module for determining a display grid based on selected spline information and length information perpendicular to the spline direction, wherein a coordinate conversion relationship between a virtual space coordinate system and a texture map UV coordinate system; The uv coordinate set acquisition module is used to obtain the uv coordinate set of the information to be displayed in the uv coordinate system; a virtual coordinate set determining module, configured to determine a virtual coordinate set of the information to be displayed in the virtual space coordinate system based on the UV coordinate set and the coordinate conversion relationship; A rendering module is used to render the information to be displayed in a virtual space based on the virtual coordinate set and the display grid to obtain a rendered image.

Citation Information

Patent Citations

  • Method and device for graphic rendering

    CN101216945A

  • Sketch-based image matching method and device

    CN111931794A