Concentricity determination method, apparatus, storage medium, and electronic device
Patent Information
- Application Number
- CN202210929281.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-03
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2042-08-03
AI Technical Summary
[0004]在这个过程中,对圆形工件的边缘进行检测的感知能力往往不足,导致拟合出的圆形工件的边缘的准确性较低,进而导致计算出的圆形工件的圆心的准确性较低,计算出的同心度的准确性较低
[0039]Through the above technical solutions, firstly, an edge detection algorithm using eight-directional gradient synthesis is employed to perform eight-directional convolution on each first pixel, resulting in more accurate gradient magnitudes for each first pixel. This leads to more comprehensive and accurate edge information extracted by subsequent edge detection algorithms. Secondly, a dynamic threshold setting allows the threshold to change with the background brightness of the first pixel. This dynamic threshold change better aligns with human visual characteristics. By comparing the gradient magnitude with the dynamic threshold, a suitable number of second pixels is obtained, avoiding both excessive and insufficient numbers. This prevents false edges caused by an excessive number of second pixels and edge discontinuities caused by a insufficient number. Thirdly, morphological erosion of the second pixels filters the image edges formed by them, removing isolated light spots and false edges, thus improving the accuracy of the target pixels. Fourthly, the least squares method is used to fit multiple accurate target pixels, resulting in clearer and more accurate edges for the first target object. The center of the first target object obtained based on clear and accurate edges is more accurate, leading to higher accuracy in the final calculated concentricity.
Smart Images

Figure CN117557588B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more specifically, to a method, apparatus, storage medium, and electronic device for determining concentricity. Background Technology
[0002] Concentricity, also known as coaxiality, is an important technical indicator for evaluating whether two circular workpieces are on the same axis. Concentricity error will directly affect the assembly of the entire circular workpiece.
[0003] In related technologies, the edges of the circular workpiece are first detected, then the center of the circular workpiece is determined based on the edges, and finally the concentricity between the centers of the two circular workpieces is determined.
[0004] In this process, the sensing ability to detect the edge of a circular workpiece is often insufficient, resulting in low accuracy of the fitted edge of the circular workpiece, which in turn leads to low accuracy of the calculated center of the circular workpiece and low accuracy of the calculated concentricity. Summary of the Invention
[0005] The purpose of this disclosure is to provide a method, apparatus, storage medium, and electronic device for determining concentricity to solve the aforementioned technical problems.
[0006] To achieve the above objectives, a first aspect of this disclosure provides a method for determining concentricity, the method comprising:
[0007] For the target image corresponding to the first target object, an edge detection algorithm with eight-directional gradient synthesis is used to detect the gradient magnitude of multiple first pixels of the first target object.
[0008] From multiple gradient magnitudes, determine multiple second pixel points corresponding to multiple gradient magnitudes that are greater than the dynamic threshold;
[0009] The plurality of second pixels are subjected to morphological erosion to obtain a plurality of target pixels;
[0010] The center of the first target object is obtained by fitting the plurality of target pixels using the least squares method;
[0011] The concentricity between the first target and the second target is determined based on the distance between their centers.
[0012] Optionally, the step of detecting the edge using an eight-directional gradient synthesis algorithm on the target image corresponding to the first target object to obtain the gradient magnitude of multiple first pixels of the first target object includes:
[0013] The first pixel of the target image is convolved with the first convolution kernel to obtain the gradient of the first pixel in eight directions;
[0014] The gradient magnitude of the first pixel is determined based on the gradient of the first pixel in eight directions.
[0015] Optionally, the dynamic threshold is determined through the following steps:
[0016] When the background brightness of the first pixel is above a first preset value and below a second preset value, the dynamic threshold is determined according to a first exponential function.
[0017] When the background brightness of the first pixel is greater than the second preset value and less than the third preset value, the dynamic threshold is determined according to the cubic curve function.
[0018] When the background brightness of the first pixel is above the third preset value, the dynamic threshold is determined according to the second exponential function.
[0019] Optionally, the step of obtaining multiple target pixels by morphological erosion of the plurality of second pixels includes:
[0020] The image edge formed by the plurality of second pixels is convolved by the second convolution kernel to obtain the local minimum value among the plurality of second pixels covered by the second convolution kernel on the image edge;
[0021] The local minimum value among the plurality of second pixels is taken as the plurality of target pixels.
[0022] Optionally, the step of fitting the plurality of target pixels using the least squares method to obtain the center of the first target object includes:
[0023] If the difference between the square of the first distance between the plurality of target pixels and the reference center and the square of the second distance between the reference radius of the reference circle and the reference center is close to a first value, the center of the reference circle shall be taken as the center of the first target object.
[0024] Optionally, the distance between the centers of the first target and the second target is determined by the following steps:
[0025] The size of each pixel is determined through camera calibration;
[0026] The distance between the centers of the first target object and the second target object is determined based on the size of each pixel and the number of pixels that separate the centers of the first target object and the second target object.
[0027] Optionally, the target image is obtained through the following steps:
[0028] The image to be processed is smoothed using a third convolution kernel to obtain the target image.
[0029] According to a second aspect of the present disclosure, a concentricity determination apparatus is provided, the apparatus comprising:
[0030] The edge detection module is configured to perform edge detection on the target image corresponding to the first target object using an eight-directional gradient synthesis edge detection algorithm to obtain the gradient magnitude of multiple first pixels of the first target object.
[0031] The second pixel point determination module is configured to determine multiple second pixel points corresponding to multiple gradient magnitudes that are greater than a dynamic threshold from multiple gradient magnitudes.
[0032] The target pixel point determination module is configured to perform morphological erosion processing on the plurality of second pixels to obtain a plurality of target pixels;
[0033] The fitting module is configured to fit the plurality of target pixels using the least squares method to obtain the center of the first target object;
[0034] The concentricity determination module is configured to determine the concentricity between the first target object and the second target object based on the distance between the centers of the first target object and the second target object.
[0035] According to a third aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the concentricity determination method provided in the first aspect of the present disclosure.
[0036] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising:
[0037] A memory on which computer programs are stored;
[0038] A processor is configured to execute the computer program in the memory to implement the steps of the concentricity determination method provided in the first aspect of the present disclosure.
[0039] Through the above technical solutions, firstly, an edge detection algorithm using eight-directional gradient synthesis is employed to perform eight-directional convolution on each first pixel, resulting in more accurate gradient magnitudes for each first pixel. This leads to more comprehensive and accurate edge information extracted by subsequent edge detection algorithms. Secondly, a dynamic threshold setting allows the threshold to change with the background brightness of the first pixel. This dynamic threshold change better aligns with human visual characteristics. By comparing the gradient magnitude with the dynamic threshold, a suitable number of second pixels is obtained, avoiding both excessive and insufficient numbers. This prevents false edges caused by an excessive number of second pixels and edge discontinuities caused by a insufficient number. Thirdly, morphological erosion of the second pixels filters the image edges formed by them, removing isolated light spots and false edges, thus improving the accuracy of the target pixels. Fourthly, the least squares method is used to fit multiple accurate target pixels, resulting in clearer and more accurate edges for the first target object. The center of the first target object obtained based on clear and accurate edges is more accurate, leading to higher accuracy in the final calculated concentricity.
[0040] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0041] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0042] Figure 1 This is a flowchart illustrating the steps of a concentricity determination method in an exemplary embodiment.
[0043] Figure 2 This is a schematic diagram of a horizontally oriented convolution kernel, as illustrated in an exemplary embodiment.
[0044] Figure 3 This is a schematic diagram illustrating a pixel and its neighborhood in an exemplary embodiment.
[0045] Figure 4 This is a schematic diagram of a vertically oriented convolution kernel, as illustrated in an exemplary embodiment.
[0046] Figure 5 This is a schematic diagram illustrating the relationship between a dynamic threshold and the grayscale value of the background brightness, as shown in an exemplary embodiment.
[0047] Figure 6 This is a schematic diagram illustrating morphological corrosion as an exemplary embodiment.
[0048] Figure 7 This is a logical schematic diagram illustrating a concentricity determination method in an exemplary embodiment.
[0049] Figure 8 This is a schematic diagram illustrating a gemstone and HF adhesive as an exemplary embodiment.
[0050] Figure 9 This is a block diagram illustrating a concentricity determination device in an exemplary embodiment.
[0051] Figure 10 This is a block diagram illustrating an electronic device in an exemplary embodiment. Detailed Implementation
[0052] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0053] It should be noted that all actions involving the acquisition of signals, information, or data in this disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the location is situated, and with authorization from the owner of the relevant device.
[0054] Please refer to Figure 1 As shown, this disclosure proposes a method for determining concentricity, which includes the following steps:
[0055] In step S11, the target image corresponding to the first target object is detected by an edge detection algorithm that synthesizes gradients in eight directions to obtain the gradient magnitude of multiple first pixels of the first target object.
[0056] In this disclosure, the first target object can be HF adhesive surrounding the second target object, and the second target object can be a circular piece such as a gemstone. Since the edges of the captured image of the first target object are usually blurry, it is necessary to detect the edges of the first target object; while the edges of the image of the second target object are relatively clear, so it is not necessary to detect the edges of the second target object.
[0057] The target image contains multiple first pixels, each with its own corresponding gradient magnitude, which refers to the gray value of the coordinate point where the first pixel is located.
[0058] In related technologies, the Sobel edge detection algorithm calculates the gradient magnitude of a pixel based on the difference between adjacent pixels in the horizontal and vertical directions, thereby achieving edge detection of the first target object. However, the Sobel edge detection algorithm does not consider the differences between adjacent pixels in other directions, resulting in missing detected pixels and the loss of some edge information of the first target object.
[0059] To reduce the loss of some edge information of the first target object, this disclosure proposes to use the Sobel edge detection algorithm with gradient synthesis in eight directions to perform edge detection in the target object image corresponding to the first target object, specifically including the following sub-steps:
[0060] Sub-step A1: Convolve the first pixel of the target image with the first convolution kernel to obtain the gradient of the first pixel in eight directions.
[0061] The eight directions include: 0°, 22.5°, 45°, 67.5°, 90°, 112.5°, 135°, and 157.5°. The convolution kernel in the Sobel edge detection algorithm is also changed from a 3x3 kernel to a 5x5 first convolution kernel. Changing the kernel to a 5x5 first convolution kernel increases the convolution efficiency on the target image.
[0062] Specifically, in the relevant technologies, when adopting Figure 2 The Sobel edge detection algorithm shown is used to detect edges in the horizontal direction. Figure 3 When the first pixel (x, y) of the target image is convolved, the gradient in the horizontal direction is:
[0063] G x =(z7+2z8+z9)-(z1+2z2+z3) (1)
[0064] In formula (1), G x z1 represents the gradient of the first pixel in the horizontal direction, and z2, z3, z7, z8, and z9 are the values of each neighborhood in the convolution kernel.
[0065] In Adoption Figure 4 The Sobel edge detection algorithm in the numerical direction shown is used to detect edges. Figure 3 When the first pixel (x, y) of the target image is convolved, the gradient in the vertical direction is:
[0066] G y =(z3+2z6+z9)-(z1+2z4+z7) (2)
[0067] In formula (2), G y Z is the gradient of the first pixel in the vertical direction, and z1, z6, z3, z7, z4, and z9 are the values of each neighborhood in the convolution kernel.
[0068] In this disclosure, when using a 5x5 first convolution kernel to perform eight-directional convolution on the target image, the gradients obtained in each direction are as follows:
[0069] G 0°(z5+2z6+4z7+2z8+z9)-(z 15 +2z 16 +4z 17 +2z 18 +z 19 (3)
[0070] G 22.5° (2z6+4z7+2z8+z 10 +4z 11 )-(4z 13 +z 14 +2z 16 +4z 17 +2z 18 (4)
[0071] G 45° (z3+2z6+4z7+4z 11 +z 15 )-(z9+4z 13 +4z 17 +2z 18 +z 21 (5)
[0072] G 67.5° (z2+2z6+4z7+24+2z 16 )-(2z8+4z 13 +4z 17 +2z 18 +z 22 (6)
[0073] G 90° (z1+2z6+4z) 11 +2z 16 +z 21 )-(z3+2z8+4z 13 +2z 18 +z 23 (7)
[0074] G 112.5° (2z6+4z) 11 +2z 16 +4z 17 +z 22 )-(z2+4z7+2z8+4z 13 +2z 18 (8)
[0075] G 135° (z5+4z) 11 +2z 16 +4z 17 +z 23)-(z1+4z7+2z8+4z 13 +z 19 (9)
[0076] G 157.5° =(z 10 +4z 11 +2z 16 +4z 17 +2z 18 )-(2z6+4z7+2z8+4z 13 +z 14 (10)
[0077] From formulas (3) to (10), we can obtain the gradients of the first pixel in the target image at 0°, 22.5°, 45°, 67.5°, 90°, 112.5° and 135°, 157.5° respectively.
[0078] Sub-step A2: Determine the gradient magnitude of the first pixel based on the gradient of the first pixel in eight directions.
[0079] In this disclosure, after obtaining the gradient of the first pixel in eight directions, the gradient magnitude of the first pixel can be obtained based on the gradient in the eight directions.
[0080] Specifically, the gradient magnitude of the first pixel can be represented by the following formula (11) or formula (12).
[0081] M1 = |G 0° |+|G 22.5° |+|G 45° |+|G 67.5° |+|G 90° |+|G 112.5° |+|G 135° |+|G 157.5° | (11)
[0082] M ∞ =max{|G 0° |,|G 22.5° |,|G 45° |,|G 67.5° |,|G 90° |,|G 112.5° |,|G 135° |,|G 157.5° |} (12)
[0083] In formulas (11) and (12), M1 and M ∞ Both are gradient magnitudes of the first pixel. Since their values are close, either gradient magnitude can be chosen as the gradient magnitude of the first pixel.
[0084] After calculation using formulas (3) to (12), the gradient magnitude of each first pixel in the target image can be obtained. Since each first pixel is convolved in eight directions by the first convolution kernel, the accuracy of the gradient magnitude of the first pixel is higher and more comprehensive. Naturally, the edge of the target image detected based on the gradient magnitude of the first pixel is also more accurate and comprehensive.
[0085] In step S12, multiple second pixel points corresponding to multiple gradient magnitudes that are greater than the dynamic threshold are determined from multiple gradient magnitudes.
[0086] In related technologies, the gradient magnitude of the first pixel is compared with a fixed threshold. The first pixel that is greater than the fixed threshold is taken as the second pixel. Then, multiple second pixels that are greater than the first pixel are fitted to obtain the edge of the first target object, thereby completing the edge detection of the first target object.
[0087] In this disclosure, the first step S11 involves using a first convolution kernel to perform eight-directional convolution on each first pixel in the target image, thereby making the gradient magnitude of each first pixel more accurate and comprehensive. After comparison with the threshold, the edge information extracted by the subsequent edge detection algorithm will also be more comprehensive.
[0088] Furthermore, subjective vision is obtained by the stimulation of the optic nerve when light reflected from an object strikes the retina. Subjective brightness has a logarithmic relationship with the intensity of light entering the eye, but it is not entirely determined by the brightness of the object itself, but also by the brightness of the background. If a fixed threshold is used to compare with the gradient magnitude, if the fixed threshold is set too high, the number of second pixels obtained will be small, resulting in discontinuous edges of the detected first target object; if the fixed threshold is set too low, the number of second pixels obtained will be large, resulting in false edges in the detected first target object.
[0089] The present invention designs a dynamic threshold that conforms to the characteristics of human vision, so that the number of first pixels obtained is appropriate in different stages of human vision, without too many or too few, thereby avoiding the phenomenon of edge discontinuity or false edges.
[0090] Specifically, when the background brightness of the first pixel is above a first preset value and below a second preset value, a dynamic threshold is determined according to a first exponential function; when the background brightness of the first pixel is greater than a second preset value and less than a third preset value, a dynamic threshold is determined according to a cubic curve function; and when the background brightness of the first pixel is above a third preset value, a dynamic threshold is determined according to a second exponential function.
[0091] Specifically, it can be expressed by the following formula (13):
[0092]
[0093] In formula (13), α0, α1, β0, β1, β2, β3, γ0, and γ1 are all constants and can be set according to the actual situation; I is the background brightness of the first pixel; a is the cutoff gradient of the dark area; b is the starting gradient of the bright area; and ΔI is the dynamic threshold.
[0094] The background brightness of the first pixel can be understood as the grayscale value of the background brightness of the first pixel, which is obtained by averaging the values of the pixels in its 24 neighboring regions. Since the target image is a 5x5 image, the grayscale value of the background brightness of the first pixel is the average value of its 24 neighboring regions. The first preset value can be the cutoff gradient for low dark areas, and the second preset value can be the starting gradient for bright areas. The first exponential function can be represented by α0exp(1 / (α1I+1)), and the cubic curve function can be represented by β0I. 3 +β1I 2 The second exponential function can be represented by γ0exp(γ1 / (1.0-I)); the cutoff gradient in the low dark region can be 0.18, and the starting gradient in the bright region can be 0.71.
[0095] Specifically, please refer to Figure 5 The three function curves shown are: the first segment [0, a] represents the first exponential function, the second segment (a, b) represents the cubic function, and the third segment [, +∞) represents the second exponential function. When the background brightness of the first pixel is below the cutoff gradient in the low dark region, the greater the background brightness of the first pixel, the smaller the dynamic threshold, and the more second pixels are obtained. When the background brightness of the first pixel is greater than the cutoff gradient in the low dark region but less than the starting gradient in the bright region, the greater the background brightness of the first pixel, the larger the dynamic threshold, and the fewer second pixels are obtained. When the background brightness of the first pixel is above the starting gradient in the bright region, the greater the background brightness of the first pixel, the larger the dynamic threshold, and the increase in the dynamic threshold is greater than the increase in the cubic function.
[0096] By setting a dynamic threshold, the threshold can change with the background brightness of the first pixel, which is more in line with the characteristics of human vision. This results in a more appropriate number of second pixels, avoiding both too many and too few pixels. This prevents false edges caused by too many pixels and discontinuous edges caused by too few pixels.
[0097] In step S13, the plurality of second pixels are subjected to morphological erosion to obtain a plurality of target pixels.
[0098] Since this disclosure uses the Sobel edge detection algorithm to determine multiple first pixel points, and the Sobel edge detection algorithm is relatively sensitive to noise, it will cause the fitted first target object to have false edges and isolated light spots. Isolated light spots refer to the presence of extra bright spots in the target image of the first target object. In order to avoid the occurrence of false edges and isolated light spots, this disclosure will also perform morphological erosion processing on multiple second pixel points to obtain multiple target pixel points, so as to make the edge of the first target object fitted based on multiple target pixel points clearer and reduce the impact of noise on the target image.
[0099] Specifically, the second convolution kernel can be used to convolve the image edge formed by multiple second pixels to obtain the local minimum value among the multiple second pixels covering the image edge; the local minimum value among the multiple second pixels is used as multiple target pixels.
[0100] The second convolutional kernel can be a 3x3 convolutional kernel, for example, see [link to example]. Figure 6 As shown, the image before erosion is A, the second convolution kernel is B, and the pentagram in the second convolution kernel B is the core of the second convolution kernel. After convolving the second convolution kernel along the inner boundary of image A, the eroded image is obtained. The eroded image is shrunk by one size compared to image A.
[0101] During the convolution process of the second convolution kernel B along the inner boundary of image A, the pixels in image A that can completely contain the core of the convolution kernel are retained. This can also be understood as using the core of the pentagram of the second convolution kernel as the target pixel of the edge of the eroded image, thereby filtering the boundary points of multiple second pixels in image A, so that the target pixels are retained in image A, and the image edge formed by the target pixels is clearer.
[0102] By performing morphological erosion on an image formed by multiple second pixels, the target pixel can be obtained. The image formed based on the target pixel can avoid the phenomena of false edges and isolated light spots, making the image edges clearer and more accurate.
[0103] In step S14, the multiple target pixels are fitted using the least squares method to obtain the center of the first target object.
[0104] In this disclosure, after obtaining multiple target pixels of the first target object, the multiple target pixels can be fitted by the least squares method to obtain the circular edge of the first target object, and then the center point of the first target object can be obtained based on the circular edge of the first target object.
[0105] Specifically, when the difference between the square of the first distance between multiple target pixels and the reference center and the square of the second distance between the reference radius of the reference circle and the reference center is close to a first value, the center of the reference circle is taken as the center of the first target object, and the first value can be 0.
[0106] Specifically, we can first set up formula (14):
[0107] R 2 =(xA) 2 +(yB) 2 =x 2 -2Ax+A 2 +y 2 -2Ay+B 2 (14)
[0108] In formula (14), R is the radius of the set reference circle, (A, B) are the coordinates of the reference center of the set reference circle, and (x, y) are the coordinates of the pixel on the set reference circle.
[0109] Then set the coordinates (x) of the multiple target pixels collected. i y i The distance between (A, B) and the reference center (A, B) is d. i The calculation formula is as follows:
[0110] d i 2 =(x i -A) 2 +(y i -B) 2 (15)
[0111] In formula (15), d i Let (A, B) be the distance between the target pixel and the reference center, and (A, B) be the coordinates of the reference center of the defined reference circle. i y i ) represents the coordinates of the target pixel.
[0112] Let a = -2A, b = -2B, c = A 2 +B 2 -R 2 , then d i The squared difference between R and R is:
[0113]
[0114] Based on formula (16), the difference Q(a, b, c) between the square of the distance from all target pixels to the center of the circle and the square of the distance from the pixel on the reference circle to the center of the circle is used as the objective function. By optimizing the objective function, the distance between all target pixels and the reference circle is minimized, thereby fitting the reference circle closest to the edge, which is specifically expressed by the following formula:
[0115] Q(a,b,c)=∑(d i 2 -R 2 (17)
[0116] In formula (17), Q(a, b, c) is the difference between the square of the distance from the target pixel to the center of the circle and the square of the distance from the pixel on the reference circle to the center of the circle, and d i R is the distance between the target pixel and the reference center, and R is the radius of the set reference circle.
[0117] Since the squared difference Q(a, b, c) is greater than or equal to 0, Q(a, b, c) has a minimum value greater than or equal to 0 and a maximum value of infinity. In this case, we can take the partial derivatives of Q(a, b, c) with respect to a, b, and c respectively, set the partial derivatives to 0, and obtain the extreme points. By comparing the function values of all extreme points, we can obtain the fitting circle parameters A, B, and R under the minimum value.
[0118]
[0119]
[0120]
[0121] Using formulas (18) to (20), we can obtain the minimum values of a, b, and c. Then, based on the formulas a = -2A, b = -2B, c = A 2 +B 2 -R 2 To obtain the reference circle A, B, and R.
[0122] It can be seen that the coordinates (x) of multiple target pixels i y i A reference circle can be fitted, which is the edge of the first target object. After the reference circle is determined, the center (A, B) of the reference circle can be determined, which is also the center (A, B) of the first target object.
[0123] In step S15, the concentricity between the first target object and the second target object is determined based on the distance between the centers of the first target object and the second target object.
[0124] In this disclosure, multiple target pixels can be fitted based on the aforementioned least squares method to obtain the center coordinates of the first target object. Since the edges of the second target object are clear, the center coordinates of the second target object can be directly calculated.
[0125] After determining the center coordinates of the first and second targets, the distance between them can be calculated and used as the degree of concentricity between them.
[0126] Specifically, the size of each pixel can be determined through camera calibration; and the distance between the centers of the first target object and the second target object can be determined based on the size of each pixel and the number of pixels that separate the centers of the first target object and the second target object.
[0127] Specifically, VisionPro (visual processing software) can be used to connect to a designated camera, acquire images of a standard checkerboard calibration board, select the VisionPro calibration tool CogCalibCheckerboard to calibrate the camera, select the calibration mode as Linear, the calibration board feature searcher as detailed checkerboard, the reference symbol as StandardRectangles, and the block size of the calibration board X and Y both set to 3mm. After capturing the image to be calibrated, the calibration model is used to preprocess the image to be calibrated to obtain a target image with a first target object and a second target object.
[0128] During the process of acquiring target images using a camera, the size and number of pixels of the target image are preset in the camera. Therefore, the size of the target image can be divided by the number of pixels to obtain the size of each pixel. Then, the number of pixels between the center of the first target object and the center of the second target object in the acquired target image is multiplied by the size of each pixel to obtain the distance between the center points of the first target object and the second target object.
[0129] The closer the distance between the center points of the first target and the second target, the higher the concentricity between them; the farther the distance between the center points of the first target and the second target, the lower the concentricity between them.
[0130] The concentricity determination method proposed in this disclosure has the following aspects: First, it uses an eight-directional gradient synthesis edge detection algorithm to perform eight-directional convolution on each first pixel, making the gradient magnitude of each first pixel more accurate, and the edge information extracted by the subsequent edge detection algorithm more comprehensive and accurate. Second, by setting a dynamic threshold, the dynamic threshold can change with the background brightness of the first pixel. The change of the dynamic threshold is more in line with the visual characteristics of the human eye. After comparing the gradient magnitude with the dynamic threshold, a suitable number of second pixels is obtained, avoiding the phenomenon of false edges caused by too many second pixels and edge discontinuity caused by too few second pixels. Third, by processing the second pixels with morphological erosion, the image edges formed by the second pixels can be filtered to remove some isolated light spots and false edges, making the obtained target pixels more accurate. Fourth, by fitting multiple accurate target pixels with the least squares method, a clearer and more accurate edge of the first target object can be obtained. The center of the first target object obtained based on the clear and accurate edge will be more accurate, and the accuracy of the final calculated concentricity will be higher.
[0131] In one possible implementation, the image to be processed can also be smoothed using a third convolution kernel to obtain the target image.
[0132] One-dimensional Gaussian function G(x,y) can be used to construct a filter, and convolution operations can be performed on the image to be processed f(x,y) in rows and columns respectively to obtain the target image I(x,y).
[0133] Specifically, the target image can be obtained using the following formula:
[0134]
[0135]
[0136] I(x,y)=[G(x)G(y)]*f(x,y) (23)
[0137] In formulas (21) to (23), σ is the standard deviation of the Gaussian function, which is used to control the smoothness of the output image, f(x,y) is the image to be processed, and I(x,y) is the target image.
[0138] After smoothing the image to be processed, the settings for the target image can make the pixel values of the pixels in the target image smoother.
[0139] In one possible implementation, please refer to Figure 7 The diagram shown illustrates the logic of the concentricity determination method, which includes the following steps:
[0140] In step S21, the lens (the second target object, such as a gemstone) is assembled with HAF glue (the first target object, such as HF glue).
[0141] Specifically, the gemstone feeding mechanism can be used first to transfer the gemstone to the assembly position, and the HAF adhesive feeding mechanism can be used to transfer the HF adhesive to the assembly position; then, the HAF adhesive bonding mechanism can be used to complete the assembly of the gemstone and the HAF adhesive. Please refer to [link to relevant documentation]. Figure 8 As shown, HF adhesive is evenly applied to the edge of the gemstone.
[0142] In step S22, the assembled camera takes pictures of the first target object and the second target object to obtain target images.
[0143] In step S23, based on the target image, the center of the first target object in the target image is fitted, and the concentricity between the center of the first target object and the center of the second target object is calculated.
[0144] In step S24, if the concentricity is less than a set value, the first target object and the second target object are packaged; if the concentricity is greater than or equal to the set value, the first target object and the second target object are rejected.
[0145] Specifically, if the concentricity is less than the set value, it indicates that the concentricity between the first target object and the second target object is high, and the quality of the produced product is good. At this time, the first target object and the second target object can be packaged. If the concentricity is greater than or equal to the set value, it indicates that the concentricity between the first target object and the second target object is low, and the quality of the produced product is poor. At this time, the first target object and the second target object can be discarded, and the first target object and the second target object can be photographed again.
[0146] Based on the same inventive concept, this disclosure proposes a concentricity determination device; please refer to [link to relevant documentation]. Figure 9 As shown, the concentricity determining device 120 includes:
[0147] The edge detection module 121 is configured to perform edge detection on the target image corresponding to the first target object using an eight-directional gradient synthesis edge detection algorithm to obtain the gradient magnitude of multiple first pixels of the first target object.
[0148] The second pixel point determination module 122 is configured to determine multiple second pixel points corresponding to multiple gradient magnitudes that are greater than a dynamic threshold from multiple gradient magnitudes.
[0149] The target pixel point determination module 123 is configured to perform morphological erosion processing on the plurality of second pixels to obtain a plurality of target pixels;
[0150] The fitting module 124 is configured to fit the plurality of target pixels using the least squares method to obtain the center of the first target object;
[0151] The concentricity determination module 125 is configured to determine the concentricity between the first target object and the second target object based on the distance between the centers of the first target object and the second target object.
[0152] Optionally, the edge detection module 121 includes:
[0153] The gradient determination module is configured to convolve the first pixel of the target image with the first convolution kernel to obtain the gradient of the first pixel in eight directions.
[0154] The gradient magnitude determination module is configured to determine the gradient magnitude of the first pixel based on the gradient of the first pixel in eight directions.
[0155] Optionally, the concentricity determining device 120 includes:
[0156] The first dynamic threshold determination module is configured to determine the dynamic threshold according to a first exponential function when the background brightness of the first pixel is above a first preset value and below a second preset value.
[0157] The second dynamic threshold determination module is configured to determine the dynamic threshold based on a cubic curve function when the background brightness of the first pixel is greater than a second preset value and less than a third preset value.
[0158] The third dynamic threshold determination module is configured to determine the dynamic threshold according to a second exponential function when the background brightness of the first pixel is above the third preset value.
[0159] Optionally, the target pixel determination module 123 includes:
[0160] The local minimum value determination module is configured to perform convolution on the image edge formed by the plurality of second pixels using a second convolution kernel to obtain the local minimum value among the plurality of second pixels covered by the second convolution kernel on the image edge;
[0161] The erosion module is configured to take the local minimum value among the plurality of second pixels as the plurality of target pixels.
[0162] Optionally, the fitting module 124 includes:
[0163] The center determination module is configured to take the center of the reference circle as the center of the first target object when the difference between the square of the first distance between the plurality of target pixels and the reference center and the square of the second distance between the reference radius of the reference circle is close to a first value.
[0164] Optionally, the concentricity determination module 125 includes:
[0165] The camera calibration module is configured to determine the size of each pixel through camera calibration;
[0166] The distance calculation module is configured to determine the distance between the centers of the first target object and the second target object based on the size of each pixel and the number of pixels that are spaced between the centers of the first target object and the second target object.
[0167] Optionally, the concentricity determining device 120 includes:
[0168] The smoothing module is configured to smooth the image to be processed using a third convolutional kernel to obtain the target image.
[0169] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0170] Figure 10 This is a block diagram illustrating an electronic device 700 according to an exemplary embodiment. Figure 10 As shown, the electronic device 700 may include a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.
[0171] The processor 701 controls the overall operation of the electronic device 700 to complete all or part of the steps in the concentricity determination method described above. The memory 702 stores various types of data to support the operation of the electronic device 700. This data may include, for example, instructions for any application or method operating on the electronic device 700, and application-related data such as contact data, sent and received messages, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 702 or transmitted via communication component 705. The audio component also includes at least one speaker for outputting audio signals. I / O interface 704 provides an interface between processor 701 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. Communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IoT, eMTC, or other 5G technologies, or combinations thereof, is not limited here. Therefore, the corresponding communication component 705 may include: a Wi-Fi module, a Bluetooth module, an NFC module, etc.
[0172] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the concentricity determination method described above.
[0173] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the concentricity determination method described above. For example, the computer-readable storage medium may be the memory 702 including the program instructions described above, which may be executed by the processor 701 of the electronic device 700 to complete the concentricity determination method described above.
[0174] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and all such simple modifications fall within the protection scope of this disclosure.
[0175] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0176] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A method for determining concentricity, characterized in that, The method includes: For the target image corresponding to the first target object, an edge detection algorithm with eight-directional gradient synthesis is used to detect the gradient magnitude of multiple first pixels of the first target object; wherein, the eight directions are 0°, 22.5°, 45°, 67.5°, 90°, 112.5°, 135° and 157.5°, and the convolution kernel used for detection is a 5×5 convolution kernel; From multiple gradient magnitudes, determine multiple second pixel points corresponding to multiple gradient magnitudes that are greater than the dynamic threshold; The plurality of second pixels are subjected to morphological erosion to obtain a plurality of target pixels; The center of the first target object is obtained by fitting the plurality of target pixels using the least squares method; The concentricity between the first target and the second target is determined based on the distance between their centers. The dynamic threshold is determined through the following steps: When the background brightness of the first pixel is above a first preset value and below a second preset value, the dynamic threshold is determined according to a first exponential function. When the background brightness of the first pixel is greater than the second preset value and less than the third preset value, the dynamic threshold is determined according to the cubic curve function. When the background brightness of the first pixel is above the third preset value, the dynamic threshold is determined according to the second exponential function.
2. The method according to claim 1, characterized in that, The target image corresponding to the first target object is detected using an eight-directional gradient synthesis edge detection algorithm to obtain the gradient magnitudes of multiple first pixels of the first target object, including: The first pixel of the target image is convolved with the first convolution kernel to obtain the gradient of the first pixel in eight directions; The gradient magnitude of the first pixel is determined based on the gradient of the first pixel in eight directions.
3. The method according to claim 1, characterized in that, The morphological erosion process applied to the plurality of second pixels to obtain a plurality of target pixels includes: The image edge formed by the plurality of second pixels is convolved by the second convolution kernel to obtain the local minimum value among the plurality of second pixels covered by the second convolution kernel on the image edge; The local minimum value among the plurality of second pixels is taken as the plurality of target pixels.
4. The method according to claim 1, characterized in that, The step of fitting the plurality of target pixels using the least squares method to obtain the center of the first target object includes: If the difference between the square of the first distance between the plurality of target pixels and the reference center and the square of the second distance between the reference radius of the reference circle and the reference center is close to a first value, the center of the reference circle is taken as the center of the first target object, wherein the reference circle is used to characterize the circular edge of the first target object.
5. The method according to claim 1, characterized in that, The distance between the centers of the first target and the second target is determined by the following steps: The size of each pixel is determined through camera calibration; The distance between the centers of the first target object and the second target object is determined based on the size of each pixel and the number of pixels that separate the centers of the first target object and the second target object.
6. The method according to claim 1, characterized in that, The target image is obtained through the following steps: The image to be processed is smoothed using a third convolution kernel to obtain the target image.
7. A concentricity determining device, characterized in that, The device includes: The edge detection module is configured to perform edge detection using an eight-directional gradient synthesis algorithm on the target image corresponding to the first target object, thereby obtaining the gradient magnitudes of multiple first pixels of the first target object; wherein the eight directions are 0°, 22.5°, 45°, 67.5°, 90°, 112.5°, 135° and 157.5°, and the convolution kernel used for detection is a 5×5 convolution kernel; The second pixel point determination module is configured to determine multiple second pixel points corresponding to multiple gradient magnitudes that are greater than a dynamic threshold from multiple gradient magnitudes. The target pixel point determination module is configured to perform morphological erosion processing on the plurality of second pixels to obtain a plurality of target pixels; The fitting module is configured to fit the plurality of target pixels using the least squares method to obtain the center of the first target object; The concentricity determination module is configured to determine the concentricity between the first target object and the second target object based on the distance between the centers of the first target object and the second target object; The first dynamic threshold determination module is configured to determine the dynamic threshold according to a first exponential function when the background brightness of the first pixel is above a first preset value and below a second preset value. The second dynamic threshold determination module is configured to determine the dynamic threshold based on a cubic curve function when the background brightness of the first pixel is greater than a second preset value and less than a third preset value. The third dynamic threshold determination module is configured to determine the dynamic threshold according to a second exponential function when the background brightness of the first pixel is above the third preset value.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method described in any one of claims 1-6.
9. An electronic device, characterized in that, include: A memory on which computer programs are stored; A processor for executing the computer program in the memory to implement the steps of the method according to any one of claims 1-6.