A workpiece scanning method and related equipment based on a line scan camera

By adjusting the luminous intensity and mode of the line scan light source, and considering the non-uniformity of the workpiece surface, the problem of image non-uniformity in the line scan solution was solved, achieving a highly efficient workpiece scanning effect.

CN122858323BActive Publication Date: 2026-11-17RSEE LIGHTING TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202611347285.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-09-02
Publication Date
2026-11-17
Estimated Expiration
2046-09-02

AI Technical Summary

Technical Problem

Existing line scanning solutions are prone to uneven image imaging when inspecting workpieces with uneven surface conditions, resulting in some areas being overexposed and others being underexposed, which fails to meet the requirements for efficient inspection.

Method used

By accumulating the real-time scan lines of the line scan camera, the line number range is determined, and the luminous intensity and mode of the line scan light source are adjusted according to the range, including setting different flicker times and line-by-line changes, to ensure that the light source output adapts to the non-uniformity of the workpiece surface.

Benefits of technology

It improves the scanning uniformity and detection efficiency of workpieces with uneven surface conditions without increasing the number of cameras, thus avoiding the need for multiple scanning stations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122858323B_ABST
    Figure CN122858323B_ABST
Patent Text Reader

Abstract

This application relates to the field of visual scanning technology, providing a workpiece scanning method and related equipment based on a line scan camera. The method includes: during the scanning process of a workpiece by a line scan light source and a line scan camera working together, accumulating the real-time scan lines of the line scan camera; determining the line number interval to which the real-time scan lines belong; determining the light source mode according to the line number interval; when the light source mode is a first mode, controlling the output of the line scan light source to a set luminous intensity; when the light source mode is a second mode, controlling the output luminous intensity of the line scan light source to change line by line during each scan of the line scan camera within the line number interval. This application sets different modes of the line scan light source according to the number of scan lines. When the surface condition of the workpiece is uneven, the uniformity of the scan is improved by changing the line scan light source, eliminating the need for multiple scanning stations; a clear scan can be achieved with just one station.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of visual scanning, and more specifically to a workpiece scanning method and related equipment based on a line scan camera. Background Technology

[0002] Line scan light sources feature ultra-high brightness and high uniformity, and are designed specifically for high-speed continuous production line operations. They can work perfectly with line scan cameras to achieve real-time and rapid detection of moving objects, thereby improving the automation level and production efficiency of industrial production.

[0003] Existing line scanning solutions are mostly used to inspect workpieces with uniform surface conditions, such as metals, plastics, paper, and fibers. The object being inspected usually moves at a constant speed, and one or more cameras are used to scan it line by line to achieve uniform inspection of its entire surface.

[0004] When the object being inspected is a workpiece with an uneven surface condition, uneven image imaging will occur, with some areas being overexposed and others being underexposed.

[0005] Therefore, when conventional line scanning solutions need to inspect workpieces with uneven surface conditions, in order not to affect efficiency, the number of cameras can only be increased, and multiple camera stations (a combination of light source and camera) can be used to take pictures. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this application provides a workpiece scanning method based on a line scan camera, the technical solution of which is as follows: In a first aspect, embodiments of this application provide a workpiece scanning method based on a line scan camera. The method includes: during the scanning process of the workpiece by the line scan light source and the line scan camera in collaboration, accumulating the real-time scan lines of the line scan camera; determining the row number interval to which the real-time scan lines belong; determining the light source mode according to the row number interval; when the light source mode is a first mode, controlling the line scan light source to output a set luminous intensity during each scan of the line scan camera within the row number interval; wherein, when the first mode exists, the first mode belongs to at least two row number intervals; when the light source mode is a second mode, controlling the luminous intensity output by the line scan light source to change line by line during each scan of the line scan camera within the row number interval.

[0007] In a second aspect, this application provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform a workpiece scanning method based on a line scan camera as described in the first aspect.

[0008] Thirdly, this application provides a computer-readable storage medium storing an executable program, which is executed by a processor to implement the workpiece scanning method based on a line scan camera as described in the first aspect.

[0009] Fourthly, this application provides a computer program product, which includes a computer program that, when executed by a processor, implements the workpiece scanning method based on a line scan camera as described in the first aspect.

[0010] One of the beneficial effects of this application is that the line scan light source is set to different modes according to the number of scan lines. When the surface condition of the workpiece is uneven, the uniformity of scanning is improved by changing the line scan light source. There is no need to set up multiple scanning stations, and clear scanning can be achieved by one station. Attached Figure Description

[0011] Figure 1 This is a schematic flowchart of the workpiece scanning method based on a line scan camera provided in the embodiments of this application.

[0012] Figure 2 This is a schematic diagram of the software settings provided in the embodiments of this application.

[0013] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0014] Figure 4 This is a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. Detailed Implementation

[0015] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0016] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0017] For ease of description of the first and second directions in the embodiments of this application, the first direction is the up-down direction in the figures, the second direction is the front-back direction in the figures, and the third direction is the left-right direction in the figures. The x-axis arrow direction is referred to as the "up" direction, the y-axis arrow direction as the "back" direction, and the z-axis arrow direction as the "right" direction, but these are not the sole limitations in the actual application of this application.

[0018] Please see Figure 1 , Figure 1 This is a schematic flowchart of the workpiece scanning method based on a line scan camera provided in an embodiment of this application. Figure 1 As shown, the workpiece scanning method 100 based on a line scan camera of this application includes steps 101 to 105.

[0019] Step 101: During the scanning process of the workpiece by the line scan light source and the line scan camera, accumulate the real-time scan lines of the line scan camera.

[0020] In related technologies, to address workpieces with uneven surface conditions, a solution typically employs multiple scanning stations. In this approach, the luminous intensity of the light source at each scanning station is pre-set for the workpiece area it covers, representing a static configuration. Once set, the light source parameters remain unchanged throughout the scanning process of that area.

[0021] In step 101, the time sequence of the scanning process and the spatial position of the workpiece are established by accumulating the number of real-time scan rows. Based on this row count information, the light source output can be independently set according to the surface characteristics of the workpiece corresponding to each row during scanning, ensuring that any local reflectivity difference on the workpiece surface can be compensated accordingly.

[0022] Optionally, after each line of image exposure and readout is completed, the line scan camera generates a level transition signal via its dedicated output pin. This signal is called the line valid signal or line sync signal. During the scanning process, the number of rising or falling edges of the line valid signal can be used to determine the number of lines scanned in real time.

[0023] Step 102: Determine the row number range to which the real-time scanned row number belongs.

[0024] Optionally, before scanning the workpiece, a pre-scan is performed on the workpiece. The pre-scan is used to determine the total number of scan lines after the scan is completed, thereby dividing the workpiece into multiple line number intervals based on the total number of scan lines.

[0025] Step 103: Determine the light source mode based on the row number range it belongs to.

[0026] Optionally, the light source mode can be determined based on the mapping relationship between the row number interval and the light source mode.

[0027] Step 104: When the light source mode is the first mode, when the line scan camera scans each line within the corresponding line number interval, control the line scan light source to output a set luminous intensity; wherein, when the first mode exists, the first mode belongs to at least two line number intervals.

[0028] Specifically, the first mode is for a workpiece with at least two regions whose surface conditions (such as color, material, reflectivity) are different from each other, but the surface conditions within each region are spatially uniform.

[0029] For example, a workpiece surface includes a white area and a black area.

[0030] White areas: These areas have high reflectivity (e.g., approximately 90%). Under the same lighting conditions, this area will reflect most of the incident light back to the line scan camera. If the default longer strobe time is used, this area will be overexposed, resulting in loss of detail.

[0031] Black areas: Low reflectivity (e.g., about 5%). This area reflects only a very small amount of incident light. Using the same flicker time as the white areas will result in severe underexposure of this area, making defect features undetectable.

[0032] The two regions differ by orders of magnitude in absolute reflectance, but the reflectance within each region remains essentially constant in spatial distribution. The white region exhibits high reflectance throughout, while the black region exhibits low reflectance throughout, with no directional trend of gradual brightening or darkening.

[0033] In this scenario, both areas are configured with the first light source mode. They have the same mode type, but their corresponding mode parameters, i.e., the specific luminous intensity settings, are different. The white area should be configured with a shorter flicker time to reduce exposure, while the black area should be configured with a longer flicker time to increase exposure.

[0034] Optionally, the luminous intensity of the line scan light source can be controlled by setting the flicker time.

[0035] The flicker time refers to the duration of the light source in each line scan cycle of the line scan camera, from the moment it is lit to the moment it is turned off. The longer the flicker time, the brighter the image captured by the line scan camera.

[0036] Step 105: When the light source mode is the second mode, the light intensity output by the line scan light source is controlled to change line by line during each scan of the line scan camera within the range of the corresponding number of lines.

[0037] Specifically, the second mode targets a type of workpiece surface where there is at least one region whose surface state changes continuously and directionally in space, i.e., the reflectivity gradually increases or decreases along the scanning direction, rather than remaining constant.

[0038] For example, a garment fabric surface includes a gradient color printed area. Within this area, the color transitions continuously from a light color (such as white) to a dark color (such as dark blue) from one end to the other.

[0039] The characteristic of this gradient region is that there are no clear boundaries that can further divide the region into several internally uniform sub-regions. Each scan line position within the region corresponds to a unique reflectance value, and the reflectance difference between adjacent lines is extremely small but continuously accumulates, forming a macroscopic color gradient.

[0040] Please refer to the following: Figure 2 , Figure 2 This is a schematic diagram of the software settings provided in an embodiment of this application. For example... Figure 2 As shown, for a specific type of clothing, Figure 2 The scanning process is set up by first setting a second mode with increasing strobe value, interspersing multiple first modes with different strobe values ​​in between, and finally setting a second mode with decreasing strobe value. Thus, the luminous intensity (strobe value) of the line scan light source changes continuously during a scanning process, enabling a single line scan camera to scan workpieces with uneven surface conditions.

[0041] in, Figure 2 There are two line scan light sources, namely light source CH1 and light source CH2. Light source CH1 and light source CH2 assist the same line scan camera to perform scanning, thereby realizing time-division stroboscopic scanning. Finally, the line scan camera takes a black and white image, which is called dark field and bright field respectively. Then, the black and white image is split into a dark image and a bright image by the algorithm software.

[0042] In one possible approach, the range of rows corresponding to each row number interval, as well as the light source mode and light source parameters for each row number interval, are all manually set by the user.

[0043] In another possible approach, the number of rows and the light source mode are automatically divided by software. In this case, the workpiece scanning method 100 based on the line scan camera provided in this application further includes steps 106 to 110 before step 101.

[0044] Step 106: Obtain the total number of scan lines of the workpiece scanned by the line scan camera.

[0045] The total number of scan lines can be determined in advance by pre-scanning the workpiece.

[0046] Step 107: Divide the total number of scan lines into multiple line intervals based on the surface condition characteristics of the workpiece.

[0047] Optionally, the surface state features that affect the lighting effect of the light source include at least one of the following: color features, material features, and geometric features.

[0048] Optionally, in order to better divide the workpiece into regions, step 107 includes steps 1071 to 1078.

[0049] Step 1071: Import the 3D model of the workpiece into 3D software and extract the features of all surface points of the 3D model of the workpiece. The features corresponding to each surface point include spatial coordinates, surface normal vector and reflectivity.

[0050] In this context, a 3D model refers to a data file generated using computer-aided design software, containing the complete geometry and surface material properties of a workpiece. This 3D model discretizes the continuous surface of the workpiece into a finite set of surface points. Each surface point represents a tiny polygon on the workpiece surface, carrying at least the following attribute information: Spatial coordinates (x, y, z): The three-dimensional spatial position of this surface point in a preset workpiece coordinate system. The workpiece coordinate system is a rectangular coordinate system established with a reference point on the workpiece (such as the geometric center or the starting corner of the scan) as the origin, used to uniformly describe the relative positional relationships of various points on the workpiece.

[0051] Surface normal vector (nx, ny, nz): A unit vector perpendicular to the tangent plane of the workpiece surface at this surface point, pointing outwards from the workpiece. This surface normal vector is used to subsequently calculate the angle of incidence of the light emitted from the virtual light source relative to this surface point.

[0052] Reflectivity ρ: The overall reflectivity of this surface point to light within the operating wavelength band of the line-scanned light source. The reflectivity is a dimensionless value, ranging from [0,1]. ρ=0 indicates complete absorption, and ρ=1 indicates complete reflection. When the surface characteristics include color features, the reflectivity can be the equivalent reflectivity obtained by weighted averaging of the light source's spectral power distribution; when the surface characteristics include material features, the reflectivity can be determined based on the value of the material's bidirectional reflectance distribution function in the camera's receiving direction.

[0053] Step 1072: Generate a virtual line scan light source model in the 3D software and set the optical characteristic parameters.

[0054] Specifically, based on the specifications of the line scan light source used in the actual scanning system, a corresponding virtual line scan light source model is generated in the simulation environment of the 3D software. The virtual line scan light source model is a digital description of the light emission behavior of the actual line scan light source, and its optical characteristic parameters include at least: Spatial position and emission direction of the light source: Define the three-dimensional coordinates of the virtual line scan light source model in the workpiece coordinate system and its main emission direction vector. This position and direction are consistent with the mounting pose of the line scan light source relative to the workpiece scanning plane in the actual scanning system.

[0055] Outgoing light intensity distribution: describes the spatial distribution of radiation intensity at various points on the emitting surface of the virtual linear scanned light source model. It can be simplified to a uniform surface light source model, where the instantaneous radiant power P_0 at each point on the emitting surface is the same and constant.

[0056] Emitted light spectrum: Describes the spectral power distribution of the emitted light from the virtual line-scanned light source model, used to calculate the amount of reflected light in conjunction with the reflectivity properties of surface points. In simplified models, the light source can be assumed to be monochromatic or narrowband, and the reflectivity values ​​for the corresponding wavelengths can be used directly.

[0057] Optionally, the number of light source models is consistent with the number of light sources in the actual scanning scene. Therefore, the number of light source models can be one or more, and this application does not impose any restrictions.

[0058] Step 1073: Set multiple candidate strobe times to form a candidate strobe time sequence.

[0059] Step 1074: Control the virtual line scan light source model to simulate each candidate stroboscopic time in sequence, and obtain the imaging grayscale values ​​of all surface points of the 3D model of the workpiece after each simulation.

[0060] Optionally, step 1074 includes steps 10741 to 10743.

[0061] Step 10741: Calculate the incident light energy at each surface point during the candidate stroboscopic time.

[0062] Optionally, for each surface point P(x,y,z) on the three-dimensional digital model, its spatial coordinates and surface normal vector extracted in step 1071 are obtained. Based on the spatial position and emission direction of the virtual line scan light source model, the direction vector of the incident ray pointing from the light source to the surface point P is determined, and the angle between the direction vector of the incident ray and the surface normal vector of the surface point P is calculated and denoted as the ray incident angle θ.

[0063] When θ ≥ 90°, it indicates that the surface point is facing away from the light source, the incident light energy is zero, and the surface point is within the candidate stroboscopic time T. j The image grayscale value is directly set to the preset background grayscale value, skipping subsequent calculations.

[0064] When θ < 90°, calculate the illumination intensity reaching surface point P based on the emitted light intensity distribution and distance attenuation characteristics of the light source. For a uniform surface light source model, It is a constant I0 or calculated according to a preset distance attenuation function.

[0065] Surface point P at candidate stroboscopic time T j The incident light energy obtained inside Calculate using the following formula:

[0066] Step 10742: Convert the incident light energy into reflected light energy based on reflectivity.

[0067] Optionally, the reflectivity ρ(P) extracted from the surface point P in step 1071 is obtained. The reflectivity ρ(P) is defined as the proportion of incident light energy reflected by the surface point P, and its value ranges from [0,1].

[0068] incident light energy Multiplying by the reflectivity ρ(P), we obtain the reflected light energy from surface point P towards the camera. .

[0069] Step 10743: Convert the reflected light energy into image grayscale values.

[0070] Optionally, the simulation imaging unit has a preset camera response model for mapping the received reflected light energy into image grayscale values.

[0071] Optionally, the mapping relationship between reflected light energy and imaging grayscale value can be obtained by looking up a preset mapping relationship table.

[0072] Optionally, the calculation formula for the linear mapping model between reflected light energy and imaging grayscale value provided in this application is as follows:

[0073] in, Let surface point P be at candidate stroboscopic time T j The simulated image grayscale value is a dimensionless value, and its range is determined by the camera's output bit depth (e.g., [0, 255] for an 8-bit image); α is the system gain coefficient, which comprehensively characterizes factors such as camera quantum efficiency, lens aperture, and analog-to-digital conversion gain, and can be obtained through actual system calibration; β is the dark current bias, which represents the camera's background grayscale output value under no-light conditions.

[0074] Through steps 10741 to 10743 above, for each candidate stroboscopic time T jThe simulation imaging unit generates a grayscale value mapping table, recording the relationship between each surface point P on the three-dimensional digital model of the workpiece and the candidate stroboscopic time T. j The corresponding simulated image grayscale value G(P, T) j ).

[0075] Step 1075: Establish a target grayscale range and set the surface points located within the target grayscale range to belong to the same region corresponding to the current candidate flicker time.

[0076] The target grayscale range refers to the desired range of grayscale values ​​to be obtained in the final scanned image. The target grayscale range can be represented as [G_low, G_high], where G_low is the lower limit of the target grayscale and G_high is the upper limit of the target grayscale.

[0077] Through this step, N regions R1, R2, ..., R corresponding one-to-one with the candidate flicker times are obtained. n .

[0078] Step 1076: Based on the scanning direction of the line scan light source, classify all surface points in the 3D model of the workpiece into multiple scan lines.

[0079] Optionally, the scanning direction of the line scan camera during actual scanning can be obtained. The scanning direction refers to the direction in which the workpiece moves relative to the line scan camera during the scanning process.

[0080] On a plane perpendicular to the scanning direction, a set of parallel planes are established with a row width Δy as the spacing. The intersection of each plane with the workpiece surface constitutes a scanning line. Surface points located within the neighborhood of the same intersection line are assigned to the same scanning line Li.

[0081] Optionally, the line width Δy is consistent with the physical width of a single line scan covered by the line scan camera in the actual scanning system. Its value is determined by the pixel size of the camera sensor and the magnification of the lens, and is given as a preset parameter in the simulation.

[0082] Through this step, all surface points on the workpiece surface are assigned to M scan lines L1, L2, ..., LM.

[0083] Step 1077: Determine the number of surface points belonging to each region in each scan line, and divide the scan line into the region with the largest number of surface points belonging to each region.

[0084] For example, if 80% of the surface points of a scan line belong to a first region and 20% of the surface points belong to a second region, then the scan line is determined to belong to the first region.

[0085] Through this step, each scan line Li is assigned a unique membership region.

[0086] Step 1078: Merge adjacent scan lines belonging to the same region to divide the total number of scan lines into multiple line number intervals.

[0087] Optionally, the membership region of each scan line Li is checked sequentially along the scanning direction, and adjacent scan lines with consecutive scan line numbers i and the same membership region are merged into a single line number interval.

[0088] For each range of row numbers, record the following information: The starting scan row number, which is the smallest scan row number contained within this range.

[0089] End of scan line number, the maximum number of scan lines contained in this range.

[0090] The corresponding candidate flicker time is the candidate flicker time of the region to which this row number interval belongs.

[0091] The above steps enable automated division of workpiece areas, reducing manual labeling time.

[0092] Step 108: Determine the region type for each region.

[0093] Optionally, step 108 may include steps 1081 to 1087.

[0094] Step 1081: Obtain M regions arranged sequentially along the scanning direction, and the corresponding strobe time for each region, where M is a positive integer greater than or equal to 2.

[0095] The flicker time corresponding to each region can be the candidate flicker time in step 1075.

[0096] Step 1082: Calculate the gradient of the stroboscopic time change between adjacent regions to obtain a gradient sequence consisting of M-1 gradient values; where the i-th gradient value is the difference between the stroboscopic time corresponding to the (i+1)-th region and the stroboscopic time corresponding to the i-th region, i=1, 2, ..., M-1.

[0097] Step 1083: Determine the gradient threshold and the minimum number of gradient regions, and initialize the gradient segment start number start=1, the gradient segment end number end=1, and the gradient number k=1.

[0098] Step 1084: Determine if k is less than or equal to M-1. If so, perform a gradient condition check on the k-th gradient; otherwise, proceed to the final processing step.

[0099] Step 1085: The gradient condition determination includes: if the absolute value of the k-th gradient is less than the gradient threshold, and the sign of the k-th gradient is the same as the confirmed gradient direction in the gradient segment when end is greater than start, then it is determined that the gradient condition is met, end is updated to k+1, k=k+1, and the step of determining whether k is less than or equal to M-1 is returned; otherwise, it is determined that the gradient condition is not met.

[0100] Step 1086: When the gradient condition is not met, determine the number of regions contained in the current gradient segment based on start and end. If the number of regions is greater than or equal to the minimum number of gradient regions, merge all regions from start to end into one region and determine the region type of the merged region as gradient color. If the number of regions is less than the minimum number of gradient regions, determine the region type of each region from start to end as solid color. Then, reset both start and end to k+1, let k=k+1, and return to the step of determining whether k is less than or equal to M-1.

[0101] Step 1087: The end processing step includes: determining the number of regions based on the current start and end; if the number of regions is greater than or equal to the minimum number of gradient regions, then all regions from start to end are merged into one region, and the region type of the merged region is determined to be gradient color; otherwise, the region type of each region from start to end is determined to be solid color.

[0102] Specifically, the detailed process steps in steps 1083 to 1087 are as follows: S1: Set the start number of the gradient segment start=1, the end number end=1, and the gradient traversal number k=1.

[0103] S2: Determine if k is less than or equal to M-1; if yes, execute S3; otherwise, jump to S7.

[0104] Specifically, M equals the total number of regions arranged sequentially along the scanning direction.

[0105] S3: Check whether the current k-th strobe time change gradient LAk satisfies the following two conditions: Condition 1: |Δk|<δ; δ is the gradual threshold.

[0106] Condition 2: If end > start, then the sign of Δk must be the same as the confirmed gradient direction in the current gradient segment (i.e., consistent with the sign of the existing gradient in the segment); if end = start, then no direction comparison is required, and this condition is satisfied by default.

[0107] If condition 1 and condition 2 are satisfied, it is determined that the gradient condition is met, and S4 is executed; otherwise, it is determined that the gradient condition is not met, and S5 is executed.

[0108] S4: Extend the gradient segment, update end = k+1, set k = k+1, and return to S2.

[0109] S5: Process the ended gradient segment, and calculate the number of regions contained in the current gradient segment as count=end-start +1; If count ≥ Q_min, merge the regions R_start to R_end into one region, determine the region type thereof as gradient color, and execute S6; If count<Q_min, determine each of the regions R_start to R_end as a solid color respectively, and execute S6.

[0110] S6: Reset the pointer and continue Set start = k+1, end = k+1, k = k+1, and return to S2.

[0111] S7: End segment processing Calculate the number of regions in the end segment as count = end-start+1; If count ≥ Q_min, merge the regions R_start to R_end into one region, and determine the region type thereof as gradient color; Otherwise, determine each of the regions R_start to R_end as a solid color respectively.

[0112] S8: After the end segment processing is completed, the process ends.

[0113] Step 109: Configure the light source mode for each of the row number intervals according to the region type of each of the regions.

[0114] Optionally, the surface state features include color features, and step 109 includes step 1091 to step 1092.

[0115] Step 1091: When the region type of the region is a solid color, configure the light source mode of the corresponding row number interval as a first mode.

[0116] Step 1092: When the region type of the region is a gradient color, configure the light source mode of the corresponding row number interval as a second mode.

[0117] Optionally, simply configuring the mode is insufficient for accurate scanning of the workpiece; further configuration of the mode parameters is required. In this case, the method further includes configuring the mode parameters corresponding to the light source mode for each of the line number intervals. The mode parameters for the first mode include the flicker time of the line scan light source during each line scan by the line scan camera. The mode parameters for the second mode include the gradient direction and the total gradient intensity. After each line scan by the line scan camera, the change in the flicker time of the line scan light source is equal to the total gradient intensity / the total number of lines in the line number interval.

[0118] Optionally, the flicker time of the line scan light source during each line scan of the line scan camera in the mode parameters of the first mode can be determined when dividing the area, for example, set to the flicker time of each area determined in steps 1071 to 1078, or can be set manually. This application does not impose any restrictions on this.

[0119] Optionally, in the mode parameters of the second mode, the gradient direction and the total value of the gradient intensity can be determined when dividing the region. For example, the total value of the gradient intensity can be determined based on the minimum and maximum flicker times in the merged gradient regions obtained in steps 1081 to 1087, while the gradient direction has been directly determined in steps 1051 to 1087.

[0120] Furthermore, in the above scheme, different light source modes and luminous intensities are assigned to different row number intervals, resulting in abrupt changes in luminous intensity at the boundaries of these intervals. When the brightness settings of adjacent intervals differ significantly, this abrupt change directly leads to visible bright and dark stripes or seams on the image, affecting the continuity of subsequent image stitching and defect detection. This is analogous to taking two photos with a camera, one facing a strong light source and the other facing a dark area, and then stitching these two photos together with their top and bottom edges touching. Although their exposures are independent, the brightness contrast at the stitching point will clearly give the impression of a "seam."

[0121] Based on this, this application provides the following solution to eliminate brightness steps between adjacent pixel rows, wherein method 100 further includes steps 110 to 117.

[0122] Step 110: Obtain the first and second strobe time boundary values ​​of the Nth row interval and the (N+1)th row interval; where N is a positive integer and the initial value of N is 1.

[0123] Step 111: Calculate the difference between the first strobe time boundary value and the second strobe time boundary value.

[0124] The first strobe time boundary value is defined as: the strobe time at the boundary between the Nth row interval and the (N+1)th row interval. Specifically: If the light source mode of the Nth row interval is the first mode, then the flicker time of all rows in that interval is constant, and the first flicker time boundary value is this constant value.

[0125] If the light source mode of the Nth row interval is the second mode, then the flicker time in this interval changes row by row, and the first flicker time boundary value is the flicker time of the last row calculated according to the gradation rule in this interval.

[0126] The second strobe time boundary value is defined as: the strobe time at the boundary between the (N+1)th row interval and the Nth row interval. Specifically: If the light source mode of the (N+1)th row interval is the first mode, then the second flicker time boundary value is the constant flicker time of that interval.

[0127] If the light source mode of the N+1th row interval is the second mode, then the boundary value of the second flicker time is taken as the theoretical flicker time of the first row calculated according to the gradation rule in that interval.

[0128] Step 112: If the difference is greater than the grayscale step threshold, extract the last P rows of the Nth row interval and the first P rows of the (N+1)th row interval as a transition interval; where P is a positive integer.

[0129] Optionally, P is the preset number of transition half-width rows, which is a positive integer. The value of P is set according to the system's requirements for the smoothness of the brightness transition. The larger P is, the smoother the transition, but it occupies more rows near the boundary of the interval that originally belonged to solid color or gradient configuration; the smaller P is, the steeper the transition.

[0130] Optionally, the transition interval is a scan line range with a total number of 2P, consisting of the last P lines of the Nth line interval (i.e., the last P lines to the last 1 lines in the interval) and the first P lines of the N+1th line interval (i.e., the first line to the P lines in the interval). The transition interval is used to perform interpolation transition between the original flicker time settings of the two intervals.

[0131] Optionally, the grayscale step threshold can be set to 3% to 15% of the total strobe time span used by the scanning system.

[0132] For example, if in a scanning system, the minimum flicker time configured for all row intervals is 10μs and the maximum is 100μs, with a total span of 90μs, then the lower limit of the grayscale step threshold range is 90μs×3%≈2.7μs; and the upper limit of the grayscale step threshold range is 90μs×15%≈13.5μs.

[0133] Step 113: Calculate the normalized position of each row in the transition interval within the transition interval.

[0134] Optionally, the transition interval contains a total of 2P rows, which are numbered sequentially from front to back according to the scanning direction as row 1 to row 2P (where row 1 to row P are the scan rows that originally belonged to the last P rows of the Nth row interval, and row P+1 to row 2P are the scan rows that originally belonged to the first P rows of the N+1th row interval).

[0135] For the z-th row (z=1, 2, ..., 2P) within the transition interval, its normalized position The calculation formula is:

[0136] Among them, normalized position It is a dimensionless value in the interval [0, 1], representing the relative progress of the scan line within the transition interval. When z=1 =0, indicating that it is located at the beginning of the transition interval; when z=2P =1 indicates that it is located at the end of the transition interval.

[0137] Step 114: Using the normalized position as a coefficient, calculate the corresponding strobe time for each row in the transition interval based on the coefficient, the first strobe time boundary value, and the second strobe time boundary value, and overwrite the original strobe time.

[0138] Among them, the normalized position calculated in step 113 As interpolation coefficients, the first stroboscopic time boundary value obtained in step 110 is used for... Second flicker time boundary value Interpolation calculations are performed to obtain the transition strobe time corresponding to the z-th row within the transition interval. The specific formula is as follows:

[0139] Step 115: Determine whether N+1 is equal to Nmax.

[0140] Step 116: If N+1 equals Nmax, then stop the process.

[0141] Step 117: If N+1 is not equal to Nmax, then set N=N+1 and return to the step of obtaining the first and second strobe time boundary values ​​adjacent to the Nth row interval and the N+1th row interval.

[0142] By detecting the flicker time difference at the boundary between adjacent row intervals, and automatically constructing a transition interval when the difference exceeds the grayscale step threshold, the flicker time at both ends is smoothly calculated using the normalized position as the interpolation coefficient. This effectively eliminates the brightness abrupt change at the boundary caused by the difference in light source configuration between different intervals, making the grayscale transition between adjacent pixel rows in the scanned image smooth and natural, improving the overall uniformity of the image and the accuracy of subsequent defect detection.

[0143] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. For example... Figure 3 As shown, the electronic device 200 includes: one or more processors 210 and a memory 220. Figure 3 Take a processor 210 as an example.

[0144] In some implementations, the processor 210 and the memory 220 can be connected via a bus or other means. Figure 3 Taking the example of a connection between China and Israel via a bus.

[0145] In some embodiments, the processor 210 is configured to: accumulate the real-time scan lines of the line scan camera during the scanning process of the workpiece in collaboration between the line scan light source and the line scan camera; determine the line number interval to which the real-time scan lines belong; determine the light source mode according to the line number interval; when the light source mode is a first mode, control the line scan light source to output a set luminous intensity during each scan of the line scan camera within the line number interval; wherein, when the first mode exists, the first mode belongs to at least two line number intervals; when the light source mode is a second mode, control the luminous intensity output by the line scan light source to change line by line during each scan of the line scan camera within the line number interval.

[0146] In some implementations, memory 220 serves as a non-volatile computer-readable storage medium, used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules of the workpiece scanning method based on a line scan camera in the embodiments of this application. Processor 210 executes various functional applications and data processing of the electronic device by running the non-volatile software programs, instructions, and modules stored in memory 220, thereby implementing the workpiece scanning method based on a line scan camera as described in the above embodiments.

[0147] In some embodiments, memory 220 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created based on the use of the electronic device. Furthermore, memory 220 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 220 may optionally include memory remotely located relative to processor 210, and these remote memories may be connected to the controller via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0148] In some implementations, one or more modules are stored in memory 220 and, when executed by one or more processors 210, perform the workpiece scanning method based on a line scan camera as described in any of the above method embodiments, for example, performing the above-described... Figure 1 Steps 101 to 105 of the method.

[0149] Please refer to Figure 4 , Figure 4 This is a structural block diagram of a computer-readable storage medium provided in an embodiment of this application. The computer-readable storage medium 300 stores program code 310, which can be called by a processor to execute the workpiece scanning method based on a line scan camera described in the above method embodiments.

[0150] The computer-readable storage medium 300 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM. Optionally, the computer-readable storage medium includes a non-volatile computer-readable medium. The computer-readable storage medium 300 has storage space for program code that performs any of the method steps of the control method described above. This program code can be read from or written to one or more computer program products. The program code may, for example, be compressed in a suitable form.

[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A workpiece scanning method based on a line scan camera, characterized in that, Applied to a scanning system, the scanning system including a line scan light source and a line scan camera, the method includes: During the scanning process of the workpiece by the coordinated scanning of the line scan light source and the line scan camera, the number of real-time scan lines of the line scan camera is accumulated; Determine the range of rows to which the real-time scanned rows belong; The light source mode is determined based on the row number range to which it belongs; When the light source mode is the first mode, the line scan camera controls the line scan light source to output a set light intensity during each line scan within the corresponding line number interval; wherein, when the first mode exists, the first mode belongs to at least two line number intervals; When the light source mode is the second mode, the light intensity output by the line scan light source is controlled to change line by line during each scan of the line scan camera within the range of the corresponding number of lines. Before the line scan light source and the line scan camera scan the workpiece in concert, the method further includes: Obtain the total number of scan lines of the workpiece scanned by the line scan camera; The total number of scan lines is divided into multiple line number intervals based on the surface condition characteristics of the workpiece; Determine the region type corresponding to each row number interval; Configure the light source mode for each row number interval according to the region type of each region; The surface state features include color features, and configuring the light source mode for each row number interval according to the region type of each region includes: When the region type of the area is solid color, the light source mode of the corresponding row number interval is configured as the first mode; When the region type of the area is gradient color, the light source mode of the corresponding row number interval is configured as the second mode; The method further includes: Configure the mode parameters corresponding to the light source mode for each of the aforementioned row number intervals; wherein, The mode parameters of the first mode include: the flicker time of the line scan light source during each line scan by the line scan camera; The mode parameters of the second mode include: gradient direction, total gradient intensity, and after each line scan by the line scan camera, the flicker time change amplitude of the line scan light source is equal to the total gradient intensity / the total number of lines in the line number interval. The method further includes: Obtain the first and second strobe time boundary values ​​of the Nth row interval and the (N+1)th row interval; where N is a positive integer and the initial value of N is 1; Calculate the difference between the first flicker time boundary value and the second flicker time boundary value; If the difference is greater than the grayscale step threshold, the last P rows of the Nth row interval and the first P rows of the (N+1)th row interval are extracted as a transition interval; where P is a positive integer. Calculate the normalized position of each row within the transition interval; Using the normalized position as a coefficient, the flicker time corresponding to each row in the transition interval is calculated based on the coefficient, the first flicker time boundary value, and the second flicker time boundary value, and the original flicker time is overwritten. Determine if N+1 equals Nmax; If N+1 equals Nmax, then stop the process; If N+1 is not equal to Nmax, then set N=N+1 and return to the step of obtaining the first and second strobe time boundary values ​​adjacent to the Nth row interval and the N+1th row interval.

2. The method according to claim 1, characterized in that, The surface condition features include at least one of the following: color features, material features, and geometric features.

3. The method according to claim 1, characterized in that, Based on the surface condition characteristics of the workpiece, the total number of scan lines is divided into multiple line number intervals, including: The 3D model of the workpiece is imported into 3D software, and the features of all surface points of the 3D model of the workpiece are extracted. The features corresponding to each surface point include spatial coordinates, surface normal vector and reflectivity. A virtual line scan light source model is generated in the 3D software, and optical characteristic parameters are set; Multiple candidate strobe times are set to form a candidate strobe time sequence; The virtual line scan light source model is controlled to simulate each candidate flicker time in sequence, and the imaging grayscale values ​​of all surface points of the 3D model of the workpiece are obtained after each simulation. Establish a target grayscale range, and set the surface points located within the target grayscale range to belong to the same region corresponding to the current candidate flicker time; Based on the scanning direction of the line scan light source, all surface points in the 3D model of the workpiece are classified into multiple scan lines; Determine the number of surface points belonging to each region in each scan row, and divide the scan row into the region with the largest number of surface points belonging to each region. Adjacent scan lines belonging to the same region are merged, thereby dividing the total number of scan lines into multiple line number intervals.

4. The method according to claim 3, characterized in that, Determining the region type for each of the regions includes: Obtain M regions arranged sequentially along the scanning direction, and the corresponding strobe time for each region, where M is a positive integer greater than or equal to 2; Calculate the gradient of the flicker time change between adjacent regions to obtain a gradient sequence consisting of M-1 gradient values; where the i-th gradient value is the difference between the flicker time corresponding to the (i+1)-th region and the flicker time corresponding to the i-th region. Determine the gradient threshold and the minimum number of gradient regions, and initialize the gradient segment start number start=1, the gradient segment end number end=1, and the gradient number k=1; Determine if k is less than or equal to M-1. If so, perform a gradient condition check on the k-th gradient; otherwise, proceed to the final processing step. The gradient condition determination includes: if the absolute value of the k-th gradient is less than the gradient threshold, and the sign of the k-th gradient is the same as the confirmed gradient direction in the gradient segment when end is greater than start, then the gradient condition is satisfied, end is updated to k+1, k=k+1, and the step of determining whether k is less than or equal to M-1 is returned; otherwise, the gradient condition is not satisfied. When the gradient condition is not met, the number of regions contained in the current gradient segment is determined based on start and end. If the number of regions is greater than or equal to the minimum number of gradient regions, all regions from start to end are merged into one region, and the region type of the merged region is determined to be gradient color. If the number of regions is less than the minimum number of gradient regions, the region type of each region from start to end is determined to be solid color. Subsequently, start and end are both reset to k+1, k=k+1, and the process returns to the step of determining whether k is less than or equal to M-1. The end processing steps include: determining the number of regions based on the current start and end; if the number of regions is greater than or equal to the minimum number of gradient regions, merging all regions from start to end into one region and determining the region type of the merged region as gradient color; otherwise, determining the region type of each region from start to end as solid color.

5. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the workpiece scanning method based on a line scan camera as described in any one of claims 1 to 4.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an executable program, which is executed by a processor to implement the workpiece scanning method based on a line scan camera as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Scanning method and device based on line scanning camera, electronic equipment and storage medium

    CN118301251A

  • PCB defect reinspection method, device and equipment based on time-sharing stroboflash and storage medium

    CN121253565A