Camera exposure automatic adjustment method based on image brightness statistical information
By acquiring image brightness statistics in real time and dynamically adjusting exposure parameters, the problem of poor exposure effects caused by local uneven lighting in the prior art is solved, and precise exposure control is achieved under complex lighting conditions.
Patent Information
- Application Number
- CN202510604750.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-07-11
AI Technical Summary
The existing automatic exposure algorithm mainly relies on the global brightness information of the image, and it is difficult to cope with complex environments with uneven local lighting, resulting in poor exposure effects.
Acquire the brightness statistics of the image in real time, including the average brightness and standard deviation, calculate the brightness error, and dynamically adjust the exposure time and gain to achieve fine exposure control.
It can achieve accurate exposure adjustments under complex lighting conditions, avoid overexposed or underexposed, and maintain image quality.
Smart Images

Figure CN120302161A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of computer vision, image processing, and intelligent hardware, and particularly relates to an automatic camera exposure adjustment method based on image brightness statistical information with high adaptability and adjustment accuracy. Background Art
[0002] Existing automatic exposure technologies mainly rely on the global brightness information of images. Usually, they automatically adjust the exposure settings of cameras by calculating the brightness mean or histogram of images to ensure that the image brightness is within an ideal range. However, most of these methods only consider the changes in overall illumination and ignore the changes in local illumination in the environment, resulting in less-than-satisfactory performance of automatic exposure algorithms in complex or uneven illumination environments. The automatic exposure algorithm (AE) in the prior art is currently the most common exposure adjustment method in camera systems. It dynamically adjusts exposure parameters such as exposure time, aperture size, and ISO by analyzing the brightness information of images in real time. The AE algorithm is usually based on the mean or histogram distribution of image brightness and adjusts by analyzing the global brightness of the image to ensure reasonable overall exposure of the image. However, the AE algorithm mainly relies on global brightness information and is difficult to handle complex environments with uneven local illumination. For example, in backlight or high-contrast scenes, the AE algorithm may not be able to effectively process the details of dark and bright parts, thus affecting the exposure effect. Summary of the Invention
[0003] Object of the Invention: The object of the present invention is to provide an automatic camera exposure adjustment method based on image brightness statistical information with high adaptability and adjustment accuracy.
[0004] Technical Solution: The automatic camera exposure adjustment method based on image brightness statistical information according to the present invention includes the following steps:
[0005] (1) Initialize the camera settings;
[0006] (2) Capture images in real time and obtain brightness statistical information;
[0007] (3) Calculate the brightness error and adjust the exposure parameters;
[0008] (4) Reshoot the image according to the adjustment result.
[0009] Further, the basic parameters for initializing the camera in step (1) include setting its pixel format to RGB565, frame size to QQVGA, and turning off automatic white balance and automatic exposure.
[0010] Further, the step (1) includes: turning on the camera module, initializing the image sensor, setting the pixel format and frame size of the camera; turning off the auto white balance and auto exposure functions, setting the exposure window, and adjusting the window range to the target area; starting the camera and allowing it to work stably, and preparing to collect image data.
[0011] Further, in the step (2), the method sensor.snapshot() is called to capture images in real time, and the brightness statistical data of the images is obtained through img.get_statistics(). The method stats.1mean() is used to extract the average brightness value of the images, which serves as the basis for subsequent exposure adjustment.
[0012] Further, the step (2) includes capturing images in real time, obtaining the brightness statistical information of the captured images, and extracting the average brightness value of the images by using the method stats.1mean().
[0013] Further, the obtaining of the brightness statistical information of the images includes the average brightness and the standard deviation.
[0014] Further, the brightness error calculation formula in the step (3) is: error = current_brightness - target_brightness, and the exposure time is dynamically adjusted according to the error.
[0015] Further, in the step (3), if the error is large, the exposure time is dynamically calculated, and the exposure time is adjusted by using the formula new_exposure_time = max_exposure_time - (error * exposure_factor). The adjustment of the exposure time is dynamically calculated based on the magnitude of the brightness error to set the exposure time of the camera; ensure that the exposure time does not exceed the maximum value max_exposure_time and will not be lower than the minimum value min_exposure_time;
[0016] The new exposure time is set through sensor.set_auto_exposure(False, exposure_us = new_exposure_time), and the gain is adjusted through sensor.set_auto_gain(False, gain_db = target_gain).
[0017] Further, in step (3), calculate the brightness error of the current image. If the current brightness error is higher than a preset threshold, reduce the exposure time of the camera to prevent overexposure; set the gain to a lower value to avoid excessive brightness. If the current brightness is lower than the target brightness and the brightness error is higher than the preset threshold, then enable automatic exposure and gain adjustment to allow the camera to adjust according to the ambient light.
[0018] Further, step (4) includes using the adjusted exposure and gain parameters to reshoot the image; obtaining the brightness statistical information of the image again to check whether the brightness and brightness error of the adjusted image meet the target values; if the brightness of the image does not reach the target value, repeat the exposure adjustment in step (3) to further optimize the parameters.
[0019] Beneficial effects: Compared with the prior art, the present invention has the following remarkable advantages: By obtaining the brightness statistical information of the image in real time, the present invention can not only adjust the exposure parameters according to the overall brightness of the image, but also make fine adjustments according to the brightness changes in the local area of the image; this dynamic adjustment method based on brightness statistics enables the system to more accurately cope with complex lighting conditions and avoids the limitations of traditional automatic exposure algorithms in the face of uneven local lighting. In addition, the present invention combines manual and automatic exposure adjustments, which is more flexible and can be optimized in real time according to the actual lighting conditions, thereby providing more accurate exposure control. Description of the Drawings
[0020] Figure 1 is a flow chart of the present invention;
[0021] Figure 2 is the brightness effect diagram exported for operation. Detailed Embodiments
[0022] The technical solutions of the present invention will be further described below with reference to the drawings.
[0023] As Figure 1 shown, the automatic exposure adjustment method of the camera based on image brightness statistical information according to the present invention includes the following steps:
[0024] Step 1: Initialize the camera settings
[0025] Purpose: Initialize the basic parameters of the camera (taking OPEMMV as an example), set its pixel format to RGB565, the frame size to QQVGA (160x120), and turn off the automatic white balance and automatic exposure. To ensure that stable image information can be captured.
[0026] Required conditions: The camera model supports manual control of exposure, gain and other parameters. Ensure that the camera can perform real-time image acquisition. The camera is correctly connected to the computing device.
[0027] Specific operations: Turn on the camera module and initialize the image sensor. Set the pixel format and frame size of the camera for real-time processing. Turn off the auto white balance and auto exposure functions to ensure that subsequent exposure adjustments are based on program settings. Set the exposure window and adjust the window range to the target area (e.g., (10, 0, 126, 120)). Start the camera and let it work stably to prepare for collecting image data.
[0028] Step 2: Capture images in real-time and obtain brightness statistics: Capture images in real-time by calling the sensor.snapshot() method, and obtain the brightness statistics data of the images through img.get_statistics(). Use the stats.1_mean() method to extract the average brightness value of the images as the basis for subsequent exposure adjustments.
[0029] Purpose: Obtain the image brightness information of the current scene in real-time to provide data support for subsequent exposure adjustments.
[0030] Required conditions: The environmental lighting conditions should be stable, avoiding areas with rapidly changing strong light or shadows. The camera can stably collect image data.
[0031] Specific operations: Capture images in real-time. Obtain the brightness statistics information of the captured images (such as average brightness, standard deviation, etc.). Extract the average brightness value of the images through the stats.1mean() method, and this data will be used for subsequent exposure adjustments.
[0032] Step 3: Calculate the brightness error and adjust the exposure parameters
[0033] Purpose: Compare the obtained brightness statistics information with the target brightness and dynamically adjust the exposure parameters (exposure time, gain, etc.).
[0034] Required conditions: Determine the target brightness value and set a reasonable target brightness according to different scene requirements. The brightness statistics data of the images has been obtained, and the current brightness value can be stably calculated.
[0035] Specific operations: Calculate the brightness error: error = current_brightness - target_brightness, and dynamically adjust the exposure time according to the error.
[0036] If the error is large (e.g., error > 0), then dynamically calculate the exposure time and use the formula new_exposure_time = max_exposure_time - (error * exposure_factor) to adjust the exposure time. The adjustment of the exposure time is dynamically calculated based on the magnitude of the brightness error to set the exposure time of the camera.
[0037] Ensure that the exposure time does not exceed the maximum value max_exposure_time and does not fall below the minimum value min_exposure_time.
[0038] Set the new exposure time by sensor.set_auto_exposure(False, exposureus = new_exposure_time), and adjust the gain by sensor.set_auto_gain(False, gain_db = target_gain).
[0039] Calculate the brightness error of the current image. If the current brightness error is higher than the pre-set threshold, then: Decrease the exposure time of the camera to prevent overexposure. Set the gain to a lower value to avoid excessive brightness.
[0040] If the current brightness is lower than the target brightness and the brightness error is higher than the pre-set threshold, then: Enable automatic exposure and gain adjustment to allow the camera to adjust according to the ambient light.
[0041] Step 4: Retake the image according to the adjustment result
[0042] Purpose: After adjusting the exposure and gain parameters, retake the image to ensure that the exposure effect meets the expectations.
[0043] Required conditions: The exposure and gain adjustments have been completed and the new exposure settings have taken effect. The camera is capable of stably capturing images again.
[0044] Specific operation: Use the adjusted exposure and gain parameters to retake the image. Obtain the brightness statistics of the image again, and check whether the brightness of the adjusted image and the brightness error meet the target values. If the brightness of the image does not reach the target value, repeat the exposure adjustment in Step 3 to further optimize the parameters.
[0045] Application conditions and precautions of the method
[0046] Ambient light conditions: This method is applicable to scenarios with large changes in ambient light. Especially in outdoor lighting conditions or when shooting at night, it can provide better exposure adjustment effects.
[0047] Device requirements: The system should have sufficient computing power to obtain images in real time and perform brightness statistical analysis, especially in the case of high-resolution images or dynamic scenes.
[0048] Example:
[0049] This embodiment demonstrates a dynamic exposure adjustment method based on image brightness statistical information, which is applied to an embedded camera system to optimize image quality under different lighting conditions. This method obtains the brightness statistical information of the image in real time, calculates the error between the current image brightness and the target brightness, and dynamically adjusts the exposure time and gain parameters based on the error to avoid overexposure and underexposure. The specific steps include: First, initialize the camera settings, set the pixel format and frame size of the camera, and turn off the automatic white balance and automatic exposure to ensure that the exposure adjustment is based on the set values. Then, capture the image in real time and obtain the brightness statistical information, and obtain the mean value of the image brightness as the basis for exposure adjustment. Next, calculate the brightness error (i.e., the difference between the current brightness and the target brightness), and dynamically adjust the exposure time according to the error: If the brightness is too high, adjust it by dynamically calculating the exposure time. To avoid the exposure time being too short or too long and ensure that the exposure time is within a certain range, set the new exposure time and reduce the gain to avoid excessive brightening. When the brightness of the adjusted image does not reach the target value, the system will continue to adjust the exposure time and gain until the image brightness approaches the target value. Through experimental verification, this method can successfully adjust the image brightness to the target value in different scenarios such as normal lighting, backlighting, and low light, and the image details are effectively retained. Under backlighting and low light conditions, the system effectively avoids overexposure or brightening noise by dynamically adjusting the exposure time, ensuring the image quality. The experimental results show that the adjusted exposure parameters keep the image brightness error within ±10, fully meeting the target brightness requirements. This method can adjust the exposure in real time according to environmental changes, has strong adaptability and flexibility, especially in scenarios with complex or rapidly changing lighting conditions, and can maintain high image quality.
[0050] The following Table 1 shows the image brightness information exported when the camera works using this method (the target brightness is 60, and the maximum allowable error is 20). The numbers on the graph are the current brightness values:
[0051] Table 1: Image Brightness Information
[0052] Low brightness operation High brightness operation Normal operation 51 59 62 52 62 64 44 83 63 32 95 63 22 81 61 39 34 63 52 60 66 60 61 60
[0053] As Figure 2 shown, according to the exported brightness statistical information during operation, it can be seen that when the camera enters the set low brightness range from the normal brightness range: the brightness starts to be lower than 40, Figure 2 (a) The brightness is 32, and the camera can quickly adjust back to the normal brightness working range, as Figure 2 (b), and the adjusted brightness is 52. When the camera enters the set high brightness range from the normal brightness range, the brightness starts to be higher than 80, Figure 2 (c) The brightness is 95, and the camera can quickly adjust back to the normal brightness working range, as Figure 2(d), the adjusted brightness is 81.
Claims
1. An automatic camera exposure adjustment method based on image brightness statistical information, characterized in that, It includes the following steps: (1) Initialize the camera settings; (2) Capture images in real time and obtain brightness statistical information; (3) Calculate the brightness error and adjust the exposure parameters; (4) Reshoot the image according to the adjusted exposure and gain parameters to optimize the parameters.
2. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 1, characterized in that, The basic parameters for initializing the camera in step (1) include setting its pixel format to RGB565, the frame size to QQVGA, and turning off the automatic white balance and automatic exposure.
3. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 1, characterized in that, (1) includes: turning on the camera module, initializing the image sensor, setting the pixel format and frame size of the camera; turning off the automatic white balance and automatic exposure functions, setting the exposure window, and adjusting the window range to the target area; starting the camera and allowing it to work stably to prepare for collecting image data.
4. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 1, characterized in that, (2) captures images in real time by calling the sensor.snapshot() method, obtains the brightness statistical data of the image through img.get_statistics(), and uses the stats.l_mean() method to extract the average brightness value of the image as the basis for subsequent exposure adjustment.
5. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 1, characterized in that (2) includes capturing images in real time, obtaining the brightness statistical information of the captured images, and extracting the average brightness value of the images by using the stats.l_mean() method.
6. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 5, characterized in that, The obtained brightness statistical information of the image includes the average brightness and the standard deviation.
7. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 1, characterized in that, (3) The brightness error calculation formula: error = current_brightness - target_brightness, and the exposure time is dynamically adjusted according to the error.
8. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 1, characterized in that, (3) If the error is large, the exposure time is dynamically calculated, and the exposure time is adjusted using the formula new_exposure_time = max_exposure_time - (error * exposure_factor). The adjustment of the exposure time is dynamically calculated based on the magnitude of the brightness error to set the exposure time of the camera; ensure that the exposure time does not exceed the maximum value max_exposure_time and will not be lower than the minimum value min_exposure_time; Set the new exposure time through sensor.set_auto_exposure(False, exposure_us = new_exposure_time), and adjust the gain through sensor.set_auto_gain(False, gain_db = target_gain).
9. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 1, characterized in that, (3) calculates the brightness error of the current image. If the current brightness error is higher than the preset threshold, the exposure time of the camera is reduced to prevent overexposure; Set the gain to a lower value to avoid too high brightness; if the current brightness is lower than the target brightness and the brightness error is higher than the preset threshold, then: enable automatic exposure and gain adjustment to allow the camera to adjust according to the ambient light.
10. The automatic camera exposure adjustment method based on image brightness statistical information according to claim 1, characterized in that, Step (4) includes re - shooting the image using the adjusted exposure and gain parameters; obtaining the brightness statistical information of the image again, and checking whether the brightness of the adjusted image and the brightness error meet the target values; If the brightness of the image does not reach the target value, repeat the exposure adjustment in step (3) to further optimize the parameters.