Elliptical detection method for inner hole profile of workpiece, computing device and storage medium
By obtaining a set of contour points on the inner hole image and combining it with an improved segmentation method, the problems of misjudgment and low accuracy in the inner hole contour detection of complex shaft hole parts are solved, and efficient and accurate ellipse detection and pose correction are achieved.
Patent Information
- Application Number
- CN202310587590.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-23
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2043-05-23
AI Technical Summary
Existing ellipse detection methods suffer from misjudgment and low accuracy in detecting the inner hole contour of complex shaft and hole parts, especially when there is a large deviation between the camera and the workpiece pose, which leads to the loss of inner hole edge information during image segmentation processing.
The method acquires a set of contour points from the inner hole image based on a predetermined angle step size, fits the initial ellipse through multiple judgment conditions, including distance threshold and coverage angle threshold, and combines an improved maximum inter-class variance threshold segmentation method to improve image segmentation accuracy and ellipse detection efficiency.
It improves the accuracy and efficiency of elliptical detection of the inner hole contour of shaft and hole parts, avoids misjudgment and loss of image information, and ensures the accuracy of pose correction.
Smart Images

Figure CN116630266B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect detection technology, and in particular to a method, computing device and storage medium for detecting the ellipticity of the inner hole contour of a workpiece. Background Technology
[0002] Cylindrical shaft and hole parts are widely used in equipment across various industries, such as docking rings in the aerospace field, fuel injectors in automotive engines, gear shafts, flanges for connection, and couplings. Shaft and hole parts typically have complex structures and complex manufacturing processes, requiring high standards for geometric tolerances, surface roughness, and surface quality. They are primarily used in assembly and docking applications. Common surface defects in shaft and hole parts include: dents on the workpiece end face, vibration marks and scratches on the inner and outer cylindrical surfaces, and damaged threads on the threaded surface. These surface defects not only affect the performance and lifespan of the parts themselves but also the accuracy of assembly or docking, thus reducing the stability and reliability of the equipment. Therefore, surface defect detection of the inner and outer surfaces of shaft and hole parts is of paramount importance for ensuring the performance of the parts during use, reducing the probability of accidents during equipment operation, and ensuring the safe and reliable operation of the equipment.
[0003] With the advent of the era of intelligent manufacturing, an increasing number of complex shaft and hole parts are being inspected using visual inspection methods, employing specialized visual inspection equipment for defect detection. Due to the complex internal and external structures of shaft and hole parts, and the numerous inspection items, especially for slender shaft and hole parts, multi-station visual inspection is required. Common measurement methods include two types: the first is a fixed imaging device with a robotic arm holding and moving the workpiece; the second is a fixed workpiece position with a robotic arm driving the imaging device. Both methods can lead to changes in the relative pose between the camera lens and the workpiece; therefore, necessary pose detection and correction are required. Pose detection is of paramount theoretical and engineering value in improving the efficiency of multi-station visual surface defect detection for complex shaft and hole parts, preventing damage during assembly or inspection, and improving production efficiency.
[0004] For complex cylindrical shaft and hole parts, a vision inspection device needs to be developed to automate the inspection of defects on the inner and outer surfaces. These parts are slender and structurally complex, with the outer surface primarily composed of cylindrical surfaces of varying diameters and external threads, while the inner surface mainly consists of stepped holes, stepped surfaces, and internal threads. Since defects may be distributed across both the inner and outer surfaces, multi-station inspection is required, employing a measurement method where an imaging device is fixed while a robotic arm holds and moves the workpiece. Because the robotic arm's gripping posture is not consistent each time, and long-term vibrations in industrial environments can cause fasteners in the imaging device to loosen, the workpiece's posture during imaging may deviate from the ideal imaging posture. This deviation may result in the image not fully capturing defect information on the workpiece surface, and may also lead to collisions between the imaging device and the workpiece, causing damage to the imaging device and scratches on the workpiece.
[0005] It is evident that pose detection and correction are essential in the defect detection of shaft and hole parts, and are one of the key technologies in the development of vision inspection equipment. Regarding the issue of deviation between the actual and ideal imaging poses during the internal and external surface defect detection of round shaft and hole parts, how to detect the pose between the round shaft and hole part and the camera based on endoscopic imaging is of significant engineering importance for the safe production and reliable pose detection of shaft and hole parts.
[0006] It should be noted that for shaft and hole type parts, the workpiece is generally held by a robotic arm, which is then controlled to move the workpiece to a designated imaging position for imaging. Endoscopic images of shaft and hole type parts do not have obvious point or line features, only circular features; therefore, a pose detection method based on circular features is required.
[0007] When the camera's optical axis is not perpendicular to the workpiece's end face, the spatial circle projected onto the imaging plane will become an ellipse. To detect the pose of the target spatial circle, it is necessary to first identify the ellipse projected onto the imaging plane. Therefore, one of the key technologies for pose detection based on circular features lies in ellipse detection. According to existing ellipse detection schemes, during image segmentation, high-grayscale background areas near the inner hole edge contour are misidentified as target areas. In addition, due to the large relative pose deviation between the camera and the workpiece, some inner hole contours are not obvious, resulting in the loss of some inner hole edge information during image segmentation, thus leading to low ellipse detection accuracy.
[0008] Therefore, an ellipse detection method is needed to solve the problems existing in the above-mentioned technical solutions. Summary of the Invention
[0009] Therefore, the present invention provides a method for detecting the ellipse of the inner hole contour of a workpiece, in order to solve or at least alleviate the problems mentioned above.
[0010] According to one aspect of the present invention, a method for ellipse detection of the inner hole contour of a workpiece is provided, executed in a computing device, comprising: acquiring a set of inner hole contour points from an image of the inner hole of the workpiece based on a predetermined angular step size; randomly acquiring a predetermined number of contour points from the set of inner hole contour points, wherein the predetermined number is greater than 3; determining whether the distance between any two contour points among the predetermined number of contour points is greater than a first distance threshold; if it is greater than the first distance threshold, fitting an initial ellipse based on the predetermined number of contour points; randomly acquiring the next contour point from the set of inner hole contour points, and determining whether the distance from the next contour point to the initial ellipse is less than a second distance threshold; if it is less than the second distance threshold, determining the target coverage angle values of all target contour points in the set of inner hole contour points whose distance to the initial ellipse is less than the second distance threshold; determining whether the target coverage angle values are greater than a first coverage angle threshold, and if they are greater than the first coverage angle threshold, obtaining ellipse parameters based on the initial ellipse.
[0011] Optionally, in the ellipse detection method for the inner hole profile of a workpiece according to the present invention, before obtaining the set of inner hole profile points from the inner hole image of the workpiece based on a predetermined angular step size, the method further includes: obtaining an inner hole image of the workpiece acquired by a camera along the optical axis direction, so as to determine the pose of the workpiece relative to the camera according to the final ellipse parameters.
[0012] Optionally, in the ellipse detection method for the inner hole contour of the workpiece according to the present invention, randomly obtaining the next contour point from the set of inner hole contour points includes: determining whether the major and minor axis dimensions and the ratio of the major and minor axes of the initial ellipse meet predetermined conditions; if the predetermined conditions are met, then randomly obtaining the next contour point from the set of inner hole contour points.
[0013] Optionally, in the ellipse detection method for the inner hole contour of a workpiece according to the present invention, obtaining a set of inner hole contour points from the inner hole image of the workpiece based on a predetermined angular step size includes: segmenting the inner hole image using a maximum inter-class variance thresholding method to obtain a high grayscale region; sorting the grayscale values of the high grayscale region by size and obtaining the median grayscale value; segmenting the high grayscale region according to the median grayscale value to extract the inner hole contour; and extracting multiple contour points from the inner hole contour based on the predetermined angular step size to obtain a set of inner hole contour points.
[0014] Optionally, in the ellipse detection method for the inner hole contour of a workpiece according to the present invention, determining the target coverage angle value of all target contour points in the inner hole contour point set whose distance to the initial ellipse is less than a second distance threshold includes: 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; and determining the target coverage angle value of all target contour points according to the predetermined angle step size and the number of target contour points.
[0015] Optionally, in the ellipse detection method for the inner hole contour of the workpiece according to the present invention, after counting the number of target contour points in the inner hole contour point set whose distance to the initial ellipse is less than a second distance threshold, the method further includes: saving the ellipse parameters of the initial ellipse with the largest number of target contour points.
[0016] Optionally, in the ellipse detection method for the inner hole profile of a workpiece according to the present invention, the predetermined number is 6.
[0017] Optionally, in the ellipse detection method for the inner hole profile of a workpiece according to the present invention, the predetermined angle is 0.5°.
[0018] Optionally, in the ellipse detection method for the inner hole profile of a workpiece according to the present invention, the first coverage angle threshold is 288°.
[0019] Optionally, in the ellipse detection method for the inner hole profile of a workpiece according to the present invention, the workpiece is a shaft-hole type part.
[0020] According to one 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 executed by the at least one processor, the program instructions including instructions for performing an ellipse detection method for the inner hole profile of a workpiece as described above.
[0021] According to one aspect of the present invention, a readable storage medium storing program instructions is provided, which, when read and executed by a computing device, causes the computing device to perform the ellipse detection method for the inner hole profile of a workpiece as described above.
[0022] According to the technical solution of the present invention, an ellipse detection method for the inner hole contour of a workpiece is provided. The method involves obtaining a set of inner hole contour points from an image of the workpiece based on a predetermined angular step size; randomly selecting a predetermined number of contour points from the set; determining whether the distance between any two contour points is greater than a first distance threshold; if it is greater than the first distance threshold, fitting an initial ellipse based on the predetermined number of contour points. Next, randomly selecting the next contour point from the set, and determining whether the distance from the next contour point to the initial ellipse is less than a second distance threshold; if it is less than the second distance threshold, determining the target coverage angle values of all target contour points in the set whose distance to the initial ellipse is less than the second distance threshold, and determining whether the target coverage angle values are greater than a first coverage angle threshold; if they are greater than the first coverage angle threshold, obtaining ellipse parameters based on the initial ellipse. Thus, according to the technical solution of the present invention, the existing ellipse detection algorithm is improved by adding multiple judgment conditions, which can promptly stop the subsequent detection process for erroneous ellipses, thereby improving the efficiency of ellipse detection for the inner hole contour of shaft-hole type workpieces.
[0023] Furthermore, this invention utilizes the maximum inter-class variance thresholding method. First, the internal hole image is segmented to obtain high grayscale regions. Then, the grayscale values of these high grayscale regions are sorted by size to obtain the median grayscale value. Finally, the high grayscale regions are segmented based on this median grayscale value to extract the internal hole contour. Thus, according to the improved maximum inter-class variance thresholding method of this invention, the segmentation accuracy of the internal hole image and the accuracy of the extracted internal hole contour are improved, thereby further enhancing the ellipse detection accuracy of the internal hole contour of shaft-hole workpieces.
[0024] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0025] To achieve the foregoing and related objectives, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings. These aspects indicate various ways in which the principles disclosed herein may be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. The foregoing and other objectives, features, and advantages of this disclosure will become more apparent from the following detailed description, taken in conjunction with the accompanying drawings. Throughout this disclosure, the same reference numerals generally refer to the same parts or elements.
[0026] Figure 1 A schematic diagram of a computing device 100 according to an embodiment of the present invention is shown;
[0027] Figure 2 A schematic diagram of a method 200 for detecting the ellipse of the inner hole profile of a workpiece according to an embodiment of the present invention is shown.
[0028] Figure 3 A schematic diagram of an ellipse detection method 300 based on contour restoration according to an embodiment of the present invention is shown;
[0029] Figure 4 This diagram illustrates the effect of obtaining the contour region to be restored based on the second inner hole contour intercepted by a circular ring according to an embodiment of the present invention.
[0030] Figure 5 The illustration shows the effect of merging the set of inner hole contour points to be restored with the first set of inner hole contour points according to an embodiment of the present invention to obtain a new set of inner hole contour points. Detailed Implementation
[0031] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0032] Figure 1 A schematic diagram of a computing device 100 according to an embodiment of the present invention is shown. Figure 1 As shown, in a basic configuration, computing device 100 includes at least one processing unit 102 and system memory 104. According to one aspect, depending on the configuration and type of the computing device, the processing unit 102 may be implemented as a processor. System memory 104 includes, but is not limited to, volatile memory (e.g., random access memory), non-volatile memory (e.g., read-only memory), flash memory, or any combination of such memories. According to one aspect, system memory 104 includes an operating system 105.
[0033] According to one aspect, operating system 105 is, for example, suitable for controlling the operation of computing device 100. Furthermore, examples are practiced in conjunction with graphics libraries, other operating systems, or any other applications, and are not limited to any particular application or system. Figure 1 The basic configuration is illustrated by the components within the dashed lines. According to one aspect, the computing device 100 has additional features or functions. For example, according to one aspect, the computing device 100 includes additional data storage devices (removable and / or non-removable), such as disks, optical discs, or magnetic tapes. This additional storage... Figure 1The middle part is shown by removable storage device 109 and non-removable storage device 110.
[0034] As stated above, according to one aspect, program module 103 is stored in system memory 104. According to one aspect, program module 103 may include one or more applications. The present invention does not limit the type of application; for example, applications may include: email and contact applications, word processing applications, spreadsheet applications, database applications, slideshow applications, drawing or computer-aided applications, web browser applications, etc.
[0035] According to one aspect, program module 103 includes multiple program instructions adapted to perform the ellipse detection method 200 for the inner hole contour of the workpiece of the present invention and / or the ellipse detection method 300 based on contour recovery, so as to perform the ellipse detection method 200 for the inner hole contour of the workpiece of the present invention and / or the ellipse detection method 300 based on contour recovery.
[0036] According to one aspect, examples can be practiced on circuits including discrete electronic components, packaged or integrated electronic chips containing logic gates, circuits utilizing microprocessors, or on a single chip containing electronic components or a microprocessor. For example, it can be practiced via wherein... Figure 1 Each or many of the components shown can be implemented as an example by integrating a System-on-a-Chip (SOC) on a single integrated circuit. According to one aspect, such an SOC device may include one or more processing units, graphics units, communication units, system virtualization units, and various application functions, all integrated (or “burned in”) as a single integrated circuit onto a chip substrate. When operating via the SOC, the functions described herein can be operated via dedicated logic integrated on a single integrated circuit (chip) with other components of the computing device 100. Embodiments of the invention can also be implemented using other techniques capable of performing logical operations (e.g., AND, OR, and NOT), including but not limited to mechanical, optical, fluid, and quantum technologies. Additionally, embodiments of the invention can be implemented within a general-purpose computer or in any other circuit or system.
[0037] According to one aspect, computing device 100 may also have one or more input devices 112, such as a keyboard, mouse, pen, voice input device, touch input device, etc. It may also include output devices 114, such as a display, speaker, printer, etc. The foregoing devices are examples and other devices may also be used. Computing device 100 may include one or more communication connections 116 that allow communication with other computing devices 118. Examples of suitable communication connections 116 include, but are not limited to: RF transmitter, receiver and / or transceiver circuitry; Universal Serial Bus (USB), parallel and / or serial ports.
[0038] As used herein, the term computer-readable medium includes computer storage medium. Computer storage medium can include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information (e.g., computer-readable instructions, data structures, or program module 103). System memory 104, removable storage device 109, and non-removable storage device 110 are examples of computer storage media (i.e., memory storage). Computer storage media can include random access memory (RAM), read-only memory (ROM), electrically erasable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape, magnetic tape, disk storage or other magnetic storage devices, or any other article of manufacture that can be used to store information and is accessible by computing device 100. According to one aspect, any such computer storage medium can be part of computing device 100. Computer storage media does not include carrier waves or other transmitted data signals.
[0039] According to one aspect, the communication medium is implemented by computer-readable instructions, data structures, program modules 103, or other data in a modulated data signal (e.g., a carrier wave or other transmission mechanism), and includes any information transmission medium. According to one aspect, the term "modulated data signal" describes a signal having one or more sets of characteristics or altered in a manner that encodes information in the signal. By way of example and not limitation, the communication medium includes wired media such as wired networks or direct wired connections, and wireless media such as acoustic, radio frequency (RF), infrared, and other wireless media.
[0040] In an embodiment of the invention, a computing device 100 is configured to perform an ellipse detection method 200 for the inner hole contour of a workpiece and / or an ellipse detection method 300 based on contour recovery according to the invention. The computing device 100 includes one or more processors and one or more readable storage media storing program instructions that, when configured to be executed by one or more processors, cause the computing device to perform the ellipse detection method 200 for the inner hole contour of a workpiece and / or the ellipse detection method 300 based on contour recovery according to the embodiments of the invention.
[0041] According to one embodiment of the present invention, the program module 103 of the computing device 100 includes multiple program instructions for executing the ellipse detection method 200 for the inner hole contour of the workpiece and / or the ellipse detection method 300 based on contour recovery according to the present invention. These program instructions can instruct the processor to execute the ellipse detection method 200 for the inner hole contour of the workpiece and / or the ellipse detection method 300 based on contour recovery according to the present invention, so that in the process of missing part detection for shaft and hole type parts, the ellipse detection method 200 for the inner hole contour of the workpiece and / or the ellipse detection method 300 based on contour recovery according to the present invention can realize the pose detection between the workpiece and the camera, and improve the ellipse detection efficiency and detection accuracy of the inner hole contour of the workpiece.
[0042] Figure 2 A schematic diagram of an ellipse detection method 200 for the inner hole profile of a workpiece according to an embodiment of the present invention is shown. The ellipse detection method 200 for the inner hole profile of a workpiece is adapted to be executed in a computing device (e.g., the aforementioned computing device 100).
[0043] It should be noted that in the defect detection method 200 for the inner hole contour of a workpiece according to the present invention, the workpiece to be detected can be a shaft-hole type part (specifically a round shaft-hole type part, including an inner surface and an outer surface). The present invention does not limit the specific type and structure of shaft-hole type parts. For example, in some embodiments, the outer surface of the workpiece (shaft-hole type part) may include multiple cylindrical surfaces of different diameters and an external thread surface, and the inner surface may include a stepped hole, a stepped surface, and an internal thread.
[0044] like Figure 2 As shown, method 200 begins with step 210.
[0045] It should be noted that before performing step 210, an image of the workpiece's inner hole needs to be acquired in advance. This image can be an endoscopic image of the workpiece. Specifically, the image of the workpiece's inner hole can be acquired by a camera along its optical axis. The computing device 100 can acquire the image of the workpiece's inner hole acquired by the camera along its optical axis. Then, the method 200 of the present invention can be executed based on the image of the workpiece's inner hole to determine the workpiece's pose relative to the camera (during the defect detection process). In this way, during the defect detection process, the pose detection of the workpiece and the camera can be achieved, and the pose offset can be determined so that pose correction can be performed in a timely manner.
[0046] It should be understood that when the workpiece is axially offset from the camera's optical axis (with a certain angle), the inner hole image of the workpiece acquired along the camera's optical axis will have an elliptical inner hole profile.
[0047] like Figure 2 As shown, in step 210, a set of inner hole contour points can be obtained from the inner hole image of the workpiece based on a predetermined angular step size. Subsequently, some threshold parameters (including a first distance threshold, a second distance threshold, a first coverage angle threshold, and a maximum number of iterations) can be initialized, and ellipse detection is performed on the set of inner hole contour points.
[0048] Here, the present invention does not limit the specific value of the predetermined angle. For example, in one embodiment, the predetermined angle may be 0.5°.
[0049] According to one embodiment of the present invention, an improved maximum inter-class variance threshold segmentation method can be used to segment the inner hole image of a workpiece to extract the inner hole contour, and to extract the inner hole contour point set from the inner hole contour based on a predetermined angular step size.
[0050] Specifically, this invention can utilize the idea of K-Means classification to improve the maximum inter-class variance threshold segmentation method.
[0051] In one specific embodiment, according to the improved maximum inter-class variance threshold segmentation method of the present invention, obtaining the set of inner hole contour points from the inner hole image of the workpiece may specifically include the following steps:
[0052] First, the maximum inter-class variance thresholding method can be used to segment the inner hole image to obtain high grayscale regions (containing the inner hole contour). The obtained high grayscale regions include the inner hole contour and may also include high grayscale background regions near the inner hole contour.
[0053] Furthermore, this invention further classifies high grayscale regions. Specifically, the grayscale values of high grayscale regions are sorted by size to obtain the median grayscale value. This median grayscale value can be used as the final image segmentation threshold of this invention. Subsequently, the high grayscale regions can be segmented (classified) based on the median grayscale value to extract the inner hole contour from the high grayscale regions. That is, higher grayscale regions are extracted from the high grayscale regions to obtain the inner hole contour.
[0054] Finally, multiple contour points can be extracted from the inner hole profile based on a predetermined angular step size. Based on these extracted contour points, a set of inner hole contour points can be obtained.
[0055] In one embodiment, during the process of extracting multiple contour points from the inner hole contour, the angle information corresponding to each contour point can also be recorded.
[0056] Specifically, the ellipse detection of the inner hole contour point set can be performed according to the following steps 220-270.
[0057] In step 220, a predetermined number of contour points (of the inner hole) are randomly selected from the set of inner hole contour points. Here, it is necessary to ensure that the predetermined number of contour points are spaced apart from each other.
[0058] In one embodiment, the predetermined quantity is greater than 3. Specifically, the predetermined quantity can be 6.
[0059] In step 230, it is determined whether the distance between any two contour points from a predetermined number of contour points is greater than a first distance threshold. Here, the first distance threshold is the minimum distance that needs to be ensured between any two contour points, so as to ensure that there is a certain interval between any two contour points.
[0060] If the distance between any two contour points is greater than the first distance threshold (ensuring a minimum distance between any two contour points), then step 240 can be continued. Otherwise, return to step 220: randomly select a predetermined number of contour points from the set of inner hole contour points again.
[0061] It should be noted that, as Figure 2 As shown, each return to step 220 initiates a new iteration, incrementing the iteration count F by 1. Before executing step 220, it's necessary to determine if the current iteration count F is greater than the iteration count threshold Tf. If the current iteration count F is not greater than the iteration count threshold Tf (F ≤ Tf), step 220 can be executed again. If the current iteration count F is greater than the iteration count threshold Tf (F > Tf), the ellipse detection process can be terminated.
[0062] like Figure 2As shown, in step 240, an initial ellipse is fitted and formed based on the predetermined number of contour points. In one implementation, the least squares method can be used to fit and form the initial ellipse based on the predetermined number of contour points.
[0063] According to one embodiment of the present invention, before executing step 250, it can be determined whether the major and minor axis dimensions and the ratio of the major and minor axes of the initial ellipse meet predetermined conditions. If the predetermined conditions are met, step 250 can continue. Otherwise, the process returns to step 220 (randomly selecting a predetermined number of contour points from the set of inner hole contour points again) to start a new iteration. In this way, by adding constraints on the major and minor axis dimensions and the ratio of the major and minor axes, the subsequent detection process of ellipses whose dimensions do not meet the requirements can be stopped in a timely manner, thereby improving the ellipse detection efficiency.
[0064] In step 250, the next contour point is randomly selected from the set of inner hole contour points, and it is determined whether the distance from the next contour point to the initial ellipse is less than the second distance threshold.
[0065] Here, the second distance threshold is used to determine whether the contour point is on the initial ellipse. If the distance from the contour point to the initial ellipse is less than the second distance threshold, then the contour point is determined to be on the initial ellipse.
[0066] In one embodiment, when the predetermined number of contour points is 6, the next contour point randomly obtained in step 250 is the 7th contour point.
[0067] If the distance from the next contour point to the initial ellipse is less than the second distance threshold (indicating that the next contour point is on the initial ellipse, which is a potentially real ellipse), then proceed to step 260. Otherwise, return to step 220 (randomly select a predetermined number of contour points from the set of inner hole contour points again) and begin a new iteration.
[0068] In step 260, the target coverage angle value (Value) of all target contour points in the inner hole contour point set whose distance to the initial ellipse is less than the second distance threshold is determined.
[0069] Here, by determining the number of target contour points, the target coverage angle value can be calculated based on this number. Specifically, this is done by counting the number of target contour points in the inner hole contour point set whose distance to the initial ellipse is less than a second distance threshold. Subsequently, the target coverage angle value for all target contour points can be calculated based on a predetermined angle step size and the number of target contour points.
[0070] In one embodiment of the present invention, based on the angle information recorded during the extraction of 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. Thus, 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 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°, then the corresponding target coverage angle value is 90°.
[0071] Finally, in step 270, it is determined whether the target coverage angle value is greater than the first coverage angle threshold. If the target coverage angle value is greater than the first coverage angle threshold (which proves that the initial ellipse is a true complex ellipse), then the ellipse parameters are obtained based on the initial ellipse (these ellipse parameters are the final ellipse parameters to be output), and the ellipse parameters are 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.
[0072] Otherwise, if the target coverage angle value is less than or equal to the first coverage angle threshold, the process can return to step 220 and begin a new iteration.
[0073] In one embodiment, 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 according to the specific application scenario and actual situation.
[0074] Considering the significant loss of inner hole contours due to large workpiece pose offset 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). Therefore, in one embodiment, during each iteration, 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). Thus, when the iteration number F is greater than the iteration number threshold Tf (F > Tf), the saved ellipse parameters of the initial ellipse can be output, and the ellipse detection process ends.
[0075] It is worth noting that this invention actually performs ellipse detection on the set of inner hole contour points of a workpiece. Since the contour points in the set are not continuous and are spaced apart, selecting only 3 contour points cannot guarantee reaching the minimum number of points for ellipse fitting; therefore, a predetermined number of 6 points is selected. Furthermore, to ensure that the initially fitted ellipse is a real ellipse, this invention adds multiple judgment conditions to promptly stop the subsequent detection process for erroneous ellipses. In addition, considering that the inner hole contour point set of this invention is obtained based on a predetermined angular step size and is not continuous in the image, it is not suitable to use the ratio of the number of fitted points to the perimeter of the fitted ellipse as the threshold for correctly detecting the ellipse. Therefore, this invention sets a first coverage angle threshold as the threshold for the target coverage angle value of all target contour points, serving as a condition for determining whether the initial ellipse is a real ellipse.
[0076] In addition, considering that the large pose offset of the workpiece relative to the camera causes some inner hole contours to be indistinct, resulting in a large loss of inner hole contours during image segmentation, this invention also proposes an ellipse detection method 300 based on contour restoration to perform ellipse detection on the inner hole contour of the workpiece.
[0077] Figure 3 An ellipse detection method 300 based on contour restoration according to an embodiment of the present invention is shown. This method 300 is adapted to be executed in a computing device (e.g., the aforementioned computing device 100). According to the ellipse detection method 300 based on contour restoration, contour restoration can be performed in cases where the inner hole contour is lost, thereby enabling ellipse detection of the restored inner hole contour of the workpiece.
[0078] In embodiments of the present invention, the workpiece to be inspected can be a shaft-hole type part (specifically a round shaft-hole type part, including an inner surface and an outer surface). The present invention does not limit the specific type and structure of shaft-hole type parts. For example, in some embodiments, the outer surface of the workpiece (shaft-hole type part) may include multiple cylindrical surfaces of different diameters and an external thread surface, and the inner surface may include a stepped hole, a stepped surface, and an internal thread.
[0079] It should be noted that before performing step 310, it is necessary to pre-acquire an image of the inner hole of the workpiece. The inner hole image can be an endoscopic image of the workpiece. Specifically, the inner hole image of the workpiece can be acquired by a camera along its optical axis. The computing device 100 can obtain the inner hole image of the workpiece acquired by the camera along its optical axis, and then the method 300 of the present invention can be executed based on the inner hole image of the workpiece.
[0080] It should be understood that when the workpiece is axially offset from the camera's optical axis (with a certain angle), the inner hole image of the workpiece acquired along the camera's optical axis will have an elliptical inner hole profile.
[0081] like Figure 3As shown, in step 310, a first set of inner hole contour points is obtained from the inner hole image of the workpiece.
[0082] In one embodiment, a radial search method can be used to obtain a first set of inner hole contour points from an image of the workpiece's inner hole.
[0083] According to one embodiment of the present invention, an improved maximum inter-class variance threshold segmentation method can be used to segment the inner hole image of a workpiece to extract a first inner hole contour, and to extract a first inner hole contour point set from the first inner hole contour based on a predetermined angular step size.
[0084] Specifically, this invention can utilize the idea of K-Means classification to improve the maximum inter-class variance threshold segmentation method.
[0085] In one specific embodiment, according to the improved maximum inter-class variance threshold segmentation method of the present invention, obtaining a first set of inner hole contour points from the inner hole image of the workpiece may specifically include the following steps:
[0086] First, the maximum inter-class variance thresholding method can be used to segment the inner hole image to obtain a high grayscale region (containing the inner hole contour). The obtained high grayscale region includes the first inner hole contour and may also include a high grayscale background region near the first inner hole contour.
[0087] Furthermore, this invention further classifies high grayscale value regions. Specifically, the grayscale values of high grayscale value regions are sorted by size to obtain the median grayscale value. This median grayscale value can be used as the final image segmentation threshold of this invention. Subsequently, the high grayscale value regions can be segmented (classified) based on the median grayscale value to extract the first inner hole contour from the high grayscale value regions. That is, higher grayscale value regions are extracted from the high grayscale value regions to obtain the first inner hole contour.
[0088] Finally, a radial search method can be used to extract multiple contour points from the first inner hole contour. Based on the multiple contour points extracted from the first inner hole contour, a set of first inner hole contour points can be obtained.
[0089] In one embodiment, during the process of extracting multiple contour points from the first inner hole contour, the angle information corresponding to each contour point can also be recorded.
[0090] Subsequently, in step 320, the coverage angle range and coverage angle value corresponding to the first inner hole contour point set are determined.
[0091] In one embodiment, during the extraction of multiple contour points, the angle information corresponding to each contour point in the first set of inner hole contour points can be recorded. Thus, in step 320, the coverage angle range can be determined based on the angle information corresponding to all contour points, and the corresponding coverage angle value can be determined based on the coverage angle range.
[0092] Next, in step 330, it is determined whether the aforementioned coverage angle value is greater than a second coverage angle threshold. Here, the second coverage angle threshold is used to determine whether the inner hole contour needs to be restored. In one embodiment, the second coverage angle threshold can be set to 180° for example.
[0093] In one embodiment, if the coverage angle value is greater than the second coverage angle threshold (indicating that no restoration of the inner hole contour is required), then step 335 is executed. In step 335, ellipse detection can be performed on the first inner hole contour point set to obtain a first ellipse parameter, and this first ellipse parameter is used as the final ellipse parameter (i.e., the final output ellipse parameter). Specifically, ellipse detection can be performed on the first inner hole contour point set according to steps 220 to 270 in the aforementioned method 200 to obtain the first ellipse parameter.
[0094] If the coverage angle value is less than or equal to the second coverage angle threshold (indicating that the inner hole profile needs to be restored), then proceed to step 340.
[0095] In step 340, ellipse detection is performed on the first inner hole contour point set to obtain the corresponding first ellipse parameters. Specifically, ellipse detection can be performed on the first inner hole contour point set according to steps 220 to 270 in the aforementioned method 200 to obtain the first ellipse parameters.
[0096] Next, in step 350, a ring is constructed based on the parameters of the first ellipse.
[0097] In step 360, the second inner hole contour is extracted from the inner hole image of the workpiece using the maximum entropy threshold segmentation method.
[0098] In step 370, based on the annulus constructed in step 350, the contour of the second inner hole is cut off to obtain the contour region to be restored. Here, Figure 4 A schematic diagram illustrating the effect of obtaining the contour region to be restored based on the second inner hole contour intercepted by a circular ring according to an embodiment of the present invention is shown.
[0099] Subsequently, in step 380, multiple contour points of the inner hole are obtained from the contour area to be restored, and these multiple contour points are merged with the first set of inner hole contour points to obtain a new set of inner hole contour points.
[0100] Specifically, multiple contour points within the contour area to be restored can be searched in areas outside the coverage angle range. Based on all the searched contour points, a set of contour points for the inner hole to be restored can be obtained. Subsequently, by merging the set of inner hole contour points to be restored with the first set of inner hole contour points, a new set of inner hole contour points can be obtained. Here, Figure 5 The illustration shows the effect of merging the set of inner hole contour points to be restored with the first set of inner hole contour points according to an embodiment of the present invention to obtain a new set of inner hole contour points.
[0101] Finally, in step 390, ellipse detection is performed on the new set of inner hole contour points to obtain new ellipse parameters, and these new ellipse parameters are used as the final ellipse parameters (i.e., the final output ellipse parameters).
[0102] In an embodiment of the present invention, ellipse detection can be performed on the set of inner hole contour points (first inner hole contour point set / new inner hole contour point set) according to steps 220 to 270 in the aforementioned method 200 to obtain the corresponding ellipse parameters (first ellipse parameters / new ellipse parameters).
[0103] Specifically, the method for performing ellipse detection on the set of inner hole contour points (first inner hole contour point set / new inner hole contour point set) according to steps 220-270 of the aforementioned method 200 is as follows:
[0104] A predetermined number of contour points are randomly selected from the set of inner hole contour points (first inner hole contour point set / new inner hole contour point set). Here, the predetermined number is greater than 3. In one embodiment, the predetermined number can be 6.
[0105] Determine whether the distance between any two contour points from a predetermined number of contour points is greater than a first distance threshold. In one embodiment, the first distance threshold can be 288°.
[0106] If the distance is greater than the first distance threshold, an initial ellipse is fitted based on a predetermined number of contour points.
[0107] The next contour point is randomly selected from the set of inner hole contour points (first inner hole contour point set / new inner hole contour point set), and it is determined whether the distance from the next contour point to the initial ellipse is less than the second distance threshold.
[0108] If the distance is less than the second distance threshold, then determine the target coverage angle value of all target contour points in the inner hole contour point set (first inner hole contour point set / new inner hole contour point set) whose distance to the initial ellipse is less than the second distance threshold.
[0109] Determine whether the target coverage angle value is greater than the first coverage angle threshold. If it is greater than the first coverage angle threshold, obtain the ellipse parameters (first ellipse parameters / new ellipse parameters) based on the initial ellipse.
[0110] Here, it should be understood that performing ellipse detection on the first set of inner hole contour points according to steps 220-270 of the aforementioned method 200 yields the first ellipse parameters. Performing ellipse detection on the new set of inner hole contour points according to steps 220-270 of the aforementioned method 200 yields the new ellipse parameters.
[0111] In one embodiment, before randomly selecting the next contour point from the set of inner hole contour points (first inner hole contour point set / new inner hole contour point set), it can be determined whether the major and minor axis dimensions and the ratio of the major and minor axes of the initial ellipse meet predetermined conditions. If the predetermined conditions are met, the next contour point is randomly selected from the set of inner hole contour points.
[0112] It should be noted that the specific implementation of ellipse detection on the set of inner hole contour points (first inner hole contour point set / new inner hole contour point set) to obtain the corresponding ellipse parameters (first ellipse parameters / new ellipse parameters) can be found in the description of method 200 above, and will not be repeated here.
[0113] In summary, the ellipse detection method 200 for the inner hole contour of a workpiece according to the present invention obtains a set of inner hole contour points from the inner hole image of the workpiece based on a predetermined angular step size. A predetermined number of contour points are randomly selected from the inner hole contour point set. It is determined whether the distance between any two contour points is greater than a first distance threshold. If it is greater than the first distance threshold, an initial ellipse is formed based on the predetermined number of contour points. Next, the next contour point is randomly selected from the inner hole contour point set, and it is determined whether the distance from the next contour point to the initial ellipse is less than a second distance threshold. If it is less than the second distance threshold, the target coverage angle values of all target contour points in the inner hole contour point set whose distance to the initial ellipse is less than the second distance threshold are determined. It is then determined whether the target coverage angle values are greater than a first coverage angle threshold. If they are greater than the first coverage angle threshold, the ellipse parameters are obtained based on the initial ellipse. Thus, according to the technical solution of the present invention, the existing ellipse detection algorithm is improved by adding multiple judgment conditions, which can promptly stop the subsequent detection process for erroneous ellipses, thereby improving the efficiency of ellipse detection for the inner hole contour of shaft-hole type workpieces.
[0114] Furthermore, this invention utilizes the maximum inter-class variance thresholding method. First, the internal hole image is segmented to obtain high grayscale regions. Then, the grayscale values of these high grayscale regions are sorted by size to obtain the median grayscale value. Finally, the high grayscale regions are segmented based on this median grayscale value to extract the internal hole contour. Thus, according to the improved maximum inter-class variance thresholding method of this invention, the segmentation accuracy of the internal hole image and the accuracy of the extracted internal hole contour are improved, thereby further enhancing the ellipse detection accuracy of the internal hole contour of shaft-hole workpieces.
[0115] According to the ellipse detection method 300 based on contour restoration of the present invention, a first set of inner hole contour points is obtained from the inner hole image of the workpiece. The coverage angle range and coverage angle value corresponding to the first set of inner hole contour points are determined. It is then determined whether the coverage angle value is greater than a second coverage angle threshold. If not, ellipse detection is performed on the first set of inner hole contour points to obtain first ellipse parameters. A ring is constructed based on the first ellipse parameters, and a second inner hole contour is extracted from the inner hole image of the workpiece using the maximum entropy threshold segmentation method. Subsequently, the second inner hole contour is truncated based on the ring to obtain the contour region to be restored. Furthermore, multiple contour points of the inner hole are obtained from the contour region to be restored and merged with the first set of inner hole contour points to obtain a new set of inner hole contour points. Ellipse detection is then performed on the new set of inner hole contour points according to the above method 200 to obtain new ellipse parameters, which are then used as the final ellipse parameters. Thus, according to the technical solution of the present invention, the inner hole contour can be restored when the workpiece's pose offset relative to the camera is large, resulting in significant loss of inner hole contour. Ellipse detection is then performed on the restored new set of inner hole contour points, thereby improving the accuracy of ellipse detection.
[0116] A9. The method as described in any one of A1-A8, wherein the first coverage angle threshold is 288°.
[0117] A10, the method as described in any one of A1-A9, wherein the workpiece is a shaft-hole type part.
[0118] The various techniques described herein can be implemented in combination with hardware or software, or a combination thereof. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, can take the form of program code (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, USB flash drive, floppy disk, CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into and executed by a machine such as a computer, the machine becomes an apparatus for practicing the present invention.
[0119] When the program code is executed on a programmable computer, the mobile terminal generally includes a processor, a processor-readable storage medium (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store program code; the processor is configured to execute the ellipse detection method for the inner hole contour of a workpiece according to the instructions in the program code stored in the memory.
[0120] By way of example, and not limitation, readable media include readable storage media and communication media. Readable storage media stores information such as computer-readable instructions, data structures, program modules, or other data. Communication media generally embodies computer-readable instructions, data structures, program modules, or other data in the form of modulated data signals such as carrier waves or other transmission mechanisms, and includes any information delivery medium. Any combination of the above is also included within the scope of readable media.
[0121] In the specification provided herein, the algorithms and displays are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used with the examples of this invention. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0122] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0123] Similarly, it should be understood that, in order to streamline this disclosure and aid in understanding one or more of the various aspects of the invention, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof.
[0124] Those skilled in the art will understand that modules, units, or components of the devices disclosed in the examples herein can be arranged in the devices described in this embodiment, or alternatively, can be located in one or more devices different from the devices in this example. The modules in the foregoing examples can be combined into a single module or, in addition, can be divided into multiple sub-modules.
[0125] Those skilled in the art will understand that the modules in the device of the embodiment can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiment can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components.
[0126] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of the invention and form different embodiments.
[0127] Furthermore, some of the embodiments described herein are methods or combinations of method elements that can be implemented by a processor of a computer system or by other means of performing the functions. Therefore, a processor having the necessary instructions for implementing the methods or method elements forms means for implementing the methods or method elements. Furthermore, the elements described herein in the apparatus embodiments are examples of means for implementing the functions performed by the objective elements for carrying out the invention.
[0128] As used herein, unless otherwise specified, the use of ordinal numbers such as “first,” “second,” “third,” etc., to describe ordinary objects merely indicates different instances of similar objects and is not intended to imply that the objects being described must have a given order in time, space, ordering, or any other manner.
[0129] Although the invention has been described with respect to a limited number of embodiments, those skilled in the art will understand from the foregoing description that other embodiments are conceivable within the scope of the invention described herein. Furthermore, it should be noted that the language used in this specification has been chosen primarily for readability and edibility purposes, and not for the purpose of explaining or limiting the subject matter of the invention.
Claims
1. A method for detecting the ellipse of the inner hole contour of a workpiece, executed in a computing device, comprising: Based on a predetermined angle step size, a set of inner hole contour points is obtained from the inner hole image of the workpiece, including: segmenting the inner hole image using the maximum inter-class variance thresholding method to obtain high grayscale value regions; sorting the grayscale values of the high grayscale value regions by size and obtaining the median grayscale value; segmenting the high grayscale value regions according to the median grayscale value to extract the inner hole contour; and extracting multiple contour points from the inner hole contour based on the predetermined angle step size to obtain a set of inner hole contour points. A predetermined number of contour points are randomly selected from the set of inner hole contour points, wherein the predetermined number is greater than 3; Determine whether the distance between any two contour points among the predetermined number of contour points is greater than a first distance threshold. If the distance is greater than the first distance threshold, then an initial ellipse is fitted based on the predetermined number of contour points; Randomly select the next contour point from the set of inner hole contour points, and determine whether the distance from the next contour point to the initial ellipse is less than the second distance threshold. If it is less than the second distance threshold, then determine the target coverage angle value of all target contour points in the set of inner hole contour points whose distance to the initial ellipse is less than the second distance threshold; Determine whether the target coverage angle value is greater than the first coverage angle threshold. If it is greater than the first coverage angle threshold, obtain the ellipse parameters based on the initial ellipse.
2. The method as described in claim 1, wherein, Before obtaining the set of inner hole contour points from the inner hole image of the workpiece based on a predetermined angular step size, the following steps are also included: The inner hole image of the workpiece is acquired by the camera along the optical axis, so as to determine the pose of the workpiece relative to the camera based on the ellipse parameters.
3. The method as described in claim 1, wherein, Randomly select the next contour point from the set of inner hole contour points, including: Determine whether the major and minor axis dimensions and the ratio of the major and minor axes of the initial ellipse meet the predetermined conditions; If the predetermined conditions are met, the next contour point is randomly selected from the set of inner hole contour points.
4. The method according to any one of claims 1-3, wherein, Determine the target coverage angle values of all target contour points in the set of inner hole contour points whose distance to the initial ellipse is less than a second distance threshold, including: The number of target contour points in the set of inner hole contour points whose distance to the initial ellipse is less than the second distance threshold is counted. The target coverage angle value of all target contour points is determined based on the predetermined angle step size and the number of target contour points.
5. The method of claim 4, wherein, After counting the number of target contour points in the set of inner hole contour points whose distance to the initial ellipse is less than the second distance threshold, the method further includes: Save the ellipse parameters of the initial ellipse with the most target contour points.
6. The method according to any one of claims 1-3, wherein, The predetermined quantity is 6.
7. The method according to any one of claims 1-3, wherein, The predetermined angle step size is 0.5°.
8. The method according to any one of claims 1-3, wherein, The first coverage angle threshold is 288°.
9. The method according to any one of claims 1-3, wherein, The workpiece is a shaft-hole type part.
10. 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, the program instructions including instructions for performing the method as described in any one of claims 1-9.
11. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method as described in any one of claims 1-9.
Citation Information
Patent Citations
Round hole feature extraction method
CN109859206A
Multi-ellipse detection and evaluation algorithm and device based on image gradient information, terminal and readable storage medium
CN111311593A