Method for detecting light leakage of screen, method for detecting ambient light, and apparatus for detecting ambient light
The present disclosure provides a method for detecting light leakage of a screen, a method for detecting ambient light, and an apparatus for detecting ambient light. The method for detecting light leakage of a screen includes: acquiring display parameters of a screen, the display parameters including: a brightness value of the screen and grayscale values of respective pixel points within a preset display region of the screen; inputting the display parameters into a pre-trained neural network model, to process the display parameters using the neural network model, to obtain light leakage values corresponding to the respective pixel points; and obtaining a light leakage value of the screen based on the light leakage values corresponding to the respective pixel points. Based on the above technical solutions, the light leakage value of the screen can be accurately and reliably determined.
1. A method for detecting light leakage of a screen, applied to an electronic device, comprising:
acquiring display parameters of a screen, the display parameters comprising: a brightness value of the screen and grayscale values of respective pixel points within a preset display region of the screen; wherein acquiring the display parameters of the screen comprises: reading the brightness value of the screen from an operating system of the electronic device by using a system interface; and capturing a display content within the preset display region on the screen by using a screenshot software to obtain the grayscale values of the respective pixel points within the preset display region;
inputting the display parameters into a pre-trained neural network model, to process the display parameters using the neural network model, to obtain light leakage values corresponding to the respective pixel points; wherein the pre-trained neural network model represents an internal correlation between the brightness value of the screen and the grayscale value of the respective pixel points and the light leakage values of the pixel points; and
obtaining a light leakage value of the screen based on the light leakage values corresponding to the respective pixel points, for correcting an ambient light value detected by a light sensor provided below the screen.
2. The detection method according to claim 1 , wherein the neural network model comprises a plurality of light leakage detection sub-models, wherein each of the light leakage detection sub-models corresponds to a target brightness interval; and
the inputting the display parameters into the pre-trained neural network model, to process the display parameters using the neural network model, to obtain the light leakage values corresponding to the respective pixel points, comprises:
determining a target brightness interval in which the brightness value is located; and
inputting the display parameters into a light leakage detection sub-model corresponding to the target brightness interval, to process the display parameters using the light leakage detection sub-model, to obtain the light leakage values corresponding to the respective pixel points.
3. The detection method according to claim 1 , wherein the neural network model comprises a residual module, the residual module comprises a plurality of fully connected units, the plurality of fully connected units is sequentially connected in series, a skip connection exists between the plurality of fully connected units, and the skip connection comprises a connection between two non-adjacent fully connected units.
4. The detection method according to claim 3 , wherein the skip connection is a skip connection between a first fully connected unit and a last fully connected unit among the plurality of fully connected units.
5. The detection method according to claim 3 , wherein a number of the residual module is plural, the neural network model further comprises a first fully connected module and a second fully connected module, and the plurality of residual modules is cascade-connected and is located between the first fully connected module and the second fully connected module.
6. The detection method according to claim 3 , wherein each of the fully connected units comprises a fully connected layer, batch normalization, and an activation function.
7. The detection method according to claim 1 , wherein a training process of the neural network model comprises:
establishing an initial neural network model;
acquiring sample display parameters and a sample light leakage value of the screen;
inputting the sample display parameters into the initial neural network model to obtain a predicted light leakage value;
obtaining a loss value of the initial neural network model based on the predicted light leakage value and the sample light leakage value; and
training the initial neural network model based on the loss value, to obtain the neural network model.
8. The detection method according to claim 7 , wherein the neural network model comprises a plurality of output channels, the predicted light leakage value comprises a plurality of predicted channel light leakage values, one of the predicted channel light leakage values corresponds to one of the output channels, the sample light leakage value comprises a plurality of sample channel light leakage values, and one of the sample channel light leakage values corresponds to one of the output channels; and
the obtaining the loss value of the initial neural network model based on the predicted light leakage value and the sample light leakage value comprises:
obtaining, for each of the output channels, a loss value corresponding to the output channel based on a predicted channel light leakage value and a sample channel light leakage value corresponding to the output channel; and
fusing the loss values corresponding to the plurality of output channels to obtain the loss value of the initial neural network model.
9. The detection method according to claim 8 , wherein the detection method further comprises: performing integer quantization on the neural network model, and storing the quantized neural network model.
10. The detection method according to claim 1 , wherein the preset display region is a light detection region of the screen, and the light detection region corresponds to a position of a light sensor provided below the screen.
11. The detection method according to claim 1 , wherein the obtaining the light leakage value of the screen based on the light leakage values corresponding to the respective pixel points comprises:
acquiring light leakage weight values of the respective pixel points, wherein the light leakage weight value of each of the respective pixel points is associated with a relative position between the pixel point and the light sensor provided below the screen; and
determining the light leakage value of the screen based on the light leakage values corresponding to the respective pixel points and the light leakage weight values of the respective pixel points.
12. A method for detecting ambient light, comprising:
determining a light leakage value of a screen based on the method for detecting light leakage of a screen according to claim 1 ;
acquiring a light sensitivity value detected by a light sensor provided below the screen; and
determining a real ambient light value based on the light sensitivity value and the light leakage value.
13. An apparatus for detecting ambient light, comprising: a processor and a memory storing a computer program thereon, wherein the computer program, when executed by a processor, implements operations of:
acquiring display parameters of a screen, the display parameters comprising: a brightness value of the screen and grayscale values of respective pixel points within a preset display region of the screen; wherein acquiring the display parameters of the screen comprises: reading the brightness value of the screen from an operating system of the electronic device by using a system interface; and capturing a display content within the preset display region on the screen by using a screenshot software to obtain the grayscale values of the respective pixel points within the preset display region;
inputting the display parameters into a pre-trained neural network model, to process the display parameters using the neural network model, to obtain light leakage values corresponding to the respective pixel points; wherein the pre-trained neural network model represents an internal correlation between the brightness value of the screen and the grayscale value of the respective pixel points and the light leakage values of the pixel points; and
obtaining a light leakage value of the screen based on the light leakage values corresponding to the respective pixel points, for correcting an ambient light value detected by a light sensor provided below the screen;
acquiring a light sensitivity value detected by a light sensor provided below the screen; and
determining a real ambient light value based on the light sensitivity value and the light leakage value.