Position detection method based on inner hole imaging of shaft-type workpieces

Through monocular vision inspection and ambiguity removal method of angle constraints, the time-consuming and labor-intensive manual inspection of shaft and hole parts is solved, efficient and accurate posture detection is achieved, collision between the camera and the workpiece is avoided, and production efficiency is improved.

CN117274213BActive Publication Date: 2025-10-03HUNAN UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311286480.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-07
Publication Date
2025-10-03
Estimated Expiration
2043-10-07

AI Technical Summary

Technical Problem

Traditional surface quality inspection of shaft and hole parts relies on manual inspection, which is time-consuming, labor-intensive, costly, and has a high false detection rate. In particular, during posture inspection, it is easy for the camera lens to collide with the workpiece, affecting production efficiency.

Method used

Monocular vision inspection is combined with an ambiguity removal method based on angle constraints. By collecting the inner hole image of the workpiece, the ellipse parameters and posture parameters are determined, and the grayscale distribution is used to remove the ambiguous interference and avoid collision between the camera and the workpiece.

Benefits of technology

It improves the efficiency of multi-station visual inspection of shaft and hole parts, reduces the false detection rate, avoids collision between the camera and the workpiece during movement, and improves production efficiency and inspection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117274213B_ABST
    Figure CN117274213B_ABST
Patent Text Reader

Abstract

The present invention discloses a posture detection method based on imaging the inner hole of an axial-type workpiece. The method comprises: acquiring an inner hole image of the workpiece and determining the parameters of an ellipse of the inner hole image, wherein the ellipse points to the inner hole of the workpiece; determining two sets of posture parameters for the inner hole of the workpiece based on the ellipse parameters and the radius of the inner hole of the workpiece; determining whether the horizontal distance between the inner hole of the workpiece and a collection unit is no greater than a first distance threshold; if not, determining the true posture parameters from the two sets of posture parameters based on the grayscale mean of the ellipse of the inner hole image at different angles to obtain a posture detection result. This method addresses the problem of removing ambiguous interference when the center of the inner hole of the workpiece is located near the optical axis of the camera by utilizing the grayscale distribution of the workpiece end face. This method fully utilizes image information, reduces the average time consumed for ambiguity removal during posture detection, and avoids collisions between the collection unit and the workpiece during movement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the application field of detection equipment, and in particular to a posture detection method based on imaging of the inner hole of an axial hole workpiece. Background Art

[0002] Traditional surface quality inspection for shaft and hole parts mostly relies on manual sorting with the help of tools, which is time-consuming, labor-intensive, and costly. Furthermore, the results of defect detection are subject to factors such as the experience and subjective intentions of the inspectors, resulting in high rates of missed detections and false detections during surface defect detection. This traditional inspection method severely restricts production efficiency and poses a huge challenge to manufacturing quality control. With the advent of the intelligent manufacturing era, product quality inspection is becoming increasingly automated, hoping to improve production efficiency while reducing costs. In the automated detection of product surface defects, defect detection based on machine vision has the advantages of high detection efficiency, high automation, no need for human intervention, and no reliance on human experience. It is of great significance to improving and ensuring product quality.

[0003] Therefore, visual inspection is increasingly being used for complex shaft-and-hole parts, and specialized visual inspection equipment is being developed. Due to the complex internal and external structures of shaft-and-hole parts and the numerous inspection items, especially slender shaft-and-hole parts, visual inspection at multiple locations is required. Consequently, two common measurement methods exist: the first uses a fixed imaging device while a robotic arm moves the workpiece; the second uses a fixed workpiece position while a robotic arm moves the imaging device. Both methods can cause the relative position of the camera lens and the workpiece to change, requiring necessary position detection and correction.

[0004] Therefore, posture detection has extremely important theoretical significance and engineering value for improving the efficiency of multi-station visual surface defect detection of complex shaft and hole parts, as well as for preventing damage during assembly or inspection and improving production efficiency. Summary of the Invention

[0005] In view of the above problems, the present invention is proposed to provide a posture detection method based on inner hole imaging of axial hole workpieces, which overcomes the above problems or at least partially solves the above problems.

[0006] According to one aspect of the present invention, a posture detection method based on imaging of the inner hole of an axial-hole workpiece is provided, the method comprising: acquiring an inner hole image of the workpiece, and determining ellipse parameters of the inner hole image, wherein the ellipse points to the inner hole of the workpiece; determining two sets of posture parameters of the inner hole of the workpiece based on the ellipse parameters and the radius of the inner hole of the workpiece; judging whether the horizontal distance between the inner hole of the workpiece and the acquisition unit is greater than a first distance threshold; if it is not greater than the first distance threshold, determining the true posture parameters from the two sets of posture parameters based on the grayscale mean of the ellipse of the inner hole image at different angles to obtain a posture detection result.

[0007] Optionally, in the posture detection method based on imaging of the inner hole of an axial-hole workpiece according to the present invention, the ellipse parameters include at least the center point, major semi-axis, minor semi-axis, and inclination angle of the ellipse in the image coordinate system, and the posture parameters include at least the center position of the spatial circle and the normal vector information corresponding to the center; and based on the ellipse parameters and the radius of the inner hole of the workpiece, two sets of posture parameters of the inner hole of the workpiece are determined, including: establishing a rectangular coordinate system with the center of the inner hole image as the origin as the image coordinate system; using the ellipse parameters to construct a first ellipse expression in the image coordinate system; based on the imaging principle of the acquisition unit, converting the first ellipse expression into a second ellipse expression in the acquisition unit coordinate system; based on the second ellipse expression and the radius of the inner hole of the workpiece, obtaining two sets of posture parameters of the spatial circle corresponding to the inner hole of the workpiece in the acquisition unit coordinate system.

[0008] Optionally, in the posture detection method based on the imaging of the inner hole of an axial hole workpiece according to the present invention, whether the horizontal distance between the inner hole of the workpiece and the acquisition unit is greater than a first distance threshold is determined, including: determining the horizontal distance between the inner hole of the workpiece and the acquisition unit based on the distance between the center position of the inner hole image and the center point of the ellipse.

[0009] Optionally, in the posture detection method based on inner hole imaging of axial-hole workpieces according to the present invention, it also includes: if the horizontal distance between the inner hole of the workpiece and the acquisition unit is greater than a first distance threshold, the acquisition unit is horizontally moved along a preset direction by a preset distance to acquire the inner hole image of the workpiece again; using the inner hole images acquired twice, the true posture parameters of the workpiece are determined from the two sets of posture parameters through an ambiguity removal method based on angle constraints to obtain a posture detection result.

[0010] Optionally, in the posture detection method based on the imaging of the inner hole of an axial hole workpiece according to the present invention, the real posture parameters are determined from two sets of posture parameters based on the grayscale mean of the ellipse of the inner hole image at different angles, including: constructing a rectangular coordinate system with the center point of the ellipse of the inner hole image as the origin, and dividing the inner hole image into a first area, a second area, a third area and a fourth area based on the quadrant area of ​​the rectangular coordinate system; respectively counting the first grayscale mean of the first and second areas, the second grayscale mean of the third and fourth areas, the third grayscale mean of the second and third areas, and the fourth grayscale mean of the first and fourth areas; determining the first normal vector based on the size of the first grayscale mean and the second grayscale mean; determining the second normal vector based on the size of the third grayscale mean and the fourth grayscale mean; and determining the real posture parameters from the two sets of posture parameters based on the determined first normal vector and the second normal vector.

[0011] Optionally, in the posture detection method based on inner hole imaging of axial hole workpieces according to the present invention, the first normal vector is determined based on the size of the first grayscale mean and the second grayscale mean, including: if the first grayscale mean is greater than the second grayscale mean, the direction sign of the first normal vector is positive; if the first grayscale mean is not greater than the second grayscale mean, the direction sign of the first normal vector is negative.

[0012] Optionally, in the posture detection method based on inner hole imaging of axial hole workpieces according to the present invention, the second normal vector is determined based on the size of the third grayscale mean and the fourth grayscale mean, including: if the third grayscale mean is greater than the fourth grayscale mean, the direction sign of the second normal vector is positive; if the third grayscale mean is not greater than the fourth grayscale mean, the direction sign of the second normal vector is negative.

[0013] Optionally, in the posture detection method based on the imaging of the inner hole of an axial hole workpiece according to the present invention, the real posture parameters are determined from the two sets of posture parameters based on the determined first normal vector and the second normal vector, including: taking a set of posture parameters in the two sets of posture parameters, in which the direction of the normal vector corresponding to the center of the circle is the same as the direction of the first normal vector and the second normal vector, as the real posture parameters.

[0014] Optionally, in the posture detection method based on imaging of the inner hole of an axial hole workpiece according to the present invention, the sizes of the first grayscale mean and the second grayscale mean, the third grayscale mean and the fourth grayscale mean are judged to determine the true normal vector information of the inner hole of the workpiece in the coordinate system of the acquisition unit, including: if the first grayscale mean is greater than the second grayscale mean, the direction sign of the first normal vector corresponding to the true posture parameter is positive; if the first grayscale mean is not greater than the second grayscale mean, the direction sign of the first normal vector corresponding to the true posture parameter is negative; if the third grayscale mean is greater than the fourth grayscale mean, the direction sign of the second normal vector corresponding to the true posture parameter is positive; if the third grayscale mean is not greater than the fourth grayscale mean, the direction sign of the second normal vector corresponding to the true posture parameter is negative.

[0015] Optionally, in the posture detection method based on inner hole imaging of axial hole workpieces according to the present invention, determining the ellipse parameters of the inner hole image includes: preprocessing the inner hole image, the preprocessing includes image filtering processing, invalid area removal, and image segmentation processing; extracting edge contour information from the preprocessed image to obtain an edge contour point set; based on the edge contour point set, fitting an ellipse of the inner hole image to obtain the ellipse parameters.

[0016] Optionally, in the posture detection method based on inner hole imaging of axial hole workpieces according to the present invention, edge contour information is extracted from the preprocessed image to obtain an edge contour point set, including: extracting edge contour information from the preprocessed image based on a predetermined angle step.

[0017] Optionally, in the posture detection method based on the imaging of the inner hole of an axial hole workpiece according to the present invention, an ellipse of the inner hole image is fitted based on the edge contour point set to obtain the ellipse parameters, including: selecting a predetermined number of contour points from the edge contour point set; judging whether the distance between any two contour points is greater than a second distance threshold; if greater, fitting an initial ellipse based on the selected contour points; randomly selecting a verification contour point from the edge contour point set; judging whether the distance between the verification contour point and the initial ellipse is less than a third distance threshold; if less, determining the target coverage angle values ​​of all target contour points whose distance from the edge contour point set to the initial ellipse is less than the third distance threshold; judging whether the target coverage angle value is greater than the first coverage angle threshold, and if greater than the first coverage angle threshold, obtaining the imaging ellipse parameters based on the initial ellipse.

[0018] Optionally, in the posture detection method based on inner hole imaging of axial hole workpieces according to the present invention, the image segmentation processing includes: using the maximum inter-class variance threshold segmentation method to segment the inner hole image to obtain a high grayscale value area; sorting the grayscale values ​​of the high grayscale value area to determine the median grayscale value; and segmenting the high grayscale value area according to the median grayscale value.

[0019] Optionally, in the posture detection method based on inner hole imaging of axial hole workpieces according to the present invention, the invalid area removal includes: converting the inner hole image into a binary image based on a preset grayscale threshold; using the minimum circumscribed rectangle to treat all areas of the binary image containing pixels as valid areas; treating all areas outside the valid area as invisible areas, and removing the invalid areas.

[0020] Optionally, in the posture detection method based on inner hole imaging of an axial hole workpiece according to the present invention, the predetermined number is 6, the predetermined angle is 0.5°, and the first coverage angle threshold is 288°.

[0021] Optionally, in the posture detection method based on inner hole imaging of axial hole workpieces according to the present invention, before randomly selecting a verification contour point from the edge contour point set, it also includes: judging whether the major and minor axis sizes and the major and minor axis ratios of the initial ellipse meet the conditions for constituting an ellipse.

[0022] According to another aspect of the present invention, a computing device is provided, comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be suitable for execution by the at least one processor, and the program instructions include instructions for executing the above-mentioned alliance chain-based travel card data processing method.

[0023] According to another aspect of the present invention, a readable storage medium storing program instructions is provided. When the program instructions are read and executed by a computing device, the computing device executes the above-mentioned alliance chain-based travel card data processing method.

[0024] According to the present invention, when the center of a workpiece's inner hole is near the camera's optical axis, the grayscale distribution of the workpiece's end face is used to remove ambiguity. This fully utilizes image information, reduces the average time required for ambiguity removal during pose detection, and avoids collisions between the camera and the workpiece during movement.

[0025] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present invention. The same reference symbols are used throughout the drawings to represent the same components. In the drawings:

[0027] Figure 1 A physical diagram of a shaft-hole workpiece according to an embodiment of the present invention is shown;

[0028] Figure 2 A schematic structural diagram of a shaft-hole workpiece according to an embodiment of the present invention is shown;

[0029] Figure 3 A schematic diagram of a workpiece imaging station according to an embodiment of the present invention is shown;

[0030] Figure 4 FIG. 1 shows a schematic diagram of the ambiguity of a circle according to an embodiment of the present invention;

[0031] Figure 5 A flow chart of a method 500 for detecting a position and posture of a workpiece based on imaging of an inner hole of an axial hole according to an embodiment of the present invention is shown;

[0032] Figure 6 A schematic diagram of a collection unit according to an embodiment of the present invention is shown;

[0033] Figure 7 A physical diagram of an inner hole image according to an embodiment of the present invention is shown;

[0034] Figure 8 A flow chart of an ellipse fitting method according to an embodiment of the present invention is shown;

[0035] Figure 9 A schematic diagram of a coordinate system relationship according to an embodiment of the present invention is shown;

[0036] Figure 10 A schematic diagram of a computing device 1000 according to one embodiment of the present invention is shown. DETAILED DESCRIPTION

[0037] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0038] refer to Figure 1 and Figure 2 .in, Figure 1 A physical diagram of a shaft-hole workpiece according to an embodiment of the present invention is shown; Figure 2 The schematic diagram of the structure of a shaft hole workpiece according to an embodiment of the present invention is shown. Since shaft hole parts are slender in shape and complex in structure, the outer surface is mainly composed of cylindrical surfaces of different diameters and external threaded surfaces; the inner surface is mainly composed of stepped holes, stepped surfaces and internal threads. Defects are distributed on the inner and outer surfaces of the parts, so multi-station detection is required (such as Figure 3 As shown in the figure, the imaging device (acquisition unit) is fixed and the measurement method uses a robotic arm to hold the workpiece. Because the robotic arm's position is not consistent each time it holds the part, and long-term vibrations in the industrial field can cause the fasteners in the imaging device to loosen, the workpiece's position during imaging will deviate from the ideal imaging position. Deviations in the imaging position may result in the image not covering complete defect information on the workpiece surface. There is also the possibility of collision between the imaging device and the workpiece, resulting in damage to the imaging device and scratches on the workpiece. Therefore, posture detection and correction during the defect detection process are extremely necessary.

[0039] At present, the posture detection technology based on machine vision is mainly divided into binocular posture detection and monocular posture detection according to the number of cameras (acquisition units). The binocular vision posture detection method requires matching feature points. The quality of the matching result directly affects the accuracy and speed of posture detection, and it takes up a large space and is costly. The monocular vision measurement system has a simple structure, and the calibration and distortion correction technology of the camera is also relatively simple, which greatly simplifies the hardware requirements of the measurement system and the complexity of the posture detection algorithm, and improves the speed of posture recognition. Therefore, this application adopts a monocular to detect posture.

[0040] For example, Figure 3 A schematic diagram of a workpiece imaging station according to an embodiment of the present invention is shown.

[0041] refer to Figure 3 Imaging station one: This imaging station images the outer surface of the workpiece and collects the cylindrical surface and threaded surface of the workpiece. The difficulty of this imaging station is that the clamping mechanism of the robot arm cannot block the workpiece during image acquisition, and this station does not require posture detection.

[0042] Imaging station 2: This imaging station is used to image the small end face of the workpiece and all the outer cylindrical inclined surfaces on the outer surface of the workpiece. The difficulty of this imaging station lies in designing a reasonable imaging position so that the imaging of the outer cylindrical inclined surface can be completed with fewer imaging times and ensure that all the small end faces of the workpiece appear in the image.

[0043] Imaging Station 3: This imaging station images the exterior of the workpiece, capturing images of the single internal thread near the large end, the inner hole wall near the large end face, the large end face, and the stepped surface within the large end hole. The challenge of this imaging station lies in how to illuminate the workpiece's inner surface and reflect it into the camera lens without obstructing the image of the designated area.

[0044] Imaging Station 4: This imaging station images the interior of the workpiece, using a rigid endoscope to image small bores and deep, difficult-to-light areas. During defect detection, the camera is located within the workpiece, imaging small and deep holes. Therefore, the challenge lies in determining the relative position of the camera and the workpiece end face, enabling timely position correction to prevent collisions between the endoscope lens and the workpiece during defect detection, potentially damaging the lens and scratching the workpiece.

[0045] Based on the analysis of the difficulties of each imaging station mentioned above, the difficulty of imaging station one can be solved by supporting the inner wall of the workpiece or clamping different areas of the outer surface of the workpiece for multiple imaging to solve the problem of occlusion of the clamping mechanism during imaging; the difficulty of imaging station two can be solved by multiple imaging to solve the problem caused by unreasonable imaging position design; the difficulty of imaging station three can be solved by multiple imaging for occlusion, and for the problem of lighting method, an effective solution can be found by conducting multiple lighting experiments. The imaging difficulties of the above three stations can all be solved by simply increasing the number of imaging times. However, for imaging station four, it cannot be solved by increasing the number of imaging times. In view of the difficulties existing in imaging station four, it is necessary to detect the relative posture of the camera and the workpiece at this station and perform posture correction.

[0046] Existing pose detection methods can be roughly divided into three categories: model-based pose detection methods, geometric feature-based pose detection methods, and deep learning-based pose detection methods.

[0047] Among them, model-based pose detection methods often need to establish a more comprehensive model database to ensure the accuracy and reliability of model-based pose detection; however, the generation of the database and the search and matching of the model will take up a large amount of storage space and computing time, which will reduce the versatility and efficiency of the model-based pose detection algorithm to a certain extent.

[0048] However, the posture detection method based on deep learning requires training on a large amount of data with posture information, and the amount of data processing is large.

[0049] Geometric feature-based pose detection methods mainly include point feature-based pose detection methods, line feature-based pose detection methods, and circle feature-based pose detection methods. Geometric feature-based pose detection methods do not require the establishment of a workpiece model database like model-based pose detection methods, nor do they require the acquisition of a large amount of data containing target pose information like deep learning-based pose detection methods. Therefore, geometric feature-based pose detection methods are more suitable for this application.

[0050] Geometric feature-based pose detection methods mainly include point feature-based pose detection methods, line feature-based pose detection methods, and circle feature-based pose detection methods. Among them, due to the complex internal and external structures of shaft-hole parts, there are no obvious point and line features, only circle features. Therefore, this application adopts the circle feature-based pose detection method.

[0051] like Figure 4 As shown, Figure 4 A schematic diagram illustrating circle ambiguity according to one embodiment of the present invention is shown. When using circle features for pose detection, the monocular imaging principle dictates that pose calculation using only a single circle feature presents ambiguity. This means that two sets of solutions exist for the circle center position and the circle plane normal, satisfying the same projection constraints. Only by eliminating false pose solutions from the ambiguous solution can the true pose of the workpiece be determined.

[0052] In order to eliminate the false pose solutions in the ambiguous solution, the more mature method at present is to use the motion recovery structure method to reconstruct the spatial constraint angle, and eliminate the ambiguity of the circular pose estimation by the angle constraint that the rigid body motion does not change the spatial angle (that is, the ambiguity removal method based on angle constraint).

[0053] In a specific example, the implementation process and principle of the ambiguity removal method based on angle constraints are explained:

[0054] To eliminate the ambiguity in monocular vision, a robotic arm is used to hold the workpiece and translate it, capturing two images. Since translation does not change the workpiece's attitude angle, the ambiguity is resolved by using the consistency of the attitude angles at the two positions before and after translation.

[0055] Specifically, when the workpiece moves to the initial station, the first inner hole image is taken first, then the robotic arm is controlled to move towards the optical axis of the acquisition unit, and the second inner hole image is taken. It is necessary to ensure that the inner hole of the workpiece appears completely in the image during both photographings, and then the normal vectors passing through the center of the inner hole in the two images are calculated respectively using the elliptical parameter information in the two images.

[0056] Let the two normal vectors calculated using the first image be denoted as n1 and n2, and the two normal vectors calculated using the second image be denoted as n3 and n4. Since it is only a translation and there is no angular change, the true normal vectors of the two images should be parallel, and the magnitude v of the cross product is close to 0. Therefore, the normal vector located near the optical axis of the acquisition unit corresponding to the minimum value of the magnitude after cross product is taken as the true normal vector.

[0057] V1 = |n1 × n3|

[0058] V2 = |n1 × n4|

[0059] V3 = |n2 × n3|

[0060] V4 = |n2 × n4|

[0061] V = argmin(V1, V2, V3, V4)

[0062] V1, V2, V3, and V4 respectively represent the magnitude values of the cross products of the two normal vectors calculated from the first image and the two normal vectors calculated from the second image pairwise.

[0063] Although the above method based on angle constraint can eliminate the ambiguity by moving the workpiece to take two photos, the ambiguity discrimination ability of this method will decrease as the moving distance decreases. When the initial position of the workpiece is already near the camera optical axis and then moves closer to the camera optical axis, due to the过小 moving distance, it may lead to an inability to correctly distinguish the true solution from the false solution. To ensure the correct removal of ambiguity, it is necessary to move away from the camera optical axis direction. After the ambiguity removal is completed, the workpiece still needs to be moved to the camera optical axis, which will bring additional time consumption for subsequent inner hole defect detection.

[0064] To solve the problems existing in the above-mentioned prior art, the solution of the present invention is proposed. An embodiment of the present invention provides a pose detection method based on the inner hole imaging of shaft-hole type workpieces.

[0065] Figure 5 The flowchart of a pose detection method 500 based on the inner hole imaging of shaft-hole type workpieces according to an embodiment of the present invention is shown.

[0066] As Figure 5As shown, method 500 aims to remove ambiguity by using the grayscale distribution of the workpiece end face when the center of the workpiece's inner hole is near the camera's optical axis. This method fully utilizes image information, reduces the average time required for ambiguity removal during pose detection, and avoids collisions between the camera and the workpiece during movement.

[0067] The method 500 begins at step 502 . In step 502 , an inner hole image of a workpiece is acquired, and ellipse parameters of the inner hole image are determined, wherein the ellipse points to the inner hole of the workpiece.

[0068] The present application uses a collection unit to collect the inner hole image of the workpiece. Preferably, the collection unit can be a camera. In order to facilitate the collection of the internal image of the shaft hole, the camera is equipped with a hard endoscope. The camera model can be MV-CE050-30UC, with a resolution of 2592×1944 pixels, and the hard endoscope model is J0200G, with an outer diameter of 4mm. Its structural diagram is shown as follows: Figure 6 shown.

[0069] When the camera collects the inner hole image of the workpiece, the endoscope is inserted into the inner hole of the workpiece to take pictures to collect the above inner hole image.

[0070] Then, the ellipse parameters are obtained from the acquired inner hole image (this is because in the actual acquisition process, the inner hole of the workpiece does not coincide with all planes of the optical axis of the camera, so that the projection of the inner hole of the workpiece on the image plane is an ellipse).

[0071] Specifically, first, the inner hole image is preprocessed, and the preprocessing includes image filtering processing, invalid area removal, and image segmentation processing.

[0072] 1. Image filtering

[0073] The purpose of image filtering is to improve the signal-to-noise ratio of the image and improve the image quality. In some embodiments, mean filtering, median filtering and Gaussian filtering can be used to filter the inner hole image.

[0074] 2. Invalid Area Removal

[0075] Figure 7 Figure 2 shows a real-life image of an inner hole according to an embodiment of the present invention. Figure 7 It can be seen that the valid area of ​​the workpiece image is within a circular area, and the area outside the circular area contains some black useless areas. These useless areas will increase the time consumption of subsequent image processing. Therefore, it is necessary to remove the invalid areas in the image and extract the truly valid areas before image detection.

[0076] Specifically, the inner hole image is converted into a binary image based on a preset grayscale threshold. In this embodiment, a low grayscale value is used as the grayscale threshold, for example, a grayscale threshold of 5. A minimum bounding rectangle is used to define all areas of the binary image containing pixels as the valid region; all areas outside the valid region are defined as the invisible region, and the invalid regions are removed. This embodiment uses a minimum bounding rectangle to extract the region of interest, which not only avoids the influence of interfering contours within the interference circle but also shortens the extraction time.

[0077] 3. Image Segmentation Processing

[0078] It is easy to understand that a grayscale image can be divided into three parts: noise, target area, and background area. Filtering and denoising can reduce or remove noise and separate the target area from the background area.

[0079] This embodiment uses the improved maximum inter-class variance threshold segmentation (K-Means) method to segment the inner hole image of the workpiece. In the traditional K-Means method, K is set to 2 categories, namely the target class and the background class, but the extracted inner hole contour shrinks inward and is too small, making it impossible to accurately segment the inner hole edge contour. Figure 7 It can be seen that the grayscale value of the target area is significantly greater than that of the background area. In order to avoid the background area with high grayscale value being mistakenly divided into the target area, K-Means clustering segmentation is used to divide the image into three categories, that is, K is set to 3, which are the target area, the background area with higher grayscale value and the background area with lower grayscale value.

[0080] Specifically, the maximum inter-class variance threshold segmentation method is used to segment the inner hole image to obtain high grayscale value areas. The grayscale values ​​of the high grayscale value areas are sorted to determine the grayscale median. The high grayscale value areas are segmented based on the grayscale median.

[0081] At this point, the image preprocessing is completed.

[0082] Then, edge contour information is extracted from the preprocessed image to obtain an edge contour point set. Specifically, edge contour information is extracted from the preprocessed image based on a predetermined angle step size. Here, the present invention does not limit the specific value of the predetermined angle. For example, in one embodiment, the predetermined angle can be 0.5°.

[0083] Specifically, the minimum enveloping rectangle is used to envelop it, and the center of this rectangle is used as the center point of the inner hole contour search. The initial search radius R is half the length of the rectangle's diagonal line. The route from R to 0 is traversed at different angles (0° to 360°, with a step size of 0.5°) to see if there are any pixel points with a pixel value of 255. If so, the angle value, pixel position, and distance from the pixel point to the search center are recorded. When the angle has been recorded, the smaller of the two distances is recorded, and the pixel point is updated to the pixel point with the smaller distance. If not, no operation is performed. After completing the search from 0° to 360°, the set of inner hole contour points to be detected can be obtained.

[0084] Finally, based on the edge contour point set, the ellipse of the inner hole image is fitted to obtain the ellipse parameters.

[0085] As mentioned above, when the optical axis of the camera is not perpendicular to the end face of the workpiece, the spatial circle will become an ellipse when projected onto the imaging plane. In order to detect the position of the target spatial circle, the ellipse projected onto the image must first be identified.

[0086] refer to Figure 8 , Figure 8 The flowchart of the ellipse fitting method according to one embodiment of the present invention is shown. The process of fitting the inner hole image ellipse in this application includes the following steps:

[0087] 1. Select a predetermined number of contour points from the edge contour point set. Here, it is necessary to ensure that the predetermined number of contour points are spaced apart from each other. In one embodiment, the predetermined number is greater than 3. Specifically, the predetermined number can be 6.

[0088] 2. Determine whether the distance between any two contour points is greater than a second distance threshold. Here, the second distance threshold is the minimum distance that must be ensured between any two contour points to ensure that there is a certain distance between any two contour points.

[0089] If the distance between any two contour points is greater than the first distance threshold (ensuring the minimum distance between any two contour points), then proceed to step 3. Otherwise, return to step 1: randomly obtain a predetermined number of contour points from the inner hole contour point set again.

[0090] It should be noted that if Figure 8 As shown, each time the process returns to step 1, a new iteration begins, and the number of iterations F is increased by 1. Before executing step 1, it is necessary to determine whether the current number of iterations F is greater than the iteration threshold Tf. If the current number of iterations F is not greater than the iteration threshold Tf (F ≤ Tf), step 1 can be executed again. If the current number of iterations F is greater than the iteration threshold Tf (F > Tf), the ellipse detection process can be terminated.

[0091] 3. Fitting an initial ellipse based on the selected contour points. Here, in one implementation, the least square method can be used to fit the initial ellipse based on a predetermined number of contour points.

[0092] According to one embodiment of the present invention, before executing step 4, it is possible to determine whether the major and minor axis dimensions and ratio of the initial ellipse meet predetermined conditions. If so, step 4 can be continued. Otherwise, the process returns to step 1 (randomly obtaining a predetermined number of contour points from the inner hole contour point set) and begins a new iteration. In this way, by adding constraints on the major and minor axis dimensions and ratio, the subsequent detection process for ellipses that do not meet the required dimensions can be promptly terminated, thereby improving ellipse detection efficiency.

[0093] 4. Randomly select a verification contour point from the edge contour point set.

[0094] 5. Determine whether the distance between the verification contour point and the initial ellipse is less than a third distance threshold. Here, the third distance threshold is used to determine whether the contour point is on the initial ellipse. If the distance between the contour point and the initial ellipse is less than the third distance threshold, then the contour point is determined to be on the initial ellipse.

[0095] In one embodiment, when the predetermined number of contour points is 6 contour points, the next contour point randomly obtained in step 4 is the 7th contour point.

[0096] If the distance between the next contour point and the initial ellipse is less than the third distance threshold (indicating that the next contour point is on the initial ellipse and that the initial ellipse is a real ellipse), proceed to step 6. Otherwise, return to step 1 (randomly obtain a predetermined number of contour points from the inner hole contour point set again) and start a new iteration.

[0097] 6. Determine the target coverage angle value (Value) for all target contour points whose distance from the edge contour point set to the initial ellipse is less than a third distance threshold. Here, the target coverage angle value can be calculated based on the number of target contour points determined. Specifically, the target contour points in the inner hole contour point set whose distance from the initial ellipse is less than the third distance threshold are counted. Subsequently, the target coverage angle values ​​for all target contour points can be calculated based on a predetermined angle step size and the number of target contour points.

[0098] In one embodiment of the present invention, based on the angle information corresponding to each contour point recorded during the process of extracting multiple contour points from the inner hole contour, when determining all target contour points in the inner hole contour point set whose distance to the initial ellipse is less than a second distance threshold, the angle information corresponding to each target contour point can also be obtained. In this way, based on the angle information corresponding to all target contour points, the target coverage angle range (angle) corresponding to all target contour points can be determined, and then the target coverage angle value (Value) can be determined based on the target coverage angle range (angle). For example, if the target coverage angle range corresponding to all target contour points includes 0-60° and 90-120°, the corresponding target coverage angle value is 90°.

[0099] 7. Determine whether the target coverage angle value is greater than a first coverage angle threshold. If it is greater than the first coverage angle threshold (proving that the initial ellipse is a true ellipse), obtain the imaging ellipse parameters based on the initial ellipse (these ellipse parameters are the final ellipse parameters to be output). In other words, here, by determining the parameters of the initial ellipse, the parameters of the initial ellipse are used as the final ellipse parameters and output.

[0100] Otherwise, if the target coverage angle value is less than or equal to the first coverage angle threshold, the process may return to step 1 and start a new iteration.

[0101] In one embodiment, the ellipse parameters include at least the center point, semi-major axis, semi-minor axis, and tilt angle of the ellipse in the image coordinate system. The first coverage angle threshold can be, for example, 288°. However, it should be noted that the present invention does not limit the specific value of the first coverage angle threshold, which can be set by those skilled in the art based on specific application scenarios and actual conditions.

[0102] Taking into account the situation where a large amount of inner hole contour is lost due to a large offset of the workpiece relative to the camera, in this case, the target coverage angle values ​​of all target contour points determined from the inner hole contour point set may not meet the requirement of the first coverage angle threshold (less than or equal to the first coverage angle threshold). To this end, in one embodiment, in each iteration process, after counting the number of target contour points in the inner hole contour point set whose distance to the initial ellipse is less than the second distance threshold, the ellipse parameters of the initial ellipse with the largest number of target contour points can be saved simultaneously (from the first iteration to the local iteration process). In this way, when the number of iterations F is greater than the iteration number threshold Tf (F>Tf), the ellipse parameters of the saved initial ellipse can be output, and then the ellipse detection process ends.

[0103] It is worth noting that the present invention actually performs ellipse detection on the inner hole contour point set of the workpiece. There are gaps between the contour points in the contour point set and they are not continuous. If 3 contour points are selected, it cannot be guaranteed that the minimum number of points for ellipse fitting is reached, so the predetermined number selected is 6. In addition, in order to ensure that the initial ellipse fitted is a real ellipse, the present invention adds a variety of judgment conditions so as to promptly terminate the subsequent detection process of the wrong ellipse. In addition, considering that the inner hole contour point set of the present invention is obtained based on a predetermined angle step size and is not continuous in the image, it is not suitable to use the ratio of the number of fitting points to the circumference of the fitted ellipse as the threshold for correctly detecting the ellipse. In this regard, the present invention sets a first coverage angle threshold as the threshold of the target coverage angle value of all target contour points as a condition for judging whether the initial ellipse is a real ellipse.

[0104] After obtaining the ellipse parameters, the process proceeds to step 504 , in which two sets of posture parameters of the workpiece inner hole are determined based on the ellipse parameters and the radius of the workpiece inner hole.

[0105] Specifically, first, a rectangular coordinate system is established with the center of the inner hole image as the origin, which serves as the image coordinate system (image physical coordinate system).

[0106] Machine vision measurement systems usually involve image pixel coordinate system, image physical coordinate system, camera coordinate system and world coordinate system. The conversion relationship (a) and relative position relationship (b) between these four coordinate systems are as follows: Figure 9 shown.

[0107] Figure 9 In the figure, the coordinate relationship between the point p in the world coordinate system and the projection in the image pixel coordinate system is as follows:

[0108]

[0109] in, f represents the focal length of the camera lens, dx and dy represent the physical dimensions of a single pixel in the x- and y-axis directions, respectively, in the image's physical coordinate system. u0 and v0 are the intersections of the camera's optical axis and the image pixel coordinate system, and R and T are the camera's extrinsic parameters.

[0110] Then, the first ellipse expression is constructed in the image coordinate system using the ellipse parameters.

[0111] ax 2 +by 2 +cxy+dx+ey+f=0

[0112] Afterwards, based on the imaging principle of the acquisition unit, the first ellipse expression is converted into a second ellipse expression in the acquisition unit coordinate system.

[0113] Specifically, Substitute the first ellipse expression above to obtain the second ellipse expression:

[0114] AX 2 +BY 2 +CXY+DXZ+EYZ+FZ 2 =0

[0115] Finally, based on the second ellipse expression and the radius of the inner hole of the workpiece, two sets of posture parameters of the space circle corresponding to the inner hole of the workpiece in the coordinate system of the acquisition unit are obtained.

[0116] Rewrite the above second ellipse expression into matrix form:

[0117]

[0118] make Q is a real symmetric matrix and can be rewritten as:

[0119] [XYZ]Q[XYZ] T =0

[0120] Since Q is a real symmetric matrix, there must exist:

[0121] P T QP=diag(λ1,λ2,λ3)

[0122] Where λ1, λ2, and λ3 are the eigenvalues ​​of Q, and P is an orthogonal matrix. P is the rotation matrix that transforms from the standard elliptical cone coordinates to the camera coordinate system. Suppose the point in the camera coordinate system is (X, Y, Z) and the corresponding point coordinates in the standard elliptical cone coordinate system are [X′, Y′, Z′]. The corresponding relationship between these two points is as follows:

[0123] [XYZ] T =P[X′, Y′, Z′] T

[0124] P T QP=diag(λ1,λ2,λ3) and [XYZ] T =P[X′, Y′, Z′]T fusion, we get:

[0125] λ1X′ 2 +λ2Y′ 2 +λ3Z′ 2 =0

[0126] When the radius R of the inner hole of the workpiece is known, the coordinates of the two possible circle centers in the standard elliptical cone coordinate system can be obtained.

[0127]

[0128]

[0129] The normal vectors corresponding to the two circle center positions are:

[0130]

[0131]

[0132] The center position of the circle and the corresponding normal vector information in the camera coordinate system are as follows:

[0133] [X1, Y1, Z1] T =P[X1′, Y1′, Z1′] T

[0134] [X2, Y2, Z2] T =P[X2′, Y2′, Z2′] T

[0135] [N 1X , N 1Y , N 1Z ]=P[N 1X′ , N 1Y′ , N 1Z′ ]

[0136] [N 2X , N 2Y , N 2Z ]=P[N 2X , N 2Y′ , N 2Z′ ]

[0137] At this point, two sets of pose parameters of the workpiece inner hole are obtained, namely the center position of the space circle (the workpiece inner hole) and the normal vector information corresponding to the center.

[0138] Then, in step 506, it is determined whether the horizontal distance between the inner hole of the workpiece and the acquisition unit is greater than a first distance threshold. Here, the first distance threshold can be set by the staff according to actual conditions. For example, it can be set based on the difference between the diameter of the inner hole of the workpiece and the diameter of the endoscope. The larger the difference, the larger the first distance threshold can be set.

[0139] Specifically, the horizontal distance between the inner hole of the workpiece and the acquisition unit is determined according to the distance between the center position of the inner hole image and the center point of the ellipse.

[0140] In a specific example, a method for obtaining the horizontal distance between the inner hole of the workpiece and the acquisition unit is shown:

[0141] First, in the inner hole image, mark the center position of the inner hole image and the center point of the ellipse.

[0142] Then, the horizontal distance between the inner hole of the workpiece and the acquisition unit is determined based on the number of pixels between the center position and the center point of the ellipse.

[0143] If the horizontal distance between the inner hole of the workpiece and the acquisition unit is not greater than the first distance threshold, the process proceeds to step 508 , where the true pose parameters are determined from the two sets of pose parameters based on the grayscale mean of the ellipse of the inner hole image at different angles to obtain a pose detection result.

[0144] Specifically, first, a rectangular coordinate system is constructed with the center point of the ellipse of the inner hole image as the origin, and the inner hole image is divided into a first area, a second area, a third area and a fourth area based on the quadrant areas of the rectangular coordinate system.

[0145] Then, the first grayscale mean of the first and second regions, the second grayscale mean of the third and fourth regions, the third grayscale mean of the second and third regions, and the fourth grayscale mean of the first and fourth regions are counted respectively.

[0146] Then, a first normal vector is determined based on the first grayscale mean and the second grayscale mean. Specifically, if the first grayscale mean is greater than the second grayscale mean, the direction sign of the first normal vector is positive; if the first grayscale mean is not greater than the second grayscale mean, the direction sign of the first normal vector is negative.

[0147] Subsequently, based on the third grayscale mean and the fourth grayscale mean, the second normal vector is determined. Specifically, if the third grayscale mean is greater than the fourth grayscale mean, the direction sign of the second normal vector is positive; if the third grayscale mean is not greater than the fourth grayscale mean, the direction sign of the second normal vector is negative.

[0148] Finally, based on the determined first normal vector and second normal vector, the true pose parameters are determined from the two sets of pose parameters. Specifically, the set of pose parameters in which the normal vector corresponding to the center of the circle has the same direction as the first normal vector and the second normal vector is used as the true pose parameter. In a specific example, the corresponding relationship between the pose normal vector and the grayscale distribution is as follows:

[0149] In the rectangular coordinate system, when the grayscale mean corresponding to 0°~180° is greater than the grayscale mean corresponding to 180°~360°, the normal vector y in the true pose parameter is positive;

[0150] When the grayscale mean corresponding to 180° to 360° is greater than the grayscale mean corresponding to 0° to 180°, the normal vector y in the true pose parameter is positive;

[0151] When the grayscale mean corresponding to 90°~270° is greater than the grayscale mean corresponding to 270°~90°, the normal vector x in the true pose parameter is positive;

[0152] When the grayscale mean corresponding to 270°~90° is greater than the grayscale mean corresponding to 90°~270°, the normal vector x in the true pose parameter is positive.

[0153] The correspondence between the pose normal vector and the grayscale distribution can be used to determine the true pose parameters of the workpiece from the two sets of pose parameters, thereby determining the true pose of the workpiece.

[0154] In addition, if the horizontal distance between the inner hole of the workpiece and the acquisition unit is greater than a first distance threshold, the acquisition unit is horizontally moved a preset distance in a preset direction to reacquire an inner hole image of the workpiece. Using the two acquired inner hole images, an ambiguity removal method based on angle constraints is used to determine the true pose parameters of the workpiece and obtain a pose detection result. In other words, when the horizontal distance between the inner hole of the workpiece and the acquisition unit is too large, a traditional ambiguity removal method based on angle constraints can be directly used to determine the true pose of the workpiece. The specific description of the ambiguity removal method based on angle constraints can be referred to the above description and will not be repeated in this application.

[0155] The method provided by this invention addresses the problem of removing ambiguous interference by using the grayscale distribution of the workpiece end face when the center of the workpiece's inner hole is located near the camera's optical axis. This method fully utilizes image information, reduces the average time required for removing ambiguity during pose detection, and avoids collisions between the camera and the workpiece during movement.

[0156] In some embodiments, the above method 500 may be implemented by a computing device. Figure 10 A schematic diagram of a computing device 1000 according to one embodiment of the present invention is shown.

[0157] like Figure 10 As shown, in a basic configuration 1002, computing device 1000 typically includes a system memory 1006 and one or more processors 1004. A memory bus 1008 may be used for communication between processor 1004 and system memory 1006.

[0158] Depending on the desired configuration, processor 1004 can be any type of processor, including but not limited to a microprocessor (μP), a microcontroller (μC), a digital signal processor (DSP), or any combination thereof. Processor 1004 can include one or more levels of cache, such as a level 1 cache 1010 and a level 2 cache 1012, a processor core 1014, and registers 1016. An example processor core 1014 can include an arithmetic logic unit (ALU), a floating point unit (FPU), a digital signal processing core (DSP core), or any combination thereof. An example memory controller 1018 can be used with processor 1004, or in some implementations, memory controller 1018 can be an internal part of processor 1004.

[0159] Depending on the desired configuration, system memory 1006 can be any type of memory, including but not limited to volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. Physical memory in a computing device typically refers to volatile RAM. Data stored on a disk must be loaded into physical memory before it can be read by processor 1004. System memory 1006 may include an operating system 1020, one or more applications 1022, and program data 1024. Applications 1022 are essentially multiple program instructions that instruct processor 1004 to perform corresponding operations. In some embodiments, applications 1022 can be arranged so that one or more processors 1004 execute instructions on the operating system using program data 1024. Operating system 1020, for example, may be Linux, Windows, etc., and includes program instructions for handling basic system services and performing hardware-dependent tasks. Applications 1022 include program instructions for implementing various user-desired functions. Applications 1022 may be, for example, browsers, instant messaging software, software development tools (such as integrated development environments (IDEs), compilers, etc.), but are not limited thereto. When the application 1022 is installed into the computing device 1000 , a driver module may be added to the operating system 1020 .

[0160] When computing device 1000 is started, processor 1004 reads and executes program instructions from operating system 1020 from memory 1006. Applications 1022 run on operating system 1020, utilizing interfaces provided by operating system 1020 and the underlying hardware to implement various user-desired functions. When a user launches application 1022, application 1022 is loaded into memory 1006, and processor 1004 reads and executes the program instructions from memory 1006.

[0161] The computing device 1000 also includes a storage device 1032 , which includes a removable storage 1036 and a non-removable storage 1038 , both of which are connected to a storage interface bus 1034 .

[0162] The computing device 1000 may also include an interface bus 1040 that facilitates communication from various interface devices (e.g., output devices 1042, peripheral interfaces 1044, and communication devices 1046) to the basic configuration 1002 via the bus / interface controller 1030. Example output devices 1042 include a graphics processing unit 1048 and an audio processing unit 1050. These can be configured to facilitate communication with various external devices such as a display or speakers via one or more A / V ports 1052. Example peripheral interfaces 1044 may include a serial interface controller 1054 and a parallel interface controller 1056, which can be configured to facilitate communication with external devices such as input devices (e.g., a keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printers, scanners, etc.) via one or more I / O ports 1058. Example communication devices 1046 may include a network controller 1060 , which may be arranged to facilitate communications with one or more other computing devices 1062 via one or more communication ports 1064 over a network communication link.

[0163] A network communication link can be an example of a communication medium. Communication media can generally be embodied as computer-readable instructions, data structures, program modules in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium. A "modulated data signal" can be a signal in which one or more of its data sets or changes thereto can be performed in a manner that encodes information in the signal. As non-limiting examples, communication media can include wired media such as a wired network or a dedicated line network, and various wireless media such as sound, radio frequency (RF), microwave, infrared (IR) or other wireless media. The term computer-readable medium as used herein can include both storage media and communication media.

[0164] The computing device 1000 also includes a storage interface bus 1034 connected to the bus / interface controller 1030. The storage interface bus 1034 is connected to a storage device 1032, which is suitable for storing data. Example storage devices 1032 may include removable storage 1036 (e.g., CD, DVD, USB flash drive, removable hard disk, etc.) and non-removable storage 1038 (e.g., hard disk drive HDD, etc.).

[0165] The various techniques described herein may be implemented in conjunction with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions of the methods and apparatus of the present invention, may be implemented in the form of program codes (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, a USB flash drive, a floppy disk, a CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes an apparatus for practicing the present invention.

[0166] A9. The method as described in A1, wherein determining the ellipse parameters of the inner hole image includes: preprocessing the inner hole image, wherein the preprocessing includes image filtering, invalid region removal, and image segmentation; extracting edge contour information from the preprocessed image to obtain an edge contour point set; and fitting an ellipse of the inner hole image based on the edge contour point set to obtain the ellipse parameters. A10. The method as described in A9, wherein extracting edge contour information from the preprocessed image to obtain an edge contour point set includes: extracting edge contour information from the preprocessed image based on a predetermined angle step size. A11. A method as described in A9, wherein an ellipse of the inner hole image is fitted based on the edge contour point set to obtain the ellipse parameters, including: selecting a predetermined number of contour points from the edge contour point set; determining whether the distance between any two contour points is greater than a second distance threshold; if greater than, fitting an initial ellipse based on the selected contour points; randomly selecting a verification contour point from the edge contour point set; determining whether the distance between the verification contour point and the initial ellipse is less than a third distance threshold; if less than, determining the target coverage angle values ​​of all target contour points from the edge contour point set whose distance to the initial ellipse is less than the third distance threshold; determining whether the target coverage angle value is greater than a first coverage angle threshold, and if greater than the first coverage angle threshold, obtaining imaging ellipse parameters based on the initial ellipse. A12. The method as described in A9, wherein the image segmentation processing includes: segmenting the inner hole image using the maximum inter-class variance threshold segmentation method to obtain high grayscale value regions; sorting the grayscale values ​​of the high grayscale value regions to determine the median grayscale value; and segmenting the high grayscale value regions based on the median grayscale value. A13. The method as described in A9, wherein the invalid area removal includes: converting the inner hole image into a binary image based on a preset grayscale threshold; using a minimum bounding rectangle to define all areas of the binary image containing pixels as valid areas; defining all areas outside the valid areas as invisible areas, and removing the invalid areas. A14. The method as described in A11, wherein the predetermined number is 6, the predetermined angle is 0.5°, and the first coverage angle threshold is 288°. A15. The method as described in A9, wherein, before randomly selecting a verification contour point from the set of edge contour points, the method further includes: determining whether the major and minor axis dimensions and the major and minor axis ratio of the initial ellipse meet the conditions for forming an ellipse.

[0167] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of this description.

Claims

1. A posture detection method based on internal hole imaging of an axial hole workpiece, the method comprising: Acquiring an inner hole image of the workpiece and determining ellipse parameters of the inner hole image, wherein the ellipse points to the inner hole of the workpiece; Determining two sets of posture parameters of the inner hole of the workpiece based on the ellipse parameters and the radius of the inner hole of the workpiece; Determining whether the horizontal distance between the inner hole of the workpiece and the acquisition unit is greater than a first distance threshold; If it is not greater than the first distance threshold, the true posture parameters are determined from the two groups of posture parameters based on the grayscale mean of the ellipse of the inner hole image at different angles to obtain a posture detection result, including: constructing a rectangular coordinate system with the center point of the ellipse of the inner hole image as the origin, and dividing the inner hole image into a first area, a second area, a third area and a fourth area based on the quadrant area of ​​the rectangular coordinate system, respectively counting the first grayscale mean of the first area and the second area, the second grayscale mean of the third area and the fourth area, the third grayscale mean of the second area and the third area, and the fourth grayscale mean of the first area and the fourth area; determining a first normal vector based on the size of the first grayscale mean and the second grayscale mean; determining a second normal vector based on the size of the third grayscale mean and the fourth grayscale mean; and determining the true posture parameters from the two groups of posture parameters based on the determined first normal vector and the second normal vector.

2. The method according to claim 1, wherein The ellipse parameters include at least the center point, major semi-axis, minor semi-axis, and tilt angle of the ellipse in the image coordinate system, and the pose parameters include at least the center position of the space circle and the normal vector information corresponding to the center; as well as Based on the ellipse parameters and the radius of the workpiece inner hole, two sets of posture parameters of the workpiece inner hole are determined, including: Establishing a rectangular coordinate system with the center of the inner hole image as the origin as the image coordinate system; Constructing a first ellipse expression in the image coordinate system using the ellipse parameters; Based on the imaging principle of the acquisition unit, converting the first ellipse expression into a second ellipse expression in the acquisition unit coordinate system; Based on the second ellipse expression and the radius of the inner hole of the workpiece, two sets of posture parameters of the space circle corresponding to the inner hole of the workpiece in the coordinate system of the acquisition unit are obtained.

3. The method according to claim 2, wherein: Determining whether the horizontal distance between the inner hole of the workpiece and the acquisition unit is greater than a first distance threshold includes: The horizontal distance between the inner hole of the workpiece and the acquisition unit is determined according to the distance between the center position of the inner hole image and the center point of the ellipse.

4. The method according to claim 1, wherein Also includes: If the horizontal distance between the inner hole of the workpiece and the acquisition unit is greater than a first distance threshold, the acquisition unit is horizontally moved along a preset direction by a preset distance and the inner hole image of the workpiece is acquired again; By using the inner hole images collected twice and an ambiguity removal method based on angle constraints, the true posture parameters of the workpiece are determined from the two sets of posture parameters to obtain a posture detection result.

5. The method according to claim 1, wherein Determining a first normal vector based on the first grayscale mean and the second grayscale mean includes: If the first grayscale mean is greater than the second grayscale mean, the direction sign of the first normal vector is positive; If the first grayscale mean is not greater than the second grayscale mean, the direction sign of the first normal vector is negative.

6. The method according to claim 5, wherein: Determining a second normal vector based on the third grayscale mean and the fourth grayscale mean includes: If the third grayscale mean is greater than the fourth grayscale mean, the direction sign of the second normal vector is positive; If the third grayscale mean is not greater than the fourth grayscale mean, the direction sign of the second normal vector is negative.

7. The method according to claim 6, wherein: Determining true pose parameters from the two sets of pose parameters based on the determined first normal vector and second normal vector includes: Among the two sets of pose parameters, a set of pose parameters in which the normal vector direction corresponding to the circle center is the same as the first normal vector and the second normal vector is used as the true pose parameter.

8. The method of claim 1, wherein: Determining ellipse parameters of the inner hole image includes: Preprocessing the inner hole image, wherein the preprocessing includes image filtering, invalid area removal, and image segmentation; Extract edge contour information from the preprocessed image to obtain an edge contour point set; Based on the edge contour point set, an ellipse of the inner hole image is fitted to obtain the ellipse parameters.

9. The method of claim 8, wherein: Extract edge contour information from the preprocessed image to obtain an edge contour point set, including: Based on a predetermined angle step, edge contour information is extracted from the preprocessed image.

10. The method of claim 8, wherein: Fitting an ellipse of the inner hole image based on the edge contour point set to obtain the ellipse parameters includes: Selecting a predetermined number of contour points from the edge contour point set; Determine whether the distance between any two contour points is greater than a second distance threshold; If it is greater than, an initial ellipse is fitted based on the selected contour points; Randomly select a verification contour point from the edge contour point set; Determining whether the distance between the verification contour point and the initial ellipse is less than a third distance threshold; If it is less than, determining the target coverage angle values ​​of all target contour points whose distance from the edge contour points to the initial ellipse is less than a third distance threshold; It is determined whether the target coverage angle value is greater than a first coverage angle threshold; if so, imaging ellipse parameters are obtained according to the initial ellipse.

11. The method of claim 8, wherein: The image segmentation process includes: The inner hole image is segmented using the maximum inter-class variance threshold segmentation method to obtain a high gray value area; The grayscale values ​​of the high grayscale value area are sorted to determine a grayscale value median; and the high grayscale value area is segmented according to the grayscale value median.

12. The method of claim 8, wherein: The invalid area removal includes: Converting the inner hole image into a binary image based on a preset grayscale threshold; Using a minimum bounding rectangle, all areas of the binary image containing pixels are taken as valid areas; All areas outside the valid area are regarded as invisible areas, and the invalid area is eliminated.

13. The method of claim 10, wherein: The predetermined number is 6, the predetermined angle is 0.5°, and the first coverage angle threshold is 288°.

14. The method of claim 10, wherein: Before randomly selecting a verification contour point from the edge contour point set, the method further includes: It is determined whether the major and minor axis sizes and the major and minor axis ratios of the initial ellipse meet the conditions for forming an ellipse.

15. A computing device comprising: at least one processor; as well as A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the method according to any one of claims 1 to 14.

16. A readable storage medium storing program instructions, wherein when the program instructions are read and executed by a computing device, the computing device is caused to execute the method according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Ellipse detection method for inner hole contour of workpiece, computing equipment and storage medium

    CN116630266A