Motor shaft surface light bar center extraction device and method
By combining the grayscale weighting method of geometric center method and the grayscale center of gravity method, the surface of the motor shaft is refined and extracted, solving the problem of large error in the extraction result caused by uneven and discontinuous light strips, and achieving high-precision center extraction of the light strips under different ambient lights.
Patent Information
- Application Number
- CN202411938735.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-18
AI Technical Summary
In the prior art, when extracting the center of the light strip on the surface of the motor shaft, there is a problem that the extraction result error is large due to the uneven and discontinuous light of the light strips, and poor adaptability under different ambient lights.
The grayscale weighting method combining geometric center method and grayscale center of gravity method is adopted to refine the frame of the light bar profile through mathematical morphological operations. The center of the light bar is extracted by the improved grayscale center of gravity method in the direction of the frame normal, and the geometric center method is used to extract the center of the light bar profile for grayscale weighting correction to obtain stable light bar center coordinates.
The algorithm's adaptability under different ambient light is improved, the adverse effects of uneven and discontinuous light strips are overcome, and the high-precision extraction of the center of the light strip is achieved, meeting the accuracy requirements of three-dimensional reconstruction measurement.
Smart Images

Figure CN119850706A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a device and method for extracting the center of a light strip on the surface of a motor shaft. Background Art
[0002] The motor shaft in the motor has the functions of bearing the weight of rotating parts, transmitting motion, and bearing torque. Its radial runout and other geometric errors and dimensional errors directly determine the mechanical properties and output characteristics of the motor. Therefore, high-precision measurement of geometric dimensions such as the shaft diameter and radial runout and other geometric errors of the motor shaft is of great significance.
[0003] At present, the line structured light 3D reconstruction measurement system is widely used due to its advantages of non-contact, high precision and fast measurement. In the online structured light 3D reconstruction measurement system, a straight line laser is projected on the surface of the motor shaft to be measured, the surface light stripe image is collected, and the center of the light stripe image is extracted. The principle of triangulation is used to convert the center coordinates of the light stripe in the light stripe image into high-precision 3D coordinates on the surface of the motor shaft. After data processing and model reconstruction, the relevant dimensions of the motor shaft can be obtained. Therefore, the extraction of the center line of the light stripe is a key step in obtaining the three-dimensional information of the object, which directly affects the final measurement results. Since the surface of the motor shaft is smooth and there may be a step structure, it is easy to produce high reflection, uneven reflection, interference light strips, and bending light strips when projecting the line laser, which makes the light stripe center extraction line fluctuate greatly, resulting in interference results. It is necessary to use an appropriate light stripe center extraction algorithm for center extraction.
[0004] Traditional methods for extracting the center of structured light stripes can be divided into two categories: the geometric center method and the energy center method. The geometric center method mainly includes the threshold method, and the energy center method mainly includes the extreme value method, grayscale center method, fitting method, Steger method and directional template method. At present, the process of extracting the center of light stripes mainly uses the Steger algorithm and the grayscale center method. The Steger algorithm has high extraction accuracy, but the amount of calculation is huge; the grayscale center method greatly improves real-time performance at the expense of a certain degree of accuracy, but it is greatly affected by the changes and discontinuities of the light stripes, and has low accuracy.
[0005] Patent 202010609360.7 proposes a light strip center extraction algorithm based on the Steger method. On the basis of using the Steger algorithm to extract the center coordinates of the light strip, a weighted graph structure of each center point is introduced at the end of the light strip to screen the redundant extraction results, which effectively solves the problem of bifurcation noise that appears at the end of the light strip center when the Steger method is used to extract the light strip. The accuracy of the algorithm is improved, but this method does not solve the problems of the Steger method being time-consuming and the presence of breakpoints in the extraction of uneven light strips.
[0006] Patent 202010999750.X proposes a light stripe center extraction algorithm based on the principal component analysis method. The principal component analysis method is used to calculate the light stripe normal vector within the K-neighborhood of a central point of the light strip skeleton, and Gaussian fitting is used in the normal direction to calculate the sub-pixel center coordinates. This improves the center extraction accuracy of light strips with large changes in curvature and width, but it still requires multiple refinement iterations, with a large amount of calculation, and does not solve the problem that the fitting center point result is affected by the uneven grayscale distribution and has large errors.
[0007] Patent 202010034498.9 proposes an improved grayscale centroid method, which uses a one-dimensional template method to extract the center point of the rough light strip, and uses the grayscale centroid method to calculate the sub-pixel coordinates in its normal direction, thereby improving the center extraction accuracy of the grayscale centroid method. However, when the light strip defect is large, the extraction result error is large.
[0008] In 2014, LI et al. published a method for extracting the center coordinates of laser stripes based on multi-scale analysis in the journal Acta Optica Sinica. The paper proposed a method for extracting the center of laser stripes based on multi-scale analysis. However, when extracting the center of the stripes, it is necessary to perform Gaussian fitting on the grayscale distribution of the stripe cross section, which has low computational efficiency. In 2020, Yang Yi et al. published a method for extracting the center line of structured light based on a quadratic smoothing algorithm in the journal Laser and Optoelectronics Progress. The paper proposed a stripe center extraction algorithm based on a quadratic smoothing algorithm. The mean method and Savitzky-Golay filtering algorithm were used to smooth the extraction results of the grayscale centroid method, which improved the extraction accuracy of the center line. However, when the stripe defects are large and the stripes are discontinuous, the extraction results still fluctuate greatly.
[0009] To address the problem of large extraction error caused by missing light stripes, interfering light stripes, and discontinuous light stripes, the grayscale centroid method is improved, the light stripe outline is skeletonized using mathematical morphological operations, and the light stripe center is extracted using the grayscale centroid method in the skeleton normal direction. In order to reduce the fluctuation caused by missing light stripes and improve the accuracy of centerline extraction, a grayscale weighted method combining the geometric center method and the grayscale centroid method is proposed to obtain high-precision light stripe center coordinates. Summary of the invention
[0010] The present invention is to solve the problems existing in the above-mentioned prior art and provide a device and method for extracting the center of the light strip on the surface of a motor shaft. The present invention improves the adaptability of the algorithm under different ambient light conditions, can overcome the adverse effects caused by uneven and discontinuous light strips, stably extract the center of the light strip, and meet the accuracy requirements of three-dimensional reconstruction measurement.
[0011] The technical solutions adopted in the present invention are:
[0012] A method for extracting the center of a light stripe on a motor shaft surface comprises the following steps:
[0013] S1: Acquire light stripe images of the motor shaft under different ambient light and different angles, and perform preprocessing operations on the light stripe images;
[0014] S2: Use mathematical morphological corrosion and expansion operations to refine the light stripe image and extract the light stripe skeleton;
[0015] S3: Improve the grayscale centroid method to extract the center coordinates of the light strip;
[0016] S4: Use the geometric center method to extract the center of the light strip contour, perform weighted averaging on the extraction results of the geometric center method and the improved grayscale centroid method according to the grayscale value relationship, correct the coordinates with abnormal grayscale values, and obtain stable light strip center coordinates.
[0017] Furthermore, in S1, the preprocessing operation includes:
[0018] 1) Using pixel operations to process the light stripe image, pre-processing is performed on the area where the interfering light stripe is located in the light stripe image by setting the pixel value to "0" to remove the interfering light stripe;
[0019] 2) Process the filtered image using threshold method;
[0020] 3) Use morphological opening operation to process the image and perform convolution operation on the light strip image to remove small noise points and holes in the image and avoid the light strip from breaking;
[0021] 4) Using median filtering for filtering;
[0022] 5) Extract the ROI area of the light strip image.
[0023] Furthermore, when the threshold method is used to process the filtered image, the set segmentation threshold threshold is used as the segmentation boundary between the light bar body and the background in the light bar image to remove background interference. The specific formula is as follows:
[0024]
[0025] Among them, I a is the gray value of the highest peak of the gray histogram, I b is the maximum gray value of the grayscale histogram.
[0026] Furthermore, in S2, the defined convolution kernel E2 is used to perform an erosion operation on the light strip image as a whole, and then an expansion operation is performed. The specific formula is as follows:
[0027]
[0028] Among them, F(x,y) is the original light stripe image;
[0029] F'(x, y) is the light stripe image after the corrosion operation. If the convolution kernel E2 is completely contained in the light stripe area in F(x, y), then the light stripe area in the light stripe image F'(x, y) is composed of the center point z1 of the convolution kernel E2.
[0030] H(x,y) is the light stripe image after the dilation operation. If the midpoint element z2 of the convolution kernel E2 is contained in F'(x,y), then the light stripe area in the light stripe image H(x,y) is composed of the points in the entire E2.
[0031] Subtract the current dilation result from the original light stripe image to get the skeletonization result of the current iteration. The specific formula is as follows:
[0032] S2(x,y)=G(x,y)-S1(x,y)
[0033] Among them, S2(x,y) is the skeletonized image of the current iteration process, G(x,y) is the original light stripe image, and S1(x,y) is the light stripe image after the expansion operation;
[0034] Perform a logical OR operation on the skeletonization result of the current iteration and the skeletonization result of the previous iteration, and add the skeleton of each iteration to the final skeleton image. The specific formula is as follows:
[0035] S(x,y)=S′(x,y)∨S2(x,y)
[0036] Wherein, S(x, y) is the skeletonized image result formed by all iterative processes up to the current iteration, S′(x, y) is the skeletonized image formed by all iterative processes up to the previous iteration, and S2(x, y) is the skeletonized image of the current iterative process;
[0037] Repeat the above process to find the maximum pixel value H in the image after each iteration max , if H max =0, the skeletonization process is completed;
[0038] The skeleton is post-processed, and the specific formula is as follows:
[0039]
[0040] in, is the ordinate value at point (i0, j0), is the pixel value at point (i0, j0), is the sum of the ordinates of all points whose pixel values are not 0 when the abscissa is i0, Indicates the number of points whose pixel value is not 0 when the horizontal coordinate is i0.
[0041] Furthermore, it is characterized in that: in S3, the improved grayscale centroid method includes:
[0042] The light strip skeleton is used as the initial center for grayscale centroid extraction;
[0043] Use the least squares method to fit the light strip skeleton and calculate the normal direction of the light strip skeleton The normal direction is used as the extraction direction of the grayscale centroid method.
[0044] Furthermore, a set of points with equal distance and number on both sides of the light strip skeleton is extracted in the normal direction, and points with abnormally small gray values are removed. The improved grayscale centroid method is used to extract the center coordinates of the light strip on this point set. The specific formula is as follows:
[0045]
[0046]
[0047] Among them, i h , j h are the horizontal and vertical coordinates of the grayscale centroid extraction center, and S is the grayscale centroid extraction point set.
[0048] Furthermore, in S4, the geometric center method is used to extract the center of the light stripe contour from the light stripe image. The specific formula is as follows:
[0049]
[0050] Among them, (i1, j1) and (i2, j2) are the coordinates of the first and last points in each column whose pixel values are 255, respectively. g ,j g ) are the initial center coordinates obtained by the geometric center method;
[0051] The grayscale weighted average of the center coordinates of the light stripe contour extracted by the geometric center method and the center coordinates of the light stripe contour extracted by the improved grayscale centroid method is performed. The weight of the two extraction results is determined by the percentage of the grayscale value of the extracted center point. The specific formula is as follows:
[0052]
[0053] i p =i g *Q g +i h *Q h
[0054] j p =j g *Q g +j h *Q h
[0055] Among them, Q g , Q h are the weights of the extraction results of the geometric center method and the improved grayscale centroid method, respectively. p , j p They are respectively the horizontal and vertical coordinates of the center extracted after grayscale weighted averaging.
[0056] The invention also discloses a device for extracting the center of the light strip on the surface of a motor shaft, comprising:
[0057] A line laser, which is used to emit a light strip toward the surface of the motor shaft to be tested;
[0058] An industrial camera, which can move in three axes, X, Y, and Z, and is used to capture light strips on the surface of the motor shaft to be tested;
[0059] The rotary clamping mechanism is used to fix the motor shaft to be tested and can drive the motor shaft to be tested to rotate along its axial direction.
[0060] Furthermore, a light source for fill light is also provided on one side of the motor shaft to be tested.
[0061] The present invention has the following beneficial effects:
[0062] The present invention utilizes image pixel operation, threshold segmentation and other operations to remove interfering light strips and background; utilizes median filtering to obtain the complete outline of the light strip, eliminates the discontinuity of the light strip area and the noise points existing on the outlines on both sides; utilizes morphological refinement operation to obtain the light strip skeleton, performs screening based on the grayscale value near the skeleton to reduce the influence caused by the high grayscale value of points near the light strip in a bright environment, extracts equidistant point sets in the skeleton normal direction, and calculates the center coordinates using the grayscale centroid method; utilizes the geometric center method to calculate the center of the light strip outline and performs grayscale weighted correction to eliminate the fluctuation error of the center point caused by the light strip defects, thereby realizing high-precision extraction of the light strip center. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 This is a physical diagram of the present invention.
[0064] Figure 2 It is a structural schematic diagram of the present invention.
[0065] Figure 3 This is a physical picture of the motor shaft used in the experiment.
[0066] Figure 4 It is a scene image at a certain angle.
[0067] Figure 5 The present invention is a flowchart for implementing the method.
[0068] Figure 6This is the pre-processing light strip image.
[0069] Figure 7 This is a light strip image collected in a dimly lit environment.
[0070] Figure 8 This is a light stripe image collected in a brighter lighting environment.
[0071] Fig. 9 These are light strip images collected at different angles.
[0072] Fig.10a This is a partial enlargement of the effect of traditional grayscale centroid method extraction in a dark lighting environment.
[0073] Fig.10b This is a partial enlargement of the extraction effect of the traditional Steger algorithm in a dark lighting environment.
[0074] Fig.10c This is a locally enlarged image of the extraction effect based on the quadratic smoothing algorithm in a dark lighting environment.
[0075] Fig.10d This is a locally enlarged image of the extraction effect of the proposed algorithm in a dark lighting environment.
[0076] Fig.11a This is a partial enlargement of the effect of traditional grayscale centroid method extraction in a bright lighting environment.
[0077] Fig.11b This is a partial enlargement of the extraction effect of the traditional Steger algorithm in a bright lighting environment.
[0078] Fig.11c This is a locally enlarged image of the extraction effect based on the quadratic smoothing algorithm in a brighter lighting environment.
[0079] Fig.11d This is a locally enlarged image of the extraction effect of the proposed algorithm in a brighter lighting environment. DETAILED DESCRIPTION
[0080] The present invention will be further described below in conjunction with the accompanying drawings.
[0081] like Figure 1 and Figure 2 In order to achieve high-precision extraction of the center of a light stripe image on a part surface, the present invention discloses a device for extracting the center of a light stripe on a motor shaft surface, which includes a straight-line laser 1, an industrial camera 2, a light source 4, an experimental platform 5 and a three-axis moving platform 6.
[0082] A straight line laser is used to emit a light strip onto the surface of the motor shaft 3 to be tested. The industrial camera 2 is arranged on a three-axis mobile platform 6. The three-axis mobile platform 6 is an electric lead screw mechanism that can realize three-dimensional motion. It drives the industrial camera 2 to move in the X, Y, and Z directions. The industrial camera 2 is used to shoot the light strip on the surface of the motor shaft to be tested.
[0083] A rotating clamping mechanism is provided on the experimental platform 5, which includes a motor and two rotatable ejectors, one of which is fixed in position and the other can be horizontally displaced. The motor shaft 3 to be tested is coaxially fixed between the two ejectors. The motor drives the ejector with a fixed position to rotate, and finally drives the motor shaft to be tested to rotate along its axial direction.
[0084] The motor shaft used in the experiment is as follows Figure 3 As shown, the total length is 93.5mm. The thicker step shaft is 78mm long and 10mm in diameter; the thinner step shaft is 15.5mm long and 8mm in diameter. The experimental results are as follows: Figure 4 The flow chart of the light strip center extraction method is shown in Figure 5 As shown, the specific implementation steps are as follows:
[0085] (1) Perform preprocessing on the image to remove image noise and extract the light strip ROI area. The preprocessing effect is as follows: Figure 6 shown.
[0086] In the preprocessing stage, pixel operations are used to process the light stripe image and remove interfering light stripes. The coordinates of a pixel in the light stripe image are set to (i, j), the gray value of the point is I(i, j), and the minimum vertical coordinate value of the interfering light stripe position is row0, that is, when j>row0-1, let I(i, j)=0.
[0087] The threshold method is used to process the filtered image, and the set segmentation threshold threshold is used as the segmentation boundary between the light stripe body and the background in the light stripe image.
[0088] The image is processed using morphological opening operations, and the convolution kernel E1 is selected with a size of 5 × 5. The light strip image is convolved to remove small noise points and holes in the image, while preventing the light strip from breaking.
[0089] Median filtering is used for filtering, and the size of the filter window S is set to 29 × 29 according to the filtering effect. The interference area is eliminated while protecting the edge of the light strip.
[0090] Extract the ROI area of the image. According to the light stripe image size of 5472×3648 pixels, set the small window size to 456×304 pixels, divide the image into 12×12 small windows, and select the part with the maximum gray value of 255 in each window as the light stripe ROI area. The specific formula is as follows:
[0091]
[0092] Among them, I a is the gray value at the highest peak of the gray histogram, that is, the gray value with the highest frequency in the image, I b It is the maximum gray value appearing in the grayscale histogram, that is, the maximum gray value in the image.
[0093] (2) Using mathematical morphological operations, the dilation-erosion method is used to extract the light strip skeleton.
[0094] Define a convolution kernel E2 with a value of 1 and a size of 3×3. Use the defined convolution kernel E2 to perform an erosion operation on the entire image, and then perform an expansion operation. The specific formula is as follows:
[0095]
[0096] Among them, F(x,y) is the original light stripe image;
[0097] F'(x, y) is the light stripe image after the corrosion operation. If the convolution kernel E2 is completely contained in the light stripe area in F(x, y), then the light stripe area in the light stripe image F'(x, y) is composed of the center point z1 of the convolution kernel E2.
[0098] H(x,y) is the light stripe image after the dilation operation. If the midpoint element z2 of the convolution kernel E2 is contained in F'(x,y), then the light stripe area in the light stripe image H(x,y) is composed of the points in the entire E2.
[0099] Subtract the current dilation result from the original light strip image to get the skeletonization result of the current iteration. The specific formula is as follows:
[0100] S2(x,y)=G(x,y)-S1(x,y)
[0101] Among them, S2(x, y) is the skeletonized image of the current iteration process, G(x, y) is the original light stripe image, and S1(x, y) is the light stripe image after the expansion operation.
[0102] Perform a logical OR operation on the skeletonization result of the current iteration and the skeletonization result of the previous iteration, and add the skeleton of each iteration to the final light strip skeleton image. The specific formula is as follows:
[0103] S(x,y)=S′(x,y)∨S2(x,y)
[0104] Among them, S(x,y) is the skeletonized image result formed by all iterative processes up to the current iteration, S′(x,y) is the skeletonized image formed by all iterative processes up to the previous iteration, and S2(x,y) is the skeletonized image of the current iterative process. Save the eroded image for the next iteration.
[0105] Repeat the above steps to find the maximum pixel value H in the image after each iteration max , if H max =0, the skeletonization process is completed.
[0106] The skeleton is post-processed, and the specific formula is as follows:
[0107]
[0108] in, is the ordinate value at point (i0, j0), is the pixel value at point (i0, j0), is the sum of the ordinates of all points whose pixel values are not 0 when the abscissa is i0, Indicates the number of points whose pixel value is not 0 when the horizontal coordinate is i0.
[0109] (3) Use the light strip skeleton as the initial center for grayscale centroid extraction. Use the least squares method to fit the light strip skeleton and calculate the normal direction of the light strip skeleton. The normal direction is used as the extraction direction of the grayscale centroid method.
[0110] Set the maximum gray value in the normal direction to G max , extract a set of points with a number of m and an interval of l on both sides of the skeleton, and select the points with gray values between [G max -g,G max ] points (g is generally 10 to 20) to reduce the error caused by light stripe defects. The grayscale centroid method is used to extract the light stripe center with high precision. The specific formula is as follows:
[0111]
[0112] Among them, i h , j h are the horizontal and vertical coordinates of the grayscale centroid extraction center, S is the grayscale centroid extraction point set,
[0113] (4) The geometric center method is used to extract the light stripe center of the preprocessed light stripe image. The specific formula is as follows:
[0114]
[0115] Among them, (i1, j1) and (i2, j2) are the coordinates of the first and last points in each column whose pixel values are 255, respectively. g ,j g ) are the initial center coordinates obtained by the geometric center method.
[0116] The grayscale weighted average of the light strip center coordinates extracted by the geometric center method and the light strip center coordinates extracted by the improved grayscale centroid method is as follows:
[0117]
[0118] i p =i g *Q g +i h *Q h
[0119] j p =j g *Q g +j h *Q h
[0120] Among them, Q g , Q h are the weights of the extraction results of the geometric center method and the improved grayscale centroid method, respectively. p , j p They are respectively the horizontal and vertical coordinates of the center extracted after grayscale weighted averaging.
[0121] In order to verify the effectiveness of the method of the present invention, light stripe images collected under different ambient light conditions and 5 light stripe images collected at different angles are used as experimental objects. Figure 7 , Figure 8 As shown in Figure 2, 5 light strip images collected at different angles are shown in Figure 2. Fig. 9 As shown in Table 1. The traditional grayscale centroid method, Steger algorithm, light stripe center extraction algorithm based on quadratic smoothing algorithm and the proposed algorithm are used to perform light stripe center extraction experiments. All experiments are deployed on a standard computer with an Intel(R) Core(TM) i7-13700H CPU and 16G memory. The programming language is C++ and the experimental environment is VisualStudio 2017. The experimental images are collected by a Hikvision industrial camera with model MV-CS200-10UM and a dual telecentric lens with a lens model of M150-04XMPW. The specific parameters are shown in Tables 1 and 2. The image size is 5472×3648 pixels. The line laser light source is a line laser with model HW650AB100-16GD-WLD.
[0122] Table 1 Main parameters of the camera
[0123]
[0124] Table 2 Main parameters of the lens
[0125]
[0126] (1) In order to verify the center extraction effect of the proposed algorithm under different ambient light conditions, the traditional grayscale centroid method, Steger algorithm, light stripe center extraction algorithm based on quadratic smoothing algorithm and the proposed algorithm are used to extract the center of the light stripe. Figure 7 , Figure 8 The center extraction experiment is performed on the light strip images under bright and dark ambient light. The extraction results of different algorithms in dark environment are shown in Figure 10, and the extraction results of different algorithms in bright environment are shown in Figure 11.
[0127] As shown in Figures 10(a2) and (a3), in a dark environment, the center point position obtained by the grayscale centroid method fluctuates greatly, and the center line error extracted in areas with large changes in direction and curvature is large; as shown in Figures 10(b1) and (b2), the extraction results of the traditional Steger algorithm have many light bar outer points, which need to be eliminated by the curve fitting method in the later stage; the extraction results based on the quadratic smoothing algorithm are relatively stable, and the extraction effect is better in areas with fewer light bar defects, as shown in Figure 10(c1), but in areas with more light bar defects, the extraction results still fluctuate greatly. When the grayscale centroid method extracts the center point of the uneven light bar, the extraction center will deviate from the theoretical center, making the overall extraction result biased upward, as shown in Figure 10(c3); in contrast, as shown in Figures 10(d1), (d2), and (d3), the proposed method uses the grayscale centroid method to extract the center point coordinates in the direction of the skeleton normal, and combines the center point coordinates obtained by the geometric center method under the complete outline of the light bar to correct it, reducing the impact of the uneven distribution of the grayscale value of the light bar, and the extracted center line is smoother and closer to the center of the light bar. As shown in Figure 11, in bright environments, the extraction results of the traditional algorithm fluctuate. By comparing Figure 11 (a1), (a2), (b1), (b2), (c1), (c2) with Figure 10 (a1), (a2), (b1), (b2), (c1), (c2), the grayscale centroid method, the Steger algorithm, and the light strip center extraction algorithm based on the secondary smoothing algorithm are affected by the background on the light strip, and the fluctuation of the extracted center line is larger than that in dark environments. In Figure 11 (c3), it can be clearly found that the center line extraction result of the light strip center extraction algorithm based on the secondary smoothing algorithm is generally biased to the top of the light strip. In contrast, as shown in Figure 10 (d2), (d3) and Figure 11 (d2), (d3), under the change of ambient light, the algorithm in this paper is less affected by the surrounding interference points and the missing of the middle light strip area. The extracted center line can still change with the light strip contour curve and is close to the center of the overall grayscale distribution of the light strip.
[0128] (2) In order to verify the accuracy and efficiency of the proposed algorithm in extracting the center of the light strip, this experiment calculates the distance error between the extracted center point and the average value of all points, uses the root mean square error as the standard for measuring the accuracy of the algorithm, and converts the calculated standard deviation to obtain the accuracy ratio of each algorithm. The specific formula is as follows:
[0129]
[0130] Where n is the number of points extracted, is the average value of all point coordinates. If the root mean square error of the algorithm is large, it means that the accuracy of the measurement result is low and the light strip center extraction is relatively inaccurate; on the contrary, if the root mean square error is small, it means that the light strip center extraction is relatively accurate.
[0131] The calculated standard deviation is converted to obtain the accuracy ratio of each algorithm.
[0132]
[0133] Among them, m is the number of all algorithms, Error i To calculate the root mean square error of each algorithm. If the accuracy ratio of the algorithm is small, it means that the accuracy of the measurement result is low and the light strip center extraction is relatively inaccurate; on the contrary, if the accuracy ratio is large, it means that the light strip center extraction is relatively accurate.
[0134] In order to better reflect the actual size accuracy of the center extracted by each algorithm, the actual physical size of a single pixel is calculated according to the resolution and field of view of the industrial camera used. The actual size accuracy of each algorithm is obtained by combining the root mean square error of each algorithm. The calculation formula is as follows:
[0135]
[0136] Among them, Accuracy is the actual accuracy of the center extracted by each algorithm, FOV is the field of view of the camera in the length or width direction, and Resolution is the resolution corresponding to the length or width direction of the camera. For example, the field of view of the industrial camera used in the length direction and the corresponding resolution in the length direction are 5472 pixels.
[0137] The calculation formula for the camera's long-direction field of view is as follows:
[0138]
[0139] Where L is the sensor size in the long direction and β(x) is the lens magnification.
[0140] Four different algorithms are compared to conduct center extraction experiments on five light stripe images collected at different angles. The root mean square error of the light stripe center line extracted by each algorithm is shown in Table 1, the accuracy ratio of the light stripe center line extracted by each algorithm is shown in Table 2, and the running time of each algorithm for extracting the light stripe center line is shown in Table 3.
[0141] Table 1
[0142]
[0143]
[0144] Table 2
[0145]
[0146] Table 3
[0147]
[0148] As shown in Table 1 and Table 2, the root mean square error and accuracy ratio of the light strip centerline extracted by the algorithm in this paper are 1.298 pixels and 37.4% respectively, which are 1.020 pixels and 16.4% higher than the extraction results of the traditional grayscale centroid method; 5.849 pixels and 30.6% higher than the Steger algorithm; 0.099 pixels and 2.6% higher than the light strip center extraction algorithm based on the secondary smoothing algorithm. The light strip image used in this experiment is collected within a field of view of 32 mm in the horizontal direction, and the image resolution is 5472 pixels in the horizontal direction. Through calculation, it is found that the actual size accuracy of the algorithm in this paper can reach 0.008 mm, and the extraction accuracy can meet the needs of the actual industrial application environment.
[0149] It can be seen from Table 3 that under the same operating environment, the traditional grayscale centroid method takes an average of 8.079s, the Steger algorithm takes an average of 8.551s, the light stripe center extraction algorithm based on the secondary smoothing algorithm takes an average of 13.958s, and the average running time of the proposed method is 7.186s. Under the same processing environment, it is faster than the other three algorithms.
[0150] The above description is only a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements without departing from the principle of the present invention, and these improvements should also be regarded as within the protection scope of the present invention.
Claims
1. A method for extracting the center of a light stripe on the surface of a motor shaft, characterized in that: The following steps are involved: S1: Acquire light stripe images of the motor shaft under different ambient light and different angles, and perform preprocessing operations on the light stripe images; S2: Use mathematical morphological corrosion and expansion operations to refine the light stripe image and extract the light stripe skeleton; S3: Improve the grayscale centroid method to extract the center coordinates of the light strip; S4: Use the geometric center method to extract the center of the light strip contour, perform weighted averaging on the extraction results of the geometric center method and the improved grayscale centroid method according to the grayscale value relationship, correct the coordinates with abnormal grayscale values, and obtain stable light strip center coordinates.
2. The method for extracting the center of the light stripe on the surface of the motor shaft according to claim 1, characterized in that: In S1, the preprocessing operations include: 1) Using pixel operations to process the light stripe image, pre-processing is performed on the area where the interfering light stripe is located in the light stripe image by setting the pixel value to "0" to remove the interfering light stripe; 2) Process the filtered image using threshold method; 3) Use morphological opening operation to process the image and perform convolution operation on the light strip image to remove small noise points and holes in the image and avoid the breakage of the light strip; 4) Using median filtering for filtering; 5) Extract the ROI area of the light strip image.
3. The method for extracting the center of the light stripe on the surface of the motor shaft according to claim 2, characterized in that: When the threshold method is used to process the filtered image, the set segmentation threshold is used as the segmentation boundary between the light strip body and the background in the light strip image to remove background interference. The specific formula is as follows: Among them, I a is the gray value of the highest peak of the gray histogram, I b is the maximum gray value of the grayscale histogram.
4. The method for extracting the center of the motor shaft surface light stripe according to claim 1, characterized in that: In S2, the defined convolution kernel E2 is used to perform an erosion operation on the light strip image as a whole, and then an expansion operation is performed. The specific formula is as follows: Among them, F(x,y) is the original light stripe image; F'(x, y) is the light stripe image after the corrosion operation. If the convolution kernel E2 is completely contained in the light stripe area in F(x, y), then the light stripe area in the light stripe image F'(x, y) is composed of the center point z1 of the convolution kernel E2. H(x,y) is the light stripe image after the dilation operation. If the midpoint element z2 of the convolution kernel E2 is contained in F'(x,y), then the light stripe area in the light stripe image H(x,y) is composed of the points in the entire E2. Subtract the current dilation result from the original light stripe image to get the skeletonization result of the current iteration. The specific formula is as follows: S2(x,y)=G(x,y)-S1(x,y) Among them, S2(x,y) is the skeletonized image of the current iteration process, G(x,y) is the original light stripe image, and S1(x,y) is the light stripe image after the expansion operation; Perform a logical OR operation on the skeletonization result of the current iteration and the skeletonization result of the previous iteration, and add the skeleton of each iteration to the final skeleton image. The specific formula is as follows: S(x,y)=S′(x,y)∨S2(x,y) Wherein, S(x, y) is the skeletonized image result formed by all iterative processes up to the current iteration, S′(x, y) is the skeletonized image formed by all iterative processes up to the previous iteration, and S2(x, y) is the skeletonized image of the current iterative process; Repeat the above process to find the maximum pixel value H in the image after each iteration max , if H max =0, the skeletonization process is completed; The skeleton is post-processed, and the specific formula is as follows: in, is the ordinate value at point (i0, j0), is the pixel value at point (i0, j0), is the sum of the ordinates of all points whose pixel values are not 0 when the abscissa is i0, Indicates the number of points whose pixel value is not 0 when the horizontal coordinate is i0.
5. The method for extracting the center of the light stripe on the surface of the motor shaft according to claim 1, characterized in that: In S3, the improved grayscale centroid method includes: The light strip skeleton is used as the initial center for grayscale centroid extraction; Use the least squares method to fit the light strip skeleton and calculate the normal direction of the light strip skeleton The normal direction is used as the extraction direction of the grayscale centroid method.
6. The method for extracting the center of the light stripe on the surface of the motor shaft according to claim 5, characterized in that: In the normal direction, we extract the points of equal distance and quantity on both sides of the light strip skeleton, and remove the points with abnormally small gray values. We use the improved gray scale centroid method to extract the center coordinates of the light strip on this point set. The specific formula is as follows: Among them, i h , j h are the horizontal and vertical coordinates of the grayscale centroid extraction center, and S is the grayscale centroid extraction point set.
7. The method for extracting the center of the light stripe on the surface of the motor shaft according to claim 1, characterized in that: In S4, the geometric center method is used to extract the center of the light stripe contour from the light stripe image. The specific formula is as follows: Among them, (i1, j1) and (i2, j2) are the coordinates of the first and last points in each column whose pixel values are 255, respectively. g ,j g ) are the initial center coordinates obtained by the geometric center method; The grayscale weighted average of the center coordinates of the light stripe contour extracted by the geometric center method and the center coordinates of the light stripe contour extracted by the improved grayscale centroid method is performed. The weight of the two extraction results is determined by the percentage of the grayscale value of the extracted center point. The specific formula is as follows: i p =i g *Q g +i h *Q h j p =j g *Q g +j h *Q h Among them, Q g , Q h are the weights of the extraction results of the geometric center method and the improved grayscale centroid method, respectively. p , j p They are respectively the horizontal and vertical coordinates of the center extracted after grayscale weighted averaging.
8. The device for extracting the center of the motor shaft surface light stripe according to claim 1, characterized in that: include A line laser (1), the line laser being used to emit a light strip toward the surface of a motor shaft (3) to be tested; An industrial camera (2), wherein the industrial camera (2) can be moved in three axes, namely, X, Y, and Z, and the industrial camera (2) is used to photograph light strips on the surface of the motor shaft to be tested; A rotary clamping mechanism is used to fix the motor shaft (3) to be tested and can drive the motor shaft to be tested to rotate along its axial direction.
9. The device for extracting the center of the light stripe on the surface of the motor shaft according to claim 8, characterized in that: A light source (4) for supplementary light is also provided on one side of the motor shaft (3) to be tested.
Citation Information
Patent Citations
Line structured light center extraction method and system
CN111260708A
Light bar center extraction method
CN111784725A
Light bar center extraction method for non-contact measurement of line structured light
CN112241964A