Laser ray center point extraction method and device, computer equipment and storage medium
By deeply analyzing the frequency domain properties and edge properties of laser line pictures, building a segmentation model and performing KMEANS clustering, combining the filtering core relationship of the steger algorithm, the problems of high noise and low accuracy of laser line extraction in the complex environment in the existing technology are solved, and high-precision and robust laser line center point extraction is achieved.
Patent Information
- Application Number
- CN202510365042.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-03-26
AI Technical Summary
In the three-dimensional reconstruction of online structured light, when detecting objects in complex environments, the existing laser line extraction methods lead to high noise and insufficient accuracy and robustness due to factors such as underwater refraction, background interference and object reflection.
By obtaining laser line pictures, analyzing its frequency domain and edge properties, building a segmentation model for laser frequency domain and edge information, generating a mask picture, using the KMEANS algorithm to divide the region and perform threshold segmentation, determining the optimal dividing point of the laser line width, and according to the relationship between the filter core and the laser line width of the steger algorithm, Gaussian filtering is used to use different convolution kernel sizes to finally extract the laser line center.
It significantly improves the accuracy and adaptability of the center point extraction of laser lines, enhances the precision and robustness of the processing results, and effectively improves the accuracy and efficiency of subsequent processing.
Smart Images

Figure CN119885909A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a laser line center point extraction method, device, computer equipment and storage medium. Background Art
[0002] In the 3D reconstruction of line structured light, accurate extraction of the center of the laser line is one of the key steps. However, when detecting objects in complex environments, due to factors such as underwater refraction, background interference, and object reflection, the noise is greatly increased. The existing laser line extraction method cannot achieve the ideal accuracy and robustness, which is significantly reflected in the laser-like noise. Summary of the invention
[0003] In order to solve the above technical problems, the present invention provides a method for extracting the center point of a laser line, which adopts the following technical solution, including: Get the laser line image; Analyzing the frequency domain properties and edge properties of the laser line image; Constructing a segmentation model for laser frequency domain and edge information, and processing the laser line image by using the segmentation model to obtain a mask image; According to the mask image, obtaining laser line width information; KMEANS is used to analyze the laser line width information by dividing the area, and threshold segmentation is performed to obtain the optimal dividing point of the laser line width; According to the optimal dividing point and the relationship between the filter kernel and the laser line width when Gaussian filtering is performed using the Steger algorithm, different convolution kernel sizes are used for different width areas in the laser line image, and then the laser line center is extracted according to the constraints of the mask image.
[0004] Preferably, the step of obtaining a laser line image specifically includes: Collect pictures of the scene illuminated by the laser line; The collected scene pictures are preprocessed.
[0005] Preferably, the step of analyzing the frequency domain properties and edge properties of the laser line image specifically includes: The laser line image is converted from the spatial domain to the frequency domain using a two-dimensional Fourier transform to obtain a frequency domain image, and a frequency domain analysis is performed to identify high-frequency and low-frequency components; An edge detection operator is applied to perform edge detection on the laser line image to identify edge points in the laser line image.
[0006] Preferably, the step of constructing a segmentation model for laser frequency domain and edge information, and processing the laser line image by the segmentation model to obtain a mask image specifically comprises: Extracting high-frequency components from the frequency domain image as high-frequency features, and extracting edge points from edge detection results as edge features; Constructing a segmentation model according to the extracted high-frequency features and edge features; The trained segmentation model is used to segment the original laser line image, and the segmentation result is binarized to obtain a mask image containing only the laser line.
[0007] Preferably, the step of obtaining laser line width information according to the mask image specifically includes: Scan the mask image line by line, and record the starting point and ending point of the laser line area in each line; According to the positions of the starting point and the ending point, the width of the laser line on each row is calculated; Store the calculated width information in array or matrix form.
[0008] Preferably, the step of using KMEANS to analyze the laser line width information by dividing the area and performing threshold segmentation to obtain the optimal dividing point of the laser line width specifically includes: The laser line width information is used as input data and the KMEANS algorithm is applied for clustering; Analyze the clustering results and determine the dividing point between different clusters as the threshold; The optimal cut-off point was determined by evaluating the stability and accuracy of the clustering results.
[0009] Preferably, according to the optimal demarcation point and the relationship between the filter kernel and the laser line width when Gaussian filtering is performed using the Steger algorithm, different convolution kernel sizes are used for different width areas in the laser line image, and then according to the constraints of the mask image, the step of extracting the laser line center specifically includes: Divide the laser line into areas of different widths according to the optimal dividing point; Apply a convolution kernel of corresponding size to the laser line image of each width area to perform Gaussian filtering to remove noise; Construct the Hessian matrix for the filtered image and calculate its eigenvalues and eigenvectors; Apply Taylor polynomial expansion to the pixel grayscale in the normal direction to obtain the grayscale distribution function; According to the mask image, only the center point in the laser line area is retained to extract the center of the laser line.
[0010] In order to solve the above technical problems, the present invention further provides a laser line center point extraction device, which adopts the following technical solution, including: Image acquisition module, used to acquire laser line images; An analysis module, used for analyzing the frequency domain properties and edge properties of the laser line image; A processing module, used for constructing a segmentation model for laser frequency domain and edge information, and processing the laser line image through the segmentation model to obtain a mask image; A width information acquisition module, used to obtain laser line width information according to the mask image; A threshold segmentation module is used to analyze the laser line width information by dividing the area using KMEANS, and perform threshold segmentation to obtain the optimal dividing point of the laser line width; The extraction module is used to use different convolution kernel sizes for different width areas in the laser line image according to the optimal demarcation point and the relationship between the filter kernel and the laser line width when Gaussian filtering is performed using the Steger algorithm, and then extract the laser line center according to the constraints of the mask image.
[0011] In order to solve the above technical problems, the present invention also provides a computer device, which adopts the technical solution described below, including a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the above-mentioned laser line center point extraction method when executing the computer-readable instructions.
[0012] In order to solve the above technical problems, the present invention also provides a computer-readable storage medium, which adopts the technical solution described below, and stores computer-readable instructions on the computer-readable storage medium. When the computer-readable instructions are executed by the processor, the steps of the above-mentioned laser line center point extraction method are implemented.
[0013] Compared with the prior art, the present invention mainly has the following beneficial effects: by acquiring a laser line image, the frequency domain properties and edge properties thereof are deeply analyzed, thereby laying a solid foundation for subsequent processing; by constructing a segmentation model for the laser frequency domain and edge information, the laser line image can be accurately processed to generate a high-quality mask image, thereby effectively improving the accuracy and efficiency of subsequent processing; the laser line width information is obtained by using the mask image, and the KMEANS algorithm is used for region division and threshold segmentation, thereby determining the optimal dividing point of the laser line width, significantly enhancing the precision and robustness of the processing result; according to the optimal dividing point and the relationship between the filter kernel and the laser line width in the Steger algorithm, this method uses different convolution kernel sizes for Gaussian filtering of regions of different widths, and extracts the laser line center in combination with the mask image constraint. This flexible and sophisticated processing method greatly improves the accuracy and adaptability of the laser line center point extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the scheme in the present invention, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0015] Figure 1 is an exemplary system architecture diagram in which the present invention can be applied; Figure 2 It is a structural schematic diagram of an embodiment of a laser line center point extraction device of the present invention; Figure 3 It is a schematic structural diagram of an embodiment of a computer device of the present invention. DETAILED DESCRIPTION
[0016] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present invention; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention; the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present invention or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0017] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0018] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.
[0019] It should be noted that the laser line center point extraction method provided in the embodiment of the present invention is generally executed by a server / terminal device, and accordingly, the laser line center point extraction device is generally arranged in the server / terminal device.
[0020] It should be understood that the number of terminal devices, networks and servers is only illustrative. Depending on the implementation requirements, there can be any number of terminal devices, networks and servers.
[0021] Embodiment 1: Please refer to Figure 1 , shows a flow chart of an embodiment of the laser line center point extraction method of the present invention. The laser line center point extraction method comprises the following steps: Step S1, obtaining a laser line image.
[0022] In this embodiment, the electronic device (e.g., server / terminal device) on which the laser line center point extraction method is running can receive the laser line center point extraction request through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAXX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0023] In this embodiment, step S1, obtaining a laser line image may specifically include the following steps: S11, collecting images of the scene illuminated by the laser line.
[0024] Ensure that the photographic equipment (such as a camera) has high resolution and low noise performance to clearly capture the details of the laser line and the background of the scene. Secondly, according to the color and brightness of the laser line, reasonably adjust the camera's white balance and exposure settings to avoid information loss due to overexposure or underexposure. Use a tripod to fix the camera to reduce blur caused by vibration and ensure image stability. When collecting, consider lighting conditions, such as the angle and intensity of natural light and the laser line. If necessary, use a lens hood to reduce stray light interference. Finally, use a remote shutter or timed shooting function to further reduce image quality degradation caused by human factors.
[0025] S12: pre-processing the collected scene images.
[0026] The main goals of preprocessing are to remove image noise, enhance target features, and simplify data.
[0027] Grayscale processing is performed to convert the color image into a grayscale image to reduce the amount of calculation and increase the processing speed. This step can be achieved through the component method, maximum method, average method or weighted average method, among which the weighted average method is often used because of the human eye's sensitivity to color.
[0028] Geometric transformation is applied to correct systematic and random errors in the image and ensure the spatial accuracy of the image.
[0029] Image enhancement techniques, such as smoothing and sharpening algorithms in the spatial domain method, or low-pass and high-pass filters in the frequency domain method, are used to highlight the features of the laser line and suppress background noise.
[0030] Step S2, analyzing the frequency domain properties and edge properties of the laser line image.
[0031] In this embodiment, step S2, analyzing the frequency domain properties and edge properties of the laser line image may specifically include the following steps: S21. Use two-dimensional Fourier transform to convert the laser line image from the spatial domain to the frequency domain, obtain a frequency domain image, perform frequency domain analysis, and identify high-frequency and low-frequency components.
[0032] High-frequency components usually correspond to edges and details of the image, while low-frequency components correspond to smooth areas of the image.
[0033] The image is converted to the frequency domain through the two-dimensional Fourier transform, which can be realized by the fast Fourier transform (FFT) algorithm to convert the gray distribution function of the image into a frequency distribution function. The frequency domain image obtained after the conversion, that is, the spectrum, reflects the distribution of each frequency component in the image.
[0034] On the spectrogram, high-frequency components usually appear as bright spots, corresponding to areas of rapid change in the image, such as edges and details; while low-frequency components appear as darker or uniform areas, corresponding to smooth or slowly changing parts of the image. By visually inspecting the spectrogram, the specific distribution of high-frequency and low-frequency components can be identified.
[0035] Furthermore, the frequency domain image can be processed using a high-pass or low-pass filter to highlight or suppress specific frequency components, thereby achieving the purpose of image enhancement, denoising or feature extraction.
[0036] In specific implementation, three separately trained network channels (left, middle, and right) can be used to combine the networks, respectively acquiring and fusing information from the edge of the laser line image, the frequency domain, and the original laser image. In the convolutional architecture, the horizontal connection between each two layers uses a double convolution structure, and in the vertical connection between layers, the stacking at the channel and the use of The convolutions are fused while keeping the width and height information unchanged.
[0037] The processing method of the left channel in the network is to process the laser edge information. The difference from Gated-SCNN is that the edge information here is directly input into the edge auxiliary channel of the network as the input at the edge layer, which is equivalent to artificially designing a fixed-function network layer before the input layer to identify edge information and insert it into the main channel for information exchange. It serves as an auxiliary enhancement to identify laser features in the overall network. Due to the unique edge information of the laser and the high light intensity of the laser line, in most scenarios, after edge extraction of the laser line image, the laser information can be significantly displayed. There is a big difference between the edge information of the laser stripe center and the edge information of the reflected noise around the laser due to the influence of the strong laser and the strong light noise in the general environment. The edge information of the laser can be effectively used to enhance the network's integration and judgment of laser features.
[0038] The right channel of the network is the frequency domain processing channel, and the input layer of the network is designed as a high-pass filter with multiple filter intervals. Because when analyzing the laser line in the frequency domain, it is found that the laser line mainly manifests high-frequency properties in the frequency domain, while the noise under ambient light or reflection mainly manifests low-frequency properties.
[0039] Therefore, in the input layer, the input image is first subjected to Fourier transform to convert the original image information from the spatial domain to the frequency domain. After Fourier transformation of the grayscale image, four different filter intervals are randomly selected for high-pass filtering. Each filter interval consists of five random filter centers and filter radii. Compared with the traditional single filter interval, this method can use the network to extract the characteristics of the laser in each filter interval, which is more generalized and accurate, and solves the problem of narrow applicability of a single filter radius and inaccurate target setting. During training, the size of the filter radius in each round is random, and during evaluation, the filter radius size is fixed to 20 for evaluation to determine the stability during use.
[0040] The processed image is now a spectrum diagram at the noise-removed frequency. By performing an inverse Fourier transform on the spectrum diagram at this time, an image after a certain amount of noise is removed in the spatial domain can be obtained.
[0041] In the frequency domain input layer of the network, we use The matrix expands the dimensions of the four images, superimposes them on the channels, inputs them to the next layer, and performs the same convolution operation with the network channel of the edge information to ensure that the dimensions are the same when they are integrated into the main channel.
[0042] The middle channel is the main channel of the network. The output dimension of each layer is twice the dimension of the left and right layers. The edge layer network channel and the frequency domain layer network channel are integrated into the main channel through the middle confluence layer. After separate and unified convolution, the result is output.
[0043] Taking into account the small amount of laser data and the difficulty of data collection diversity, the main effects of transfer learning and data enhancement were actually used during training. The laser line images were randomly rotated, cut, and reversed to increase the diversity of data. At the same time, random spots were artificially generated into the laser image to increase the diversity of noise. The dice function and the weighted cross entropy function were set as loss functions. Considering that the proportion of lasers is extremely small, in order to prevent the foreground segmentation effect from being poor due to the large background, the annealing algorithm and the weighted cross entropy loss were combined to initially give the foreground a large weight for training. While using transfer learning, the data set was gradually updated while the weight of the foreground was reduced. Finally, the model parameters at the end of training were obtained and laser line segmentation was performed.
[0044] In the specific implementation, most laser line images have high precision and require timely extraction. Therefore, the image is compressed to half of the original image at the input of the network, which effectively improves the running speed of the model.
[0045] S22, applying an edge detection operator to perform edge detection on the laser line image, and identifying edge points in the laser line image.
[0046] Edge detection operators include first-order differential operators such as Sobel, Prewitt, Robert, etc., and second-order differential operators such as Laplacian and Kirsch, etc. These operators detect edges by calculating the derivative or second-order derivative of the image gray value.
[0047] In view of the characteristics of laser line images, the Canny operator can be used first because it can find the best balance between noise resistance and precise positioning. The Canny operator removes noise through Gaussian filtering, calculates the gradient using the Sobel operator, and then performs non-maximum suppression and double threshold screening to obtain an accurate edge image.
[0048] In the implementation process, the laser line image must be converted into a grayscale image first, and then the Canny operator is applied for edge detection. By adjusting the parameters of the operator, such as the standard deviation of the Gaussian filter, the step size of the gradient calculation, and the size of the double threshold, the effect of edge detection can be optimized, thereby accurately identifying the edge points in the laser line image.
[0049] Step S3, constructing a segmentation model for laser frequency domain and edge information, and processing the laser line image through the segmentation model to obtain a mask image.
[0050] In this embodiment, step S3, constructing a segmentation model for laser frequency domain and edge information, and processing the laser line image by the segmentation model to obtain a mask image may specifically include the following steps: S31. Extract high-frequency components from the frequency domain image as high-frequency features, and extract edge points from the edge detection result as edge features.
[0051] In the frequency domain image, high-frequency components correspond to the details and edges in the image, which are located outside the center of the spectrum. By designing filters to selectively retain these high-frequency components and performing an inverse Fourier transform on them, high-frequency feature images can be reconstructed in the spatial domain.
[0052] The extraction of edge features depends on edge detection algorithms, such as the Canny operator or the Sobel operator. These algorithms are based on the calculation of image gradients and can identify locations in the image where the brightness changes dramatically, namely edge points. By setting a suitable threshold, significant edge points can be screened out and used as edge features. These edge features are of great significance for tasks such as image understanding and object recognition because they can concisely describe the main structure and shape information in the image.
[0053] S32. Construct a segmentation model based on the extracted high-frequency features and edge features.
[0054] The extracted high-frequency features and edge features are used as input to build a segmentation model. The segmentation model can use a classifier based on machine learning, such as support vector machine (SVM) or random forest. These classifiers can effectively distinguish between laser line areas and non-laser line areas by learning the distribution rules of different categories in the feature space.
[0055] Deep learning models, especially convolutional neural networks (CNNs), are also powerful tools for building segmentation models. Through multi-layer convolution and pooling operations, CNNs can automatically extract hierarchical features in images and train on large amounts of data to obtain highly accurate classification capabilities. In the task of extracting the center point of a laser line, a specific CNN architecture can be designed to take high-frequency features and edge features as input, and finally output a binary image of the laser line area through layer-by-layer convolution and pooling.
[0056] The segmentation model is trained to distinguish between laser line areas and non-laser line areas.
[0057] By combining high-frequency features and edge features and selecting a machine learning or deep learning model for training, an efficient and accurate laser line center point extraction and segmentation model can be constructed.
[0058] S33. Use the trained segmentation model to segment the original laser line image, binarize the segmentation result, and obtain a mask image containing only the laser lines.
[0059] During the segmentation process, the original laser line image is first input into the segmentation model. In specific implementation, the pre-processed original laser line image can also be compressed to half of the original image and divided into two images, one as the original image input and the other as edge information input into the segmentation model.
[0060] The segmentation model classifies each pixel in the image as being part of a laser line, a process that relies on the model’s learned feature representation and classification capabilities.
[0061] In order to improve the accuracy and efficiency of segmentation, the segmentation model can also use methods such as hole convolution and multi-scale feature fusion to capture richer image features and better identify laser lines.
[0062] After completing the pixel-level classification, the model generates a segmentation mask in which parts of the laser line are marked with a specific value, while other parts are marked as background or other categories. Through this segmentation mask, the precise position and shape of the laser line can be easily extracted.
[0063] Binarize the segmentation results. Binarization is the process of converting an image to contain only two pixel values (usually 0 and 255), that is, converting the image to a black and white image. In this process, you can choose the global threshold method or the adaptive threshold method to determine the threshold for pixel value conversion. The global threshold method is suitable for situations where the background is relatively uniform, while the adaptive threshold method can better handle images with complex backgrounds or uneven lighting.
[0064] Through binarization, a mask image containing only the laser lines is obtained. This mask image can be used as the key input for extracting the center point of the laser line in subsequent processing, thereby further improving the accuracy and efficiency of extraction.
[0065] During specific implementation, the Lanczos interpolation algorithm may also be used to restore the output mask image.
[0066] In order to meet the timeliness of code operation, the network model was compressed while ensuring accuracy. However, when faced with high-precision input images, there is still a problem with the running speed. Therefore, before inputting the image into the segmentation model, the image is compressed once, so that the width and height of the image are compressed to half of the original image. , In order to make the mask image have the same dimensions as the original image, the output image needs to be enlarged. Here, Lanczos interpolation is used to restore the image. First, establish the Lanczos kernel function and use The area is taken as the kernel size.
[0067] (1) For each point in the new image, take this point as the center of the region and construct a weight matrix based on the kernel function.
[0068] (2) in, and The value is taken as the relative offset position from the center of the region. The new image corresponds to the ideal point of the original image. When the image is enlarged twice, the mapping relationship between the actual point on the enlarged image and the point on the original image is: (3) is the original point on the enlarged image. From formula (3), we can see that It may not be an integer, so for non-integer The pixel value of a point is calculated using the weighted average method.
[0069] This can be used to obtain the image effect after interpolation processing. By comparing the original image with the image restored by interpolation, the image visual effect is the same, and the information of the laser line can be displayed without distortion.
[0070] Step S4, obtaining laser line width information according to the mask image.
[0071] In this embodiment, step S4, obtaining the laser line width information according to the mask image may specifically include the following steps: S41, scanning the mask image line by line, and recording the starting point and the ending point of the laser line area in each line.
[0072] The mask image has removed most of the redundant information and highlighted the laser line stripes. Start the line-by-line scanning program, starting from the first line of the mask image and scanning down line by line.
[0073] During the scanning process, the image analysis algorithm is used to detect the starting and ending points of the laser line area in each row by comparing the pixel grayscale value or color difference. When a pixel point in a row is scanned and its grayscale value or color characteristics meet the characteristics of the laser line stripe, it is recorded as the starting point. Continue scanning the row, and when a pixel point that does not meet the characteristics of the laser line stripe is encountered again, it is recorded as the ending point.
[0074] In order to ensure the accuracy of extraction, sub-pixel level image processing methods, such as Gaussian fitting, can be used to further determine the specific positions of the starting point and the end point. At the same time, in order to avoid the influence of noise and interference, the mask image can be filtered and smoothed before scanning.
[0075] By scanning line by line and recording the starting and ending points of the laser line area in each line, a reliable data basis can be provided for subsequent center point extraction and laser line fringe analysis.
[0076] S42. Calculate the width of the laser line on each row according to the positions of the starting point and the ending point.
[0077] The image is binarized or thresholded by setting a threshold to distinguish the laser line from the background. This step helps to clearly define the starting and ending points of the laser line.
[0078] For each row of pixels, the continuous pixel sequences whose grayscale values exceed the preset threshold are traversed and identified. The starting and ending positions of these sequences correspond to the left and right boundaries of the laser line in the row.
[0079] The pixel distance between the left and right boundaries is calculated as the width of the laser line on that row. In order to improve the accuracy of the calculation, the boundary position can be finely adjusted by using interpolation or sub-pixel level analysis methods.
[0080] In addition, considering that laser lines may be distorted or discontinuous due to various factors (such as surface characteristics of the object, lighting conditions, etc.), filtering and smoothing can be performed when calculating the width to reduce noise interference and ensure the stability and reliability of the results.
[0081] S43. Store the calculated width information in array or matrix form.
[0082] To store this width information, a two-dimensional array or matrix can be created whose dimensions match the size of the original image. Then, the processed image data is traversed, and the laser line width value corresponding to each pixel or pixel block is assigned to the element at the corresponding position in the two-dimensional array or matrix.
[0083] In specific implementation, you can use lists in programming languages such as Python or arrays in the NumPy library to easily create and manipulate this two-dimensional data structure. For example, in Python, you can first create an empty list, then use nested loops to traverse the image data and add the width values to the corresponding positions in the list one by one. Or you can use the NumPy library to directly create an array of a specified size and assign the width value to the array element through indexing operations.
[0084] Step S5, using KMEANS to analyze the laser line width information by dividing the area, and performing threshold segmentation to obtain the optimal dividing point of the laser line width.
[0085] In this embodiment, step S5, using KMEANS to analyze the laser line width information by dividing the area, and performing threshold segmentation to obtain the optimal demarcation point of the laser line width may specifically include the following steps: S51. Use the laser line width information as input data and apply the KMEANS algorithm for clustering.
[0086] The laser line width information is used as input and the KMEANS algorithm is applied for clustering. The KMEANS algorithm is an unsupervised learning clustering algorithm that can divide the data in the data set into different categories or clusters. In this step, the algorithm randomly selects k initial cluster centers, then calculates the distance from each pixel to these cluster centers and assigns it to the cluster with the closest distance. Subsequently, the algorithm recalculates the cluster center of each cluster, that is, takes the average value of all data points in the cluster as the new cluster center. This process is repeated until the cluster center no longer changes or the preset number of iterations is reached.
[0087] Through KMEANS clustering, the pixels on the laser line can be divided into different regions, each corresponding to a cluster center. These cluster centers can be regarded as representative points of different width regions on the laser line. Finally, the center point position of the laser line can be determined by further processing these cluster centers, such as calculating their average or median. This method can fully consider the width information of the laser line and improve the accuracy and robustness of center point extraction. Select an appropriate number of clusters (such as 2 or 3) to obtain the clustering results.
[0088] S52, analyzing the clustering results, and determining the dividing point between different clusters as a threshold.
[0089] The clustering quality is evaluated by indicators such as silhouette coefficient and Calinski-Harabasz Index to ensure good clustering effect. On this basis, the feature differences between different clusters are analyzed to determine the dividing points between them. These dividing points usually correspond to the transition points between the laser line and the non-laser line area in the image, so they can be used as thresholds for extracting the center points of the laser lines.
[0090] According to the determined threshold, the image is binarized or threshold segmented to accurately extract the center point of the laser line. This method combines the accuracy of cluster analysis and the uniqueness of laser line features, which can significantly improve the accuracy and efficiency of laser line center point extraction.
[0091] The laser line is divided into regions of different widths according to the threshold.
[0092] S53. Determine the optimal dividing point by evaluating the stability and accuracy of the clustering results.
[0093] The optimal dividing point refers to the boundary value or boundary condition that can most accurately and stably divide data points into different categories during the clustering process.
[0094] During the clustering process, the stability and accuracy of the clustering results need to be constantly evaluated. Stability can be measured by running the clustering algorithm multiple times and comparing the consistency of the results; accuracy can be evaluated by comparing with the actual labels (if any) or using internal evaluation indicators (such as silhouette coefficient, Calinski-Harabasz index, etc.).
[0095] Based on the evaluation results of stability and accuracy, the optimal cutoff point is determined. This cutoff point may be a specific value or a boundary condition that can most effectively divide the data points into different categories, thereby accurately extracting the center point of the laser line. This process requires comprehensive consideration of multiple factors, including the characteristics of the data, the choice of clustering algorithm, and the applicability of the evaluation index.
[0096] Step S6, according to the optimal demarcation point and the relationship between the filter kernel and the laser line width when using the Steger algorithm for Gaussian filtering, different convolution kernel sizes are used for different width areas in the laser line image, and then the laser line center is extracted according to the constraints of the mask image.
[0097] In this embodiment, step S6, according to the optimal demarcation point and the relationship between the filter kernel and the laser line width when the Steger algorithm is used for Gaussian filtering, different convolution kernel sizes are used for different width areas in the laser line image, and then according to the constraints of the mask image, the center of the laser line is extracted, which specifically includes the following steps: S61. Divide the laser line into regions of different widths according to the optimal dividing point.
[0098] For each width region, select the appropriate convolution kernel size based on the relationship between the laser line width and the Gaussian filter kernel size. For narrower laser lines, a smaller filter kernel can be selected to avoid edge blurring caused by oversmoothing; for wider laser lines, a larger filter kernel can be selected to better suppress noise and preserve the overall shape of the light strip. The width of the laser line can be set according to actual conditions. When selecting the filter kernel, the image noise should also be considered, and the size and standard deviation of the filter kernel should be appropriately adjusted to achieve the best filtering effect.
[0099] In order to achieve more accurate extraction, an adaptive filtering method can also be used, that is, dynamically adjusting the size and parameters of the filter kernel according to the local characteristics of each pixel point. This method can further improve the extraction accuracy of the laser line center point.
[0100] S62, applying a convolution kernel of a corresponding size to the laser line image of each width area to perform Gaussian filtering to remove noise.
[0101] Gaussian filtering is a linear smoothing filter suitable for removing Gaussian noise. Its principle is to smooth the image by calculating the weighted average of surrounding pixels. According to the width and area characteristics of the laser line image, select the appropriate convolution kernel size. The size of the convolution kernel is usually proportional to the width of the laser line to ensure that the filtering effect can effectively remove noise and keep the detailed characteristics of the laser line as much as possible.
[0102] The laser line image is convolved using a convolution kernel of a selected size. The convolution operation involves sliding the convolution kernel over the image and calculating the sum of the products of the pixel values in the area covered by the convolution kernel and the convolution kernel weight to obtain a new pixel value. In Gaussian filtering, the weight distribution of the convolution kernel follows a Gaussian function, that is, the center weight is the largest and the edge weight gradually decreases, which helps to preserve edge information while smoothing the image.
[0103] Through this step, the noise in the laser line image is effectively suppressed, providing a clearer and more accurate image basis for subsequent center point extraction.
[0104] S63. Construct a Hessian matrix for the filtered image and calculate its eigenvalues and eigenvectors.
[0105] Construct the Hessian matrix. In a two-dimensional image, each pixel has a 2x2 Hessian matrix whose elements consist of the second-order partial derivatives of the image at that point in the x and y directions. These partial derivatives reflect the rate of change of the image grayscale value near that point.
[0106] After obtaining the Hessian matrix, its eigenvalues and eigenvectors are calculated. The eigenvalue represents the rate of change of the image grayscale value in the direction of the eigenvector. In the context of light strip center extraction, the eigenvector corresponding to the maximum eigenvalue usually represents the normal direction of the light strip. This is because the grayscale value at the center of the light strip is the largest, and when leaving the center along the normal direction, the grayscale value gradually decreases, forming a shape similar to a Gaussian distribution.
[0107] By calculating the eigenvalues and eigenvectors of the Hessian matrix, the normal direction of the light strip can be determined, and this provides a basis for subsequently applying Taylor polynomial expansion in the normal direction to locate the sub-pixel position of the center of the light strip.
[0108] S64. Apply Taylor polynomial expansion to the pixel grayscale in the normal direction to obtain a grayscale distribution function.
[0109] The eigenvalues and eigenvectors of each pixel in the image are calculated through the Hessian matrix, where the eigenvector corresponding to the maximum eigenvalue is regarded as the normal direction of the point. In the determined normal direction, the pixel grayscale value is expanded by Taylor polynomial. This expansion process actually approximates the grayscale distribution function in this direction as a polynomial function to facilitate subsequent calculations and analysis.
[0110] In specific implementation, the Taylor polynomial can be expanded to the second order or higher to improve the accuracy of the approximation. After expansion, the coordinates of the center point of the light bar in the normal direction can be determined by solving the extreme points of the polynomial function. The implementation of this step depends on the accurate calculation of the Taylor polynomial expansion and the effective solution of the extreme points.
[0111] S65. According to the mask image, only the center point in the laser line area is retained to extract the center of the laser line.
[0112] The mask image is used to crop or mask the original image, retaining only the pixel information in the laser line area. This can be achieved by comparing the mask image with the original image pixel by pixel, and only when the corresponding pixel value in the mask image is true (that is, indicating that the pixel belongs to the laser line area), the information of the pixel in the original image is retained.
[0113] In the cropped image area, a center extraction algorithm is applied. This can be based on grayscale gradient, extremum method, grayscale centroid method or more advanced algorithms such as Steger algorithm, which determines the normal direction of the light stripe by constructing the Hessian matrix and finding the extremum point in the normal direction to get the sub-pixel position of the light stripe center.
[0114] Through the verification and screening steps, it is ensured that the extracted center point is within the laser line area and meets certain accuracy and continuity requirements.
[0115] Through the above steps, the goal of retaining only the center point in the laser line area according to the mask image can be achieved.
[0116] The implementation of this embodiment has the following beneficial effects: by acquiring a laser line image, the frequency domain properties and edge properties thereof are deeply analyzed, thereby laying a solid foundation for subsequent processing; by constructing a segmentation model for the laser frequency domain and edge information, the laser line image can be accurately processed to generate a high-quality mask image, thereby effectively improving the accuracy and efficiency of subsequent processing; the laser line width information is acquired using the mask image, and the KMEANS algorithm is used for region division and threshold segmentation, thereby determining the optimal dividing point of the laser line width, thereby significantly enhancing the precision and robustness of the processing result; according to the optimal dividing point and the relationship between the filter kernel and the laser line width in the Steger algorithm, this method uses different convolution kernel sizes for Gaussian filtering of regions of different widths, and extracts the laser line center in combination with the mask image constraints. This flexible and sophisticated processing method greatly improves the accuracy and adaptability of the laser line center point extraction.
[0117] The present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0118] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0119] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0120] Embodiment 2: Further references Figure 2 , as a response to the above Figure 1 The present invention provides an embodiment of a laser line center point extraction device, and the device embodiment is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0121] like Figure 2 As shown, the laser line center point extraction device 70 of this embodiment includes: an image acquisition module 71, an analysis module 72, a processing module 73, a width information acquisition module 74, a threshold segmentation module 75 and an extraction module 76. Among them: An image acquisition module 71 is used to acquire a laser line image; An analysis module 72, for analyzing the frequency domain properties and edge properties of the laser line image; The processing module 73 is used to construct a segmentation model for the laser frequency domain and edge information, and to process the laser line image through the segmentation model to obtain a mask image; A width information acquisition module 74 is used to obtain laser line width information according to the mask image; The threshold segmentation module 75 is used to analyze the laser line width information by dividing the area using KMEANS, and perform threshold segmentation to obtain the optimal dividing point of the laser line width; The extraction module 76 is used to use different convolution kernel sizes for different width areas in the laser line image according to the optimal demarcation point and the relationship between the filter kernel and the laser line width when using the Steger algorithm for Gaussian filtering, and then extract the laser line center according to the constraints of the mask image.
[0122] The implementation of this embodiment has the following beneficial effects: by acquiring a laser line image, the frequency domain properties and edge properties thereof are deeply analyzed, thereby laying a solid foundation for subsequent processing; by constructing a segmentation model for the laser frequency domain and edge information, the laser line image can be accurately processed to generate a high-quality mask image, thereby effectively improving the accuracy and efficiency of subsequent processing; the laser line width information is acquired using the mask image, and the KMEANS algorithm is used for region division and threshold segmentation, thereby determining the optimal dividing point of the laser line width, thereby significantly enhancing the precision and robustness of the processing result; according to the optimal dividing point and the relationship between the filter kernel and the laser line width in the Steger algorithm, this method uses different convolution kernel sizes for Gaussian filtering of regions of different widths, and extracts the laser line center in combination with the mask image constraints. This flexible and sophisticated processing method greatly improves the accuracy and adaptability of the laser line center point extraction.
[0123] Embodiment three: To solve the above technical problems, the embodiment of the present invention also provides a computer device. Figure 3 , Figure 3 This is a basic structural block diagram of the computer device in this embodiment.
[0124] The above-mentioned computer device 8 includes a memory 81, a processor 82, and a network interface 83 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 8 having components of a memory 81, a processor 82, and a network interface 83, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a programmable gate array (FPGA), a digital processor (DSP), an embedded device, etc.
[0125] The computer device may be a desktop computer, a notebook computer, a PDA, a cloud server, etc. The computer device may interact with the user through a keyboard, a mouse, a remote control, a touch pad, or a voice control device.
[0126] The memory 81 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 81 may be an internal storage unit of the computer device 8, such as a hard disk or memory of the computer device 8. In other embodiments, the memory 81 may also be an external storage device of the computer device 8, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the computer device 8. Of course, the memory 81 may also include both the internal storage unit of the computer device 8 and its external storage device. In this embodiment, the memory 81 is generally used to store the operating system and various application software installed on the computer device 8, such as computer-readable instructions of the laser line center point extraction method, etc. In addition, the memory 81 can also be used to temporarily store various types of data that have been output or are to be output.
[0127] In some embodiments, the processor 82 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 82 is generally used to control the overall operation of the computer device 8. In this embodiment, the processor 82 is used to run the computer-readable instructions stored in the memory 81 or process data, such as running the computer-readable instructions of the laser line center point extraction method.
[0128] The network interface 83 may include a wireless network interface or a wired network interface. The network interface 83 is generally used to establish a communication connection between the computer device 8 and other electronic devices.
[0129] The implementation of this embodiment has the following beneficial effects: by acquiring a laser line image, the frequency domain properties and edge properties thereof are deeply analyzed, thereby laying a solid foundation for subsequent processing; by constructing a segmentation model for the laser frequency domain and edge information, the laser line image can be accurately processed to generate a high-quality mask image, thereby effectively improving the accuracy and efficiency of subsequent processing; the laser line width information is acquired using the mask image, and the KMEANS algorithm is used for region division and threshold segmentation, thereby determining the optimal dividing point of the laser line width, thereby significantly enhancing the precision and robustness of the processing result; according to the optimal dividing point and the relationship between the filter kernel and the laser line width in the Steger algorithm, this method uses different convolution kernel sizes for Gaussian filtering of regions of different widths, and extracts the laser line center in combination with the mask image constraints. This flexible and sophisticated processing method greatly improves the accuracy and adaptability of the laser line center point extraction.
[0130] Embodiment 4: The present invention also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the laser line center point extraction method as described above.
[0131] The implementation of this embodiment has the following beneficial effects: by acquiring a laser line image, the frequency domain properties and edge properties thereof are deeply analyzed, thereby laying a solid foundation for subsequent processing; by constructing a segmentation model for the laser frequency domain and edge information, the laser line image can be accurately processed to generate a high-quality mask image, thereby effectively improving the accuracy and efficiency of subsequent processing; the laser line width information is acquired using the mask image, and the KMEANS algorithm is used for region division and threshold segmentation, thereby determining the optimal dividing point of the laser line width, thereby significantly enhancing the precision and robustness of the processing result; according to the optimal dividing point and the relationship between the filter kernel and the laser line width in the Steger algorithm, this method uses different convolution kernel sizes for Gaussian filtering of regions of different widths, and extracts the laser line center in combination with the mask image constraints. This flexible and sophisticated processing method greatly improves the accuracy and adaptability of the laser line center point extraction.
[0132] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the various embodiment methods of the present invention.
[0133] Obviously, the embodiments described above are only some embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the accompanying drawings, but they do not limit the patent scope of the present invention. The present invention can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific embodiments, or to perform equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of the present invention, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present invention.
Claims
1. A method for extracting the center point of a laser line, characterized in that: The steps include: Get the laser line image; Analyzing the frequency domain properties and edge properties of the laser line image; Constructing a segmentation model for laser frequency domain and edge information, and processing the laser line image by using the segmentation model to obtain a mask image; According to the mask image, obtaining laser line width information; KMEANS is used to analyze the laser line width information by dividing the area, and threshold segmentation is performed to obtain the optimal dividing point of the laser line width; According to the optimal dividing point and the relationship between the filter kernel and the laser line width when Gaussian filtering is performed using the Steger algorithm, different convolution kernel sizes are used for different width areas in the laser line image, and then the laser line center is extracted according to the constraints of the mask image.
2. The method for extracting the center point of a laser line according to claim 1, characterized in that: The step of obtaining the laser line image specifically includes: Collect pictures of the scene illuminated by the laser line; The collected scene pictures are preprocessed.
3. The method for extracting the center point of a laser line according to claim 1, characterized in that: The step of analyzing the frequency domain properties and edge properties of the laser line image specifically includes: The laser line image is converted from the spatial domain to the frequency domain using a two-dimensional Fourier transform to obtain a frequency domain image, and a frequency domain analysis is performed to identify high-frequency and low-frequency components; An edge detection operator is applied to perform edge detection on the laser line image to identify edge points in the laser line image.
4. The method for extracting the center point of a laser line according to claim 3, characterized in that: The step of constructing a segmentation model for laser frequency domain and edge information, and processing the laser line image by using the segmentation model to obtain a mask image specifically includes: Extracting high-frequency components from the frequency domain image as high-frequency features, and extracting edge points from edge detection results as edge features; Constructing a segmentation model according to the extracted high-frequency features and edge features; The trained segmentation model is used to segment the original laser line image, and the segmentation result is binarized to obtain a mask image containing only the laser line.
5. The method for extracting the center point of a laser line according to claim 4, characterized in that: The step of obtaining the laser line width information according to the mask image specifically includes: Scan the mask image line by line, and record the starting point and ending point of the laser line area in each line; According to the positions of the starting point and the ending point, the width of the laser line on each row is calculated; Store the calculated width information in array or matrix form.
6. The method for extracting the center point of a laser line according to claim 5, characterized in that: The step of using KMEANS to analyze the laser line width information by dividing the area and performing threshold segmentation to obtain the optimal dividing point of the laser line width specifically includes: The laser line width information is used as input data and the KMEANS algorithm is applied for clustering; Analyze the clustering results and determine the dividing point between different clusters as the threshold; The optimal cut-off point was determined by evaluating the stability and accuracy of the clustering results.
7. The method for extracting the center point of a laser line according to claim 6, characterized in that: According to the optimal demarcation point and the relationship between the filter kernel and the laser line width when the Steger algorithm is used for Gaussian filtering, in the laser line image, different convolution kernel sizes are used for different width areas, and then according to the constraints of the mask image, the step of extracting the laser line center specifically includes: Divide the laser line into areas of different widths according to the optimal dividing point; Apply a convolution kernel of corresponding size to the laser line image of each width area to perform Gaussian filtering to remove noise; Construct the Hessian matrix for the filtered image and calculate its eigenvalues and eigenvectors; Apply Taylor polynomial expansion to the pixel grayscale in the normal direction to obtain the grayscale distribution function; According to the mask image, only the center point in the laser line area is retained to extract the center of the laser line.
8. A laser line center point extraction device, characterized in that: include: Image acquisition module, used to acquire laser line images; An analysis module, used for analyzing the frequency domain properties and edge properties of the laser line image; A processing module, used for constructing a segmentation model for laser frequency domain and edge information, and processing the laser line image through the segmentation model to obtain a mask image; A width information acquisition module, used to obtain laser line width information according to the mask image; A threshold segmentation module is used to analyze the laser line width information by dividing the area using KMEANS, and perform threshold segmentation to obtain the optimal dividing point of the laser line width; The extraction module is used to use different convolution kernel sizes for different width areas in the laser line image according to the optimal demarcation point and the relationship between the filter kernel and the laser line width when Gaussian filtering is performed using the Steger algorithm, and then extract the laser line center according to the constraints of the mask image.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the laser line center point extraction method according to any one of claims 1 to 7 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the laser line center point extraction method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
High-precision sub-pixel extraction method for centers of light bars of structured light
CN105931232A
Laser ray extraction method and system based on deep learning
CN113628170A
Industrial detection multi-line laser light stripe center line extraction method
CN117237433A
Improved structured light center point extraction method based on unilateral tracking
CN119068009A
Weld joint feature recognition and path extraction method based on line laser measurement
CN119458374A