Freehand pattern recognition method, computer program product and equipment

By sampling and clustering the drawing trajectory of the user on the electronic whiteboard, the shapes drawn by the user are automatically identified, which solves the problems of cumbersome operations and poor flexibility in the prior art and improves the user experience.

CN119919681AInactive Publication Date: 2025-05-02HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510402809.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-01
Publication Date
2025-05-02
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When users draw graphics, existing electronic whiteboards need to first select shapes from the graphics list. The operation is cumbersome and users can only select existing graphics, which has poor flexibility and poor user experience.

Method used

By sampling the track points on the user-drawn trajectory, filtering out possible vertex points, clustering, determining the vertices set of trajectories, thereby automatically identifying the shapes drawn by the user.

Benefits of technology

It realizes that users do not need to select the graphics first when drawing graphics, and directly draw and automatically recognize the shapes, simplifying the operation process and improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919681A_ABST
    Figure CN119919681A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a hand-drawn pattern recognition method, a computer program product and equipment. The method comprises the following steps: acquiring a drawing track of a user, sampling track points in the drawing track to obtain a sampling point sequence, screening out target sampling points which are possibly vertexes from the sampling point sequence, clustering the target sampling points, classifying the target sampling points within a certain distance range into one class, and extracting the target sampling points from the target sampling points. And determining a vertex in the drawn trajectory based on the target sampling points of each category obtained by clustering, and then determining the shape of the drawn trajectory based on the vertex. In this way, the shape of the user drawing track can be automatically recognized, and then the graph with the same shape is output, so that graph drawing is simpler, more convenient and more flexible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of interactive devices, and in particular to a hand-drawn graphic recognition method, a computer program product, a device and a storage medium. Background Art

[0002] In order to facilitate users to write on the blackboard, many interactive devices (such as tablets) can provide an electronic whiteboard function. Users can write on the whiteboard with a stylus or finger. For example, users can draw some graphics on the electronic whiteboard. At present, in order to enable users to draw graphics on the electronic whiteboard, a graphic list is usually pre-set in the electronic whiteboard. The graphic list includes graphics of various shapes. When the user needs to draw a certain shape of graphics, he can first select the shape of the graphic in the graphic list, and then draw it. This method requires the user to make a selection operation every time he draws a graphic, which is cumbersome, and the user can only select existing graphics in the graphic list for drawing, which makes the graphic drawing process not flexible enough and the user experience is poor. Summary of the invention

[0003] In view of this, the present application provides a hand-drawn graphic recognition method, computer program product, device and storage medium.

[0004] According to a first aspect of the present application, a hand-drawn graphic recognition method is provided, the method comprising: Sampling the trajectory points on the trajectory drawn by the user to obtain a sampling point sequence, wherein the sampling points in the sampling point sequence are arranged in the order of drawing; Filtering out a target sampling point from the sampling point sequence, wherein an angle between a straight line formed by two sampling points before and after the target sampling point and the target sampling point is greater than a preset first angle threshold; Performing clustering processing on the target sampling points, and determining a vertex in the drawing trajectory based on the target sampling points in each category obtained by clustering, so as to obtain a vertex set of the drawing trajectory, wherein the distance between the target sampling points in each category is less than a preset first distance threshold; A shape of the drawing trajectory is determined based on the set of vertices.

[0005] According to a second aspect of the present application, a computer program product is provided, wherein the computer program product comprises a computer program, and when the computer program is executed, the method mentioned in the first aspect is implemented.

[0006] According to a third aspect of the present application, an electronic device is provided, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein the processor implements the method mentioned in the first aspect when executing the computer program.

[0007] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed, the method mentioned in the first aspect is implemented.

[0008] By applying the solution provided by the present application, the user's drawing trajectory can be obtained, the trajectory points in the drawing trajectory can be sampled to obtain a sampling point sequence, and then the target sampling points that may be vertices can be screened out from the sampling point sequence, and the target sampling points can be clustered to classify the target sampling points within a certain distance range into one category, and a vertex in the drawing trajectory can be determined based on the target sampling points of each category obtained by clustering, and then the shape of the drawing trajectory can be determined based on the vertex. In this way, the shape of the user's drawing trajectory can be automatically identified, and then a graphic of the same shape can be output, making graphic drawing easier and more flexible.

[0009] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0011] Figure 1 It is a schematic diagram of drawing graphics in the related art.

[0012] Figure 2 It is a flowchart of a hand-drawn graphic recognition method according to an embodiment of the present application.

[0013] Figure 3 It is a schematic diagram of selecting target sampling points from a sampling point sequence according to an embodiment of the present application.

[0014] Figure 4 It is a schematic diagram of clustering target sampling points according to an embodiment of the present application.

[0015] Figure 5A It is a schematic diagram of removing noise vertices according to an embodiment of the present application.

[0016] Figure 5B , Figure 5C , Figure 5D It is a schematic diagram of the trajectory drawn by the user and the final output graphics in the embodiment of the present application.

[0017] Figure 6 , Figure 7 , Figure 8 It is a schematic diagram of optimizing vertices in a vertex set according to an embodiment of the present application.

[0018] Fig. 9 It is a schematic diagram of the logical structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0019] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0020] Interactive devices such as tablets usually provide an electronic whiteboard function, and users can write on the whiteboard with a stylus or a finger. For example, users can draw some graphics on the electronic whiteboard. Figure 1 As shown, usually a graphic list is pre-set in the electronic whiteboard, and the graphic list includes graphics of various shapes, such as straight lines, triangles, circles, etc. When the user needs to draw a certain shape of graphic, he can first select the graphic of the shape in the graphic list, and then draw it. For example, when the user wants to draw a circle, he can first click the circle, and then operate in the interactive interface to draw the circle.

[0021] This method requires the user to select a graphic each time they draw a graphic, which is cumbersome, and the user can only select existing graphics in the graphic list for drawing, making the graphic drawing process inflexible and the user experience poor.

[0022] Based on this, an embodiment of the present application provides a hand-drawn graphic recognition method, and the user can directly use a stylus or finger to draw graphics in an interactive interface. After detecting the user's hand-drawn operation, the user's drawing trajectory can be obtained, and the trajectory points in the drawing trajectory can be sampled to obtain a sampling point sequence. Then, the vertices in the drawing trajectory can be determined based on the sampling point sequence, and the shape of the user's drawing trajectory can be determined based on the vertices. Then, based on the recognized shape, a standard graphic of the same shape can be automatically displayed in the interactive interface. Therefore, when the user draws a graphic, he can operate directly in the interactive interface without having to perform a graphic selection operation first, making the drawing of the graphic simpler.

[0023] The hand-drawn graphics recognition method provided in the embodiment of the present application can be executed by various devices with user blackboard writing function, for example, it can be a tablet (such as a conference tablet, a teaching tablet, etc.), a mobile phone, a computer, etc. These devices can provide an interactive interface, and the user can perform interactive operations such as writing and drawing in the interactive interface through finger touch, a stylus, etc. The hand-drawn graphics mentioned in the embodiment of the present application can be graphics drawn by the user on the interactive interface through finger touch, or can also be graphics drawn by the user on the interactive interface through various input devices such as a stylus, a mouse, etc. For example, in some scenarios, these devices can provide an electronic whiteboard function so that the user can write or draw on the whiteboard.

[0024] like Figure 2 As shown, the hand-drawn graphic recognition method provided in the embodiment of the present application may include the following steps: S202, sampling the trajectory points on the trajectory drawn by the user to obtain a sampling point sequence, wherein the sampling points in the sampling point sequence are arranged in the order of drawing; In step S202, the trajectory points on the trajectory drawn by the user can be sampled to obtain a sampling point sequence. The drawing trajectory can be a trajectory formed by the user's drawing operation on the interactive interface through finger touch, stylus touch, or mouse and other input devices. For example, taking the example of a user using a finger to draw a graphic on the interactive interface, the coordinates of the current touch position of the finger can be recorded during the movement of the finger, that is, a trajectory point is obtained, and these trajectory points are connected in sequence to form a drawing trajectory. Since there are a large number of trajectory points on the drawing trajectory, if the trajectory points are directly processed, the amount of calculation is large. Therefore, the trajectory points on the drawing trajectory can be sampled to obtain a sampling point sequence, and the sampling points in the sampling point sequence are arranged in the order of drawing. The sampling interval can be flexibly set based on actual needs, and the embodiment of the present application is not limited.

[0025] S204, selecting a target sampling point from the sampling point sequence, wherein an angle between a straight line formed by two sampling points before and after the target sampling point and the target sampling point is greater than a preset first angle threshold; In the embodiment of the present application, when identifying the shape of a drawing trajectory, vertices can be determined from the drawing trajectory, and then the shape of the drawing trajectory can be determined based on the vertices. Therefore, in step S204, the target sampling points that may be vertices can be first screened out from the sampling point sequence. Considering that the angles of the positions of the vertices in the figure usually change greatly, that is, the vertex angles corresponding to the vertices are usually greater than a certain angle threshold, when screening the target sampling points from the sampling points, each sampling point in the sampling point sequence can be traversed. For the currently traversed sampling point, the angle between the sampling point and the straight line A formed by the previous sampling point of the sampling point, and the straight line B formed by the sampling point and the next sampling point of the sampling point can be determined. If the angle is greater than the preset first angle threshold, the sampling point is used as the target sampling point. Among them, the first angle threshold can be flexibly set based on the actual situation. For example, for the vertex angle of a polygon, it is usually greater than 10°, so the first angle threshold can be set to 10°.

[0026] For example, Figure 3 As shown, assuming that points 1, 2, 3, 4, 5, and 6 are sampling points arranged in the sampling point sequence in the order of drawing, for point 3, if the angle between the straight line A formed by point 3 and point 2 and the straight line B formed by point 3 and point 4 (such as the angle α in the figure) is greater than 10°, then point 3 is taken as the target sampling point.

[0027] S206, performing clustering processing on the target sampling points, and determining a vertex in the drawing trajectory based on the target sampling points in each category obtained by clustering, so as to obtain a vertex set of the drawing trajectory, wherein the distance between the target sampling points in each category is less than a preset first distance threshold; Considering that when a user draws a figure, due to hand shaking and other reasons, the straight line drawn is often not a standard straight line, so some of the target sampling points determined in step S204 may not be vertices, for example, they may be points around the vertices. Figure 4 As shown, due to factors such as user hand shaking, the line segments around the vertices of the hand-drawn triangle are not standard straight lines (such as the three areas boxed in the figure), but wavy curves, so many sampling points in these line segments will be determined as target sampling points, but there is only one vertex among these target sampling points. Therefore, in step S206, the target sampling points can be clustered, and a bunch of points within a certain distance range can be clustered into one category, so that one or more categories can be obtained.

[0028] The distance between target sampling points in the same category is less than a preset first distance threshold, which can be set based on actual needs. For example, the approximate size of the corner corresponding to the vertex can be determined based on the size of the figure drawn by the user, and then the first distance threshold is determined based on the size.

[0029] After clustering the target sampling points, a vertex in the drawing trajectory can be determined based on the target sampling points in each category obtained by clustering to obtain a vertex set of the drawing trajectory. For example, the center of the target sampling points of this category can be taken as the vertex.

[0030] For example, Figure 4 For example, after clustering the target sampling points, three categories may be obtained, each category may include multiple target sampling points, and then a vertex of the triangle may be determined based on the target sampling points in each category.

[0031] S208: Determine the shape of the drawing trajectory based on the vertex set.

[0032] In step S208, after determining the vertex set formed by the vertices in the drawing trajectory, the shape of the drawing trajectory can be determined based on the vertex set. For example, the shape of the drawing trajectory can be determined based on the number of vertices, the angle between the edges connecting the vertices, the distance between the vertices, etc.

[0033] In some embodiments, in order to reduce the amount of calculation, the coordinates of the sampling points in the sampling point sequence are normalized coordinates. For example, considering that the original coordinates of the trajectory points in the drawn trajectory are relatively complex and the amount of calculation is large, after sampling the trajectory points, the sampled sampling points can be normalized. When the coordinates of the sampling points in the sampling point sequence are normalized, the minimum and maximum X, Y coordinates of all the sampling points in the sampling point sequence can be determined to form a rectangular box (i.e., a bounding box) that can surround all points, and then the bounding box can be scaled to scale the coordinates of all the sampling points to a fixed range. For example, the coordinates of the sampling points are normalized to between 0 and 1.

[0034] In some embodiments, when determining a vertex in the drawing trajectory based on the target sampling points in each category obtained by clustering, the average coordinates of the target sampling points in each category can be determined, and the average coordinates can be used as the coordinates of a vertex in the drawing trajectory. For example, the coordinate values ​​of the X coordinates of the target sampling points in each category can be averaged as the coordinate value of the X coordinate of the vertex, and the coordinate values ​​of the Y coordinates of the target sampling points in each category can be averaged as the coordinate value of the Y coordinate of the vertex.

[0035] In some embodiments, when determining a vertex in the drawing trajectory based on the target sampling points in each category obtained by clustering, the median coordinates of the target sampling points in each category may also be determined, and the median coordinates may be used as the coordinates of a vertex in the drawing trajectory. For example, the median coordinate value of the X coordinate of the target sampling points in each category may be determined as the coordinate value of the X coordinate of the vertex, and the median coordinate value of the Y coordinate of the target sampling points in each category may be determined as the coordinate value of the Y coordinate of the vertex.

[0036] Considering that the vertices determined in the above manner may still contain some noise vertices, these noise vertices may be formed due to hand shaking when the user draws the graphics, the user's writing personality, etc. In order to remove these noise vertices, more accurate vertices can be obtained. In some embodiments, when determining the shape of the drawing trajectory based on a vertex set, the noise vertices in the vertex set can be first removed to obtain a denoised vertex set, and then the shape of the drawing trajectory is determined based on the denoised vertex set. Among them, considering that noise vertices are often points with larger corners, that is, they usually deviate from the normal drawing trajectory, and the degree of deviation is small.

[0037] Therefore, when determining the noise vertices, the vertices in the vertex set may be arranged in the order of drawing. For a vertex in the vertex set, if the vertex deviates from the target trajectory and is within a preset distance range of the target trajectory, the vertex is determined as a noise vertex, wherein the target trajectory may be a trajectory formed by at least two vertices adjacent to the vertex in the vertex set. For example, the target trajectory may be a normal drawing trajectory of the user, and the noise vertex may be a point that deviates from the normal drawing trajectory due to hand shaking or other reasons.

[0038] In some embodiments, considering that the noise vertex is a vertex with a larger corner, the angle between the straight line formed by the noise vertex and the vertex in front of it and the straight line formed by the vertices in front and behind the noise vertex is often smaller. Therefore, the noise vertex can also be determined based on the angle. For example, if the angle between the straight line A formed by the noise vertex and the vertex in front of the vertex and the straight line B formed by the vertex in front of the vertex and the vertex in the back of the vertex is less than the preset second angle threshold, then the vertex is determined as a noise vertex. Among them, the second angle threshold can be flexibly set based on actual needs, usually a smaller angle value, such as 10°.

[0039] For example, Figure 5A As shown, point 1, point 2, point 3, point 4, point 5, and point 6 are vertices in the vertex set. For point 3, if the angle between the straight line A formed by point 2 and point 3 and the straight line B formed by point 2 and point 4 (such as the β angle in the figure) is less than 10° (threshold), then point 3 is considered to be a noise vertex.

[0040] When removing noise vertices from a vertex set to obtain a denoised vertex set, this can be achieved in a variety of ways. In some embodiments, the denoised vertex set can be determined based on the following method: starting from the second vertex in the vertex set, traversing the vertices in the vertex set, for the currently traversed vertex, if the angle between the straight line formed by the two vertices before and after the vertex and the straight line formed by the previous vertex of the vertex and the vertex is less than a preset second angle threshold, then delete the vertex from the vertex set, and after traversing all the vertices in the vertex set, use the remaining vertices in the vertex set as vertices in the denoised vertex set; wherein, after performing the vertex deletion operation, the previous vertex and the next vertex of the vertex in the vertex set are determined based on the vertex set after the vertex is deleted. That is, the previous vertex and the next vertex of each vertex are determined based on the latest vertex set.

[0041] The first vertex in the vertex set can be directly used as the vertex in the denoising vertex set without traversal, and the last vertex in the vertex set can be the first vertex in the vertex set.

[0042] For example, assuming that the vertex set includes 6 vertices, namely point 1, point 2, point 3, point 4, point 5, and point 6, we can start from point 2 to traverse each vertex. For point 2, if the angle between the straight line formed by point 1 and point 2 and the straight line formed by point 1 and point 3 is less than 10°, then delete point 2. At this time, the vertex set includes point 1, point 3, point 4, point 5, and point 6. Then traverse the following vertices from point 3. For point 3, repeat the above process. For example, if the straight line formed by point 3 and point 1 and the straight line formed by point 1 and point 4 is less than 10°, then delete 3. At this time, the vertex set includes point 1, point 4, point 5, and point 6. Then repeat the above process from point 4 until traversing to point 6. At this time, the remaining vertices in the vertex set can be used as vertices in the denoising vertex set.

[0043] Since this method only needs to calculate the angle between adjacent vertices, the calculation process is simple and involves fewer mathematical operations. Therefore, the overall calculation amount is small and no complex iterative process is required. The denoising operation can be completed quickly when processing large-scale vertex sets.

[0044] In some embodiments, the denoised vertex set can also be determined based on the following method: using the vertex set as the current vertex set in the first round of iteration, the following iterative process is performed until the number of vertices in the current vertex set remains unchanged: starting from the second vertex in the current vertex set, traverse the vertices in the current vertex set, for the currently traversed vertex, if the angle between the straight line formed by the two vertices before and after the vertex and the straight line formed by the previous vertex of the vertex and the vertex is less than the preset second angle threshold, then move the vertex into the target point set, otherwise, move the next vertex of the vertex into the target point set, after traversing all the vertices in the current vertex set, use the obtained target point set as the current vertex set in the next round of iteration, and after the iterative process ends, use the target point set obtained at the end of the iteration as the denoised vertex set. Wherein, after executing the operation of moving the vertex into the target point set, the previous vertex and the next vertex of the vertex in the vertex set are determined based on the current vertex set after the vertex is removed, that is, the previous vertex and the next vertex of each vertex are determined based on the latest vertex set.

[0045] Among them, for the first vertex in the vertex set, it can be directly used as the vertex in the denoising vertex set without traversal. For the last vertex in the vertex set, the next vertex can be the first vertex in the vertex set. For example, assuming that the vertex set includes 6 vertices, namely point 1, point 2, point 3, point 4, point 5, and point 6, each vertex can be traversed starting from point 2. For point 2, if the angle between the straight line formed by point 1 and point 2 and the straight line formed by point 1 and point 3 is greater than 10°, then point 2 is moved into the target point set K. At this time, the vertex set includes point 1, point 3, point 4, point 5, and point 6, and the target point set K includes point 2. If the angle between the straight line formed by point 1 and point 2 and the straight line formed by point 1 and point 3 is less than or equal to 10°, then point 3 is moved into the target point set K. At this time, the vertex set includes point 1, point 2, point 4, point 5, and point 6, and the target point set K includes point 3.

[0046] Assume that point 2 is moved into the target point set K, and then the following vertices are traversed starting from point 3. For point 3, the above process is repeated. For example, if the straight line formed by point 3 and point 1, and the straight line formed by point 1 and point 4 are greater than 10°, then point 3 is moved into the target point set K. At this time, the vertex set includes point 1, point 4, point 5, and point 6, and the target point set K includes point 2 and point 3. For point 4, the same steps are performed until point 6 is traversed to obtain the target point set K. Assume that the target point set K includes point 2, point 3, and point 4.

[0047] At this point, the above steps can be repeated to traverse the target point set K to obtain a new target point set, and the above process is repeated until the number of vertices in the target point set no longer changes, and the current target point set is used as the denoising vertex set.

[0048] Through multiple rounds of iterative optimization, this method can gradually screen out the vertices that best meet the geometric structure characteristics, thereby removing noise more accurately. In each iteration, the structure of the vertex set will be dynamically adjusted according to the current state, so that it can better adapt to complex geometric shapes.

[0049] In some embodiments, when determining the denoised vertex set, the vertices in the vertex set may also be traversed. For the currently traversed vertex, if the distance of the vertex from the straight line formed by the two vertices before and after the vertex is less than a preset target distance, the vertex is deleted from the vertex set. After traversing all the vertices in the vertex set, the remaining vertices in the vertex set are used as vertices in the denoised vertex set; wherein, after performing the vertex deletion operation, the previous vertex and the next vertex of the vertex in the vertex set are determined based on the vertex set after the vertex is deleted. The target distance can be flexibly set based on actual needs.

[0050] For example, suppose the vertex set includes 6 vertices, namely point 1, point 2, point 3, point 4, point 5, and point 6. You can traverse from the beginning. When you traverse to point 2, you can determine whether point 2 falls near the straight line formed by point 1 and point 3 (within a certain distance range). If so, remove point 2. If not, keep point 2. If point 2 is removed, the next step is to traverse to point 3. Similarly, you can determine whether point 3 is within a certain distance range of the straight line formed by point 1 and point 4. If so, point 3 is determined to be a noise vertex. In this way, you can remove the noise points in the vertex set and get the vertex set.

[0051] This method determines whether to delete a vertex by calculating the distance from the vertex to the straight line. The calculation process is simple and efficient. It is suitable for processing simple geometric shapes. It has high calculation efficiency and can effectively retain the main geometric features.

[0052] In some embodiments, if the shape of the drawing trajectory is a circle, there are no vertices in the drawing trajectory, and therefore, there is no need to determine the shape of the drawing trajectory by determining a vertex set. Therefore, after obtaining the sampling point sequence, it is possible to first determine whether the shape of the drawing trajectory is a circle based on the sampling point sequence. If it is not a circle, the step of selecting the target sampling point from the sampling point sequence and further determining the vertex is performed.

[0053] In some embodiments, if the sampling points in the sampling point sequence are normalized sampling points, when determining whether the shape of the drawing trajectory is a circle based on the sampling point sequence, the center point of each sampling point in the sampling point sequence can be determined first, and then it can be determined whether the distance between each sampling point in the sampling point sequence and the center point is greater than a preset second distance threshold. If so, the shape of the drawing trajectory is determined to be a circle, otherwise, the drawing trajectory is determined to be non-circular. The second distance threshold can be set based on the normalized coordinates. For example, when the sampling point coordinates are normalized to 0~1, the second distance threshold can be set to a value close to 1 to ensure that the trajectory is a circle, for example, it can be set to 0.8.

[0054] In some embodiments, it can also be determined whether the difference between the distances of each sampling point in the sampling point sequence and the center point is greater than a preset difference. If so, the shape of the drawn trajectory is determined to be non-circular, otherwise, it is determined to be circular. The difference between the distances of each sampling point and the center point can be an absolute difference or a relative difference, as long as it can reflect the degree of difference between the distances, and the embodiment of the present application does not limit this.

[0055] Considering that the distance between the starting point and the end point of a straight line and a polyline is often large, after determining the vertex set, it is possible to determine whether the drawing trajectory is a straight line or a polyline based on whether there is a vertex in the vertex set. For example, in some embodiments, if the distance between the starting point and the end point in the drawing trajectory is greater than or equal to a preset third distance threshold, and there is at least one vertex in the vertex set, the shape of the drawing trajectory is determined to be a polyline. The third distance threshold can be flexibly set based on factors such as the user's drawing habits and the size of the interactive interface.

[0056] In some embodiments, if the distance between the start point and the end point in the drawing trajectory is greater than or equal to a preset third distance threshold, and there is no vertex in the vertex set, the shape of the drawing trajectory is determined to be a straight line.

[0057] If there are 3 or more vertices in the vertex set, and the drawing trajectory is determined to be not a polyline based on the distance between the starting point and the end point in the drawing trajectory, then the drawing trajectory is a polygon. Considering that polygons are concave polygons and convex polygons, it is possible to first determine whether the hand-drawn shape is a concave polygon or a convex polygon based on the vertex set. For example, in some embodiments, if the distance between the starting point and the end point in the drawing trajectory is less than a preset third distance threshold, and for each connecting edge formed by two adjacent vertices in the vertex set, all vertices in the vertex set are located on the same side of the connecting edge, then the drawing trajectory is determined to be a convex polygon.

[0058] In some embodiments, if the distance between the start point and the end point in the drawing trajectory is less than a preset third distance threshold, and there is at least one connecting edge among the connecting edges formed by two adjacent vertices in the vertex set so that the vertices in the vertex set are located on both sides of the connecting edge, then the drawing trajectory is determined to be a concave polygon.

[0059] Usually, considering that the user's drawing trajectory is caused by hand shaking and other reasons, the graphics drawn are not standard graphics, for example, the circle drawn is not a standard circle, and the straight line drawn may be a wavy line, etc. Therefore, after recognizing the shape of the user's drawing trajectory, a standard graphic of the same shape can be automatically output based on the user's drawing trajectory and displayed on the interactive interface.

[0060] For example, in some embodiments, when the drawn trajectory is determined to be a circle based on the sampling point sequence, a standard circle can be output to the user. For example, a target circle can be displayed in the interactive interface; wherein the center of the target circle is the above-mentioned center point, and the radius of the target circle is the average value of the distance between each sampling point in the sampling point sequence and the center point.

[0061] In some embodiments, after determining that the shape of the drawing trajectory is a polyline, a standard polyline may be output to the user. For example, a target polyline may be displayed on an interactive interface, where the target polyline is obtained by sequentially connecting the start point and the end point in the drawing trajectory and each vertex in the vertex set in the order of drawing.

[0062] In some embodiments, after determining that the shape of the drawing trajectory is a straight line, a standard straight line can be output to the user. For example, a target straight line can be displayed on the interactive interface, where the target straight line is a straight line formed by the starting point and the end point of the drawing trajectory. Figure 5B As shown, the left picture is the trajectory drawn by the user, and the right picture is the output target straight line.

[0063] In some embodiments, after determining that the shape of the drawing trajectory is a concave polygon, the concave polygon can be output to the user. For example, the target concave polygon can be displayed on the interactive interface, and the vertices of the target concave polygon are the vertices in the vertex set, that is, a closed figure can be obtained by connecting the vertices in the vertex set in the order of drawing, as the target concave polygon, and output to the user.

[0064] If the drawing trajectory is a convex polygon, there are some special convex polygons with special angles or special side lengths. For example, taking a triangle as an example, a triangle can be further divided into ordinary triangles and special triangles such as equilateral triangles, isosceles triangles, and right triangles. Considering that for special convex polygons, due to the particularity of their angles and side lengths, for example, the three vertex angles of an equilateral triangle are all 60°, and the triangle obtained by connecting the vertices in the vertex set may not be a standard equilateral triangle, therefore, further optimization processing is required to output standard graphics to users.

[0065] Therefore, in some embodiments, when determining that the shape of the drawing trajectory is a convex polygon, it is possible to determine whether the drawing trajectory is a special convex polygon based on the angles of adjacent connecting edges in the connecting edges obtained by connecting the vertices in the vertex set in the order of drawing, and the number of vertices in the vertex set. For example, the vertices in the vertex set can be connected in sequence in the order of drawing to form a closed figure, and then the angle between two adjacent edges of the closed figure is determined, and whether the drawing trajectory is a special convex polygon is determined based on the size of the angle and the number of vertices in the vertex set. For example, assuming that the number of vertices in the vertex set is 3, and the three angles formed by the adjacent edges are all within the range of 55~65°, it can be determined that the triangle is an equilateral triangle, that is, a special convex polygon. Otherwise, it can be determined that the triangle is an ordinary triangle.

[0066] If the convex polygon is determined to be a non-special convex polygon, the first target convex polygon can be displayed on the interactive interface, wherein the vertices of the first target convex polygon are the vertices in the vertex set. For example, the vertices in the vertex set can be connected in sequence according to the order of drawing to form a closed figure, and the closed figure is used as the first target convex polygon and displayed to the user through the interactive interface.

[0067] For example, Figure 5C As shown in the figure, the left picture shows the trajectory drawn by the user, and the right picture shows the triangle output based on the trajectory drawn by the user. Figure 5D As shown, the left picture is a user-drawn trajectory, and the right picture is a quadrilateral output based on the user-drawn trajectory. In some embodiments, the special convex polygon can be a convex polygon whose angle or side length meets specific conditions, for example, it can be a regular polygon (regular triangle, square, regular pentagon, etc.), rectangle, isosceles triangle, right triangle, right trapezoid, etc.

[0068] In some embodiments, when determining whether a drawing trajectory is a special convex polygon based on the angles of adjacent connecting edges in connecting edges obtained by sequentially connecting vertices in a vertex set in a drawing order and the number of vertices in the vertex set, if the number of vertices in the vertex set is n, and the deviations of the angles of adjacent connecting edges from the target angle are all less than a preset deviation (for example, 5° or 10°), the drawing trajectory is determined to be a regular polygon, wherein the target angle is 180°×(n-2) / n; wherein n is 3 or n≥5; In some embodiments, if the number of vertices in the vertex set is 3, and the deviation of two included angles of adjacent connecting edges is less than a preset deviation, the drawing trajectory is determined to be an isosceles triangle.

[0069] In some embodiments, if the number of vertices in the vertex set is 3, and the deviation of one angle between the adjacent connecting edges from 90° is less than a preset deviation, the drawing trajectory is determined to be a right triangle.

[0070] In some embodiments, if the number of vertices in the vertex set is 4, and only two of the angles of adjacent connecting edges have a deviation from 90° that is less than a preset deviation, the drawing trajectory is determined to be a right-angled trapezoid.

[0071] In some embodiments, if the number of vertices in the vertex set is 4, and the deviation of the included angles of adjacent connecting edges from 90° is less than a preset deviation, and the lengths of adjacent connecting edges are not equal, then the drawing trajectory is determined to be a rectangle.

[0072] In some embodiments, if the number of vertices in the vertex set is 4, and the deviation of the included angles of adjacent connecting edges from 90° is less than a preset deviation, and the lengths of adjacent connecting edges are equal, then the drawing trajectory is determined to be a square.

[0073] In some embodiments, if the drawing trajectory is determined to be a special convex polygon, considering that the side length and angle of the special convex polygon usually have certain particularities, such as equal side lengths and fixed angles, directly connecting the vertices in the vertex set in the order of drawing to form a closed figure may not meet the above conditions due to user hand shaking and other reasons. For example, if the drawing trajectory is determined to be an equilateral triangle, the internal angles of the closed figure may be 65°, 60°, and 55°. In order to make the final output shape meet the characteristics of the special convex polygon, the target points obtained by optimizing the vertices in the vertex set can be used as vertices to draw a second target convex polygon, and the second target convex polygon is displayed in the interactive interface. Among them, the purpose of the optimization process is to make the side length and / or angle of the second target convex polygon finally output meet specific conditions, wherein the specific conditions include the angle being a specified angle, the side length being equal or parallel. For example, assuming that the drawing trajectory is determined to be an equilateral triangle, the goal of the optimization process is to make each internal angle of the second target convex polygon finally output be 60°.

[0074] In some embodiments, considering that the position of the final output standard figure should be as close as possible to the position of the trajectory drawn by the user, in the process of optimizing each vertex in the vertex set, the position of the target point obtained by the optimization process should be as close as possible to the position of the vertex in the vertex set, that is, the deviation between the two should be as small as possible.

[0075] In some embodiments, the target point obtained by the optimization process may be located on the circumscribed circle of each vertex in the vertex set, and the position deviation between the target point and each vertex in the vertex set is less than a preset deviation. That is, during the optimization process, the circumscribed circle of each vertex in the vertex set may be determined first, and then, based on the characteristics of the side length or angle of the special convex polygon, each target point may be determined in turn in the circumscribed circle as the vertex of the second target convex polygon.

[0076] For example, suppose that after the noise vertex removal step, only point 1, point 2, and point 3 remain in the vertex set. At this time, we can calculate the angles of the lines formed by point 1 and point 2, point 2 and point 3, and point 3 and point 1. If the angles are all greater than 55° and less than 65°, we can determine that the drawing trajectory is an equilateral triangle. At this time, we need to optimize the vertices in the vertex set. The specific steps are as follows: like Figure 6As shown, the circumscribed circle of point 1, point 2, and point 3 can be determined. For example, the center point of the above three points can be calculated as the center of the circumscribed circle, and the average distance between the above three points and the center point can be calculated as the radius of the circumscribed circle. Then you can randomly select a point from the vertex set as a reference point. For example, take point 1, and calculate the straight line formed by point 1 and the center of the circle, which intersects at a point of the circumscribed circle to obtain point 4. At this time, point 4 is an optimized target point. Because the angle between each vertex of the equilateral triangle and the straight line formed by the center of the circle is 120°, point 5 and point 6 are obtained by rotating point 4 by 120° and 240°, so that the optimized target points are finally obtained as points 4, 5, and 6, and then the equilateral triangle with points 4, 5, and 6 as vertices is output and displayed in the interactive interface.

[0077] In addition, suppose that after the noise vertex removal step, only point 1, point 2, and point 3 remain in the vertex set. If the angles of the adjacent edges formed by the three points are similar but not greater than 55° and less than 60° (excluding equilateral triangles) and the difference is within ±10°, the drawn trajectory is considered to be an isosceles triangle. At this time, the vertices in the vertex set need to be optimized. The specific steps are as follows: like Figure 7 As shown, the circumscribed circle of point 1, point 2, and point 3 can be determined. For example, the center point of the above three points can be calculated as the center of the circumscribed circle, and the average distance between the above three points and the center point can be calculated as the radius of the circumscribed circle. Then the straight line formed by point 1 and the center of the circle can be calculated, intersecting at a point of the circumscribed circle to obtain point 4, and the straight line formed by point 2 and the center of the circle can be calculated, intersecting at a point of the circumscribed circle to obtain point 5. At this time, point 4 and point 5 are the two optimized target points. Determine the two points obtained by the perpendicular bisector of the line segment formed by point 1 and point 2 intersecting at the circumscribed circle, namely point 6 and point 7. Determine which of the two points is closer to point 3, and retain which point as the third optimized target point, assuming it is point 6. At this time, the optimized target points are point 4, point 5, and point 6, and then output an isosceles triangle with point 4, point 5, and point 6 as vertices, and display it in the interactive interface.

[0078] In addition, suppose that after the noise vertex removal step, only point 1, point 2, and point 3 remain in the vertex set. At this time, if the angles of the lines formed by point 1 and point 2, point 2 and point 3, and point 3 and point 1 are greater than 80° and less than 100°, it is considered to be a right triangle. At this time, the vertices in the vertex set need to be optimized. The specific steps are as follows: like Figure 8As shown, the circumscribed circle of point 1, point 2, and point 3 can be determined. For example, the center point of the above three points can be calculated as the center of the circumscribed circle, and the average distance between the above three points and the center point can be calculated as the radius of the circumscribed circle. It is known that point 1 is a right-angle point, so the straight line formed by point 1 and the center of the circle is calculated, and it intersects at a point of the circumscribed circle to obtain point 4. The straight line formed by point 2 and the center of the circle is calculated, and it intersects at a point of the circumscribed circle to obtain point 5. At this time, point 4 and point 5 are the two optimized target points. Then the straight line formed by point 2 and the center of the circle is calculated to intersect at the circumscribed circle to obtain point 6. The straight line formed by point 1 and the center of the circle is calculated to intersect at the circumscribed circle to obtain point 7. Determine which of the two points is closer to point 3, and retain which point as the third optimized target point, assuming it is point 6. At this time, the optimized target points are point 4, point 5, and point 6. Then a right triangle with points 4, 5, and 6 as vertices is output and displayed in the interactive interface.

[0079] For other special convex polygons, similar methods can be used to optimize the vertices in the vertex set, which will not be listed one by one here.

[0080] In order to further introduce the hand-drawn pattern recognition method provided by the embodiment of the present application, the following is explained in conjunction with a specific embodiment. Among them, the hand-drawn image recognition method may include the following steps: 1. Get the drawing trajectory.

[0081] First, the drawing trajectory can be obtained from the user's hand-drawn operation. The drawing operation can be detected, such as through touch or mouse events, to detect the user's drawing operation on the canvas. For each movement (such as mouse movement or touch movement), the current coordinate point is recorded, and these points are connected in sequence to form a drawing trajectory.

[0082] 2. Sample points on the plotted trajectory.

[0083] In order to prevent high performance consumption caused by too much processing of point data, you can sample the points on the drawing trajectory, sampling a point every certain pixel. The specific steps are as follows: Calculate the length of the drawn track: Calculate the total length of the drawn track (that is, the sum of the distances between all adjacent points).

[0084] Set sampling interval: Set a sampling interval (for example, sample a point every 20 pixels).

[0085] Traverse the drawing trajectory: Traverse the points on the drawing trajectory, sample at set intervals, and record these sampling points.

[0086] For example, suppose there are 5 points on the drawing trajectory: A(0,0), B(10,0), C(10,10), D(20,10), E(20,20). Calculate the length of the drawing trajectory: |AB| + |BC| + |CD| + |DE| = 10 + 10 + 10 + 10 = 40 pixels. Set the sampling interval to 20 pixels, then the sampling points are A, C, E.

[0087] 3. Normalize all sampling points to obtain the set P.

[0088] The purpose of normalization is to convert point coordinates into relative coordinates for easy subsequent processing and comparison. Normalization usually includes two steps: scaling and offset. The specific steps are as follows: Calculate the bounding box: Find the minimum and maximum X, Y coordinates of all sample points to form a rectangular box that surrounds all points (i.e., the bounding box).

[0089] Scaling: Scales the coordinates of all points to a fixed range, usually [0, 1] or [-1, 1].

[0090] Offset: Translates all points so that their center is at the origin (0, 0).

[0091] For example, suppose the sampling points are A(0, 0), C(10, 10), E(20, 20). The bounding box is: minX = 0, minY = 0, maxX = 20, maxY = 20, the total scaling factor: scale = 20, calculate the X-axis scaling factor: scaleX = maxX – minX, calculate the Y-axis scaling factor: scaleY = maxY – minY, and choose the larger of the two scaling factors as the total scaling factor (for example, here you can choose the larger value of scaleX or scaleY).

[0092] The coordinates of the normalized points are as follows: A(0,0) : (0,0) C(10,10): (0.5,0.5) E(20,20): (1,1) Through the above steps, the normalized point set P can be obtained.

[0093] 4. Calculate the center point c of all points in the set P.

[0094] The center point c (center of gravity) is the average value of the coordinates of all points in P. The formula for calculating the center point is as follows: Calculate the X coordinate of the center point: Center point X coordinate = (sum of all points' X coordinates) / number of points Calculate the Y coordinate of the center point: Center point Y coordinate = (sum of all points’ Y coordinates) / number of points 5. Determine whether the distances between all points in set P and the center point c are greater than a certain threshold.

[0095] If the distance from all points to the center point is greater than a certain threshold, it can be preliminarily determined that these points may form a circle. The specific steps are as follows: Calculate the distance from each point to the center point: distance = sqrt((point X coordinate - center point X coordinate)^2+(point Y coordinate - center point Y coordinate)^2) Set the threshold: Because all points have been normalized, the threshold can be set to a value between 0 and 1 to make a unified judgment on all graphics, such as 0.8 (this threshold can be adjusted according to actual conditions).

[0096] If the distance from all points to the center point is greater than the threshold, it is judged as a circle. After being judged as a circle, the maximum or minimum average distance is returned as the radius and the center point is returned as the center of the circle, and the process is exited.

[0097] 6. If it is not a circle, determine the position where the angle changes greatly, and calculate all the vertices on the path to obtain the point set O, as follows: Calculate the angle of the line connecting adjacent points: traverse the normalized point set P, and for each three adjacent points, set them as point A, point B, and point C. When traversing to point B, calculate the angle between vector AB and vector BC using the vector method. If the angle value is greater than the set threshold (for example, 10 degrees), it is considered that the angle has changed significantly at this position, and it is added to the point set O.

[0098] 7. Traverse the point set O in order and classify the points that are close to each other within a certain threshold into a point heap. The specific steps are as follows: Set distance threshold: First, determine a suitable distance threshold, which can be set according to the specific application scenario and the characteristics of the data in the previous steps. For example, based on factors such as the normalized range of the previous points, set the distance threshold to 0.005 (again, this value can be adjusted as needed).

[0099] Traverse the point set O in path order: traverse each point in the point set O in order, and for the currently traversed point, calculate the distance between it and other points that have been traversed and not yet classified. The distance calculation formula can use the common Euclidean distance formula, that is, for point A (x1, y1) and point B (x2, y2), the distance between the two points d = √((x2 -x1)²+ (y2 - y1)²). When the calculated distance between the two points is less than the set distance threshold, the two points are classified into the same pile. Add the current point to the existing pile that contains points close to it; if such a pile does not exist, create a new pile and put the current point into it.

[0100] 8. Take the average of the points in each category to get a new point set U.

[0101] Traverse the classified point piles: Traverse each point pile obtained by classification, assuming that these point piles are stored in a list called point_piles, where each element is a sublist containing several points, representing a pile of points.

[0102] Calculate the average value of each pile of points and generate a new point set U: combine the average coordinates calculated for each pile of points into a new point, namely (average_x, average_y), and add these new points in turn to a new set, which is the point set U.

[0103] 9. Determine whether it is a broken line or a straight line by checking whether the distance between the starting point and the end point of the trajectory is greater than a certain threshold and whether there is a point in the point set U.

[0104] Determine the threshold: First, you need to set a suitable distance threshold. The setting of this threshold should be determined based on the characteristics of the data in the previous step and the specific requirements of the entire hand-drawn shape processing process. For example, considering factors such as the normalization range of the previous points, the distance threshold can be set to 0.05 (this value can be flexibly adjusted according to actual conditions).

[0105] Get the starting point and end point: find the starting point and end point of the original drawing trajectory (the initial starting point and final end point recorded when obtaining the drawing trajectory in the first step).

[0106] Calculate the distance between the starting point and the end point: Use an appropriate distance calculation formula, such as the Euclidean distance formula, to calculate the distance between the starting point and the end point. At the same time, determine the new point set U obtained in the previous step to confirm whether there is a point in it.

[0107] If the calculated distance between the start point and the end point is greater than the set distance threshold, and there are points in the point set U, then it can be preliminarily determined that the hand-drawn shape may be a polyline; if the distance between the start point and the end point is greater than the set distance threshold, but the point set U is an empty set, then it may be a straight line. This is because in the case of forming a polyline, after the processing in the previous steps, some average points reflecting the polyline vertex characteristics will be left in the point set U, while a straight line may not leave points in the point set U after similar processing due to its shape characteristics.

[0108] If it is determined to be a broken line, the starting point, the end point, and the broken line obtained by connecting the points in the point set U in sequence are output; if it is a straight line, the straight line formed by the starting point and the end point is output and the process is exited.

[0109] 10. If it is not a straight line or a broken line, traverse the point set U and filter out noise points (points with larger corners due to hand shaking, average calculation, and user writing personality). There are two specific solutions.

[0110] Scenario 1: Create an empty list to store the new point set K obtained in the end. Starting from the second point, traverse all points in the point set U, calculate the straight line A formed by the current point and the previous point, and the straight line B formed by the previous point and the next point. If the angle between AB is less than a certain angle (for example, 10 degrees), add the point to the point set K, and then traverse from the next point, and repeat the above steps. If the angle is greater than a certain angle, add the next point to the point set K, and traverse from the next two points, repeat the above steps until the last point is traversed, and the new point set K can be obtained.

[0111] Then, for point set K, the above process can be repeated to traverse the points in point set K to obtain a new point set K. Repeat the above process until the number of points in the final point set K remains unchanged, at which point the obtained point set K can be used as the final point set K.

[0112] Scenario 2: Start traversing from the second point, traverse all points in the point set U, calculate the straight line A formed by the current point and the previous point, and the straight line B formed by the previous point and the next point. If the angle between AB is less than a certain angle (for example, 10 degrees), delete the current point, continue traversing from the next point, and repeat the above operation until the last point is traversed and stop. At this time, the point set K is obtained after deleting all noise points.

[0113] 11. Determine concave and convex polygons.

[0114] Connect the points in the point set K in order to form a polygon, traverse each edge of the polygon, and for each traversed edge, determine whether all other vertices are on the same side of the straight line where the edge is located. If not, it means that the polygon is a concave polygon, and no other classification is performed. It is directly classified as a concave polygon. Concave polygons do not perform vertex optimization (vertex optimization, such as optimizing triangles into regular triangles and isosceles triangles). Directly output the points in the point set K connected in order to form a polygon.

[0115] 12. If the point set K has three vertices, it is a triangle. At this time, the next step of classification is carried out as follows: ①. If the angles of all sides and adjacent sides are within the range of 60±10 degrees, it is judged as an equilateral triangle, and then all vertices are optimized using the circumscribed circle method.

[0116] ② If there are two similar angles with a difference of ±10 degrees, it is judged as an isosceles triangle, and then all vertices are optimized using the circumscribed circle method.

[0117] ③. If there is an angle within the range of 90±10 degrees, it is judged as a right triangle, and then all vertices are optimized using the circumscribed circle method.

[0118] 13. Similarly, if there are 4 vertices and 5 fixed points in the point set K, the operation is similar, that is, first determine whether it is a special polygon (for example, a regular polygon, a rectangle, a right trapezoid, etc.). If it is a special polygon, use the circumscribed circle method to optimize the vertices and output the optimized graphics. If not, output the points in the point set K connected in sequence to form a polygon.

[0119] The specific details of optimizing the points in the point set K by using the circumscribed circle can be referred to the description in the above embodiment, which will not be repeated here.

[0120] Among them, the solutions of the above-mentioned embodiments can be freely combined to obtain new solutions when there is no conflict. Due to space constraints, they will not be listed one by one here.

[0121] In addition, an embodiment of the present disclosure further provides a computer program product, which includes a computer program. When the computer program is executed, the method mentioned in any of the above embodiments is implemented.

[0122] Furthermore, the present disclosure also provides an electronic device, such as Fig. 9 As shown, the electronic device includes a processor 91, a memory 92, and computer instructions stored in the memory 92. When the processor 91 executes the computer instructions, the method mentioned in any of the above embodiments is implemented.

[0123] Accordingly, an embodiment of the present specification further provides a computer storage medium, in which a program is stored. When the program is executed by a processor, the method in any of the above embodiments is implemented.

[0124] The embodiments of this specification may take the form of a computer program product implemented on one or more storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing program code. Computer-usable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include but are not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0125] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0126] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0127] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. The terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprises a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0128] The method and device provided in the embodiments of the present invention are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A hand-drawn graphic recognition method, characterized in that: The method comprises: Sampling the trajectory points on the trajectory drawn by the user to obtain a sampling point sequence, wherein the sampling points in the sampling point sequence are arranged in the order of drawing; Filtering out a target sampling point from the sampling point sequence, wherein an angle between a straight line formed by two sampling points before and after the target sampling point and the target sampling point is greater than a preset first angle threshold; Performing clustering processing on the target sampling points, and determining a vertex in the drawing trajectory based on the target sampling points in each category obtained by clustering, so as to obtain a vertex set of the drawing trajectory, wherein the distance between the target sampling points in each category is less than a preset first distance threshold; A shape of the drawing trajectory is determined based on the set of vertices.

2. The method according to claim 1, characterized in that The step of determining a vertex in the drawing trajectory based on the target sampling point in each category comprises: Determine the average coordinates of the target sampling points in each category, and use the average coordinates as the coordinates of a vertex in the drawing trajectory; or The median coordinates of the target sampling points in each category are determined, and the median coordinates are used as the coordinates of a vertex in the drawing trajectory.

3. The method according to claim 1, characterized in that: The vertices in the vertex set are arranged in a drawing order, and the determining the shape of the drawing trajectory based on the vertex set includes: Removing noise vertices from the vertex set to obtain a denoised vertex set; wherein the noise vertex is within a preset distance range of a target trajectory, and the target trajectory is a trajectory formed by at least two vertices adjacent to the noise vertex in the vertex set; The shape of the drawing trajectory is determined based on the denoised vertex set.

4. The method according to claim 3, characterized in that The denoised vertex set is determined based on the following method: Starting from the second vertex in the vertex set, traversing the vertices in the vertex set, for the currently traversed vertex, if the angle between the straight line formed by the two vertices before and after the vertex and the straight line formed by the vertex and the vertex before and after the vertex is less than a preset second angle threshold, then deleting the vertex from the vertex set, after traversing all the vertices in the vertex set, taking the remaining vertices in the vertex set as the vertices in the denoising vertex set; wherein, after performing the vertex deletion operation, the previous vertex and the next vertex of the vertex in the vertex set are determined based on the vertex set after the vertex is deleted; or The vertex set is used as the current vertex set in the first round of iteration, and the following iteration process is performed until the number of vertices in the current vertex set remains unchanged: Starting from the second vertex in the current vertex set, traverse the vertices in the current vertex set. For the currently traversed vertex, if the angle between the straight line formed by the two vertices before and after the vertex and the straight line formed by the vertex and the previous vertex of the vertex is less than a preset second angle threshold, then move the vertex into the target point set; otherwise, move the next vertex of the vertex into the target point set. After traversing the vertices in the current vertex set, use the obtained target point set as the current vertex set in the next round of iteration; wherein, after executing the operation of moving the vertex into the target point set, the previous vertex and the next vertex of the vertex in the vertex set are determined based on the current vertex set after the vertex is removed; The target point set obtained at the end of iteration is used as the denoising vertex set; or The vertices in the vertex set are traversed starting from the second vertex in the vertex set. For the currently traversed vertex, if the distance of the vertex deviating from the straight line formed by the two vertices before and after the vertex is less than a preset target distance, the vertex is deleted from the vertex set. After traversing all the vertices in the vertex set, the remaining vertices in the vertex set are used as vertices in the denoising vertex set; wherein, after performing the vertex deletion operation, the previous vertex and the next vertex of the vertex in the vertex set are determined based on the vertex set after the vertex is deleted.

5. The method according to claim 1, characterized in that The step of selecting a target sampling point from the sampling point sequence comprises: In the case where it is determined based on the sampling point sequence that the drawn trajectory is non-circular, selecting target sampling points from the sampling point sequence; In the case where the drawn trajectory is determined to be a circle based on the sampling point sequence, a target circle is displayed in the interactive interface; wherein the center of the target circle is the center point, and the radius of the target circle is the average value of the distances between each sampling point in the sampling point sequence and the center point; If the coordinates of each sampling point in the sampling point sequence are normalized coordinates, and there is at least one sampling point in the sampling point sequence whose distance from the center point is less than a preset second distance threshold, then it is determined that the shape of the drawn trajectory is non-circular; or If the difference between the distances between each sampling point in the sampling point sequence and the center point is greater than a preset difference, determining that the shape of the drawing trajectory is non-circular; The center point is the center point of each sampling point in the sampling point sequence.

6. The method according to claim 1, characterized in that The determining the shape of the drawing trajectory based on the vertex set includes: If the distance between the starting point and the end point in the drawing trajectory is greater than or equal to a preset third distance threshold, and there is at least one vertex in the vertex set, determining that the shape of the drawing trajectory is a polyline; and / or If the distance between the starting point and the end point in the drawing trajectory is greater than or equal to a preset third distance threshold, and there is no vertex in the vertex set, determining that the shape of the drawing trajectory is a straight line; and / or If the distance between the start point and the end point in the drawing trajectory is less than a preset third distance threshold, and for each connecting edge formed by two adjacent vertices in the vertex set, all vertices in the vertex set are located on the same side of the connecting edge, then the drawing trajectory is determined to be a convex polygon; and / or If the distance between the starting point and the end point in the drawing trajectory is less than a preset third distance threshold, and there is at least one connecting edge among the connecting edges formed by two adjacent vertices in the vertex set so that the vertices in the vertex set are located on both sides of the connecting edge, then the drawing trajectory is determined to be a concave polygon.

7. The method according to claim 6, characterized in that The method further comprises: When it is determined that the shape of the drawing trajectory is a polyline, a target polyline is displayed on the interactive interface, wherein the target polyline is obtained by sequentially connecting the starting point and the end point in the drawing trajectory and each vertex in the vertex set in the order of drawing; and / or In the case where it is determined that the shape of the drawing trajectory is a straight line, a target straight line is displayed on the interactive interface, wherein the target straight line is a straight line formed by a starting point and an end point in the drawing trajectory; and / or In the case where it is determined that the shape of the drawing trajectory is a concave polygon, a target concave polygon is displayed on an interactive interface, and the vertices of the target concave polygon are the vertices in the vertex set; and / or In the case where it is determined that the shape of the drawing trajectory is a convex polygon, determining whether the drawing trajectory is a special convex polygon based on the angles of adjacent connecting edges in connecting edges obtained by sequentially connecting the vertices in the vertex set in the order of drawing, and the number of vertices in the vertex set; If the drawing trajectory is a non-special convex polygon, a first target convex polygon is displayed on the interactive interface, and the vertices of the first target convex polygon are the vertices in the vertex set; If the drawing trajectory is a special convex polygon, a second target convex polygon is displayed on the interactive interface, wherein the vertices of the second target convex polygon are target points obtained by optimizing each vertex in the vertex set, and the optimization process makes the side length and / or vertex angle of the second target convex polygon meet specific conditions, and the specific conditions include one or more of the following: the vertex angle is a specified angle, and the side lengths are equal or parallel.

8. The method according to claim 7, characterized in that The target point is located on the circumscribed circle of each vertex in the vertex set, and the position deviation between the target point and each vertex in the vertex set is less than a preset deviation; and / or The determining whether the drawing trajectory is a special convex polygon based on the angles of adjacent connecting edges in connecting edges obtained by sequentially connecting the vertices in the vertex set in the order of drawing, and the number of vertices in the vertex set, includes: If the number of vertices in the vertex set is n, and the deviations of the angles of adjacent connecting edges from the target angle are all less than a preset deviation, then the drawing trajectory is determined to be a regular polygon, wherein the target angle is 180°×(n-2) / n; wherein n is an integer, n=3 or, n≥5; If the number of vertices in the vertex set is 3, and the deviations of two included angles of adjacent connecting edges are less than a preset deviation, then the drawing trajectory is determined to be an isosceles triangle; If the number of vertices in the vertex set is 3, and the deviation of one angle between the adjacent connecting edges from 90° is less than a preset deviation, then the drawing trajectory is determined to be a right triangle; If the number of vertices in the vertex set is 4, and only two of the angles of adjacent connecting edges have a deviation from 90° that is less than a preset deviation, then it is determined that the drawing trajectory is a right-angled trapezoid; If the number of vertices in the vertex set is 4, and the deviation of the angles of adjacent connecting edges from 90° is less than a preset deviation, and the lengths of adjacent connecting edges are not equal, then the drawing trajectory is determined to be a rectangle; If the number of vertices in the vertex set is 4, and the deviation of the included angles of adjacent connecting edges from 90° is less than a preset deviation, and the lengths of adjacent connecting edges are equal, then it is determined that the drawing trajectory is a square.

9. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed, the method according to any one of claims 1 to 8 is implemented.

10. An electronic device, characterized in that: The electronic device comprises a processor, a memory, and computer instructions stored in the memory, and the processor implements the method according to any one of claims 1 to 8 when executing the computer instructions.

Citation Information

Patent Citations

  • Method and device for identifying and editing freehand sketch

    CN104424473A

  • Method and apparatus for converting geometric graph into Braille dot-matrix graph

    CN105550987A

  • Method and device for generating equilateral polygon, and electronic equipment

    CN111696169A

  • Information identification method and device

    CN112083870A

  • Dynamic obstacle detection method based on fitting graph

    CN115308770A