A method and apparatus for accurately calculating the brightness value of a human face region

By utilizing variance and histogram analysis in face detection, brightness deviation is processed in partitions and pixels are filtered, solving the problem of inaccurate face brightness calculation in existing technologies and improving the effectiveness of exposure adjustment and the accuracy of face recognition.

CN116668672BActive Publication Date: 2026-05-26UNIVERSAL UBIQUITOUS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
UNIVERSAL UBIQUITOUS TECH CO LTD
Filing Date
2022-03-23
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Existing face exposure adjustment algorithms rely on the bounding boxes of AI face detection, which leads to a large deviation between the calculated face brightness and the actual face brightness, affecting the effectiveness of exposure adjustment and the accuracy of face recognition.

Method used

The region of interest is determined by face detection. The variance and histogram distribution trends are used to determine whether there are non-face areas or mask obstructions. Brightness deviations are processed by region, and pixels are selected for recalculation to obtain more accurate brightness values ​​for face areas.

Benefits of technology

It reduces the deviation in face brightness calculation results, solves the problem of repeated oscillations in exposure adjustment, and improves the accuracy of face recognition and image quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116668672B_ABST
    Figure CN116668672B_ABST
Patent Text Reader

Abstract

This invention discloses a method for accurately calculating the brightness value of a facial region. The method analyzes the brightness histogram and calculates brightness constraints for the face bounding box identified by the algorithm. It performs secondary selection of the face for brightness statistics, reducing the impact of masks or other non-facial areas on the brightness calculation. By calculating mathematical features such as average brightness, variance, and median, it can preliminarily determine whether there are many areas in the image that do not meet facial attributes. By filtering the pixels of the region according to brightness constraints and removing overexposed and underexposed background pixels, the average skin tone brightness of the facial region can be more accurately obtained. This invention also provides a device for accurately calculating the brightness value of a facial region. This invention improves the facial brightness calculation method, reduces the deviation between the calculated facial brightness and the actual facial brightness, and solves problems such as repeated fluctuations or underexposure and overexposure in subsequent exposure adjustments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of face recognition, and in particular to a method and apparatus for accurately calculating the brightness value of a face region. Background Technology

[0002] With the rapid development of artificial intelligence, facial recognition technology, as a means of identity authentication, plays an increasingly important role in applications such as attendance systems and access control systems. Therefore, ensuring image quality, especially facial image quality, is crucial for these intelligent applications. In production, most manufacturers choose to use wide dynamic range (WDR) cameras to ensure image brightness. However, in practical applications, although WDR cameras can dynamically adjust exposure to ensure overall image brightness, the image quality of WDR fused thermal images is still insufficient compared to linear images in terms of sharpness and color reproduction. Furthermore, they cannot provide facial images that meet recognition requirements under low light or shadow conditions. Therefore, a method that automatically adjusts camera exposure based on the brightness of the facial region can optimize the quality of the facial region image. This can yield higher-quality facial images on the same hardware and algorithm basis, thereby improving the facial recognition rate and promoting technological development in the field of intelligent products.

[0003] Since exposure adjustment relies on facial brightness calculation, the accuracy of this calculation directly determines the effectiveness and timeliness of the exposure. Therefore, a highly accurate facial exposure brightness calculation is crucial for facial exposure algorithms. Most existing facial exposure adjustment algorithms rely on a rectangular bounding box provided by AI face detection to calculate facial brightness. The calculation method simply involves pixel stacking or using statistical brightness blocks provided by the SOC. This method does not consider the deviation between the algorithm bounding box and the actual facial bounding box, nor the influence of occlusions such as masks on the face. This leads to a high probability that the calculated facial brightness will deviate significantly from the actual facial brightness, causing subsequent exposure adjustments to experience repeated fluctuations, underexposure, or overexposure, thus affecting the accuracy of subsequent face recognition. Summary of the Invention

[0004] (a) Technical problems to be solved

[0005] To address the aforementioned technical problems, this invention provides a method and apparatus for accurately calculating the brightness value of a face region. The method includes: determining the region containing the face of interest in the current video frame through face detection; based on the distribution trend of the variance and histogram calculated in preliminary statistics, initially determining whether there are a large number of non-face areas within the face region bounding box, and whether there are masks obscuring the face region; based on the preliminary judgment results, further dividing the face region into partitions to determine whether there are significant brightness differences between the upper and lower regions of the face, and further determining whether there are masks obscuring the face region; based on the judgment results, performing brightness filtering on the pixels in the face region, and recalculating the filtering results to obtain a more accurate brightness value for the face region.

[0006] (II) Technical Solution

[0007] To solve the aforementioned technical problems and achieve the invention's objective, the present invention is implemented through the following technical solution:

[0008] A method for accurately calculating the brightness value of a facial region includes the following steps:

[0009] The location of the face in the image is obtained by face detection as OriZone[(x,y),(x+width,y+height)], where x and y represent the starting point coordinates of the face, located at the lower left corner of the defined area, and (width,height) are the width and height dimensions of the face area, in pixels, with N bits of data.

[0010] Step 1: Determine the sampling step size based on the region size and calculate the brightness of a single pixel. To improve algorithm speed, sample the extracted OriZone data. When the region's width > WidthRef or height > HeightRef, the sampling step size is set as follows: height sampling step size Hstep = height / HeightRef (integer), width sampling step size Wstep = width / WidthRef (integer); otherwise, Hstep = 1 and Wstep = 1. HeightRef and WidthRef are the maximum number of pixels set to optimize calculation speed. When the size of the face bounding box detected by the intelligent algorithm is larger than this threshold, the face needs to be sampled. This ensures that the calculation amount for the face bounding box is no more than HeightRef * WidthRef operations. This parameter can be adjusted appropriately when higher calculation accuracy or faster calculation speed is required.

[0011] Sample the brightness of a single pixel in OriZone [i,j] The following standard calculation formula is used:

[0012] Brightness [i,j] =(299*R) [i,j] +587*G [i,j] +114*B [i,j] ) / 1000, where R [i,j] G [i,j] B [i,j] These are the RGB brightness values ​​of the pixel.

[0013] Further normalization processing of pixel brightness:

[0014]

[0015] The calculation results are then linearly processed until the threshold [0-2] is reached. M-1 Save it to LumaStatOri[w][h].

[0016] Where w = width / Wstep, h = height / Hstep, and the total number of pixels is w*h.

[0017] Step 2: Based on the size of the face bounding box, construct the brightness histogram information of all pixels or sampled pixels in the region OriZone, and calculate the mathematical statistics of the average value, maximum value, and variance.

[0018] Based on the following formula, statistical histograms are plotted to calculate the average brightness and variance (LumaAvg) of OriZone. ori LumaVar ori :

[0019]

[0020]

[0021] Simultaneously, the minimum brightness value LumaMin in OriZone was calculated. ori With maximum brightness LumaMax ori The dark-state brightness threshold, LumaLowLimit, is obtained using the following formula. Ori High brightness threshold LumaHighLimit Ori .

[0022] LumaLowLimit=LumaAvg*LumaLowThr

[0023] LumaHighLimit=LumaAvg*LumaHighThr

[0024] LumaLowThr and LumaHighThr are given brightness constraint thresholds. It is generally assumed that the brightness of facial skin color is basically the same in the area (excluding eyebrows, eyes and lips). Therefore, it can be agreed that the average value of facial skin color is within ±30%, that is: LumaLowThr = 70% and LumaHighThr = 130%. In actual use, it can be finely adjusted according to the needs.

[0025] Statistics are less than LumaLowLimit Ori Number of pixels LumaLowCnt Ori and greater than LumaHighLimit Ori Number of pixels LumaHighCnt Ori And the median luminance LumaMid in OriZone ori .

[0026] Step 3: Based on the calculated face region's LumaHighCnt Ori Compared with the set threshold for the number of highlighted pixels, LumaHighCnt ref and LumaLowCnt Ori Compared with the set threshold for the number of dark pixels, LumaLowCnt ref To make a judgment, a preliminary analysis can be made to determine whether the brightness distribution in the image is uniform, and to preliminarily analyze whether there are a large number of pixels with non-facial attributes.

[0027] Among them, the threshold for the number of bright pixels, LumaHighCnt ref And the threshold for the number of dark pixels, LumaLowCnt ref It can be obtained through the following formula:

[0028] LumaHighCnt ref =LumaHighCntPer ref *w*h

[0029] LumaLowCnt ref =LumaLowCntPer ref *w*h

[0030] Among them, LumaHighCntPer ref LumaLowCnt is the threshold ratio for the number of highlighted pixels. ref This represents the threshold ratio for the number of dark pixels.

[0031] If LumaHighCnt Ori <LumaHighCnt ref And LumaLowCnt Ori<LumaLowCnt ref If the pixel distribution trend in the initial image meets the basic facial pixel distribution trend, then proceed to Step 5 to determine whether there is a large amount of dark information or overexposed areas in the region.

[0032] if

[0033] LumaHighCnt Ori >LumaHighCnt ref

[0034] or

[0035] LumaLowCnt Ori >LumaLowCnt ref

[0036] If abnormal pixels such as those from a mask are found in the initial image, proceed to Step 4 to divide the face area into regions and re-analyze the brightness.

[0037] Step 4: Divide the face area into regions and re-analyze the brightness.

[0038] Divide the face region into two parts: TopZone and BelowZone. TopZone is defined as [(x,y+height*2 / 3),(x+width,y+height)], and BelowZone as [(x,y),(x+width,y+height / 2)]. Repeat Step 1 and Step 2 for both the Top and Below regions to calculate the new LumaAvg. top LumaVar top LumaAvg below LumaVar below And histogram information. Determine LumaAvg respectively. top LumaAvg below With LumaAvg ori The difference is considered to be that the lower half of the face is generally brighter if the following conditions are met:

[0039] LumaAvg top <LumaAvg ori -LumaCompensation

[0040] LumaAvg below >LumaAvg ori +LumaCompensation

[0041] Or, if the following conditions are met, the lower half of the face is generally darker:

[0042] LumaAvg top >LumaAvg ori +LumaCompensation

[0043] LumaAvg below <LumaAvg ori -LumaCompensation

[0044] And simultaneously meet the following two conditions:

[0045] LumaVar below <LumaVar ori

[0046] LumaVar top <LumaVar ori

[0047] Here, LumaCompensation is the brightness compensation value. Its value can be calculated using LumaCompensation = LumaAvg * CompensationThr%. CompensationThr is the preset compensation amount.

[0048] This indicates a significant brightness difference between the upper and lower areas of the image, which can be attributed to the mask obstructing the lower half of the image. At this point, the TopZone area is selected as the brightness statistics region for the face; the TopZone statistics are then replaced with the OriZone statistics, and the process proceeds to Step 5.

[0049] If the above conditions are not met, proceed directly to Step 5 for processing.

[0050] Step 5: Calculate the luminance variance LumaVar ori LumaVar (luminance variance threshold) ref To make a judgment,

[0051] if

[0052] LumaVar ori ≤LumaVar ref

[0053] The current OriZone screen has a uniform brightness distribution, and the current LumaAvg... ori This is the final average brightness of the face;

[0054] on the contrary

[0055] LumaVar ori >LumaVarref

[0056] In other words, if the brightness distribution of pixels in a region is uneven, then pixels with brightness values ​​between (LumaHighLimit) need to be removed. ori LumaMax ori ) and (LumaMix ori LumaLowLimit ori The pixels are then used to calculate LumaAvg as the final average face brightness.

[0057] Using the above method, some areas that affect the calculation of facial skin brightness can be filtered out in the [(x,y),(x+width,y+height)] region (such as masks, large areas of hair covering the face, and the introduction of a large amount of background color due to the deviation between the face frame and the actual face area). The face brightness can then be recalculated. If no filtering is performed in the end, the brightness distribution in the current image will be uniform, and the calculation can be performed directly. Using this processing flow can improve the reliability of the face brightness calculated in the exposure processing.

[0058] The present invention also provides a device for accurately calculating the brightness value of a facial region, which specifically includes:

[0059] The face image data sampling module is used to obtain the location of the face in the image through face detection, determine the sampling step size according to the size of the region, calculate the brightness of the sampled pixels, and perform normalization processing.

[0060] The face image data processing module is used to construct the brightness histogram information of all pixels in the region by using the results calculated by the face image data sampling module, and to calculate the mathematical statistics of the average value, maximum value, and variance.

[0061] The preliminary facial image analysis module is used to judge the number of bright pixels and dark pixels in the facial region calculated by the facial image data processing module, and to compare them with the set threshold for the number of bright pixels and dark pixels. It can preliminarily analyze whether the brightness distribution in the image is uniform and whether there are a large number of pixels with non-facial attributes.

[0062] The face image partitioning module is used to divide the face region into regions and re-analyze the brightness. Based on the analysis results of the preliminary face image analysis module, when it is determined that there are abnormal pixels in the face region, the face region is divided into regions and the brightness is re-analyzed.

[0063] The face image adjustment output module is used to calculate whether the brightness variance meets the threshold condition. If it does, the average brightness is directly used as the final output result. Otherwise, some areas that affect the calculation of face skin brightness are filtered out and the face brightness is recalculated.

[0064] (III) Beneficial Effects

[0065] Compared with the prior art, the beneficial effects of the present invention are that it takes into account the deviation between the algorithm frame and the actual face frame and the influence of the mask covering the face area, reduces the deviation between the calculated face brightness and the actual face brightness, solves the problems of repeated oscillations or even underexposure or overexposure in subsequent exposure adjustment, obtains the brightness value of the face area more accurately, and improves the algorithm speed. It can obtain higher quality face images on the same hardware and algorithm basis to improve the face recognition rate. Attached Figure Description

[0066] Figure 1 A flowchart illustrating the method for calculating the brightness value of a face region as provided in an embodiment of the present invention. Detailed Implementation

[0067] The technical solutions in the embodiments of the present invention will be clearly and completely described below. 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.

[0068] To explain the technical content, objectives, and technical effects of the present invention in detail, the following description is provided in conjunction with the embodiments and accompanying drawings.

[0069] See Figure 1 A method for accurately calculating the brightness value of a facial region, comprising the following steps:

[0070] The Get ORI Region method obtains the region location of the face in the image as Region[(Startx,Starty),(Startx+Width,Starty+Height)], where Startx and Starty represent the starting point coordinates of the face, located at the lower left corner of the agreed region, and Width and Height are the width and height dimensions of the face region, in pixels, with N bits of data.

[0071] Step 1: Determine the sampling step size Step based on the Region size. To improve algorithm speed, data is sampled from the extracted ORI Region. If the region's Width > WidthRef or Height > HeightRef, the sampling step size is set as follows: Height sampling step size Hstep = height / HeightRef (integer), Width sampling step size Wstep = width / WidthRef (integer); otherwise, Hstep = 1 and Wstep = 1. HeightRef and WidthRef are the maximum number of pixels set to optimize calculation speed. When the face bounding box detected by the intelligent algorithm is larger than this threshold, the face needs to be sampled. This ensures that the calculation of the face bounding box does not exceed HeightRef * WidthRef operations. This parameter can be adjusted appropriately when higher calculation accuracy or faster calculation speed is required.

[0072] Brightness of a single sample pixel [i,j] The following standard calculation formula is used:

[0073] Brightness [i,j] =(299*R) [i,j] +587*G [i,j] +114*B [i,j] ) / 1000, where R [i,j] G [i,j] B [i,j] These are the RGB brightness values ​​of the pixel.

[0074] Further normalization processing of pixel brightness:

[0075]

[0076] The calculation results are then linearly processed until the threshold [0-2] is reached. M-1 Save it to LumaStatOri[w][h].

[0077] Where w = width / Wstep, h = height / Hstep, and the total number of pixels is w*h.

[0078] Step 2: Based on the size of the face bounding box, construct the brightness histogram information of all pixels or sampled pixels in the ORI region and calculate the average brightness LumaAvg, variance LumaVariance, and median LumaMid. Based on the histogram distribution, determine the main distribution range of ORI brightness, as follows:

[0079] Based on the following formula, calculate the mean luminance value LumaAvg and variance value LumaVariance of the ORI by plotting the histogram:

[0080]

[0081]

[0082] Simultaneously, the minimum brightness value (MinLuma) and the maximum brightness value (MaxLuma) in the ORI are calculated, and the dark-state brightness threshold (LumaLowLimit) is obtained using the following formula. Ori High brightness threshold LumaHighLimit Ori .

[0083] LumaLowLimit=LumaAvg*LumaLowThr

[0084] LumaHighLimit=LumaAvg*LumaHighThr

[0085] LumaLowThr and LumaHighThr are given brightness constraint thresholds. It is generally assumed that the brightness of facial skin color is basically the same in the area (excluding eyebrows, eyes and lips). Therefore, it can be agreed that the average value of facial skin color is within ±30%, that is: LumaLowThr = 70% and LumaHighThr = 130%. In actual use, it can be finely adjusted according to the needs.

[0086] The number of pixels in the brightness range (MinLuma, LumaLowLimit) of the histogram (LowLumaPixelCnt) and the number of pixels in the brightness range (LumaHighLimit, MaxLuma) (HighLumaPixelCnt) of the histogram are counted.

[0087] Step 3: Based on the calculated HighLumaPixelCnt of the face region and the set threshold for the number of bright pixels, and LowLumaPixelCnt and the set threshold for the number of dark pixels, a preliminary analysis is made to determine whether the brightness distribution in the image is uniform, and to preliminarily analyze whether there are a large number of pixels with non-face attributes.

[0088] The thresholds for the number of bright pixels (HighLumaPixelCntRef) and the thresholds for the number of dark pixels (LowLumaPixelCntRef) are obtained using the following formulas:

[0089] HighLumaPixelCntRef=LumaHighCntPer ref *w*h

[0090] LowLumaPixelCntRef=LumaLowCntPer ref *w*h

[0091] Among them, LumaHighCntPer ref LumaLowCnt is the threshold ratio for the number of highlighted pixels. ref This represents the threshold ratio for the number of dark pixels.

[0092] if

[0093] HighLumaPixelCnt>HighLumaPixelCntRef

[0094] or

[0095] LowLumaPixelCnt>LowLumaPixelCntRef

[0096] If abnormal pixels such as those from a mask are found in the initial image, proceed to Step 4 to divide the face area into regions and re-analyze the brightness.

[0097] Otherwise, if the pixel distribution trend in the initial image meets the basic facial pixel distribution trend, proceed to Step 5 to determine whether there is a large amount of dark information or overexposed areas in the region.

[0098] By quantizing the brightness histogram distribution of the region and adjusting the segmentation threshold, a secondary selection of the face can be performed to statistically analyze the brightness. This can reduce the impact of face mask occlusion or other non-face areas on the brightness calculation of the face region.

[0099] Step 4: Divide the face area into regions and re-analyze the brightness.

[0100] Divide the face region into two parts: TopZone and BelowZone. TopZone is defined as [(Startx,Starty+height*2 / 3),(Startx+width,Starty+height)], and BelowZone is defined as [(Startx,Starty),(Startx+width,Starty+height / 2)]. Repeat Step 1 and Step 2 for both Top and BelowZone regions, calculating their step sizes TopStep and BelowStep based on TopZone and BelowZone.

[0101] Based on the step size, histogram information for both is constructed, and the mean and variance TopLumaAvg, BelowLumaAvg, TopLumaVar, and BelowLumaVar are calculated.

[0102] Determine TopLumaAvg, BelowLumaAvg, and LumaAvg respectively. ori The differences, among which, LumaAvg ori The average brightness of the ORI (Organic Area Reflection) across the entire area is considered to indicate that the lower half of the face is generally brighter if the following conditions are met:

[0103] TopLumaAvg <LumaAvg ori -LumaComp

[0104] BelowLumaAvg>LumaAvg ori +LumaComp

[0105] Or, if the following conditions are met, the lower half of the face is generally darker:

[0106] TopLumaAvg>LumaAvg ori +LumaComp

[0107] BelowLumaAvg <LumaAvg ori -LumaComp

[0108] And simultaneously meet the following two conditions:

[0109] BelowLumaAvg <LumaVar ori

[0110] TopLumaAvg <LumaVar ori

[0111] Where LumaComp is the brightness compensation value. Its value can be calculated using LumaCompensation = LumaAvg * CompensationThr%. CompensationThr is the preset compensation amount.

[0112] This indicates a significant brightness difference between the upper and lower areas of the image, which can be attributed to the mask obstructing the lower half of the image. At this point, the TopZone area is selected as the statistical region for the face's brightness. The TopZone statistics are then used to replace the ORI statistics, and the process proceeds to Step 5, where the replacement is as follows:

[0113] LumaAvg = TopLumaAvg;

[0114] LumaVar = TopLumaVar;

[0115] LumaMid = TopLumaMid.

[0116] If the above conditions are not met, proceed directly to Step 5 for processing.

[0117] Step 5: Compare the calculated luminance variance LumaVar with the luminance variance threshold LumaVar ref To render a judgment;

[0118] if

[0119] LumaVar≤LumaVar ref

[0120] The current screen brightness distribution is uniform, and the current LumaAvg... ori This is the final average face brightness value, OriLuma.

[0121] on the contrary

[0122] LumaVar>LumaVar ref

[0123] That is, if the pixel brightness distribution in the region is uneven, pixels with brightness values ​​higher than HighLumaLimit and lower than LowLumaLimit should be removed. A new NewLumaAvg is then recalculated as the final average face brightness value, OriLuma.

[0124] Using the above method, areas that affect the calculation of facial skin brightness (such as masks, large areas of hair obscuring the face, and large background colors introduced due to deviations between the face frame and the actual face area) can be filtered out within the [(Startx,Starty),(Startx+Width,Starty+Height)] region. The facial brightness can then be recalculated. If no filtering is performed, the brightness distribution in the current image is uniform, and calculation can be performed directly. By filtering the pixels in the region with brightness constraints, the influence of overexposed and underexposed pixels and other background pixels can be removed, and the average skin brightness of the facial area can be accurately obtained. Using this processing flow can improve the reliability of facial brightness calculations in exposure processing.

[0125] This invention also proposes a device for accurately calculating the brightness value of a facial region, which specifically includes:

[0126] The face image data sampling module is used to obtain the location of the face in the image through face detection, determine the sampling step size according to the size of the region, calculate the brightness of the sampled pixels, and perform normalization processing.

[0127] The face image data processing module is used to construct the brightness histogram information of all pixels in the region by using the results calculated by the face image data sampling module, and to calculate the mathematical statistics of the average value, maximum value, and variance.

[0128] The preliminary facial image analysis module is used to judge the number of bright pixels and dark pixels in the facial region calculated by the facial image data processing module, and to compare them with the set threshold for the number of bright pixels and dark pixels. It can preliminarily analyze whether the brightness distribution in the image is uniform and whether there are a large number of pixels with non-facial attributes.

[0129] The face image partitioning module is used to divide the face region into regions and re-analyze the brightness. Based on the analysis results of the preliminary face image analysis module, when it is determined that there are abnormal pixels in the face region, the face region is divided into regions and the brightness is re-analyzed.

[0130] The face image adjustment output module is used to calculate whether the brightness variance meets the threshold condition. If it does, the average brightness is directly used as the final output result. Otherwise, some areas that affect the calculation of face skin brightness are filtered out and the face brightness is recalculated.

[0131] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made by those skilled in the art to the technical solutions of the present invention without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.

Claims

1. A method for accurately calculating the brightness value of a facial region, characterized in that, Includes the following steps: To obtain the location of the face region, the sampling step size is determined based on the region size, specifically as follows: The location of the face in the image is obtained through face detection; Step 1: Sample the data of the extracted region. When the width of the region is greater than a set threshold or the height is greater than a set maximum pixel threshold, the sampling step size is set as follows: the height sampling step size is the ratio of the height value to the maximum pixel threshold, and the width sampling step size is the ratio of the width value to the maximum pixel threshold, rounded to an integer; otherwise, the step size is set to 1. Calculate the brightness of a single pixel sampled in the region and perform normalization processing; Step 2: Based on the size of the face frame, construct the brightness histogram information of all pixels or sampled pixels in the region, calculate the mathematical statistics of the average brightness, maximum and minimum values, and variance, calculate the dark state brightness threshold and the bright state brightness threshold, and count the number of pixels less than the dark state brightness threshold and the number of pixels greater than the bright state brightness threshold, as well as the median brightness in the region. Step 3: Based on the calculated number of pixels in the face area that are greater than the high brightness threshold and the set high brightness pixel count threshold, and the number of pixels that are less than the dark brightness threshold and the set dark brightness pixel count threshold, a preliminary analysis is made to determine whether the brightness distribution in the image is uniform and whether there are a large number of pixels with non-face attributes. If there is uneven brightness distribution or a large number of pixels with non-face attributes, it is preliminarily determined that there are occlusions in the image. In this case, proceed to Step 4; otherwise, proceed to Step 5. Step 4: Divide the face area into regions and re-analyze the brightness. Specifically, divide the face area into two parts: the upper region is the upper 1 / 3 of the image at the given location, and the lower region is the upper 1 / 2 of the image at the given location. Repeat Step 1 and Step 2 for each region to calculate new average brightness, variance, and histogram information. Determine the differences between the average brightness of the upper region, the average brightness of the lower region, and the average brightness of the entire image. If the judgment result shows that the brightness difference between the upper and lower areas of the image is large, it can be considered that there is an obstruction affecting the lower half of the image. In this case, the upper area is taken as the image brightness statistics area for the face. Replace the statistical information of the upper area with the statistical result of the area, and then proceed to Step 5. Otherwise, proceed directly to Step 5 for processing; Step 5: Determine the uniformity of screen brightness distribution based on the calculated brightness variance and brightness variance threshold. The brightness variance threshold can be set to different values ​​according to different scene requirements. If the screen brightness distribution is uniform, the current average brightness value is the final average brightness value of the face. Conversely, some areas that affect the calculation of facial skin brightness are filtered out, and the average brightness is recalculated as the final average facial brightness.

2. The method for accurately calculating the brightness value of the face region according to claim 1, characterized in that: The step Step1 in the single pixel brightness Brightness [i,j] The following standard calculation formula is used: Brightness [i,j] =(299*R) [i,j] +587*G [i,j] +114*B [i,j] ) / 1000, where R [i,j] G [i,j] B [i,j] These are the RGB brightness values ​​for that pixel.

3. The method for accurately calculating the brightness value of the face region according to claim 2, characterized in that: The normalization process for pixel brightness specifically involves: The calculation result is linearly calculated to a threshold value [0-2 M-1 ] and saved in LumaStatOri[w][h]; Where w = width / Wstep, h = height / Hstep, and the total number of pixels is w*h; width is the width of the region, height is the height of the region; Wstep is the width sampling step size, Hstep is the height sampling step size, and N is the number of bits.

4. The method for accurately calculating the brightness value of the face region according to claim 3, characterized in that: Step 2, which involves constructing the luminance histogram information of all pixels in the region, specifically includes calculating the average luminance value and variance value LumaAvg of the region using the following formula. ori LumaVar ori : And the minimum brightness value LumaMin at the location of the region. ori With maximum brightness LumaMax ori .

5. The method for accurately calculating the brightness value of the face region according to claim 4, characterized in that: The dark state brightness threshold and the bright state brightness threshold mentioned in Step 2 are calculated using the following formulas: LumaLowLimit=LumaAvg*LumaLowThr LumaHighLimit=LumaAvg*LumaHighThr; LumaLowLimit Ori LumaHighLimit is the dark-state brightness threshold. Ori LumaLowThr and LumaHighThr are the high brightness thresholds, while LumaLowThr and LumaHighThr are the given brightness constraint thresholds.

6. The method for accurately calculating the brightness value of the face region according to claim 4, characterized in that: The threshold values ​​for the number of bright pixels and the threshold values ​​for the number of dark pixels mentioned in Step 3 are obtained using the following formulas: LumaHighCnt ref =LumaHighCntPer ref *w*h LumaLowCnt ref =LumaLowCntPer ref *w*h Among them, LumaHighCnt ref LumaLowCnt is the threshold for the number of highlighted pixels. ref LumaHighCnt is the threshold for the number of dark-state pixels. ref LumaLowCnt is the threshold ratio for the number of highlighted pixels. ref This represents the threshold ratio for the number of dark pixels.

7. The method for accurately calculating the brightness value of the face region according to claim 6, characterized in that: Step 3, which involves preliminary analysis of whether the brightness distribution in the image is uniform and whether there are a large number of pixels with non-facial attributes, specifically involves: If the number of bright pixels and the number of dark pixels are less than the threshold for the number of bright pixels and the threshold for the number of dark pixels, respectively, then the pixel distribution trend in the initial image meets the basic face pixel distribution trend. If the number of bright pixels exceeds the threshold for the number of bright pixels or the number of dark pixels exceeds the threshold for the number of dark pixels, it is preliminarily determined that there are abnormal pixels in the image.

8. The method for accurately calculating the brightness value of the face region according to claim 4, characterized in that: The difference between the average brightness of the upper region, the average brightness of the lower region, and the average brightness of the entire image, as described in Step 4, is as follows: The lower half of the face is considered to be brighter if the following conditions are met: LumaAvg top <LumaAvg ori -LumaCompensation LumaAvg below >LumaAvg ori +LumaCompensation Or, if the following conditions are met, the lower half of the face is generally darker: LumaAvg top >LumaAvg ori +LumaCompensation LumaAvg below <LumaAvg ori -LumaCompensation And simultaneously satisfy the following two conditions LumaVar below <LumaVar ori LumaVar top <LumaVar ori Among them, LumaAvg top LumaAvg represents the average brightness of the upper region. below LumaAvg represents the average brightness of the lower region. ori LumaCompensation is the average brightness of the entire image, and its value can be calculated as LumaCompensation = LumaAvg * CompensationThr%. CompensationThr is the preset compensation amount.

9. The method for accurately calculating the brightness value of the face region according to claim 1, characterized in that: Step 5, which involves determining the uniformity of screen brightness distribution based on the calculated brightness variance and brightness variance threshold, specifically involves: If the brightness variance is less than or equal to the brightness variance threshold, then the brightness distribution of the current area is uniform, and the current average brightness is the final average brightness of the face. Conversely, if the brightness variance is greater than the brightness variance threshold, the brightness distribution of pixels in the region is uneven. Pixels with brightness values ​​between the high brightness threshold and the maximum brightness, and pixels with brightness values ​​between the dark brightness threshold and the minimum brightness, need to be removed from the image. The average brightness value is then recalculated as the final average brightness value of the face.

10. An apparatus for accurately calculating the brightness value of a face region as described in any one of claims 1-9, characterized in that, The device includes: The face image data sampling module is used to obtain the location of the face in the image through face detection, determine the sampling step size according to the size of the region, calculate the brightness of the sampled pixels, and perform normalization processing. The face image data processing module is used to use the results obtained by the face image data sampling module to construct the brightness histogram information of all pixels in the region, and to calculate the mathematical statistics of the average value, maximum value, and variance. The preliminary facial image analysis module is used to judge the number of bright pixels and dark pixels in the facial region calculated by the facial image data processing module, and to compare them with the set threshold for the number of bright pixels and the set threshold for the number of dark pixels. It can preliminarily analyze whether the brightness distribution in the image is uniform and can preliminarily analyze whether there are a large number of pixels with non-facial attributes. The face image partitioning module is used to divide the face region into regions and re-analyze the brightness. Based on the analysis results of the preliminary face image analysis module, when it is determined that there are abnormal pixels in the face region, the face region is divided into regions and the brightness is re-analyzed. The face image adjustment output module is used to calculate whether the brightness variance meets the threshold condition. If it does, the average brightness is directly used as the final output result. Otherwise, some areas that affect the calculation of face skin brightness are filtered out and the face brightness is recalculated.