Product detection method and system based on TDI camera, and medium
By combining a TDI true color camera with red, green and blue line light sources, high-precision 3D topography reconstruction of a color camera under a single exposure is achieved, solving the problems of measurement error and low efficiency of color cameras, and realizing efficient and accurate 3D topography detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, color cameras suffer from measurement errors caused by channel response differences and uneven surface color reflectivity during single exposure, making it difficult to achieve high-precision 3D topography reconstruction. Furthermore, traditional methods are inefficient in high-speed detection.
A TDI true color camera is used in conjunction with three light sources of consistent intensity: red, green, and blue. The phase-shifting method is used to control the flicker frequency of the light source to synchronize with the line frequency of the camera, thereby achieving synchronous acquisition of RGB channel stripe images. Furthermore, an adaptive weighted averaging mechanism is used to fuse the data from each channel, suppressing channel crosstalk and response inconsistency errors.
While ensuring high-speed measurement, it significantly improves the accuracy and robustness of phase deflection reconstruction, simplifies the data processing flow, adapts to changes in object surface color and complex reflection characteristics, and improves measurement accuracy and efficiency.
Smart Images

Figure CN121860962A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine vision, and in particular relates to a product inspection method, system and medium based on a TDI camera. Background Technology
[0002] Surface defect detection is a key technology in industrial manufacturing and quality control, aiming to automatically identify scratches, dents, stains, unevenness, and other defects on product surfaces. Phase deflection, due to its high-precision optical measurement, has been widely applied in the three-dimensional morphology measurement and defect detection of precision components, optical mirrors, electronic screens, and other products. Its basic principle is to reconstruct the microscopic height information of the surface by analyzing the wavefront phase changes that occur after regular structured light (such as sinusoidal fringes) is reflected or transmitted through the surface under test. Traditional phase deflection measurement systems typically use a monochrome industrial camera in conjunction with a digital projection device, and solve for the absolute phase distribution using the "phase-shifting method." To eliminate measurement uncertainties, the phase-shifting method requires sequentially projecting multiple (e.g., four images in a four-step phase-shifting method) grating images with fixed phase differences onto the object under test, and the camera simultaneously acquires a corresponding number of images. While this "time-division multiple-exposure" working mode can obtain reliable measurement results in static or low-speed scenarios, its inherent timing operation limits the data acquisition rate, making it difficult to meet the high efficiency and high throughput requirements of modern industrial online inspection.
[0003] To overcome the aforementioned efficiency bottlenecks, the industry naturally developed a need to acquire multiple phase information images simultaneously in a single exposure. One intuitive approach is to encode color information, using a color camera to simultaneously project sinusoidal fringes of red, green, and blue, each color fringe pre-coded with a specific phase difference (e.g., 0°, 90°, 180°). Theoretically, a single color image acquisition contains information from three channels (R, G, B), allowing for the calculation of three independent phase maps, thus increasing measurement speed several times over. However, this approach faces significant challenges in practical applications. Its core bottleneck lies in the measurement errors introduced by the inherent characteristics of the color camera, severely limiting the accuracy of the final 3D topographic reconstruction.
[0004] Specifically, cameras inherently differ in their electrical response characteristics and sensitivity to R, G, and B light, and the color and reflectivity of the object's surface also selectively reflect these three colors, resulting in uneven signal-to-noise ratios across the channels. The main reason is that the reflectivity response of different points on the object's surface to different wavelengths of light (R / G / B) varies significantly. This manifests in the following ways: 1. Color-selective absorption: For example, red areas strongly reflect red light but very weakly reflect blue light, resulting in extremely low signal-to-noise ratios for the blue light channel and unreliable phase data; 2. Localized specular reflection (highlights): Highlights can cause signal oversaturation in one or more channels, rendering phase calculations completely ineffective; 3. Inhomogeneous surface materials: Different materials have different reflectivity characteristics, leading to inconsistent signal quality across the three channels. If data from a single channel is simply selected as the final result, the effective information from other channels will be lost, and a large error may be introduced due to the low signal-to-noise ratio of that channel. If the three channels are directly fused without processing, crosstalk and response differences between channels will become the main sources of error. Furthermore, the image of the object to be tested acquired by a traditional color area array camera needs to be de-mosaiced to recover the missing component data, which will introduce new error data during the interpolation process, causing the accuracy problem that the existing single-exposure phase deflection scheme based on color cameras cannot effectively solve.
[0005] Therefore, this invention provides a product inspection method, system, and medium based on a TDI camera. The method utilizes a TDI true color camera to acquire three-channel stripe images and suppresses channel crosstalk and response inconsistency errors through an adaptive weighted averaging mechanism. This significantly improves the reconstruction accuracy and robustness of phase deflection while ensuring high-speed measurement and avoiding false data introduced by interpolation. Summary of the Invention
[0006] The purpose of this invention is to overcome the above-mentioned problems in the prior art and to provide a product inspection method, system and medium based on a TDI camera.
[0007] To achieve the above-mentioned technical objectives and effects, the present invention is implemented through the following technical solution:
[0008] A product inspection method based on a TDI camera utilizes a TDI true-color camera to detect defects on the surface of the object under test. The inspection method includes:
[0009] Install three linear light sources with the same light intensity and colors of red, green and blue, to project onto the moving surface of the test object and correspond to the scanning area of the TDI true color camera, so that the scanning area of the linear light source covers the detection area of the test object;
[0010] The light intensity of the line light source is controlled to exhibit periodic bright and dark flickering according to the stripe distribution, and the flickering frequency is 1 / N of the line frequency of the TDI true color camera, so that the TDI true color camera can acquire stripe images that satisfy the phase shift method under the three RGB channels.
[0011] By analyzing the stripe images under the three RGB channels, the original height data of all pixel positions under each RGB channel are calculated based on phase deflection.
[0012] Iterate through the raw height data of all pixel positions, and then calculate the final height data of the current pixel position by weighted averaging according to the weight of each RGB channel corresponding to the current pixel position.
[0013] Where N is the number of pixel rows of the TDI true color camera; the weights of each RGB channel are obtained by extracting the R data, G data and B data of the current pixel position from the image information of the region to be detected.
[0014] Furthermore, the TDI true color camera consists of three rows of pixels, namely the R pixel row, the G pixel row, and the B pixel row.
[0015] Furthermore, the speed of the object under test is monitored in real time by the encoder, and the line frequency of the TDI true color camera is dynamically adjusted to synchronize the acquisition of the TDI true color camera with the movement of the object under test.
[0016] Furthermore, before iterating through the raw height data for all pixel locations, the following is also included:
[0017] Determine whether the difference between the original height data of each pixel position in the current channel and the mean of its neighborhood is greater than a preset comparison threshold. If so, set the corresponding weight to zero; otherwise, do not respond.
[0018] Furthermore, the neighborhood is a 3×3 array region centered on each pixel position.
[0019] Furthermore, after obtaining the final height data of the current pixel position, the method further includes: comparing the final height data of the current pixel position with the corresponding reference height data to obtain the height deviation, and analyzing whether the height deviation exceeds a preset deviation threshold: if so, the current pixel position is marked; otherwise, no response is made.
[0020] The reference height data refers to the final height data obtained after applying the above-mentioned detection method to the standard part.
[0021] Furthermore, when analyzing the weights of each RGB channel, it is determined whether the R, G, and B data at the current pixel position exceed the preset channel threshold. If so, the corresponding weight is set to zero; otherwise, no response is made.
[0022] Furthermore, the stripe distribution is modulated by three monochromatic lasers: red, green, and blue.
[0023] The present invention also provides a product inspection system based on a TDI camera, comprising:
[0024] The light source projection module is used to install three line light sources with the same light intensity and colors of red, green and blue, to project onto the moving surface of the test object and correspond to the scanning area of the TDI true color camera, so that the scanning area of the line light source covers the detection area of the test object.
[0025] The light source control module is used to control the light intensity of the line light source to exhibit periodic bright and dark flickering according to a sinusoidal distribution, and the flickering frequency is 1 / N of the line frequency of the TDI true color camera, so that the TDI true color camera can acquire a striped image that satisfies the phase shift method under the three RGB channels; where N is the number of pixel rows of the TDI true color camera.
[0026] The stripe analysis module is used to analyze stripe images under the three RGB channels and calculate the original height data of all pixel positions under each RGB channel based on phase deflection.
[0027] The weight analysis module is used to traverse the original height data of all pixel positions, and to obtain the final height data of the current pixel position by weighted averaging according to the weights of each RGB channel corresponding to the current pixel position; the weights of each RGB channel are obtained by extracting the R data, G data and B data of the current pixel position from the image information of the region to be detected.
[0028] The present invention also provides a computer-readable storage medium including a computer program that, when executed by a processor, implements the above-described detection method.
[0029] The beneficial effects of this invention are:
[0030] (1) In this invention, by installing three line light sources with the same light intensity and colors of red, green and blue, respectively, to project onto the moving surface of the test object and correspond to the scanning area of the TDI true color camera, the scanning area of the line light source covers the test area of the test object. By illuminating the scanning area of the TDI true color camera with the line light source, the test area of the test object is collected frame by frame to cooperate with the movement of the test object. The three beams of red, green and blue sinusoidal stripes formed after splicing have the same light intensity when projected onto the surface of the test object, so as to ensure that the response of the three colors in each channel of the camera can actually reflect the difference in reflectivity of each pixel on the surface of the test object to different color components. This ensures that the initial signal intensity of the three channels is balanced, avoids the channel weight deviation caused by uneven illumination, lays the mathematical foundation for subsequent channel processing, and realizes the accurate matching of optical encoding and sensor reception.
[0031] By controlling the light intensity of the line light source to exhibit periodic bright-dark flickering according to the fringe distribution, with the flicker frequency being 1 / N of the line frequency of the TDI true color camera, the TDI true color camera can acquire fringe images that satisfy the phase-shift method in the three RGB channels. By strictly controlling the flicker frequency of the line light source and the timing of the camera's line frequency, the same point of the object is illuminated sequentially by fringe light in different brightness states during movement and captured by different pixel rows of the TDI camera. Thus, the complete image output after multiple acquisitions and stitching inherently contains a fringe pattern sequence with a fixed phase difference, perfectly meeting the input requirements of the phase-shift method. This allows the three channel images to constitute a dataset that can be used for phase calculation, transforming multiple exposures in time into parallel acquisition in the spectral dimension, achieving extremely high detection efficiency.
[0032] By analyzing the stripe images under the three RGB channels, the original height data of all pixel positions under each RGB channel is obtained based on phase deflection calculation. Each channel is regarded as an independent measurement system. The phase deflection algorithm is applied to the stripe images of the R, G, and B channels respectively to calculate the phase distribution map under each channel. Then, through pre-calibrated system parameters, the phase values are converted into the original height data of the object surface. For each pixel position in the image, three height data calculated based on different wavelengths of light are obtained in one measurement, which greatly improves the measurement speed.
[0033] By traversing the original height data of all pixel locations, the final height data of the current pixel location is obtained by weighted averaging according to the weights of each RGB channel corresponding to the current pixel location. This aims to intelligently fuse the three-channel data to select the best and eliminate the worst, effectively suppressing random errors introduced by channel crosstalk, color spots on the object surface, or uneven local reflectivity. Moreover, the weights are directly derived from the proportion of R, G, and B component values of the original image at that pixel point. Based on the actual optical response characteristics of the reflectivity of each point on the object surface, the contribution of each channel data is dynamically adjusted. By assigning higher signal-to-noise ratio channels higher weights, the system automatically tends to use more reliable data, significantly improving the measurement accuracy of the final three-dimensional topography data.
[0034] (2) In this invention, a TDI true color camera is introduced into the phase deflection to realize the synchronous acquisition of stripe images of different color channels. Based on the reflectivity difference characteristics of the surface of the object under test, the height data of each channel stripe image is fused with different weights to obtain the final height data. It has stronger adaptability to the color change and complex reflectivity characteristics of the surface of the object under test, effectively suppresses random errors caused by channel crosstalk, color spots on the surface of the object or uneven local reflectivity, and by giving higher weights to the high signal-to-noise ratio channel, the system automatically tends to use more reliable data, which is better than the result of any single channel or the simple arithmetic average result.
[0035] (3) In this invention, the TDI true color camera is specifically composed of three independent rows of pixels. These three rows of pixels are arranged in space and cover R, G and B color filters respectively, that is, they are divided into R pixel rows, G pixel rows and B pixel rows. The interval between each pixel row is set to be zero. The filter colors of the three rows of pixels correspond one-to-one with the three color light sources, so that the optical information of each color channel can be received by the camera sensor. This ensures the natural separation of RGB image data from the hardware perspective. Furthermore, the color data obtained by the TDI true color camera avoids the error caused by de-mosaic, providing a clear original data foundation for the subsequent phase shift method calculation of the sub-channels and simplifying the data processing flow.
[0036] (4) In this invention, the speed of the object under test is monitored in real time and with high precision by an encoder. Based on the speed signal fed back by the encoder, the line frequency of the TDI true color camera is dynamically adjusted to match the instantaneous speed of the object under test in real time, ensuring strict synchronization during the acquisition process so that the system can adapt to the speed fluctuations of the production line. Dynamic synchronization ensures that the core relationship that the flicker frequency of the line light source is 1 / N of the line frequency of the TDI true color camera still holds when the speed changes, thereby ensuring the correct acquisition of the phase-shifted stripe image sequence and maintaining the high precision of three-dimensional measurement. Attached Figure Description
[0037] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0038] Figure 1 This is a flowchart of the detection method in this invention;
[0039] Figure 2 This is a block diagram of the detection system in this invention. Detailed Implementation
[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] To address the issue of ensuring the authenticity of color data while achieving single-exposure and high-speed detection using ordinary color area scan cameras, and to overcome the problem of decreased measurement accuracy caused by channel crosstalk, response differences, and color differences on the object surface in traditional color-coded phase measurement.
[0042] like Figure 1As shown, this embodiment first provides a product inspection method based on a TDI camera, which uses a TDI true color camera to detect defects on the surface of the object to be tested. The inspection method includes:
[0043] Install three linear light sources with the same light intensity and colors of red, green and blue, to project onto the moving surface of the test object and correspond to the scanning area of the TDI true color camera, so that the scanning area of the linear light source covers the detection area of the test object;
[0044] The light intensity of the line light source is controlled to exhibit periodic bright and dark flickering according to the stripe distribution, and the flickering frequency is 1 / N of the line frequency of the TDI true color camera, so that the TDI true color camera can acquire stripe images that satisfy the phase shift method under the three RGB channels.
[0045] By analyzing the stripe images under the three RGB channels, the original height data of all pixel positions under each RGB channel are calculated based on phase deflection.
[0046] Iterate through the raw height data of all pixel positions, and then calculate the final height data of the current pixel position by weighted averaging according to the weight of each RGB channel corresponding to the current pixel position.
[0047] Wherein, N is the number of pixel rows of the TDI true color camera; the weights of each RGB channel are obtained by extracting the R, G, and B data of the current pixel position from the image information of the region to be detected; the red, green, and blue correspond to the three RGB channels of the TDI true color camera, respectively.
[0048] In this embodiment, the line light source is used to emit polychromatic light, which has at least three wavelengths of light: red, green, and blue, and the light intensity of each wavelength is consistent. This ensures that the RGB channel data corresponding to each pixel in the acquired image is not affected by the difference in light intensity of each wavelength of the light source, so as to reflect the actual RGB reflectivity difference of each pixel. This ensures that the initial signal intensity of the three channels is balanced, avoids channel weight deviation caused by uneven illumination, and thus improves the accuracy of subsequent weight ratio acquisition.
[0049] In this embodiment, a line light source is used to illuminate the scanning area of the TDI true color camera, and each frame of image captured by the TDI true color camera is stitched together to form a complete image of the object under test. The illumination intensity of the line light source corresponding to different frames of images is adjusted according to a preset stripe distribution to form striped light according to the preset stripe distribution on the complete image of the object under test.
[0050] In this embodiment, the stripe light can be sine, cosine, binarized black and white stripes, or a stripe pattern with Gray code encoding. Preferably, a sine stripe pattern is used in this embodiment.
[0051] In this embodiment, satisfying the phase shift method means that the acquired channel data is preprocessed before phase deflection to make the data satisfy the phase shift method calculation. The specific preprocessing steps need to be set according to the actual situation.
[0052] In this embodiment, consistent light intensity means that the light intensity of the three colors of striped light reaching the surface of the object under test is consistent, so that the light intensity that finally illuminates the surface of the object under test will not affect the subsequent calculation of the weight ratio due to differences, thus ensuring the accuracy of the subsequent algorithm calculation.
[0053] In this embodiment, striped light refers to a periodic light field with varying brightness transmitted onto the surface of an object through a projection device. "Sine" refers to the pattern of light intensity variation. The intensity distribution of sinusoidal striped light, along the direction perpendicular to the stripes, strictly follows a sine (or cosine) function law in terms of brightness variation, which can be specifically expressed by the following formula:
[0054] I(x,y)=A+Bcos(2πfx+φ0)
[0055] Where: I(x,y) is the intensity of a point on the image plane, A is the average light intensity (background light), B is the modulation degree (contrast) of the stripes, f is the spatial frequency of the stripes (how many cycles per unit distance), x is the position coordinate on the image plane, and φ0 is the initial phase.
[0056] In this embodiment, since the light intensity of the three color stripes is the same, the weight of each color channel is directly adopted by the proportion of different color channel data at each pixel position, which is used to allocate the original height data corresponding to each color channel.
[0057] In this embodiment, the original height data is the height data in the three-dimensional shape obtained by performing phase deflection calculation on the stripe images of each color channel, while the final height data is the estimated height data after weighting the original height data corresponding to each color channel. This indicates that the phase deflection detection result corresponding to each pixel position is closer to the actual height data result.
[0058] In this embodiment, red, green, and blue correspond to the three RGB channels of the TDI true color camera, indicating that the wavelength of each color channel corresponds one-to-one with the wavelength of light passing through the filter on the TDI true color camera.
[0059] In this embodiment, three line light sources with consistent intensity and colors (red, green, and blue) are installed and projected onto the moving surface of the test object, corresponding to the scanning area of the TDI true color camera. This ensures that the scanning area of the line light sources covers the detection area of the test object. By illuminating the scanning area of the TDI true color camera with the line light sources, the detection area at different positions on the test object's surface is captured frame by frame in coordination with the movement of the test object. The three sinusoidal stripes of red, green, and blue light, formed after splicing, have consistent intensity when projected onto the test object's surface. This ensures that the response of the three colors in each channel of the camera can actually reflect the difference in reflectivity of each pixel on the test object's surface for different color components, guaranteeing the initial signal strength balance of the three channels and avoiding channel weight deviation caused by uneven illumination. This lays the mathematical foundation for subsequent channel-specific processing and achieves precise matching between optical encoding and sensor reception.
[0060] By controlling the light intensity of the line light source to exhibit periodic bright-dark flickering according to the fringe distribution, with the flicker frequency being 1 / N of the line frequency of the TDI true color camera, the TDI true color camera can acquire fringe images that satisfy the phase-shift method in the three RGB channels. By strictly controlling the flicker frequency of the line light source and the timing of the camera's line frequency, the same point of the object is illuminated sequentially by fringe light in different brightness states during movement and captured by different pixel rows of the TDI camera. Thus, the complete image output after multiple acquisitions and stitching inherently contains a fringe pattern sequence with a fixed phase difference, perfectly meeting the input requirements of the phase-shift method. This allows the three channel images to constitute a dataset that can be used for phase calculation, transforming multiple exposures in time into parallel acquisition in the spectral dimension, achieving extremely high detection efficiency.
[0061] By analyzing the stripe images under the three RGB channels, the original height data of all pixel positions under each RGB channel is obtained based on phase deflection calculation. Each channel is regarded as an independent measurement system. The phase deflection algorithm is applied to the stripe images of the R, G, and B channels respectively to calculate the phase distribution map under each channel. Then, through pre-calibrated system parameters, the phase values are converted into the original height data of the object surface. For each pixel position in the image, three height data calculated based on different wavelengths of light are obtained in one measurement, which greatly improves the measurement speed.
[0062] By traversing the original height data of all pixel locations, the final height data of the current pixel location is obtained by weighted averaging according to the weights of each RGB channel corresponding to the current pixel location. This aims to intelligently fuse the three-channel data to select the best and eliminate the worst, effectively suppressing random errors introduced by channel crosstalk, color spots on the object surface, or uneven local reflectivity. Moreover, the weights are directly derived from the proportion of R, G, and B component values of the original image at that pixel point. Based on the actual optical response characteristics of the reflectivity of each point on the object surface, the contribution of each channel data is dynamically adjusted. By assigning higher signal-to-noise ratio channels higher weights, the system automatically tends to use more reliable data, significantly improving the measurement accuracy of the final three-dimensional topography data.
[0063] In this embodiment, the core logic of achieving accurate detection through weighted averaging is that the stronger the original signal of a certain channel, the higher the signal-to-noise ratio of that channel at that pixel, and the more reliable the data. For example, if the G component value collected by a pixel is much higher than that of the R and B components, then the height data calculated by the G channel will be given a higher weight during fusion.
[0064] In this embodiment, for each pixel, the weights determined above are used to perform a weighted average of its three original height data points, thereby obtaining a final, better height estimate. This method is adaptive, dynamically adjusting the contribution of each channel's data based on the actual optical response characteristics of each point on the object's surface.
[0065] In this invention, a TDI true-color camera is introduced into the phase deflection to achieve synchronous acquisition of stripe images of different color channels. Based on the reflectivity difference characteristics of the surface of the object under test, the height data of the stripe images of each channel are fused with different weights to obtain the final height data. This invention has stronger adaptability to the color changes and complex reflectivity characteristics of the surface of the object under test, effectively suppressing random errors introduced by channel crosstalk, color spots on the object surface, or uneven local reflectivity. By assigning higher weights to high signal-to-noise ratio channels, the system automatically tends to use more reliable data, which is superior to the results of any single channel or a simple arithmetic average.
[0066] In some implementations, in order to cooperate with the TDI true color camera and the RGB strobe light source for three-channel separate image acquisition, the TDI true color camera consists of three rows of pixels, namely the R pixel row, the G pixel row, and the B pixel row.
[0067] In this embodiment, the TDI true color camera is specifically composed of three independent rows of pixels. These three rows of pixels are arranged in space and cover R, G, and B color filters respectively, i.e., divided into R pixel rows, G pixel rows, and B pixel rows. The interval between each pixel row is set to be zero. The filter colors of the three rows of pixels correspond one-to-one with the three color light sources, so that the optical information of each color channel can be received by the camera sensor. This ensures the natural separation of RGB image data from a hardware perspective. Furthermore, the color data obtained by the TDI true color camera avoids the errors caused by de-mosaicing, providing a clear original data foundation for subsequent phase-shifting calculations of the sub-channels and simplifying the data processing flow.
[0068] In some implementations, in order to address the potential fluctuations in the speed of the object under test in actual production lines and to ensure that the light source flicker, the line frequency of the TDI camera, and the speed of the object are always kept in strict synchronization to avoid the failure of the phase-shift method or the increase in measurement error due to loss of synchronization, the speed of the object under test is monitored in real time by an encoder, and the line frequency of the TDI true color camera is dynamically adjusted so that the acquisition by the TDI true color camera is synchronized with the movement of the object under test.
[0069] In this embodiment, the motion speed of the object under test is monitored in real time and with high precision by an encoder. Based on the speed signal fed back by the encoder, the line frequency of the TDI true color camera is dynamically adjusted to match the instantaneous speed of the object under test in real time, ensuring strict synchronization during the acquisition process. This allows the system to adapt to fluctuations in the speed of the production line. Dynamic synchronization ensures that the core relationship that the flicker frequency of the line light source is 1 / N of the line frequency of the TDI true color camera still holds true when the speed changes, thereby ensuring the correct acquisition of the phase-shifted fringe image sequence and maintaining high precision in three-dimensional measurement.
[0070] In some implementations, in order to address the inherent inconsistency in the photoelectric response of the R, G, and B channels of a TDI true color camera, even if white light of uniform intensity is projected, the original output values of the three channels of the camera may be different. This inconsistency will directly affect the accuracy of weight calculation. Before acquiring image information of the area to be detected, the TDI true color camera is further subjected to white balance correction to make the response of the three RGB channels consistent.
[0071] In this embodiment, the main steps of white balance correction are as follows: first, an image is acquired from a standard white reference board, and then the camera's internal parameters are adjusted or corrected by software algorithm based on the acquisition results, so that the camera can output equal R, G, and B values for neutral white objects, which is used to establish a unified and normalized color response benchmark for the measurement system.
[0072] In this embodiment, white balance correction ensures that the original R, G, and B data values used for subsequent weight calculation can accurately reflect the reflective characteristics of the object's surface, thereby reducing errors caused by the camera's own response bias. This makes the subsequent weight allocation more accurate and fair, avoiding weight calculation distortion caused by camera defects, and further improving the effectiveness of the weighted average fusion algorithm and the accuracy of the final result.
[0073] In some implementations, in order to improve the accuracy and anti-interference capability of phase deflection calculation, a four-step phase shift method is used to obtain the original height data of all pixel positions in each RGB channel during phase deflection calculation.
[0074] In this embodiment, four sinusoidal fringe patterns with a 90-degree phase difference are projected and acquired. Since it is a single exposure, this typically means that the red, green, and blue light each carry different phase shifts (e.g., 0°, 90°, 180°, 270° phase shifts). Using the arctangent function, the influence of background light and modulation intensity variations is eliminated from multiple images, and the principal phase value is directly solved. This method effectively solves the phase value from the fringe image with high accuracy and interference resistance, suppressing the influence of ambient light noise and uneven surface reflectivity, and obtaining a high-precision phase distribution.
[0075] In this embodiment, four horizontal sinusoidal fringe patterns are projected first, followed by four vertical sinusoidal fringe patterns, so that a total of eight sinusoidal fringe patterns are projected in the two vertical directions of the surface of the object under test, so as to detect the defect types in the two directions of the surface of the object under test respectively.
[0076] In some implementations, before iterating through the raw height data for all pixel locations, the following steps are also included:
[0077] Determine whether the difference between the original height data of each pixel position in the current channel and the mean of its neighborhood is greater than a preset comparison threshold. If so, set the corresponding weight to zero; otherwise, do not respond.
[0078] The neighborhood is a 3×3 array area centered on each pixel position.
[0079] In this embodiment, to avoid certain bad pixels or noise points in the image affecting the accuracy of the subsequent weighted average, a comparison threshold is set to filter all pixels, thereby eliminating pixel bad pixels with abrupt changes and improving the purity of the image data participating in the subsequent calculation.
[0080] In some implementations, in order to further convert the final height data into specific defect judgments, after obtaining the final height data of the current pixel position, the method further includes: comparing the final height data of the current pixel position with the corresponding reference height data to obtain the height deviation, and analyzing whether the height deviation exceeds a preset deviation threshold: if so, the current pixel position is marked; otherwise, no response is made.
[0081] The reference height data refers to the final height data obtained after applying the above-mentioned detection method to the standard part.
[0082] In this embodiment, a reference standard is established for defect determination. Specifically, a defect-free reference height map is obtained by measuring a standard part. Then, the height data of the part to be tested is compared with the reference height map pixel by pixel. The height deviation is calculated and compared with the deviation threshold to determine whether the pixel position is a defect point.
[0083] In this embodiment, the standard for judging standard parts is to select test objects whose surface flatness meets the accuracy requirements. The deviation threshold is also set according to the actual accuracy requirements. The threshold can be flexibly adjusted according to the quality requirements of the product, so that the method can be applied to various products with different tolerance standards, which is highly practical. Pixels with deviations exceeding the threshold are marked as defect points, realizing the automation and intelligence of the detection process.
[0084] In some implementations, to address the issue that when the color of a point on an object's surface is close to the complementary color of a certain color, the reflection signal of that channel becomes extremely weak (e.g., a point on a red object reflects blue light very weakly). In this case, the signal-to-noise ratio of that channel is extremely low, and the calculated height data may be invalid. If it is included in the weighted average, it will pollute the results. Therefore, when analyzing the weights of each RGB channel, it is determined whether the R, G, and B data of the current pixel position are lower than a preset channel threshold. If so, the corresponding weight is set to zero; otherwise, no response is made.
[0085] In this embodiment, by setting a channel threshold, the original R, G, and B data values of each pixel are judged before calculating the weights. If the value of a certain channel is lower than the threshold, the channel signal is considered invalid, and its corresponding weight is forcibly set to zero so that it does not participate in the final weighted average. This provides an effective abnormal data processing mechanism that can intelligently filter out obviously unreliable channel data, prevent low signal-to-noise ratio data from negatively affecting the final result, enhance the robustness of the weighted average algorithm, and enable the system to maintain measurement accuracy when facing object surfaces with strong color differences, local light absorption, specular reflection, or other extreme conditions.
[0086] In some embodiments, the stripe distribution is modulated by three monochromatic lasers—red, green, and blue—to form sinusoidal stripe light.
[0087] like Figure 2 As shown, the present invention also provides a product inspection system based on a TDI camera, comprising:
[0088] The light source projection module is used to install three line light sources with the same light intensity and colors of red, green and blue, to project onto the moving surface of the test object and correspond to the scanning area of the TDI true color camera, so that the scanning area of the line light source covers the detection area of the test object.
[0089] The light source control module is used to control the light intensity of the line light source to exhibit periodic bright and dark flickering according to a sinusoidal distribution, and the flickering frequency is 1 / N of the line frequency of the TDI true color camera, so that the TDI true color camera can acquire a striped image that satisfies the phase shift method under the three RGB channels; where N is the number of pixel rows of the TDI true color camera.
[0090] The stripe analysis module is used to analyze stripe images under the three RGB channels and calculate the original height data of all pixel positions under each RGB channel based on phase deflection.
[0091] The weight analysis module is used to traverse the original height data of all pixel positions, and to obtain the final height data of the current pixel position by weighted averaging according to the weights of each RGB channel corresponding to the current pixel position; the weights of each RGB channel are obtained by extracting the R data, G data and B data of the current pixel position from the image information of the region to be detected.
[0092] For detailed operating methods and principles of each module in the detection system, please refer to the detection method described above, and they will not be repeated here.
[0093] The present invention also provides a computer-readable storage medium including a computer program that, when executed by a processor, implements the above-described detection method.
[0094] In practical applications, a computer-readable storage medium can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0095] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, capable of sending, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device.
[0096] Program code contained on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0097] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0098] In the description of this specification, references to terms such as "an embodiment," "example," and "specific example" indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0099] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention.
Claims
1. A product inspection method based on a TDI camera, which utilizes a TDI true color camera to detect defects on the surface of the object under test, characterized in that... The detection method includes: Install three linear light sources with the same light intensity and colors of red, green and blue, to project onto the moving surface of the test object and correspond to the scanning area of the TDI true color camera, so that the scanning area of the linear light source covers the detection area of the test object; The light intensity of the line light source is controlled to exhibit periodic bright and dark flickering according to the stripe distribution, and the flickering frequency is 1 / N of the line frequency of the TDI true color camera, so that the TDI true color camera can acquire stripe images that satisfy the phase shift method under the three RGB channels. By analyzing the stripe images under the three RGB channels, the original height data of all pixel positions under each RGB channel are calculated based on phase deflection. Iterate through the raw height data of all pixel positions, and then calculate the final height data of the current pixel position by weighted averaging according to the weight of each RGB channel corresponding to the current pixel position. Wherein, N is the number of pixel rows of the TDI true color camera; the weights of each RGB channel are obtained by extracting the R, G, and B data of the current pixel position from the image information of the region to be detected; the red, green, and blue correspond to the three RGB channels of the TDI true color camera, respectively.
2. The product inspection method based on a TDI camera according to claim 1, characterized in that, TDI true color cameras consist of three rows of pixels, namely R pixel row, G pixel row, and B pixel row.
3. The product inspection method based on a TDI camera according to claim 1, characterized in that, The speed of the object under test is monitored in real time by an encoder, and the line frequency of the TDI true color camera is dynamically adjusted to synchronize the acquisition of the TDI true color camera with the movement of the object under test.
4. The product inspection method based on a TDI camera according to claim 1, characterized in that, Before iterating through the raw height data for all pixel locations, the following is also included: Determine whether the difference between the original height data of each pixel position in the current channel and the mean of its neighborhood is greater than a preset comparison threshold. If so, set the corresponding weight to zero; otherwise, do not respond.
5. The product inspection method based on a TDI camera according to claim 4, characterized in that, The neighborhood is a 3×3 array area centered on each pixel position.
6. A product inspection method based on a TDI camera according to any one of claims 1-5, characterized in that, After obtaining the final height data of the current pixel position, the method further includes: comparing the final height data of the current pixel position with the corresponding reference height data to obtain the height deviation, and analyzing whether the height deviation exceeds a preset deviation threshold: if so, the current pixel position is marked; otherwise, no response is made. The reference height data refers to the final height data obtained after applying the above-mentioned detection method to the standard part.
7. A product inspection method based on a TDI camera according to any one of claims 1-5, characterized in that, When analyzing the weights of each RGB channel, it is determined whether the R, G, and B data of the current pixel position exceed the preset channel threshold. If so, the corresponding weight is set to zero; otherwise, no response is made.
8. A product inspection method based on a TDI camera according to any one of claims 1-5, characterized in that, The stripe distribution is modulated by three monochromatic lasers: red, green, and blue.
9. A product inspection system based on a TDI camera, characterized in that, include: The light source projection module is used to install three line light sources with the same light intensity and colors of red, green and blue, to project onto the moving surface of the test object and correspond to the scanning area of the TDI true color camera, so that the scanning area of the line light source covers the detection area of the test object. The light source control module is used to control the light intensity of the line light source to exhibit periodic bright and dark flickering according to the stripe distribution, and the flickering frequency is 1 / N of the line frequency of the TDI true color camera, so that the TDI true color camera can acquire stripe images that satisfy the phase shift method under the three RGB channels; where N is the number of pixel rows of the TDI true color camera. The stripe analysis module is used to analyze stripe images under the three RGB channels and calculate the original height data of all pixel positions under each RGB channel based on phase deflection. The weight analysis module is used to traverse the original height data of all pixel positions, and to obtain the final height data of the current pixel position by weighted averaging according to the weight of each RGB channel corresponding to the current pixel position. The weight of each RGB channel is obtained by extracting the R data, G data and B data of the current pixel position from the image information of the area to be detected. The red, green and blue correspond to the three RGB channels of the TDI true color camera.
10. A computer-readable storage medium comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the detection method as described in any one of claims 1-8.