Search

CN-122023578-A - Polygonal labeling method and device based on contour feature recognition

CN122023578ACN 122023578 ACN122023578 ACN 122023578ACN-122023578-A

Abstract

The application provides a polygon labeling method and a polygon labeling device based on contour feature recognition, wherein the method comprises the following steps: automatic acquisition of a user coordinate system, contour data acquisition and preprocessing, peripheral main label generation and local concave supplementary labeling. The outline vertex data of the complex polygon is obtained, a user coordinate system is determined, a peripheral main label is generated based on the axial bounding box, and then the local concave supplementary label is generated through concave edge feature judgment, so that a complete continuous size label chain which is reasonable in layout and accords with engineering drawing standards can be finally formed. Compared with the traditional manual marking and the traditional marking tool, the processing efficiency and the drawing quality are greatly improved.

Inventors

  • LIU TONG

Assignees

  • 旭杰科技(苏州)股份有限公司

Dates

Publication Date
20260512
Application Date
20251231

Claims (10)

  1. 1. The polygon labeling method based on contour feature recognition is characterized by comprising the following steps of: step1, automatically acquiring a user coordinate system; Obtaining direction angles of all sides of a multi-section line corresponding to a complex polygon to be marked, carrying out normalization and range mapping processing on the direction angles, and determining the main side direction of the multi-section line; defining a user coordinate system adapting to the polygon placement position according to a preset coordinate system rule based on the main edge direction; step2, contour data acquisition and preprocessing; acquiring ordered vertex coordinates of the closed multi-segment line under the user coordinate system in the step 1 according to the closed multi-segment line to be marked under the input two-dimensional drawing scene; Simultaneously calculating an axial bounding box which can completely wrap the polygon and has a boundary parallel to a coordinate axis of a user coordinate system, and determining boundary extremum parameters of the axial bounding box; Step 3, generating a peripheral main mark; screening peripheral feature vertexes of each side of the polygon through a geometric feature detection algorithm to form a plurality of groups of peripheral feature vertex sets; After each group of peripheral feature vertex sets are ordered according to a coordinate sequence, a continuous size labeling chain is generated in batches at a preset offset position outside the axial bounding box; step 4, local concave supplementary marking; screening polygon vertexes which are not covered by the peripheral labels in the step 3, and identifying concave characteristic vertexes in the polygon vertexes through neighborhood characteristic analysis; And generating corresponding supplementary dimension marks for the vertexes of the concave features to form complete dimension marks for covering the peripheries of the polygons and the concave areas.
  2. 2. The polygon labeling method based on contour feature recognition according to claim 1, wherein the normalization and range mapping process is performed on the direction angles in step 1, specifically includes normalizing the direction angles to [0 °,360 ° ], subtracting 180 ° when the direction angles are located in the (90 °,270 ° ] section, subtracting 360 ° when the direction angles are located in the (270 °,360 °) section, and mapping all the direction angles to (-90 °,90 ° ] section, and determining the main side direction of the multi-segment line in step 1, specifically, determining the direction angle with the highest occurrence frequency after statistical mapping, and taking the direction corresponding to the direction angle as the main side direction.
  3. 3. The method for labeling polygons based on contour feature recognition according to claim 2, wherein in step 1, the preset coordinate system rule is specifically: If the main side direction is located in the (45 DEG, 90 DEG) section, the Y-axis forward direction of the user coordinate system is taken as the direction, and the clockwise rotation direction of the Y-axis forward direction is taken as the X-axis forward direction; if the main side direction is located in the (-90 DEG, -45 DEG) interval, taking the main side direction as the negative direction of the Y axis of the user coordinate system, and taking the anticlockwise rotation direction of the main side direction as the positive direction of the X axis; If the main side direction is located in the interval of [ -45 DEG, 45 DEG ], the direction is taken as the X-axis forward direction of the user coordinate system, and the direction rotated 90 DEG anticlockwise is taken as the Y-axis forward direction.
  4. 4. The polygonal labeling method based on contour feature recognition according to claim 1, wherein the geometric feature detection algorithm in the step 3 is a unidirectional ray collision detection algorithm, and specifically comprises the steps of emitting rays from vertexes on each side of the polygon to the outside of the polygon respectively, wherein the directions of the rays are parallel to the axial direction of a user coordinate system, counting the number of intersection points of the rays and a multi-segment line, and screening out vertexes with only one intersection point as peripheral feature vertexes.
  5. 5. The method for labeling polygons based on contour feature recognition according to claim 1, wherein in step 4, the concave feature vertices among the uncovered vertices are identified by neighborhood feature analysis, specifically comprising determining a vertex as a concave feature vertex if neither a preceding neighboring vertex nor a following neighboring vertex of the vertex is peripherally labeled or both the preceding neighboring vertex and the following neighboring vertex are peripherally labeled but coordinate values in a direction to be supplemented are different from the vertex.
  6. 6. The method for labeling polygons based on contour feature recognition according to claim 1, wherein generating corresponding supplementary dimension labels for the vertices of the concave features in step 4 specifically comprises: Putting the concave feature vertexes needing X-direction labeling into a list p_ lst _AddXdim , and putting the concave feature vertexes needing Y-direction labeling into a list p_ lst _AddYdim ; Comparing X coordinates of each concave characteristic vertex in p_ lst _AddXdim with X coordinates of adjacent vertices, if the concave characteristic vertices are different, taking the concave characteristic vertex and the adjacent vertex as marking pick-up points, and taking the larger Y coordinate of the concave characteristic vertex and the adjacent vertex plus a preset distance as the Y coordinate of a marking size line to carry out X-direction linear marking; Comparing Y coordinates of each concave characteristic vertex in p_ lst _AddYdim with Y coordinates of adjacent vertices, if the concave characteristic vertices are different, taking the concave characteristic vertex and the adjacent vertex as marking pick-up points, and taking the larger X coordinate of the concave characteristic vertex and the adjacent vertex plus a preset distance as the X coordinate of a marking size line to carry out Y-direction linear marking.
  7. 7. The polygonal labeling method based on contour feature recognition according to claim 1, wherein: the method also comprises a step 5 of automatically optimizing the local concave supplementary marking layout, and specifically comprises the following substeps: s51, labeling classification and sorting; the supplementary dimension marking of the local concave vertex generated in the step S4 is divided into two types of X-direction marking and Y-direction marking; s52, performing layout adjustment on the X-direction mark and the Y-direction mark, wherein the layout adjustment comprises the following steps: removing the adjacent repeated labels; labeling collision detection and position adjustment in the same direction; cross-direction labeling collision detection and position adjustment; and repeatedly executing the same-direction labeling collision detection and position adjustment and the cross-direction labeling collision detection and position adjustment until no collision exists among all labels.
  8. 8. The method for labeling polygons based on contour feature recognition as set forth in claim 7, wherein the collision detection for labeling in the same direction in step S52 is specifically: extracting a current marked word bounding box, a size line and two size boundaries, and a marked word bounding box, a size line and two size boundaries to be compared and marking the current marked word, if the current marked size line overlaps with the size line to be compared or the current marked word bounding box overlaps with the marked word bounding box or the size line to be compared, judging that the to-be-compared mark collides with the current mark; The cross-direction labeling collision detection in step S52 specifically includes: Extracting a current marked word bounding box, a dimension line and two dimension limits, and a marked word bounding box, a dimension line and two dimension limits to be compared, wherein if any one of the current marked word bounding box, the dimension line or the two dimension limits is overlapped with the marked word bounding box to be compared or the current marked word bounding box is overlapped with the dimension line to be compared, the to-be-compared mark is considered to collide with the current mark.
  9. 9. A polygon labeling device based on contour feature recognition, comprising: The automatic acquisition module of the user coordinate system is configured to acquire direction angles of all sides of the multi-section line corresponding to the complex polygon to be marked, normalize and map the direction angles in a range, and determine the main side direction of the multi-section line; the contour data acquisition and preprocessing module is configured to acquire ordered vertex coordinates of the closed multi-segment line under the user coordinate system according to the closed multi-segment line to be marked in the input two-dimensional drawing scene; The peripheral main label generating module is configured to screen peripheral feature vertexes on each side of the polygon through a geometric feature detection algorithm to form a plurality of groups of peripheral feature vertex sets; The local concave supplementary marking module is configured to screen polygon vertexes which are not covered by the peripheral marking, identify concave characteristic vertexes in the polygon vertexes through neighborhood characteristic analysis, and generate corresponding supplementary dimension marking for the concave characteristic vertexes to form a complete dimension marking chain covering the periphery of the polygon and the concave area.
  10. 10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the contour feature recognition based polygon labeling method of any of claims 1-8 when the program is executed by the processor.

Description

Polygonal labeling method and device based on contour feature recognition Technical Field The invention relates to the technical field of constructional engineering design, in particular to a polygonal labeling method and device based on contour feature recognition. Background In the fields of building design, mechanical manufacturing, electronic engineering and the like, a Computer Aided Design (CAD) technology has become a core tool for engineering drawing and scheme design, and dimension marking is used as a key link for transmitting geometric dimension information in a CAD drawing, so that the accuracy, the integrity and the standardability of the CAD drawing directly determine the precision of subsequent production processing and construction, and the CAD drawing is an important technical foundation for guaranteeing the engineering quality. In the CAD software currently in mainstream, although the basic automatic labeling function is already provided for simple regular patterns (such as rectangles and regular polygons) composed of multiple segments, the dimension labeling is still highly dependent on the manual operation of designers for complex polygons (such as special-shaped building components, irregular mechanical component profiles, customized electronic component packages, etc.) existing in large quantities in engineering practice. Specifically, an operator needs to manually select the vertexes or edges of the multi-section lines one by one, basic tools such as 'linear labeling', 'alignment labeling' and the like provided by software are used for adding dimension labeling point by point and side by side, the whole process is complex in operation, and the requirements on professional experience and fineness of the operator are extremely high. In order to improve the current situation, in the prior art, an automatic tool for labeling polygons or a secondary development plug-in based on a CAD platform has appeared, but these technical schemes generally have functional limitations, and can only adapt to convex polygons or concave polygons with simple structures, so that the labeling requirements of complex polygons cannot be met, and specific defects can be summarized into the following three aspects: Firstly, the intelligent degree is low, and the manual intervention is excessively relied on. The existing automatic labeling tool usually realizes labeling logic based on a preset regular graph template (such as based on the parallelism of edges and the right angle characteristic of vertexes), can not automatically identify the geometric characteristics of complex polygons through an algorithm, particularly for polygons with multiple groups of concave edges and asymmetric concave structures, the tool can not accurately judge the characteristic vertexes and the size labeling requirements of concave areas, labeling deletion or labeling errors often occur, finally, a great deal of correction is still needed to be carried out on labeling results manually, and the practical application value of automatic labeling is greatly reduced. Secondly, the labeling efficiency is low, and human errors are easy to generate. The complex polygon in engineering practice often contains tens or even hundreds of vertexes, when a manual labeling mode is adopted, the time for labeling a single graph is usually 1-3 minutes, and if batch processing (such as batch labeling of special-shaped components of a building group and serial design labeling of mechanical parts) is involved, a large amount of working hours are consumed, and the design flow efficiency is seriously affected. Meanwhile, long-time repeated labeling operation is easy to cause visual fatigue of designers, so that the problems of vertex miss-selection, wrong transmission of dimension numerical values, wrong labeling direction selection and the like are caused, drawing dimension information deviation is caused, and quality hidden hazards are buried in subsequent engineering links. Thirdly, the labeling layout does not accord with engineering specifications, and the drawing readability is poor. Even if a part of tools can primarily label complex polygons, the capacity of optimizing label layout has obvious defects that on one hand, size lines and size characters are always overlapped and crossed to cause drawing information confusion, and on the other hand, the labeling positions do not follow industry habits of engineering drawing (such as peripheral size labeling is required to be positioned on the outer side of a graph) so as to not meet the standard requirements, increase the communication cost of drawing auditing and construction intersection, and reduce engineering cooperation efficiency. Therefore, how to solve the above-mentioned drawbacks of the prior art is a subject to be studied and solved by the present invention. Disclosure of Invention The invention aims to provide a polygon labeling method and device based on contour feature recognition, so as to so