Light source dynamic adjustment method, device, system and storage medium
By dynamically adjusting the incident angle of the light source, and based on the color and surface features of the target object, an error index is constructed using image contrast and the proportion of specular reflection area. This solves the problem of poor imaging quality in vision systems and enables more efficient automated production.
Patent Information
- Application Number
- CN202511725985.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-24
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2045-11-24
AI Technical Summary
In automated production processes, the imaging quality of vision systems is affected by differences in ambient light intensity and the diversity of target object colors, leading to inaccurate positioning, false detections or missed detections, and reduced production efficiency.
By determining the color and surface features based on the initial image of the target object, the incident angle of the light source is dynamically adjusted. An incident angle error index is constructed using image contrast and the proportion of specular reflection area. The incident angle of the light source is then adaptively adjusted to optimize the imaging quality.
It significantly improves imaging quality, enhances the positioning accuracy and stability of vision systems, reduces false detections and missed detections, and improves the efficiency of automated production.
Smart Images

Figure CN121174335B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of computer vision technology based on image data processing, for example, to a light source dynamic adjustment method, device, system and storage medium. BACKGROUND
[0002] In an automated production process, accurate positioning of a vision system is a key prerequisite for realizing automated operation, and accurate positioning is heavily dependent on the imaging quality of a target object. However, vision imaging often faces challenges from various adverse factors, resulting in poor imaging quality of the target object.
[0003] Taking a spinning production textile scene as an example, in the automatic production of a spinning workshop, the environmental light intensity of different regions differs significantly, and combined with the complex installation layout of equipment, it is easy to form a shadow area on the surface of a yarn tube or a skin roller. Environmental light and shadow interference cause the edge of the target object to be blurred and features to be lost, which seriously affects the imaging quality. In addition, the material and color of the yarn tube and the skin roller are diverse (such as white, red, blue, etc.), and there are significant differences in the reflection and absorption characteristics of light by different colors, which further affect the imaging quality. For example, dark objects absorb more light, which easily leads to insufficient brightness in imaging; light-colored objects may be overexposed due to excessive reflection. Poor imaging quality will affect the accurate positioning of the vision system, and then trigger repeated work or manual intervention due to false detection or missed detection, thereby reducing overall production efficiency.
[0004] In related technologies, a light source can be configured for a vision system to improve imaging quality by actively illuminating a target object. However, the light source of the related technology cannot adapt to the lighting needs of target objects with different properties, and it is difficult to significantly improve the imaging quality, and the improvement effect on the accurate positioning of the vision system is limited. SUMMARY
[0005] The present disclosure provides a light source dynamic adjustment method, device, system and storage medium, which can improve the imaging quality of a target object and improve the accuracy and stability of the positioning of a vision system.
[0006] According to a first aspect of the present disclosure, a light source dynamic adjustment method is provided, comprising:
[0007] determining the color of the target object based on an initial image of the target object, matching a surface feature corresponding to the color in an optical feature database, and determining an initial value of the incident angle of the light source based on the surface feature, wherein the target object is a yarn tube or a skin roller, and the optical feature database is obtained by performing spectral scanning on different sample objects;
[0008] adjusting the incident angle of the light source based on the initial value;
[0009] entering a dynamic adjustment phase, and in the dynamic adjustment phase, the following steps are repeatedly performed:
[0010] determine an image contrast and a specular reflection region proportion based on a real-time image of a target object;
[0011] determine an incident angle error index based on the image contrast and the specular reflection region proportion;
[0012] adjust an incident angle of a light source based on the incident angle error index.
[0013] In some embodiments, a color of the target object is determined based on an initial image of the target object, a surface feature in an optical feature database is matched based on the color, an initial value of the incident angle of the light source is determined based on the surface feature, comprising:
[0014] inputting the initial image of the target object to an incident angle setting model, and identifying the color of the target object by the incident angle setting model;
[0015] matching a surface feature corresponding to the color in the optical feature database by the incident angle setting model, and determining the initial value of the incident angle of the light source according to the surface feature, wherein the incident angle setting model is obtained by joint training based on sample images of sample objects of different colors, surface features corresponding to each color in the optical feature database, and imaging quality data of the sample objects under different incident angles.
[0016] In some embodiments, the surface feature comprises any one of the following: a specular reflection coefficient, a diffuse reflection coefficient, a surface roughness, and a refractive index.
[0017] In some embodiments, the image contrast is obtained by the following way:
[0018] determining a maximum pixel value and a minimum pixel value of the grayed real-time image;
[0019] calculating a pixel difference value and a pixel sum value of the maximum pixel value and the minimum pixel value;
[0020] taking a ratio of the pixel difference value and the pixel sum value as the image contrast.
[0021] In some embodiments, the specular reflection region proportion is obtained by the following way:
[0022] determining a number of pixels of a specular reflection region and a total number of pixels of the real-time image;
[0023] taking a ratio of the number of pixels of the specular reflection region and the total number of pixels as the specular reflection region proportion.
[0024] In some embodiments, the number of pixels of the specular reflection region is obtained by the following way:
[0025] converting the real-time image from RGB to LAB space, and separating L channel, A channel and B channel;
[0026] According to the luminance data of the L channel and a preset luminance condition, pixels meeting the preset luminance condition are screened out to form a luminance feature region, wherein the luminance feature region is used to reflect the strong highlight characteristic of the specular reflection;
[0027] Gradient calculation is performed on the luminance data of the L channel, and according to the calculated gradient data and a preset gradient condition, pixels meeting the preset gradient condition are screened out to form a gradient feature region, wherein the gradient feature region is used to reflect the mutation characteristic of the edge of the specular reflection;
[0028] According to the chrominance data of the A channel and the B channel, pixel saturation is calculated, and according to the calculated saturation data and a preset saturation condition, pixels meeting the preset saturation condition are screened out to form a saturation feature region, wherein the saturation feature region is an achromatic interference region;
[0029] The luminance feature region, the gradient feature region and the saturation feature region are merged to obtain a specular reflection region, and the number of pixels in the specular reflection region is counted.
[0030] In some embodiments, the merging of the luminance feature region, the gradient feature region and the saturation feature region to obtain the specular reflection region comprises:
[0031] The luminance feature region, the gradient feature region and the saturation feature region are taken as a union set to obtain a comprehensive feature region;
[0032] The comprehensive feature region is subjected to a morphological closing operation with a preset neighborhood range and small connected regions are removed to obtain the specular reflection region.
[0033] In some embodiments, the incident angle error index is determined based on the image contrast and the specular reflection region proportion, comprising:
[0034] A contrast error component is calculated based on the image contrast and a preset reference contrast;
[0035] A specular reflection region proportion error component is calculated based on the specular reflection region proportion and a preset maximum allowed specular reflection region proportion;
[0036] The contrast error component and the specular reflection region proportion error component are fused to obtain the incident angle error index.
[0037] In some embodiments, the contrast error component is calculated based on the image contrast and a preset reference contrast, comprising: calculating a contrast difference value of the image contrast and the preset reference contrast, and taking the ratio of the contrast difference value to the reference contrast as the contrast error component;
[0038] And / or, based on the specular reflection area proportion and the preset maximum allowed specular reflection area proportion, a specular reflection area proportion error component is calculated, including: calculating a proportion difference value of the specular reflection area proportion and the preset maximum allowed specular reflection area proportion, and taking a ratio of the proportion difference value and the maximum allowed specular reflection area proportion as the specular reflection area proportion error component.
[0039] In some embodiments, the contrast error component and the specular reflection area proportion error component are fused to obtain an incident angle error index, including:
[0040] Based on the contrast error component and the corresponding contrast error weight, the specular reflection area proportion error component and the corresponding area proportion error weight, a weighted sum of the contrast error component and the specular reflection area proportion error component is calculated.
[0041] The weighted sum is taken as the incident angle error index.
[0042] In some embodiments, based on the incident angle error index, the incident angle of the light source is adjusted, including:
[0043] Based on the incident angle error index, a proportional gain, an integral gain and a differential gain are calculated respectively.
[0044] Based on the incident angle error index, the proportional gain, the integral gain and the differential gain, an incident angle adjustment amount is calculated.
[0045] Based on the incident angle adjustment amount, the incident angle of the light source is adjusted.
[0046] According to a second aspect of the present disclosure, a light source dynamic adjustment device is provided, including a processor and a memory storing program instructions, the processor executing the light source dynamic adjustment method provided by the first aspect of the present disclosure.
[0047] According to a third aspect of the present disclosure, a light source dynamic adjustment system is provided, including a light source and a light source dynamic adjustment device provided by the second aspect of the present disclosure, the light source being in communication connection with the light source dynamic adjustment device.
[0048] According to a fourth aspect of the present disclosure, a storage medium is provided, the storage medium storing computer program instructions, the computer program instructions being executed by a processor to execute the light source dynamic adjustment method provided by the first aspect of the present disclosure.
[0049] The light source dynamic adjustment method, device, system and storage medium provided by the embodiments of the present disclosure can achieve the following technical effects:
[0050] The light source dynamic adjustment method provided by the embodiments of the present disclosure first determines the color of the target object based on the initial image of the target object, and determines the initial value of the light source incident angle according to the color, so that a suitable illumination angle is preset according to the optical characteristics of the color of the target object in the initial stage, avoiding the problems of insufficient brightness or overexposure caused by color difference. Subsequently, the light source incident angle is adjusted based on the initial value, and enters the dynamic adjustment stage. In the dynamic adjustment stage, the real-time image of the target object is continuously acquired, and the imaging quality under the current lighting condition is comprehensively evaluated by analyzing two key indicators of image contrast and specular reflection area proportion. Based on the two indicators, an incident angle error index is constructed, which can quantify the deviation between the current incident angle and the ideal illumination state, and the light source incident angle is dynamically adjusted according to the incident angle error index, gradually suppressing shadows, enhancing feature contrast, and reducing interference caused by specular reflection. Through the above adjustment process, the light source can adapt to target objects of different colors and surface properties, significantly improve the imaging quality, improve the accuracy and stability of the visual system positioning, reduce false detection, missed detection and repeated operation caused by poor imaging, and thus improve the efficiency of automatic production.
[0051] The foregoing general description and the following description are only exemplary and explanatory, and are not intended to limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0052] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, which are schematic and not intended to be limiting of the embodiments, and in which like reference numerals designate similar items in the figures, and wherein:
[0053] Figure 1 is a schematic diagram of a light source dynamic adjustment system provided by an embodiment of the present disclosure;
[0054] Figure 2 is a schematic diagram of a first light source dynamic adjustment method provided by an embodiment of the present disclosure;
[0055] Figure 3 is a schematic diagram of a second light source dynamic adjustment method provided by an embodiment of the present disclosure;
[0056] Figure 4 is a schematic diagram of a third light source dynamic adjustment method provided by an embodiment of the present disclosure;
[0057] Figure 5 is a schematic diagram of a fourth light source dynamic adjustment method provided by an embodiment of the present disclosure;
[0058] Figure 6 is a schematic diagram of a light source dynamic adjustment device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0059] In order to enable more detailed understanding of the features and technical contents of the embodiments of the present disclosure, the implementation of the embodiments of the present disclosure is described in detail below, and the attached drawings are only used for reference and do not limit the embodiments of the present disclosure. In the following technical description, in order to facilitate explanation, through multiple details, a sufficient understanding of the disclosed embodiments is provided. However, one or more embodiments can still be implemented without these details. In other cases, in order to simplify the drawings, well-known structures and devices can be simplified.
[0060] The terms "first", "second", and the like in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion.
[0061] Unless otherwise specified, the term "multiple" means two or more.
[0062] In the embodiments of the present disclosure, the character " / " represents an "or" relationship between the objects before and after it. For example, A / B represents: A or B.
[0063] The term "and / or" is a description of the association between objects, which means that there can be three relationships. For example, A and / or B means: A or B, or, A and B, the three relationships.
[0064] The term "corresponding" can refer to an association or binding relationship. A and B correspond to each other means that there is an association or binding relationship between A and B.
[0065] As Figure 1 As shown in the figure, the present disclosure provides a light source dynamic adjustment system, which comprises a light source dynamic adjustment device and a light source, and the light source is in communication connection with the light source dynamic adjustment device. The light source is used to irradiate a target object, wherein the target object can be determined according to the application scene of the light source dynamic adjustment system. Taking the yarn production textile scene as an example, the target object can be at least one of a yarn pipe and a skin roller.
[0066] In the embodiments of the present disclosure, the light source dynamic adjustment device can have a camera function to obtain an image of the target object. Alternatively, the light source dynamic adjustment device can be in communication connection with a camera module, and the light source dynamic adjustment device obtains an image of the target object through the camera module. The light source dynamic adjustment device can adjust the incident angle of the light source according to the image of the target object, optimize the irradiation effect of the light source on the target object, and improve the imaging quality of the target object.
[0067] With the light source dynamic adjustment device (hereinafter referred to as adjustment device) provided by the embodiments of the present disclosure, the embodiments of the present disclosure provide a first light source dynamic adjustment method, and the embodiments of the present disclosure provide a second light source dynamic adjustment method in combination with Figure 2 As shown in FIG. 1, the light source dynamic adjustment method comprises the following steps:
[0068] S201, the adjustment device determines the color of the target object based on the initial image of the target object, matches the surface feature corresponding to the color in the optical feature database, and determines the initial value of the incident angle of the light source based on the surface feature.
[0069] In the embodiments of the present disclosure, the light source dynamic adjustment method is applied to a spinning scene, and the target object is a bobbin or a flyer. Here, the optical feature database is obtained by performing spectral scanning on different sample objects. Specifically, a multi-spectral scanning system can be used to perform rapid spectral acquisition on sample objects (such as bobbins and flyers) of different colors within a preset wavelength range (for example, 300nm to 1100nm); and in the visible light range (400nm to 700nm), the sampling needs to be encrypted to fully cover the surface features under different environmental light conditions, thereby constructing the optical feature database.
[0070] In the embodiments of the present disclosure, the initial image refers to the first frame image of the target object acquired before starting to adjust the incident angle of the light source. The initial image is mainly used to determine the color of the target object, and provides a basis for determining the initial value of the incident angle of the light source. By presetting a suitable illumination angle according to the optical properties of the color of the target object in the initial stage, the problem of insufficient brightness or overexposure caused by the color difference of the target object is avoided.
[0071] S202, the adjustment device adjusts the incident angle of the light source based on the initial value.
[0072] After S202, the adjustment device enters the dynamic adjustment stage. In the dynamic adjustment stage, the adjustment device periodically acquires real-time images of the target object, and each real-time image is an image of the target object collected at a certain time in the dynamic adjustment stage. For each acquired real-time image, S203 to S205 are executed in turn. That is, S203 to S205 are repeatedly executed, and the contents of S203 to S205 are as follows:
[0073] S203, the adjustment device determines the image contrast and the mirror reflection area ratio based on the real-time image of the target object.
[0074] S204, the adjustment device determines the incident angle error index based on the image contrast and the mirror reflection area ratio.
[0075] In the embodiments of the present disclosure, the image contrast reflects the clarity of the target edge and feature, and the mirror reflection area ratio represents the degree of highlight interference. The incident angle error index is constructed based on the two indexes, which can quantify the deviation between the current incident angle and the ideal illumination state.
[0076] In S205, the adjusting device adjusts the incident angle of the light source based on the incident angle error index.
[0077] The light source dynamic adjustment method provided by the embodiments of the present disclosure first determines the color of the target object based on the initial image of the target object, and determines the initial value of the incident angle of the light source according to the color, so that a suitable illumination angle is preset according to the optical characteristics of the color of the target object in the initial stage, avoiding the problems of insufficient brightness or overexposure caused by color difference. Subsequently, the incident angle of the light source is adjusted based on the initial value, and enters the dynamic adjustment stage. In the dynamic adjustment stage, the real-time image of the target object is continuously acquired, and the imaging quality under the current illumination condition is comprehensively evaluated by analyzing two key indexes of image contrast and mirror reflection area ratio. The incident angle error index is constructed based on the two indexes, which can quantify the deviation between the current incident angle and the ideal illumination state, and the incident angle of the light source is dynamically adjusted according to the incident angle error index, gradually suppressing shadows, enhancing feature contrast, and reducing the interference caused by mirror reflection. Through the above adjustment process, the light source can adapt to target objects of different colors and surface properties, significantly improve the imaging quality, improve the accuracy and stability of the positioning of the vision system, reduce the false detection, missed detection and repeated operation caused by poor imaging, and thus improve the efficiency of automatic production.
[0078] In some embodiments, the color of the target object is determined based on the initial image of the target object, the surface feature in the optical feature database is matched based on the color, and the initial value of the incident angle of the light source is determined based on the surface feature, including: inputting the initial image of the target object into the incident angle setting model, and identifying the color of the target object by the incident angle setting model; determining the surface feature of the target object based on the color by using the incident angle setting model, and determining the initial value of the incident angle of the light source according to the surface feature.
[0079] In combination with Figure 3 As shown in the figure, the embodiments of the present disclosure provide a second light source dynamic adjustment method, which includes the following steps:
[0080] In S301, the adjusting device inputs the initial image of the target object into the incident angle setting model, and identifies the color of the target object by the incident angle setting model.
[0081] In S302, the adjusting device matches the surface feature corresponding to the color in the optical feature database by using the incident angle setting model, and determines the initial value of the incident angle of the light source according to the surface feature.
[0082] S303, the adjusting device adjusts the incident angle of the light source based on the initial value.
[0083] After S303, the adjusting device enters a dynamic adjustment phase. In the dynamic adjustment phase, the adjusting device periodically acquires real-time images of the target object, each real-time image being an image of the target object captured at a certain time in the dynamic adjustment phase. For each acquired real-time image, S304 to S306 are sequentially executed. That is, S304 to S306 are repeatedly executed, and the contents of S304 to S306 are as follows:
[0084] S304, the adjusting device determines the image contrast and the specular reflection region proportion based on the real-time image of the target object.
[0085] S305, the adjusting device determines the incident angle error index based on the image contrast and the specular reflection region proportion.
[0086] S306, the adjusting device adjusts the incident angle of the light source based on the incident angle error index.
[0087] In some embodiments, the incident angle setting model is obtained by joint training based on sample images of sample objects of different colors, surface features corresponding to each color in the optical feature database, and imaging quality data of the sample objects under different incident angles. Here, the surface features include any one of the following: specular reflection coefficient, diffuse reflection coefficient, surface roughness, and refractive index. A multi-spectral scanning system can be used to perform rapid spectral acquisition on sample objects (such as yarn tubes and leather rollers) of different colors within a preset waveband (for example, 300 nm to 1100 nm); among them, in the visible light range (400 nm to 700 nm), encrypted sampling is required to fully cover the surface features under different environmental light conditions. Based on the sample images of sample objects of different colors and the spectral data corresponding to each color, a sample data set is constructed, and each sample is labeled with an "optimal initial incident angle" - the optimal initial incident angle can be determined by experiment, and finally a four-dimensional training data set of "sample image-spectral data-color category-optimal initial incident angle" is formed. The above spectral data can be used as surface features representing the sample object. Based on the collected spectral data, surface feature vectors containing physical properties such as specular reflection coefficient, diffuse reflection coefficient, surface roughness, and refractive index are further extracted and constructed. Subsequently, the sample data is classified according to the color of the sample object in a fine-grained manner, and a convolutional neural network is used to jointly learn the sample image, its corresponding surface features, and the optimal initial incident angle, and an incident angle setting model is trained. The incident angle setting model can identify the color of the sample object from the initial image of the sample object, and predict the initial value of the incident angle of the light source that adapts to the sample object based on the surface features associated with the color, thereby effectively reducing the search range in the dynamic adjustment process and improving the adjustment response speed and positioning accuracy.
[0088] In some embodiments, the image contrast is obtained by determining a maximum pixel value and a minimum pixel value of the grayscale real-time image, calculating a pixel difference value and a pixel sum value of the maximum pixel value and the minimum pixel value, and taking a ratio of the pixel difference value to the pixel sum value as the image contrast.
[0089] In the embodiments of the present disclosure, the image contrast can be calculated by the following formula:
[0090] .
[0091] In the above formula, denotes the image contrast of the real-time image collected at time t, denotes the maximum pixel value of the grayscale real-time image, denotes the minimum pixel value of the grayscale real-time image.
[0092] The embodiments of the present disclosure take the ratio of the pixel difference value to the pixel sum value as the image contrast, which can highlight the difference between the brightest and darkest areas in the image, and intuitively reflect the edge sharpness and texture visibility of the target object. Moreover, this image contrast is essentially a normalization process, which can suppress the interference brought by the overall brightness change of the image, so that the image contrast has better consistency and comparability under different light intensities, which is conducive to stable judgment of the lighting state.
[0093] In some embodiments, the specular reflection area ratio is obtained by determining a number of specular reflection area pixels and a total number of pixels of the real-time image, and taking a ratio of the number of specular reflection area pixels to the total number of pixels as the specular reflection area ratio.
[0094] In the embodiments of the present disclosure, the specular reflection area ratio can be calculated by the following formula:
[0095] .
[0096] In the above formula, denotes the specular reflection area ratio of the real-time image collected at time t, denotes the number of specular reflection area pixels of the real-time image, denotes the total number of pixels of the real-time image.
[0097] The embodiment of the present disclosure can objectively and quantitatively evaluate the overexposure or strong reflection degree of the target surface under the current lighting condition by counting the proportion of the specular reflection region in the whole image. This index directly reflects whether the light source causes serious highlights, resulting in loss of details, and provides a clear basis for optimizing the lighting angle. When the proportion of the specular reflection region is too high, it indicates that the incident angle may be too small or the light source direction is improper, causing the local area to be too bright. The incident angle of the light source can be adjusted in time according to this index to suppress strong reflection and prevent key feature areas from being identified due to saturation, thereby ensuring the stability of the imaging quality.
[0098] In some embodiments, the number of pixels of the specular reflection region is obtained by converting the real-time image from RGB to LAB space, separating the L channel (luminance channel), A channel (red-green color difference channel) and B channel (yellow-blue color difference channel); according to the luminance data of the L channel and the preset luminance condition, the pixels meeting the preset luminance condition are screened to form a luminance feature region; the gradient of the luminance data of the L channel is calculated, and according to the calculated gradient data and the preset gradient condition, the pixels meeting the preset gradient condition are screened to form a gradient feature region; the saturation of the pixels is calculated according to the chroma data of the A channel and the B channel, and according to the calculated saturation data and the preset saturation condition, the pixels meeting the preset saturation condition are screened to form a saturation feature region; the luminance feature region, the gradient feature region and the saturation feature region are merged to obtain the specular reflection region, and the number of pixels of the specular reflection region is counted in the specular reflection region.
[0099] In the embodiment of the present disclosure, the real-time image is converted from RGB space to LAB color space, and the L channel, A channel and B channel are separated to separate the luminance and chroma features.
[0100] For the L channel of the LAB color space, the processing flow is as follows: first, median filtering or Gaussian filtering is used for preprocessing, which filters out image noise to avoid interference with subsequent feature judgment; then, a preset percentage (such as 95%) of the luminance data of the filtered L channel is used as a luminance threshold, and the pixel positions whose luminance data in the L channel are greater than the luminance threshold are screened out, and the luminance feature region is formed by these pixel positions; then, the gradient of the luminance data of the filtered L channel is calculated, and a preset value (such as 30) is used as a gradient threshold, and the pixel positions whose gradient values are greater than the gradient threshold are screened out, and the gradient feature region is formed by these pixel positions.
[0101] For the A channel and the B channel of the LAB color space, the processing procedure is as follows: taking a preset value (20) as a saturation threshold, first, the chroma value square of each pixel in the A channel and the chroma value square of each pixel in the B channel are calculated respectively, then the chroma value squares of the two channels are summed, and the arithmetic square root of the sum is taken; then, the pixel positions with the arithmetic square root result less than the saturation threshold are screened out, and the pixel positions form a saturation feature region.
[0102] In the embodiments of the present disclosure, the luminance feature region is used to reflect the strong light reflection characteristic of the mirror reflection, and the pixels in the luminance feature region are high-luminance pixels. The gradient feature region is used to reflect the mutation characteristic of the edge of the mirror reflection, and provides a basis for distinguishing the real reflection region from the uniform high-brightness region, and the pixels in the gradient feature region are high-gradient pixels. The saturation feature region is a colorless interference region, saturation is a core quantitative index of the chroma feature in the LAB space, and the low saturation characteristic can exclude color interference, so the saturation feature region can accurately lock the "high brightness and colorless" property of the mirror reflection. By merging the luminance feature region, the gradient feature region and the saturation feature region, the accurate identification of the mirror reflection region is realized through the complementary verification of the three features (high luminance ensures light reflection, high gradient ensures edge, and low saturation ensures colorless interference), and finally the number of pixels in the mirror reflection region is obtained in the mirror reflection region.
[0103] In some embodiments, the merging of the luminance feature region, the gradient feature region and the saturation feature region to obtain the mirror reflection region comprises: taking the union of the luminance feature region, the gradient feature region and the saturation feature region to obtain a comprehensive feature region; and performing a morphological closing operation on the comprehensive feature region using a preset neighborhood range and removing small connected regions to obtain the mirror reflection region.
[0104] The embodiments of the present disclosure can more comprehensively capture the mirror reflection phenomenon that may exist in the image by combining the information of three dimensions of luminance (L channel), gradient (gradient of the L channel) and saturation (A channel and B channel). After obtaining the comprehensive feature region, the morphological closing operation is used to fill the possible holes or broken parts in the region, smooth the boundary, and effectively reduce the small errors caused by noise or local changes. Removing small connected regions further filters out false regions that are too small in area and do not meet the characteristics of mirror reflection, reduces the false detection rate, and ensures the authenticity and reliability of the detection result.
[0105] In some embodiments, the incident angle error index is determined based on the image contrast and the mirror reflection region proportion, comprising: calculating a contrast error component based on the image contrast and a preset reference contrast; calculating a mirror reflection region proportion error component based on the mirror reflection region proportion and a preset maximum allowed mirror reflection region proportion; and fusing the contrast error component and the mirror reflection region proportion error component to obtain the incident angle error index.
[0106] In combination Figure 4 As shown in the above, the third light source dynamic adjustment method provided by the embodiments of the present disclosure comprises the following steps:
[0107] S401, determining the color of the target object based on the initial image of the target object, and determining the initial value of the incident angle of the light source based on the color.
[0108] In the embodiments of the present disclosure, the initial image refers to the first frame image of the target object acquired before starting to adjust the incident angle of the light source. The initial image is mainly used to determine the color of the target object, and provides a basis for determining the initial value of the incident angle of the light source. By presetting a suitable illumination angle according to the optical characteristics of the color of the target object in the initial stage, the problem of insufficient brightness or overexposure caused by the color difference of the target object is avoided.
[0109] S402, adjusting the incident angle of the light source based on the initial value.
[0110] After S402, the adjustment device enters the dynamic adjustment stage. In the dynamic adjustment stage, the adjustment device periodically acquires real-time images of the target object, and each real-time image is an image of the target object collected at a certain time in the dynamic adjustment stage. For each acquired real-time image, S403 to S407 are sequentially executed. That is, S403 to S407 are repeatedly executed, and the contents of S403 to S407 are as follows:
[0111] S403, determining the image contrast and the mirror reflection area proportion based on the real-time image of the target object.
[0112] S404, calculating a contrast error component based on the image contrast and a preset reference contrast.
[0113] S405, calculating a mirror reflection area proportion error component based on the mirror reflection area proportion and a preset maximum allowed mirror reflection area proportion.
[0114] S406, fusing the contrast error component and the mirror reflection area proportion error component to obtain an incident angle error index.
[0115] S407, adjusting the incident angle of the light source based on the incident angle error index.
[0116] In some embodiments, calculating the contrast error component based on the image contrast and the preset reference contrast comprises: calculating a contrast difference value of the image contrast and the preset reference contrast, and taking the ratio of the contrast difference value to the reference contrast as the contrast error component.
[0117] The ratio of the contrast difference value to the reference contrast is used as the contrast error component, which is essentially a normalization process. This contrast error component eliminates the influence of different image brightness absolute values or dynamic ranges, so that the contrast error component is comparable under different lighting conditions and different target objects, thereby improving the adaptability and stability under different scenes.
[0118] In some embodiments, the specular reflection region proportion error component is calculated based on the specular reflection region proportion and a preset maximum allowed specular reflection region proportion, including: calculating a proportion difference value of the specular reflection region proportion and the preset maximum allowed specular reflection region proportion, and using the ratio of the proportion difference value to the maximum allowed specular reflection region proportion as the specular reflection region proportion error component.
[0119] The ratio of the proportion difference value to the maximum allowed specular reflection region proportion is used as the specular reflection region proportion error component, which is essentially a normalization process. This specular reflection region proportion error component can eliminate the influence of different image resolutions, field of view sizes or target object sizes, so that the specular reflection region proportion error component has a unified measurement standard under different scenes, thereby improving the adaptability and evaluation consistency under different scenes.
[0120] In some embodiments, the contrast error component and the specular reflection region proportion error component are fused to obtain an incident angle error index, including: calculating a weighted sum of the contrast error component and the specular reflection region proportion error component based on the contrast error component and a corresponding contrast error weight, and the specular reflection region proportion error component and a corresponding region proportion error weight; and using the weighted sum as the incident angle error index.
[0121] In the embodiments of the present disclosure, the contrast error component reflects the clarity of the target edge and the feature, and the specular reflection region proportion error component represents the degree of highlight interference. Through weighted fusion, a dynamic balance between enhancing image contrast and suppressing specular reflection can be achieved, and the imbalance caused by a single index can be avoided, thereby obtaining an overall optimal imaging effect.
[0122] In the embodiments of the present disclosure, the incident angle error index is calculated by the following formula:
[0123] .
[0124] In the above formula, denotes the incident angle error index of the real-time image collected at time t, denotes the image contrast of the real-time image collected at time t, denotes the reference contrast, denotes the contrast error weight, a specular reflection region proportion of a real-time image collected at a time t, a maximum allowed specular reflection region proportion, a region proportion error weight.
[0125] In some embodiments, adjusting the incident angle of the light source based on the incident angle error index comprises: calculating a proportional gain, an integral gain and a differential gain based on the incident angle error index respectively; calculating an incident angle adjustment amount based on the incident angle error index, the proportional gain, the integral gain and the differential gain; and adjusting the incident angle of the light source based on the incident angle adjustment amount.
[0126] In the embodiments of the present disclosure, the proportional gain responds to the current error quickly, the integral gain eliminates the steady-state error, and the differential gain suppresses overshoot and oscillation in the adjustment process. The three work together to ensure that the incident angle of the light source converges accurately to the optimal value, and to improve the adjustment accuracy and system stability. Specifically, when the initial value of the incident angle deviates greatly from the target value, the proportional gain dominates the adjustment process, a large incident angle adjustment amount is generated, and fast approximation is achieved. As the error decreases, the integral gain and the differential gain gradually play a role, making the adjustment process smooth, avoiding repeated oscillation caused by excessive response, and balancing the adjustment speed and stability.
[0127] In combination with Figure 5 As shown in FIG. 4, the embodiments of the present disclosure provide a fourth light source dynamic adjustment method. The light source dynamic adjustment method comprises the following steps:
[0128] S501, the adjustment device determines the color of the target object based on the initial image of the target object, and determines the initial value of the incident angle of the light source based on the color.
[0129] S502, the adjustment device adjusts the incident angle of the light source based on the initial value.
[0130] After S502, the adjustment device enters the dynamic adjustment stage. In the dynamic adjustment stage, the adjustment device periodically acquires real-time images of the target object. Each real-time image is an image of the target object collected at a certain time in the dynamic adjustment stage. For each acquired real-time image, S503 to S507 are executed in turn. That is, S503 to S507 are repeatedly executed, and the contents of S503 to S507 are as follows:
[0131] S503, the adjustment device determines the image contrast and the specular reflection region proportion based on the real-time image of the target object.
[0132] S504, the adjustment device determines the incident angle error index based on the image contrast and the specular reflection region proportion.
[0133] S505, the adjustment device calculates a proportional gain, an integral gain and a differential gain based on the incident angle error index respectively.
[0134] S506, the adjusting device calculates the incident angle adjustment amount based on the incident angle error index, the proportional gain, the integral gain and the differential gain.
[0135] S507, the adjusting device adjusts the incident angle of the light source based on the incident angle adjustment amount.
[0136] In the embodiments of the present disclosure, the proportional gain is calculated by the following formula:
[0137] .
[0138] In the above formula, represents the proportional gain, represents the basic proportional gain, represents the gain adjustment coefficient, represents the incident angle error index of the real-time image collected at time t.
[0139] In the embodiments of the present disclosure, the integral gain is calculated by the following formula:
[0140] .
[0141] In the above formula, represents the integral gain, represents the basic integral gain, represents the integral adjustment coefficient, represents the incident angle error index of the real-time image collected at time t.
[0142] In the embodiments of the present disclosure, the differential gain is calculated by the following formula:
[0143] .
[0144] In the above formula, represents the differential gain, represents the basic differential gain, represents the differential adjustment coefficient, represents the incident angle error index of the real-time image collected at time t.
[0145] In the embodiments of the present disclosure, the incident angle adjustment amount is calculated by the following formula:
[0146] .
[0147] represents the incident angle adjustment amount at time t, represents the proportional gain, represents the integral gain, represents the differential gain, an indicator of an angle of incidence error of a real-time image acquired at time t, an integral of an indicator of an angle of incidence error of a real-time image, a derivative of an indicator of an angle of incidence error.
[0148] in combination Figure 6 As shown in the drawings, the light source dynamic adjustment device 600 provided by the embodiments of the present disclosure includes a processor 601 and a memory 602. Optionally, the light source dynamic adjustment device 600 can further include a communication interface 603 and a bus 604. The processor 601, the communication interface 603, and the memory 602 can complete communication with each other through the bus 604. The communication interface 603 can be used for information transmission. The processor 601 can invoke the logical instructions in the memory 602 to execute the light source dynamic adjustment method of the above-mentioned embodiments.
[0149] In addition, the logical instructions in the memory 602 described above can be implemented in the form of a software functional unit and sold or used as an independent product, which can be stored in a computer readable storage medium.
[0150] The memory 602 as a kind of computer readable storage medium can be used to store software programs, computer executable programs, such as the program instructions / modules corresponding to the method in the embodiments of the present disclosure. The processor 601 executes the program instructions / modules stored in the memory 602, thereby executing functional applications and data processing, that is, implementing the light source dynamic adjustment method in the above-mentioned embodiments.
[0151] The memory 602 can include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required by a function; the data storage area can store data created according to the use of the terminal device, etc. In addition, the memory 602 can include a high-speed random access memory, and can also include a non-volatile memory.
[0152] The embodiments of the present disclosure provide a computer readable storage medium, which stores computer executable instructions, and the computer executable instructions are configured to execute the light source dynamic adjustment method described above.
[0153] The technical solutions of the embodiments of the present disclosure can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes one or more instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method disclosed in the embodiments of the present disclosure. The aforementioned storage medium can be a non-transitory storage medium, for example, a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes. The above description and drawings sufficiently illustrate the embodiments of the present disclosure, so that those skilled in the art can practice them. Other embodiments can include structural, logical, electrical, process, and other changes. The embodiments only represent possible changes. Unless explicitly required, individual components and functions are optional, and the order of operations can be changed. Some parts and features of some embodiments can be included in or replace parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and not to limit the claims. As used in the description of the embodiments and the claims, unless the context clearly indicates otherwise, the singular forms "a", "an", and "the" are intended to include the plural forms as well. Similarly, as used in this application, the term "and / or" refers to any and all possible combinations of one or more associated listed items. In addition, when used in this application, the term "comprise" and its variants "comprises" and / or "comprising" and the like refer to the presence of the stated features, integers, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. Without more limitations, the element defined by the statement "comprises one" does not exclude the presence of additional identical elements in the process, method, or device that includes the stated element. In this document, each embodiment focuses on the differences from other embodiments, and the same or similar parts between various embodiments can be referred to each other. For the method, product, etc. disclosed in the embodiments, if it corresponds to the method part disclosed in the embodiments, the relevant part can be referred to the description of the method part.
[0154] Those skilled in the art can understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods for each specific application to realize the described functions, but such implementation should not be considered beyond the scope of the embodiments of the present disclosure. The skilled person can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described system, device and unit can refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.
[0155] In the embodiments disclosed herein, the disclosed methods, products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the above-described device embodiments are only schematic, for example, the division of the units can only be a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms. The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to implement the embodiments. In addition, each functional unit in the embodiments of the present disclosure can be integrated in one processing unit, or each unit can be a physically independent unit, or two or more units can be integrated in one unit.
[0156] The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other processing device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other processing device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks.
Claims
1. A method of dynamic adjustment of a light source, characterized by, The method comprises the following steps: determining the color of the target object based on an initial image of the target object, matching a surface feature corresponding to the color in an optical feature database, and determining an initial value of the incident angle of the light source based on the surface feature, wherein the target object is a bobbin or a leather roller, and the optical feature database is obtained by performing spectral scanning on different sample objects; adjusting the incident angle of the light source based on the initial value; entering a dynamic adjustment stage, in which the following steps are repeatedly performed: determining the image contrast and the mirror reflection area proportion based on a real-time image of the target object; determining the incident angle error index based on the image contrast and the mirror reflection area proportion; adjusting the incident angle of the light source based on the incident angle error index; The mirror reflection area proportion is obtained by determining the number of mirror reflection area pixels and the total number of pixels in the real-time image, and taking the ratio of the number of mirror reflection area pixels to the total number of pixels as the mirror reflection area proportion. The determination of the incident angle error index based on the image contrast and the mirror reflection area proportion comprises the following steps:
2. The light source dynamic adjustment method of claim 1, wherein, calculating a contrast error component based on the image contrast and a preset reference contrast; calculating a mirror reflection area proportion error component based on the mirror reflection area proportion and a preset maximum allowed mirror reflection area proportion; calculating a weighted sum of the contrast error component and the mirror reflection area proportion error component based on the contrast error component and its corresponding contrast error weight, the mirror reflection area proportion error component and its corresponding area proportion error weight; and taking the weighted sum as the incident angle error index.
3. The light source dynamic adjustment method of claim 2, wherein, The method for determining the initial value of the incident angle of the light source based on the color of the target object and matching the surface feature in the optical feature database comprises the following steps:
4. The light source dynamic adjustment method of claim 1, wherein, inputting the initial image of the target object into an incident angle setting model to identify the color of the target object by the incident angle setting model; matching the surface feature corresponding to the color in the optical feature database by using the incident angle setting model, and determining the initial value of the incident angle of the light source based on the surface feature, wherein the incident angle setting model is obtained by joint training based on sample images of sample objects of different colors, surface features corresponding to each color in the optical feature database, and imaging quality data of the sample objects under different incident angles. The surface feature comprises any one of the following: a mirror reflection coefficient, a diffuse reflection coefficient, a surface roughness, and a refractive index. The image contrast is obtained by the following steps:
5. The light source dynamic adjustment method of claim 1, wherein, determining the maximum pixel value and the minimum pixel value of the grayed real-time image; calculating the pixel difference value and the pixel sum value of the maximum pixel value and the minimum pixel value; taking the ratio of the pixel difference value to the pixel sum value as the image contrast. The number of mirror reflection area pixels is obtained by the following steps: converting the real-time image from RGB to LAB space, separating the L channel, the A channel and the B channel; screening out pixels meeting a preset brightness condition to form a brightness feature region according to the brightness data of the L channel and the preset brightness condition, wherein the brightness feature region is used to reflect the strong light reflection characteristic of the mirror reflection; Gradient calculation is performed on the luminance data of the L channel, and pixels meeting preset gradient conditions are screened out from the calculated gradient data and the preset gradient conditions to form a gradient feature region, wherein the gradient feature region is used to reflect the mutation characteristics of the specular reflection edge; Pixel saturation is calculated according to the chrominance data of the A channel and the B channel, and pixels meeting preset saturation conditions are screened out from the calculated saturation data and the preset saturation conditions to form a saturation feature region, wherein the saturation feature region is an achromatic interference region; The luminance feature region, the gradient feature region and the saturation feature region are merged to obtain a specular reflection region, and the number of pixels in the specular reflection region is counted.
6. The light source dynamic adjustment method of claim 5, wherein, The luminance feature region, the gradient feature region and the saturation feature region are merged to obtain a specular reflection region, including: The luminance feature region, the gradient feature region and the saturation feature region are taken as a union set to obtain a comprehensive feature region; The comprehensive feature region is subjected to morphological closing operation with a preset neighborhood range and small connected regions are removed to obtain the specular reflection region.
7. The light source dynamic adjustment method of claim 1, wherein, A contrast error component is calculated based on the image contrast and a preset reference contrast, including: calculating a contrast difference value of the image contrast and the preset reference contrast, and taking the ratio of the contrast difference value to the reference contrast as the contrast error component; And / or, a specular reflection region proportion error component is calculated based on the specular reflection region proportion and a preset maximum allowed specular reflection region proportion, including: calculating a proportion difference value of the specular reflection region proportion and the preset maximum allowed specular reflection region proportion, and taking the ratio of the proportion difference value to the maximum allowed specular reflection region proportion as the specular reflection region proportion error component.
8. The light source dynamic adjustment method of claim 1, wherein, The incident angle of the light source is adjusted based on the incident angle error index, including: The proportional gain, the integral gain and the differential gain are calculated based on the incident angle error index, respectively; The incident angle adjustment amount is calculated based on the incident angle error index, the proportional gain, the integral gain and the differential gain; The incident angle of the light source is adjusted based on the incident angle adjustment amount.
9. A light source dynamic adjustment apparatus comprising a processor and a memory having stored therein program instructions, the apparatus being characterized by: The processor executes the light source dynamic adjustment method according to any one of claims 1 to 8.
10. A light source dynamic adjustment system, characterized by, The light source and the light source dynamic adjustment device according to claim 9 are in communication connection.
11. A storage medium, characterized by The storage medium stores computer program instructions, and when the computer program instructions are run by the processor, the light source dynamic adjustment method according to any one of claims 1 to 8 is executed.
Citation Information
Patent Citations
Socket surface defect detection method and system based on image processing
CN120064298A
Assembly production line workpiece defect detection method and system based on machine vision
CN120427521A