Adjusting method of binocular camera adaptive parameter adjusting device

By combining the EMA and PI algorithms with a distance compensation mechanism, adaptive parameter tuning of the binocular camera was achieved, solving the problems of uneven brightness and inconsistent brightness in dynamic detection, and improving the stability and accuracy of image acquisition and depth detection.

CN121691925APending Publication Date: 2026-03-17ANHUI UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-26
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing binocular stereo vision systems cannot adapt to the lighting differences in their respective fields of view in terms of brightness adjustment, resulting in uneven brightness between the left and right sides, which affects the accuracy of depth detection. In particular, the brightness is inconsistent when the distance between the workpiece and the camera changes in dynamic detection scenarios, affecting the stability of imaging.

Method used

A binocular camera adaptive parameter adjustment device is adopted. The EMA algorithm smooths brightness fluctuations, the PI algorithm dynamically adjusts exposure time and gain, and combined with a distance compensation mechanism, the left and right cameras can independently adjust brightness to ensure the stability and consistency of image acquisition.

Benefits of technology

It achieves adaptive control of the brightness of the left and right cameras, eliminates stereo matching errors caused by brightness imbalance, improves the stability of image acquisition and the accuracy of depth detection, and adapts to brightness changes in dynamic detection scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121691925A_ABST
    Figure CN121691925A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer vision and industrial automatic detection, and discloses an adjusting method of a binocular camera self-adaptive parameter adjusting device, and the binocular camera self-adaptive parameter adjusting device comprises an industrial camera support, a binocular camera, a high-power area light source, an industrial personal computer, a PC, a power supply and an industrial lens. According to the adjusting method, depth detection is finally achieved through initialization, target brightness setting, current brightness calculation, smooth fluctuation, error feedback, dynamic exposure and gain adjustment, distance compensation and binocular independent adjustment. A binocular brightness independent self-adaptive control mechanism is innovatively constructed, the left and right cameras can automatically adjust parameters according to respective view illumination and workpiece reflection characteristics, brightness deviation is monitored in real time and balanced compensation is performed, and the problems that a traditional system cannot adjust parameters according to illumination conditions and the brightness of the left and right cameras is not uniform are solved. And a balanced and reliable image basis is provided for subsequent depth detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer vision and industrial automation inspection technology, and in particular to an adjustment method for a binocular camera adaptive parameter adjustment device. Background Technology

[0002] With the development of intelligent manufacturing and industrial automation, binocular stereo vision technology, with its advantages of non-contact measurement and high-precision 3D information acquisition, has been widely used in industrial inspection, robot navigation, quality control, and other fields. It simulates the principle of human binoculars, using two cameras to acquire images from different perspectives, and then reconstructs the 3D information of an object through parallax calculation, enabling precise workpiece inspection and improving production efficiency. Clear and balanced images and stable acquisition are crucial to ensuring the accuracy of subsequent measurements.

[0003] However, existing systems have obvious defects: in terms of brightness adjustment, they mostly adopt synchronous parameter adjustment of the left and right cameras, which cannot adapt to the differences in illumination of their respective fields of view, easily leading to uneven brightness between the left and right sides, causing stereo matching errors and affecting the depth detection accuracy; in dynamic detection scenarios, there is no distance brightness compensation, and the exposure cannot be adjusted according to the real-time distance between the workpiece and the camera. When the workpiece is far away, the image is dark; when it is close, it is overexposed. The brightness is inconsistent at different positions, which destroys the image stability, affects the detection accuracy, and does not meet the requirements of dynamic detection. Summary of the Invention

[0004] To overcome the above shortcomings, the present invention provides an adjustment method for a binocular camera adaptive parameter adjustment device, which aims to improve the problem that the existing technology mostly uses synchronous parameter adjustment of the left and right cameras, resulting in the inability to adapt to the lighting differences in their respective fields of view.

[0005] To achieve the above objectives, the present invention adopts the following technical solution: an adjustment method for a binocular camera adaptive parameter adjustment device, the binocular camera adaptive parameter adjustment device comprising an industrial camera bracket, a binocular camera, a high-power surface light source, an industrial control computer, a PC, and a power supply; the workpiece to be inspected is placed on the loading platform at the bottom of the industrial camera bracket, the high-power surface light source is located at the top of the industrial camera bracket, the binocular camera consists of two industrial cameras, each equipped with an industrial lens, the binocular camera is fixed on both sides of the top of the industrial camera bracket, the industrial control computer establishes a communication connection with the PC and the binocular camera through a network cable, and the power supply provides power to the binocular camera, the high-power surface light source, the industrial control computer, and the PC;

[0006] The adjustment method steps are as follows:

[0007] S1 System Initialization: Set the fixed frame rate f of the left and right stereo cameras via PC, and preset the exposure time range [E]. min E max and gain range [G] min G max Read the calibration parameters of the stereo camera and start the image acquisition thread;

[0008] S2 Target Brightness Setting: Based on the reflectivity of the workpiece, the target brightness value L of the left and right binocular camera fields of view is manually set via a PC control program. tL L tR The brightness value ranges from [0, 255].

[0009] S3 calculates the current brightness value: The amount of light received is collected through the internal sensors of the binocular camera, acquiring images of the workpiece captured by the left and right binocular cameras. Each frame of the image is processed according to the formula... Calculate the average brightness, where I i Let L be the gray level of the i-th pixel, and N be the total number of pixels. The current brightness values ​​L for the left and right pixels are obtained respectively. curL L curR ;

[0010] S4 Smoothing Brightness Fluctuations: The current brightness value obtained in step S3 is smoothed using the EMA algorithm. The algorithm formula is as follows: , where L ema (t) represents the smoothed brightness value at time t, ranging from [0, 255]; α is the smoothing coefficient, ranging from 0 < α ≤ 1; L cur (t) represents the original observed brightness at time t; L ema (t-1) represents the EMA output of the previous frame;

[0011] S5 calculates the relative error: according to the formula Calculate the relative error, where L target e(t) represents the target brightness value, and e(t) represents the current brightness error, which is used to provide feedback on whether the current brightness is too bright or too dark relative to the target brightness.

[0012] S6 dynamically adjusts exposure time: using brightness error as feedback, it dynamically calculates the control quantity based on the PI algorithm and adjusts according to the strategy of "prioritizing exposure to increase brightness and prioritizing gain to decrease brightness". The exposure adjustment algorithm is as follows: Where E(t+1) is the exposure value of the next frame, E(t) is the current exposure value, Clamp is the clipping function, and K... p The value range is [0.01, 0.5], K i The value range is [0.001, 0.05];

[0013] S7 Dynamic Gain Adjustment: Gain adjustment is triggered when the exposure time reaches the preset upper limit. The adjustment algorithm is as follows: Where G(t+1) is the gain value for the next frame, G(t) is the current gain value, and K... g This is the gain adjustment coefficient, with a value range of [0.01, 0.1].

[0014] S8 Distance Compensation Corrects Target Brightness: When the workpiece's height changes within the range of [-50mm, 50mm] from the binocular camera, the real-time distance Z is obtained through binocular stereo ranging, and the result is calculated using the formula... Correct target brightness, where L c To compensate for the target brightness value, L t K is the initial target brightness value. Z Z0 is the distance compensation coefficient, and Z0 is the reference distance. This refers to the relative distance deviation;

[0015] S9 Dual-Cam Independent Adjustment: The left and right dual cameras adjust independently based on the target brightness value L. tL L tR Steps S3 to S8 are executed independently to make the brightness of the workpiece surface in the left and right images approach the set target value.

[0016] S10 Depth Detection Output: After the brightness stabilizes, the disparity map is calculated using the stereoSGBM algorithm, and the workpiece depth is detected through the depth matrix Z(u,v).

[0017] Preferably, the smoothing coefficient α is in the range of 0.1 to 0.5, which is used to balance the brightness response speed and stability.

[0018] Preferably, the workpiece undergoes binocular calibration and stereo correction sequentially to obtain relevant calibration parameters, and a binocular stereo matching algorithm is used to determine the distance Z, as shown in the formula: Where f is the camera focal length, B is the binocular baseline length, D is the disparity value of the same pixel in the field of view of the left and right cameras (in pixels), and Z is the distance between the camera and a single pixel on the workpiece surface; a depth map is generated through stereo matching, and the depth map is used to calculate the distance from each pixel on the workpiece surface to the camera. The depth values ​​of all pixels on the workpiece surface are summed to obtain the depth matrix: .

[0019] Preferably, the exposure time range [E] min E max The gain range is [500μs, 20000μs], and the gain range is [G]. min G max The value is [0, 12dB], and the fixed frame rate f is 30FPS. The frame rate is kept stable by parameter limiting.

[0020] Preferably, the core of the stereoSGBM algorithm is to minimize the energy function E(D), which is defined as: Where p and q are image pixels, and D p Let C(p,D) be the disparity value of pixel P. p ) represents the matching cost, N pLet P be the set of neighboring pixels of pixel P, where P1 is the small disparity penalty term and P2 is the large disparity penalty term.

[0021] Preferably, the system periodically calculates and smooths the left and right brightness differences. Automatic balance compensation is performed when ΔL > ε, where the threshold is... The exposure and gain of the binocular camera are adjusted by linking the industrial control computer with the PC.

[0022] Preferably, the target brightness value is adaptively adjusted according to the workpiece position: when the workpiece depth is constant, the target brightness value remains constant, and the exposure and gain are adjusted to adapt to changes in ambient light; when the workpiece depth changes, the brightness compensation algorithm based on distance measurement is applied. The target brightness value is dynamically corrected to make the workpiece brightness consistent with the initial calibration state.

[0023] Preferably, the parameters are set as follows: EMA parameter α = 0.3, PI control parameter K p =0.02, K i =0.001, Distance compensation coefficient K Z =0.15, under the conditions of ambient brightness variation of ±30% and workpiece distance variation of ±50mm, the brightness fluctuation is controlled within ±5%, and the depth detection error is less than 0.3mm.

[0024] Preferably, the PC is equipped with Visual Studio software, and the control program is developed using C# and OpenCV, including image acquisition, PI adaptive control, and binocular ranging brightness compensation modules.

[0025] The present invention has the following beneficial effects:

[0026] 1. This invention employs a binocular brightness independent adaptive control mechanism, overcoming the core challenge of uneven brightness between the left and right images in traditional binocular systems. The left and right cameras can autonomously set appropriate target brightness based on the lighting conditions and workpiece reflection characteristics within their respective fields of view. Exposure time and gain parameters can be flexibly adjusted without manual intervention, perfectly adapting to lighting differences from different viewing angles and uneven local reflections of the workpiece. The system also continuously monitors the brightness deviation between the left and right images. Once the deviation exceeds a reasonable range, a balance compensation process is automatically initiated. By precisely fine-tuning the exposure and gain parameters, the brightness characteristics of the two images are ensured to be highly consistent, eliminating stereo matching errors caused by brightness imbalance at the source. This provides a balanced and reliable image foundation for subsequent parallax calculation and depth detection.

[0027] 2. In this invention, a dual design of frame rate stability assurance and brightness smoothing processing ensures continuous and stable operation of the image acquisition process. The system sets a fixed frame rate and employs a parameter limiting strategy, effectively avoiding frame rate fluctuations that may occur during automatic exposure adjustment, ensuring smooth and continuous image acquisition without stuttering or frame skipping. Simultaneously, an exponential moving average filtering algorithm is introduced to smooth the real-time acquired brightness values, effectively filtering brightness jitter caused by instantaneous fluctuations in illumination, making brightness changes smoother and significantly improving the stability of the brightness signal. This dual assurance mechanism provides high-quality, highly stable raw image data for subsequent error calculation, parameter adjustment, and depth detection, greatly reducing detection errors caused by image fluctuations and laying a solid foundation for stable system operation.

[0028] 3. This invention incorporates a distance-based brightness compensation mechanism to achieve consistent brightness control of the workpiece at different positions, completely resolving the brightness deviation problem caused by workpiece movement in dynamic inspection scenarios. When the distance between the workpiece and the camera changes, the system captures the workpiece's distance information in real time using binocular stereo ranging technology. Combined with a preset reference distance and compensation coefficient, the system dynamically corrects the target brightness value. When the workpiece moves away from the camera, the light intensity naturally decreases, and the system automatically increases the target brightness to offset the darkening effect caused by insufficient light flux. When the workpiece moves closer to the camera, the light intensity increases, and the system correspondingly reduces the target brightness to avoid overexposure. This mechanism ensures that regardless of the workpiece's position, its surface brightness remains consistent with the initial calibration state, allowing the system to maintain a stable and clear imaging effect even in dynamic inspection scenarios. Attached Figure Description

[0029] Figure 1 This is an overall diagram of the present invention;

[0030] Figure 2 This is a schematic diagram of a binocular camera structure;

[0031] Figure 3 A schematic diagram of the structure for the binocular camera and the workpiece to work together;

[0032] Figure 4 Diagram of an adaptive parameter tuning system;

[0033] Figure 5 This is a flowchart for adaptive parameter tuning.

[0034] Legend:

[0035] 1. Industrial camera bracket; 2. High-power surface light source; 3. Industrial computer; 4. Binocular camera; 5. PC; 6. Workpiece. Detailed Implementation

[0036] 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.

[0037] Example 1, refer to Figures 1-5 An adjustment method for a binocular camera adaptive parameter adjustment device is disclosed. The binocular camera adaptive parameter adjustment device includes an industrial camera bracket 1, a binocular camera 4, a high-power surface light source 2, an industrial control computer 3, a PC 5, a power supply, and an industrial lens. The platform at the bottom of the industrial camera bracket 1 is used to place the workpiece 6 to be inspected. The high-power surface light source 2 is installed on the top of the industrial camera bracket 1. The binocular camera 4 consists of two industrial cameras with industrial lenses on the left and right sides and is fixed on the top sides of the industrial camera bracket 1. The industrial control computer 3 establishes stable communication with the PC 5 and the binocular camera 4 through a network cable. The power supply continuously provides power to the binocular camera 4, the high-power surface light source 2, the industrial control computer 3, and the PC 5 to ensure the operation of the system.

[0038] The adjustment method steps are as follows:

[0039] S1 system initialization: Set the fixed frame rate of the left and right binocular cameras 4 to 30FPS through PC 5, preset the exposure time range to 500μs to 20000μs and the gain range to 0 to 12dB, read the intrinsic and extrinsic parameters of the binocular cameras 4 after MATLAB calibration and start the image acquisition thread to ensure that the image acquisition is continuous and without lag.

[0040] S2 Target Brightness Setting: Based on the reflection characteristics of workpiece 6, the target brightness value L of the left and right binocular cameras 4 is manually set using the control program developed in Visual Studio software on PC 5. tL L tR The brightness value ranges from 0 to 255, adapting to the differences in reflectivity of different workpiece surfaces;

[0041] S3 calculates the current brightness value: The amount of light received is collected by the internal sensor of the binocular camera 4, acquiring images of the workpiece 6 captured by the left and right binocular cameras 4. Each frame of the image is processed according to the formula... Calculate the average brightness, where I i Let L be the gray level of the i-th pixel, and N be the total number of pixels. The current brightness values ​​L for the left and right channels are obtained respectively. curL L curR This provides basic data for subsequent adjustments;

[0042] S4 Smoothing Brightness Fluctuations: The current brightness value obtained in step S3 is smoothed using the EMA exponential moving average algorithm. The algorithm formula is as follows: Lema (t) represents the smoothed brightness value at time t, ranging from 0 to 255. α is the smoothing coefficient, with an optimal value of 0.3. A larger α value improves the smoothing effect on the latest observations of L. cur (t) A faster response but weaker smoothing effect; a smaller α indicates a greater dependence on historical values, resulting in a slower but smoother response. L cur (t) represents the original observed brightness at time t, typically referring to the average grayscale value of the ROI. ema (t-1) represents the EMA output of the previous frame, effectively suppressing brightness jitter caused by instantaneous fluctuations in illumination;

[0043] S5 calculates the relative error: according to the formula Calculate the relative error, where L target e(t) represents the target brightness value, and e(t) represents the current brightness error. This provides a clear feedback on whether the current brightness is too bright or too dark relative to the target brightness, thus providing a clear direction for parameter adjustment.

[0044] S6 Dynamic Exposure Time Adjustment: Using brightness error as feedback, it dynamically calculates the control quantity based on a PI control algorithm and adjusts according to a "brightness increase priority exposure, brightness decrease priority gain" strategy. The exposure adjustment algorithm is as follows: Where E(t+1) is the exposure value for the next frame, and E(t) is the current exposure value. The Clamp function limits the calculation result to a preset range to prevent exposure overflow or falling below the minimum exposure. K p The optimal parameters are K, with values ​​of 0.02 and Ki, and 0.001. p K is used to adjust the instantaneous response level of brightness error. i This is used to adjust the compensation intensity for error accumulation, ensuring fast and stable brightness adjustment;

[0045] S7 Dynamic Gain Adjustment: Gain adjustment is triggered when the exposure time reaches a preset upper limit. The adjustment algorithm is as follows: Where G(t+1) is the gain value for the next frame, G(t) is the current gain value, and K... g K is the gain adjustment coefficient, ranging from 0.01 to 0.1. g A higher gain results in a faster response to brightness errors but is also more prone to oscillations or increased noise. Gain adjustment can further optimize the brightness effect.

[0046] S8 Distance Compensation Corrects Target Brightness: When the height of workpiece 6 changes within the range of -50mm to 50mm from the binocular camera 4, the real-time distance Z is obtained through binocular stereo ranging, and the result is calculated according to the formula... Correct target brightness, where L c To compensate for the target brightness value, L t K is the initial target brightness value. Z The optimal value for the distance compensation coefficient is 0.15, and Z0 is the reference distance, i.e., the reference position of the workpiece during system calibration. This represents the relative distance deviation, with a positive deviation indicating distance from the camera and a negative deviation indicating proximity to the camera, effectively offsetting the difference in light flux caused by changes in distance.

[0047] S9 Dual-Cam Independent Adjustment: The left and right dual-camera 4 adjust independently based on the target brightness value L. tL L tR Steps S3 to S8 are executed independently to adapt to the differences in lighting and the reflection characteristics of the workpiece in their respective fields of view, so that the brightness of the surface of workpiece 6 in the left and right images tends to the set target value, thus ensuring the consistency of the two images.

[0048] S10 Depth Detection Output: After the brightness stabilizes, the disparity map is calculated using the stereoSGBM algorithm, and the depth of the workpiece is detected using the depth matrix Z(u,v). This algorithm significantly improves the accuracy of depth detection by minimizing the energy function while taking into account the matching cost and spatial continuity.

[0049] Example 2, refer to Figures 1-5 Based on Example 1, the smoothness coefficient α ranges from 0.1 to 0.5. This range can effectively balance the brightness response speed and stability. The choice of α value directly affects the sensitivity and smoothness of brightness adjustment. 0.3 is the optimal value, which not only ensures timely response to changes in illumination, but also effectively filters brightness jitter caused by instantaneous fluctuations, keeping the brightness signal stable and providing a reliable basis for subsequent error calculation and parameter adjustment.

[0050] Workpiece 6 undergoes binocular calibration and stereo correction to obtain relevant calibration parameters. The distance Z is determined using a binocular stereo matching algorithm, with the following formula: Where f is the camera focal length, B is the binocular baseline length (these two parameters need to be determined after calibrating the camera's intrinsic and extrinsic parameters using MATLAB software), D is the disparity value of the same pixel in the field of view of the left and right cameras (in pixels), and Z is the distance between the camera and a single pixel on the surface of workpiece 6. A depth map is generated through stereo matching. The depth map is used to calculate the distance from each pixel on the workpiece surface to the camera. This calculation method needs to be based on the calibrated intrinsic parameter matrix, distortion coefficients, and rotation and translation matrices of the extrinsic parameters to ensure accurate and reliable ranging results. The depth values ​​of all pixels on the surface of workpiece 6 are summarized to obtain the depth matrix. .

[0051] Exposure time range [E min E max The gain range is 500μs to 20000μs, and the gain range is [G]. min G maxThe frame rate is 0 to 12 dB, and the fixed frame rate f is 30 FPS. These specific parameters were determined through rigorous laboratory testing. The parameter limiting design can effectively ensure frame rate stability, avoid stuttering and frame skipping during automatic exposure and gain adjustment, ensure the continuity of image acquisition sequence, and provide high-quality raw data for subsequent stereo matching and depth detection. Even when the ambient brightness changes significantly, the system can maintain stable operation.

[0052] The core of the stereoSGBM algorithm is to minimize the energy function E(D), which is defined as follows: Where p and q are pixels in the image, and D p Let C(p,D) be the disparity value of pixel P. p N is the matching cost, used to measure the brightness difference of corresponding points in the left and right images. p The disparity map is the set of neighboring pixels of pixel P. P1 is the small disparity penalty term, which is the penalty when the disparity of adjacent pixels differs by 1. P2 is the large disparity penalty term, which is the penalty when the disparity of adjacent pixels differs by more than 1. This design ensures that the disparity map can maintain low matching cost and spatial continuity, thereby improving the accuracy of disparity calculation.

[0053] The system periodically calculates the smoothed left and right brightness difference. Periodic detection can promptly identify binocular brightness deviations, and automatic balance compensation is performed when ΔL > ε, where the threshold... The value of ε is determined based on the target brightness difference to ensure that the compensation standard meets the actual needs. The exposure and gain of the binocular camera 4 are adjusted by linking the industrial control computer 3 with the PC 5. The industrial control computer acts as a communication hub to transmit control commands through the network cable, while the PC accurately calculates the adjustment amount through the developed program, so that the brightness difference of the binocular cameras is kept within a reasonable range, avoiding the impact of brightness imbalance on the stereo matching effect.

[0054] The target brightness value is adaptively adjusted according to the position of workpiece 6. When the depth of workpiece 6 is constant, the target brightness value remains constant. The system automatically adjusts the camera's exposure and gain by detecting changes in ambient light in real time, ensuring that the brightness of the camera's field of view always matches the initially set target brightness. When the depth of workpiece 6 changes, the brightness compensation algorithm based on distance measurement is applied. The target brightness value is dynamically corrected. When the camera moves away from the workpiece 6, the target brightness value is increased to offset the darkening effect caused by the light flux attenuation. When the camera moves closer to the workpiece 6, the target brightness value is decreased to avoid overexposure, so that the brightness of the workpiece 6 is consistent with the initial calibration state.

[0055] The parameters are set to EMA parameter α = 0.3, and PI control parameter K. p =0.02, K i =0.001, Distance compensation coefficient K Z=0.15. These parameters have been verified as the optimal combination through multiple laboratory tests. Under complex conditions such as ambient brightness variation of ±30% and workpiece distance variation of ±50mm, the brightness fluctuation can be controlled within ±5%, and the depth detection error is less than 0.3mm. This meets the stringent requirements of industrial inspection for accuracy and stability. At the same time, these parameters have good versatility and are suitable for various types of industrial cameras and different inspection scenarios.

[0056] The Visual Studio software is installed on PC 5. The control program is developed using C# and OpenCV. The program includes core modules such as image acquisition, PI adaptive control, and binocular ranging brightness compensation. The image acquisition module is responsible for acquiring image data from the binocular camera in real time. The PI adaptive control module realizes dynamic adjustment of exposure and gain. The binocular ranging brightness compensation module corrects the target brightness according to the distance change. All modules work together to complete the entire adaptive parameter tuning process.

[0057] Working Principle: The stage at the bottom of the industrial camera bracket 1 is used to place the workpiece 6 to be inspected. The high-power surface light source 2 is installed on the top of the industrial camera bracket 1 to provide stable illumination for imaging. The binocular camera 4 consists of two industrial cameras, one on the left and one on the right, each equipped with an industrial lens and fixed on both sides of the top of the industrial camera bracket 1. The industrial control computer 3 establishes stable communication with the PC 5 and the binocular camera 4 via a network cable. The power supply continuously provides power to the binocular camera 4, the high-power surface light source 2, the industrial control computer 3, and the PC 5 to ensure system operation. After startup, the PC 5 first completes system initialization, sets the fixed frame rate of the left and right binocular cameras 4 to 30 FPS, presets the exposure time range to 500 μs to 20000 μs, and the gain range to 0 to 12 dB. At the same time, it reads the calibration parameters of the binocular camera 4 and starts the image acquisition thread. According to the reflection characteristics of the workpiece 6 to be inspected, the control program of the PC 5 manually sets the target brightness value L in the field of view of the left and right binocular cameras 4. tL and L tR The brightness value is limited to the range of 0 to 255. The binocular camera 4 collects the amount of light received through its internal sensor, captures an image of the workpiece 6 to be inspected, calculates the sum of all pixel grayscale values ​​and divides it by the total number of pixels to obtain the current brightness values ​​L for both the left and right channels. curL and L curR To balance brightness response speed and stability, the system uses the EMA algorithm to smooth the current brightness value, with a smoothing coefficient α set to 0.3. The smoothed value is then L. ema (t). Then, the relative error e(t), which is the difference between the target brightness value and the smoothed brightness value, is calculated to provide feedback on whether the current brightness is too bright or too dark relative to the target brightness. Based on this error, the system dynamically adjusts the exposure time using a PI control algorithm, with a proportional gain K... p The integral gain K is 0.02. iWith a value of 0.001, the clipping function Clamp strictly controls the exposure value within a preset range, following the adjustment strategy of "prioritizing exposure to increase brightness and prioritizing gain to decrease brightness." When the exposure time reaches the preset upper limit, gain adjustment is triggered, with the gain adjustment coefficient K... g The value ranges from 0.01 to 0.1. Simultaneously, the system periodically calculates the smoothed left-right brightness difference ΔL. When ΔL exceeds the threshold ε, the industrial control computer 3, in conjunction with the PC 5, adjusts the exposure and gain of the binocular camera 4 to achieve brightness balance compensation.

[0058] When the height of the workpiece 6 to be inspected changes within the range of -50mm to 50mm from the binocular camera 4, the system obtains the real-time distance Z through a binocular stereo matching algorithm. This algorithm calculates Z using the camera focal length f, the binocular baseline length B, and the parallax values ​​D(u,v) of the left and right cameras, combined with the distance compensation coefficient K. Z =0.15, the system corrects the target brightness value according to the formula, where Z0 is the reference distance, to ensure that the brightness of the workpiece 6 to be inspected is consistent with the initial calibration state. The left and right binocular cameras 4 respectively adjust the target brightness value L according to their respective target brightness values ​​L. tL and L tR The system independently executes processes such as brightness acquisition, smoothing, error calculation, exposure and gain adjustment, and distance compensation, ensuring that the brightness of the surface of the workpiece 6 under inspection in both left and right images approaches the set target value. When the ambient brightness changes by ±30% and the distance to the workpiece 6 changes by ±50mm, the system can control brightness fluctuations within ±5%. After brightness stabilization, the system uses the stereoSGBM algorithm to calculate the disparity map. The core of this algorithm is to minimize the energy function E(D). By comprehensively calculating the pixel matching cost and the neighborhood disparity penalty term, the accuracy of the disparity solution is ensured, where P1 is the small disparity penalty term and P2 is the large disparity penalty term. Finally, the depth detection of the workpiece 6 is achieved through the depth matrix Z(u,v), with a detection error of less than 0.3mm. The Visual Studio software installed on PC 5 integrates core modules such as image acquisition, PI adaptive control, and binocular ranging brightness compensation through a control program developed using C# and OpenCV, providing software support for the entire workflow.

[0059] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for adjusting a binocular camera adaptive parameter adjusting device, characterized in that, The binocular camera adaptive parameter adjusting device comprises an industrial camera support (1), a binocular camera (4), a high-power area light source (2), an industrial computer (3), a PC (5) and a power supply; a workpiece (6) to be detected is arranged on a worktable at the bottom of the industrial camera support (1), the high-power area light source (2) is arranged at the top of the industrial camera support (1), the binocular camera (4) is composed of two industrial cameras arranged in parallel and is equipped with industrial lenses, the binocular camera (4) is fixed to the two sides of the top of the industrial camera support (1), the industrial computer (3) is connected with the PC (5) and the binocular camera (4) through a network cable to establish a communication connection, and the power supply supplies power to the binocular camera (4), the high-power area light source (2), the industrial computer (3) and the PC (5). The adjusting method comprises the following steps: S1 system initialization: set the fixed frame rate f of the left and right binocular cameras (4) through the PC (5), preset the exposure time range [E min ,E max ] and the gain range [G min ,G max ], read the calibration parameters of the binocular camera (4) and start the image acquisition thread; S2 Target brightness setting: According to the reflection characteristics of the workpiece (6), manually set the target brightness value L of the field of view of the left and right binocular cameras (4) through the control program of the PC (5) tL , L tR , the brightness value range is [0, 255]; S3 calculates the current brightness value: the amount of light collected by the internal sensor of the binocular camera (4), the image of the workpiece (6) taken by the left and right binocular cameras (4), and the average brightness of each frame of image is calculated according to the formula I i is the gray value of the i-th pixel, and N is the total number of pixels, respectively, to obtain the left and right current brightness values L curL , curR ; S4: Smooth the brightness fluctuation: the EMA algorithm is used to smooth the current brightness value obtained in step S3, and the algorithm formula is: L ema (t) = a * L cur (t) + (1-a) * L ema (t-1), where L ema (t) is the smoothed brightness value at time t, the value range is [0, 255]; a is the smoothing coefficient, the value range is 0 < a ≤ 1; L cur (t) is the original observed brightness at time t; L ema (t-1) is the previous frame EMA output. S5 calculates the relative error: according to the formula The relative error is calculated, wherein, L target (t) is the target brightness value, e(t) is the current brightness error, used to feedback the light or dark state of the current brightness relative to the target brightness; S6 dynamically adjust exposure time: with brightness error as feedback, based on PI algorithm dynamic calculation control quantity, according to "light priority exposure, light priority gain" strategy adjustment, exposure adjustment algorithm is: Wherein, E (t+1) is the next frame exposure value, E (t) is the current exposure value, Clamp (x, E min , E max ) is the limiting function, K p The value range is [0.01, 0.5], K i The value range is [0.001, 0.05]. S7 Dynamic adjustment of gain: trigger gain adjustment when the exposure time reaches the preset upper limit, the adjustment algorithm is: Wherein, G(t+1) is the next frame gain value, G(t) is the current gain value, K g is the gain adjustment coefficient, the value range is [0.01, 0.1]. S8 Distance compensation correction target brightness: when the workpiece (6) distance binocular camera (4) occurs [-50mm, 50mm] range of height change, through binocular stereo ranging to obtain real-time distance Z, according to the formula Correction target brightness, wherein, L c L is the target brightness value after compensation, L t L is the initial target brightness value, K Z Z0 is the reference distance, The relative distance deviation; S9 Binocular independent adjustment: left and right binocular cameras (4) respectively according to target brightness value L tL 、 tR Steps S3-S8 are independently executed, so that the brightness of the workpiece (6) surface in the left and right images tends to the set target value; S10 depth detection output: after the brightness is stabilized, a disparity map is calculated by using a stereo SGBM algorithm, and the depth detection of the workpiece (6) is realized through a depth matrix Z(u, v).

2. The adjusting method of the binocular camera adaptive parameter adjusting device according to claim 1, characterized in that: The value range of the smoothing coefficient a is 0.1-0.5, and the value is used to balance the brightness response speed and stability.

3. The adjusting method of the binocular camera adaptive parameter adjusting device according to claim 1, characterized in that: The workpiece (6) obtains relevant calibration parameters through double target calibration and three-dimensional correction in sequence, and a binocular stereo matching algorithm is used to determine the distance Z, and the formula is: Wherein f is the focal length of the camera, B is the binocular baseline length, D is the parallax value of the same pixel point in the field of view of the left and right cameras, the unit is pixel, and Z is the distance between the camera and the surface of the workpiece (6). A depth map is generated by stereo matching, and the depth map is used to calculate the distance from each pixel point on the surface of the workpiece to the camera. The depth values of all pixel points on the surface of the workpiece (6) are collected to obtain a depth matrix: .

4. The adjusting method of the binocular camera adaptive parameter adjusting device according to claim 1, characterized in that: The exposure time range [E min ,E max ] is [500 μs, 20000 μs], the gain range [G min ,G max ] is [0, 12 dB], and the fixed frame rate f is 30 FPS, and the frame rate is guaranteed to be stable by parameter limiting.

5. The adjusting method of the binocular camera adaptive parameter adjusting device according to claim 1, characterized in that: The core of the stereoSGBM algorithm is to minimize an energy function E(D), which is defined as: where p, q are image pixels, D p is the disparity value of pixel P, C(p, D p ) is the matching cost, N p is the set of neighboring pixels of pixel P, P1 is a small disparity penalty term, and P2 is a large disparity penalty term.

6. The adjusting method of the binocular camera adaptive parameter adjusting device according to claim 1, characterized in that: The system periodically calculates a smoothed left-right luminance difference Automatic balance compensation is performed when ΔL > ε, where the threshold The exposure and gain of the binocular camera (4) are adjusted by the industrial computer (3) in linkage with the PC (5).

7. The adjusting method of the binocular camera adaptive parameter adjusting device according to claim 1, characterized in that: The target brightness value is self-adaptively adjusted according to the position state of the workpiece (6): when the depth of the workpiece (6) is constant, the target brightness value is maintained constant, and the exposure and gain are adjusted to adapt to the change of ambient light; when the depth of the workpiece (6) changes, the ranging brightness compensation algorithm is used The target brightness value is dynamically corrected, so that the brightness of the workpiece (6) is consistent with the initial calibration state.

8. The adjusting method of the binocular camera adaptive parameter adjusting device according to claims 1-7, characterized in that: The parameter settings are: EMA parameter a = 0.3, PI control parameter K p = 0.02, K i = 0.001, distance compensation coefficient K Z = 0.15, under the conditions of environment brightness variation ± 30%, workpiece (6) distance variation ± 50 mm, the brightness fluctuation is controlled within ± 5%, and the depth detection error is less than 0.3 mm.

9. The adjusting method of the binocular camera adaptive parameter adjusting device according to claim 1, characterized in that: Visual Studio software is installed in the PC (5), a control program is developed by using C# and OpenCV, and the control program comprises an image acquisition module, a PI adaptive control module and a binocular distance measuring brightness compensation module.