A point-based shape contour recognition method
By generating convex polygons through density-based clustering and convex hull algorithms, and combining IoU comparison, the problem of low efficiency and poor adaptability of shape recognition based on point data in existing technologies is solved, realizing an automated and highly versatile shape contour recognition method.
Patent Information
- Application Number
- CN202310966608.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-03
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2043-08-03
AI Technical Summary
Existing technologies lack a universal and efficient method to automatically identify and match various shapes of two-dimensional planar outer contours based on point data, resulting in shape recognition in engineering design and manufacturing being time-consuming, labor-intensive, and prone to human error.
A density-based clustering algorithm is used to divide the point data into clusters, and a convex hull algorithm is used to generate convex polygons. The best matching shape contour is determined by comparing the IoU with a pre-built standard graphics library.
It achieves automated and versatile shape contour recognition, reduces manual intervention, and improves recognition efficiency and accuracy. It is applicable to the recognition and analysis of various shapes.
Smart Images

Figure CN117078979B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image recognition technology, specifically a point-based shape contour recognition method. Background Technology
[0002] In drawing recognition technology, in addition to traditional line-segment-based drawing data, drawing data composed of base points has also emerged. Drawing software transforms drawings into regularly arranged points. However, in engineering design, architecture, and manufacturing, automatically recognizing, classifying, and analyzing shapes in drawings remains a challenging task. Traditionally, manual visual inspection and analysis of drawings is not only time-consuming and labor-intensive but also prone to human error. Therefore, developing an automated shape recognition and matching method is crucial.
[0003] Currently, there are some automatic shape recognition methods for images, most of which are based on feature extraction and matching of specified shapes. For example, Chinese patent CN202111431962.9 discloses a method for recognizing walls based on CAD outer contours. This method mainly focuses on recognizing wall contours, converting lines in the drawing into polygons, determining the distance between parallel lines in the polygons to obtain candidate walls, and selecting the final wall from the candidate walls. This method applies line segment contours but lacks processing of point data. Chinese patent CN202310033713.7 discloses a contour recognition method for industrial parts. It is applied to the obtained images of industrial parts, inputting the initial contour of irregular polygons into the HRnet deep learning network to obtain parameters of multiple key points and reference points. The key points are used as vertices, and multiple vertices are connected end to end to obtain the contour. The limitation of this method is that for each new shape recognized, a large number of corresponding images need to be collected for retraining, resulting in a significant time cost. Chinese patent CN201610644289.X combines geometric shapes, geometric angles, and vertex relationships to form two sets of feature vectors for tangram pattern matching. This requires separate feature extraction for each geometric shape, increasing the complexity of the algorithm and limiting its application. Currently, there is no universal and adaptable method based on point data to identify multiple geometric shapes.
[0004] Therefore, a more general and efficient method is needed to automatically identify and match various shapes of two-dimensional planar outer contours. This invention aims to provide a point-based shape contour recognition method to improve the versatility and recognition efficiency of shape contour recognition. Summary of the Invention
[0005] To address the shortcomings of existing technologies, the technical problem this invention aims to solve is to provide a point-based shape contour recognition method. This method utilizes algorithms such as clustering and convex hull to determine the minimum standard graphic bounding box of discrete points, thereby achieving automatic recognition of shapes in drawings.
[0006] The technical solution adopted by the present invention to solve the aforementioned technical problem is as follows:
[0007] A point-based shape contour recognition method, the recognition method comprising the following:
[0008] Construct a standard graphics library, which includes regular graphics or custom graphics. All graphics are in images of equal size, and the center of gravity of the graphics and the images coincide. The image size in the standard graphics library is denoted as m*n.
[0009] Obtain point data for each shape in the drawing to be identified;
[0010] A density-based clustering algorithm is used to divide a group of points into different clusters in space. For each cluster, the convex hull algorithm is applied to obtain a convex polygon that encloses all the points in the cluster.
[0011] Compress the convex polygon to an m*n size to form a standard convex polygon, and record the compression ratio;
[0012] The IoU is compared between the standard convex polygon and each graphic in the standard graphic library. The graphic in the standard graphic library with the highest score is taken as the outline of the predicted convex polygon. Then, based on the predicted shape, the original size is obtained by inverse mapping according to the compression ratio, so as to realize the recognition of the shape outline in the drawing.
[0013] Furthermore, the IoU calculation process is as follows: the highest-scoring standard graphics library and the obtained standard convex polygon are filled with the same pixel values, and the pixel values filled inside are different from the existing pixel values outside. Then, the centroids of the two filled graphics are aligned. After alignment, each pixel element is compared. If the coordinates of the two are the same, it is recorded as 1, which means that the two graphics coincide at that pixel point. Otherwise, it is recorded as 0, which means that the two images do not coincide at that pixel point. The total number of 0s and 1s is the union, and the number of 1s is the intersection. The ratio of the intersection and the union is the IoU value.
[0014] Preferably, the IoU calculation process is as follows: The highest-scoring image from the standard graphics library and the obtained standard convex polygon are filled with grayscale, with all pixels set to 255; This yields the pixel set A = {x} of a single image from the standard graphics library. A |x A =255} and the pixel set B = {x B |x B=255}; Then, the centroids of the two filled shapes are aligned together. After they are aligned, each pixel element is compared. If the same coordinate is 255, it is recorded as 1, which means that the two shapes are aligned at that pixel. Otherwise, it is recorded as 0, which means that the two shapes are not aligned at that pixel. The total number of 0s and 1s is the union, and the number of 1s is the intersection. The ratio of the intersection to the union is the IoU value.
[0015] The graphics in the standard graphics library are graphics that are input by the user and pre-marked based on actual industrial conditions; the regular graphics are rectangles, triangles, circles, pentagons, or hexagons.
[0016] If a graphic in the standard graphics library is a triangle, then, provided that the centroids coincide, the vertices of the triangle are in contact with the edge of the image, and one side of the triangle coincides with the edge of the image.
[0017] If a graphic in the standard graphics library is a rectangle, then at least one pair of sides of the rectangle must coincide with the edge of the image containing it, provided that the centroids coincide.
[0018] If a graphic in the standard graphics library is circular, then, provided that the centers of gravity coincide, the outline of the circle must have at least two points that touch the edge of the image.
[0019] If a graphic in the standard graphics library is an irregular shape, then, under the premise that the centers of gravity coincide, find the two relative points of the largest outline of the irregular shape. These two relative points are in contact with the edge of the image.
[0020] The process of the convex hull algorithm is as follows:
[0021] (2.1) Selecting a reference point: Select a reference point from the cluster, and denote the reference point as p0;
[0022] (2.2) Polar Angle Sort: Calculate the angle between the line connecting each point in the cluster to the reference point and the positive x-axis, and sort according to this angle; if multiple points have the same polar angle as the reference point, select the point closer to the reference point and sort it first. The sorted points are denoted as p1, p2, p3, ... pn; the first point p1 and the last point pn must be points on the convex hull.
[0023] (2.3) Constructing the convex hull: Push the reference point p0 and the first point p1 in the sorted points onto the stack. Then, starting from p2, set the current point in order according to the sorted order for calculation. Initially, the reference point p0 is the first point under the stack, the stack vertex is p1, and the current point is p2. Calculate whether the vector formed by the first point under the stack as the starting point and the stack vertex as the ending point and the vector formed by the first point under the stack as the starting point and the current point as the ending point rotate counterclockwise. If yes, push the current point onto the stack and update the stack vertex, the first point under the stack, and the current point; if not, discard p2 and update the current point.
[0024] Continue selecting the top two elements of the stack and the next current point. Again, calculate whether the vector formed by the first point below the stack as the starting point and the stack vertex as the ending point, and the vector formed by the first point below the stack as the starting point and the current point as the ending point, rotate counter-clockwise. If they rotate counter-clockwise, push the current point onto the stack. If not, check if the number of elements in the stack is greater than 2. If the number is greater than 2, pop the stack vertex, update the stack vertex, the first point below the stack, and the current point. If the number is not greater than 2, discard the current point and update the current point. Repeat this process until the current point is determined to be the last sorted point pn.
[0025] Finally, the elements in the stack are the points on the outer perimeter of the convex hull of the cluster, and the lines connecting all the points on the outer perimeter of the convex hull form a convex polygon.
[0026] The process of determining whether it is a counter-clockwise rotation is as follows: Define the first point below the current stack top as a, the stack top as b, and the current point as c. The coordinates of these three points are denoted as (a...c ... x a y (b) x b y ), (c x c y ), calculate the area of the region enclosed by the three, if the area area > 0, then it is rotated counterclockwise in the order of a-b-c;
[0027] The area = (b x -a x )*(c y -a y )-(b y -a y )*(c x -a x ).
[0028] The reference point is selected based on the point with the smallest y-coordinate. If multiple points have the same y-coordinate, the point with the smallest x-coordinate is selected. The x-coordinate and y-coordinate are arbitrary spatial coordinates established in the drawing.
[0029] The drawing to be identified is an electronic drawing that can export point coordinate information, including CAD drawings, etc.
[0030] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0031] Automation: By adopting automated shape recognition and matching methods, the need for manual intervention is reduced, and work efficiency is improved.
[0032] Versatility: This method is applicable to various shapes, including squares, rectangles, triangles, and circles, and has good robustness and adaptability.
[0033] High precision: By calculating the intersection-union ratio between the standard convex polygon and the standard graphic, the best-matching predicted graphic can be accurately determined.
[0034] In summary, the point-based shape contour recognition method of this invention is a novel method based on convex hull algorithm and shape matching technology. It can be used for the automatic recognition, classification and analysis of shapes in electronic drawings that can derive point coordinate information in engineering design, construction and manufacturing fields. This will improve the automation level of engineering design and manufacturing processes, reduce human error, and improve work efficiency and accuracy.
[0035] This invention uses the convex hull algorithm to find the outer contour of a shape in a drawing composed of points, forming a convex polygon. Next, it matches this polygon one-to-one with shapes in a pre-recorded standard graphic library, calculating the intersection-over-union (IoU) ratio to determine the best-matching predicted shape. This invention creatively applies the convex hull algorithm to the recognition of graphic contours based on point data. It can calculate the minimum convex enclosing shape for a given set of points, and can be applied to the recognition and analysis of various shapes, exhibiting high efficiency, stability, and wide applicability. Attached Figure Description
[0036] Figure 1 The flowchart of the point-based shape contour recognition method of the present invention.
[0037] Figure 2 : A schematic diagram of the OPTICS clustering results in an embodiment of the present invention.
[0038] Figure 3 : A schematic diagram of the irregular contour obtained by the convex hull algorithm in this invention.
[0039] Figure 4 : Results of the cluster 1 convex hull algorithm similar to a circle.
[0040] Figure 5 : Results of the cluster 2 convex hull algorithm similar to a triangle.
[0041] Figure 6 : Results of the cluster 3-convex hull algorithm similar to a rectangle.
[0042] Figure 7 : Schematic diagram of vector cross product.
[0043] Figure 8 Original image.
[0044] Figure 9 : Compressed image.
[0045] Figure 10 Diagram of IoU calculation process.
[0046] Figure 11 : Contour maps of various input graphics in the standard graphics library, where (a) is the contour map of a regular graphic and (b) is the contour map of a custom graphic.
[0047] Figure 12 Comparison of the overlap between standard graphics and convex polygons.
[0048] Figure 13 : A schematic diagram of the process of image compression and enlargement. Detailed Implementation
[0049] The present invention will be further explained below with reference to the embodiments and accompanying drawings, but this is not intended to limit the scope of protection of this application.
[0050] This invention employs two input methods: one is images used to construct a standard graphics library, primarily for comparison with the results compressed using the convex hull algorithm; the other is points derived from electronic drawings. Engineering drawings typically feature a dispersed arrangement of components, a characteristic inherited by the input points. Based on this, a density-based clustering algorithm is used to divide a group of points into different clusters in space. Each cluster is then processed using the convex hull algorithm to obtain a convex polygon enclosing all points within that cluster. To enhance the algorithm's versatility and reduce the input volume of the standard graphics library, image compression technology is used to compress the convex polygons to a specified m*n size, forming a standard convex polygon to address the problem of recognizing objects of the same shape but different sizes. The standard convex polygon is compared with each image in the standard graphics library using an IoU (Intersection over Union) comparison, and the highest score is used as the predicted shape result. Then, based on the predicted shape, the original size is obtained through inverse mapping using the compression ratio.
[0051] The point-based shape contour recognition method of the present invention is as follows: Figure 1 As shown, the specific process of the method is as follows: Engineering drawings and a standard graphics library are input. Based on the input file format, it is determined whether the input content is points or graphics. Formats such as txt represent input data in point format, while formats such as png and jpg represent input data in image format. If it is a graphic, the image is stored in the standard graphics library; if it is a point, the points are clustered using OPTICS (density-based clustering algorithm). The clustering algorithm distinguishes points with different density characteristics, grouping them into different clusters. Then, a convex hull algorithm is applied to each cluster to obtain a convex polygon.
[0052] The obtained convex polygons are compressed and normalized to obtain standard convex polygons. The standard convex polygons are then compared with each graphic in the standard graphics library to calculate the IOU. The one with the highest score is the outline of the standard convex polygon. The original size of the convex polygon is then obtained by inverse mapping based on the outline of the standard convex polygon and the compression ratio.
[0053] The process of the OPTICS clustering algorithm is as follows:
[0054] (1.1) For a sample set S, with m sample points:
[0055] The reachable distance of all points is initialized to infinity. `reach_dist = array([np.inf]*m)` means creating an array `reach_dist` containing `m` elements, where each element is positive infinity (`np.inf`). Here, `[np.inf]*m` creates a Python list of length `m`, and `array()` is a function in the NumPy library used to create arrays.
[0056] The statement `ordering = np.zeros(m, dtype = int)` initializes a list of samples sorted by reachability distance from smallest to largest to all zeros. This means creating an `ordering` array with m elements and initializing all elements of the array to 0, with the data type set to integer (int), and `ordering` being the sorted samples.
[0057] Initialize all flags indicating whether a sample has been processed to False. `processed = np.zeros(m, dtype = bool)` is an array of `processed` containing `m` elements, with all elements initialized to False and their data type set to boolean (bool).
[0058] (1.2) Assuming the distance threshold is ε, calculate the core distance of all points based on the parameter MinPts, and denote the core distance as core_dist. If the core distance is greater than the distance threshold ε, then there is no core distance, which is represented by infinity inf.
[0059] (1.3) Take the point with the smallest reachable distance from the unprocessed points, idx = np.argmin(reach_dist), put it in the first position of ordering, and mark whether to process it as True, processed[idx] = True. If the current idx sample has a core distance, calculate the reachable distance between the current point idx and the points in processed that are False as rdist. If the reachable distance in rdist is less than the corresponding reachable distance value in the reach_dist array, then update and replace it with the value in rdist; if the current point idx does not have a core distance, that is, it is not a core point, then do not process it.
[0060] (1.4) Repeat step 1.3, take the currently unprocessed samples, i.e., samples where processed = False, and return the sample point idx with the smallest reachable distance in reach_dist among these unprocessed samples. Add it to the second position of ordering and mark it as True. If processed[idx] = True is a core point, calculate its reachable distance from other unprocessed points; otherwise, do not process it. Continue until all samples are processed, at which point the OPTICS clustering algorithm ends, resulting in different clusters with significantly different densities. Using randomly sampled points of circles, triangles, and parallelograms as input, the results of the OPTICS clustering algorithm in this embodiment are as follows: Figure 2 As shown, Figure 2 There are three clusters obtained from clustering, namely cluster0, cluster1, and cluster2.
[0061] The process of the convex hull algorithm is as follows:
[0062] Because different parts in the drawing are distributed differently in space, clustering is performed to obtain different clusters with large differences in distance and density. All points in each cluster are used as input to the convex hull algorithm. The result of the convex hull algorithm is as follows: Figure 3 As shown, several convex polygons are finally obtained, and the results of the convex polygons are as follows. Figure 4 , 5 As shown in Figure 6. The specific process is as follows:
[0063] (2.1) Selecting a reference point: Select a reference point from the given set of points. In this embodiment, the point with the smallest y-coordinate is selected. If multiple points have the same y-coordinate, the point with the smallest x-coordinate is selected, and the reference point is denoted as p0.
[0064] (2.2) Polar Angle Sort: Sort all other points according to their polar angle relative to the reference point. That is, calculate the angle between the line connecting each point to the reference point and the positive x-axis, and sort according to this angle. If multiple points have the same polar angle as the reference point, select the point closer to the reference point and place it first. The sorted points are denoted as p1, p2, p3, ..., pn. Geometrically, the first point p1 and the last point pn in the result must be points on the convex hull.
[0065] (2.3) Constructing the convex hull: Push the reference point p0 and the first point p1 in the sorted points onto the stack. Then, starting from p2, set the current point in order according to the sorted order for calculation. Initially, the reference point p0 is the first point under the stack, the stack vertex is p1, and the current point is p2. Calculate whether the vector formed by the first point under the stack as the starting point and the stack vertex as the ending point and the vector formed by the first point under the stack as the starting point and the current point as the ending point rotate counterclockwise. If yes, push the current point onto the stack and update the stack vertex, the first point under the stack, and the current point; if not, discard p2 and update the current point.
[0066] Continue selecting the top two elements of the stack and the next current point. Again, calculate whether the vector formed by the first point below the stack as the starting point and the stack vertex as the ending point, and the vector formed by the first point below the stack as the starting point and the current point as the ending point, rotate counter-clockwise. If they rotate counter-clockwise, push the current point onto the stack. If not, check if the number of elements in the stack is greater than 2. If the number is greater than 2, pop the stack vertex, update the stack vertex, the first point below the stack, and the current point. If the number is not greater than 2, discard the current point and update the current point. Repeat this process until the current point is determined to be the last sorted point pn.
[0067] Finally, the elements in the stack are the points on the outer perimeter of the convex hull of the cluster, and the lines connecting all the points on the outer perimeter of the convex hull form a convex polygon.
[0068] The process of determining whether a rotation is counterclockwise, and then pushing or popping points from the stack based on whether it is counterclockwise, is as follows: Define the first point below the current stack top as 'a', the stack top as 'b', and the current point as 'c'. Their coordinates are denoted as (a...c ... x a y (b) x b y ), (c x c y ), calculate the area of the region enclosed by the three, if the area area > 0, then it is rotated counterclockwise in the order of a-b-c.
[0069] By calculating the magnitude of the cross product of vectors, we can obtain the conclusions of counterclockwise, clockwise, and a straight line, such as... Figure 7 As shown.
[0070] area=(b x -a x )*(c y -a y )-(b y -a y )*(c x -a x )
[0071] If area > 0, rotate the order of abc counterclockwise;
[0072] If area < 0, rotate the order of abc clockwise;
[0073] When area = 0, a, b, and c are on a straight line.
[0074] The cluster 1, which approximates a circle, is obtained by applying the convex hull algorithm, as follows: Figure 4 As shown; the cluster 2 of the approximate triangle is obtained by applying the convex hull algorithm, as follows. Figure 5 As shown; the convex hull algorithm is applied to the approximately rectangular cluster 3 to obtain the result, as shown in the figure. Figure 6 As shown.
[0075] The obtained convex polygons are compared with the graphics in the standard graphics library to determine the compression ratio. After determining the compression ratio, the convex polygons are compressed according to the compression ratio. Convex polygons of different sizes are uniformly normalized to the fixed m*n size of the design to obtain standard convex polygons. This can enhance the applicability of part graphics of the same specification but different sizes and reduce the storage of unnecessary standard graphics libraries.
[0076] In this embodiment, it is assumed that the original image size of the convex polygon is 8*8. Figure 8 As shown in the middle left image, the compressed image size is required to be 4*4, with a compression ratio of 2, where the compression ratio can also be a decimal. The pixels in the original image are divided into non-overlapping blocks of size (8*8) / (4*4), and the average pixel value of each block is calculated. This average value is used as the corresponding pixel value in the compressed image, as shown below. Figure 8 Each small block has a size of 4. Taking the first small block in the upper left corner as an example, the average of all the pixel values in the small block is summed: (8+147+221+91) / 4=116.75. 116.75 is recorded as the pixel value of the upper left corner of the compressed image.
[0077] IoU-based similarity template matching
[0078] IoU stands for Intersection over Union, a concept used in object detection. IoU calculates the overlap ratio between the predicted bounding boxes and the ground truth bounding boxes; that is, the ratio of their intersection to their union. Ideally, they overlap completely, meaning the ratio is 1. Traditional IoU calculation methods use the coordinates of the top left, right, and top right vertices of the bounding boxes, which only applies to bounding boxes. This application borrows this concept to calculate the intersection over union ratio between polygons in a standard graphics library and standard convex polygons, and calls it the improved IoU algorithm.
[0079] The improved IoU algorithm is equal to the ratio of the intersection and union of the "standard convex polygon" and the "real polygon," such as... Figure 10B1 contains polygons from the standard graphics library, and B2 contains standard convex polygons, which are normalized and compressed convex polygons. The graphics in the standard graphics library are user-inputted and pre-marked shapes tailored to industrial applications; these are also called real polygons. They include rectangles, squares, triangles, circles, etc., that meet standard dimensions, as well as user-defined shapes. The image containing user-defined polygons is guaranteed to be m*n in size. All images containing graphics from the standard graphics library have the same size. The center of gravity of the graphic and its image must first coincide, and then they must be tangent or touch one of their edges. Figure 11 As shown. The IoU (Intersection over Union) is calculated between each standard convex polygon and all types of real polygons, as follows: Figure 12 As shown, a higher IoU score indicates a higher overlap rate. Finally, the graphic from the standard graphic library with the highest IoU score is selected as the predicted shape image.
[0080] Fill the interiors of the highest-scoring graphics from the standard graphics library and the obtained standard convex polygons with grayscale, setting the grayscale value to 255. This yields the pixel set A = {x} for each graphic from the standard graphics library. A |x A =255} and the pixel set B = {x B |x B =255}. Then, the centroids of the two filled shapes are aligned. After alignment, each element is compared. If the same coordinate is 255, it is recorded as 1, indicating that the two shapes coincide at that pixel. Otherwise, it is recorded as 0, indicating that the two shapes do not coincide at that pixel. This process is repeated until every pixel element of set A and set B is traversed. The total number of 0s and 1s is the union, and the number of 1s is the intersection. The ratio of the intersection to the union is calculated to determine the actual shape of the standard convex polygon.
[0081] Multiply by the compression ratio to obtain the size-based prediction information:
[0082] To address the problem of recognizing standard graphics of the same shape but different sizes, after recognizing the shape, a compression ratio is used to backmap it back to the original size (M*N), resulting in the final graphic of each cluster of points with size information, such as... Figure 13 As shown.
[0083] Any aspects not covered in this invention are applicable to existing technologies.
Claims
1. A point-based shape contour recognition method, characterized in that, The identification method includes the following: Construct a standard graphics library, which includes regular graphics or custom graphics. All graphics are in images of equal size, and the center of gravity of the graphics and the images coincide. The image size in the standard graphics library is denoted as m*n. Obtain point data for each shape in the drawing to be identified; A density-based clustering algorithm is used to divide a group of points into different clusters in space. For each cluster, the convex hull algorithm is applied to obtain a convex polygon that encloses all the points in the cluster. Compress the convex polygon to an m*n size to form a standard convex polygon, and record the compression ratio; The IoU of the standard convex polygon and each graphic in the standard graphic library is compared, and the graphic in the standard graphic library with the highest score is taken as the outline of the predicted convex polygon. Then, based on the predicted shape, the original size is obtained by inverse mapping according to the compression ratio, so as to realize the recognition of the shape outline in the drawing. The process of the convex hull algorithm is as follows: (2.1) Selecting a reference point: Select a reference point from the cluster, and denote the reference point as p0; (2.2) Polar Angle Sort: Calculate the angle between the line connecting each point in the cluster to the reference point and the positive x-axis, and sort according to this angle; if multiple points have the same polar angle as the reference point, select the point closer to the reference point and sort it first. The sorted points are denoted as p1, p2, p3, ... pn; the first point p1 and the last point pn must be points on the convex hull. (2.3) Constructing the convex hull: Push the reference point p0 and the first point p1 in the sorted points onto the stack. Then, starting from p2, set the current point in order according to the sorted order for calculation. Initially, the reference point p0 is the first point under the stack, the stack vertex is p1, and the current point is p2. Calculate whether the vector formed by the first point under the stack as the starting point and the stack vertex as the ending point and the vector formed by the first point under the stack as the starting point and the current point as the ending point rotate counterclockwise. If yes, push the current point onto the stack and update the stack vertex, the first point under the stack, and the current point; if not, discard p2 and update the current point. Continue selecting the top two elements of the stack and the next current point. Again, calculate whether the vector formed by the first point below the stack as the starting point and the stack vertex as the ending point, and the vector formed by the first point below the stack as the starting point and the current point as the ending point, rotate counter-clockwise. If they rotate counter-clockwise, push the current point onto the stack. If not, check if the number of elements in the stack is greater than 2. If the number is greater than 2, pop the stack vertex, update the stack vertex, the first point below the stack, and the current point. If the number is not greater than 2, discard the current point and update the current point. Repeat this process until the current point is determined to be the last sorted point pn. Finally, the elements in the stack are the points on the outer perimeter of the convex hull of the cluster, and the lines connecting all the points on the outer perimeter of the convex hull form a convex polygon.
2. The point-based shape contour recognition method according to claim 1, characterized in that, The IoU calculation process is as follows: Fill the interior of the highest-scoring standard graphics library and the obtained standard convex polygon with the same pixel values, and the pixel values filled inside are different from the existing pixel values outside. Then, the centroids of the two filled graphics are aligned. After alignment, each pixel element is compared. If the coordinates of the two are the same, it is recorded as 1, which means that the two graphics coincide at that pixel point. Otherwise, it is recorded as 0, which means that the two graphics do not coincide at that pixel point. The total number of 0s and 1s is the union, and the number of 1s is the intersection. The ratio of the intersection and the union is the IoU value.
3. The point-based shape contour recognition method according to claim 1, characterized in that, The IoU calculation process is as follows: The highest-scoring image from the standard graphics library and the resulting standard convex polygon are filled with grayscale, with all pixels set to 255; This yields the pixel set A = {x} of a single image from the standard graphics library. A |x A =255} and the pixel set B = {x B |x B =255}; Then, the centroids of the two filled shapes are aligned together. After they are aligned, each pixel element is compared. If the same coordinate is 255, it is recorded as 1, which means that the two shapes are aligned at that pixel. Otherwise, it is recorded as 0, which means that the two shapes are not aligned at that pixel. The total number of 0s and 1s is the union, and the number of 1s is the intersection. The ratio of the intersection to the union is the IoU value.
4. The point-based shape contour recognition method according to claim 1, characterized in that, The graphics in the standard graphics library are graphics that are input by the user and pre-marked based on actual industrial conditions; the regular graphics are rectangles, triangles, circles, pentagons, or hexagons. If a graphic in the standard graphics library is a triangle, then, provided that the centroids coincide, the vertices of the triangle are in contact with the edge of the image, and one side of the triangle coincides with the edge of the image. If a graphic in the standard graphics library is a rectangle, then at least one pair of sides of the rectangle must coincide with the edge of the image containing it, provided that the centroids coincide. If a graphic in the standard graphics library is circular, then, provided that the centers of gravity coincide, the outline of the circle must have at least two points that touch the edge of the image. If a graphic in the standard graphics library is an irregular shape, then, under the premise that the centers of gravity coincide, find the two relative points of the largest outline of the irregular shape. These two relative points are in contact with the edge of the image.
5. The point-based shape contour recognition method according to claim 1, characterized in that, The process of determining whether it is a counter-clockwise rotation is as follows: Define the first point below the current stack top as a, the stack top as b, and the current point as c. The coordinates of these three points are denoted as (a...c ... x a y (b) x b y ), (c x c y ), calculate the area of the region enclosed by the three, if the area area > 0, then it is rotated counterclockwise in the order of a-b-c; The area = (b x -a x )*(c y -a y )-(b y -a y )*(c x -a x ).
6. The point-based shape contour recognition method according to claim 1, characterized in that, The reference point is selected based on the point with the smallest y-coordinate. If multiple points have the same y-coordinate, the point with the smallest x-coordinate is selected. The x-coordinate and y-coordinate are arbitrary spatial coordinates established in the drawing.
7. The point-based shape contour recognition method according to claim 1, characterized in that, The drawing to be identified is an electronic drawing that can export point coordinate information, including CAD drawings.
Citation Information
Patent Citations
A Tangram Pattern Recognition Method Based on Image Processing
CN106228195B
Method and device for recognizing wall based on CAD outer contour, medium and electronic equipment
CN114092953A
Industrial part contour recognition method, device and equipment and computer storage medium
CN115953593A
Needle-sheet-shaped particle content detection method based on binocular camera image acquisition and recognition
CN110033516A
Outer package defect detection method
CN112508090A
