A face exposure adjustment method
By acquiring face region coordinates, cropping, and brightness histogram analysis, and combining this with dynamic calculation of face target brightness using an EV table, the problems of uneven face brightness and unstable brightness during movement are solved. This enables appropriate adjustment of face brightness in various scenarios, improving the shooting experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEFEI JUNZHENG TECH CO LTD
- Filing Date
- 2024-12-20
- Publication Date
- 2026-06-23
AI Technical Summary
Existing automatic exposure technology cannot guarantee proper brightness of faces when shooting images containing faces, especially in backlit and frontlit scenes where the brightness of faces is uneven and unstable when the face moves, resulting in a poor shooting experience.
By obtaining the coordinates of the face region, filtering and cropping are performed. Combined with the brightness histogram and EV table, the brightness of the target face is dynamically calculated, and the face exposure is adjusted to prevent face shaking. Fine-tuning is also performed based on the overall image brightness.
It ensures appropriate facial brightness in various scenarios, improves the shooting experience, is highly adaptable, and avoids problems such as overexposure or underexposure of faces.
Smart Images

Figure CN122269142A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and specifically relates to a method for adjusting facial exposure. Background Technology
[0002] Currently, when taking photos, recording videos, or making video calls using devices such as laptops, USB cameras, and facial recognition door locks, the exposure often takes into account overall brightness if a face is present in the frame. This can lead to inappropriate face brightness, such as overexposing the face in front of the camera or underexposing it in backlight. If only the face's brightness is considered, the background may be overexposed in backlight or very dark in front of the camera. Furthermore, when considering the brightness of the face area during exposure, inaccurate face detection and significant brightness variations can occur when the face is moving or unstable, resulting in a poor user experience.
[0003] Existing automatic exposure technology determines whether the image exposure is appropriate based on the overall brightness and EV of the image, and then adjusts the exposure level accordingly.
[0004] However, the shortcomings of existing technologies are:
[0005] (1) Automatic image exposure is based on the entire image. If there is a face in the image, it cannot be guaranteed that the brightness of the face is appropriate. In scenes where the face is important, the face will be overexposed in front lighting scenes and underexposed in back lighting scenes.
[0006] (2) When the exposure is targeted at a face, the brightness of the image changes significantly or sluggishly when the face moves or the scene changes significantly, resulting in a poor visual experience.
[0007] (3) Poor adaptability, not applicable to all scenarios. It is not easy to balance the brightness of the face and the brightness of the background. The face brightness may be appropriate, but the background may be overexposed or too dark.
[0008] In addition, the terminology commonly used in this technology includes:
[0009] (1)AE: Automatic exposure.
[0010] (2) EV: Exposure Value
[0011] (3) USB: Universal Serial Bus
[0012] (4) Brightness Histogram: This is a statistical reporting graph that uses a series of vertical bars or lines of varying heights to represent the distribution of data. The horizontal axis represents the brightness value, and the vertical axis represents the number of pixels at that brightness level.
[0013] (5) Overexposure: Overexposure will result in excessive brightness in the image, making the photo appear washed out. Summary of the Invention
[0014] In order to solve the above problems, the purpose of this application is:
[0015] (1) When adjusting the automatic exposure, the brightness of the face will be taken into account. If there is a face in the picture, the brightness of the face will be used as one of the standards to measure whether the brightness of the image is appropriate. Adjusting the exposure in this way can make the brightness of the face in the image more appropriate.
[0016] (2) When the face moves, anti-shake tracking and other processing are performed on the face area so that the brightness of the image can remain stable when the scene changes drastically.
[0017] (3) Using face brightness in conjunction with EV table and interpolation to calculate target brightness, it has better compatibility and adjustability, making face brightness suitable in various scenarios.
[0018] Specifically, the present invention provides a method for adjusting facial exposure, the method comprising the following steps:
[0019] S1, obtain the coordinates of the face region;
[0020] S2, Face coordinate processing: includes:
[0021] Remove faces: Select the main faces as those that need to be exposed;
[0022] Adjust face size: Crop the area where the face is exposed to ensure that the entire exposed area is the face and there is no background;
[0023] Face stabilization: Prevents inaccurate exposure caused by facial shaking;
[0024] S3, calculates the brightness of the face area and the image:
[0025] Based on the brightness histograms of the face region and the entire image, respectively, the brightness of the face and the entire image is calculated by determining the proportions of bright, dark, and normal brightness points in the brightness histograms.
[0026] Overall screen brightness:
[0027] n: The number of pixels with brightness i, this data is in the histogram;
[0028] w: Image width, in pixels;
[0029] h: Image height, in pixels;
[0030] Face brightness:
[0031] luma=(sum_dark+sum_mid+sum_sat) / (face_w*face_h)
[0032] sum_dark: The sum of the brightness of the darker pixels in the face area;
[0033] sum_mid: The sum of the pixel brightness in the face area where the brightness is normal;
[0034] sum_sat: The sum of the brightness of the brightest pixels in the face area;
[0035] face_w: Face width, in pixels;
[0036] face_h: Face height, in pixels;
[0037] S4, Obtain the base brightness: Obtain the base target brightness based on the current EV and the EV table;
[0038] S5, Calculate target brightness: Based on the brightness of the entire image, obtain the final target brightness of the face;
[0039] S6, Brightness Activation: Adjusts the image brightness to an appropriate level based on the brightness of the face target.
[0040] Step S1 further includes:
[0041] For chips with computing power, facial coordinates can be obtained through their own algorithms. Here, "own algorithms" refers to facial recognition algorithms, and chips with computing power can perform facial recognition.
[0042] For laptop webcams and USB webcams, configure ROI support in the UVC descriptor. When a Windows camera receives an image, it will perform face recognition and send the face coordinates to the device via USB.
[0043] Step S2 further includes:
[0044] S2.1 After obtaining the coordinates, the face coordinates are first filtered. If the face width and height are too small, it is considered that the face is too far from the camera. In this case, adjusting the face exposure will easily have a significant impact on the overall image, so such faces are filtered out. The filtering includes:
[0045] The minimum width w = 35 * image_width / 640, and the width must be greater than 20;
[0046] The minimum height h = 40 * image_height / 640, and the height must be greater than 25;
[0047] S2.2, Adjust face size: Because the face is not a standard rectangle, the background of the face needs to be removed and the area where the face is exposed needs to be cropped, that is, the image around the face is cropped: crop 1 / 4 of the top, bottom, left and right sides of the face to ensure that the entire area exposed by the face is the face and there is no background.
[0048] S2.3, Face Coordinate Stabilization: When a face appears, it is not immediately exposed as a face. The system needs to determine if the face is stable before starting the exposure. This prevents the face coordinates from being out of sync with the actual scene when the face is moving, resulting in the exposure position not being the face. The following conditions indicate that the face is not stable:
[0049] Condition 1: The face moves more than 1 / 3 of its size within 1 second;
[0050] Condition 2: The face size changes by more than 1 / 2 within 1 second.
[0051] Step S2 also includes step S2.4, face selection in multi-face scenes: if multiple faces appear in the image, the face with the largest area is selected as the face to be exposed.
[0052] Step S4 further includes: calculating the brightness of the exposure target.
[0053] S4.1 Obtain the current EV value: EV = exp * again * dgain. S4.2 Pre-set an EV table and a target brightness table; the pre-set EV table and target brightness table are empirical tables and can be adjusted according to needs. The basic rule is that the higher the EV value, the lower the target brightness. S4.3 Calculate the target face brightness value based on the EV value through interpolation.
[0054] Assuming ev is 200000:
[0055] target=(280000-154500) / (200000-154500)*(50-45);
[0056] S4.4, then obtain the current backlighting level through the brightness histogram and adjust the brightness target of the face; S4.5, backlighting judgment, if the brightness of the face is much lower than the brightness of the whole image, it is judged as backlighting, and backlighting uses another set of EV tables; there are two sets of EV tables, one set for normal lighting conditions and the other set for backlighting conditions. The target brightness is lower in backlighting conditions to prevent severe overexposure of the image.
[0057] In step S4.2, an EV table and a target brightness table are preset, as shown in the following table.
[0058] EV 3500 20000 50000 60000 89000 154500 280000 360000 640000 840000 960000 1280000 1560000 2334500 3304500 AT 55 55 55 55 50 50 45 45 45 45 40 40 40 40 40 .
[0059] The step S4.4, which involves obtaining the degree of forward and backlighting through the brightness histogram, further includes: first, calculating the histogram variance var.
[0060]
[0061] Where x is the average image brightness, and n is the image pixel format. i The brightness of each pixel;
[0062] If var > 10, proceed to the next step. Here, 10 is an empirical value, and the parameter can be adjusted according to the actual situation.
[0063] Secondly, calculate the current image mean (mean_luma) and median (mid_luma) based on the histogram.
[0064] If abs(mean_luma-mid_luma)>20, proceed to the next step.
[0065] Among them, 20 is an empirical value, and the parameter can be adjusted according to the actual situation;
[0066] Finally, pass through dark spots 30, pass through bright spots 230.
[0067] The number of pixels with a brightness greater than 230 (sat_num).
[0068] pix_num: The number of pixels in the image;
[0069] dark_num: The number of pixels with a brightness less than 30;
[0070] sat_ratio = sat_num / pix_num
[0071] dark_ratio = dark_num / pix_num
[0072] If sat_ratio*(1+dark_ratio)<0.15, it is considered dark light;
[0073] If sat_ratio + dark_ratio > 0.8, it is considered to be front lighting;
[0074] Among them, 0.15 and 0.8 are empirical values, and the parameters can be adjusted according to the actual situation.
[0075] Step S5 further includes:
[0076] The target brightness of the face is dynamically adjusted based on the overall image brightness. To prevent the overall image from being too dark or overexposed due to relying solely on the face's brightness when the image is either too bright or too dark, a protective mechanism is implemented. When the image is too bright, the target brightness of the face is appropriately reduced; similarly, when the image is too dark, the target brightness of the face is appropriately increased. This includes:
[0077] The sum of the brightness of all pixels in the face region is: luma_sum, where the brightness range of each pixel is [0, 255].
[0078] Number of pixels in the face region: luma_num;
[0079] rotio = luma_sum / luma_num;
[0080] If ratio >= 1, dynamic_target = dynamic_target + 1;
[0081] If ratio < 0.5, dynamic_target = dynamic_target - 1;
[0082] target=target+dynamic_target;
[0083] After 5 frames, perform another check. The value of dynamic_target is in the range of [-5, +5].
[0084] Step S6 further includes:
[0085] After obtaining the brightness of the target face, the brightness of the face area in subsequent exposures is compared with the target brightness. If the face brightness is higher than the target brightness, the exposure is reduced; if the face brightness is lower than the target brightness, the exposure is increased.
[0086] The method is applicable to computer cameras, USB cameras, face recognition door lock cameras, security monitoring cameras, and face recognition gate cameras, especially laptop cameras and related equipment.
[0087] Therefore, the advantage of this application is:
[0088] (1) In scenes with faces, the brightness of the faces will be a key consideration.
[0089] Existing technology: Exposure is based on the brightness of the entire image, which is not suitable for the brightness of the face in front lighting and back lighting; This application: will focus on the brightness of the face to make the brightness of the face suitable;
[0090] (2) Using the EV table and face brightness table, the target brightness is dynamically calculated.
[0091] Existing technology: Face brightness may not be suitable in different scenarios;
[0092] This application uses an EV table and a face brightness table to dynamically calculate the target brightness, so that a suitable face brightness target can be obtained in any environment.
[0093] (3) Make some minor adjustments to the brightness of the face based on the overall brightness of the image and the degree of front and backlighting. Existing technology: No relevant adjustments;
[0094] This application makes minor adjustments to the brightness of the face based on the overall brightness of the image and the degree of front and backlighting, to prevent the image from being overexposed or underexposed due to only considering the face. Attached Figure Description
[0095] The accompanying drawings, which are provided to further illustrate the invention and form part of this application, are not intended to limit the scope of the invention.
[0096] Figure 1 This is a flowchart illustrating the method. Detailed Implementation
[0097] To better understand the technical content and advantages of the present invention, the present invention will now be described in further detail with reference to the accompanying drawings.
[0098] This invention relates to a method for adjusting facial exposure, and pertains to computer webcams, USB webcams, facial recognition door lock cameras, security monitoring cameras, and facial recognition gate cameras. It particularly relates to laptop webcams and related equipment.
[0099] like Figure 1 As shown, the main steps of this method include:
[0100] S1, obtain the coordinates of the face region;
[0101] S2, Face coordinate processing: includes:
[0102] Remove faces: Select the main faces as those that need to be exposed;
[0103] Adjust face size: Crop the area where the face is exposed to ensure that the entire exposed area is the face and there is no background;
[0104] Face stabilization: Prevents inaccurate exposure caused by facial shaking;
[0105] S3, calculates the brightness of the face area and the image:
[0106] Based on the brightness histograms of the face region and the entire image, respectively, the brightness of the face and the entire image is calculated by determining the proportions of bright, dark, and normal brightness points in the brightness histograms.
[0107] Overall screen brightness:
[0108] n: The number of pixels with brightness i, this data is in the histogram;
[0109] w: Image width, in pixels;
[0110] h: Image height, in pixels;
[0111] Face brightness:
[0112] luma=(sum_dark+sum_mid+sum_sat) / (face_w*face_h)
[0113] sum_dark: The sum of the brightness of the darker pixels in the face area;
[0114] sum_mid: The sum of the pixel brightness in the face area where the brightness is normal;
[0115] sum_sat: The sum of the brightness of the brightest pixels in the face area;
[0116] face_w: Face width, in pixels;
[0117] face_h: Face height, in pixels;
[0118] S4, Obtain the base brightness: Obtain the base target brightness based on the current EV and the EV table;
[0119] S5, Calculate target brightness: Based on the brightness of the entire image, obtain the final target brightness of the face;
[0120] S6, Brightness Activation: Adjusts the image brightness to an appropriate level based on the brightness of the face target.
[0121] Specifically, the content implemented in this application includes:
[0122] S1, Obtain face region coordinates: For chips with computing power, face coordinates can be obtained through their own algorithm. Here, the algorithm refers to the face recognition algorithm. Chips with computing power can perform face recognition. The face recognition algorithm is not within the scope of this invention and will not be described further.
[0123] For laptop webcams and USB webcams, configure ROI support in the UVC descriptor. When a Windows camera receives an image, it will perform face recognition and send the face coordinates to the device via USB.
[0124] S2, Face coordinate processing:
[0125] S2.1 After obtaining the coordinates, the face coordinates are first filtered. If the face width and height are too small, it is considered that the face is too far from the camera. In this case, adjusting the face exposure will easily have a significant impact on the overall image, so it is filtered out. The filtering includes:
[0126] The minimum width w = 35 * image_width / 640, and the width must be greater than 20;
[0127] The minimum height h = 40 * image_height / 640, and the height must be greater than 25;
[0128] S2.2, Adjust face size: Because the face is not a standard rectangle, the background of the face needs to be removed and the area for face exposure needs to be cropped, that is, crop the image around the face: crop 1 / 4 of the top, bottom, left and right sides of the face to ensure that the entire area for face exposure is the face and there is no background.
[0129] S2.3, Face Coordinate Stabilization: When a face appears, it is not immediately exposed as a face. The system needs to determine if the face is stable before starting the exposure. This prevents the face coordinates from being out of sync with the actual scene when the face is moving, resulting in the exposed position not being the face. The face is considered unstable if any of the following conditions are met: 1. The face position moves more than 1 / 3 of the face size within 1 second; 2. The face size changes more than 1 / 2 within 1 second.
[0130] Condition 1: The face moves more than 1 / 3 of its size within 1 second;
[0131] Condition 2: The face size changes by more than 1 / 2 within 1 second.
[0132] S2.4, Face Filtering in Multi-Face Scenes: If multiple faces appear in the image, the face with the largest area is selected for exposure.
[0133] S3, Calculate the brightness of the face area and the image: Based on the brightness histograms of the face area and the entire image, calculate the brightness of the face and the entire image by the proportion of bright spots, dark spots and normal brightness points in the brightness histogram.
[0134] S4, obtain the base brightness, that is, calculate the brightness of the target to be exposed:
[0135] S4.1 Obtain the current EV value: EV = exp * again * dgain. S4.2 Pre-set an EV table and a target brightness table. These are empirical tables and can be adjusted as needed. The basic rule is that the higher the EV value, the lower the target brightness. Examples are shown in the table below.
[0136] EV 3500 20000 50000 60000 89000 154500 280000 360000 640000 840000 960000 1280000 1560000 2334500 3304500 AT 55 55 55 55 50 50 45 45 45 45 40 40 40 40 40
[0137] S4.3, calculates the target's face brightness value using interpolation based on EV. For example, when EV is 200000...
[0138] target=(280000-154500) / (200000-154500)*(50-45)
[0139] S4.4, then obtain the current front and backlighting levels through the brightness histogram, and adjust the target brightness of the face. Obtaining the front and backlighting levels through the brightness histogram further includes:
[0140] First, calculate the histogram variance var.
[0141]
[0142] Where x is the average image brightness, and n is the image pixel format. i The brightness of each pixel;
[0143] If var > 10, proceed to the next step. Here, 10 is an empirical value, and the parameter can be adjusted according to the actual situation.
[0144] Secondly, calculate the current image mean (mean_luma) and median (mid_luma) based on the histogram.
[0145] If abs(mean_luma-mid_luma)>20, proceed to the next step.
[0146] Among them, 20 is an empirical value, and the parameter can be adjusted according to the actual situation;
[0147] Finally, pass through dark spots 30, pass through bright spots 230.
[0148] The number of pixels with a brightness greater than 230 (sat_num).
[0149] pix_num: The number of pixels in the image;
[0150] dark_num: The number of pixels with a brightness less than 30;
[0151] sat_ratio = sat_num / pix_num
[0152] dark_ratio = dark_num / pix_num
[0153] If sat_ratio*(1+dark_ratio)<0.15, it is considered dark light;
[0154] If sat_ratio + dark_ratio > 0.8, it is considered to be front lighting;
[0155] Among them, 0.15 and 0.8 are empirical values, and the parameters can be adjusted according to the actual situation.
[0156] S4.5 Backlight Detection: If the brightness of a person's face is significantly lower than the overall image brightness, it is determined to be backlighting. Backlighting is detected using a separate set of EV meters. There are two sets of EV meters: one for normal lighting conditions and the other for backlighting conditions. In backlighting conditions, the target brightness is even lower to prevent severe overexposure of the image.
[0157] S5, Calculate target brightness:
[0158] The target brightness for the face is dynamically adjusted based on the overall image brightness. To prevent overexposure due to insufficient or excessive lighting on the face, a protective mechanism is implemented. When the image is too bright, the target brightness for the face is appropriately reduced; similarly, when the image is too dark, the target brightness for the face is appropriately increased. This includes:
[0159] The sum of the brightness of all pixels in the face region: luma_sum, where the brightness range of each pixel is [0, 255].
[0160] Number of pixels in the face region: luma_num;
[0161] rotio = luma_sum / luma_num;
[0162] If ratio >= 1, dynamic_target = dynamic_target + 1;
[0163] If ratio < 0.5, dynamic_target = dynamic_target - 1;
[0164] target=target+dynamic_target;
[0165] After 5 frames, perform another check. The value of dynamic_target is in the range of [-5, +5].
[0166] S6, brightness activated:
[0167] After obtaining the target brightness of the face, the brightness of the subsequently exposed face area is compared with the target brightness. If the face brightness is higher than the target brightness, the exposure is reduced; if the face brightness is lower than the target brightness, the exposure is increased. For example:
[0168] If target = 80 is calculated, the brightness of the face region (face_luma) will be determined in each frame.
[0169] If face_luma > 80±1, increase the exposure;
[0170] If face_num > 80±1, reduce the exposure;
[0171] Methods to increase and decrease exposure:
[0172] Exposure adjustment methods include increasing exposure time, increasing sensor analog gain, and increasing data gain, which are not within the scope of this patent and will not be elaborated here.
[0173] This method allows for appropriate brightness levels for faces in scenes with facial features, while also providing good compatibility and scene adaptability.
[0174] In summary, the key technical solutions of this application include:
[0175] (1) Obtain the brightness of the face using the brightness histogram and face region information:
[0176] The brightness of a human face is calculated by the proportion of bright spots, dark spots, and normal brightness spots in the brightness histogram.
[0177] (2) Target brightness is dynamically calculated using an EV table and a face brightness table:
[0178] Using EV tables and face brightness tables, the target brightness is dynamically calculated, so that a suitable face brightness target can be obtained in any environment.
[0179] (3) Adjust the brightness of the image, the degree of front and backlighting, and make some minor adjustments to the brightness of the face:
[0180] Based on the overall brightness of the image and the degree of front and backlighting, make some minor adjustments to the brightness of the face to prevent the image from being overexposed or underexposed due to only considering the face.
[0181] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations can be made to the embodiments of the present invention. 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 facial exposure, characterized in that, The method includes the following steps: S1, obtain the coordinates of the face region; S2, Face coordinate processing: includes: Remove faces: Select the main faces as those that need to be exposed; Adjust face size: Crop the area where the face is exposed to ensure that the entire exposed area is the face and there is no background; Face stabilization: Prevents inaccurate exposure caused by facial shaking; S3, calculates the brightness of the face area and the image: Based on the brightness histograms of the face region and the entire image, respectively, the brightness of the face and the entire image is calculated by determining the proportions of bright, dark, and normal brightness points in the brightness histograms. Overall screen brightness: n: The number of pixels with brightness i, this data is in the histogram; w: Image width, in pixels; h: Image height, in pixels; Face brightness: luma=(sum_dark+sum_mid+sum_sat) / (face_w*face_h) sum_dark: The sum of the brightness of the darker pixels in the face area; sum_mid: The sum of the pixel brightness in the face area where the brightness is normal; sum_sat: The sum of the brightness of the brightest pixels in the face area; face_w: Face width, in pixels; face_h: Face height, in pixels; S4, Obtain the base brightness: Obtain the base target brightness based on the current EV and the EV table; S5, Calculate target brightness: Based on the brightness of the entire image, obtain the final target brightness of the face; S6, Brightness Activation: Adjusts the image brightness to an appropriate level based on the brightness of the face target.
2. The face exposure adjustment method according to claim 1, characterized in that, Step S1 further includes: For chips with computing power, facial coordinates can be obtained through their own algorithms. Here, "own algorithms" refers to facial recognition algorithms, and chips with computing power can perform facial recognition. For laptop webcams and USB webcams, configure ROI support in the UVC descriptor. When a Windows camera receives an image, it will perform face recognition and send the face coordinates to the device via USB.
3. The face exposure adjustment method according to claim 1, characterized in that, Step S2 further includes: S2.1 After obtaining the coordinates, the face coordinates are first filtered. If the face width and height are too small, it is considered that the face is too far from the camera. In this case, adjusting the face exposure will easily have a significant impact on the overall image, so such faces are filtered out. The filtering includes: The minimum width w = 35 * image_width / 640, and the width must be greater than 20; The minimum height h = 40 * image_height / 640, and the height must be greater than 25; S2.2, Adjust face size: Because the face is not a standard rectangle, the background of the face needs to be removed and the area where the face is exposed needs to be cropped, that is, the image around the face is cropped: crop 1 / 4 of the top, bottom, left and right sides of the face to ensure that the entire area exposed by the face is the face and there is no background. S2.3, Face Coordinate Stabilization: When a face appears, it is not immediately exposed as a face. The system needs to determine if the face is stable before starting the exposure. This prevents the face coordinates from being out of sync with the actual scene when the face is moving, resulting in the exposure position not being the face. The following conditions indicate that the face is not stable: Condition 1: The face moves more than 1 / 3 of its size within 1 second; Condition 2: The face size changes by more than 1 / 2 within 1 second.
4. The face exposure adjustment method according to claim 3, characterized in that, Step S2 further includes step S2.4, face filtering in multi-face scenes: if multiple faces appear in the image, The face with the largest area is used for exposure.
5. The face exposure adjustment method according to claim 1, characterized in that, Step S4 further includes: calculating the brightness of the exposure target. S4.1, obtain the current EV value: EV = exp * again * dgain S4.2, Pre-set an EV table and a target brightness table; the preset EV table and target brightness table are empirical tables and can be adjusted according to needs. The basic rule is that the higher the EV value, the lower the target brightness; S4.3, interpolate and calculate the target face brightness value based on the EV value. Assuming ev is 200000: target=(280000-154500) / (200000-154500)*(50-45); S4.4, then obtain the current backlighting level through the brightness histogram and adjust the brightness target of the face; S4.5, backlighting judgment, if the brightness of the face is much lower than the brightness of the whole image, it is judged as backlighting, and backlighting uses another set of EV tables; there are two sets of EV tables, one set for normal lighting conditions and the other set for backlighting conditions. The target brightness is lower in backlighting conditions to prevent severe overexposure of the image.
6. The face exposure adjustment method according to claim 1, characterized in that, In step S4.2, an EV table and a target brightness table are preset, as shown in the following table. 。 7. The face exposure adjustment method according to claim 1, characterized in that, The step S4.4, which involves obtaining the degree of forward and backlighting through the brightness histogram, further includes: first, calculating the histogram variance var. Where x is the average image brightness, and n is the image pixel format. i The brightness of each pixel; If var > 10, proceed to the next step. Here, 10 is an empirical value, and the parameter can be adjusted according to the actual situation. Secondly, calculate the current image mean (mean_luma) and median (mid_luma) based on the histogram. If abs(mean_luma-mid_luma)>20, proceed to the next step. Among them, 20 is an empirical value, and the parameter can be adjusted according to the actual situation; Finally, pass through dark spots 30, pass through bright spots 230. The number of pixels with a brightness greater than 230 (sat_num). pix_num: The number of pixels in the image; dark_num: The number of pixels with a brightness less than 30; sat_ratio = sat_num / pix_num dark_ratio = dark_num / pix_num If sat_ratio*(1+dark_ratio)<0.15, it is considered dark light; If sat_ratio + dark_ratio > 0.8, it is considered to be front lighting; Among them, 0.15 and 0.8 are empirical values, and the parameters can be adjusted according to the actual situation.
8. The face exposure adjustment method according to claim 1, characterized in that, Step S5 further includes: The target brightness of the face is dynamically adjusted based on the overall image brightness. To prevent the overall image from being too dark or overexposed due to relying solely on the face's brightness when the image is either too bright or too dark, a protective mechanism is implemented. When the image is too bright, the target brightness of the face is appropriately reduced; similarly, when the image is too dark, the target brightness of the face is appropriately increased. This includes: The sum of the brightness of all pixels in the face region: luma_sum, where the brightness range of each pixel is [0, 255]. Number of pixels in the face region: luma_num; rotio = luma_sum / luma_num; If ratio >= 1, then dynamic_target = dynamic_target + 1; If ratio < 0.5, dynamic_target = dynamic_target - 1; target=target+dynamic_target; After 5 frames, perform another check. The value of dynamic_target is in the range of [-5, +5].
9. A face exposure adjustment method according to claim 1, characterized in that, Step S6 further includes: After obtaining the brightness of the target face, the brightness of the face area in subsequent exposures is compared with the target brightness. If the face brightness is higher than the target brightness, the exposure is reduced; if the face brightness is lower than the target brightness, the exposure is increased.
10. A face exposure adjustment method according to claim 1, characterized in that, The method is applicable to computer cameras, USB cameras, face recognition door lock cameras, security monitoring cameras, and face recognition gate cameras, especially laptop cameras and related equipment.