A laser stripe center extraction method and system for FPGA devices

By implementing the laser stripe center extraction method on FPGA equipment, using sliding window and connectivity domain completion technology, the real-time and accuracy problems of laser stripe center extraction on small hardware are solved, and efficient and accurate laser stripe center extraction is achieved.

CN119417887BActive Publication Date: 2025-06-06HANGZHOU LINGXI ROBOT INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510018777.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-06-06
Estimated Expiration
2045-01-07

AI Technical Summary

Technical Problem

The existing anti-interference laser stripe center extraction method is difficult to implement on small hardware, and the real-time and detection accuracy of the extraction method are poor.

Method used

A laser stripe center extraction method applied to FPGA equipment is provided. By acquiring pixel columns, acquiring pixels from top to bottom using a sliding window, dividing the pixels in a connected domain, completing the connecting domain based on the starting point and end point pixel parameters, calculating the grayscale mean and gradient sum to determine the weight of the connecting domain, and then determining the laser stripe center.

Benefits of technology

The accuracy and stability of the laser stripe center extraction method are improved, and can be efficiently implemented on small hardware to meet the needs of real-time and high frame rate production scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119417887B_ABST
    Figure CN119417887B_ABST
Patent Text Reader

Abstract

The present application relates to a method and system for extracting the center of a laser stripe applied to an FPGA device, wherein the method comprises: obtaining a pixel column, using a sliding window to collect pixels in the pixel column from top to bottom, dividing the pixels into connected domains, obtaining a connected domain and a structure of the connected domain, wherein the structure comprises a starting pixel parameter, an end pixel parameter, and a gradient sum and a grayscale coordinate sum of pixels in the connected domain; completing the connected domain based on the starting pixel parameter and the end pixel parameter, calculating the grayscale mean of all pixels in the completed connected domain, and determining the weight of the connected domain according to the grayscale mean and the gradient sum; determining a target connected domain for each of the pixel columns according to the weight, calculating the grayscale centroid coordinates of the target connected domain according to the grayscale sum and the grayscale coordinate sum of the target connected domain, and using the grayscale centroid coordinates of all the target connected domains as the center of the laser stripe.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of laser stripe detection, and in particular to a laser stripe center extraction method and system applied to FPGA devices. Background Art

[0002] In modern production, accurate extraction of laser stripes plays a vital role. Laser stripe extraction technology is widely used in industrial inspection, three-dimensional measurement, machine vision and other fields. By accurately extracting the center of laser stripes, key information such as the shape, size, and position of the object can be obtained, providing strong data support for quality control, automated operation and product development in the production process.

[0003] Existing methods for extracting the center of laser stripes include: processing the laser stripe image through a complex deep learning algorithm to reduce the impact of interference on the extraction results. However, this type of method has some limitations in practical applications. This is mainly because this type of method has high computational complexity, high demand for hardware resources, and is difficult to implement in small hardware, resulting in high implementation costs, which makes it difficult for many small and medium-sized enterprises to afford in actual production. In addition, in the absence of dedicated hardware acceleration, the scanning frame rate of this type of method is low, making it difficult to adapt to some production scenarios with high real-time requirements. For example, in the inspection of high-speed production lines, low frame rates may lead to missed detections or false detections, affecting product quality and production efficiency.

[0004] In summary, the existing anti-interference laser stripe center extraction method is difficult to implement on small hardware, and the real-time performance and detection accuracy of the extraction method are poor. Summary of the invention

[0005] The embodiments of the present application provide a laser stripe center extraction method and system applied to FPGA devices, so as to at least solve the problems in the related art that the interference-resistant laser stripe center extraction method is difficult to implement on small hardware, and the real-time performance and detection accuracy of the extraction method are poor.

[0006] In a first aspect, an embodiment of the present application provides a laser stripe center extraction method applied to an FPGA device, comprising:

[0007] Obtain a pixel column, use a sliding window to collect pixels in the pixel column from top to bottom, divide the pixels into connected domains, and obtain a connected domain and a structure of the connected domain, wherein the structure includes a starting pixel parameter, an end pixel parameter, and a gradient sum and a grayscale coordinate sum of pixels in the connected domain;

[0008] The connected domain is completed based on the starting pixel parameter and the end pixel parameter, the grayscale mean of all pixels in the completed connected domain is calculated, and the weight of the connected domain is determined according to the grayscale mean and the gradient sum;

[0009] The target connected domain of each pixel column is determined according to the weight, the grayscale centroid coordinates of the target connected domain are calculated according to the grayscale sum and grayscale coordinates of the target connected domain, and the grayscale centroid coordinates of all the target connected domains are used as the laser stripe center.

[0010] In one embodiment, the step of collecting pixels in the pixel column from top to bottom using a sliding window, dividing the pixels into connected domains, and obtaining connected domains and structures of the connected domains includes:

[0011] Obtaining the grayscale value of each pixel in the pixel column, and determining the gradient value of the current pixel according to the grayscale value of the current pixel and the grayscale value of the previous pixel;

[0012] The pixels in the pixel column are divided into connected domains according to the gradient value and the grayscale value to obtain a connected domain and a structure of the connected domain.

[0013] In one embodiment, dividing the pixels in the pixel column into connected domains according to the gradient value and the grayscale value includes:

[0014] According to the gray value of the current pixel, determine whether the current pixel is a zero point or an accumulation point, and according to the gradient value of the current pixel and the gradient value of the previous pixel, determine whether the current pixel is a saddle point;

[0015] When the previous pixel is a zero point and the current pixel is an accumulation point, or the current pixel is a saddle point, the current pixel is used as the starting point of the current connected domain;

[0016] When the previous pixel is an accumulation point and the current pixel is a zero point, or the next pixel is a saddle point, the current pixel is taken as the end point of the current connected domain.

[0017] In one embodiment, the starting pixel parameter includes a starting grayscale value and a starting gradient value, the end pixel parameter includes an end grayscale value and an end gradient value, and the completing the connected domain based on the starting pixel parameter and the end pixel parameter includes:

[0018] The first supplementary pixel number on the starting point side is determined based on the starting point grayscale value and the starting point gradient value, and the formula is as follows:

[0019]

[0020] Among them, N start represents the first supplementary pixel number on the starting point side, Y start represents the gray value of the starting point, Kstart represents the starting point gradient value;

[0021] The area of ​​the supplementary pixels on the starting point side and the grayscale value of each supplementary pixel are determined based on the starting point grayscale value, the starting point gradient value and the first number of supplementary pixels, and the formula is as follows:

[0022]

[0023] Among them, B is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the starting point side, S start represents the area of ​​the supplementary pixels on the starting point side, N start represents the first supplementary pixel number on the starting point side, Y start represents the gray value of the starting point, K start represents the starting point gradient value;

[0024] The number of second supplementary pixels on the end point side is determined based on the end point grayscale value and the end point gradient value, and the formula is as follows:

[0025]

[0026] Among them, N end Indicates the number of the second supplementary pixels on the end point side, Y end represents the endpoint gray value, K end represents the endpoint gradient value;

[0027] Determine the area of ​​the supplementary pixels on the end point side and the grayscale value of each supplementary pixel based on the end point grayscale value, the end point gradient value and the second number of supplementary pixels,

[0028]

[0029] Among them, C is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the end point side, S end represents the area of ​​the supplementary pixels on the end point side, N end Indicates the number of the second supplementary pixels on the end point side, Y end represents the endpoint gray value, K end Represents the endpoint gradient value.

[0030] In one embodiment, the structure of the connected domain further includes the initial number of pixels in the connected domain, and the grayscale mean of all pixels in the connected domain after completion is calculated, including:

[0031] The grayscale mean of all pixels in the connected domain after completion is calculated according to the grayscale sum, the area of ​​the supplementary pixels on the starting point side, the area of ​​the supplementary pixels on the end point side, the initial number of pixels, the first number of supplementary pixels and the second number of supplementary pixels. The calculation formula is as follows:

[0032]

[0033] Among them, GRAY average Represents the grayscale mean of all pixels in the connected domain after completion, S origin Represents the grayscale and, S start represents the area of ​​the supplementary pixel on the starting point side, S end represents the area of ​​the supplementary pixels on the end point side, N origin Represents the initial number of pixels, N start represents the first supplementary pixel number, N end represents the second supplementary pixel number.

[0034] In one embodiment, determining the weight of the connected domain according to the grayscale mean and the gradient sum includes:

[0035] The difference between the grayscale mean and the absolute value of the gradient sum is calculated, and the difference is used as the weight of the connected domain.

[0036] In one embodiment, determining the target connected domain of each pixel column according to the weight includes:

[0037] The connected domain with the largest weight in the current pixel column is used as the target connected domain of the pixel column.

[0038] In one embodiment, the step of calculating the grayscale centroid coordinates of the target connected domain according to the grayscale sum and grayscale coordinates of the target connected domain includes:

[0039] The grayscale centroid coordinates of the target connected domain are obtained by dividing the grayscale coordinate sum of the target connected domain by the grayscale sum.

[0040] In a second aspect, an embodiment of the present application provides a laser stripe center extraction system applied to an FPGA device, comprising:

[0041] Connected domain acquisition module: used to acquire pixel columns, collect pixels in the pixel columns from top to bottom using a sliding window, divide the pixels into connected domains, and obtain connected domains and structures of the connected domains, wherein the structures include starting pixel parameters and end pixel parameters of the connected domains, and the gradient sum and grayscale coordinate sum of the pixels in the connected domains;

[0042] Connected domain completion module: used to complete the connected domain based on the starting pixel parameter and the end pixel parameter, calculate the grayscale mean of all pixels in the connected domain after completion, and determine the weight of the connected domain according to the grayscale mean and the gradient sum;

[0043] Determination module: used to determine the target connected domain of each pixel column according to the weight, calculate the grayscale centroid coordinates of the target connected domain according to the grayscale sum and grayscale coordinates of the target connected domain, and use the grayscale centroid coordinates of all the target connected domains as the center of the laser stripe.

[0044] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the laser stripe center extraction method applied to an FPGA device as described in the first aspect above is implemented.

[0045] The embodiments of the present application provide a method and system for extracting the center of a laser stripe applied to an FPGA device, which have at least the following technical effects.

[0046] This application takes into account the different distribution characteristics of laser stripes and halos, and completes the connected domain. After completion, the height of the connected domain increases, the average grayscale decreases, and its weight also decreases accordingly, thereby increasing the relative weight of the connected domain where the laser stripes are located, achieving the effect of anti-halo interference, and effectively improving the accuracy and stability of the laser stripe center extraction method. The image algorithm is accelerated through dedicated hardware, and the parallel units in the FPGA are used for calculation, which reduces the power consumption of the camera equipment, greatly improves the performance of the camera, and meets the real-time and accuracy requirements of different production scenarios.

[0047] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0049] Figure 1 It is a flow chart of a laser stripe center extraction method applied to an FPGA device according to an embodiment of the present application;

[0050] Figure 2 is a schematic diagram of detection results before and after connected domain completion according to an exemplary embodiment;

[0051] Figure 3It is a structural block diagram of a laser stripe center extraction system applied to an FPGA device according to an embodiment of the present application;

[0052] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0054] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.

[0055] Reference to "embodiments" in this application 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 application. The appearance of the phrase in various locations 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 of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0056] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantity limitation, and may indicate the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0057] In a first aspect, an embodiment of the present application provides a method for extracting the center of a laser stripe applied to an FPGA device. Figure 1 is a flow chart of a laser stripe center extraction method applied to an FPGA device according to an embodiment of the present application. Figure 1 As shown, the method includes:

[0058] Step S101, obtain a pixel column, use a sliding window to collect pixels in the pixel column from top to bottom, divide the pixels into connected domains, and obtain a connected domain and a structure of the connected domain, the structure including the starting pixel parameters and the end pixel parameters of the connected domain and the gradient and grayscale coordinates of the pixels in the connected domain.

[0059] Optionally, the input data is an image pixel matrix, and the length and width of the matrix are determined according to the actual image size and resolution. This application is for processing each column of data. The height of the sliding window is 2, and the width is 1. The grayscale value of the previous pixel is stored in the upper window, and the grayscale value of the current pixel is stored in the lower window. The sliding window slides from top to bottom in the current column of pixels to obtain the gradient value of each pixel. A one-dimensional connected domain is generated according to the gradient value and grayscale value of the pixel, and the structure of each connected domain is stored. Among them, the structure of the connected domain includes: starting grayscale value, starting gradient value, starting coordinate, end grayscale value, end gradient value, end coordinate, number of pixels, grayscale sum, gradient sum and grayscale coordinate sum. Due to the limited storage resources in FPGA, the grayscale value and coordinate value of each pixel in the connected domain are not saved in this application to reduce calculation and storage consumption.

[0060] In one example, step S101 includes:

[0061] Step S1011, obtain the gray value of each pixel in the pixel column, and determine the gradient value of the current pixel according to the gray value of the current pixel and the gray value of the previous pixel. Optionally, the result of subtracting the gray value of the previous pixel from the gray value of the current pixel is used as the gradient value of the current pixel.

[0062] Step S1012, dividing the pixels in the pixel column into connected domains according to the gradient value and the grayscale value, and obtaining the connected domains and the structures of the connected domains.

[0063] In one example, step S1012 includes:

[0064] Step S121, judging whether the current pixel is a zero point or an accumulation point according to the gray value of the current pixel, and judging whether the current pixel is a saddle point according to the gradient value of the current pixel and the gradient value of the previous pixel.

[0065] Optionally, when the gray value of a pixel is less than a preset threshold, the pixel is classified as a "zero point"; when the gray value of a pixel is greater than a preset threshold, the pixel is classified as an "accumulation point". If the gradient direction of the current pixel and the previous pixel changes, for example, the gradient changes from positive to negative or from negative to positive, the current pixel is classified as a saddle point. The preset threshold for determining whether a pixel is a zero point or an accumulation point can be set according to actual application requirements.

[0066] Step S122: when the previous pixel is a zero point and the current pixel is an accumulation point, or the current pixel is a saddle point, the current pixel is used as the starting point of the current connected domain.

[0067] Step S123, when the previous pixel is an accumulation point and the current pixel is a zero point, or the next pixel is a saddle point, the current pixel is used as the end point of the current connected domain.

[0068] Optionally, starting from the starting point of the connected domain, each time a "cumulation point" is passed, the grayscale, gradient, and grayscale coordinates of the accumulation point pixels are accumulated to obtain the grayscale sum, gradient sum, and grayscale coordinate sum. Due to the limited storage resources in the FPGA, the grayscale value and coordinate value of each pixel in the connected domain are not saved in this application to reduce calculation and storage consumption. In this way, the pixels are classified according to the gradient value and grayscale value, and the starting point and end point of the connected domain are determined according to the category and order of the pixels, avoiding the influence and interference of the preset threshold alone on the connected domain extraction, and enhancing the stability of the method.

[0069] Step S102, completing the connected domain based on the starting pixel parameters and the end pixel parameters, calculating the grayscale mean of all pixels in the completed connected domain, and determining the weight of the connected domain according to the grayscale mean and the gradient.

[0070] Optionally, the connected domain is completed by linear interpolation and spline interpolation. Since the computing resources consumed by spline interpolation are large and it is not convenient to use in small hardware devices, the connected domain is completed by linear interpolation in this application to save computing resources. Since laser stripes and halos have different distribution characteristics, the grayscale distribution of laser stripes on the image usually roughly conforms to the characteristics of Gaussian distribution, while the grayscale distribution of halos often does not conform to the characteristics of Gaussian distribution. Therefore, the characteristics of laser stripes can be quantified by gradient sum. For example, if the grayscale distribution of the connected domain is a completely symmetrical Gaussian distribution, then the absolute value of the gradient sum in the connected domain is 0, and the larger the absolute value of the gradient sum, the less it conforms to the Gaussian distribution. Therefore, the connected domain weight is determined according to the absolute value of the grayscale mean and the gradient sum, which can effectively distinguish and filter stray light and halos.

[0071] In one example, the starting pixel parameters include a starting grayscale value and a starting gradient value, and the ending pixel parameters include an ending grayscale value and an ending gradient value. Step S102 includes:

[0072] The first supplementary pixel number on the starting point side is determined based on the starting point grayscale value and the starting point gradient value. The formula is as follows:

[0073]

[0074] Among them, N start Indicates the number of the first supplementary pixels on the starting point side, Y start Indicates the starting gray value, K start Indicates the starting gradient value.

[0075] The area of ​​the supplementary pixels on the starting point side and the grayscale value of each supplementary pixel are determined based on the starting point grayscale value, the starting point gradient value and the first number of supplementary pixels. The formula is as follows:

[0076]

[0077] Among them, B is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the starting point side, S start Indicates the area of ​​the supplementary pixels on the starting point side, N start Indicates the number of the first supplementary pixels on the starting point side, Y start Indicates the starting gray value, K start represents the starting point gradient value. Optionally, the area of ​​the supplementary pixels on the starting point side is the grayscale sum of the supplementary pixels on the starting point side. The number of pixels and the grayscale sum required to complete the starting point side of the connected domain can be simply calculated using the idea of ​​summing arithmetic progression.

[0078] The number of second supplementary pixels on the end point side is determined based on the end point grayscale value and the end point gradient value. The formula is as follows:

[0079]

[0080] Among them, N end Indicates the number of the second supplementary pixels on the end point side, Y end Indicates the end gray value, K end Indicates the end point gradient value.

[0081] The area of ​​the supplementary pixels on the end point side and the grayscale value of each supplementary pixel are determined based on the end point grayscale value, the end point gradient value and the second number of supplementary pixels.

[0082] Among them, C is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the end point side, S end Indicates the area of ​​the additional pixels on the end point side, N end Indicates the number of the second supplementary pixels on the end point side, Y end Indicates the end gray value, K end represents the end point gradient value. Optionally, the area of ​​the end point side supplementary pixels is the grayscale sum of the end point side supplementary pixels. The number of pixels and grayscale sum required to complete the end point side of the connected domain can be simply calculated using the idea of ​​summing arithmetic progression.

[0083] In one example, the structure of the connected domain also includes the initial number of pixels in the connected domain. The grayscale mean of all pixels in the completed connected domain is calculated in step S102, including:

[0084] The grayscale mean of all pixels in the connected domain after completion is calculated according to the grayscale sum, the area of ​​the supplementary pixels on the starting point side, the area of ​​the supplementary pixels on the end point side, the number of initial pixels, the number of first supplementary pixels and the number of second supplementary pixels. The calculation formula is as follows:

[0085]

[0086] Among them, GRAY averageRepresents the grayscale mean of all pixels in the connected domain after completion, S origin Represents the grayscale and S start represents the area of ​​the supplementary pixels on the starting point side, S end Indicates the area of ​​the supplementary pixels on the end point side, N origin Indicates the initial number of pixels, N start Indicates the number of first supplementary pixels, N end Optionally, the area of ​​the supplementary pixels at the starting point side is the grayscale sum of the supplementary pixels at the starting point side, and the area of ​​the supplementary pixels at the end point side is the grayscale sum of the supplementary pixels at the end point side.

[0087] In one example, step S102 includes: calculating the difference between the grayscale mean and the absolute value of the gradient sum, and using the difference as the weight of the connected domain.

[0088] Optionally, since laser stripes and halos have different distribution characteristics, usually the grayscale distribution of laser stripes on an image roughly conforms to the characteristics of a Gaussian distribution, while the grayscale distribution of a halo often does not conform to the characteristics of a Gaussian distribution. Therefore, the characteristics of the laser stripes can be quantified by the gradient sum. For example, if the grayscale distribution of a connected domain is a completely symmetrical Gaussian distribution, then the absolute value of the gradient sum in the connected domain is 0, and the larger the absolute value of the gradient sum, the less it conforms to the Gaussian distribution. Therefore, the difference between the grayscale mean and the absolute value of the gradient sum is used as the connected domain weight. The gradient sum absolute value of the laser stripes is closer to 0, while the gradient sum absolute value of the halo and stray light is larger. Correspondingly, the connected domain weights of the halo and stray light are smaller, so that stray light and halo can be effectively distinguished and filtered.

[0089] In this way, the connected domain is completed based on the starting point and end point of the connected domain by using linear interpolation method in step S102. After completion, the height of the connected domain increases, the average grayscale decreases, and its weight also decreases accordingly, thereby increasing the relative weight of the connected domain where the laser stripes are located, so as to enhance the characteristics of the halo and laser stripes, achieve the effect of anti-halo interference, and effectively improve the accuracy and stability of the laser stripe center extraction method.

[0090] Step S103, determining the target connected domain of each pixel column according to the weight, calculating the grayscale centroid coordinates of the target connected domain according to the grayscale sum and grayscale coordinates of the target connected domain, and taking the grayscale centroid coordinates of all target connected domains as the center of the laser stripe.

[0091] Optionally, according to the characteristics that the grayscale distribution of laser stripes on the image roughly conforms to the Gaussian distribution, while the grayscale distribution of halo often does not conform to the Gaussian distribution, the resulting gradient and absolute value of the laser stripes are closer to 0, while the gradient and absolute value of the halo and stray light are larger, and the weight of the connected domain of the halo and stray light is smaller. The connected domain is updated by comparing the weight of the connected domain, and the weight of the current connected domain and the target connected domain are compared and updated each time the refresh is performed until the extraction of a column of pixels is completed, the refresh is stopped, and the target connected domain of the column is output. Among them, the target connected domain is the connected domain where the laser stripes are located.

[0092] In one example, step S103 includes: taking the connected domain with the largest weight in the current pixel column as the target connected domain of the pixel column.

[0093] Optionally, the connected domain is updated by comparing the weights of the connected domains. The weights of the current connected domain and the target connected domain are compared each time the connected domain is refreshed. Assuming that the weight of the current connected domain is greater than the weight of the target connected domain, the current connected domain is used as the target connected domain. After a column of pixels is extracted, the refresh is stopped and the target connected domain of the column is output. In this way, the connected domain with the largest connected domain weight in each column of pixels is used as the target connected domain, which facilitates accurate extraction of the center of the laser stripe.

[0094] In one example, step S103 includes: obtaining the grayscale centroid coordinates of the target connected domain by dividing the grayscale coordinate sum of the target connected domain by the grayscale sum. Optionally, the grayscale coordinate sum in the connected domain divided by the grayscale sum is used as the grayscale centroid coordinates of the current connected domain.

[0095] Furthermore, since the laser stripe extraction method often needs to match high frame rate scenes, dedicated hardware is usually required to accelerate the image algorithm. Therefore, the method provided in this application is implemented in an FPGA chip, and the calculation is performed through the parallel unit in the FPGA, and then the PCB containing the FPGA is placed at the back end of the camera to achieve efficient edge intelligent computing. This application uses the parallel computing resources in the FPGA to perform parallel and efficient processing of each column of pixels in the image, which can not only reduce the power consumption of the camera device, but also greatly improve the performance of the camera, and meet the real-time and accuracy requirements of different production scenarios. Especially for some scenarios with high frame rate requirements, such as high-speed production line detection, the laser stripe center extraction method applied to FPGA devices provided in this application has high detection efficiency and accuracy in high-demand scenarios, which is conducive to improving product quality and production efficiency.

[0096] As an example, the input image size is 2048 pixels wide and 1216 pixels high. The present application uses FPGA to calculate 2048 columns at the same time, and generates the center coordinates of the laser stripes at the same time, and finally obtains 2048 center coordinates of the laser stripes. Figure 2FIG. 1 is a schematic diagram showing detection results before and after connected domain completion according to an exemplary embodiment. Figure 2 As shown in the figure, before completing the connected domain, the average grayscale of the connected domain where the upper halo is located is greater than the average grayscale of the connected domain where the lower laser stripes are located, because the grayscale values ​​of the starting point and the end point of the connected domain where the upper halo is located are relatively high. The linear interpolation method is used to complete the rising and falling curves of the starting point and the end point of the upper connected domain. After completion, the width of the upper connected domain increases, the average grayscale decreases, and the weight also decreases accordingly. In disguise, the relative weight of the connected domain where the lower laser stripes are located is increased. Figure 2 As shown in the figure, after the connected domain is completed, the relative weight of the connected domain where the laser stripes are located is improved, the detection accuracy of the center point of the laser stripes is improved, and the effect of resisting halo interference is achieved.

[0097] In summary, the present application divides the connected domain of the pixel points according to the ladder value and the grayscale value, and determines the starting point and end point of the connected domain according to the category and order of the pixel points, avoiding the influence and interference of the preset threshold alone on the connected domain extraction, and enhancing the stability of the method. Considering that the laser stripes and the halo have different distribution characteristics, the linear interpolation method is used to complete the connected domain based on the starting point and end point of the connected domain. After completion, the height of the connected domain increases, the average grayscale decreases, and its weight also decreases accordingly, thereby increasing the relative weight of the connected domain where the laser stripes are located, achieving the effect of anti-halo interference, and effectively improving the accuracy and stability of the laser stripe center extraction method. The image algorithm is accelerated by dedicated hardware, calculated by the parallel unit in the FPGA, and then the PCB containing the FPGA is placed at the back end of the camera to achieve efficient edge intelligent computing, reduce the power consumption of the camera device, greatly improve the performance of the camera, and meet the requirements of real-time and accuracy in different production scenarios. The laser stripe center extraction method applied to FPGA devices provided in this application has high detection efficiency and accuracy in high-demand scenarios, which is conducive to improving product quality and production efficiency.

[0098] In a second aspect, the embodiment of the present application provides a laser stripe center extraction system applied to an FPGA device. Figure 3 is a structural block diagram of a laser stripe center extraction system applied to an FPGA device according to an embodiment of the present application, such as Figure 3 As shown, the system includes:

[0099] Connected domain acquisition module 100: used to acquire pixel columns, collect pixels in the pixel columns from top to bottom using a sliding window, divide the pixels into connected domains, and obtain connected domains and structures of the connected domains, the structures including starting pixel parameters, end pixel parameters, and gradient and grayscale coordinates of pixels in the connected domains.

[0100] Connected domain completion module 200: used to complete the connected domain based on the starting pixel parameters and the end pixel parameters, calculate the grayscale mean of all pixels in the connected domain after completion, and determine the weight of the connected domain according to the grayscale mean and the gradient.

[0101] Determination module 300: used to determine the target connected domain of each pixel column according to the weight, calculate the grayscale centroid coordinates of the target connected domain according to the grayscale sum and grayscale coordinates of the target connected domain, and use the grayscale centroid coordinates of all target connected domains as the center of the laser stripe.

[0102] In one example, the connected domain acquisition module 100 includes:

[0103] It is used to obtain the gray value of each pixel in the pixel column and determine the gradient value of the current pixel based on the gray value of the current pixel and the gray value of the previous pixel.

[0104] The pixels in the pixel column are divided into connected domains according to the gradient value and the gray value to obtain the connected domains and the structures of the connected domains.

[0105] In one example, the connected domain acquisition module 100 includes:

[0106] It is used to determine whether the current pixel is a zero point or an accumulation point according to the gray value of the current pixel, and to determine whether the current pixel is a saddle point according to the gradient value of the current pixel and the gradient value of the previous pixel.

[0107] When the previous pixel is a zero point and the current pixel is an accumulation point, or the current pixel is a saddle point, the current pixel is used as the starting point of the current connected domain.

[0108] When the previous pixel is an accumulation point and the current pixel is a zero point, or the next pixel is a saddle point, the current pixel is taken as the end point of the current connected domain.

[0109] In one example, the starting pixel parameters include a starting grayscale value and a starting gradient value, the end pixel parameters include an end grayscale value and an end gradient value, and the connected domain completion module 200 includes:

[0110] The first supplementary pixel number on the starting point side is determined based on the starting point grayscale value and the starting point gradient value. The formula is as follows:

[0111]

[0112] Among them, N start Indicates the number of the first supplementary pixels on the starting point side, Y start Indicates the starting gray value, K start Indicates the starting gradient value.

[0113] The area of ​​the supplementary pixels on the starting point side and the grayscale value of each supplementary pixel are determined based on the starting point grayscale value, the starting point gradient value and the first number of supplementary pixels. The formula is as follows:

[0114]

[0115] Among them, B is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the starting point side, S start Indicates the area of ​​the supplementary pixels on the starting point side, N start Indicates the number of the first supplementary pixels on the starting point side, Y start Indicates the starting gray value, K start Indicates the starting gradient value.

[0116] The number of second supplementary pixels on the end point side is determined based on the end point grayscale value and the end point gradient value. The formula is as follows:

[0117]

[0118] Among them, N end Indicates the number of the second supplementary pixels on the end point side, Y end Indicates the end gray value, K end Indicates the endpoint gradient value.

[0119] The area of ​​the supplementary pixels on the end point side and the grayscale value of each supplementary pixel are determined based on the end point grayscale value, the end point gradient value and the second number of supplementary pixels.

[0120] Among them, C is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the end point side, S end Indicates the area of ​​the supplementary pixels on the end point side, N end Indicates the number of the second supplementary pixels on the end point side, Y end Indicates the end gray value, K end Indicates the endpoint gradient value.

[0121] In one example, the connected domain completion module 200 includes:

[0122] The grayscale mean of all pixels in the connected domain after completion is calculated according to the grayscale sum, the area of ​​the supplementary pixels on the starting point side, the area of ​​the supplementary pixels on the end point side, the number of initial pixels, the number of first supplementary pixels and the number of second supplementary pixels. The calculation formula is as follows:

[0123]

[0124] Among them, GRAY average Represents the grayscale mean of all pixels in the connected domain after completion, S origin Represents the grayscale and S start represents the area of ​​the supplementary pixels on the starting point side, S end Indicates the area of ​​the supplementary pixels on the end point side, N originIndicates the initial number of pixels, N start Indicates the number of first supplementary pixels, N end Indicates the number of second supplementary pixels.

[0125] In one example, the connected domain completion module 200 includes: calculating the difference between the grayscale mean and the absolute value of the gradient sum, and using the difference as the weight of the connected domain.

[0126] In one example, the determination module 300 includes: a module for taking a connected domain with the largest weight in the current pixel column as a target connected domain of the pixel column.

[0127] In one example, the determination module 300 includes: a method for obtaining the grayscale centroid coordinates of the target connected domain by dividing the grayscale coordinate sum of the target connected domain by the grayscale sum.

[0128] In summary, the present application divides the connected domain of the pixel points according to the ladder value and the grayscale value, and determines the starting point and end point of the connected domain according to the category and order of the pixel points, avoiding the influence and interference of the preset threshold alone on the connected domain extraction, and enhancing the stability of the method. Considering that the laser stripes and the halo have different distribution characteristics, the linear interpolation method is used to complete the connected domain based on the starting point and end point of the connected domain. After completion, the height of the connected domain increases, the average grayscale decreases, and its weight also decreases accordingly, thereby increasing the relative weight of the connected domain where the laser stripes are located, achieving the effect of anti-halo interference, and effectively improving the accuracy and stability of the laser stripe center extraction method. The image algorithm is accelerated by dedicated hardware, calculated by the parallel unit in the FPGA, and then the PCB containing the FPGA is placed at the back end of the camera to achieve efficient edge intelligent computing, reduce the power consumption of the camera device, greatly improve the performance of the camera, and meet the requirements of real-time and accuracy in different production scenarios. The laser stripe center extraction method applied to FPGA devices provided in this application has high detection efficiency and accuracy in high-demand scenarios, which is conducive to improving product quality and production efficiency.

[0129] In a third aspect, an embodiment of the present application provides an electronic device, Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the laser stripe center extraction method applied to an FPGA device provided in the first aspect is implemented. Figure 4 The electronic device 60 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0130] The electronic device 60 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 60 may include but are not limited to: at least one processor 61, at least one memory 62, and a bus 63 connecting different system components (including the memory 62 and the processor 61).

[0131] The bus 63 includes a data bus, an address bus, and a control bus.

[0132] The memory 62 may include a volatile memory, such as a random access memory (RAM) 621 and / or a cache memory 622 , and may further include a read-only memory (ROM) 623 .

[0133] The memory 62 may also include a program / utility 625 having a set (at least one) of program modules 624, such program modules 624 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0134] The processor 61 executes various functional applications and data processing by running the computer program stored in the memory 62, such as the laser stripe center extraction method applied to the FPGA device provided in the first aspect of the present application.

[0135] The electronic device 60 may also communicate with one or more external devices 64 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 65. Furthermore, the model-generated device 60 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 66. As shown, the network adapter 66 communicates with other modules of the model-generated device 60 via a bus 63. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the model-generated device 60, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.

[0136] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.

[0137] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0138] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A laser stripe center extraction method applied to FPGA equipment, characterized in that: include: Obtain a pixel column, use a sliding window to collect pixels in the pixel column from top to bottom, divide the pixels into connected domains, and obtain a connected domain and a structure of the connected domain, wherein the structure includes a starting pixel parameter, an end pixel parameter, and a gradient sum and a grayscale coordinate sum of pixels in the connected domain; The connected domain is completed based on the starting pixel parameter and the end pixel parameter, the grayscale mean of all pixels in the completed connected domain is calculated, and the weight of the connected domain is determined according to the grayscale mean and the gradient sum, wherein the starting pixel parameter includes a starting grayscale value and a starting gradient value, and the end pixel parameter includes an end grayscale value and an end gradient value, and the completing the connected domain based on the starting pixel parameter and the end pixel parameter includes: The first supplementary pixel number on the starting point side is determined based on the starting point grayscale value and the starting point gradient value, and the formula is as follows: Among them, N start represents the first supplementary pixel number on the starting point side, Y start represents the gray value of the starting point, K start represents the starting point gradient value, The area of ​​the supplementary pixels on the starting point side and the grayscale value of each supplementary pixel are determined based on the starting point grayscale value, the starting point gradient value and the first number of supplementary pixels, and the formula is as follows: Among them, B is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the starting point side, S start represents the area of ​​the supplementary pixels on the starting point side, N start represents the first supplementary pixel number on the starting point side, Y start represents the gray value of the starting point, K start represents the starting point gradient value, The number of second supplementary pixels on the end point side is determined based on the end point grayscale value and the end point gradient value, and the formula is as follows: Among them, N end Indicates the number of the second supplementary pixels on the end point side, Y end represents the end point gray value, K end represents the endpoint gradient value, Determine the area of ​​the supplementary pixels on the end point side and the grayscale value of each supplementary pixel based on the end point grayscale value, the end point gradient value and the second number of supplementary pixels, Among them, C is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the end point side, S end represents the area of ​​the supplementary pixels on the end point side, N end Indicates the number of the second supplementary pixels on the end point side, Y end represents the endpoint gray value, K end represents the endpoint gradient value; The target connected domain of each pixel column is determined according to the weight, the grayscale centroid coordinates of the target connected domain are calculated according to the grayscale sum and grayscale coordinates of the target connected domain, and the grayscale centroid coordinates of all the target connected domains are used as the laser stripe center.

2. The laser stripe center extraction method according to claim 1, characterized in that: The method of using a sliding window to collect pixels in the pixel column from top to bottom, dividing the pixels into connected domains, and obtaining connected domains and structures of the connected domains includes: Obtaining the grayscale value of each pixel in the pixel column, and determining the gradient value of the current pixel according to the grayscale value of the current pixel and the grayscale value of the previous pixel; The pixels in the pixel column are divided into connected domains according to the gradient value and the grayscale value to obtain a connected domain and a structure of the connected domain.

3. The laser stripe center extraction method according to claim 2, characterized in that: The dividing the pixels in the pixel column into connected domains according to the gradient value and the grayscale value comprises: According to the gray value of the current pixel, determine whether the current pixel is a zero point or an accumulation point, and according to the gradient value of the current pixel and the gradient value of the previous pixel, determine whether the current pixel is a saddle point; When the previous pixel is a zero point and the current pixel is an accumulation point, or the current pixel is a saddle point, the current pixel is used as the starting point of the current connected domain; When the previous pixel is an accumulation point and the current pixel is a zero point, or the next pixel is a saddle point, the current pixel is taken as the end point of the current connected domain.

4. The laser stripe center extraction method according to claim 1, characterized in that: The structure of the connected domain also includes the initial number of pixels in the connected domain, and the grayscale mean of all pixels in the connected domain after calculation and completion includes: The grayscale mean of all pixels in the connected domain after completion is calculated according to the grayscale sum, the area of ​​the supplementary pixels on the starting point side, the area of ​​the supplementary pixels on the end point side, the initial number of pixels, the first number of supplementary pixels and the second number of supplementary pixels. The calculation formula is as follows: Among them, GRAY average Represents the grayscale mean of all pixels in the connected domain after completion, S origin Represents the grayscale and, S start represents the area of ​​the supplementary pixel on the starting point side, S end represents the area of ​​the supplementary pixels on the end point side, N origin represents the initial number of pixels, N start represents the first supplementary pixel number, N end represents the second supplementary pixel number.

5. The laser stripe center extraction method according to claim 1, characterized in that: Determining the weight of the connected domain according to the grayscale mean and the gradient sum includes: The difference between the grayscale mean and the absolute value of the gradient sum is calculated, and the difference is used as the weight of the connected domain.

6. The laser stripe center extraction method according to claim 1, characterized in that: The step of determining a target connected domain of each pixel column according to the weight comprises: The connected domain with the largest weight in the current pixel column is used as the target connected domain of the pixel column.

7. The method for extracting the center of a laser stripe according to claim 1, characterized in that: The step of calculating the grayscale centroid coordinates of the target connected domain according to the grayscale sum and grayscale coordinates of the target connected domain comprises: The grayscale centroid coordinates of the target connected domain are obtained by dividing the grayscale coordinate sum of the target connected domain by the grayscale sum.

8. A laser stripe center extraction system applied to FPGA equipment, characterized in that: include: Connected domain acquisition module: used to acquire pixel columns, collect pixels in the pixel columns from top to bottom using a sliding window, divide the pixels into connected domains, and obtain connected domains and structures of the connected domains, wherein the structures include starting pixel parameters and end pixel parameters of the connected domains, and the gradient sum and grayscale coordinate sum of the pixels in the connected domains; A connected domain completion module: used to complete the connected domain based on the starting pixel parameters and the end pixel parameters, calculate the grayscale mean of all pixels in the completed connected domain, and determine the weight of the connected domain according to the grayscale mean and the gradient sum, wherein the starting pixel parameters include the starting grayscale value and the starting gradient value, and the end pixel parameters include the end grayscale value and the end gradient value, and the completion of the connected domain based on the starting pixel parameters and the end pixel parameters includes: The first supplementary pixel number on the starting point side is determined based on the starting point grayscale value and the starting point gradient value, and the formula is as follows: Among them, N start represents the first supplementary pixel number on the starting point side, Y start represents the gray value of the starting point, K start represents the starting point gradient value, The area of ​​the supplementary pixels on the starting point side and the grayscale value of each supplementary pixel are determined based on the starting point grayscale value, the starting point gradient value and the first number of supplementary pixels, and the formula is as follows: Among them, B is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the starting point side, S start represents the area of ​​the supplementary pixels on the starting point side, N start represents the first supplementary pixel number on the starting point side, Y start represents the gray value of the starting point, K start represents the starting point gradient value, The number of second supplementary pixels on the end point side is determined based on the end point grayscale value and the end point gradient value, and the formula is as follows: Among them, N end Indicates the number of the second supplementary pixels on the end point side, Y end represents the end point gray value, K end represents the endpoint gradient value, Determine the area of ​​the supplementary pixels on the end point side and the grayscale value of each supplementary pixel based on the end point grayscale value, the end point gradient value and the second number of supplementary pixels, Among them, C is an arithmetic progression used to represent the grayscale values ​​of all supplementary pixels on the end point side, S end represents the area of ​​the supplementary pixels on the end point side, N end Indicates the number of the second supplementary pixels on the end point side, Y end represents the endpoint gray value, K end represents the endpoint gradient value; Determination module: used to determine the target connected domain of each pixel column according to the weight, calculate the grayscale centroid coordinates of the target connected domain according to the grayscale sum and grayscale coordinates of the target connected domain, and use the grayscale centroid coordinates of all the target connected domains as the center of the laser stripe.

9. An electronic device, characterized in that: The invention comprises a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for extracting the center of a laser stripe applied to an FPGA device as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Systems and methods for image processing

    US20240013391A1

  • Calibration method and calibration device for line structured light measurement system, and system

    WO2022143796A1