A segmentation method and system for closed contour of elongated workpiece based on contour corner point matching
Patent Information
- Application Number
- CN202611108958.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-24
- Publication Date
- 2026-10-13
AI Technical Summary
然而,在实际工业生产环境中,工件轮廓常因姿态旋转、局部倒角、噪声干扰、冗余折点和形变等因素出现不规则变化,导致现有方法存在显著局限性:(1)分段位置对目标姿态和轮廓局部变化过度敏感,同一工件在不同成像条件下的分段结果一致性差;(2)外接矩形或最小旋转矩形的角点通常位于轮廓外部,无法与真实轮廓上的特征点稳定对应;(3)闭合轮廓首尾衔接处易出现分段断裂,影响后续分析的连续性;(4)当多个参考点映射到同一轮廓点时,缺乏有效的冲突消解机制,导致分段逻辑混乱
1、提升分段结果的稳定性:本发明利用多边形逼近、多级角点筛选合并策略,降低噪声、冗余折点和局部形变对角点定位的干扰,并基于参考四边形的切分方法,使分段位置不再依赖于目标的绝对姿态,降低了对局部形变、倒角等轮廓变化的敏感性,同一工件在不同成像条件下的分段结果一致性与稳定性显著提升。
Smart Images

Figure CN122906100A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision, image processing and pattern recognition, and specifically to a method and system for segmenting the closed contour of slender workpieces based on contour corner point matching. Background Technology
[0002] In the fields of intelligent manufacturing and industrial vision inspection, the morphological quality inspection of slender workpieces (such as chopsticks, rods, pipes, and cables) is a key step in ensuring product consistency. This type of inspection typically relies on accurately extracting the closed contour of the workpiece from an image and dividing it into multiple contour segments according to fixed semantic rules to achieve refined analysis of different parts.
[0003] With the popularization of machine vision technology, automatic detection schemes based on image processing have gradually replaced traditional manual sampling. Existing closed contour segmentation methods mainly include equal arc length segmentation, geometric center direction segmentation, circumscribed rectangle / minimum rotation rectangle reference segmentation, etc. However, in actual industrial production environments, workpiece contours often undergo irregular changes due to factors such as posture rotation, local chamfering, noise interference, redundant inflection points, and deformation, resulting in significant limitations of existing methods: (1) The segmentation position is overly sensitive to the target posture and local contour changes, and the segmentation results of the same workpiece under different imaging conditions are inconsistent; (2) The corner points of the circumscribed rectangle or minimum rotation rectangle are usually located outside the contour and cannot stably correspond to the feature points on the real contour; (3) Segmentation breaks are prone to occur at the beginning and end of the closed contour, affecting the continuity of subsequent analysis; (4) When multiple reference points are mapped to the same contour point, there is a lack of effective conflict resolution mechanisms, leading to segmentation logic confusion. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a segmentation method and system for slender workpiece closed contours based on contour corner point matching that can stably and continuously segment the contours.
[0005] In a first aspect, the present invention provides a method for segmenting the closed contour of a slender workpiece based on contour corner point matching, specifically including the following steps: S1. Obtain the closed contour point sequence of the target to be measured; S2. Construct a four-corner reference frame based on the closed contour point sequence, and determine the four reference corner points of the four-corner reference frame; S3. Perform polygon approximation on the closed contour point sequence to obtain an approximation point sequence; S4. Iteratively filter the corner points of the approximation point sequence in a circular order: calculate the contour angle between the midpoints of three consecutive points in sequence; retain the midpoints with contour angles less than or equal to the angle filtering threshold as candidate corner points, and remove the points with contour angles greater than the angle filtering threshold; if there are points that are removed in this round of filtering, reconnect the retained candidate corner points in the original circular order to form a new approximation point sequence, and repeat the filtering process until no contour points are removed in a single filtering, and proceed to the next step; wherein, the circular order is the arrangement order of the closed contour point sequence in a clockwise or counterclockwise direction with the first and last points connected; S5. Significant Corner Detection and Neighboring Corner Merging: First, determine whether the included angle of the contour corresponding to the filtered candidate corner is less than or equal to the retention angle threshold. If so, the candidate corner is determined to be a significant corner, the significant corner is retained, and the merging operation is skipped; otherwise, the candidate corner is determined to be a normal candidate corner. After the selected candidate corner points are sorted in a circular order and their neighboring corner points are determined to be significant corner points, the distance between neighboring corner points that are all ordinary candidate corner points is calculated. If the distance is less than or equal to a preset distance threshold, the adjacent corner points are merged; otherwise, they are not merged. S6: Generate reference quadrilateral: Traverse the significant corner points and the merged candidate corner points, perform nearest distance matching between each significant corner point and the merged candidate corner point and the four reference corner points respectively, obtain four real contour corner points arranged in a ring order, and generate a reference quadrilateral with the four real contour corner points as vertices. S7: Initialize array structure: Define a minimum distance array of length 4 to store the minimum distance arrays corresponding to each vertex of the reference quadrilateral, and determine the index array in the closed contour point sequence, wherein the index array includes four segmentation indices; S8. Correct the four segmentation indices: sequentially traverse each contour point p in the closed contour point sequence, compare the distance of each contour point p to each vertex of the reference quadrilateral with the value in the minimum distance array. If it is less than the minimum distance array, update the minimum distance array and the index array to obtain the four contour point indices closest to the vertices of the reference quadrilateral; otherwise, do not update. S9. Result Output: Based on the four corrected segmentation indices, the closed contour point sequence is segmented into four segments in a circular order and the four contour segments are output.
[0006] Furthermore, the method for determining the four corner reference frames and the four reference corner points in S2 is as follows: Perform minimum rotation rectangle fitting on the closed contour point sequence and obtain the outer rectangle of the minimum rotation rectangle; determine four reference corner points based on the outer rectangle, which correspond to the upper left, upper right, lower right and lower left of the outer rectangle respectively.
[0007] Furthermore, the specific method for iterative corner selection described in S4 includes: Take three consecutive points in a circular counterclockwise order from the current point sequence. , , According to Equation 1: Formula 2: Japanese Style 3: Calculate the midpoint The included angle of the contour at the location; in Equations 1 to 3, equal to vector The angle with the positive X-axis; equal to vector The angle between the X-axis and the positive X-axis; θ is equal to the profile angle at the midpoint pt2; when season ;when season Then, according to equation 4: Calculation points Contour angle value In the formula, They are respectively , , The x and y coordinates; like Less than or equal to the angle filtering threshold Then As candidate corner points, record their coordinates and included angle values; if greater than the angle filtering threshold Then remove the intermediate point. The process involves reconstructing the approximation point sequence using the retained candidate corner points and repeating the filtering process until no contour points are removed in a single filtering.
[0008] Furthermore, the specific methods for determining significant corner points and merging adjacent corner points in S5 are as follows: Significant corner point determination: A preset angle retention threshold is used to extract the included angle of the contour corresponding to each filtered candidate corner point. Compared with the retained angle threshold, if the contour angle If the angle is less than or equal to the retention angle threshold, the candidate corner point is determined to be a significant corner point, the significant corner point is retained, and the merging operation is skipped; if the contour angle is less than or equal to the retention angle threshold, the candidate corner point is determined to be a significant corner point, the candidate ... If the angle threshold is retained, it is determined to be a normal candidate corner point; Neighboring Corner Merging: After determining the significant corners of the screened candidate corners in a circular order, the distances between neighboring corners that are all ordinary candidate corners are calculated. Let the neighboring corners be a and b, and the distance threshold be... ; If either a or b is a significant corner point, then skip the merging operation; If both a and b are ordinary candidate corner points, then according to Equation 5: Calculate the squared distance between two ordinary candidate corner points ; like If ordinary candidate corner points a and b are considered to be duplicate candidate corner points near the same actual corner point, according to Equation 6: Merge two candidate corner points into candidate corner point c; otherwise, do not merge.
[0009] Furthermore, the specific method for S6 to generate the reference quadrilateral is as follows: Traverse the significant corner points and the merged candidate corner points c, according to Equation 7: Calculate each significant corner point or each candidate corner point c after merging to four reference corner points. , , , square Euclidean distance In the formula, , These are the x and y coordinates of the four reference corner points, i = 0~3; Let c be the x and y coordinates of the candidate corner point; and let c be the squared Euclidean distance. The candidate corner point c corresponding to the minimum value is taken as the corresponding true contour corner point. This yields the four corresponding reference corner points. True outline corner points ,Depend on As vertices, the reference quadrilateral is formed in a circular sequence according to the reference corner points.
[0010] Furthermore, the specific correction method for S8 includes the following steps: Iterate through each contour point p in the closed contour point sequence, and let the contour point be... Reference quadrilateral vertices According to Equation 8: Calculate the relationship between each contour point p and the vertex of the reference quadrilateral. Euclidean distance and with the minimum distance array Perform a comparison; like Then perform the update operation: ; Conversely, no update operation will be performed; After the traversal is completed, the result is In the sequence of closed contour points, respectively, and the vertex The four most recent contour point indices are arranged in a circular order.
[0011] Furthermore, based on the four contour point indices obtained in S8, the closed contour is segmented in a cyclic order, with the specific segmentation range as follows: First outline: From arrive ; Second outline: From arrive ; Third outline: From arrive ; Fourth outline: From arrive .
[0012] If the fourth contour segment crosses the end of the closed contour sequence, then extract the contour segment from the end of the closed contour sequence first. Extract to the end of the sequence, then extract from the beginning of the sequence to... This is to ensure the integrity and continuity of the segments.
[0013] Furthermore, it also includes: S10, extracting segment-level measurement features from the above four contours in sequence for subsequent quality inspection; wherein, the segment-level measurement features include: segment-level diameter features, segment-level curvature features, and segment-level color difference features.
[0014] Secondly, the present invention also provides a segmentation system for the closed contour of slender workpieces based on contour corner point matching, for performing the above-described method, specifically including: The contour acquisition module is used to acquire the closed contour point sequence of the target under test; The reference frame generation module is used to generate four-corner reference frames and determine reference corner points based on a sequence of closed contour points. The contour approximation module is used to perform polygon approximation processing on a sequence of closed contour points to obtain a sequence of approximation points. The corner point screening module is used to extract candidate corner points through an iterative angle screening mechanism; The corner optimization module is used to perform neighbor merging and significant corner retention processing on candidate corners; The corner matching and mapping module is used to match candidate corner points with reference corner points to generate a reference quadrilateral. The segmentation index determination module is used to calculate the segmentation index of the closed contour based on the reference quadrilateral; The contour segmentation output module is used to segment and output closed contours based on the corrected segmentation index.
[0015] The present invention has the following advantages: 1. Improve the stability of segmentation results: This invention utilizes polygon approximation and multi-level corner point screening and merging strategies to reduce the interference of noise, redundant inflection points and local deformation on corner point positioning. Based on the segmentation method of reference quadrilateral, the segment position no longer depends on the absolute attitude of the target, reducing the sensitivity to contour changes such as local deformation and chamfering. The consistency and stability of segmentation results of the same workpiece under different imaging conditions are significantly improved.
[0016] 2. Enhance the reliability of segmentation results: By extracting corner points from the real contour and matching them with the corner points of the reference box, the problem that the corner points of the circumscribed rectangle or the minimum rotation rectangle are located outside the contour and cannot be stably matched with the real feature points in the traditional method is avoided, which significantly enhances the reliability of the segmentation results.
[0017] 3. Achieve continuous segmentation processing: Based on the characteristics of closed contours, a segmentation logic that spans the beginning and end is designed to avoid the segmentation breakage problem that easily occurs at the beginning and end of the traditional method, thus ensuring the integrity and continuity of the segmentation results.
[0018] 4. Improve the conflict resolution mechanism: By using the dynamic update strategy of the minimum distance array, the conflict problem of multiple reference points mapping to the same contour point can be effectively resolved, ensuring the clarity and consistency of the segmentation logic.
[0019] 5. Enhanced corner matching accuracy: By adopting an iterative angle selection and neighboring corner merging mechanism, noise interference and redundant inflection points can be effectively eliminated, and stable significant corner points can be accurately extracted, providing a high-quality feature point set for subsequent matching. Attached Figure Description
[0020] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0021] Figure 1 This is a flowchart illustrating the execution process of the method of the present invention.
[0022] Figure 2 This is a schematic diagram of the closed contour point sequence, four corner reference frames, and reference quadrilateral of the present invention. Detailed Implementation
[0023] The segmentation method of this invention follows a progressive logic of "contour acquisition - feature extraction - corner matching - index correction - contour segmentation". S1, acquiring the closed contour point sequence, is the foundation of the entire process, providing data for all subsequent processing. S2-S6, through operations such as constructing a reference box, polygon approximation, and corner point filtering and matching, gradually extract key features from the original contour and establish a reference frame. S7-S8 initialize and correct the segmentation index, providing a basis for accurate segmentation. S9, based on the corrected index, completes contour segmentation, which is the core output of the entire process. S10, extracting segment-level features, further refines the segmentation results, providing data support for quality inspection. Specific embodiments are described below: Example 1
[0024] refer to Figure 1 , Figure 2 As shown, this embodiment provides a segmentation method for the closed contour of slender workpieces based on contour corner point matching, specifically including the following steps: S1. Obtain the closed contour point sequence of the target to be measured. Figure 2 (Solid line shown); This step separates the target object in the image from the background, obtaining a closed contour composed of a series of ordered points, which facilitates subsequent geometric calculations and feature extraction.
[0025] S2. Construct a four-corner reference frame based on the closed contour point sequence. Figure 2 (As shown by the dashed lines), the four-corner reference frame is the bounding rectangle of the smallest rotated rectangle of the closed contour point sequence, or the axially circumscribed rectangle after attitude correction, or the user-configured detection reference frame; the four reference corner points are determined based on the four-corner reference frame. Figure 2 As shown in the figure, their order corresponds to the top left, top right, bottom right, and bottom left, respectively. Let the top left corner of the smallest rotated rectangle be... The bottom right corner is ,but , , , ; This step standardizes the target contour by constructing a four-corner reference box, eliminating the impact of target pose changes on subsequent processing and improving the robustness and adaptability of the algorithm. It also provides a unified reference framework for subsequent polygon approximation and corner point selection, ensuring the accuracy and consistency of subsequent processing.
[0026] S3. Use OpenCV's approxPolyDP function to approximate the closed contour point sequence with polygons to obtain the approximate point sequence. The purpose is to reduce the number of contour points, simplify the contour complexity, and retain the main shape features of the contour, so as to improve the efficiency of subsequent corner point selection and feature extraction, while ensuring the accuracy of the contour shape.
[0027] S4. Iteratively filter corner points in a circular order for the approximation point sequence: Take three consecutive points in a circular order (the closed contour point sequence is arranged in a clockwise or counterclockwise direction with the first and last points connected). ; According to Equation 1: Formula 2: Japanese Style 3: Calculate the midpoint The included angle of the contour at the location; in Equations 1 to 3, equal to vector The angle with the positive X-axis; equal to vector The angle between the X-axis and the positive X-axis; θ is equal to the profile angle at the midpoint pt2; when ,make ;when season Then, according to equation 4: Calculation points Contour angle value In the formula, They are respectively The x and y coordinates; like Less than or equal to the angle filtering threshold Then As candidate corner points, record their coordinates and included angle values; if greater than the angle filtering threshold Then remove the intermediate point. The remaining candidate corner points are then reconnected in the original circular order to form a new sequence of approximate points; this filtering process is repeated until no contour points are removed in a single filtering iteration. Angle threshold. The value can be set according to the target contour shape and contour sampling density, preferably between 140° and 170°, and is 160° in this embodiment.
[0028] This step iteratively calculates the contour angle between the midpoints of three consecutive points, filters out candidate corner points that meet the angle threshold, and removes points with excessively large contour angles to extract key corner points on the contour. This achieves accurate screening of contour corner points, removes redundant candidate corner points, and retains key corner points that can reflect the shape characteristics of the contour, providing a reliable foundation for subsequent corner point matching and contour segmentation.
[0029] S5. Determining significant corner points and merging adjacent corner points: (1) Significant corner point determination: preset the angle retention threshold, and extract the contour angle corresponding to each filtered candidate corner point. Compared with the retained angle threshold, if the contour angle If the angle threshold is retained, the candidate corner point is determined to be a significant corner point, which is then retained and the merging operation is skipped; if the contour angle is... If the angle threshold is retained, it is determined to be a normal candidate corner point; (2) Neighboring Corner Merging: After determining the significant corners of the screened candidate corners in a circular order, the distances between neighboring corners that are all ordinary candidate corners are calculated. Let the neighboring corners be a and b, and the distance threshold be... ; If either a or b is a significant corner point, then skip the merging operation; If both a and b are ordinary candidate corner points, then according to Equation 5: Calculate the squared distance between two ordinary candidate corner points ; like If ordinary candidate corner points a and b are considered to be duplicate candidate corner points near the same actual corner point, according to Equation 6: Merge two candidate corner points into candidate corner point c; otherwise, do not merge. Distance threshold. The value can be set according to the target image resolution, target size, and contour sampling density, and the value range is 5% to 20% of the long side size of the target's outer rectangle, or 50 to 200 pixels; in this embodiment, 150 pixels are used.
[0030] This step uses significant corner point identification and neighboring corner point merging operations to filter out significant corner points that can reflect the key features of the contour, eliminate redundant ordinary candidate corner points, and merge ordinary candidate corner points that are close to each other to optimize the quality of the corner point set. This achieves optimized processing of the corner point set, retains the key feature points of the contour, reduces the number of corner points, and improves the accuracy and efficiency of subsequent corner point matching and contour segmentation.
[0031] S6: Generate a reference quadrilateral: Traverse the significant corner points and the merged candidate corner points, according to Equation 7: Calculate the distance from each significant corner point or each candidate corner point c after merging to the four reference corner points. square Euclidean distance In the formula, , These are the x and y coordinates of the four reference corner points, i = 0~3; Let c be the x and y coordinates of the candidate corner point; and let c be the squared Euclidean distance. The candidate corner point c corresponding to the minimum value is taken as the corresponding true contour corner point. This yields the four corresponding reference corner points. True outline corner points ,Depend on As vertices arranged in a circular sequence according to the reference corner points, a reference quadrilateral is formed. Figure 2 (As shown).
[0032] This step determines the true contour corners and generates a reference quadrilateral by performing nearest-distance matching between significant corner points and merged candidate corner points and four reference corner points, providing an accurate reference for subsequent contour segmentation. It realizes the extraction of corner points from the true contour and matching with the reference box corner points, avoiding the problem in traditional methods where the corner points of the circumscribed rectangle or minimum rotation rectangle are located outside the contour and cannot stably correspond to the true feature points, thus significantly enhancing the reliability of the segmentation results.
[0033] S7: Initialize array structure: Define a minimum distance array of length 4 to store the minimum distance array corresponding to each vertex of the reference quadrilateral, and determine the index array in the closed contour point sequence, wherein the index array includes four splitting indices; This step initializes the minimum distance array and index array, providing the basic data structure for subsequent segmentation index correction. This ensures that the index of the contour point closest to the vertex of the reference quadrilateral can be accurately recorded and updated. It also implements the initialization settings of the segmentation index, providing the basis for data storage and updating for subsequent correction operations, and ensuring the smooth progress of the segmentation index correction process.
[0034] S8. Correct the four segmentation indices: Iterate through each contour point p in the closed contour point sequence, and set the contour point... Reference quadrilateral vertices According to Equation 8: Calculate the relationship between each contour point p and the vertex of the reference quadrilateral. Euclidean distance and with the minimum distance array Perform a comparison; like Then perform the update operation: ; Conversely, no update operation will be performed; After the traversal is completed, the result is In the sequence of closed contour points, respectively, and the vertex The four most recent contour point indices are arranged in a circular order.
[0035] This step iterates through the closed contour point sequence, calculates the distance from each contour point to each vertex of the reference quadrilateral, compares it with the values in the minimum distance array, and updates the minimum distance array and index array to obtain the indices of the four contour points closest to the vertices of the reference quadrilateral. This achieves precise correction of the segmentation index, ensuring the accuracy and reliability of the segmentation index and providing an accurate basis for subsequent contour segmentation.
[0036] S9. Output Results: Based on the four contour point indices obtained in S8, the closed contour is segmented in a circular order. The specific segmentation range is as follows: First outline: From arrive ; Second outline: From arrive ; Third outline: From arrive ; Fourth outline: From arrive .
[0037] If the fourth contour segment crosses the end of the closed contour sequence, then extract the contour segment from the end of the closed contour sequence first. Extract to the end of the sequence, then extract from the beginning of the sequence to... This is to ensure the integrity and continuity of the segments; This step, based on the four corrected segmentation indices, divides the closed contour point sequence into four segments in a circular order and outputs them to achieve accurate segmentation of the closed contour of slender workpieces, providing a basis for subsequent quality inspection. It achieves accurate segmentation of the closed contour, dividing the complete closed contour into four contour segments with clear semantics, which facilitates subsequent detailed analysis and quality inspection of different parts, while ensuring the integrity and continuity of the segmentation results.
[0038] S10. Extract segment-level measurement features from the above four contour segments sequentially for subsequent quality inspection. These segment-level measurement features include, but are not limited to: segment-level diameter features, segment-level curvature features, and segment-level color difference features. Specifically: the segment-level diameter feature includes parameters such as maximum width, minimum width, average width, and projection interval within the segment; the segment-level curvature feature includes parameters such as curvature within the segment, contour deviation, and maximum deviation point; and the segment-level color difference feature includes parameters such as the average color value within the segment, color distribution difference, and color difference value relative to the standard color template.
[0039] This step extracts segment-level measurement features from the four contours, providing basic data for subsequent quality inspection. This facilitates refined analysis and quality assessment of different parts of slender workpieces, improving the accuracy and relevance of quality inspection.
[0040] Example 2: This example provides a segmentation system for the closed contour of slender workpieces based on contour corner point matching, used to execute the method of Example 1, specifically including: The contour acquisition module is used to acquire the closed contour point sequence of the target under test; it provides reliable input for subsequent steps such as reference box generation and contour approximation.
[0041] The baseline frame generation module is used to generate four-corner baseline frames and determine baseline corner points based on the closed contour point sequence; subsequent corner point matching and segmentation index calculation provide accurate reference.
[0042] The contour approximation module is used to perform polygon approximation processing on the closed contour point sequence to obtain the approximation point sequence; it simplifies the contour and highlights features, improving the efficiency and accuracy of subsequent corner point extraction and matching.
[0043] The corner point screening module is used to extract candidate corner points through an iterative angle screening mechanism; it quickly filters out a large number of candidate corner points, providing a foundation for subsequent corner point optimization and matching.
[0044] The corner optimization module is used to perform neighbor merging and significant corner retention processing on candidate corners, thereby optimizing corner quality and improving the accuracy and reliability of corners.
[0045] The corner matching and mapping module is used to match candidate corners with reference corners, generate reference quadrilaterals, and establish the correspondence between corners; it achieves accurate corner matching and provides key correspondence for subsequent segmentation index calculation.
[0046] The segmentation index determination module is used to calculate the segmentation index of the closed contour based on the reference quadrilateral to determine the position of the contour segments; providing accurate position information for subsequent contour segmentation.
[0047] The contour segmentation output module is used to segment and output the closed contour based on the corrected segmentation index, and obtain the final segmentation result; it realizes accurate segmentation of the closed contour, and provides a foundation for subsequent quality inspection and other applications.
[0048] The method and system of the present invention have the following beneficial effects: 1. Improve the stability of segmentation results: This invention utilizes polygon approximation and multi-level corner point screening and merging strategies to reduce the interference of noise, redundant inflection points and local deformation on corner point positioning. Based on the segmentation method of reference quadrilateral, the segment position no longer depends on the absolute attitude of the target, reducing the sensitivity to contour changes such as local deformation and chamfering. The consistency and stability of segmentation results of the same workpiece under different imaging conditions are significantly improved.
[0049] 2. Enhance the reliability of segmentation results: By extracting corner points from the real contour and matching them with the corner points of the reference box, the problem that the corner points of the circumscribed rectangle or the minimum rotation rectangle are located outside the contour and cannot be stably matched with the real feature points in the traditional method is avoided, which significantly enhances the reliability of the segmentation results.
[0050] 3. Achieve continuous segmentation processing: Based on the characteristics of closed contours, a segmentation logic that spans the beginning and end is designed to avoid the segmentation breakage problem that easily occurs at the beginning and end of the traditional method, thus ensuring the integrity and continuity of the segmentation results.
[0051] 4. Improve the conflict resolution mechanism: By using the dynamic update strategy of the minimum distance array, the conflict problem of multiple reference points mapping to the same contour point can be effectively resolved, ensuring the clarity and consistency of the segmentation logic.
[0052] 5. Enhanced corner matching accuracy: By adopting an iterative angle selection and neighboring corner merging mechanism, noise interference and redundant inflection points can be effectively eliminated, and stable significant corner points can be accurately extracted, providing a high-quality feature point set for subsequent matching.
[0053] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described are merely illustrative and not intended to limit the scope of the invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A segmentation method for the closed contour of slender workpieces based on contour corner point matching, characterized in that, Includes the following steps: S1. Obtain the closed contour point sequence of the target to be measured; S2. Construct a four-corner reference frame based on the closed contour point sequence, and determine the four reference corner points of the four-corner reference frame; S3. Perform polygon approximation on the closed contour point sequence to obtain an approximation point sequence; S4. Iteratively filter the corner points of the approximation point sequence in a circular order: calculate the contour angle between the midpoints of three consecutive points in sequence; retain the midpoints with contour angles less than or equal to the angle filtering threshold as candidate corner points, and remove the points with contour angles greater than the angle filtering threshold; if there are points that are removed in this round of filtering, reconnect the retained candidate corner points in the original circular order to form a new approximation point sequence, and repeat the filtering process until no contour points are removed in a single filtering, and proceed to the next step; wherein, the circular order is the arrangement order of the closed contour point sequence in a clockwise or counterclockwise direction with the first and last points connected; S5. Significant Corner Detection and Neighboring Corner Merging: First, determine whether the included angle of the contour corresponding to the filtered candidate corner is less than or equal to the retention angle threshold. If so, the candidate corner is determined to be a significant corner, the significant corner is retained, and the merging operation is skipped; otherwise, the candidate corner is determined to be a normal candidate corner. After the selected candidate corner points are sorted in a circular order and their neighboring corner points are determined to be significant corner points, the distance between neighboring corner points that are all ordinary candidate corner points is calculated. If the distance is less than or equal to a preset distance threshold, the adjacent corner points are merged; otherwise, they are not merged. S6: Generate reference quadrilateral: Traverse the significant corner points and the merged candidate corner points, perform nearest distance matching between each significant corner point and the merged candidate corner point and the four reference corner points respectively, obtain four real contour corner points arranged in a ring order, and generate a reference quadrilateral with the four real contour corner points as vertices. S7: Initialize array structure: Define a minimum distance array of length 4 to store the minimum distance arrays corresponding to each vertex of the reference quadrilateral, and determine the index array in the closed contour point sequence, wherein the index array includes four segmentation indices; S8. Correct the four segmentation indices: sequentially traverse each contour point p in the closed contour point sequence, compare the distance of each contour point p to each vertex of the reference quadrilateral with the value in the minimum distance array. If it is less than the minimum distance array, update the minimum distance array and the index array to obtain the four contour point indices closest to the vertices of the reference quadrilateral; otherwise, do not update. S9. Output Results: Based on the four corrected segmentation indices, the closed contour point sequence is segmented into four segments in a circular order and the four contour segments are output.
2. The method for segmenting the closed contour of a slender workpiece based on contour corner point matching according to claim 1, characterized in that, The method for determining the four corner reference frames and the four reference corner points in S2 is as follows: Perform minimum rotation rectangle fitting on the closed contour point sequence and obtain the outer rectangle of the minimum rotation rectangle; determine four reference corner points based on the outer rectangle, which correspond to the upper left, upper right, lower right and lower left of the outer rectangle respectively.
3. The method for segmenting the closed contour of a slender workpiece based on contour corner point matching according to claim 1, characterized in that, The specific method for iterative corner selection described in S4 includes: Take three consecutive points in a circular counterclockwise order from the current point sequence. , , According to Equation 1: Formula 2: Japanese Style 3: Calculate the midpoint The included angle of the contour at the location; in Equations 1 to 3, equal to vector The angle with the positive X-axis; equal to vector The angle with the positive X-axis; equal to the profile angle at the midpoint pt2; when season ;when season Then, according to equation 4: Calculation points Contour angle value In the formula, They are respectively , , The x and y coordinates; like Less than or equal to the angle filtering threshold Then As candidate corner points, record their coordinates and included angle values; if greater than the angle filtering threshold Then remove the intermediate point. The process involves reconstructing the approximation point sequence using the retained candidate corner points and repeating the filtering process until no contour points are removed in a single filtering.
4. The method for segmenting the closed contour of a slender workpiece based on contour corner point matching according to claim 1, characterized in that, The specific methods for determining significant corner points and merging adjacent corner points in S5 are as follows: Significant corner point determination: A preset angle retention threshold is used to extract the included angle of the contour corresponding to each filtered candidate corner point. Compared with the retained angle threshold, if the contour angle If the angle is less than or equal to the retention angle threshold, the candidate corner point is determined to be a significant corner point, the significant corner point is retained, and the merging operation is skipped; if the contour angle is less than or equal to the retention angle threshold, the candidate corner point is determined to be a significant corner point, the candidate ... If the angle threshold is retained, it is determined to be a normal candidate corner point; Neighboring Corner Merging: After determining the significant corners of the screened candidate corners in a circular order, the distances between neighboring corners that are all ordinary candidate corners are calculated. Let the neighboring corners be a and b, and the distance threshold be... ; If either a or b is a significant corner point, then skip the merging operation; If both a and b are ordinary candidate corner points, then according to Equation 5: Calculate the squared distance between two ordinary candidate corner points ; like If ordinary candidate corner points a and b are considered to be duplicate candidate corner points near the same actual corner point, according to Equation 6: Merge two candidate corner points into candidate corner point c; otherwise, do not merge.
5. The method for segmenting the closed contour of a slender workpiece based on contour corner point matching according to claim 4, characterized in that, The specific method for generating the reference quadrilateral using S6 is as follows: Traverse the significant corner points and the merged candidate corner points c, according to Equation 7: Calculate each significant corner point or each candidate corner point c after merging to four reference corner points. , , , square Euclidean distance In the formula, , These are the x and y coordinates of the four reference corner points, i = 0~3; Let c be the x and y coordinates of the candidate corner point; and let c be the squared Euclidean distance. The candidate corner point c corresponding to the minimum value is taken as the corresponding true contour corner point. This yields the four corresponding reference corner points. , , , True outline corner points , , , ,Depend on , , , As vertices, the reference quadrilateral is formed in a circular sequence according to the reference corner points.
6. The method for segmenting the closed contour of a slender workpiece based on contour corner point matching according to claim 5, characterized in that, The specific calibration method for S8 includes the following steps: Iterate through each contour point p in the closed contour point sequence, and let the contour point be... Reference quadrilateral vertices According to Equation 8: Calculate the relationship between each contour point p and the vertex of the reference quadrilateral. , , , Euclidean distance , , , and with the minimum distance array Perform a comparison; like Then perform the update operation: ; Conversely, no update operation will be performed; After the traversal is completed, the result is , , , In the sequence of closed contour points, respectively, and the vertex , , , The four most recent contour point indices are arranged in a circular order.
7. The method for segmenting the closed contour of a slender workpiece based on contour corner point matching according to claim 6, characterized in that, Based on the four contour point indices obtained from S8, the closed contour is segmented in a circular order, with the specific segmentation range as follows: First outline: From arrive ; Second outline: From arrive ; Third outline: From arrive ; Fourth outline: From arrive ; If the fourth contour segment crosses the end of the closed contour sequence, then extract the contour segment from the end of the closed contour sequence first. Extract to the end of the sequence, then extract from the beginning of the sequence to... This is to ensure the integrity and continuity of the segments.
8. The method for segmenting the closed contour of a slender workpiece based on contour corner point matching according to claim 1, characterized in that, Also includes: S10. Extract segment-level measurement features from the above four contours in sequence for subsequent quality inspection; wherein, the segment-level measurement features include: segment-level diameter features, segment-level curvature features, and segment-level color difference features.
9. A segmentation system for the closed contour of slender workpieces based on contour corner point matching, characterized in that, The method for performing any one of claims 1-8 specifically includes: The contour acquisition module is used to acquire the closed contour point sequence of the target under test; The reference frame generation module is used to generate four-corner reference frames and determine reference corner points based on a sequence of closed contour points. The contour approximation module is used to perform polygon approximation processing on a sequence of closed contour points to obtain a sequence of approximation points. The corner point screening module is used to extract candidate corner points through an iterative angle screening mechanism; The corner optimization module is used to perform neighbor merging and significant corner retention processing on candidate corners; The corner matching and mapping module is used to match candidate corner points with reference corner points to generate a reference quadrilateral. The segmentation index determination module is used to calculate the segmentation index of the closed contour based on the reference quadrilateral; The contour segmentation output module is used to segment and output closed contours based on the corrected segmentation index.