A high-precision detection method for concave and convex feature points based on multi-segment straight line edge analysis

By using a method based on multi-segment straight line edge analysis, straight line segments in the image are screened and verified, concave and convex point hypotheses are generated, and sub-pixel precise localization is performed. This solves the problems of insufficient robustness and accuracy of concave and convex point detection in the existing technology, and achieves efficient and robust concave and convex point localization.

CN122335652APending Publication Date: 2026-07-03HANGZHOU HUICUI INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU HUICUI INTELLIGENT TECH CO LTD
Filing Date
2026-02-11
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing technologies rely on continuous and complete contours for complex and high-precision concave and convex point detection, resulting in insufficient detection reliability and accuracy. They are also sensitive to noise, making it difficult to achieve efficient and robust concave and convex point positioning in industrial scenarios.

Method used

A method based on multi-segment straight line edge analysis is adopted. By filtering out multi-segment straight line edges related to the top contour of the target object from the image, the spatial topological relationship and geometric constraints between the line segments are used to generate concave and convex point hypotheses. Through local verification and sub-pixel precise positioning, the dependence on contour integrity is reduced, thereby improving the robustness and accuracy of detection.

Benefits of technology

It achieves high-precision and robust detection of bumps and depressions in complex industrial scenarios, reduces the dependence on contour integrity, suppresses the generation of false feature points, improves computational efficiency, and is highly adaptable to different shapes and imaging conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122335652A_ABST
    Figure CN122335652A_ABST
Patent Text Reader

Abstract

This invention discloses a high-precision detection method for concave and convex feature points based on multi-segment straight line edge analysis, comprising the following steps: S10, image acquisition; S20, preprocessing and edge detection; S30, straight line segment extraction and filtering; S40, line segment relationship analysis and concave / convex hypothesis generation; S50, hypothesis verification and precise positioning; S60, outputting the coordinates of concave and convex points. This invention overcomes the dependence on continuous and complete contours by directly detecting and filtering multi-segment straight line edges related to potential concave and convex features from the image. Based on this, it robustly and accurately locates the coordinates of convex and concave points by analyzing the spatial topological relationships and geometric constraints between these straight line segments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of machine vision positioning technology and relates to a high-precision detection method for concave and convex feature points based on multi-segment straight line edge analysis. Background Technology

[0002] In numerous fields such as industrial automation, precision manufacturing, product quality control, and 3D surface morphology analysis, the accurate detection of local geometric features on object surfaces is of paramount importance. Among these, convex and concave points on the top or surface contours of an object serve as key geometric features characterizing local height variations, structural integrity, assembly accuracy, or functional properties. Accurate location of these points is fundamental for subsequent advanced tasks such as dimensional measurement, defect identification, classification and screening, and path planning. For example, in the inspection of electronic components (such as connectors and chip pins), it is necessary to locate protruding solder joints or recessed defects; in the contour analysis of mechanical parts (such as gears and cams), it is necessary to identify peaks and valleys on the contour; and in the assessment of material surface quality, it is necessary to locate bulges or pits caused by processing or corrosion. Traditional contact measurement methods (such as coordinate measuring machines), while highly accurate, have inherent limitations such as low efficiency, potential surface damage, and difficulty in online real-time detection. Therefore, non-contact, high-efficiency, and high-precision visual inspection technology has become the preferred solution to these problems.

[0003] Machine vision technology acquires digital images of targets through image sensors and extracts the required information using image processing and analysis algorithms. For the specific task of detecting concave and convex points, existing technical solutions mainly revolve around steps such as image preprocessing, edge detection, feature extraction, and key point localization. Among these, the closest implementation to this invention can be summarized as "extreme point detection methods based on global contour analysis or sub-pixel edge tracking." These solutions typically follow this process: First, the acquired raw grayscale image undergoes preprocessing such as filtering, denoising, and contrast enhancement to improve image quality. Next, classic edge detection operators (such as Canny, Sobel, LoG, etc.) or more advanced sub-pixel edge localization algorithms are used to obtain the contour information of the target object in the image. This contour is usually represented as a set of continuous, discrete pixels or sub-pixel precision points. Then, for this overall contour data, the algorithm directly searches for points on the curve where the first derivative is zero (or undergoes a sign change) and the second derivative satisfies specific conditions, identifying these as extreme points. In a two-dimensional image plane, if the contour is approximated as a function y=f(x) (or in parametric form), convex points correspond to local maxima, and concave points correspond to local minima. Specifically, a common approach in existing techniques is to process the extracted contour point sequence... To approximate the derivative, calculate the difference between its adjacent points, or perform polynomial fitting (such as quadratic curve fitting) on ​​the local point set, and locate the concave and convex features by solving for the extreme points of the fitted curve. Let's assume a local point set... A quadratic function was obtained by fitting. Then the x-coordinate of the extreme points of the fitted curve The corresponding ordinate can be calculated by substituting the values. By sliding a window through the entire contour, all matching conditions can be found. (Corresponding to the protrusion) or By defining a local window (corresponding to the concave point) and calculating its extreme points, the coordinates of a series of concave and convex points can be obtained. Another similar approach is to directly calculate the discrete curvature of the contour. For contour points... Its discrete curvature It can be estimated by the rate of change of the angle between the vectors formed by its preceding and following points, for example: ,in It is a point arrive vectors and points arrive The change in the angle between the vectors, It is the average arc length between adjacent points. Local maxima of curvature usually correspond to convex points (sharp corners or peaks), while local minima of curvature usually correspond to concave points (valleys). This type of method starts directly from the global contour, is conceptually intuitive, and can achieve certain detection results when the object contour is clear, noise interference is small, and concave and convex features are significant and isolated.

[0004] While the aforementioned extreme point detection methods based on global contour analysis have seen some application, their inherent shortcomings become particularly prominent when facing complex, high-precision, or highly interference-prone industrial scenarios, severely limiting the reliability, accuracy, and robustness of detection. First, its fundamental flaw lies in its high dependence on contour integrity and continuity. In actual image acquisition, due to uneven lighting, surface reflections, background interference, occlusion, or missing edges (e.g., insufficient lighting in deep concave points causing edge breaks), the extracted object contours are often discontinuous, broken, or contain numerous irrelevant edges (such as texture or dirt edges). Treating broken, noisy contours as a single sequence makes extreme point detection algorithms highly susceptible to interference, generating numerous false feature points (misjudging contour breaks or noise fluctuations as concave or convex points), while simultaneously missing true feature points located in areas with unclear contours. Second, the global processing strategy lacks specificity for local geometry. True concave or convex points are often only strongly correlated with a small segment of the contour's local geometry. Global traversal fitting or curvature calculation requires uniform processing of the entire contour, resulting in high computational costs and difficulty in adaptively adjusting parameters (such as the fitting window size) based on the characteristics of different regions. For complex contours with both flat regions (such as long straight edges and gentle arcs) and sharp concave and convex features, a globally fixed-size sliding window is either too sensitive to noise in flat areas or too smooth in feature areas, missing details. Furthermore, there are bottlenecks in improving sub-pixel accuracy. Existing methods typically perform sub-pixel refinement through local fitting after pixel-level contour extraction. However, if the initial edge localization has systematic deviations due to image quality or algorithm limitations, subsequent sub-pixel optimization can only proceed on the wrong "track," failing to fundamentally improve the true position accuracy of feature points. In addition, curvature calculation itself is extremely sensitive to noise; small perturbations in the position of discrete points can cause drastic fluctuations in curvature values, making detection methods based on curvature extrema highly unstable in noisy environments. Summary of the Invention

[0005] To address the main shortcomings of existing technologies, the present invention aims to provide a novel method and system for detecting concave and convex points based on multi-segment straight line edge analysis. This invention aims to overcome the reliance on continuous, complete contours by directly detecting and filtering multi-segment straight line edges related to potential concave and convex features from images. Furthermore, by analyzing the spatial topological relationships and geometric constraints between these line segments, the coordinates of convex and concave points can be robustly and accurately located. The specific objectives of this invention include: 1) designing a mechanism that can effectively filter out multiple straight-line edges related to the top contour of a target object from edge maps that may be broken, discontinuous, or contain complex backgrounds, reducing the dependence on contour integrity; 2) proposing an algorithm for generating and verifying concave and convex points based on the spatial relationships of line segments (such as relative position, angle, and endpoint proximity), which can distinguish between real concave and convex points and pseudo-points generated by noise, texture, or jointless segment connections; 3) constructing a coordinate calculation framework that includes global optimization and local fine modeling, which can determine the position of concave and convex points with high precision at the sub-pixel level, and its accuracy is not affected by the initial edge breakage; 4) ensuring the robustness and practicality of the method under common industrial visual interferences such as lighting changes, partial occlusion, and edge loss.

[0006] To solve the above problems, the technical solution of the present invention is a high-precision detection method for concave and convex feature points based on multi-segment straight line edge analysis, comprising the following steps: S10, Image Acquisition; S20, Preprocessing and Edge Detection; S30, Line Segment Extraction and Filtering; S40, Line segment relationship analysis and generation of concave-convex assumptions; S50, Hypothesis Verification and Precise Positioning; S60 outputs the coordinates of the concave and convex points.

[0007] Preferably, step S20 performs Gaussian filtering and adaptive histogram equalization on the image of the object to be detected acquired in step S10, and uses the Canny operator to extract pixel-level edge maps. .

[0008] Preferably, S30 includes processing pixel-level edge maps. Extract all possible line segments, and use probabilistic Hough transform or line segment detection algorithm to... A set of initial line segments was detected. Each line segment From its two endpoints definition; A filtering strategy based on geometric and grayscale characteristics is introduced, assuming the image coordinate system is... With the y-axis pointing downwards, for top detection of the target object, each line segment is calculated. Direction angle ,scope and retain the satisfaction The line segments, of which It is the expected edge direction. Using the angle threshold, a set of candidate line segments is obtained. .

[0009] Preferably, step S30 further includes a screening method based on the grayscale consistency of the edge support region for line segments. Take a certain width on each side along its normal direction. This forms a strip region. Calculate the average gray-level gradient magnitude within this region. Consistency with gradient direction Gradient direction consistency Defined as the average value of the cosine of the angle between the gradient direction of all pixels in the region and the normal direction of the line segment; Set threshold and Only retain those that meet the requirements. line segments; After filtering, a set of line segments related to the height of the top contour of the target object is obtained. .

[0010] Preferably, in S40, firstly, for each line segment Define its valid direction and calculate the direction vector of the line segment. ; For sets Any two line segments and ( Check the distance between their endpoints and set a distance threshold. ,if a certain endpoint and a certain endpoint Euclidean distance between If so, then these two endpoints may together constitute a feature point. The candidate position is denoted as point . Its initial coordinates can be taken as the midpoint of two points: .

[0011] Preferably, in S40, the initial determination of concavity / convexity is based on the pointing relationship of line segments, for forming hypothetical points. line segment pairs Consider departing from their respective line segments Starting from the closer end, extend a certain distance along the direction of the line segment into the interior of the line segment to obtain two reference points. and ; Calculate vectors and These two vectors describe the local orientation of the line segment near the assumed point.

[0012] Preferably, the concavity / convexity discrimination in S40 specifically involves: calculating the discrimination factor. First, calculate from point to and vector: Define the concavity / convexity discriminant factor. for: ; in, It is the z-component of the cross product of vectors. It is a symbolic function. and It is the y-component of the vector, and the sign of the cross product reflects the rotation order of the two vectors; The convex point assumption satisfies: and That is, two points The average position at Below; The concave point assumption is the opposite: and That is, two points are flat The average position at Above; Set rules: If Mark the hypothetical point as a candidate for convexity; if Mark as a concave point candidate; if If the connection is invalid or consists of parallel line segments, it should be excluded. By traversing all line segment pairs that satisfy the distance constraint, an initial set of concave and convex point hypotheses is generated. ,in It assumes the coordinates of a point. , They are related line segment pairs.

[0013] Preferably, S50 includes the following steps: S51, based on local edge support verification; S52, based on sub-pixel precise positioning of line segment extension intersection.

[0014] Preferably, S51 specifically includes: For each hypothesis and its associated line segment pairs, in the original grayscale image, with Define a small verification area centered on [the target area]. ,exist Inside, the Steger algorithm based on the Hessian matrix is ​​used to extract edge points that pass through the region. The Steger algorithm provides the edge point positions and their normal directions with sub-pixel accuracy. Suppose a set of sub-pixel edge points are extracted within this region. ,in It is the unit normal vector at the edge point. Projected onto line segments respectively and On the perpendicular normal, count the number of edge points that support each line segment, that is, the angle between the normal of the point and the normal of the line segment is less than a certain threshold, and the distance from the point to the line segment is less than a set threshold. If both line segments can obtain a sufficient number of support points, i.e., exceed the threshold If the hypothesis is supported by local image evidence, proceed to step S52; otherwise, consider it a false hypothesis and discard it, then re-extract sub-pixel edge points.

[0015] Preferably, S52 specifically includes: For line segments and The linear equation is fitted using its associated sub-pixel edge support points; assuming support The sub-pixel set is ,support The for , respectively and Perform weighted least squares line fitting; Considering the gradient magnitude at the edge points As a weight for its positioning reliability, it is minimized during fitting. ,in, It is the distance from the edge point to the fitted line; the equations of the two fitted lines are expressed as: and The coefficients are determined by the fitting process, and the direction of the straight line is consistent with the direction of the original line segment. The intersection of these two fitted lines is the coordinate of the precisely located concave / convex point. By solving a system of two linear equations in two variables: ; The solution is (when) hour): ; The coordinates It has sub-pixel accuracy, derived from the straight line fitted to sub-pixel edge points, and even the original line segments. and Even if there is no direct intersection at the endpoints, the theoretical intersection point can be found by extending straight lines to meet. The present invention has at least the following beneficial effects: 1. Extremely robust, overcoming the problem of incomplete contours: The most prominent advantage of this invention lies in its complete reduction of reliance on continuous, complete contours. By filtering meaningful line segments from complex edge maps and inferring feature points based on the spatial relationships between line segments, even if the target contour is broken, missing, or severely disturbed, as long as sufficient line segment fragments can be detected in the key areas, concave and convex points can be successfully located. This solves the pain point of existing technologies where performance drops sharply when edge extraction is unsatisfactory.

[0016] 2. High-precision positioning capability: This invention employs a "line segment local support point fitting -> straight line intersection" method for final positioning. This method bases positioning accuracy on the statistical stability of sub-pixel edge point groups and straight line fitting, rather than the position of a single endpoint. Even if the initial line segment endpoint positioning has deviations, the final fitted straight line intersection point can converge to a position closer to the true geometric intersection point, achieving sub-pixel level or even higher precision positioning. Compared to finding extrema through local curve fitting on potentially noisy discrete contour points, this method is mathematically more stable and has higher potential for accuracy.

[0017] 3. Effective Suppression of False Feature Points: This invention significantly suppresses the generation of false concave / convex points through a multi-level screening and verification mechanism. First, in the line segment extraction stage, a large number of irrelevant edges are removed through directional and grayscale consistency screening. Second, in the hypothesis generation stage, a large number of simple, neighboring but non-feature-specific endpoint connections are excluded through a concave / convexity discrimination criterion based on geometric orientation relationships. Finally, in the verification stage, the hypothesis points are required to be supported by local image evidence (sub-pixel edge points) and satisfy directional consistency, which further filters out hypotheses generated by accidental line segment arrangements or noise. This progressive filtering strategy ensures the reliability of the output results.

[0018] 4. Adaptability and Flexibility: The method framework of this invention has strong adaptability. This can be achieved by adjusting the angle threshold for line segment filtering. Distance threshold The parameters of the verification area can be easily adapted to detection tasks with different shapes, sizes, and imaging conditions. This method is particularly effective for industrial parts with significant linear features (such as polygonal contours and structures with edges).

[0019] 5. Potential for computational efficiency optimization: Although multiple steps are involved, the core operations (Hough transform, line segment selection, nearest neighbor search, and sub-pixel extraction of local small regions) can be accelerated through algorithm optimization or by leveraging the parallel computing capabilities of modern processors (such as GPUs). Compared to methods that require global sliding window fitting or calculation of the entire contour curvature, this method concentrates computational resources on a limited number of candidate line segments and local regions, making the overall computational load more controllable. Attached Figure Description

[0020] Figure 1 This is a flowchart illustrating the steps of a high-precision detection method for concave and convex feature points based on multi-segment straight line edge analysis according to an embodiment of the present invention. Figure 2 This invention provides a method for high-precision detection of concave and convex feature points based on multi-segment straight line edge analysis, which involves extracting and filtering a set of straight line segments from the original image. A schematic diagram. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0022] Conversely, this invention encompasses any substitutions, modifications, equivalent methods, and solutions made within the spirit and scope of the invention as defined in the claims. Furthermore, to provide a better understanding of the invention, certain specific details are described in detail below. However, those skilled in the art will fully understand the invention even without these detailed descriptions.

[0023] See Figure 1 The flowchart of an embodiment of the method of the present invention includes the following steps: S10, Image Acquisition; S20, Preprocessing and Edge Detection; S30, Line Segment Extraction and Filtering; S40, Line segment relationship analysis and generation of concave-convex assumptions; S50, Hypothesis Verification and Precise Positioning; S60 outputs the coordinates of the concave and convex points.

[0024] S20 performs Gaussian filtering and adaptive histogram equalization on the object image acquired by S10, and uses the Canny operator to extract pixel-level edge maps. .

[0025] S30 includes pixel-level edge maps To extract all possible line segments, first, use the Probabilistic Hough Transform (PHT) or LSD (Line Segment Detector) algorithm from... A set of initial line segments was detected. Each line segment From its two endpoints and Definition. Due to It includes various edges such as target contour edges, internal textures, and noise. The image contains a large number of irrelevant line segments. Therefore, this invention introduces a filtering strategy based on geometric and grayscale characteristics. Let the image coordinate system be... The y-axis points downwards. For top detection of target objects, we typically focus on edges that are close to horizontal or have a specific angular range. Therefore, we first calculate each line segment. Direction angle (scope ), and retain the satisfaction The line segments, of which Is the expected edge direction (e.g., for a horizontal top, ), For example, the angle threshold. This step yields a set of candidate line segments. .

[0026] To further eliminate textured or short noisy line segments, this invention designs a screening method based on "grayscale consistency of edge support regions." For line segments... Take a certain width on each side along its normal direction. (For example, 3 pixels) to form a strip region Calculate the average gray-level gradient magnitude within this region. Consistency with gradient direction Gradient direction consistency Defined as the average value of the cosine of the angle between the gradient direction of all pixels within the region and the normal direction of the line segment. A threshold is set. and Only retain those that meet the requirements. The line segments are selected. This step ensures that the retained line segments originate from real physical edges with significant and consistent grayscale variations. After filtering, we obtain a set of line segments that correlate with the height of the top contour of the target object. These line segments may be discontinuous, but they represent the main straight sections of the top outline of the object.

[0027] S40 is the key to this invention. Instead of directly connecting these line segments, we analyze their spatial relationships to infer possible concave and convex points. First, for each line segment... Define its "effective direction". Calculate the direction vector of the line segment. Since convex and concave points typically appear at the junction of the endpoints of two line segments, we focus on the relationships near the endpoints of the line segments. For sets... Any two line segments and ( Check the distance between their endpoints. Set a distance threshold. (Set according to image resolution and object size, for example, 10 pixels). If a certain endpoint (can be) or )and a certain endpoint Euclidean distance between If so, then these two endpoints may together constitute a feature point. The candidate position is denoted as point . Its initial coordinates can be taken as the midpoint of two points: , .

[0028] However, not all pairs of adjacent endpoints correspond to concave or convex points. This invention proposes a preliminary concave / convexity determination based on the "pointing relationship of line segments." For the formation of hypothetical points... line segment pairs Consider departing from their respective line segments Starting from the closer end (i.e. the endpoint involved in forming the hypothesis), extend a short distance (e.g., 10% of the line segment length or a fixed 5 pixels) inward along the line segment direction to obtain two reference points. and Calculate vectors (approximately) At the endpoint (pointing to) and (approximately) At the endpoint (The direction at the point). These two vectors describe the local orientation of the line segment near the assumed point.

[0029] Ideally, for a convex point (such as the summit of a mountain), two line segments should originate from that point and point downwards to either side. In a graphical coordinate system (where y is positive downwards), this means starting from the hypothetical point... Look, vectors and They should point roughly "outward" and their y-components should be relative to... It increases. Conversely, for a concave point (such as the bottom of a valley), the two line segments should originate from that point and point upwards to both sides, i.e., the vector points "outwards," but the y-component decreases. More precisely, we can calculate a discriminant factor. In S40, firstly, the calculation is performed from... point to and vector: Define the concavity / convexity discriminant factor. for: ; in, It is the z-component of the cross product of vectors. It is a symbolic function. and It is the y-component of the vector, and the sign of the cross product reflects the rotation order of the two vectors (clockwise or counterclockwise). The convexity assumption usually satisfies: and (meaning two points) The average position at (below), or another symmetrical case. The concave assumption is the opposite: and (The average position of the two points is above). Rules are set: If... Mark the hypothetical point as a candidate for convexity; if Mark as a concave point candidate; if If the value is close to zero (e.g., collinear vectors or values ​​close to zero), it may be an invalid connection or a connection of parallel line segments, and should be excluded. By traversing all line segment pairs that satisfy the distance constraint, an initial set of concave and convex point hypotheses is generated. ,in It assumes the coordinates of a point. , They are related line segment pairs.

[0030] Initial hypothesis set The data may contain false assumptions due to noise, incorrect line segment extraction, or accidental proximity. This invention proposes a two-stage verification and precise localization strategy, S50 including the following steps: S51, based on local edge support verification; S52, based on sub-pixel precise positioning of line segment extension intersection.

[0031] S51 specifically includes: For each hypothesis and its associated line segment pairs, in the original grayscale image, with Define a small verification area centered on [the target area]. ,exist Inside, the Steger algorithm based on the Hessian matrix is ​​used to extract edge points that pass through the region. The Steger algorithm provides the edge point positions and their normal directions with sub-pixel accuracy. Suppose a set of sub-pixel edge points are extracted within this region. ,in It is the unit normal vector at the edge point. Projected onto line segments respectively and On the perpendicular normal, count the number of edge points that support each line segment, that is, the angle between the normal of the point and the normal of the line segment is less than a certain threshold, and the distance from the point to the line segment is less than a set threshold. If both line segments can obtain a sufficient number of support points, i.e., exceed the threshold If the hypothesis is supported by local image evidence, proceed to step S52; otherwise, consider it a false hypothesis and discard it, then re-extract sub-pixel edge points.

[0032] The initial position of the validated hypothesis point. The accuracy is limited by simply averaging the coordinates of two endpoints. This invention proposes a high-precision positioning method: instead of relying on endpoints, it utilizes the intersection of two related line segments representing an infinite straight line. Therefore, S52 specifically includes: For line segments and The linear equation is fitted using its associated sub-pixel edge support points; assuming support The sub-pixel set is ,support The for , respectively and Perform weighted least squares line fitting; Considering the gradient magnitude at the edge points As a weight for its positioning reliability, it is minimized during fitting. ,in, It is the distance from the edge point to the fitted line; the equations of the two fitted lines are expressed as: and The coefficients are determined by the fitting process, and the direction of the straight line is consistent with the direction of the original line segment. The intersection of these two fitted lines is the coordinate of the precisely located concave / convex point. By solving a system of two linear equations in two variables: ; The solution is (when) hour): ; The coordinates It has sub-pixel accuracy, derived from the straight line fitted to sub-pixel edge points, and even the original line segments. and Even if there is no direct intersection at the endpoints (there may be small gaps or overlaps), the theoretical intersection point can be accurately found by extending straight lines to meet, which significantly improves the robustness and positioning accuracy in the case of edge breakage.

[0033] Figure 2 This demonstrates the process of extracting and filtering line segments from the original image. The diagram shows that background noise and irrelevant texture segments have been filtered out.

[0034] The core of this invention lies in its unique analytical reasoning framework and specific implementation technology, which traces the process "from the edges of multiple straight lines to concave and convex points." Specific key points and protection measures include: 1. A general method for detecting concave and convex points based on multiple straight line edges: This invention relates to a machine vision method for detecting concave and convex points, characterized by the following steps: extracting and filtering multiple straight line segments related to the target contour from a target image; analyzing the spatial proximity relationship between the endpoints of the straight line segments to generate candidate concave and convex point hypotheses; determining the concaveness and convexity based on the local pointing geometric relationship of the straight line segments associated with the candidate points; verifying the candidate points with local image evidence; and determining the final sub-pixel coordinates of the concave and convex points through high-precision fitting and intersection of the associated straight line segments.

[0035] 2. Geometric and Gray-Scale Consistency Criteria for Line Segment Selection: This involves protecting the specific technical features of filtering line segments after extraction by considering the angular deviation between the line segment's direction angle and the target direction, and combining this with a secondary selection based on the consistency of the average gradient magnitude and gradient direction within the line segment's support region. In particular, the consistency of the gradient direction is crucial. The calculation method and threshold judgment process.

[0036] 3. A method for determining the concavity and convexity of line segments based on their pointing relationships: Protecting two line segments associated with candidate points, a reference point is obtained by extending from their nearest endpoints into the interior of the line segments, and a vector is constructed. and And by calculating the discriminant factor The specific technical solution for determining whether a candidate point is a convex or concave point. The mathematical definition and physical meaning of this discrimination criterion (distinguishing between convex and concave points in the image coordinate system) are the key points of protection.

[0037] 4. Two-stage hypothesis verification and precise localization mechanism: In the first stage, sub-pixel edge extraction methods (such as the Steger algorithm) are used in the local region of candidate points to obtain edge point sets, and the consistency of orientation is used to determine whether the point set supports the technical features of the associated line segments. In the second stage, the sub-pixel edge support point sets obtained from each line segment are used to perform weighted least squares line fitting, and the intersection of the two fitted lines is used as the final concave / convex point coordinates. The specific technical solution involves using the gradient magnitudes of edge points as weights in weighted least squares fitting. The proposed solutions should also be protected.

[0038] 5. A system for implementing the above method: A visual inspection system comprising an image acquisition unit, a processing unit, and an output unit is protected, wherein the processing unit is configured to perform the above key method steps to achieve automatic detection and positioning of concave and convex points.

[0039] Those skilled in the art can make several substitutions or modifications without departing from the core concept of the present invention, and these substitutions can also achieve the purpose of the present invention.

[0040] Alternatives for line segment extraction algorithms: The Probabilistic Hough Transform (PHT) or LSD algorithm used in the core module can be replaced by any other algorithm capable of extracting discrete line segments from a binary edge map, such as the standard Hough Transform combined with a line segment splitting algorithm, or a line segment approximation algorithm based on edge chain codes (such as the Ramer-Douglas-Peucker algorithm). Any algorithm that outputs a list of line segments with endpoint coordinates can serve as input to this method.

[0041] Alternatives or extensions to line segment filtering criteria: In addition to orientation angle and grayscale consistency filtering, other filtering criteria can be added based on specific application scenarios. For example, a line segment length threshold can be introduced to filter out excessively short noise line segments; prior knowledge can be used to retain only line segments located within a specific region of interest (ROI) in the image; or color information (if it is a color image) can be used to filter edge line segments of specific color regions. These alternatives are all aimed at obtaining a more accurate set of line segments related to the target contour. .

[0042] Alternative expression for the concavity / convexity criterion: discriminant factor The calculation method can have an equivalent mathematical expression. For example, one can directly determine the combination of the sign of the cross product and the sign of the sum of the y-components without using a sign function. Alternatively, one can calculate the "angle" between the two line segments at the assumed point and their "inclination" relative to the horizontal line to make a comprehensive judgment. Any judgment logic that can effectively distinguish between "outward downward" and "outward upward" geometric patterns based on the local orientation of the two line segments near the candidate point can be used as an alternative implementation for this step.

[0043] Alternatives to local validation methods: In the first-stage validation, the Steger algorithm can be replaced by other sub-pixel edge localization methods, such as moment-based methods or quadratic surface fitting methods. The method for validating support can also be varied; for example, in addition to counting the number of support points, the average residual between the support points and the fitted line segment model can be calculated, and a residual less than a threshold is considered a support.

[0044] An alternative to the fitting method in precise localization: The second stage uses weighted least squares linear fitting, where the weights are the gradient magnitudes. Alternative approaches include: using ordinary least squares fitting (all weights are 1); using the RANSAC (Random Sample Consensus) algorithm for robust fitting to eliminate possible outliers; or using total least squares (TLS) fitting. The goal is to robustly estimate the line parameters representing the geometric direction of the line segment from a set of sub-pixel points.

[0045] Extending the approach to handling non-strictly straight edges: For contours containing small arcs or gently changing curvature, the core of this method (analyzing relationships between straight segments) may not be directly applicable. An alternative extension is to extract the edge points of contour gaps not covered by any line segments after the straight segments are extracted, and then perform curve fitting (e.g., arc fitting). These curve segments are then treated as "edge fragments" and included in the relationship analysis along with the straight segments. During the analysis, for the curve segments, the tangent direction at the point of tangency with the potential connection point can be used instead of the direction vector of the straight segment. This allows the method to be integrated into the framework for generating and determining concave and convex points in this invention. This enables the method to handle edges where straight lines and curves blend.

[0046] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A high-precision detection method for concave-convex feature points based on multi-segment straight line edge analysis, characterized in that, Includes the following steps: S10, Image Acquisition; S20, Preprocessing and Edge Detection; S30, Line Segment Extraction and Filtering; S40, Line segment relationship analysis and generation of concave-convex assumptions; S50, Hypothesis Testing and Precise Positioning; S60 outputs the coordinates of the concave and convex points.

2. The method according to claim 1, characterized in that, The S20 carries out Gaussian filter denoising and adaptive histogram equalization on the object image collected by the S10, and uses a Canny operator to extract a pixel-level edge map .

3. The method according to claim 2, characterized in that, S30 comprises extracting all possible line segments from the pixel-level edge map ​​​​​ A screening strategy based on geometric and gray level features is introduced, let image coordinate system be , y axis positive direction downward, for target object top detection, calculate the direction angle , range of each line segment , and keep the line segment which satisfies , where is the expected edge direction, is the angle threshold, get the candidate line segment set .

4. The method according to claim 3, characterized in that, S30 also includes a filtering method based on the grayscale consistency of the edge support region for line segments. Take a certain width on each side along its normal direction. This forms a strip region. Calculate the average gray-level gradient magnitude within this region. Consistency with gradient direction Gradient direction consistency Defined as the average value of the cosine of the angle between the gradient direction of all pixels in the region and the normal direction of the line segment; Set threshold and Only retain those that meet the requirements. line segments; After filtering, a set of line segments related to the height of the top contour of the target object is obtained. .

5. The method according to claim 4, characterized in that, In S40, firstly, for each line segment Define its valid direction and calculate the direction vector of the line segment. ; For sets Any two line segments and ( Check the distance between their endpoints and set a distance threshold. ,if a certain endpoint and a certain endpoint Euclidean distance between If so, then these two endpoints may together constitute a feature point. The candidate position is denoted as point . Its initial coordinates can be taken as the midpoint of two points: .

6. The method according to claim 5, characterized in that, The initial determination of concavity / convexity in S40 is based on the pointing relationship of line segments, for forming hypothetical points. line segment pairs Consider departing from their respective line segments Starting from the closer end, extend a certain distance along the direction of the line segment into the interior of the line segment to obtain two reference points. and ; Calculate vectors and These two vectors describe the local orientation of the line segment near the assumed point.

7. The method according to claim 6, characterized in that, The concavity / convexity discrimination in S40 specifically involves: calculating the discrimination factor. First, calculate from point to and vector: Define the concavity / convexity discriminant factor. for: ; in, It is the z-component of the cross product of vectors. It is a symbolic function. and It is the y-component of the vector, and the sign of the cross product reflects the rotation order of the two vectors; The convex point assumption satisfies: and That is, two points The average position at Below; The concave point assumption is the opposite: and That is, two points are flat The average position at Above; Set rules: If Mark the hypothetical point as a candidate for convexity; if Mark as a concave point candidate; if If the connection is invalid or consists of parallel line segments, it should be excluded. By traversing all line segment pairs that satisfy the distance constraint, an initial set of concave and convex point hypotheses is generated. ,in It assumes the coordinates of a point. , They are related line segment pairs.

8. The method according to claim 7, characterized in that, S50 includes the following steps: S51, based on local edge support verification; S52, based on sub-pixel precise positioning of line segment extension intersection.

9. The method according to claim 8, characterized in that, S51 specifically includes: For each hypothesis and its associated line segment pairs, in the original grayscale image, with Define a small verification area centered on [the target area]. ,exist Inside, the Steger algorithm based on the Hessian matrix is ​​used to extract edge points that pass through the region. The Steger algorithm provides the edge point positions and their normal directions with sub-pixel accuracy. Suppose a set of sub-pixel edge points are extracted within this region. ,in It is the unit normal vector at the edge point. Projected onto line segments respectively and On the perpendicular normal, count the number of edge points that support each line segment, that is, the angle between the normal of the point and the normal of the line segment is less than a certain threshold, and the distance from the point to the line segment is less than a set threshold. If both line segments can obtain a sufficient number of support points, i.e., exceed the threshold If the hypothesis is supported by local image evidence, proceed to step S52; otherwise, consider it a false hypothesis and discard it, then re-extract sub-pixel edge points.

10. The method according to claim 9, characterized in that, S52 specifically includes: For line segments and The linear equation is fitted using its associated sub-pixel edge support points; assuming support The sub-pixel set is ,support The for , respectively and Perform weighted least squares line fitting; Considering the gradient magnitude at the edge points As a weight for its positioning reliability, it is minimized during fitting. ,in, It is the distance from the edge point to the fitted line; the equations of the two fitted lines are expressed as: and The coefficients are determined by the fitting process, and the direction of the straight line is consistent with the direction of the original line segment. The intersection of these two fitted lines is the coordinate of the precisely located concave / convex point. By solving a system of two linear equations in two variables: ; The solution is (when) hour): ; The coordinates It has sub-pixel accuracy, derived from the straight line fitted to sub-pixel edge points, and even the original line segments. and Even if there is no direct intersection at the endpoints, the theoretical intersection point can be found by extending straight lines to meet.