Hole position detection method and device for annular workpiece, electronic equipment, storage medium and program product
By processing images and applying geometric filtering to annular workpieces, the problems of false detection and missed detection in hole detection of annular workpieces are solved, achieving high accuracy and robust hole detection, adapting to changes in workpiece position, and improving the input quality of subsequent orientation determination and pose estimation.
Patent Information
- Application Number
- CN202610867985.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-16
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2046-06-16
AI Technical Summary
Existing technologies have high false positive and false negative rates in the detection of holes in ring-shaped workpieces under complex backgrounds, and lack a collaborative mechanism, resulting in unstable input quality for subsequent orientation determination and pose estimation.
By processing the image of the ring-shaped workpiece, a set of candidate holes and a foreground region are obtained. The candidate hole set is verified using the foreground region, and false holes are eliminated. The target hole set is obtained through geometric filtering. Multi-round circle fitting and geometric constraints are used to improve the accuracy of hole detection.
It significantly reduces the false detection rate and false negative rate in complex backgrounds, improves the accuracy and robustness of hole detection, and provides high-quality input for subsequent orientation determination and pose estimation.
Smart Images

Figure CN122416002B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of industrial inspection technology, and in particular relates to a method, apparatus, electronic device, storage medium and program product for detecting hole positions of annular workpieces. Background Technology
[0002] In scenarios involving robotic arm loading, gripping, and assembly, the detection of hole locations in ring-shaped workpieces (such as flanges, end caps, perforated discs, bearings, or connecting discs) is fundamental for subsequent orientation determination and pose estimation. Existing technologies typically employ object detection networks like YOLO (You Only Look Once, a real-time object detection algorithm based on deep learning) to directly output hole bounding boxes, or use fixed ROIs (Regions of Interest) to limit the detection range. However, in complex imaging conditions in industrial settings, such as reflections, oil stains, occlusions, and cluttered backgrounds, YOLO detection is prone to false positives (identifying background noise as holes) and false negatives (failure to detect actual holes). Furthermore, fixed ROIs can lead to the truncation of actual holes and missed detections when the workpiece position changes. The detection and segmentation methods in related technologies are often used independently, lacking a collaborative mechanism, and there is a lack of specialized geometric cleaning methods for the center point set of holes in ring-shaped workpieces, resulting in unstable input quality for subsequent orientation determination and pose estimation. Summary of the Invention
[0003] This invention aims to at least solve one of the technical problems existing in the prior art. To this end, this invention proposes a method, device, electronic device, storage medium, and program product for hole position detection of annular workpieces, which effectively reduces the false detection rate and false negative rate in complex backgrounds, can adapt to changes in workpiece position without relying on a fixed ROI, significantly improves the accuracy and robustness of hole detection, and provides high-quality input for subsequent orientation determination and pose estimation.
[0004] In a first aspect, this application provides a method for detecting the hole position of a ring-shaped workpiece, comprising: The first image corresponding to the acquired annular workpiece is processed to obtain a set of candidate holes and the foreground region of the annular workpiece; Based on the foreground region, each hole detection box in the candidate hole set is verified to obtain the first hole set. The detection frames of each hole in the first hole set are filtered to obtain a target hole set. The target hole set is used to characterize the position information of each hole in the annular workpiece. When filtering the detection frames of each hole in the first hole set, multiple candidate circle models are obtained by fitting the center coordinates of each hole detection frame, and the multiple candidate circle models are filtered based on the geometric constraints of the annular workpiece.
[0005] According to the hole detection method for annular workpieces provided in this application embodiment, the image of the annular workpiece is processed to obtain a candidate hole set and a foreground region of the workpiece. Then, the foreground region is used to verify each hole detection box in the candidate hole set, and false holes located in the background region of the workpiece are removed to obtain a first hole set. Then, geometric filtering is performed on each hole detection box in the first hole set to obtain a target hole set used to characterize the precise position information of each hole in the annular workpiece. This effectively reduces the false detection rate and false negative rate in complex backgrounds, and can adapt to changes in workpiece position without relying on a fixed ROI. It significantly improves the accuracy and robustness of hole detection and provides high-quality input for subsequent orientation determination and pose estimation.
[0006] A hole position detection method for a ring-shaped workpiece according to an embodiment of this application, wherein the first hole set is obtained by verifying each hole detection frame in the candidate hole set based on the foreground region, including: If the geometric center point of the hole detection frame in the candidate hole set is located in the foreground region, the hole detection frame is added to the first hole set.
[0007] A hole position detection method for a ring-shaped workpiece according to an embodiment of this application, wherein the first hole set is obtained by verifying each hole detection frame in the candidate hole set based on the foreground region, including: Obtain the ratio of the overlap area between each hole detection frame in the candidate hole set and the foreground region to the total area of the hole detection frames; If the ratio is greater than or equal to the target ratio threshold, the hole detection box is added to the first hole set.
[0008] One embodiment of the method for detecting holes in a ring-shaped workpiece according to this application includes filtering each hole detection frame in the first hole set to obtain a target hole set, comprising: The coordinates of the center of each hole in the first set of holes are calculated to obtain the initial set of hole centers; Perform multiple rounds of circle fitting operations on the initial set of hole centers to obtain multiple candidate circle models; Based on the multiple candidate circle models and geometric constraints, the largest effective circle is obtained. The geometric constraints include that the radius of the candidate circle model is within the target radius range, and that the distance between the center of the candidate circle model and the center of the reference circle is less than the target distance threshold. The target hole set is determined based on the interior points of the largest effective circle.
[0009] One embodiment of this application describes a method for detecting the hole position of a ring-shaped workpiece, wherein performing a multi-round circle fitting operation on the initial set of hole centers to obtain multiple candidate circle models includes: Perform a circle fitting operation on the initial set of hole centers to obtain a candidate circle model and the set of interior points corresponding to the candidate circle model; After removing the set of interior points corresponding to the candidate circle model from the initial hole center set, the next round of circle fitting operation is entered until a preset stopping condition is met, and the multiple candidate circle models are obtained. The preset stopping condition includes that the number of hole center points in the initial hole center set is less than a first quantity threshold, or the number of rounds of circle fitting operation performed is greater than or equal to a second quantity threshold.
[0010] A hole position detection method for a ring-shaped workpiece according to an embodiment of this application, wherein determining the target hole set based on the inner points of the largest effective circle includes: If the number of interior points of the maximum effective circle is greater than the third threshold, calculate the polar angle between each interior point of the maximum effective circle and the center of the maximum effective circle, as well as the angle difference between each adjacent polar angle. From the interior points of the maximum effective circle, delete the interior point with the lowest confidence among the two interior points corresponding to the smallest angle difference, and update the number of interior points of the maximum effective circle. If the number of interior points of the maximum effective circle is less than or equal to the third quantity threshold, the interior points of the maximum effective circle are determined as the target hole center point set, and each point in the target hole center point set corresponds to a hole in the target hole set.
[0011] Secondly, this application provides a hole position detection device for annular workpieces, comprising: The first processing module is used to process the first image corresponding to the acquired annular workpiece to obtain a set of candidate holes and the foreground region of the annular workpiece. The second processing module is used to verify each hole detection box in the candidate hole set based on the foreground region to obtain the first hole set; The third processing module is used to filter each hole detection frame in the first hole set to obtain a target hole set. The target hole set is used to characterize the position information of each hole in the annular workpiece. When filtering each hole detection frame in the first hole set, multiple candidate circle models are obtained by fitting the center coordinates of each hole detection frame, and the multiple candidate circle models are filtered based on the geometric constraints of the annular workpiece.
[0012] According to the hole position detection device for annular workpiece provided in the embodiments of this application, the image of the annular workpiece is processed to obtain a candidate hole set and a foreground region of the workpiece. Then, the foreground region is used to verify each hole detection box in the candidate hole set, and false holes located in the background region of the workpiece are eliminated to obtain a first hole set. Then, geometric filtering is performed on each hole detection box in the first hole set to obtain a target hole set used to characterize the precise position information of each hole in the annular workpiece. This effectively reduces the false detection rate and false negative rate in complex backgrounds. It can adapt to changes in workpiece position without relying on a fixed ROI, significantly improving the accuracy and robustness of hole detection, and providing high-quality input for subsequent orientation determination and pose estimation.
[0013] Thirdly, this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the hole position detection method for annular workpieces as described in the first aspect above.
[0014] Fourthly, this application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the hole position detection method for annular workpieces as described in the first aspect above.
[0015] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the hole position detection method for annular workpieces as described in the first aspect above.
[0016] The above-described one or more technical solutions in the embodiments of this application have at least one of the following technical effects: By processing the image of the ring-shaped workpiece, a candidate hole set and the foreground region of the workpiece are obtained. Then, the detection boxes of each hole in the candidate hole set are verified using the foreground region to remove false holes located in the background region of the workpiece, resulting in a first hole set. Geometric filtering is then applied to the detection boxes of each hole in the first hole set to obtain a target hole set that represents the precise position information of each hole in the ring-shaped workpiece. This effectively reduces the false detection rate and false negative rate in complex backgrounds, and can adapt to changes in workpiece position without relying on a fixed ROI, significantly improving the accuracy and robustness of hole detection and providing high-quality input for subsequent orientation determination and pose estimation.
[0017] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0018] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a flowchart illustrating the hole position detection method for annular workpieces provided in an embodiment of this application. Figure 2 This is a schematic diagram of the hole position detection device for annular workpieces provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0019] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0020] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0021] The hole position detection method, hole position detection device, electronic device, and readable storage medium for annular workpieces provided in this application will be described in detail below with reference to the accompanying drawings and through specific embodiments and application scenarios.
[0022] The hole position detection method for ring-shaped workpieces can be applied to a terminal, specifically executed by the hardware or software within the terminal.
[0023] The hole position detection method for annular workpieces provided in this application embodiment can be executed by an electronic device or a functional module or entity in an electronic device that can implement the hole position detection method for annular workpieces. The electronic devices mentioned in this application embodiment include, but are not limited to, mobile phones, tablets, computers, cameras and wearable devices. The hole position detection method for annular workpieces provided in this application embodiment will be described below using an electronic device as the execution subject as an example.
[0024] like Figure 1As shown, the hole position detection method for the annular workpiece includes steps 110, 120 and 130.
[0025] Step 110: Process the first image corresponding to the obtained annular workpiece to obtain the candidate hole set and the foreground region of the annular workpiece; In this step, the ring includes a perfect circular ring, an approximately circular ring, an ellipse, and a workpiece shape whose center point set can be fitted into a closed curve.
[0026] A ring-shaped workpiece is a workpiece with an overall circular or near-circular shape, rotational symmetry, and at least one hole distributed on its surface. Examples include flanges, end caps, bearings, perforated discs, and connecting discs. The holes in a ring-shaped workpiece are usually distributed circumferentially and are used for positioning, assembly, or coding.
[0027] The first image is a raw digital image of a ring-shaped workpiece acquired via an industrial camera (such as a USB camera or an Orbbec camera) or via network streaming.
[0028] Processing the first image may include: identifying the hole region from the first image using an object detection algorithm (such as the YOLO series network, or other object detection networks, which are not limited in this application), and segmenting the pixel region containing the ring-shaped workpiece from the first image using a semantic segmentation algorithm (such as the UNet network, DeepLab, SAM, or FastSAM segmentation models). These two processes can be performed in parallel or sequentially.
[0029] The candidate hole set is a set of at least one hole bounding box obtained through object detection. Each bounding box is represented by its coordinates (x1, y1, x2, y2) in the image, indicating that a hole may exist in that region.
[0030] The foreground region is a mask for the pixel region containing the ring-shaped workpiece obtained through semantic segmentation. In this mask, pixels belonging to the ring-shaped workpiece are marked as 1 (foreground), and those not belonging to it are marked as 0 (background).
[0031] In some embodiments, when the semantic segmentation module is enabled, the system can automatically skip the fixed ROI constraint and decide whether to retain the candidate hole detection box entirely based on the verification result of the foreground segmentation mask; when semantic segmentation is not enabled, the system can switch to the fixed ROI constraint mode.
[0032] Before step 110, the original image can be scaled to a fixed size T×T using the Letterbox method, with a scaling ratio of... Here, H and W represent the original image height and width, respectively, with symmetrical padding applied to the shorter sides. After inference, the hole center coordinates are mapped back to the original image resolution based on the recorded scaling ratio and padding parameters.
[0033] Step 120: Verify the detection boxes of each hole in the candidate hole set based on the foreground region to obtain the first hole set; In this step, the hole detection box refers to each bounding box in the candidate hole set.
[0034] The foreground area can be used to determine the authenticity of candidate hole detection frames, so as to eliminate false holes that are not actually on the annular workpiece (such as noise or reflective points in the background).
[0035] The first set of holes refers to the set of hole detection boxes that are retained after verification. Each detection box in this set is considered to be a real hole with a high probability.
[0036] Step 130: Filter the detection frames of each hole in the first hole set to obtain the target hole set. The target hole set is used to characterize the position information of each hole in the annular workpiece.
[0037] In this step, the hole detection boxes in the first set of holes can be further refined, including but not limited to geometric constraint operations such as calculating hole center coordinates, multi-round circle fitting, concentricity screening, and angle pruning.
[0038] The target hole set refers to the final determined set of holes used to characterize the positional information of each hole on the ring-shaped workpiece. Each hole in this set corresponds to a hole center coordinate.
[0039] Location information refers to the two-dimensional coordinates (u, v) of the hole in the image, specifically the coordinates of the center point of the hole's bounding box.
[0040] When filtering the detection frames of each hole in the first set of holes, multiple candidate circle models can be obtained by fitting the center coordinates of each hole detection frame, and the multiple candidate circle models can be filtered based on the geometric constraints of the annular workpiece.
[0041] In some embodiments, a circle fitting operation can be performed based on the coordinates of the hole center to obtain multiple candidate circle models. The circle fitting operation can be implemented using a multi-round fitting method based on RANSAC (Random Sample Consensus Algorithm). For example, in each round of fitting, multiple points (e.g., 3 points) are randomly sampled from the current hole center point set to fit a circle model, and points whose distance from the circumference of the circle model is less than a preset interior point threshold are marked as interior points of the circle model. After using this circle model and its interior points as a candidate circle model, these interior points are removed from the current point set, and then the next round of fitting begins. This process is repeated until a preset stopping condition is met (e.g., the number of remaining points is less than the minimum number of sampling points, or the number of rounds executed reaches a preset maximum number of rounds), thus obtaining multiple candidate circle models.
[0042] The geometric constraints include two sub-conditions: radius constraint, which means that the radius of the candidate circle model is within the target radius range, where the target radius range can be preset based on the actual size of the ring workpiece; and concentricity constraint, which means that the distance between the center of the candidate circle model and the reference circle center is less than the target distance threshold, where the center of the candidate circle with the most interior points can be determined as the reference circle center.
[0043] According to the hole detection method for annular workpieces provided in this application embodiment, the image of the annular workpiece is processed to obtain a candidate hole set and a foreground region of the workpiece. Then, the foreground region is used to verify each hole detection box in the candidate hole set, and false holes located in the background region of the workpiece are removed to obtain a first hole set. Then, geometric filtering is performed on each hole detection box in the first hole set to obtain a target hole set used to characterize the precise position information of each hole in the annular workpiece. This effectively reduces the false detection rate and false negative rate in complex backgrounds, and can adapt to changes in workpiece position without relying on a fixed ROI. It significantly improves the accuracy and robustness of hole detection and provides high-quality input for subsequent orientation determination and pose estimation.
[0044] In some embodiments, when the system is in a multi-configuration parallel mode, multiple artifact configurations share the same semantic segmentation instance, which can reduce memory usage and repetitive initialization costs.
[0045] In some embodiments, step 120 may include: If the geometric center of the hole detection box in the candidate hole set is located in the foreground region, the hole detection box is added to the first hole set.
[0046] In this embodiment, the geometric center point is the approximate center of the hole.
[0047] For example, for each hole detection frame ,in, Using the index of the hole detection frame, the hole center can be calculated: Then, the two-dimensional hole center point (geometric center point) is obtained: .
[0048] It can be determined whether the pixel coordinates of the geometric center point fall within the region with a value of 1 in the foreground mask obtained from semantic segmentation. If so, it means that the center of the hole detection box is located on the annular workpiece body.
[0049] Hole detection frames that meet the above conditions (center point within the foreground area) are retained and added to the first hole set; those that do not meet the conditions are removed.
[0050] For example, suppose a flange workpiece has a circular foreground area. YOLO detects three hole detection frames: the center point of frame A falls within the circular area; the center point of frame B falls outside the circular area (e.g., on the background shadow); and the center point of frame C falls at the edge of the circular area. According to this strategy, only frame A is retained, while frames B and C are discarded.
[0051] This verification method is simple, efficient, and computationally inefficient. It can quickly eliminate most false holes that are significantly deviated from the workpiece, and is especially suitable for scenarios where the hole boundary box is relatively accurate and the center point is stable.
[0052] In some embodiments, step 120 may include: Obtain the ratio of the overlap area between each hole detection box and the foreground region in the candidate hole set to the total area of the hole detection boxes; If the ratio is greater than or equal to the target ratio threshold, the hole detection box is added to the first hole set.
[0053] In this embodiment, the overlap area refers to the pixel area of the portion where the rectangular area of the hole detection frame intersects with the foreground area (pixel area with a value of 1) of the foreground mask. The calculation formula is as follows: ,in, For hole detection frame, Foreground mask (foreground region).
[0054] The total area of the hole detection bounding box refers to the pixel area of the hole detection bounding box itself, i.e. .
[0055] It can obtain the ratio of the overlap area between each hole detection box and the foreground region in the candidate hole set to the total area of the hole detection boxes: This ratio reflects the degree to which the hole detection frame is covered by the workpiece body.
[0056] The target ratio threshold is a preset value, denoted as . The value can be adjusted based on user and scenario requirements. For example, in scenarios with severe occlusion, the threshold can be appropriately lowered (e.g., 0.3); in scenarios requiring high precision, the threshold can be increased (e.g., 0.7).
[0057] when If the hole detection frame is highly overlapped with the workpiece body, it is considered a true hole and should be retained; otherwise, it should be discarded.
[0058] The overlap ratio is used to verify whether the hole detection frame is a real hole. It has strong robustness. Even if the center of the hole is shifted outside the foreground area due to detection error, it can be retained as long as most of the frame is still on the workpiece. It is particularly suitable for scenarios where the workpiece position changes or the fixed ROI fails.
[0059] In some embodiments, step 130 may include: The coordinates of the center of each hole in the first set of holes are calculated to obtain the initial set of hole centers; Multiple rounds of circle fitting operations are performed on the initial set of hole centers to obtain multiple candidate circle models; Based on multiple candidate circle models and geometric constraints, the largest effective circle is obtained; The target set of holes is determined based on the interior points of the largest effective circle.
[0060] In this embodiment, for each hole detection frame Its hole center coordinates are .
[0061] The initial hole center set is a set of points consisting of the coordinates of the hole centers of all the hole detection frames in the first hole set. .
[0062] The circle fitting operation is as follows: based on RANSAC (Random Sample Consensus), multiple points (e.g., 3 points) are randomly sampled from the current point set to fit a circle model. The distance from all points to the circumference of the circle is counted. Points whose distance is less than a preset inner point threshold (e.g., any value between 2 and 5 pixels) are marked as inner points. Then, the inner points of the circle are removed from the current point set, and the next round of fitting begins. This process is repeated until the stopping condition is met.
[0063] In some embodiments, hole center point set cleaning can also be performed based on other multi-model circle fitting or robust estimation algorithms, which is not limited in this application.
[0064] The candidate circle model is a circle model obtained in each round of fitting, including the center and radius.
[0065] The geometric constraints include two sub-conditions: radius constraint, which means that the radius of the candidate circle model is within the target radius range, where the target radius range can be preset based on the actual size of the ring workpiece; and concentricity constraint, which means that the distance between the center of the candidate circle model and the reference circle center is less than the target distance threshold, where the center of the candidate circle with the most interior points can be determined as the reference circle center.
[0066] The maximum effective circle is the circle model with the most interior points among the candidate circles that satisfy the above geometric constraints. This circle is considered to best represent the circumference of the hole distribution on the annular workpiece.
[0067] The target hole set is a set of points consisting of all interior points (i.e., the true center of the hole) of the largest valid circle, with each interior point corresponding to a hole.
[0068] According to the hole position detection method for annular workpieces provided in the embodiments of this application, through multi-round circle fitting, the circumference that best matches the workpiece geometry can be extracted from the initial set of hole centers containing noise and outliers. The radius and concentricity constraints further ensure that the selected circle matches the physical dimensions of the workpiece. Outliers can be peeled off layer by layer, effectively suppressing the influence of duplicate detection, edge noise and false holes on the results.
[0069] In some embodiments, performing multiple rounds of circle fitting operations on the initial set of hole centers to obtain multiple candidate circle models may include: Perform a circle fitting operation on the initial set of hole centers to obtain the candidate circle model and the set of interior points corresponding to the candidate circle model; After removing the set of interior points corresponding to the candidate circle model from the initial hole center set, the next round of circle fitting operation is entered until the preset stopping condition is met, resulting in multiple candidate circle models. The preset stopping condition includes that the number of hole center points in the initial hole center set is less than the first quantity threshold, or the number of rounds of circle fitting operation performed is greater than or equal to the second quantity threshold.
[0070] In this embodiment, the first quantity threshold can be the minimum number of sampling points (e.g., it can be set to 3), that is, no more circle fitting can be performed.
[0071] The second quantity threshold can be a preset maximum number of rounds to prevent infinite loops.
[0072] For example, suppose a single-loop flange has 8 holes, but the initial set of hole centers contains 12 points (including 4 noise points). The first round of RANSAC fitting yields circle A and its 8 interior points (real holes). After removing these 8 points, 4 noise points remain. The second round fits circle B, but the radius of circle B may not meet geometric constraints, or the number of interior points may be very small. In the third round, the number of remaining points is less than 3, so the process stops. Finally, two candidate circle models, circle A and circle B, are obtained.
[0073] According to the hole position detection method for annular workpieces provided in the embodiments of this application, by setting a peeling circular fitting mechanism, it is ensured that each round of fitting is not affected by the previously fitted points, and the point sets on different annular rings can be extracted step by step. By setting reasonable stopping conditions, invalid calculations are avoided.
[0074] In some embodiments, determining the target set of holes based on the interior points of the largest effective circle may include: If the number of interior points of the maximum effective circle is greater than the third threshold, calculate the polar angle between each interior point of the maximum effective circle and the center of the maximum effective circle, as well as the angle difference between each adjacent polar angle. From the interior points of the maximum effective circle, delete the interior point with the lowest confidence among the two interior points corresponding to the smallest angle difference, and update the number of interior points of the maximum effective circle. If the number of interior points of the maximum effective circle is less than or equal to the third quantity threshold, the interior points of the maximum effective circle are determined as the target hole center point set, and each point in the target hole center point set corresponds to a hole in the target hole set.
[0075] In this embodiment, the third quantity threshold is the actual expected number of holes in the annular workpiece. For example, for an 8-hole flange, the corresponding third quantity threshold is 8.
[0076] The polar angle is the polar angle relative to the center of the circle for each interior point within the largest effective circle. The range of the polar angle is usually (-π, π] or [0, 2π].
[0077] The interior points can be sorted in ascending order of their polar angles to obtain the sequence. Calculate the difference between adjacent angles. (i=1 to m-1), and the angle difference between the last and the first. .
[0078] Find the minimum value among all angle differences The two corresponding interior points are the two points that are closest to each other on the circumference.
[0079] Confidence score measures how reliably an interior point is a true hole center rather than noise. Confidence score is determined by considering the following factors: the interior point score (number of times selected as an interior point) during the RANSAC fitting process, the radial distance deviation from the point to the fitted circle, and the frequency with which the point is selected as an interior point in multiple fitting rounds. Points with lower confidence scores are more likely to be redundant or spurious.
[0080] Among the two interior points corresponding to the minimum angle difference, select the one with the lower confidence level. After deleting the point with the lowest confidence level, the number of interior points is reduced by 1, and then the above process is repeated.
[0081] When the number of inner points is equal to or lower than the desired number of holes after repeated deletions, the deletion process stops.
[0082] For example, suppose there's an 8-hole flange, but the maximum effective circle has 10 points (including 2 redundant points). Calculate and sort the polar angles of these 10 points, and you'll find that the angle difference between two adjacent points is very small (e.g., only 1 degree, while it should be 45 degrees). Of these two points, one has a radial deviation of 0.5 pixels from the fitted circle (high confidence), and the other has a radial deviation of 3 pixels (low confidence). Remove the low-confidence point, reducing the number of inliers to 9. Repeat this process until the number of inliers equals 8. The final 8 points are the target hole center point set.
[0083] According to the hole position detection method for annular workpieces provided in the embodiments of this application, by designing an angle gap pruning method, it is more in line with the circumferential distribution characteristics of annular workpieces, and can accurately delete redundant detection points (such as the same hole detected repeatedly) and outlier noise points, ensuring that the output hole center point set is evenly distributed on the circumference and that the number is consistent with the actual number of holes in the workpiece.
[0084] The hole position detection method for annular workpieces provided in this application can be executed by a hole position detection device for annular workpieces. This application uses a hole position detection device for annular workpieces as an example to illustrate the hole position detection device for annular workpieces provided in this application.
[0085] This application also provides a hole position detection device for annular workpieces.
[0086] like Figure 2 As shown, the hole position detection device for the annular workpiece includes: a first processing module 210, a second processing module 220 and a third processing module 230.
[0087] The first processing module 210 is used to process the first image corresponding to the acquired annular workpiece to obtain a set of candidate holes and the foreground region of the annular workpiece. The second processing module 220 is used to verify each hole detection box in the candidate hole set based on the foreground region to obtain the first hole set; The third processing module 230 is used to filter each hole detection frame in the first hole set to obtain a target hole set. The target hole set is used to characterize the position information of each hole in the annular workpiece. When filtering each hole detection frame in the first hole set, multiple candidate circle models are obtained by fitting the center coordinates of each hole detection frame, and the multiple candidate circle models are filtered based on the geometric constraints of the annular workpiece.
[0088] According to the hole position detection device for annular workpiece provided in the embodiments of this application, the image of the annular workpiece is processed to obtain a candidate hole set and a foreground region of the workpiece. Then, the foreground region is used to verify each hole detection box in the candidate hole set, and false holes located in the background region of the workpiece are eliminated to obtain a first hole set. Then, geometric filtering is performed on each hole detection box in the first hole set to obtain a target hole set used to characterize the precise position information of each hole in the annular workpiece. This effectively reduces the false detection rate and false negative rate in complex backgrounds. It can adapt to changes in workpiece position without relying on a fixed ROI, significantly improving the accuracy and robustness of hole detection, and providing high-quality input for subsequent orientation determination and pose estimation.
[0089] In some embodiments, the second processing module 220 may also be used for: If the geometric center of the hole detection box in the candidate hole set is located in the foreground region, the hole detection box is added to the first hole set.
[0090] In some embodiments, the second processing module 220 may also be used for: Obtain the ratio of the overlap area between each hole detection box and the foreground region in the candidate hole set to the total area of the hole detection boxes; If the ratio is greater than or equal to the target ratio threshold, the hole detection box is added to the first hole set.
[0091] In some embodiments, the third processing module 230 can also be used for: The coordinates of the center of each hole in the first set of holes are calculated to obtain the initial set of hole centers; Multiple rounds of circle fitting operations are performed on the initial set of hole centers to obtain multiple candidate circle models; Based on multiple candidate circle models and geometric constraints, the largest effective circle is obtained. The geometric constraints include that the radius of the candidate circle model is within the target radius range, and the distance between the center of the candidate circle model and the center of the reference circle is less than the target distance threshold. The target set of holes is determined based on the interior points of the largest effective circle.
[0092] In some embodiments, the third processing module 230 can also be used for: Perform a circle fitting operation on the initial set of hole centers to obtain the candidate circle model and the set of interior points corresponding to the candidate circle model; After removing the set of interior points corresponding to the candidate circle model from the initial hole center set, the next round of circle fitting operation is entered until the preset stopping condition is met, resulting in multiple candidate circle models. The preset stopping condition includes that the number of hole center points in the initial hole center set is less than the first quantity threshold, or the number of rounds of circle fitting operation performed is greater than or equal to the second quantity threshold.
[0093] In some embodiments, the third processing module 230 can also be used for: If the number of interior points of the maximum effective circle is greater than the third threshold, calculate the polar angle between each interior point of the maximum effective circle and the center of the maximum effective circle, as well as the angle difference between each adjacent polar angle. From the interior points of the maximum effective circle, delete the interior point with the lowest confidence among the two interior points corresponding to the smallest angle difference, and update the number of interior points of the maximum effective circle. If the number of interior points of the maximum effective circle is less than or equal to the third quantity threshold, the interior points of the maximum effective circle are determined as the target hole center point set, and each point in the target hole center point set corresponds to a hole in the target hole set.
[0094] The hole position detection device for the annular workpiece in this application embodiment can be an electronic device or a component of an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the specific type of device.
[0095] The hole position detection device for the annular workpiece in this embodiment can be a device with an operating system. This operating system can be a Microsoft (Windows) operating system, an Android operating system, an iOS operating system, or other possible operating systems; this embodiment does not specifically limit the specific operating system.
[0096] The hole position detection device for annular workpieces provided in this application embodiment can achieve... Figure 1 The various processes implemented in the method implementation examples will not be described again here to avoid repetition.
[0097] In some embodiments, this application also provides a hole position detection system for annular workpieces, including: an image acquisition unit, a control unit, and an output unit.
[0098] In this embodiment, the image acquisition unit can be set on an industrial robot or production line station to acquire images of the ring-shaped workpiece in real time, including industrial cameras such as USB cameras or Orbbec cameras.
[0099] The control unit, such as an industrial computer, embedded motherboard, or other computing device, includes a processor and memory, and runs the detection algorithm. The control unit is electrically connected to the image acquisition unit and can be used to receive image data and execute the hole position detection method for annular workpieces as described in any of the above embodiments.
[0100] The output unit connects to the control unit and is used to output the final set of target holes (i.e., the coordinates of each hole's center) to the downstream system. The output can take the form of sending it to the robotic arm control system for grasping planning, pushing it via the ZMQ protocol in JSON format, or displaying it on a visual interface.
[0101] Industrial robots are automated robotic arms used to perform operations such as grasping, loading, and assembly.
[0102] The hole position detection system for ring-shaped workpieces can be directly deployed on industrial robot production lines. Through reasonable hardware configuration (camera mounting position and light source, etc.) combined with software algorithms, a fully automated detection process from raw images to hole center point sets is achieved, providing accurate gripping points for the robotic arm.
[0103] In some embodiments, such as Figure 3 As shown, this application embodiment also provides an electronic device 300, including a processor 301, a memory 302, and a computer program stored in the memory 302 and executable on the processor 301. When the program is executed by the processor 301, it implements the various processes of the above-described hole position detection method embodiment for annular workpieces and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0104] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0105] This application also provides a non-transitory computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the above-described hole position detection method embodiment for annular workpieces and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0106] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0107] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described hole position detection method for annular workpieces.
[0108] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0109] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described hole position detection method embodiment for annular workpieces, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0110] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0111] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0112] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the related technology, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0113] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
[0114] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0115] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
Claims
1. A method for detecting the hole position of a ring-shaped workpiece, characterized in that, include: The first image corresponding to the acquired annular workpiece is processed to obtain a set of candidate holes and the foreground region of the annular workpiece; Based on the foreground region, each hole detection box in the candidate hole set is verified to obtain the first hole set. The detection frames of each hole in the first hole set are filtered to obtain a target hole set. The target hole set is used to characterize the position information of each hole in the annular workpiece. When filtering the detection frames of each hole in the first hole set, multiple candidate circle models are obtained by fitting the center coordinates of each hole detection frame, and the multiple candidate circle models are filtered based on the geometric constraints of the annular workpiece. The step of filtering each hole detection frame in the first hole set to obtain the target hole set includes: The coordinates of the center of each hole in the first set of holes are calculated to obtain the initial set of hole centers; Perform multiple rounds of circle fitting operations on the initial set of hole centers to obtain multiple candidate circle models; Based on the multiple candidate circle models and geometric constraints, the largest effective circle is obtained. The geometric constraints include that the radius of the candidate circle model is within the target radius range, and that the distance between the center of the candidate circle model and the center of the reference circle is less than the target distance threshold. The target hole set is determined based on the interior points of the largest effective circle; The process of performing multiple rounds of circle fitting on the initial set of hole centers yields multiple candidate circle models, including: Perform a circle fitting operation on the initial set of hole centers to obtain a candidate circle model and the set of interior points corresponding to the candidate circle model; After removing the set of interior points corresponding to the candidate circle model from the initial hole center set, the next round of circle fitting operation is entered until a preset stopping condition is met, and the multiple candidate circle models are obtained. The preset stopping condition includes that the number of hole center points in the initial hole center set is less than a first quantity threshold, or the number of rounds of circle fitting operation performed is greater than or equal to a second quantity threshold.
2. The hole position detection method for annular workpieces according to claim 1, characterized in that, The first hole set is obtained by verifying each hole detection box in the candidate hole set based on the foreground region, including: If the geometric center point of the hole detection frame in the candidate hole set is located in the foreground region, the hole detection frame is added to the first hole set.
3. The hole position detection method for annular workpieces according to claim 1, characterized in that, The first hole set is obtained by verifying each hole detection box in the candidate hole set based on the foreground region, including: Obtain the ratio of the overlap area between each hole detection frame in the candidate hole set and the foreground region to the total area of the hole detection frames; If the ratio is greater than or equal to the target ratio threshold, the hole detection box is added to the first hole set.
4. The hole position detection method for annular workpieces according to claim 1, characterized in that, Determining the target hole set based on the interior points of the largest effective circle includes: If the number of interior points of the maximum effective circle is greater than the third threshold, calculate the polar angle between each interior point of the maximum effective circle and the center of the maximum effective circle, as well as the angle difference between each adjacent polar angle. From the interior points of the maximum effective circle, delete the interior point with the lowest confidence among the two interior points corresponding to the smallest angle difference, and update the number of interior points of the maximum effective circle. If the number of interior points of the maximum effective circle is less than or equal to the third quantity threshold, the interior points of the maximum effective circle are determined as the target hole center point set, and each point in the target hole center point set corresponds to a hole in the target hole set.
5. A hole position detection device for a ring-shaped workpiece, characterized in that, include: The first processing module is used to process the first image corresponding to the acquired annular workpiece to obtain a set of candidate holes and the foreground region of the annular workpiece. The second processing module is used to verify each hole detection box in the candidate hole set based on the foreground region to obtain the first hole set; The third processing module is used to filter each hole detection frame in the first hole set to obtain a target hole set. The target hole set is used to characterize the position information of each hole in the annular workpiece. When filtering each hole detection frame in the first hole set, multiple candidate circle models are obtained by fitting the center coordinates of each hole detection frame, and the multiple candidate circle models are filtered based on the geometric constraints of the annular workpiece. The third processing module is also used for: The coordinates of the center of each hole in the first set of holes are calculated to obtain the initial set of hole centers; Perform multiple rounds of circle fitting operations on the initial set of hole centers to obtain multiple candidate circle models; Based on the multiple candidate circle models and geometric constraints, the largest effective circle is obtained. The geometric constraints include that the radius of the candidate circle model is within the target radius range, and that the distance between the center of the candidate circle model and the center of the reference circle is less than the target distance threshold. The target hole set is determined based on the interior points of the largest effective circle. The third processing module is also used for: Perform a circle fitting operation on the initial set of hole centers to obtain a candidate circle model and the set of interior points corresponding to the candidate circle model; After removing the set of interior points corresponding to the candidate circle model from the initial hole center set, the next round of circle fitting operation is entered until a preset stopping condition is met, and the multiple candidate circle models are obtained. The preset stopping condition includes that the number of hole center points in the initial hole center set is less than a first quantity threshold, or the number of rounds of circle fitting operation performed is greater than or equal to a second quantity threshold.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the hole position detection method for annular workpieces as described in any one of claims 1-4.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the hole position detection method for annular workpieces as described in any one of claims 1-4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the hole position detection method for annular workpieces as described in any one of claims 1-4.
Citation Information
Patent Citations
Method, device and system for detecting hole in workpiece and storage medium
CN114255202A
Foreign matter detection method and device, electronic equipment and computer readable storage medium
CN116129348A