Part hole automatic detection method and equipment
By automatically detecting holes in 3D five-axis cut parts through image acquisition and machine vision algorithms, the problems of low detection efficiency and high labor costs have been solved, achieving efficient and automated hole detection.
Patent Information
- Application Number
- CN202511125767.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2025-12-12
AI Technical Summary
Existing technologies suffer from low efficiency, poor consistency, high labor costs, and low automation in the detection of holes in 3D five-axis cutting parts.
Image acquisition and machine vision algorithms are used to acquire images of standard parts and test parts, perform image thresholding, extract hole contour data, and use image processing algorithms and ellipse fitting method to determine whether the hole cut through, diameter, position and contour are qualified.
It achieves efficient and automated hole inspection, improves inspection consistency, and reduces labor costs.
Smart Images

Figure CN121120506A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of material detection, and particularly relates to a part hole automatic detection method and device. BACKGROUND
[0002] Three-dimensional five-axis cutting machines have a wide range of application scenarios in the field of mechanical manufacturing and can be used to process complex three-dimensional parts. For complex three-dimensional parts, the internal processing holes are a very common structural feature, including round holes, square holes, and special-shaped holes. In order to detect whether the three-dimensional parts are qualified, the processing quality of the holes often needs to be detected. The qualified detection content of the part holes generally includes whether the hole is cut through, whether the diameter of the hole is within the tolerance range, the position error of the hole, and the contour error of the special-shaped hole. The traditional hole detection method of three-dimensional five-axis cutting parts is generally to manually use a vernier caliper, a micrometer, a smooth plug gauge, or the like to measure a plurality of holes processed on the part one by one to determine whether the holes are processed qualified. This method has the disadvantages of low efficiency, poor consistency, high labor cost, and low automation degree. Therefore, a method or device is needed to efficiently and automatically detect whether all holes of a three-dimensional five-axis cutting part are qualified. SUMMARY
[0003] The purpose of the present application is to overcome the problems of low detection efficiency, poor consistency, high labor cost, and low automation degree of part hole detection in the prior art.
[0004] To this end, the present application provides a part hole automatic detection method, comprising the following steps:
[0005] Collecting a standard part image, extracting a target area in the image, performing image threshold segmentation on each target area respectively, extracting the contour with the largest area of the target area as the standard part hole contour, and obtaining standard part hole contour image data;
[0006] Collecting a to-be-tested part image under the same conditions, extracting a target area in the image, performing image threshold segmentation on each target area respectively, extracting the contour with the largest area of the target area as the to-be-tested part hole contour, and obtaining to-be-tested part hole contour image data;
[0007] According to the detection index, calculating the error between the to-be-tested part hole contour image data and the standard part hole contour image data, comparing the error with a set error threshold, and determining whether the corresponding detection of the to-be-tested part hole is qualified.
[0008] Specifically, the detection index includes at least one of hole cutting-through detection, hole diameter detection, hole position detection, and hole contour detection.
[0009] Specifically, the judgment method of the hole penetration detection is specifically: calculating the area s1 of the hole contour of the measured part and the area s0 of the hole contour of the standard part, comparing whether the ratio s1 / s0 and the difference s1-s0 are within the set error threshold range, and if yes, the detection is passed, otherwise, the detection is not passed.
[0010] Specifically, the judgment method of the hole diameter detection is specifically: fitting the hole contour of the standard part and the hole contour of the measured part into an ellipse respectively, obtaining the long axis length a1 and the short axis length b1 of the hole contour of the measured part and the long axis length a1 and the short axis length b0 of the hole contour of the standard part, comparing whether the difference between a1 and a0 and the difference between b1 and b0 are within the set error threshold range, and if yes, the detection is passed, otherwise, the detection is not passed.
[0011] Specifically, the judgment method of the hole position detection is specifically: fitting the hole contour of the standard part and the hole contour of the measured part into an ellipse respectively, obtaining the ellipse center position c1 of the hole contour of the measured part and the ellipse center position c0 of the hole contour of the standard part, comparing whether the distance between c1 and c0 is within the set error threshold range, and if yes, the detection is passed, otherwise, the detection is not passed.
[0012] Specifically, the judgment method of the contour detection is specifically: calculating the hole contour center through image moment, from the center, every 1 degree from 0 to 359 degrees is a ray, the shortest distance from the intersection point of each ray and the hole contour to the center point is calculated, and the result difference between the hole contour of the measured part and the hole contour of the standard part is calculated one by one, and if within the set error threshold range, the detection is passed, otherwise, the detection is not passed.
[0013] Specifically, the part hole automatic detection method further comprises calculating the pixel ratio according to the true diameter of the hole of the standard part; converting the difference into an actual deviation according to the pixel ratio; comparing the actual deviation with the set error threshold to judge whether the part hole of the measured part is qualified.
[0014] Specifically, the image threshold segmentation is specifically: using a 2D image processing algorithm to calculate a recommended threshold, and using the recommended threshold to segment the image.
[0015] Specifically, the part hole automatic detection method further comprises pre-processing the standard part image and / or the measured part image before image threshold segmentation; the pre-processing comprises denoising and morphological processing.
[0016] The application also provides a part hole automatic detection device, comprising a support, a light source, an image acquisition device, a programmable controller, and an industrial computer; the light source and the image acquisition device are both mounted on the support; the image acquisition device is used to acquire standard part images or measured part images; the programmable controller is used to control the light source; and the industrial computer is used to receive images and process image data.
[0017] Compared with the prior art, the present application has the following advantages and beneficial effects:
[0018] The part hole automatic detection method provided by the present application can efficiently and automatically detect whether all holes of a three-dimensional five-axis cutting part are qualified by comparing the measured part with a part template prepared in advance through image acquisition of the three-dimensional five-axis part and using machine vision related algorithms, and has high consistency and low labor cost.
[0019] The present application will be further described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 is a hardware structure schematic diagram of a part hole automatic detection equipment in an embodiment of the present application.
[0021] Figure 2 is a system composition schematic diagram of a part hole automatic detection equipment in an embodiment of the present application.
[0022] Figure 3 is a flow chart of an offline template creation stage in an embodiment of the present application.
[0023] Figure 4 is a flow chart of an online detection stage in an embodiment of the present application.
[0024] Figure 5 is a principle diagram of hole penetration detection in the present application.
[0025] Figure 6 is a principle diagram of hole diameter detection in the present application.
[0026] Figure 7 is a principle diagram of hole position detection in the present application.
[0027] Figure 8 is a principle diagram of hole contour detection in the present application.
[0028] Reference signs: 1, support; 2, light source; 3, image acquisition device; 301, 2D camera; 302, lens; 4, industrial computer; 5, PLC; 6, network card; 7, workbench; 8, part to be measured. DETAILED DESCRIPTION
[0029] The technical solutions in the present application will be clearly and completely described below with embodiments. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Although the representative embodiments of the present application have been described in detail, those skilled in the art will understand that various modifications and changes can be made to the present application without departing from the scope of the present application. Therefore, the scope of the present application should not be limited to the embodiments, but should be defined by the appended claims and their equivalents.
[0030] The present application provides a part hole automatic detection method, comprising the following steps:
[0031] Collecting standard part images, extracting target regions in the images, respectively performing image threshold segmentation on each target region, extracting the contour with the largest area of the target region as the standard part hole contour, and obtaining standard part hole contour image data;
[0032] Collecting images of parts to be detected under the same conditions, extracting target regions in the images, respectively performing image threshold segmentation on each target region, extracting the contour with the largest area of the target region as the part-to-be-detected hole contour, and obtaining part-to-be-detected hole contour image data;
[0033] According to the detection index, calculating the error between the corresponding part-to-be-detected hole contour image data and the standard part hole contour image data, comparing the error with the set error threshold, and judging whether the corresponding detection of the part-to-be-detected part hole is qualified.
[0034] In actual use, a plurality of templates of standard parts can be created at one time, the measurement information data (image acquisition data of cameras, light sources, etc.) in the imaging process of each type of standard part, the set error threshold, and the corresponding standard part hole contour image data are recorded, and an offline module database is formed. Since the part has a three-dimensional structure, different parts of the surface cannot be completely imaged at one time. Different cameras and light sources can be used to take pictures of different parts of the part according to needs, and corresponding subgraphs are formed. One subgraph refers to a complete image taken by one camera under a group of light sources. A new subgraph is formed when the camera or the light source is changed. When detection is needed, the corresponding standard part template is loaded according to the number of the part to be detected, the subgraphs in the template are traversed, images are taken according to the saved camera and light source information, the saved detection data information is traversed, each hole region is compared and processed, and the detection result is obtained and recorded.
[0035] In order to improve the accuracy of the detection result, the part hole automatic detection method further comprises calculating a pixel ratio according to the true diameter of the standard part hole, converting the difference value into an actual deviation according to the pixel ratio, comparing the actual deviation with the set error threshold, and judging whether the part-to-be-detected part hole is qualified. Avoiding the distortion of the size of the object caused by scaling, deformation and other operations, and affecting the detection result.
[0036] The detection indexes can be designed according to actual needs, and preferably include at least one of hole cutting detection, hole diameter detection, hole position detection, and hole profile detection.
[0037] In an embodiment, the judgment method of the hole cutting detection is specifically as follows: image threshold segmentation, and after extracting the largest profile, referring to Figure 5 , the hole profile of the measured part is shown by dark shading in the figure, and the hole profile of the standard part is shown by light shading in the figure. The area s1 of the hole profile of the measured part and the area s0 of the hole profile of the standard part are calculated, and whether the ratio s1 / s0 and the difference s1-s0 are within a set error threshold range is compared. If yes, the detection passes; otherwise, the detection fails.
[0038] The judgment method of the hole diameter detection is specifically as follows: image threshold segmentation, and after extracting the largest profile, preferably using the least square method, the hole profile of the standard part and the hole profile of the measured part are fitted into an ellipse. Referring to Figure 6 , the ellipse fitted by the hole profile of the measured part is shown by dark shading in the figure, and the ellipse fitted by the hole profile of the standard part is shown by light shading in the figure. The major axis length a1 and the minor axis length b1 of the hole profile of the measured part and the major axis length a1 and the minor axis length b0 of the hole profile of the standard part are obtained, the difference between a1 and a0 and the difference between b1 and b0 are calculated, and the actual difference is converted according to the pixel proportion. The actual difference is compared with the preset error threshold value. If within the set range, the detection passes; otherwise, the detection fails.
[0039] The judgment method of the hole position detection is specifically as follows: image threshold segmentation, and after extracting the largest profile as the hole profile, preferably using the least square method, the hole profile of the standard part and the hole profile of the measured part are fitted into an ellipse. Referring to Figure 7 , the ellipse fitted by the hole profile of the measured part is shown by dark shading in the figure, and the ellipse fitted by the hole profile of the standard part is shown by light shading in the figure. The center position c1 of the ellipse of the hole profile of the measured part and the center position c0 of the ellipse of the hole profile of the standard part are obtained, the distance between c1 and c0 is calculated, and the actual distance is converted according to the pixel proportion. The actual distance is compared with the preset error threshold value. If within the set range, the detection passes; otherwise, the detection fails.
[0040] The judgment method of the profile detection is specifically as follows: image threshold segmentation, and after extracting the largest profile as the hole profile, referring to Figure 8 , the hole profile of the standard part is shown by light shading in the figure, and the difference between the hole profile of the measured part and the hole profile of the standard part is shown by dark shading in the figure. The center of the hole profile is calculated by image moment. From the center, a ray is drawn every 1 degree from 0 to 359 degrees. The shortest distance from the intersection point of each ray and the hole profile to the center point is calculated. The result difference between the hole profile of the measured part and the hole profile of the standard part is calculated one by one, and the actual difference is converted according to the pixel proportion. The actual difference is compared with the preset error threshold value. If within the set range, the detection passes; otherwise, the detection fails.
[0041] Optionally, the image threshold segmentation is specifically using a 2D image processing algorithm to calculate a recommended threshold, and using the recommended threshold to segment the image, dividing the image into a target region and a background region, to realize preliminary image segmentation, facilitating subsequent analysis and processing. In actual operation, the user can manually modify the threshold to achieve better processing effect.
[0042] Further, the part hole automatic detection method further comprises pre-processing the standard part image and / or the to-be-detected part image before image threshold segmentation is performed on the standard part image and / or the to-be-detected part image; the pre-processing comprises denoising and morphological processing. The target contour is clearer, facilitating image segmentation and feature extraction, and improving the visual effect of the image and the accuracy of subsequent processing.
[0043] The application further provides a part hole automatic detection device, comprising a support, a light source, an image acquisition device, a programmable controller, and an industrial computer; the light source and the image acquisition device are both mounted on the support; the image acquisition device is used to acquire a standard part image or a to-be-detected part image; the programmable controller is used to control the light source; and the industrial computer is used to receive the image and process image data. In use, the standard part or the to-be-detected part is fixed on a corresponding station of the workbench, and the industrial computer controls the process, the PLC controls the light source, the image acquisition device acquires an image with the best imaging effect, and then transmits the image to the industrial computer through a network card; the industrial computer processes the image and compares data, and then obtains a hole detection result.
[0044] The effect of the part hole automatic detection method and device of the application is studied through specific examples.
[0045] Example 1: Refer to Figures 1-2 The example provides a part hole automatic detection device, comprising a support 1, a light source 2, an image acquisition device 3, an industrial computer 4, and a programmable controller (PLC 5); the image acquisition device 3 comprises a plurality of 2D cameras 301, which acquire images through lenses 302 of the 2D cameras 301; the support 1 is erected on the periphery of a workbench 7 of a three-dimensional five-axis cutting machine, the light source 2 and the 2D cameras 301 are both mounted on the support 1, and the coverage range of the light source 2 and the acquisition range of the image acquisition device 3 cover the workbench 7; the industrial computer 4 is installed on the horizontal ground beside the support 1; as shown in Figure 2 the industrial computer 4 is connected with the 2D cameras 301 and the PLC 5, respectively, is used to receive images acquired by the 2D cameras 301 and perform processing and process control; the PLC 5 is connected with the light source 2 and is used to control the light source 2.
[0046] In use, the standard part or the part to be tested 8 is fixed on the workbench 7 corresponding to the work station, the 2D camera 301 and the PLC 5 are controlled by the industrial computer 4, a suitable 2D camera 301 is selected, the light source 2 is adjusted, the best imaging effect is selected by viewing the real-time image of the 2D camera 301, and a photograph is taken, the 2D image is transmitted to the industrial computer 4 through the network card 6, the image is processed and data is compared by the industrial computer 4, and then the hole detection result is obtained.
[0047] Embodiment 2: The embodiment provides a part hole automatic detection method, which comprises an offline template creation stage and an online detection stage based on template comparison, and comprises the following steps.
[0048] S1, referring to Figure 3 The processing flow of the offline template creation stage is as follows:
[0049] S101, fixing the standard part on the tooling of the external workbench of the three-dimensional five-axis cutting machine;
[0050] S102, selecting a corresponding camera, viewing the real-time image of the camera, changing the light source through PLC control, adjusting the imaging effect, until the imaging effect of part of the holes in the image is good, that is, there is a large gray scale difference between the holes and the surrounding areas;
[0051] S103, the camera collects and saves a standard part image, the system records the camera and light source information used by the image as a sub-image;
[0052] S104, in the collected sub-image, a rectangular frame is used to frame a hole area with good imaging effect as a target area, the area is intercepted from the image, and denoising and morphological processing are performed;
[0053] S105, a recommended threshold is calculated by using a 2D image processing algorithm, the threshold is used to segment the intercepted area, then the contour with the largest area of the target area is extracted as the standard part hole contour, and real-time display is performed, and the threshold can be manually modified by a user;
[0054] S106, selecting and recording a detection function, the detection function comprises hole cut-through detection, hole diameter detection, hole position detection, and hole contour detection. According to the detection function, parameter setting and image sorting are performed. For hole cut-through detection, the system records the area of the hole contour; for hole diameter detection, the system records the length of the major axis and the minor axis of the ellipse fitted by the least square method; for hole position detection, the system records the center position of the ellipse fitted by the least square method; for hole contour detection, the system records the actual contour point set; in addition, the system also records the corresponding error threshold set by the user;
[0055] S107, inputting the real diameter of the hole, calculating and saving the pixel ratio of the hole area;
[0056] S108, repeat S104-S107 until all the hole regions with good imaging effect on the image are processed;
[0057] S109, repeat S102-S108 until all the holes on the standard part that need to be detected are processed;
[0058] S110, save all the detection region information of each subgraph as an offline template, and archive it to a folder, and name it with the part model, the folder contains several pictures and an xml file, the pictures are the saved subgraph images, and the xml file contains the detection region information of each subgraph.
[0059] S2, refer to Figure 4 The processing flow of the online detection stage is as follows:
[0060] S201, the industrial computer system receives an external PLC or manual trigger signal, and starts the detection process;
[0061] S202, load the corresponding offline template file according to the workpiece model of the part to be detected;
[0062] S203, read a detection subgraph information from the template, including the light source and camera used, open the corresponding light source, and use the corresponding camera to capture an image of the part to be detected;
[0063] S204, read the ROI and threshold information of a detection region from the template subgraph information;
[0064] S205, cut the corresponding detection region from the image of the part to be detected, and perform denoising, morphological processing and other operations;
[0065] S206, use the read threshold to segment the cut image, and then extract the largest contour as the hole contour of the part to be detected;
[0066] S207, read the detection function and feature parameter information of the detection region from the subgraph information, and obtain the corresponding hole contour image data of the part to be detected;
[0067] S208, for hole cut-through detection, calculate the area s1 of the hole contour of the part to be detected, read the area s0 of the hole contour of the standard part from the template information, compare whether the ratio s1 / s0 and the difference s1-s0 are within the set error threshold range, if yes, the detection passes, otherwise, it does not pass, and is recorded as unqualified;
[0068] S209, for hole diameter detection, using least square method to fit the hole profile of the measured piece as an ellipse, the long axis length a1 and the short axis length b1 of the ellipse are obtained, the long axis length a1 and the short axis length b0 of the standard piece fitting ellipse in the template information are read, the difference between a1 and a0, the difference between b1 and b0 are calculated, and the actual difference value is converted according to the corresponding pixel ratio, and the actual difference value is compared with the preset error threshold value, within the set range, the detection is passed, otherwise it is not passed, and is recorded as unqualified;
[0069] S210, for hole position detection, using least square method to fit the hole profile of the measured piece as an ellipse, the center position c1 of the hole profile of the measured piece is obtained, and the center position c0 of the fitting ellipse of the standard piece in the template information is read, the distance between c1 and c0 is calculated, and the actual distance is converted according to the pixel ratio, and the actual distance is compared with the preset error threshold value, within the set range, the detection is passed, otherwise it is not passed, and is recorded as unqualified;
[0070] S211, for hole profile detection, the center of the hole profile is calculated by image moment, from the center, 0 to 359 degrees every 1 degree is a ray, the shortest distance from the intersection point of each ray and the hole profile to the center point is calculated, the result difference between the hole profile of the measured piece and the read standard hole profile is calculated one by one, and the actual difference value is converted according to the pixel ratio, and the actual difference value is compared with the preset error threshold value, within the set range, the detection is passed, otherwise it is not passed, and is recorded as unqualified;
[0071] S212, repeat S204~S211, until all detection units in the subgraph are processed correspondingly;
[0072] S213, repeat S203~S212, until all subgraphs in the template are processed correspondingly;
[0073] S214, send detection whether pass to PLC, and display on interface, no unqualified record as detection pass, otherwise not pass;
[0074] S215, record the detection result to the database.
[0075] The above examples are only illustrative of the present application and do not constitute a limitation on the scope of protection of the present application, any design identical or similar to the present application belongs to the protection scope of the present application.
Claims
1. An automatic detection method for holes in a part, characterized in that, Includes the following steps: Acquire images of standard parts, extract target regions from the images, perform image thresholding for each target region, extract the contour with the largest area of the target region as the standard part hole contour of that region, and obtain standard part hole contour image data; Under the same conditions, images of the test piece are acquired, and target regions are extracted from the images. Image thresholding is performed on each target region, and the contour with the largest area of the target region is extracted as the hole contour of the test piece. The hole contour image data of the test piece is then obtained. Based on the testing indicators, the error between the corresponding hole contour image data of the test part and the hole contour image data of the standard part is calculated. The error is compared with the set error threshold to determine whether the corresponding test of the hole of the test part is qualified.
2. The automatic hole detection method for parts as described in claim 1, characterized in that: The detection indicators include at least one of hole penetration detection, hole diameter detection, hole position detection, and hole contour detection.
3. The automatic hole detection method for parts as described in claim 2, characterized in that, The specific method for judging the hole penetration test is as follows: calculate the area s1 of the hole contour of the test part and the area s0 of the hole contour of the standard part, compare the ratio s1 / s0 and the difference s1-s0 to see if they are within the set error threshold range. If they are, the test passes; otherwise, it fails.
4. The automatic hole detection method for parts as described in claim 2, characterized in that, The method for determining the hole diameter is as follows: the hole contour of the standard part and the hole contour of the part to be tested are fitted into an ellipse respectively, and the major axis length a1 and minor axis length b1 of the hole contour of the part to be tested and the major axis length a1 and minor axis length b0 of the hole contour of the standard part are obtained. The difference between a1 and a0 and the difference between b1 and b0 are compared to see if they are within the set error threshold range. If they are, the test passes; otherwise, it fails.
5. The automatic hole detection method for parts as described in claim 2, characterized in that, The method for determining the hole position is as follows: the hole contour of the standard part and the hole contour of the part to be tested are respectively fitted into an ellipse to obtain the center position c1 of the ellipse of the hole contour of the part to be tested and the center position c0 of the ellipse of the hole contour of the standard part. The distance between c1 and c0 is compared to see if it is within the set error threshold range. If it is, the detection passes; otherwise, it fails.
6. The automatic hole detection method for parts as described in claim 2, characterized in that, The specific method for judging the hole contour detection is as follows: calculate the center of the hole contour through image moments, and draw a ray every 1 degree from the center to 359 degrees. Calculate the shortest distance from the intersection of each ray and the hole contour to the center point. Calculate the difference between the hole contour of the test part and the hole contour of the standard part one by one. If it is within the set error threshold range, the detection passes; otherwise, it fails.
7. The automatic hole detection method for parts as described in claim 1, characterized in that: It also includes calculating the pixel ratio based on the actual diameter of the holes in the standard parts; Based on the pixel ratio, the difference is converted into an actual deviation; the actual deviation is compared with the set error threshold to determine whether the hole of the part under test is qualified.
8. The automatic hole detection method for parts as described in claim 1, characterized in that, The image thresholding segmentation specifically involves using a 2D image processing algorithm to calculate a recommended threshold and then using that recommended threshold to segment the image.
9. The automatic hole detection method for parts as described in claim 1, characterized in that: Before performing image thresholding on the standard part image and / or the test part image, the method further includes preprocessing the standard part image and / or the test part image; the preprocessing includes denoising and morphological processing.
10. An automatic hole detection device for parts, characterized in that: The device includes a bracket, a light source, an image acquisition device, a programmable logic controller (PLC), and an industrial control computer. The light source and the image acquisition device are both mounted on the bracket. The image acquisition device is used to acquire images of standard parts or parts under test. The PLC is used to control the light source. The industrial control computer is used to receive images and process image data.
Citation Information
Patent Citations
Unmanned intelligent stamping defect identification method
CN111537517A
Spinneret plate special-shaped hole size detection method
CN111681206A
Online plate detection method and system
CN116428981A
Hole slot detection method, system and equipment and storage medium
CN116485747A
Control method of spinneret plate detection equipment and spinneret plate detection equipment
CN117074408A