A method, apparatus and storage medium for determining target white balance
By combining the color channel values of captured and non-captured frames to determine the target white balance, the problem of inaccurate white balance caused by changes in ambient light in intelligent transportation is solved, thus improving the image display effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2022-12-28
- Publication Date
- 2026-07-03
AI Technical Summary
In intelligent transportation checkpoint scenarios, existing white balance algorithms for captured frames suffer from inaccurate white balance parameter determination due to changes in ambient light, resulting in severe color cast and fluctuations.
The color channel values corresponding to the flash and the ambient light are determined based on at least one captured frame and a pre-selected non-captured frame. The target white balance of the current captured frame is determined by combining these values, and the white balance parameters are adjusted to take into account changes in ambient light.
It improves the accuracy of white balance parameters, enhances image display, and reduces color cast issues caused by changes in ambient light.
Smart Images

Figure CN116017175B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video surveillance technology, and provides a method, apparatus and storage medium for determining the white balance of a target. Background Technology
[0002] In intelligent transportation systems, checkpoint scenarios require high accuracy in capturing facial images inside vehicles. Traffic cameras used for facial capture are typically equipped with a flash to illuminate the captured frames. However, the color temperature of the flash usually differs significantly from the ambient color temperature, meaning that the white balance calculated for non-captured frames is unsuitable for captured frames. Therefore, special white balance processing is required for captured frames.
[0003] There are two main types of existing white balance algorithms for captured frames: ① Using the white balance of the previous captured frame and setting it for the next captured frame. This method can cause severe color cast problems when there is a sudden change in the color temperature of the environment after a long period of no capture, resulting in a large difference in color temperature between the two captured frames; ② Predicting the white balance of the next captured frame based on the non-captured frame and the previous captured frame. However, because non-captured frames are darker, their brightness statistics are easily affected by environmental factors such as high and low color temperature car lights and the color of the car itself, leading to severe color cast and fluctuation problems in the captured frames.
[0004] In summary, the influence of ambient light causes inaccurate determination of the white balance parameter. Summary of the Invention
[0005] This application provides a method, apparatus, and storage medium for determining target white balance, thereby improving the accuracy of white balance parameter determination and thus improving image display performance.
[0006] The specific technical solution provided in this application is as follows:
[0007] In a first aspect, embodiments of this application provide a method for determining a target white balance, including:
[0008] The first color channel value corresponding to the flash is determined based on at least one captured frame and pre-selected non-captured frames, wherein the captured frame is taken at a time when the flash emits light before the current time, and the difference between the shooting time of the pre-selected non-captured frames and the shooting time of at least one captured frame is less than a preset threshold.
[0009] The second color channel value corresponding to the ambient light is determined based on at least one non-capture frame, wherein the difference between the shooting time corresponding to the non-capture frame and the current time is less than a preset threshold, and the flash does not emit light at the shooting time.
[0010] The third color channel value of the current captured frame is determined based on the first color channel value and the second color channel value, and the target white balance is determined based on the third color channel value. The current captured frame is taken by the flash at the current moment of illumination.
[0011] If the change in ambient light exceeds the preset value, the target white balance will be used as the reference value for white in images captured by the flash after the current moment.
[0012] Optionally, the method further includes:
[0013] If the change in ambient light is not greater than the preset value, the alternative white balance is determined as the reference value of white in the image captured by the flash after the current moment. The alternative white balance is determined based on the color channel value corresponding to at least one captured frame.
[0014] Optionally, before determining the first color channel value corresponding to the flash based on at least one captured frame, the method further includes:
[0015] If it is determined that the flash has met the preset activation conditions and that the flash is not working properly, the preset exposure value is corrected based on the brightness value, where the brightness value is used to characterize the degree to which the flash is activated.
[0016] Alternatively, you can determine if the flash is working properly by:
[0017] Determine the exposure values of multiple white blocks in at least one captured frame;
[0018] The brightness value is determined based on the exposure value and the preset exposure value;
[0019] If the brightness value is greater than the preset brightness value, then the flash is working normally;
[0020] Otherwise, the flash is not working properly.
[0021] Optionally, the first color channel value corresponding to the flash is determined based on at least one captured frame and a pre-selected non-captured frame, including:
[0022] The first color mean is determined based on the color channel value of the white block corresponding to the first block and the preset exposure value in at least one captured frame.
[0023] The mean value of the preselected color is determined based on the color channel value of the preselected block corresponding to the white block in the preselected non-captured frame;
[0024] The R color channel value is obtained by subtracting the R color channel component value in the first color mean from the R color channel component value in the pre-selected color mean.
[0025] The G color channel value is obtained by subtracting the G color channel component value in the first color mean from the G color channel component value in the pre-selected color mean.
[0026] The B color channel value is obtained by subtracting the B color channel component value in the first color mean from the B color channel component value in the pre-selected color mean.
[0027] The first color channel value corresponding to the flash is determined based on the R color channel value, G color channel value, and B color channel value.
[0028] Optionally, determining the second color channel value corresponding to ambient light based on at least one non-captured frame includes:
[0029] The second color mean is determined based on the second color channel value corresponding to the white block in at least one non-captured frame.
[0030] The average value of the second color is determined as the value of the second color channel corresponding to the ambient light.
[0031] Optionally, the third color channel value of the current captured frame is determined based on the first color channel value and the second color channel value, including:
[0032] The R color channel value is obtained by adding the R color channel component value in the first color channel value to the R color channel component value in the second color channel value.
[0033] The G color channel value is obtained by adding the G color channel component value in the first color channel value to the G color channel component value in the second color channel value.
[0034] The B color channel value is obtained by adding the B color channel component value in the first color channel value to the B color channel component value in the second color channel value.
[0035] The third color channel value of the current captured frame is determined based on the R, G, and B color channel values.
[0036] Secondly, embodiments of this application also provide an apparatus for determining a target white balance, comprising:
[0037] The first determining unit is used to determine the first color channel value corresponding to the flash based on at least one captured frame and a pre-selected non-captured frame, wherein the captured frame is taken at a time when the flash emits light before the current time, and the difference between the shooting time of the pre-selected non-captured frame and the shooting time of at least one captured frame is less than a preset threshold.
[0038] The second determining unit is used to determine the second color channel value corresponding to the ambient light based on at least one non-capture frame, wherein the difference between the shooting time corresponding to the non-capture frame and the current time is less than a preset threshold, and the flash does not emit light at the shooting time.
[0039] The third determining unit is used to determine the third color channel value of the current captured frame based on the first color channel value and the second color channel value, and to determine the target white balance based on the third color channel value, wherein the current captured frame is captured by the flash at the current illumination moment;
[0040] The white balance determination unit is used to determine the target white balance as the reference value for white in images captured by the flash after the current moment if the change in ambient light is greater than a preset value.
[0041] Optionally, it also includes:
[0042] If the change in ambient light is not greater than the preset value, the alternative white balance is determined as the reference value of white in the image captured by the flash after the current moment. The alternative white balance is determined based on the color channel value corresponding to at least one captured frame.
[0043] Optionally, before determining the first color channel value corresponding to the flash based on at least one captured frame, the method further includes:
[0044] If it is determined that the flash has met the preset activation conditions and that the flash is not working properly, the preset exposure value is corrected based on the brightness value, where the brightness value is used to characterize the degree to which the flash is activated.
[0045] Alternatively, you can determine if the flash is working properly by:
[0046] Determine the exposure values of multiple white blocks in at least one captured frame;
[0047] The brightness value is determined based on the exposure value and the preset exposure value;
[0048] If the brightness value is greater than the preset brightness value, then the flash is working normally;
[0049] Otherwise, the flash is not working properly.
[0050] Optionally, the first color channel value corresponding to the flash is determined based on at least one captured frame and a pre-selected non-captured frame. The first determining unit is used for:
[0051] The first color mean is determined based on the color channel value of the white block corresponding to the first block and the preset exposure value in at least one captured frame.
[0052] The mean value of the preselected color is determined based on the color channel value of the preselected block corresponding to the white block in the preselected non-captured frame;
[0053] The R color channel value is obtained by subtracting the R color channel component value in the first color mean from the R color channel component value in the pre-selected color mean.
[0054] The G color channel value is obtained by subtracting the G color channel component value in the first color mean from the G color channel component value in the pre-selected color mean.
[0055] The B color channel value is obtained by subtracting the B color channel component value in the first color mean from the B color channel component value in the pre-selected color mean.
[0056] The first color channel value corresponding to the flash is determined based on the R color channel value, G color channel value, and B color channel value.
[0057] Optionally, the second color channel value corresponding to the ambient light is determined based on at least one non-captured frame, and the second determining unit is used for:
[0058] The second color mean is determined based on the second color channel value corresponding to the white block in at least one non-captured frame.
[0059] The average value of the second color is determined as the value of the second color channel corresponding to the ambient light.
[0060] Optionally, the third color channel value of the current captured frame is determined based on the first color channel value and the second color channel value. The third determining unit is used for:
[0061] The R color channel value is obtained by adding the R color channel component value in the first color channel value to the R color channel component value in the second color channel value.
[0062] The G color channel value is obtained by adding the G color channel component value in the first color channel value to the G color channel component value in the second color channel value.
[0063] The B color channel value is obtained by adding the B color channel component value in the first color channel value to the B color channel component value in the second color channel value.
[0064] The third color channel value of the current captured frame is determined based on the R, G, and B color channel values.
[0065] Thirdly, a smart terminal includes:
[0066] Memory, used to store executable instructions;
[0067] A processor for reading and executing executable instructions stored in memory to implement the method as described in any of the first aspects.
[0068] Fourthly, a computer-readable storage medium, when instructions in the storage medium are executed by a processor, enables the processor to perform the method described in any of the first aspects above.
[0069] The beneficial effects of this application are as follows:
[0070] In summary, the embodiments of this application provide a method, apparatus, and storage medium for determining target white balance. The method includes: determining a first color channel value corresponding to a flash based on at least one captured frame and pre-selected non-captured frames, wherein the captured frame is taken at a flash emission moment prior to the current moment, and the difference between the shooting moment of the pre-selected non-captured frames and the shooting moment of the at least one captured frame is less than a preset threshold; determining a second color channel value corresponding to ambient light based on at least one non-captured frame, wherein the difference between the shooting moment corresponding to the non-captured frame and the current moment is less than a preset threshold, and the flash does not emit light at the shooting moment; and determining the second color channel value based on the first color channel value and the second color channel value. The color channel value determines the third color channel value of the current captured frame, and the target white balance is determined based on the third color channel value. The current captured frame is taken by the flash at the current moment of illumination. If the change in ambient light is greater than a preset value, the target white balance is used as the reference value for white in images taken by the flash after the current moment. The above-mentioned scheme, which determines the third color channel value of the current captured frame based on the first color channel value corresponding to the flash and the second color channel value of the nearest ambient light when the ambient light changes significantly, and determines the target white balance based on the third color channel value, can make the determined white balance more accurate, thereby improving the display effect of the acquired image.
[0071] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0072] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0073] Figure 1 This is a schematic diagram of the system architecture for determining the target white balance in an embodiment of this application.
[0074] Figure 2 This is a schematic diagram of a process for determining the target white balance in an embodiment of this application;
[0075] Figure 3 This is a schematic diagram of the process for determining the first color channel value in an embodiment of this application;
[0076] Figure 4 This is a schematic diagram of the process for determining the second color channel value in an embodiment of this application;
[0077] Figure 5This is a schematic diagram of the process for determining the third color channel value in an embodiment of this application;
[0078] Figure 6 This is a schematic diagram of a process for determining target white balance based on changes in ambient light in an embodiment of this application;
[0079] Figure 7 This is a schematic diagram of the logic architecture of a device for determining target white balance in an embodiment of this application;
[0080] Figure 8 This is a schematic diagram of the physical architecture of a smart terminal according to an embodiment of this application. Detailed Implementation
[0081] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.
[0082] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in sequences other than those illustrated or described herein.
[0083] The preferred embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0084] See Figure 1 As shown in the embodiment of this application, the system includes at least one smart terminal and a monitoring device (e.g., a camera) that inputs image frames to the smart terminal. The monitoring device works in conjunction with a flash, that is, when the flash is on, the image acquired by the monitoring device is a snapshot frame; when the flash is off, the image acquired by the monitoring device is a non-capture frame. Both the snapshot frame and the non-capture frame are sent to the monitoring device for processing to determine the target white balance parameter, and the target white balance parameter is used as the reference value for white in the image captured by the flash after the current moment.
[0085] In this embodiment of the application, a method for determining the target white balance is mainly implemented on the smart terminal side, which will be described in detail below.
[0086] See Figure 2 As shown in the embodiments of this application, a specific process for determining the target white balance is as follows:
[0087] Step 201: Determine the first color channel value corresponding to the flash based on at least one captured frame and pre-selected non-capture frames, wherein the captured frame is taken at a time when the flash emits light before the current time, and the difference between the shooting time of the pre-selected non-capture frames and the shooting time of at least one captured frame is less than a preset threshold.
[0088] Typically, the flash is turned on at fixed intervals, and correspondingly, it is turned off at the same fixed intervals. That is, during the operation of the flash, after the monitoring device acquires one (or more) non-capture frames, it will acquire one (or more) capture frames. Obviously, the non-capture frames are images obtained by combining only the ambient light, while the capture frames are images obtained by combining the flash light and the ambient light.
[0089] In this embodiment, the first color channel value corresponding to the flash is determined by capturing a frame and not capturing a frame. That is, by subtracting an image that combines the light from the flash and the ambient light, and an image that only combines the ambient light, we obtain an image equivalent to the light from only the flash.
[0090] It should be noted that, to ensure the accuracy of the first color channel value determination, the aforementioned captured frames and pre-selected non-capture frames are typically within the time range corresponding to the aforementioned fixed interval. This effectively avoids the influence of ambient light changes on the determination of the first color channel value. Specifically, the captured frame is taken at a time when the flash fires before the current moment. The difference between the shooting time of the pre-selected non-capture frames and the shooting time of the aforementioned captured frames is less than a preset threshold, which is typically no greater than the aforementioned fixed interval.
[0091] Additionally, it should be noted that, in order to ensure the accuracy of the determination of the first color channel value, the number of the above-mentioned captured frames and pre-selected non-captured frames can be multiple frames, that is, the concept of average value is used for calculation.
[0092] Considering that the flash's on / off state is related to ambient light—that is, the flash does not work when the ambient light brightness is below the flash's rated brightness (i.e., the ambient light is relatively bright), and the flash works when the ambient light brightness reaches the flash's rated brightness (i.e., the ambient light is relatively dim)—and that the flash's on / off state needs to remain consistent even when the ambient light is stable, the process of determining the first color channel value corresponding to the flash based on at least one captured frame also includes:
[0093] If it is determined that the flash has met the preset activation conditions and that the flash is not working properly, the preset exposure value is corrected based on the brightness value, where the brightness value is used to characterize the degree to which the flash is activated.
[0094] During implementation, it is necessary to first determine whether the flash has met the preset activation conditions (e.g., ambient light is less than XX value). Usually, the flash can meet the preset activation conditions under the corresponding ambient light conditions at night, that is, the flash should be able to work normally at night.
[0095] Considering that the flash unit may malfunction at any time, and that ambient light may change suddenly (e.g., due to the influence of headlights), it is necessary to further determine whether the flash unit is working properly. This can be done by using the following methods:
[0096] (1) Determine the exposure values of multiple white blocks in at least one captured frame.
[0097] During implementation, after acquiring at least one capture frame, multiple white blocks are acquired in each capture frame. For each white block in the same frame, the exposure values corresponding to the R channel, G channel, and R channel are superimposed, and the sum of the superimposed exposure values is divided by the number of white blocks to obtain the exposure value for that frame of image.
[0098] (2) Determine the brightness value based on the exposure value and the preset exposure value.
[0099] After determining the exposure value of the frame image, the exposure value of the frame image is compared with the aforementioned preset exposure value (for example, by subtraction or quotient), and then compared with the preset brightness corresponding to the preset exposure value to determine the brightness value corresponding to the exposure value.
[0100] (3) If the brightness value is greater than the preset brightness value, then the flash is working normally.
[0101] During implementation, if the brightness value is greater than the preset brightness value, it indicates that the formation of that frame image involved the flash, confirming that the flash is working properly. When it is confirmed that the flash is working properly, the default preset exposure value corresponding to the flash is the standard value for acquiring the image, meaning that there is no need to correct the preset exposure value.
[0102] (4) Otherwise, the flash is not working properly.
[0103] During implementation, if the brightness value is not greater than the preset brightness value, it indicates that the formation of that frame image did not involve the flash, meaning the flash is not working properly, for example, the flash is not fully activated. When it is determined that the flash is not working properly, the preset exposure value needs to be corrected. During implementation, the brightness value is determined based on the current flash activation level, and this brightness value is used to correct the preset exposure value, thus unifying the flash's working state through correction.
[0104] The specific correction process includes: first, using the above brightness value and the preset exposure value to obtain the exposure multiplier, and then using the above exposure multiplier for correction. Among them, the above brightness value is calculated based on the shutter speed and gain. Assuming that the current shutter speed corresponding to the current frame is cur_shut (in lines) and the current gain is cur_gain (in dB), the preset shutter speed corresponding to the preset exposure value is yushe_shut and the preset gain is yushe_gain, then the exposure multiplier X is obtained using the following formula (1): (After the flash reaches the preset opening conditions, the aperture and filter are basically fixed, so they are not included in the calculation)
[0105]
[0106] When the flash is working normally, the value of the exposure factor X is 1; when the flash is not working normally, the value of the exposure factor X is not 1. The flash can be calibrated by dividing the preset exposure value by the exposure factor X determined based on the brightness value. The flash parameters can be unified through the calibration process.
[0107] Under stable ambient light conditions, the first color channel value corresponding to the flash is determined using at least one captured frame and a pre-selected non-captured frame within the same fixed interval. For details, please refer to [link / reference]. Figure 3 As shown, the first color channel value corresponding to the flash is determined based on at least one captured frame and pre-selected non-captured frames, including:
[0108] Step 2011: Determine the first color mean based on the first color channel value corresponding to the white block in at least one captured frame and the preset exposure value.
[0109] Since each of the at least one captured frame within the same fixed interval is generated under the combined effect of flash light and ambient light, during implementation, at least one white block is selected in each captured frame. For each white block, the channel values corresponding to each channel, such as the R channel, G channel, and B channel, are calculated. The channel sum value corresponding to each channel, such as the R channel, G channel, and B channel, is obtained by summing the channel values corresponding to the white block. Considering that there is at least one white block in each captured frame, the channel sum values corresponding to multiple white blocks are then superimposed and averaged with the number of white blocks, and then averaged again with the number of captured frames to obtain the first color channel value mentioned above.
[0110] Meanwhile, in order to avoid the influence of different flash activation levels on the color channel values for different capture frames, the first color channel value is divided by the preset exposure value during implementation to determine the first color average value.
[0111] Step 2012: Determine the average value of the preselected color based on the color channel value of the preselected block corresponding to the white block in the preselected non-captured frame.
[0112] The aforementioned pre-selected non-capture frames within the same fixed interval are generated under the influence of ambient light. During implementation, at least one white block is selected in each pre-selected non-capture frame. For each white block, the channel values corresponding to each channel, such as the R channel, G channel, and B channel, are calculated. The channel sum value corresponding to the R channel, G channel, and B channel is obtained by summing the channel values corresponding to the white block. Considering that there is at least one white block in each pre-selected non-capture frame, the channel sum values corresponding to multiple white blocks are then superimposed and averaged with the number of white blocks. That is, the pre-selected block color channel value is averaged again with the number of pre-selected non-capture frames to obtain the aforementioned pre-selected color average value.
[0113] Step 2013: Subtract the R color channel component value in the first color mean from the R color channel component value in the pre-selected color mean to obtain the R color channel value.
[0114] During implementation, after obtaining the first color mean for the captured frame, the R color channel component value is extracted from the first color mean. Similarly, after obtaining the pre-selected color mean for the pre-selected non-captured frame, the R color channel component value is extracted from the pre-selected color mean. The R color channel value is obtained by subtracting the R color channel component value with the combined effect of the flash light and ambient light from the R color channel component value with only the effect of ambient light.
[0115] Step 2014: Subtract the G color channel component value in the first color mean from the G color channel component value in the pre-selected color mean to obtain the G color channel value.
[0116] Similarly, after obtaining the first color mean for the captured frame, the G color channel component value is extracted from the first color mean. After obtaining the pre-selected color mean for the pre-selected non-captured frame, the G color channel component value is extracted from the pre-selected color mean. The difference between the G color channel component value that combines the effects of the flash and ambient light and the G color channel component value that only has the effect of ambient light is obtained.
[0117] Step 2015: Subtract the B color channel component value in the first color mean from the B color channel component value in the pre-selected color mean to obtain the B color channel value.
[0118] Similarly, after obtaining the first color mean for the captured frame, the B color channel component value is extracted from the first color mean. After obtaining the pre-selected color mean for the pre-selected non-captured frame, the B color channel component value is extracted from the pre-selected color mean. The B color channel value is obtained by subtracting the B color channel component value with the combined effect of the flash light and ambient light from the B color channel component value with only the effect of ambient light.
[0119] Step 2016: Determine the first color channel value corresponding to the flash based on the R color channel value, G color channel value, and B color channel value.
[0120] During implementation, after obtaining the R, G, and B color channel values for only the flash lighting effect, these values are summed to determine the first color channel value corresponding to the flash.
[0121] Since ambient light changes continuously under normal circumstances, after determining the first color channel value corresponding to the flash, it is necessary to further determine the second color channel value by combining the latest ambient light, and then combine the first color channel value and the second color channel value to determine the target white balance.
[0122] Step 202: Determine the second color channel value corresponding to the ambient light based on at least one non-capture frame, wherein the difference between the shooting time corresponding to the non-capture frame and the current time is less than a preset threshold, and the flash does not emit light at the shooting time.
[0123] In order to obtain the latest second color channel value corresponding to the ambient light, during the implementation process, a non-capture frame corresponding to the shooting time with a difference of less than a preset threshold is first selected. Preferably, the preset threshold is less than or equal to a fixed interval, and the flash is not emitting light during the shooting time.
[0124] After determining at least one non-captured frame, the second color channel value corresponding to the ambient light is further determined based on the aforementioned at least one non-captured frame.
[0125] See Figure 4 As shown, determining the second color channel value corresponding to ambient light based on at least one non-captured frame includes:
[0126] Step 2021: Determine the second color mean based on the second color channel value corresponding to the white block in at least one non-captured frame.
[0127] During implementation, at least one white block is selected in each non-capture frame. For each white block, the channel values corresponding to each channel, such as the R channel, G channel, and B channel, are calculated. The sum of the channel values corresponding to the R channel, G channel, and B channel is then used to obtain the total value of the channel corresponding to the white block.
[0128] Considering that there are multiple white blocks in each non-capture frame, the sum of the channel values corresponding to each white block is superimposed and then averaged with the number of non-capture frames to obtain the second color mean value mentioned above.
[0129] Step 2022: Determine the second color mean as the second color channel value corresponding to the ambient light.
[0130] During implementation, the calculated average value of the second color is determined as the second color channel value corresponding to the ambient light, thus obtaining the second color channel value corresponding to the ambient light closest to the current moment.
[0131] Step 203: Determine the third color channel value of the current captured frame based on the first color channel value and the second color channel value, and determine the target white balance based on the third color channel value. The current captured frame is captured by the flash at the current time of illumination.
[0132] During implementation, after determining the first color channel value corresponding to the flash itself and the second color channel value corresponding to the nearest ambient light, the third color channel value of the current capture frame is further determined by combining the first and second color channel values. It should be noted that the aforementioned current capture frame is taken at the current moment the flash is emitting light, and the white balance of this current capture frame serves as the reference value for white in images captured by the flash after this moment.
[0133] For details, please refer to Figure 5 As shown, the third color channel value of the current captured frame is determined based on the first and second color channel values, including:
[0134] Step 2031: Add the R color channel component value in the first color channel value to the R color channel component value in the second color channel value to obtain the R color channel value.
[0135] To obtain the third color channel value of the current captured frame, during the process, the R color channel component value in the first color channel value representing the lighting effect of the flash and the R color channel component in the second color channel value representing the nearest ambient light are determined respectively. The two determined R color channel component values are added together to obtain the R color channel value.
[0136] Step 2032: Add the G color channel component value in the first color channel value to the G color channel component value in the second color channel value to obtain the G color channel value.
[0137] Similarly, during implementation, the G color channel component value in the first color channel value representing the lighting effect of the flash lamp and the G color channel component value in the second color channel value representing the nearest ambient light are determined separately. The two determined G color channel component values are added together to obtain the G color channel value.
[0138] Step 2033: Add the B color channel component value in the first color channel value to the B color channel component value in the second color channel value to obtain the B color channel value.
[0139] Similarly, during implementation, the B color channel component value in the first color channel value representing the lighting effect of the flash lamp and the B color channel component value in the second color channel value representing the nearest ambient light are determined separately. The two determined B color channel component values are added together to obtain the B color channel value.
[0140] Step 2034: Determine the third color channel value of the current captured frame based on the R color channel value, G color channel value, and B color channel value.
[0141] During the implementation process, after obtaining the R color channel value, G color channel value, and B color channel value, the R color channel value, G color channel value, and B color channel value are summed to determine the third color channel value corresponding to the current captured frame. Obviously, the third color channel value here is the result of the combined effect of the flash light and the nearest ambient light.
[0142] In this embodiment of the application, after determining the third color channel value, the target white balance is further determined based on the third color channel value. Specifically, it is assumed that the equivalent color channel values corresponding to the R channel, G channel and B channel in the third color channel value are R3, G3 and B3 respectively. In this way, the target white balance (Rgain1, Bgain1) can be calculated using formula (2) and formula (3) respectively:
[0143]
[0144]
[0145] Step 204: If the change in ambient light is greater than the preset value, the target white balance is used as the reference value for white in the image captured by the flash after the current moment.
[0146] After determining the target white balance corresponding to the current capture frame, compare whether the change value of the ambient light is greater than the preset value. For example, the ambient light values corresponding to two non-capture frames that are close to the current time can be selected. The difference or quotient of the two ambient light values can be used to obtain the change value. Then compare whether the change value is greater than the preset value. If the change value is greater than the preset value, it means that the change of the ambient light is relatively large. It is necessary to adjust the white balance of the current capture frame in combination with the most recent ambient light. That is, the target white balance is used as the reference value of white in the image captured by the flash after the current time.
[0147] Considering that ambient light may be affected by unexpected events, such as vehicle headlights causing flash overexposure, to ensure the accuracy of the white baseline value in images taken later, please refer to... Figure 6 As shown, the method also includes:
[0148] Step 205: If the change in ambient light is not greater than the preset value, the alternative white balance is determined as the reference value of white in the image captured by the flash after the current moment. The alternative white balance is determined based on the color channel value corresponding to at least one captured frame.
[0149] Similarly, after determining the target white balance corresponding to the current capture frame, the change value of ambient light is compared to see if it is greater than the preset value. The method for obtaining the change value of ambient light will not be repeated here. During the implementation process, if the change value is not greater than the preset value, it means that the change of ambient light is relatively small, that is, the ambient light is relatively stable. In this case, the alternative white balance is determined as the reference value of white in the image captured by the flash after the current moment, thereby effectively avoiding the influence of sudden changes in ambient light caused by other influencing factors.
[0150] It should be noted that the above alternative white balance is determined based on the color channel value corresponding to at least one captured frame. Preferably, the above alternative white balance is calculated from the color channel values corresponding to each captured frame at a time when the ambient light is stable. The calculation process will not be described in detail.
[0151] Based on the same inventive concept, see [reference] Figure 7 As shown in the figure, this application provides an apparatus for determining a target white balance, comprising:
[0152] The first determining unit 701 is used to determine the first color channel value corresponding to the flash based on at least one captured frame and a pre-selected non-captured frame, wherein the captured frame is taken at a time when the flash emits light before the current time, and the difference between the shooting time of the pre-selected non-captured frame and the shooting time of at least one captured frame is less than a preset threshold.
[0153] The second determining unit 702 is used to determine the second color channel value corresponding to the ambient light based on at least one non-capture frame, wherein the difference between the shooting time corresponding to the non-capture frame and the current time is less than a preset threshold, and the flash does not emit light at the shooting time.
[0154] The third determining unit 703 is used to determine the third color channel value of the current captured frame based on the first color channel value and the second color channel value, and to determine the target white balance based on the third color channel value, wherein the current captured frame is captured by the flash at the current illumination moment;
[0155] The white balance determination unit 704 is used to determine the target white balance as the reference value for white in an image captured by the flash after the current moment if the change value of the ambient light is greater than the preset value.
[0156] Optionally, it also includes:
[0157] If the change in ambient light is not greater than the preset value, the alternative white balance is determined as the reference value of white in the image captured by the flash after the current moment. The alternative white balance is determined based on the color channel value corresponding to at least one captured frame.
[0158] Optionally, before determining the first color channel value corresponding to the flash based on at least one captured frame, the method further includes:
[0159] If it is determined that the flash has met the preset activation conditions and that the flash is not working properly, the preset exposure value is corrected based on the brightness value, where the brightness value is used to characterize the degree to which the flash is activated.
[0160] Alternatively, you can determine if the flash is working properly by:
[0161] Determine the exposure values of multiple white blocks in at least one captured frame;
[0162] The brightness value is determined based on the exposure value and the preset exposure value;
[0163] If the brightness value is greater than the preset brightness value, then the flash is working normally;
[0164] Otherwise, the flash is not working properly.
[0165] Optionally, the first color channel value corresponding to the flash is determined based on at least one captured frame and a pre-selected non-captured frame. The first determining unit 701 is used for:
[0166] The first color mean is determined based on the color channel value of the white block corresponding to the first block and the preset exposure value in at least one captured frame.
[0167] The mean value of the preselected color is determined based on the color channel value of the preselected block corresponding to the white block in the preselected non-captured frame;
[0168] The R color channel value is obtained by subtracting the R color channel component value in the first color mean from the R color channel component value in the pre-selected color mean.
[0169] The G color channel value is obtained by subtracting the G color channel component value in the first color mean from the G color channel component value in the pre-selected color mean.
[0170] The B color channel value is obtained by subtracting the B color channel component value in the first color mean from the B color channel component value in the pre-selected color mean.
[0171] The first color channel value corresponding to the flash is determined based on the R color channel value, G color channel value, and B color channel value.
[0172] Optionally, the second color channel value corresponding to the ambient light is determined based on at least one non-captured frame, and the second determining unit 702 is used for:
[0173] The second color mean is determined based on the second color channel value corresponding to the white block in at least one non-captured frame.
[0174] The average value of the second color is determined as the value of the second color channel corresponding to the ambient light.
[0175] Optionally, the third color channel value of the current captured frame is determined based on the first color channel value and the second color channel value, and the third determining unit 703 is used for:
[0176] The R color channel value is obtained by adding the R color channel component value in the first color channel value to the R color channel component value in the second color channel value.
[0177] The G color channel value is obtained by adding the G color channel component value in the first color channel value to the G color channel component value in the second color channel value.
[0178] The B color channel value is obtained by adding the B color channel component value in the first color channel value to the B color channel component value in the second color channel value.
[0179] The third color channel value of the current captured frame is determined based on the R, G, and B color channel values.
[0180] Based on the same inventive concept, see [reference] Figure 8 As shown, this application embodiment provides a smart terminal, including: a memory 801 for storing executable instructions; and a processor 802 for reading and executing the executable instructions stored in the memory, and executing any of the methods described in the first aspect above.
[0181] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium that, when the instructions in the storage medium are executed by a processor, enables the processor to perform the method described in any of the first aspects above.
[0182] In summary, the embodiments of this application provide a method, apparatus, and storage medium for determining target white balance. The method includes: determining a first color channel value corresponding to a flash based on at least one captured frame and pre-selected non-captured frames, wherein the captured frame is taken at a flash emission time prior to the current time, and the difference between the shooting time of the pre-selected non-captured frames and the shooting time of the at least one captured frame is less than a preset threshold; determining a second color channel value corresponding to ambient light based on at least one non-captured frame, wherein the difference between the shooting time of the non-captured frame and the current time is less than a preset threshold, and the flash does not emit light at the shooting time; and determining the second color channel value based on the first color channel value and the second color channel value. The color channel value determines the third color channel value of the current captured frame, and the target white balance is determined based on the third color channel value. The current captured frame is taken by the flash at the current moment of illumination. If the change in ambient light is greater than a preset value, the target white balance is used as the reference value for white in images taken by the flash after the current moment. The above-mentioned scheme, which determines the third color channel value of the current captured frame based on the first color channel value corresponding to the flash and the second color channel value of the nearest ambient light when the ambient light changes significantly, and determines the target white balance based on the third color channel value, can make the determined white balance more accurate, thereby improving the display effect of the acquired image.
[0183] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program product systems. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product system implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0184] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program product systems according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.
[0185] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0186] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0187] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for determining target white balance, characterized in that, The method includes: The first color channel value corresponding to the flash is determined based on at least one captured frame and a pre-selected non-captured frame, wherein the captured frame is taken at a time when the flash was emitted before the current time, the difference between the shooting time of the pre-selected non-captured frame and the shooting time of the at least one captured frame is less than a preset threshold, and the first color channel value is determined based on a first color mean, which is obtained by dividing the first color channel value corresponding to the white block in the at least one captured frame by a preset exposure value. Based on the second color channel value corresponding to the white block in at least one non-capture frame, a second color mean is determined, and the second color mean is determined as the second color channel value corresponding to the ambient light. The difference between the shooting time corresponding to the non-capture frame and the current time is less than a preset threshold, and the flash does not emit light at the shooting time. The third color channel value of the current captured frame is determined based on the first color channel value and the second color channel value, and the target white balance is determined based on the third color channel value, wherein the current captured frame is captured by the flash at the current illumination moment; If the change in ambient light exceeds a preset value, the target white balance will be used as the reference value for white in images captured by the flash after the current moment. Before determining the first color channel value corresponding to the flash based on at least one captured frame and a pre-selected non-captured frame, the process also includes: If it is determined that the flash meets the preset activation conditions and the brightness value is not greater than the preset brightness value, then use the formula... Calculate the exposure factor and update the current preset exposure value using the exposure factor, where X is the exposure factor, cur_shut is the current shutter speed corresponding to the current frame, cur_gain is the current gain, yushe_shut is the preset shutter speed corresponding to the current preset exposure value, yushe_gain is the preset gain, and the brightness value is determined based on the exposure values of multiple white blocks in at least one captured frame and the current preset exposure value.
2. The method as described in claim 1, characterized in that, The method further includes: If the change in ambient light is not greater than a preset value, the alternative white balance is determined as the reference value of white in the image captured by the flash after the current moment, wherein the alternative white balance is determined based on the color channel value corresponding to the at least one captured frame.
3. The method as described in claim 2, characterized in that, To confirm that the flash is working properly, use the following methods: If the brightness value is greater than the preset brightness value, then the flash is determined to be working normally.
4. The method as described in claim 2, characterized in that, The step of determining the first color channel value corresponding to the flash based on at least one captured frame and pre-selected non-captured frames includes: The average value of the preselected color is determined based on the color channel value of the preselected block corresponding to the white block in the preselected non-captured frame; The R color channel value is obtained by subtracting the R color channel component value in the first color mean from the R color channel component value in the pre-selected color mean. The G color channel value is obtained by subtracting the G color channel component value in the first color mean from the G color channel component value in the pre-selected color mean. The B color channel value is obtained by subtracting the B color channel component value in the first color mean from the B color channel component value in the pre-selected color mean. Based on the R color channel value, the G color channel value, and the B color channel value, the first color channel value corresponding to the flash is determined.
5. The method according to any one of claims 1 to 4, characterized in that, Determining the third color channel value of the current captured frame based on the first color channel value and the second color channel value includes: The R color channel component value in the first color channel value is added to the R color channel component value in the second color channel value to obtain the R color channel value; Add the G color channel component value in the first color channel value to the G color channel component value in the second color channel value to obtain the G color channel value; Add the B color channel component value in the first color channel value to the B color channel component value in the second color channel value to obtain the B color channel value; The third color channel value of the current captured frame is determined based on the R color channel value, the G color channel value, and the B color channel value.
6. An apparatus for determining target white balance, characterized in that, include: The first determining unit is configured to determine the first color channel value corresponding to the flash based on at least one captured frame and a pre-selected non-captured frame, wherein the captured frame is taken at a flash time before the current time, the difference between the shooting time of the pre-selected non-captured frame and the shooting time of the at least one captured frame is less than a preset threshold, and the first color channel value is determined based on a first color mean, which is obtained by dividing the first color channel value corresponding to the white block in the at least one captured frame by a preset exposure value. The second determining unit is used to determine a second color average value based on the second color channel value corresponding to the white block in at least one non-capture frame, and to determine the second color average value as the second color channel value corresponding to the ambient light, wherein the difference between the shooting time corresponding to the non-capture frame and the current time is less than a preset threshold, and the flash does not emit light at the shooting time. The third determining unit is used to determine the third color channel value of the current captured frame based on the first color channel value and the second color channel value, and to determine the target white balance based on the third color channel value, wherein the current captured frame is captured by the flash at the current illumination moment; The white balance determination unit is used to take the target white balance as the reference value for white in the image captured by the flash after the current moment if the change value of the ambient light is greater than the preset value. The first correction unit is configured to, before determining the first color channel value corresponding to the flash based on at least one captured frame and a pre-selected non-captured frame, determine that the flash meets the preset activation conditions and that the brightness value is not greater than the preset brightness value, then use the formula... Calculate the exposure factor and update the current preset exposure value using the exposure factor, where X is the exposure factor, cur_shut is the current shutter speed corresponding to the current frame, cur_gain is the current gain, yushe_shut is the preset shutter speed corresponding to the current preset exposure value, yushe_gain is the preset gain, and the brightness value is determined based on the exposure values of multiple white blocks in at least one captured frame and the current preset exposure value.
7. A smart terminal, characterized in that, include: Memory, used to store executable instructions; A processor for reading and executing executable instructions stored in the memory to implement the method as described in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor, the processor is able to perform the method as described in any one of claims 1-5.