Light stripe center extraction method and device, electronic equipment and storage medium
By calculating the bar width and the Gaussian template library to determine the target Gaussian template and convolutional processing of the image, the calculation complexity of the Steger algorithm in large-scale data and real-time application scenarios is solved, and efficient bar center extraction is achieved.
Patent Information
- Application Number
- CN202510197546.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-07-18
AI Technical Summary
In the prior art, the Steger algorithm has high computational complexity in large-scale data and real-time application scenarios, resulting in slow processing speed and cannot meet the needs of efficient processing.
By calculating the width of the light bar, determining the target Gaussian template based on the width of the light bar and the preset Gaussian template library, the image is convolutional processing, and the Heisen matrix is obtained, and the pixel points on the center line of the image are determined based on the Heisen matrix.
It greatly shortens the extraction time of the center of the light bar, while maintaining high-precision calculation results, meeting the application needs of real-time processing and high-precision.
Smart Images

Figure CN120339359A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical fields of computer vision and image processing, and particularly relates to a method, apparatus, electronic device and storage medium for extracting the center of a light stripe. Background Art
[0002] The extraction of the center of a light stripe is an important research topic in the fields of computer vision and image processing, and is widely applied in multiple fields such as three-dimensional reconstruction, laser scanning, medical imaging, industrial inspection, etc. The goal of extracting the center of a light stripe is to accurately determine the position of its geometric center line from the light stripe image, which is crucial for subsequent analysis and modeling.
[0003] In the prior art, a variety of algorithms can be used to achieve high-precision extraction of the center of a light stripe. For example, a center extraction algorithm based on gradient, an algorithm based on morphology, and the Steger algorithm (a line center extraction algorithm based on the Hessian matrix), etc. Among them, as a classic method for extracting the center of a light stripe, the Steger algorithm has been widely applied in various applications due to its excellent accuracy and robustness. However, the Steger algorithm has a large amount of computation and a relatively slow processing speed. Especially in large-scale data and real-time application scenarios, the computational complexity becomes a bottleneck restricting its wide application.
[0004] It should be noted that the above statements are only used to provide background technical information related to the present application, and do not necessarily constitute the prior art. Summary of the Invention
[0005] In view of the above problems, embodiments of the present application provide a method, apparatus, electronic device and storage medium for extracting the center of a light stripe, which can greatly shorten the time for extracting the center of a light stripe, while maintaining high-precision calculation results, and can meet the application requirements of real-time processing and high-precision extraction.
[0006] In a first aspect, embodiments of the present application provide a method for extracting the center of a light stripe, the method comprising:
[0007] Calculating the width of the light stripe in the image to be processed;
[0008] Based on the width of the light stripe and a preset Gaussian template library, determining a target Gaussian template; the preset Gaussian template library includes a plurality of preset Gaussian templates, and each of the preset Gaussian templates has a mapping relationship with the width of the light stripe and is used for performing convolution processing on the image to be processed;
[0009] Performing convolution on the gray-scale data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed;
[0010] Determining the pixel points located on the center line of the image to be processed based on the Hessian matrix.
[0011] In some alternative embodiments, determining the target Gaussian template based on the width of the light strip and the preset Gaussian template library includes:
[0012] Calculating the estimated convolution kernel size of the target Gaussian template based on the width of the light strip;
[0013] Determining the corresponding target Gaussian template from the preset Gaussian template library according to the calculated estimated convolution kernel size.
[0014] In some alternative embodiments, determining the corresponding target Gaussian template from the preset Gaussian template library according to the calculated estimated convolution kernel size includes:
[0015] Calculating the Gaussian variance and the two-dimensional Gaussian function of the target Gaussian template according to the calculated estimated convolution kernel size;
[0016] Determining the Gaussian first derivative convolution template and the Gaussian second derivative convolution template of the target Gaussian template based on the Gaussian variance, the estimated convolution kernel size, and the two-dimensional Gaussian function.
[0017] In some alternative embodiments, convolving the gray-scale data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed includes:
[0018] Forming a Gaussian matrix of the image to be processed based on the Gaussian first derivative and the Gaussian second derivative of the target Gaussian template;
[0019] Convolving the gray-scale data of the image to be processed based on the Gaussian matrix to obtain the Hessian matrix of the image to be processed.
[0020] In some alternative embodiments, determining the pixel points located on the center line of the image to be processed based on the Hessian matrix includes:
[0021] Determining the characteristic parameters of the image to be processed according to the Hessian matrix; the characteristic parameters include the eigenvectors corresponding to the eigenvalues of the Hessian matrix and the constants required for calculating the sub-pixel coordinates;
[0022] Determining the sub-pixel coordinates of each pixel point based on the characteristic parameters of the image to be processed;
[0023] Determining the pixel points located on the center line of the image to be processed based on the sub-pixel coordinates.
[0024] In some alternative embodiments, calculating the width of the light strip of the image to be processed includes:
[0025] Perform redundant data cropping on the image to be processed according to a preset gray threshold;
[0026] Calculate the width of the light bar based on the cropped image data.
[0027] In some optional embodiments, the performing redundant data cropping on the image to be processed according to a preset gray threshold includes:
[0028] Read the gray data of the image to be processed line by line. When the gray data of the current line meets the preset gray threshold, save the gray data of the current line; the gray data meeting the preset gray threshold indicates that there is pixel data with a gray value greater than the preset gray threshold in the gray data;
[0029] Perform line counting on the saved gray data, and when the gray data of the current line does not meet the preset gray threshold, stop saving the gray data of the current line and stop line counting.
[0030] In a second aspect, an embodiment of the present application provides a light bar center extraction device, which includes:
[0031] A light bar width calculation module, configured to calculate the width of the light bar of the image to be processed;
[0032] A Gaussian template determination module, configured to determine a target Gaussian template based on the light bar width and a preset Gaussian template library; the preset Gaussian template library includes a plurality of preset Gaussian templates, and each of the preset Gaussian templates has a mapping relationship with the light bar width and is used to perform convolution processing on the image to be processed;
[0033] A Hessian matrix acquisition module, configured to perform convolution on the gray data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed;
[0034] A central pixel determination module, configured to determine the pixel points located on the center line of the image to be processed based on the Hessian matrix.
[0035] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor runs the computer program to implement the method as described in the first aspect.
[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and the program is executed by a processor to implement the method as described in the first aspect.
[0037] In this application, the width of the light stripe of the image to be processed can be calculated first, and then based on the width of the light stripe and a preset Gaussian template library, the target Gaussian template can be determined. The gray-scale data of the image to be processed is convolved based on the target Gaussian template to obtain the Hessian matrix of the image to be processed, and then the pixel points located on the center line of the image to be processed are determined based on the Hessian matrix. In this method, the required Gaussian convolution template is determined according to the width of the light stripe to ensure high-precision calculation results. By performing convolution processing on the gray-scale data of the image to be processed through the Gaussian convolution template, the Hessian matrix of the image to be processed can be obtained, thereby combining the Gaussian filtering and the calculation of the Hessian matrix of the image to be processed to effectively solve the problem of slow operation rate caused by the large amount of calculation in the Steger algorithm itself.
[0038] The above description is only an overview of the technical solutions of the embodiments of this application. In order to be able to understand the technical means of this application more clearly, it can be implemented according to the content of the description. And in order to make the above and other purposes, features, and advantages of the embodiments of this application more obvious and understandable, the specific implementation manners of this application are specifically given below. Description of the Drawings
[0039] By reading the detailed description of the preferred embodiments below, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of this application. And in all the drawings, the same reference numerals are used to represent the same components. In the drawings:
[0040] Figure 1 It is a schematic flowchart of the light stripe center extraction method provided by some embodiments of this application;
[0041] Figure 2 It is a schematic flowchart of the specific process of step S1 provided by some embodiments of this application;
[0042] Figure 3 It is a schematic flowchart of the specific process of step S2 provided by some embodiments of this application;
[0043] Figure 4 It is a schematic flowchart of the specific process of step S3 provided by some embodiments of this application;
[0044] Figure 5 It is a schematic flowchart of the specific process of the light stripe center extraction method provided by some embodiments of this application;
[0045] Figure 6 It is a schematic flowchart of the specific process of the image cropping step provided by some embodiments of this application;
[0046] Figure 7 It is a schematic flowchart of the specific process of the center line extraction step provided by some embodiments of this application;
[0047] Figure 8 Schematic diagram of the frame structure of the light stripe center extraction device provided by some embodiments of the present application;
[0048] Figure 9 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application is shown. Specific embodiments
[0049] Hereinafter, embodiments of the technical solution of the present application will be described in detail with reference to the accompanying drawings. The following embodiments are only used to illustrate the technical solution of the present application more clearly, and thus are only examples and cannot be used to limit the protection scope of the present application.
[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the embodiments of the present application belong; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit the embodiments of the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above drawings are intended to cover non-exclusive inclusion.
[0051] In the description of the embodiments of the present application, the meaning of "a plurality" is more than two, unless otherwise specifically defined.
[0052] Reference to "embodiment" herein means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0053] In the description of the embodiments of the present application, the term " / or" is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article generally represents an "or" relationship between the associated objects before and after.
[0054] In the related art, for traditional computer systems, the implementation of the Steger algorithm usually relies on the CPU for floating-point operations. In the face of scenarios with large-scale data or high real-time requirements, this will lead to too long processing time and cannot meet the demand for efficient processing. Although the operation speed of the Steger algorithm can be improved through hardware acceleration. For example, the hardware acceleration technology based on FPGA (Field Programmable Gate Array), with its advantage of high parallel computing, can significantly improve the execution efficiency of the Steger algorithm. However, despite the many advantages of FPGA hardware acceleration, the implementation of the traditional Steger algorithm still faces the limitations of hardware resources and optimization problems. The floating-point operations and large-scale data storage involved in the Steger algorithm often lead to waste of hardware resources and a decrease in efficiency. Therefore, how to implement the Steger algorithm more efficiently is an important challenge in this field.
[0055] For the above reasons, the embodiments of this application propose a method for extracting the center of a light strip. This method can be applied to a computer system based on FPGA (Field Programmable Gate Array), specifically to the processor of this computer system or a specially set device for extracting the center of the light strip. This method can first calculate the width of the light strip, and then determine the required Gaussian convolution template according to the width of the light strip, so as to perform convolution processing on the grayscale data of the image to be processed based on this Gaussian convolution template, and can obtain the Hessian matrix of the image to be processed. Then, based on this Hessian matrix, the pixel points located on the center line of the image to be processed can be determined, so as to extract the center of the light strip. This method determines the required Gaussian convolution template according to the width of the light strip to ensure high-precision calculation results; by performing convolution processing on the grayscale data of the image to be processed through the Gaussian convolution template, the Hessian matrix of the image to be processed can be obtained, thereby combining the Gaussian filtering and the calculation of the Hessian matrix of the image to be processed, and effectively solving the problem of slow operation rate caused by the large amount of calculation in the Steger algorithm itself.
[0056] The following combines the accompanying drawings to provide a detailed description of the method for extracting the center of the light strip provided by the embodiments of this application. Please refer to Figure 1 , Figure 1 which is a schematic flowchart of the method for extracting the center of the light strip provided by the embodiments of this application. As Figure 1 shown, the method for extracting the center of the light strip can include the following steps:
[0057] Step S1, calculate the width of the light strip of the image to be processed.
[0058] Among them, the image to be processed can be any image that needs to extract the center of the light strip, and this embodiment does not make specific limitations on it. Before calculating the width of the light strip, the image to be processed can be grayscaled to obtain the grayscale data of the image to be processed, and then the width of the light strip can be calculated based on this grayscale data.
[0059] In this embodiment, the light stripe center extraction method can be implemented on the PL side (FPGA, programmable logic) of the Zynq chip. Before calculating the width of the light stripe, first read the grayscale data of the image to be processed from the DDR4 (fourth-generation double data rate synchronous dynamic random access memory) storage space on the PS side (processor subsystem based on the ARM architecture) and read it into the FIFO on the PL side.
[0060] In some alternative embodiments, when calculating the width of the light stripe in the image to be processed, the image to be processed can be cropped first, and then the width of the light stripe can be calculated according to the cropped image data to improve the calculation efficiency of the light stripe width. That is, as Figure 2 shown, the above step S1 may include the following processing: step S11, crop redundant data from the image to be processed according to a preset grayscale threshold; step S12, calculate the width of the light stripe based on the cropped image data.
[0061] Among them, the preset grayscale threshold can be set according to the specific grayscale values of the pixels in the image to be processed. Considering that the grayscale value of the light stripe center is relatively high, the pixel data with a grayscale value less than the preset grayscale threshold can be regarded as redundant data.
[0062] In this embodiment, after reading the grayscale data, the redundant data in the grayscale data can be cropped by the preset grayscale threshold, that is, the pixel data with a grayscale value less than the preset grayscale threshold is removed, so as to reduce the amount of data calculation and improve the calculation efficiency of the light stripe width.
[0063] Specifically, the grayscale data of the image to be processed is transmitted in the form of a data stream. When implementing the light stripe center extraction method on the PL side, after cropping the redundant data of the current data stream, the width of the light stripe can be calculated based on the cropped image data while cropping the redundant data of the grayscale data of the next data stream. In this way, parallel cropping of redundant data and calculation of the light stripe width can further improve the overall operation efficiency of the light stripe width.
[0064] In some other alternative embodiments, when performing the step of cropping redundant data from the image to be processed according to the preset grayscale threshold, the grayscale data of the image to be processed can be read row by row. When the grayscale data of the current row meets the preset grayscale threshold, the grayscale data of the current row is saved; then the saved grayscale data is counted row by row, and when the grayscale data of the current row does not meet the preset grayscale threshold, saving the grayscale data of the current row is stopped, and the row counting is stopped.
[0065] Among them, the grayscale data meeting the preset grayscale threshold means that there is pixel data with a grayscale value greater than the preset grayscale threshold in the grayscale data.
[0066] In this embodiment, first, the grayscale data of each pixel of the image to be processed is read line by line, and a line marker is set at the end of each line of data read. Then, a preset grayscale threshold is used to determine whether the grayscale data of each pixel is redundant data, and the image redundant data of the image to be processed is cropped line by line. That is, it is determined whether the grayscale value of each pixel in the grayscale data of each line read is greater than the preset grayscale threshold. If there are matching pixel points, the grayscale data of the image to be processed is saved line by line starting from this line, and line counting operations are performed starting from this line according to the preset line marker. After reading a line of data, if no data greater than the preset grayscale threshold is found, that is, the grayscale values of all pixels in this line of data are less than the preset grayscale threshold, no further data saving is performed, and the saving of the grayscale data of the image to be processed is stopped starting from this line, and the line counting is stopped starting from this line, thereby completing the cropping of the redundant data of the image to be processed.
[0067] Step S2: Based on the light stripe width and a preset Gaussian template library, determine the target Gaussian template.
[0068] Among them, the preset Gaussian template library includes multiple preset Gaussian templates, and each preset Gaussian template has a mapping relationship with the light stripe width and is used for performing convolution processing on the image to be processed.
[0069] In this embodiment, a Gaussian template library including multiple preset Gaussian templates can be preset, and each preset Gaussian template is used for performing convolution processing on the corresponding image to be processed. Given that the determination of the light stripe width, the variance of the Gaussian function, and the optimal Gaussian convolution kernel scale are all related to the calculation of the target Gaussian template, preset Gaussian templates with a certain mapping relationship with the light stripe width can be set, so that the target Gaussian template of the image to be processed can be determined from the preset Gaussian template library according to the light stripe width, thereby improving the calculation efficiency of the target Gaussian template and the overall extraction efficiency of the light stripe center.
[0070] In some optional embodiments, as Figure 3 shown, step S2, that is, the step of determining the target Gaussian template based on the light stripe width and the preset Gaussian template library, may include the following processing: Step S21: Calculate the estimated convolution kernel size of the target Gaussian template based on the light stripe width; Step S22: Determine the corresponding target Gaussian template from the preset Gaussian template library according to the calculated estimated convolution kernel size.
[0071] In this embodiment, each preset Gaussian template in the preset Gaussian template library has a corresponding convolution kernel size. When performing convolution processing on the image to be processed, the convolution kernel size can be estimated according to the light stripe width, and then, according to the estimated convolution kernel size, the appropriate preset Gaussian template in the preset Gaussian template library can be quickly selected as the target Gaussian template to further improve the determination efficiency of the target Gaussian template.
[0072] Specifically, the above step S22, that is, the step of determining the corresponding target Gaussian template from the preset Gaussian template library according to the calculated estimated convolution kernel size, may include the following processing: According to the calculated estimated convolution kernel size, calculate the Gaussian variance and the two-dimensional Gaussian function of the target Gaussian template; Based on the Gaussian variance, the estimated convolution kernel size, and the two-dimensional Gaussian function, determine the Gaussian first derivative convolution template and the Gaussian second derivative convolution template of the target Gaussian template.
[0073] In this embodiment, in view of the determination of the light strip width, the Gaussian function variance, and the optimal Gaussian convolution kernel scale, all of which are related to the calculation of the target Gaussian template, and the selection of the target Gaussian template can directly affect the accuracy of centerline extraction. Therefore, in this embodiment, first, according to the calculated estimated convolution kernel size, calculate the Gaussian variance and the two-dimensional Gaussian function of the target Gaussian template, and then, based on the Gaussian variance, the estimated convolution kernel size, and the two-dimensional Gaussian function, determine the Gaussian first derivative convolution template and the Gaussian second derivative convolution template of the target Gaussian template, thereby improving the calculation accuracy of the target Gaussian template (Gaussian first derivative convolution template and Gaussian second derivative convolution template).
[0074] Step S3, perform convolution on the gray-scale data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed.
[0075] Among them, the Hessian Matrix is a square matrix composed of the second partial derivatives of a multivariate function, used to describe the local curvature of the function at a certain point.
[0076] In this embodiment, by performing convolution processing on the gray-scale data of the image to be processed through the Gaussian convolution template, the Hessian matrix of the image to be processed can be obtained, thereby combining the Gaussian filtering and the Hessian matrix calculation of the image to be processed to effectively solve the problem of slow operation rate caused by the large amount of calculation in the Steger algorithm itself.
[0077] In some alternative embodiments, as Figure 4 shown, the above step S3, that is, the step of performing convolution on the gray-scale data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed, may include the following specific steps: Step S31, form a Gaussian matrix of the image to be processed based on the Gaussian first derivative and the Gaussian second derivative of the target Gaussian template; Step S32, perform convolution on the gray-scale data of the image to be processed based on the Gaussian matrix to obtain the Hessian matrix of the image to be processed.
[0078] In this embodiment, the convolution differential property can be used to combine the filtering and the Hessian matrix calculation to optimize the problem of slow operation rate caused by the large amount of calculation in the Steger algorithm itself, thereby fundamentally improving the calculation efficiency of this light strip center extraction method.
[0079] Specifically, let the Hessian matrix be H(x, y), the Gaussian function be g(x, y), and the grayscale image be z(x, y). After the image is convolved with the corresponding high-order Gaussian template, they are respectively r xx , r xy , r yy . Then, the calculation formula for solving the Hessian matrix and combining filtering through the convolution differential property is shown in formula (1) below.
[0080]
[0081] Among them, is a matrix composed of the first-order Gaussian derivative and the second-order Gaussian derivative of the target Gaussian template, which can be called the Gaussian matrix of the image to be processed.
[0082] Step S4: Determine the pixel points located on the center line of the image to be processed based on the Hessian matrix.
[0083] Among them, the pixel points located on the center line of the image to be processed can be regarded as the pixel points for which the center of the light strip needs to be extracted. After determining these pixel points, extract these pixel points, that is, perform the extraction of the center of the light strip.
[0084] In some optional embodiments, the above step S4, that is, the step of determining the pixel points located on the center line of the image to be processed based on the Hessian matrix, may include the following specific steps: Determine the characteristic parameters of the image to be processed according to the Hessian matrix; Based on the characteristic parameters of the image to be processed, determine the sub-pixel coordinates of each pixel point; Based on the sub-pixel coordinates, determine the pixel points located on the center line of the image to be processed.
[0085] Among them, the characteristic parameters include the eigenvectors corresponding to the eigenvalues of the Hessian matrix and the constants required for calculating the sub-pixel coordinates.
[0086] In this embodiment, the intermediate quantities required for calculating the eigenvalues can be calculated through the partial derivative values in the obtained Hessian matrix, and fixed-point numbers are used for calculation. Specifically, it is the trace m of the Hessian matrix, the determinant p of the Hessian matrix, the difference m 2 -p between the square of the trace and the determinant, and applying the Cordic IP core to perform a square root operation on m 2 -p to prepare for subsequent calculations. Subsequently, a four-stage pipeline program is designed based on the intermediate quantities calculated in the previous step for fixed-point operations, and the eigenvalues of the Hessian matrix and the eigenvectors n x in the corresponding x direction and y direction are calculated step by step y ; Then, the constant t required for calculation is calculated based on formula 2. Then, based on the calculated constant t, the eigenvector n x and n y and the calculated sub-pixel coordinates N = (tn x , tn y)。Then, perform center line judgment. If the absolute values of the x-coordinate and y-coordinate of the sub-pixel are both less than or equal to 0.5, it proves that this point is on the center line, and the coordinates of this point are saved through the register; otherwise, it proves that this point is not on the center line. After that, the sub-pixel data after threshold judgment can be output to extract the center of the light bar.
[0087] In addition, directly output the result after the center line judgment is completed. However, in a complex environment with multiple center lines, to avoid the influence of interfering lines, the algorithm needs to be further optimized to improve the accuracy of single line extraction. For this purpose, non-maximum suppression can be performed on the calculated x-direction eigenvalue and y-direction eigenvalue column by column. The specific operation is to retain only the eigenvalue with the largest absolute value and its corresponding coordinates in each column of data, and set the remaining eigenvalues to zero. Through this method, redundant line data can be effectively removed, and only the most significant line result is retained, thereby improving the extraction accuracy and laying a more reliable foundation for subsequent data processing. This optimization strategy is particularly suitable for complex scenarios with multiple center lines.
[0088] In a specific embodiment, the center of the light bar can be extracted according to the Figures 5 - 7 specific process shown. Among them, Figure 5 is a schematic diagram of a specific process for the method of extracting the center of the light bar provided in this embodiment, Figure 6 is a schematic diagram of the specific process of the image cropping step, Figure 7 is a schematic diagram of the center line extraction algorithm of the Steger algorithm implemented based on the FPGA of the light bar center. Based on Figures 5 - 7 , the method for extracting the center of the light bar can include three major steps: data reading, image cropping, and center line extraction. In the data reading step, first, the image data at a specific address in the PS-side DDR4 register is transmitted to the PL side via the AXIDMA bus, and then the image data input to the PL side is cached via the FIFO IP core.
[0089] In the image cropping step, as Figure 6As shown, first, the image data cached in the FIFO is read out one by one row by row, and a row marker is set at the end of each row of data read. Subsequently, it is judged whether the gray value of each input pixel is greater than a preset gray threshold, and this row of data is cached. After reading a row of data, if no data meeting the threshold requirement is found, no further data saving is performed; if data meeting the threshold requirement is found, the image gray data is saved row by row starting from this row, and row counting operations are performed according to the preset row marker starting from this row. Subsequently, it is judged whether the gray value of each input pixel is less than the preset gray threshold. If there is a gray value greater than the preset gray threshold in this row of data, this row of data continues to be saved; if all the data in this row is less than the preset gray threshold, saving the image gray data stops starting from this row, and row counting stops starting from this row. Subsequently, the light bar width data is output, and the cropped image data is output for the next operation.
[0090] In the center line extraction step, as Figure 5 and Figure 7 shown, first, based on the calculated light bar width, the calculation and presetting of the Gaussian first-order derivative and Gaussian second-order derivative convolution templates are performed. Specifically, first, the convolution template scale is calculated according to the light bar width to achieve a more accurate center line extraction effect. Subsequently, the Gaussian template convolution kernel scale is selected based on the light bar width, and based on the Gaussian variance, convolution kernel scale, and two-dimensional Gaussian function at this time, the Gaussian first-order derivative and Gaussian second-order derivative convolution templates are calculated.
[0091] Subsequently, the combined Gaussian filtering and Hessian matrix calculation are performed on the gray data after image cropping. Through the convolution differential property shown in the above formula (1), the filtering and Hessian matrix calculation are combined to optimize the problem of slow operation rate caused by the large calculation amount of the Steger algorithm itself. Specifically, if the Gaussian filtering and Hessian matrix calculation are calculated separately, two image data read-in and read-out operations are required, and two image convolution and image second-order derivative calculation operations are performed. After combining the Hessian matrix solution formula of formula 1 with the properties of matrix convolution, only one image data read-in and read-out operation is required and only one image convolution operation is required to improve the speed of implementing this algorithm on FPGA hardware. Then, the intermediate quantities required for calculating the eigenvalues are calculated through the partial derivative values in the obtained Hessian matrix, and fixed-point numbers are used for calculation. Subsequently, a four-stage pipeline program is designed based on the intermediate quantities calculated in the previous step for fixed-point operation, and the eigenvalues of the Hessian matrix and the corresponding eigenvectors n x and n y . Then, the constant t required for calculation is calculated based on the above formula (1). Then, based on the calculated constant t, eigenvector n x and n y and the calculated sub-pixel coordinate N = (tnx , tn y ), and then perform center line judgment. If the absolute values of the x - coordinate and y - coordinate of the sub - pixel are both less than or equal to 0.5, it proves that this point is on the center line, and save the coordinates of this point through the register; otherwise, it proves that this point is not on the center line.
[0092] In summary, the method for extracting the center of the light stripe provided in this embodiment can first calculate the width of the light stripe in the image to be processed, and then determine the target Gaussian template based on the light stripe width and the preset Gaussian template library. Convolve the gray - scale data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed, and then determine the pixel points located on the center line of the image to be processed based on the Hessian matrix. In this method, the required Gaussian convolution template is determined according to the light stripe width to ensure high - precision calculation results. By performing convolution processing on the gray - scale data of the image to be processed with the Gaussian convolution template, the Hessian matrix of the image to be processed can be obtained, thereby combining the Gaussian filtering and the calculation of the Hessian matrix of the image to be processed, and effectively solving the problem of slow operation speed caused by the large amount of calculation in the Steger algorithm itself.
[0093] Based on the same concept as the above - mentioned method for extracting the center of the light stripe, the embodiment of the present application also provides a device for extracting the center of the light stripe, which is used to implement the above - mentioned method for extracting the center of the light stripe, as Figure 8 shown. The device for extracting the center of the light stripe includes:
[0094] A light stripe width calculation module, which is used to calculate the width of the light stripe in the image to be processed;
[0095] A Gaussian template determination module, which is used to determine the target Gaussian template based on the light stripe width and the preset Gaussian template library; the preset Gaussian template library includes multiple preset Gaussian templates, and each preset Gaussian template has a mapping relationship with the light stripe width and is used to perform convolution processing on the image to be processed;
[0096] A Hessian matrix acquisition module, which is used to convolve the gray - scale data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed;
[0097] A central pixel determination module, which is used to determine the pixel points located on the center line of the image to be processed based on the Hessian matrix.
[0098] It can be understood that the device for extracting the center of the light stripe provided in this embodiment is used to execute the above - mentioned method for extracting the center of the light stripe, so it can at least achieve the beneficial effects that the above - mentioned method for extracting the center of the light stripe can achieve, and the above - mentioned embodiments of the method for extracting the center of the light stripe are also applicable to this device for extracting the center of the light stripe, and will not be elaborated here.
[0099] The embodiment of the present application also provides an electronic device to execute the above - mentioned method for extracting the center of the light stripe. Please refer to Figure 9, which shows a schematic diagram of an electronic device provided by some embodiments of the present application. As Figure 9 shown, the electronic device 9 includes: a processor 901, a memory 902, a bus 903, and a communication interface 904. The processor 901, the communication interface 904, and the memory 902 are connected through the bus 903; a computer program that can run on the processor 901 is stored in the memory 902, and when the processor 901 runs the computer program, it executes the light strip center extraction method provided by any one of the foregoing embodiments of the present application.
[0100] Among them, the memory 902 may include a high-speed random access memory (RAM: Random Access Memory), and may also include a non-volatile memory, such as at least one disk memory. Through at least one communication interface 904 (which can be wired or wireless), a communication connection is realized between the device network element and at least one other network element, and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used.
[0101] The bus 903 may be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. Among them, the memory 902 is used to store a program. After receiving an execution instruction, the processor 901 executes the program. The light strip center extraction method disclosed in any one of the foregoing embodiments of the present application can be applied to the processor 901 or implemented by the processor 901.
[0102] The processor 901 may be an integrated circuit chip with the ability to process signals. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor 901 or the instructions in the form of software. The above-mentioned processor 901 may be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by the combination of the hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 902, and the processor 901 reads the information in the memory 902 and combines its hardware to complete the steps of the above method.
[0103] The electronic device provided by the embodiments of the present application and the method for extracting the center of the light bar provided by the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the method adopted, run or implemented by it.
[0104] The embodiments of the present application also provide a computer-readable storage medium corresponding to the method for extracting the center of the light bar provided by the foregoing embodiments. A computer program (i.e., a program product) is stored thereon. When the computer program is run by a processor, it will execute the method for extracting the center of the light bar provided by any of the foregoing embodiments.
[0105] It should be noted that the computer-readable storage medium may include, but is not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, optical discs or other optical and magnetic storage media, etc., which will not be elaborated here one by one.
[0106] The computer-readable storage medium provided by the embodiments of the present application and the method for extracting the center of the light bar provided by the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the method adopted, run or implemented by the application program stored therein.
[0107] The embodiments of the present application also provide a computer program product corresponding to the light stripe center extraction method provided in the foregoing embodiments, including a computer program, which is executed by a processor to implement the above light stripe center extraction method.
[0108] The computer program product provided by the embodiments of the present application and the light stripe center extraction method provided by the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the method implemented by the execution of its computer program by a processor.
[0109] It can be understood that the descriptions of the foregoing embodiments tend to emphasize the differences between the embodiments. The same or similar parts can be referred to each other. For the sake of brevity, they will not be repeated herein.
[0110] Those skilled in the art can understand that in the above method of the specific embodiment, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined according to its function and possible internal logic.
[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application, and they should all be covered by the scope of the claims and the description of the present application. In particular, as long as there is no structural conflict, the technical features mentioned in each embodiment can be combined in any way. The present application is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.
Claims
1. A method for extracting the center of a light strip, characterized in that The method includes: Calculating the light stripe width of the image to be processed; Determining a target Gaussian template based on the light stripe width and a preset Gaussian template library; the preset Gaussian template library includes a plurality of preset Gaussian templates, and each of the preset Gaussian templates has a mapping relationship with the light stripe width and is used for performing convolution processing on the image to be processed; Convolving the gray data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed; Determining the pixel points located on the center line of the image to be processed based on the Hessian matrix.
2. The method according to claim 1, wherein The determining a target Gaussian template based on the light stripe width and a preset Gaussian template library includes: Calculating the estimated convolution kernel size of the target Gaussian template based on the light stripe width; Determining the corresponding target Gaussian template from the preset Gaussian template library according to the calculated estimated convolution kernel size.
3. The method according to claim 2, wherein The determining the corresponding target Gaussian template from the preset Gaussian template library according to the calculated estimated convolution kernel size includes: Calculating the Gaussian variance and the two-dimensional Gaussian function of the target Gaussian template according to the calculated estimated convolution kernel size; Determining the Gaussian first derivative convolution template and the Gaussian second derivative convolution template of the target Gaussian template based on the Gaussian variance, the estimated convolution kernel size, and the two-dimensional Gaussian function.
4. The method according to claim 1, wherein The convolving the gray data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed includes: Forming a Gaussian matrix of the image to be processed based on the Gaussian first derivative and the Gaussian second derivative of the target Gaussian template; Convolving the gray data of the image to be processed based on the Gaussian matrix to obtain the Hessian matrix of the image to be processed.
5. The method according to claim 1, characterized in that, The determining the pixel points located on the center line of the image to be processed based on the Hessian matrix includes: Determining the characteristic parameters of the image to be processed according to the Hessian matrix; the characteristic parameters include the eigenvectors corresponding to the eigenvalues of the Hessian matrix and the constants required for calculating the sub-pixel coordinates; Determining the sub-pixel coordinates of each pixel point based on the characteristic parameters of the image to be processed; Determining the pixel points located on the center line of the image to be processed based on the sub-pixel coordinates.
6. The method according to any one of claims 1-5, characterized in that The calculating the light stripe width of the image to be processed includes: Performing redundant data cropping on the image to be processed according to a preset gray threshold; Calculating the light stripe width based on the cropped image data.
7. The method according to claim 6, characterized in that, The performing redundant data cropping on the image to be processed according to a preset gray threshold includes: Reading the gray data of the image to be processed row by row, and saving the gray data of the current row when the gray data of the current row meets the preset gray threshold; the gray data meeting the preset gray threshold indicates that there is pixel data with a gray value greater than the preset gray threshold in the gray data; Counting the number of rows of the saved gray data, and stopping saving the gray data of the current row and stopping row counting when the gray data of the current row does not meet the preset gray threshold.
8. An optical stripe center extraction device, characterized in that, The device includes: A light stripe width calculation module for calculating the light stripe width of the image to be processed; A Gaussian template determination module, configured to determine a target Gaussian template based on the light stripe width and a preset Gaussian template library; the preset Gaussian template library includes a plurality of preset Gaussian templates, and each of the preset Gaussian templates has a mapping relationship with the light stripe width and is used for performing convolution processing on the image to be processed; A Hessian matrix acquisition module, configured to perform convolution on the gray data of the image to be processed based on the target Gaussian template to obtain the Hessian matrix of the image to be processed; A central pixel determination module, configured to determine the pixel points located on the center line of the image to be processed based on the Hessian matrix.
9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor runs the computer program to implement the method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the method according to any one of claims 1-7.