Term " first ", " second ", " third " and " the 4th " in description and claims of this specification etc. are to use
In the different object of difference, rather than it is used for the particular order of description object.For example, the first difference, the second difference, third difference
It is rather than the particular order for describing difference for distinguishing different differences with the 4th difference etc..
In embodiments of the present invention, " illustrative " or " such as " etc. words for indicate make example, illustration or explanation.This
Be described as in inventive embodiments " illustrative " or " such as " any embodiment or design scheme be not necessarily to be construed as comparing
Other embodiments or design scheme more preferably or more advantage.Specifically, use " illustrative " or " such as " etc. words purport
Related notion is being presented in specific ways.
In the description of the embodiment of the present invention, unless otherwise indicated, the meaning of " plurality " is refer to two or more,
For example, multiple processing units refer to two or more processing unit;Multiple element refers to two or more
Element etc..
The embodiment of the present invention provides a kind of method for obtaining ambient light intensity, in embodiments of the present invention, by obtaining the
One difference, first difference are the absolute value of the difference of first environment luminous intensity measurement value and second environment luminous intensity measurement value,
The first environment luminous intensity measurement value be first time period in, terminal device show first object image when, the terminal of measurement
The environmental light intensity angle value of equipment local environment, the second environment luminous intensity measurement value are in second time period, and terminal device is shown
When the second target image, the environmental light intensity angle value of the terminal device local environment of measurement, the second time period and this first when
Between section duration it is identical;The second difference is obtained, which is the absolute value of the difference of the first grayscale value and target gray scale value,
First grayscale value be the first object image grayscale value, the target gray scale value be second grayscale value or be to this first
For grayscale value through target treated grayscale value, which is the grayscale value of second target image, first grayscale value
It is different from the target gray scale value;According to the first environment luminous intensity measurement value, first difference, second difference and this first
Grayscale value calculates target environment light intensity value.In the program, first environment luminous intensity measurement value and second environment luminous intensity measurement
Value includes at least actual environment light intensity value and corresponding screen reflection luminous intensity respectively, due to first time period and the second time
The duration of section is identical, if the duration is shorter, in first time period and in second time period, environment locating for terminal device
Actual environment light intensity value is constant, and the variable quantity of the intensity value of screen light is the second difference, first environment luminous intensity measurement value and
The absolute value of the difference of second environment luminous intensity measurement value is the first difference, therefore, the first difference (difference of ambient light measurement value
Value) it is by caused by the second difference (variation of screen light intensity value), then terminal device can be according to the first grayscale value, first poor
Target environment light intensity value is calculated in value, the second difference and first environment luminous intensity measurement value, compared to first environment light
Intensity measurements or second environment luminous intensity measurement value, target environment light intensity value closer to actual environment light intensity value, from
And can be improved the measurement accuracy referred to the ambient light intensity of environment locating for terminal device, it can solve prior art environment light
Testing result inaccuracy problem.
Below by taking Android operation system as an example, the method provided in an embodiment of the present invention for obtaining ambient light intensity is introduced
Applied software environment.
As shown in Figure 1, being a kind of configuration diagram of possible Android operation system provided in an embodiment of the present invention.Scheming
In 1, the framework of Android operation system includes 4 layers, be respectively as follows: application layer, application framework layer, system Runtime Library layer and
Inner nuclear layer (is specifically as follows Linux inner core).
Wherein, application layer includes each application program (including system application and in Android operation system
Tripartite's application program).
Application framework layer is the frame of application program, and developer can be in the exploitation for the frame for abiding by application program
In the case where principle, some application programs are developed based on application framework layer.
System Runtime Library layer includes library (also referred to as system library) and Android operation system running environment.Library is mainly Android behaviour
As system it is provided needed for all kinds of resources.Android operation system running environment is used to provide software loop for Android operation system
Border.
Inner nuclear layer is the operating system layer of Android operation system, belongs to the bottom of Android operation system software level.It is interior
Stratum nucleare provides core system service and hardware-related driver based on linux kernel for Android operation system.
By taking Android operation system as an example, in the embodiment of the present invention, developer can be based on above-mentioned Android as shown in Figure 1
The software program of the method provided in an embodiment of the present invention for obtaining ambient light intensity is realized in the system architecture of operating system, exploitation,
So that the method for the acquisition ambient light intensity can be run based on Android operation system as shown in Figure 1.I.e. processor or
Person's terminal can realize acquisition environment light provided in an embodiment of the present invention by running the software program in Android operation system
The method of intensity.
Terminal device in the embodiment of the present invention can be mobile terminal device, or immobile terminal equipment.It moves
Dynamic terminal device can be mobile phone, tablet computer, laptop, palm PC, car-mounted terminal, wearable device, super shifting
Dynamic personal computer (ultra-mobile personal computer, UMPC), net book or personal digital assistant
(personal digital assistant, PDA) etc.;Immobile terminal equipment can be personal computer (personal
Computer, PC), television set (television, TV), automatic teller machine or self-service machine etc.;The embodiment of the present invention does not limit specifically
It is fixed.
The executing subject of the method provided in an embodiment of the present invention for obtaining ambient light intensity can be above-mentioned terminal device
(including mobile terminal device and immobile terminal equipment), or can be realized the function mould of this method in the terminal device
Block and/or functional entity can specifically determine that the embodiment of the present invention is not construed as limiting according to actual use demand.Below with end
For end equipment, the method provided in an embodiment of the present invention for obtaining ambient light intensity is illustratively illustrated.
Refering to what is shown in Fig. 2, the embodiment of the invention provides a kind of method for obtaining ambient light intensity, this method may include
Following step 201- steps 203.
Step 201, terminal device obtain the first difference, which is first environment luminous intensity measurement value and the second ring
The absolute value of the difference of border luminous intensity measurement value.
The first environment luminous intensity measurement value is when terminal device shows first object image, to measure in first time period
The terminal device local environment environmental light intensity angle value, the second environment luminous intensity measurement value be second time period in, terminal
When equipment shows the second target image, the environmental light intensity angle value of the terminal device local environment of measurement, the second time period with
The duration of the first time period is identical.
Before terminal device obtains the first difference, terminal device will first obtain first environment luminous intensity measurement value and second
Ambient light intensity measured value.First environment luminous intensity measurement value and second environment luminous intensity measurement value include at least actual rings respectively
(screen exit rays are by the reflected reflected light of the glass cover-plate of terminal device for border light intensity value and corresponding screen light intensity value
Intensity, abbreviation screen reflection luminous intensity), it may further include other light intensity values.Terminal device can be surveyed by optical sensor etc.
One ambient light intensity measured value of flow control and second environment luminous intensity measurement value can specifically refer to existing the relevant technologies, herein
It will not go into details.First environment luminous intensity measurement value is measured by optical sensor with terminal device below and second environment luminous intensity is surveyed
The method provided in an embodiment of the present invention for obtaining ambient light intensity is illustratively illustrated for magnitude.
Refering to what is shown in Fig. 3, optical sensor is located at below screen, wherein 1 is environment light, and 2 be screen reflection light, and 01 is glass
Glass cover board, 02 is screen, and 03 is optical sensor.Therefore optical sensor is other than it can detect actual environment luminous intensity, moreover it is possible to
The screen exit rays of target area are detected by the intensity of the reflected reflected light of the glass cover-plate of terminal device, for the ease of retouching
It states, the latter's abbreviation screen reflection luminous intensity.Therefore first environment luminous intensity measurement value includes the actual environment in first time period
Luminous intensity and screen reflection luminous intensity, second environment luminous intensity measurement value include actual environment luminous intensity in second time period and
Screen reflection luminous intensity.
Terminal device calculates the absolute value of the difference of first environment luminous intensity measurement value and second environment luminous intensity measurement value
It is denoted as the first difference.
First object image and the second target image can be a frame image, be also possible to multiple image, and the present invention is implemented
Example is not construed as limiting.
The duration of the second time period and the duration of the first time period are identical, and are preset duration, the preset duration
Can determine according to actual needs, the embodiment of the present invention is not construed as limiting.The first time period can be adjacent with the second time period
Two periods, be also possible to non-conterminous two periods, the embodiment of the present invention is not construed as limiting.First time period and second
Period does not have sequencing, can be first time period before second time period, is also possible to first time period second
Behind period, illustratively illustrated so that first time period is before second time period as an example below.First time period
The duration of duration (preset duration) and second time period is very short (preset duration), first time period and second time period it is adjacent or
The duration at interval is also very short, and in shorter duration, it is believed that actual environment luminous intensity is constant or almost unchanged, and the screen
Curtain brightness is also constant or almost unchanged, i.e., screen reflection luminous intensity is constant or almost unchanged.Terminal device in first time period
The number of image frames of display is identical with the number of image frames that terminal device in second time period is shown, and usually integer frame.
Preferably, which includes continuous first image of N frame, which includes that N frame is continuous
The second image, second image of N frame and first image of N frame are the image that the terminal device continuously displays, and N is positive integer.
I.e. first time period and second time period are two adjacent periods, the acquisition environment provided according to embodiments of the present invention in this way
The ambient light intensity that the method for luminous intensity obtains can be more acurrate.
First environment luminous intensity measurement value can be optical sensor and show the frame in first object image in terminal device
It is measured when the first image;It is also possible to optical sensor when terminal device shows M the first image of frame in first object image
Measurement, M is greater than 1 and is less than or equal to N;It is also possible to optical sensor and shows the M frame in first object image in terminal device
The multiple average value measured when the first image;It can also be other, the embodiment of the present invention is not construed as limiting.Similarly second environment
Luminous intensity measurement value can be what optical sensor was measured when terminal device shows second image of frame in the second target image;
It is also possible to what optical sensor was measured when terminal device shows M the second image of frame in the second target image;It is also possible to light
The multiple average value that sensor is measured when terminal device shows M the second image of frame in the second target image;It can also be
Others, the embodiment of the present invention are not construed as limiting.
Step 202, terminal device obtain the second difference, which is the difference of the first grayscale value and target gray scale value
Absolute value.
Color is usually described with three independent attributes, three independent variable comprehensive functions, just constitutes a sky naturally
Between coordinate, here it is color spaces.But color object being described itself is that objectively, different colours space is only from different
Angle goes to measure the same object.Color space can be divided into two major classes according to basic system: primary colours color space (also referred to as three
Primary colors color space) and color, show the score from color space.Primary colours color space and color, show the score can be mutual between color space
Conversion, specific conversion process can refer to the prior art, and it will not go into details herein.
Primary colours color space: what kind of color a pixel is presented, and is determined by three primary color components.For example, a pixel
Point includes red (R), green (G), blue (B) three sub-pixels, then three primary color components are respectively R value, G value and B value at this time.In another example
One pixel includes green (C), pinkish red (M), yellow (Y) three sub-pixels, then three primary color components can be C value, M value and Y at this time
Value.In the present embodiment, it is preferred that component value is RGB component value or CMY component value, is also possible to other color component values.
It should be noted that a pixel in the embodiment of the present invention can be only made of three above-mentioned sub-pixels,
It can certainly also include the 4th sub-pixel, such as white (W) sub-pixel.At this point, because white is not belonging to primary colors, therefore for this
The three primary color components of pixel are referring still to foregoing description.
Color is showed the score from color space: the color space being made of brightness and coloration, wherein brightness is referred to as grayscale
Or gray scale, coloration include tone and saturation degree.In embodiments of the present invention, color, show the score that it is empty to can be YUV color from color space
Between, YCbCr color space, HSI color space, hsv color space etc..
In the following, simply introducing several common color spaces comprising brightness and coloration.
YUV: wherein Y indicates brightness (Luminance or Luma), that is, grayscale, and what U and V were then indicated is coloration
(Chrominance or Chroma).In YUV, Y value is grayscale value.
YCbCr: being reprint of the YUV by scaling and offset.Wherein Y is consistent with the Y meaning in YUV, and Cb, Cr equally refer to
Color, it is only different on representation method.In YUV family, YCbCr be in computer systems using it is most at
Member, application field is very extensive, and JPEG, MPEG are all made of this format.The YUV that general people are said refers to YCbCr mostly.?
In YCbCr, Y value is grayscale value.
HSI: the colored mode of the vision system perception of people is reflected, with three kinds of tone (H), saturation degree (S) and brightness (I)
Essential characteristic amount perceives color.In HSI, I value is grayscale value.
HSV: being a kind of color space created according to the intuitive nature of color, parameter is respectively: tone (H), saturation degree
(S), lightness (V).In HSV, V value is grayscale value.
In the examples below, illustratively illustrated by taking RGB primary colours color space as an example.
In the prior art, when recording the color of digital picture, the bit depth actually needed with each pixel is (simple
Claim position, bit) come what is indicated, i.e., it is indicated to store digit used in each pixel with the depth of image, is also used for measurement image
Color-resolution.Picture depth determines the presumable number of colours of each pixel of color image, or determines the every of gray level image
A presumable grayscale series of pixel.It is determined in the MaxColors or gray level image that may occur in which in color image most
Big greyscale level.Such as a width monochrome image, if each pixel has 8 (bit), maximum gray number of levels is 8 times of 2
Side, i.e., 256.The pixel digit of one 3 components of width color image R, G, B is respectively 4,4,2, then the 4+ that maximum color number is 2
4+2=10 power, i.e., 1024, that is the depth of pixel is 10bit, and each pixel can be one of 1024 kinds of colors.
First grayscale value is the grayscale value of the first object image, which is second grayscale value or is
To first grayscale value through target treated grayscale value, which is the grayscale value of second target image, this
One grayscale value is different from the target gray scale value.
Terminal device will first obtain the first grayscale value and target gray scale value before obtaining the second difference.
Since the duration of the duration (preset duration) and second time period of first time period is very short (preset duration), when first
Between section and second time period is adjacent or the duration at interval is also very short, therefore, refering to what is shown in Fig. 4, wherein, L1~L3For actual environment
Luminous intensity, G1~G6、G2'、G4'、G6' it is screen reflection luminous intensity.The corresponding grayscale value of first object image is (when first Δ t
Between section, third Δ t period or the 5th Δ t period etc.) and the corresponding original gray-scale value of the second target image (second
Δ t period, the 4th Δ t period or the 6th Δ t period etc.) (the corresponding grayscale value of third target image) usual phase
Together, or there is faint variation, can not thus calculate the second difference, the second target image is third mesh in embodiments of the present invention
For logo image through target treated image, the corresponding grayscale value of the second target image is not to be through target treated grayscale value
The corresponding original gray-scale value of second image.Refering to what is shown in Fig. 5, the corresponding grayscale value of the second target image (the first Δ t time
Section, third Δ t period or the 5th Δ t period etc.) corresponding with first object image grayscale value is (when second Δ t
Between section, the 4th Δ t period or the 6th Δ t period etc.) have certain difference.
It should be understood that the process of the second target image is specifically obtained after target is handled to third target image,
It can be before showing the second target image, which obtains the second target to third target image after target is handled
The process of image;Be also possible to before showing the second target image, other terminal devices to third target image through target at
The second target image is obtained after reason;The specific embodiment of the present invention is not construed as limiting.
Illustratively, if image is the image of primary colours color space, in order to guarantee that image color is undistorted, then target is handled
Mode can be each component value of each pixel in third target image to grayscale value multiplied by the first preset value,
To obtain the second target image, i.e. target processing increases for the grayscale value of each pixel of the predeterminable area to third target image
Big or Q times of reduction, Q are greater than 0 and less than 1.For example, if third target image is RGB image, by (the first preset value of R*) (G*
First preset value) (the first preset value of B*) be used as the second target image.
Illustratively, if image is color, the image showed the score from color space, the mode of target processing be can be third
The intensity gray scale value of each pixel in target image adds the second preset value, or multiplied by third preset value, to obtain the second mesh
The processing of the intensity gray scale value of each pixel in logo image, i.e. target is each picture to the predeterminable area of third target image
The grayscale value of vegetarian refreshments increases or reduces T, or increases or reduces Q times, and T is positive integer, in order to guarantee that image color is undistorted, also
Color compensation is carried out to the coloration in third target image, to obtain the second target image.Wherein, specific color compensation
Method can refer to existing the relevant technologies, and the embodiment of the present invention is not construed as limiting.For example, if third target image is YCbCr image,
(the second preset value of Y+ or Y* third preset value) (Cb after color compensation) (Cr after color compensation) is then used as the second target
Image.
It should be understood that the first preset value, the second preset value and third preset value are set according to actual needs, the present invention
Embodiment is not construed as limiting.When determining the first preset value, the second preset value and third preset value again, need to consider following two
Point: one, consider optical sensor sensitivity, two, consider human eye sensitivity.Specifically, in conjunction with optical sensor sensitivity and
The sensitivity of human eye, by the corresponding grayscale value control of the second target image in the rigid range of variation of human eye, even if photosensitive can examine
Difference is measured, but people but perceives and jumping less than screen intensity.
First grayscale value is the corresponding grayscale value of first object image, and terminal device can read first from memory
Then the grayscale value of the corresponding each pixel of target image calculates the corresponding total grayscale value of first object image, is denoted as first
Grayscale value.
First grayscale value specifically can be the grayscale value of first image of frame;It is also possible to total grayscale of the first image of P frame
Value, P are greater than 1 and are less than or equal to N;It is also possible to the average value of total grayscale value of the first image of P frame;It can also be other,
The embodiment of the present invention is not construed as limiting.
Similarly, the second grayscale value is the corresponding grayscale value of the second target image, and terminal device can be read from memory
Then the grayscale value for taking the corresponding each pixel of the second target image calculates the corresponding total grayscale value of the second target image, note
Make the second grayscale value.
Second grayscale value specifically can be the grayscale value of second image of frame;It is also possible to total grayscale of the second image of P frame
Value, P are greater than 1 and are less than or equal to N;It is also possible to the average value of total grayscale value of the second image of P frame;It can also be other,
The embodiment of the present invention is not construed as limiting.
The target gray scale value is second grayscale value, then the first difference is the difference of the first grayscale value and the second grayscale value
Absolute value
The target gray scale value is to first grayscale value through target treated grayscale value, since first object image is corresponding
Grayscale value and the corresponding grayscale value of third target image it is usually identical, or have faint variation, therefore can be by the first grayscale value
Through with to the identical target of third target image treated grayscale value as target gray scale value.
Illustratively, which is specially the grayscale value of the first area in the first object image, this second
Grayscale value is specially the grayscale value in region identical with the first area in second target image.It is said by taking first area as an example
Bright, first area is that can detect the corresponding region in the target area of screen reflection luminous intensity, i.e. first object with optical sensor
Region corresponding with target area in image.Since the screen reflection luminous intensity in first environment luminous intensity measurement value is interference light
Sensor can not accurately measure the factor of actual environment luminous intensity, and screen reflection luminous intensity is due in first object image
The luminous generation of the pixel of first area.Therefore when first grayscale value is specially the first area in the first object image
Grayscale value, which can when being specially the grayscale value in region identical with the first area in second target image
Accurately to remove interference of the screen reflection luminous intensity to actual environment luminous intensity, make target environment luminous intensity closer to actual environment
Luminous intensity keeps the measurement to environment light more acurrate, refers to so as to improve to the ambient light intensity of environment locating for terminal device
Measurement accuracy.
Step 203, terminal device according to the first environment luminous intensity measurement value, first difference, second difference and
First grayscale value calculates target environment light intensity value.
Compared to first environment luminous intensity measurement value or second environment luminous intensity measurement value, target environment light intensity value is more connect
It is bordering on actual environment light intensity value.
Illustratively, which can specifically be realized by following step 203a.
Step 203a, terminal device according to the first environment luminous intensity measurement value, first difference, second difference and
First grayscale value calculates target environment light intensity value using the first formula.
First formula are as follows:Wherein, L1For the target environment light intensity value, L1' it is the first environment
Luminous intensity measurement value, Δ L are first difference, and Δ G is second difference, G1For first grayscale value.
Specifically, terminal device first calculates the ratio of the first difference Yu the second difference, the corresponding screen of as single grayscale value
Curtain intensity of reflected light;The product of single grayscale value corresponding screen reflection luminous intensity and first grayscale value is calculated again, as
Total screen reflection luminous intensity in one period;Finally calculate the first environment luminous intensity measurement value and total screen reflection luminous intensity
Difference, as target environment light intensity value.
Illustratively, more acurrate in order to make to calculate in practical calculating process, it can be corresponded to single grayscale value is calculated
Screen reflection luminous intensity after, add an offset for the corresponding screen reflection luminous intensity of single grayscale value, as final
The corresponding screen reflection luminous intensity of single grayscale value.Offset can also be added after total screen reflection luminous intensity is calculated,
Or add offset after target environment light intensity value is calculated, it is set with specific reference to actual conditions, the embodiment of the present invention
It is not construed as limiting.
Illustratively, if the terminal device handles third target image through target before showing the second target image
After obtain the second target image, then combine Fig. 2, it is provided in an embodiment of the present invention specific as shown in fig. 6, before step 201
The method for obtaining ambient light intensity can also include the steps that following 204.
Step 204, before showing second target image, terminal device is to the grayscale value of third target image through the mesh
Mark handles to obtain second target image.
It specifically can be with reference to the associated description in above-mentioned steps 202.
Illustratively, the second target image shown in second time period and the first mesh shown in first time period
Logo image is compared, it is possible to be changed, therefore is likely to occur to the calculating of the corresponding screen reflection luminous intensity of single grayscale value
Deviation, especially when target gray scale value be to first grayscale value through target treated grayscale value when.In order to avoid in display
Hold mutation obvious errors caused by target environment luminous intensity, after target environment luminous intensity is calculated, before being directed to
The multiple groups target environment light intensity data being calculated afterwards carries out low-pass filtering treatment.
In conjunction with Fig. 3, as shown in fig. 7, after step 203, specific acquisition environmental light intensity provided in an embodiment of the present invention
The method of degree can also include the steps that following 205.
Step 205, terminal device use low-pass filtering mode, are filtered to the target environment light intensity value.
In embodiments of the present invention, low-pass filtering mode can be is filtered by low-pass filter, is also possible to by low
Pass filter algorithm filtering, the embodiment of the present invention are not construed as limiting.
Illustratively, according to the mode of low-pass filter filtering, then the cutoff frequency of low-pass filter is the 4th default
Value.4th preset value is set according to actual needs, and the embodiment of the present invention is not construed as limiting, specifically can be with reference to existing related skill
Art, it will not go into details herein.
Illustratively, according to the mode of low-pass filtering algorithm filtering, then low-pass filtering algorithm can be sliding average filter
Wave algorithm can also be other low-pass filtering algorithms, can specifically refer to existing the relevant technologies, and the embodiment of the present invention is refused
It repeats.
The embodiment of the invention provides a kind of methods for obtaining ambient light intensity to pass through acquisition in embodiments of the present invention
First difference, first difference are the absolute of the difference of first environment luminous intensity measurement value and second environment luminous intensity measurement value
Value, the first environment luminous intensity measurement value be first time period in, terminal device show first object image when, the end of measurement
The environmental light intensity angle value of end equipment local environment, the second environment luminous intensity measurement value are in second time period, and terminal device is aobvious
When showing the second target image, the environmental light intensity angle value of the terminal device local environment of measurement, the second time period and this first
The duration of period is identical;The second difference is obtained, which is the absolute of the first grayscale value and the difference of target gray scale value
Value, first grayscale value are the grayscale value of the first object image, which is second grayscale value or is to this
For first grayscale value through target treated grayscale value, which is the grayscale value of second target image, first ash
Rank value is different from the target gray scale value;According to the first environment luminous intensity measurement value, first difference, second difference and it is somebody's turn to do
First grayscale value calculates target environment light intensity value.In the program, first environment luminous intensity measurement value and second environment luminous intensity
Measured value includes at least actual environment light intensity value and corresponding screen reflection luminous intensity respectively, due to first time period and second
The duration of period is identical, if the duration is shorter, in first time period and in second time period, and ring locating for terminal device
The actual environment light intensity value in border is constant, and the variable quantity of the intensity value of screen light is the second difference, first environment luminous intensity measurement
The absolute value of the difference of value and second environment luminous intensity measurement value is the first difference, and therefore, the first difference be (ambient light measurement value
Difference) it is caused by the second difference (variation of screen light intensity value), then terminal device can be according to the first grayscale value, first
Target environment light intensity value is calculated in difference, the second difference and first environment luminous intensity measurement value, compared to first environment
Luminous intensity measurement value or second environment luminous intensity measurement value, target environment light intensity value closer to actual environment light intensity value,
So as to improve the measurement accuracy referred to the ambient light intensity of environment locating for terminal device, prior art environment can solve
The problem of the testing result inaccuracy of light.
As shown in figure 8, the embodiment of the present invention provides a kind of terminal device 120, which includes: acquisition module
121 and computing module 122;
The acquisition module 121, for obtaining the first difference, which is first environment luminous intensity measurement value and second
The absolute value of the difference of ambient light intensity measured value, the first environment luminous intensity measurement value are terminal device in first time period
When showing first object image, the environmental light intensity angle value of the terminal device local environment of measurement, the second environment luminous intensity is surveyed
Magnitude be second time period in, when terminal device shows the second target image, the environment of the terminal device local environment of measurement
Light intensity value, the second time period are identical as the duration of the first time period;The second difference is obtained, which is the first ash
The absolute value of the difference of rank value and target gray scale value, first grayscale value are the grayscale value of the first object image, target ash
Rank value is second grayscale value or is to first grayscale value through target treated grayscale value, second grayscale value be this
The grayscale value of two target images, first grayscale value are different from the target gray scale value;
The computing module 122, for according to the first environment luminous intensity measurement value, the acquisition module 121 acquisition this
Second difference and first grayscale value that one difference, the acquisition module 121 obtain, calculate target environment light intensity value.
Optionally, which includes continuous first image of N frame, which includes that N frame is continuous
The second image, second image of N frame and first image of N frame are the image that the terminal device continuously displays, and N is positive integer.
Optionally, in conjunction with Fig. 8, as shown in figure 9, the terminal device 120 further include: processing module 123;The processing module
123, for before showing second target image, to the grayscale value of third target image through the target handle to obtain this second
Target image.
Optionally, which is specially the grayscale value of the first area in the first object image, second ash
Rank value is specially the grayscale value in region identical with the first area in second target image.
Optionally, the computing module 122 is specifically used for according to the first environment luminous intensity measurement value, first difference, is somebody's turn to do
Second difference and first grayscale value calculate target environment light intensity value using the first formula;First formula are as follows:Wherein, L1For the target environment light intensity value, L1' it is the first environment luminous intensity measurement value, Δ L is should
First difference, Δ G are second difference, G1For first grayscale value.
Optionally, in conjunction with Fig. 9, as shown in Figure 10, which goes back mass: filter module 124;The filter module
124, for this according to the first environment luminous intensity measurement value, first difference, second difference and first grayscale value,
After calculating target environment light intensity value, using low-pass filtering mode, the target environment which is calculated
Light intensity value is filtered.
Terminal device provided in an embodiment of the present invention can be realized in above method embodiment one of any institute of Fig. 2 to Fig. 7
The each process shown, to avoid repeating, details are not described herein again.
The embodiment of the invention provides one kind to obtain terminal device, in embodiments of the present invention, should by obtaining the first difference
First difference is the absolute value of the difference of first environment luminous intensity measurement value and second environment luminous intensity measurement value, the first environment
Luminous intensity measurement value is in first time period, when terminal device shows first object image, ring locating for the terminal device of measurement
The environmental light intensity angle value in border, the second environment luminous intensity measurement value are in second time period, and terminal device shows the second target figure
When picture, the environmental light intensity angle value of the terminal device local environment of measurement, the duration of the second time period and the first time period
It is identical;The second difference is obtained, which is the absolute value of the difference of the first grayscale value and target gray scale value, first grayscale
Value is the grayscale value of the first object image, which is second grayscale value or is to first grayscale value through mesh
Mark treated grayscale value, second grayscale value are the grayscale value of second target image, first grayscale value and target ash
Rank value is different;According to the first environment luminous intensity measurement value, first difference, second difference and first grayscale value, meter
Calculate target environment light intensity value.In the program, first environment luminous intensity measurement value and second environment luminous intensity measurement value are respectively extremely
It include less actual environment light intensity value and corresponding screen reflection luminous intensity, due to the duration of first time period and second time period
It is identical, if the duration is shorter, in first time period and in second time period, the actual environment of environment locating for terminal device
Light intensity value is constant, and the variable quantity of the intensity value of screen light is the second difference, first environment luminous intensity measurement value and second environment
The absolute value of the difference of luminous intensity measurement value is the first difference, and therefore, the first difference (difference of ambient light measurement value) is by the
Caused by two differences (variation of screen light intensity value), then terminal device can be according to the first grayscale value, the first difference, second poor
Target environment light intensity value is calculated in value and first environment luminous intensity measurement value, compared to first environment luminous intensity measurement value
Or second environment luminous intensity measurement value, target environment light intensity value is closer to actual environment light intensity value, so as to improve
To the measurement accuracy that the ambient light intensity of environment locating for terminal device refers to, the testing result of prior art environment light can solve
The problem of inaccuracy.
A kind of hardware structural diagram of Figure 11 terminal device of each embodiment to realize the present invention.As shown in figure 11,
The terminal device 100 includes but is not limited to: radio frequency unit 101, network module 102, audio output unit 103, input unit
104, sensor 105, display unit 106, user input unit 107, interface unit 108, memory 109, processor 110, with
And the equal components of power supply 111.It will be understood by those skilled in the art that the not structure paired terminal of terminal device structure shown in Figure 11
The restriction of equipment, terminal device may include perhaps combining certain components or different than illustrating more or fewer components
Component layout.In embodiments of the present invention, terminal device includes but is not limited to mobile phone, tablet computer, laptop, palm electricity
Brain, vehicle-mounted terminal equipment, wearable device and pedometer etc..
Wherein, processor 110, for obtaining the first difference, which is first environment luminous intensity measurement value and the
The absolute value of the difference of two ambient light intensity measured values, the first environment luminous intensity measurement value are in first time period, and terminal is set
When standby display first object image, the environmental light intensity angle value of the terminal device local environment of measurement, the second environment luminous intensity
Measured value be second time period in, when terminal device shows the second target image, the ring of the terminal device local environment of measurement
Border light intensity value, the second time period are identical as the duration of the first time period;The second difference is obtained, which is first
The absolute value of the difference of grayscale value and target gray scale value, first grayscale value are the grayscale value of the first object image, the target
Grayscale value is second grayscale value or is to first grayscale value through target treated grayscale value, which is should
The grayscale value of second target image, first grayscale value are different from the target gray scale value;According to the first environment luminous intensity measurement
Value, first difference, second difference and first grayscale value calculate target environment light intensity value.
Terminal device provided in an embodiment of the present invention, in embodiments of the present invention, by obtaining the first difference, this is first poor
Value is the absolute value of the difference of first environment luminous intensity measurement value and second environment luminous intensity measurement value, the first environment luminous intensity
Measured value be first time period in, terminal device show first object image when, the ring of the terminal device local environment of measurement
Border light intensity value, the second environment luminous intensity measurement value are when terminal device shows the second target image, to survey in second time period
The environmental light intensity angle value of the terminal device local environment of amount, the second time period are identical as the duration of the first time period;It obtains
The second difference is taken, which is the absolute value of the difference of the first grayscale value and target gray scale value, which is should
The grayscale value of first object image, the target gray scale value are second grayscale value or are to be handled through target first grayscale value
Grayscale value afterwards, second grayscale value are the grayscale value of second target image, and first grayscale value and the target gray scale value are not
Together;According to the first environment luminous intensity measurement value, first difference, second difference and first grayscale value, target is calculated
Environmental light intensity angle value.In the program, first environment luminous intensity measurement value and second environment luminous intensity measurement value include at least respectively
Actual environment light intensity value and corresponding screen reflection luminous intensity, since first time period is identical with the duration of second time period,
If the duration is shorter, in first time period and in second time period, the actual environment light intensity of environment locating for terminal device
Angle value is constant, and the variable quantity of the intensity value of screen light is the second difference, first environment luminous intensity measurement value and second environment light intensity
The absolute value for spending the difference of measured value is the first difference, and therefore, the first difference (difference of ambient light measurement value) is poor by second
Be worth (variation of screen light intensity value) caused by, then terminal device can according to the first grayscale value, the first difference, the second difference with
And target environment light intensity value is calculated in first environment luminous intensity measurement value, compared to first environment luminous intensity measurement value or
Two ambient light intensity measured values, target environment light intensity value is closer to actual environment light intensity value, so as to improve to end
The measurement accuracy that the ambient light intensity of environment locating for end equipment refers to, the testing result that can solve prior art environment light are inaccurate
True problem.
It should be understood that the embodiment of the present invention in, radio frequency unit 101 can be used for receiving and sending messages or communication process in, signal
Send and receive, specifically, by from base station downlink data receive after, to processor 110 handle;In addition, by uplink
Data are sent to base station.In general, radio frequency unit 101 includes but is not limited to antenna, at least one amplifier, transceiver, coupling
Device, low-noise amplifier, duplexer etc..In addition, radio frequency unit 101 can also by wireless communication system and network and other set
Standby communication.
Terminal device provides wireless broadband internet by network module 102 for user and accesses, and such as user is helped to receive
It sends e-mails, browse webpage and access streaming video etc..
Audio output unit 103 can be received by radio frequency unit 101 or network module 102 or in memory 109
The audio data of storage is converted into audio signal and exports to be sound.Moreover, audio output unit 103 can also provide and end
The relevant audio output of specific function that end equipment 100 executes is (for example, call signal receives sound, message sink sound etc.
Deng).Audio output unit 103 includes loudspeaker, buzzer and receiver etc..
Input unit 104 is for receiving audio or video signal.Input unit 104 may include graphics processor
(Graphics Processing Unit, GPU) 1041 and microphone 1042, graphics processor 1041 is in video acquisition mode
Or the image data of the static images or video obtained in image capture mode by image capture apparatus (such as camera) carries out
Reason.Treated, and picture frame may be displayed on display unit 106.Through graphics processor 1041, treated that picture frame can be deposited
Storage is sent in memory 109 (or other storage mediums) or via radio frequency unit 101 or network module 102.Mike
Wind 1042 can receive sound, and can be audio data by such acoustic processing.Treated audio data can be
The format output that mobile communication base station can be sent to via radio frequency unit 101 is converted in the case where telephone calling model.
Terminal device 100 further includes at least one sensor 105, such as optical sensor, motion sensor and other biographies
Sensor.Specifically, optical sensor includes ambient light sensor and proximity sensor, wherein ambient light sensor can be according to environment
The light and shade of light adjusts the brightness of display panel 1061, and proximity sensor can close when terminal device 100 is moved in one's ear
Display panel 1061 and/or backlight.As a kind of motion sensor, accelerometer sensor can detect in all directions (general
For three axis) size of acceleration, it can detect that size and the direction of gravity when static, can be used to identify terminal device posture (ratio
Such as horizontal/vertical screen switching, dependent game, magnetometer pose calibrating), Vibration identification correlation function (such as pedometer, tap);It passes
Sensor 105 can also include fingerprint sensor, pressure sensor, iris sensor, molecule sensor, gyroscope, barometer, wet
Meter, thermometer, infrared sensor etc. are spent, details are not described herein.
Display unit 106 is for showing information input by user or being supplied to the information of user.Display unit 106 can wrap
Display panel 1061 is included, liquid crystal display (Liquid Crystal Display, LCD), Organic Light Emitting Diode can be used
Forms such as (Organic Light-Emitting Diode, OLED) configure display panel 1061.
User input unit 107 can be used for receiving the number or character information of input, and generate the use with terminal device
Family setting and the related key signals input of function control.Specifically, user input unit 107 include touch panel 1071 and
Other input equipments 1072.Touch panel 1071, also referred to as touch screen collect the touch operation of user on it or nearby
(for example user uses any suitable objects or attachment such as finger, stylus on touch panel 1071 or in touch panel 1071
Neighbouring operation).Touch panel 1071 may include both touch detecting apparatus and touch controller.Wherein, touch detection
Device detects the touch orientation of user, and detects touch operation bring signal, transmits a signal to touch controller;Touch control
Device processed receives touch information from touch detecting apparatus, and is converted into contact coordinate, then gives processor 110, receiving area
It manages the order that device 110 is sent and is executed.Furthermore, it is possible to more using resistance-type, condenser type, infrared ray and surface acoustic wave etc.
Seed type realizes touch panel 1071.In addition to touch panel 1071, user input unit 107 can also include other input equipments
1072.Specifically, other input equipments 1072 can include but is not limited to physical keyboard, function key (such as volume control button,
Switch key etc.), trace ball, mouse, operating stick, details are not described herein.
Further, touch panel 1071 can be covered on display panel 1061, when touch panel 1071 is detected at it
On or near touch operation after, send processor 110 to determine the type of touch event, be followed by subsequent processing device 110 according to touching
The type for touching event provides corresponding visual output on display panel 1061.Although in Figure 11, touch panel 1071 and aobvious
Show that panel 1061 is the function that outputs and inputs of realizing terminal device as two independent components, but in some embodiments
In, can be integrated by touch panel 1071 and display panel 1061 and realize the function that outputs and inputs of terminal device, it is specific this
Place is without limitation.
Interface unit 108 is the interface that external device (ED) is connect with terminal device 100.For example, external device (ED) may include having
Line or wireless head-band earphone port, external power supply (or battery charger) port, wired or wireless data port, storage card end
Mouth, port, the port audio input/output (I/O), video i/o port, earphone end for connecting the device with identification module
Mouthful etc..Interface unit 108 can be used for receiving the input (for example, data information, electric power etc.) from external device (ED) and
By one or more elements that the input received is transferred in terminal device 100 or can be used in 100 He of terminal device
Data are transmitted between external device (ED).
Memory 109 can be used for storing software program and various data.Memory 109 can mainly include storing program area
The storage data area and, wherein storing program area can (such as the sound of application program needed for storage program area, at least one function
Sound playing function, image player function etc.) etc.;Storage data area can store according to mobile phone use created data (such as
Audio data, phone directory etc.) etc..In addition, memory 109 may include high-speed random access memory, it can also include non-easy
The property lost memory, a for example, at least disk memory, flush memory device or other volatile solid-state parts.
Processor 110 is the control centre of terminal device, utilizes each of various interfaces and the entire terminal device of connection
A part by running or execute the software program and/or module that are stored in memory 109, and calls and is stored in storage
Data in device 109 execute the various functions and processing data of terminal device, to carry out integral monitoring to terminal device.Place
Managing device 110 may include one or more processing units;Optionally, processor 110 can integrate application processor and modulatedemodulate is mediated
Manage device, wherein the main processing operation system of application processor, user interface and application program etc., modem processor is main
Processing wireless communication.It is understood that above-mentioned modem processor can not also be integrated into processor 110.
Terminal device 100 can also include the power supply 111 (such as battery) powered to all parts, optionally, power supply 111
Can be logically contiguous by power-supply management system and processor 110, to realize management charging by power-supply management system, put
The functions such as electricity and power managed.
In addition, terminal device 100 includes some unshowned functional modules, details are not described herein.
Optionally, the embodiment of the present invention also provides a kind of terminal device, may include above-mentioned processor as shown in figure 11
110, memory 109, and it is stored in the computer program that can be run on memory 109 and on the processor 110, the calculating
Realize in above method embodiment that Fig. 2 to Fig. 7 obtains environmental light intensity shown in one of any when machine program is executed by processor 110
Each process of the method for degree, and identical technical effect can be reached, to avoid repeating, details are not described herein again.
The embodiment of the present invention also provides a kind of computer readable storage medium, and meter is stored on computer readable storage medium
Calculation machine program, realized when which is executed by processor in above method embodiment Fig. 2 to Fig. 7 it is one of any shown in
The each process of method of ambient light intensity is obtained, and identical technical effect can be reached, to avoid repeating, details are not described herein again.
Wherein, the computer readable storage medium, such as read-only memory (Read-Only Memory, ROM), random access memory
Device (Random Access Memory, RAM), magnetic or disk etc..
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row
His property includes, so that the process, method, article or the device that include a series of elements not only include those elements, and
And further include other elements that are not explicitly listed, or further include for this process, method, article or device institute it is intrinsic
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do
There is also other identical elements in the process, method of element, article or device.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side
Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases
The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art
The part contributed out can be embodied in the form of software products, which is stored in a storage medium
In (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be mobile phone, computer, clothes
Business device, air conditioner or the network equipment etc.) execute method described in each embodiment of the present invention.
The embodiment of the present invention is described with above attached drawing, but the invention is not limited to above-mentioned specific
Embodiment, the above mentioned embodiment is only schematical, rather than restrictive, those skilled in the art
Under the inspiration of the present invention, without breaking away from the scope protected by the purposes and claims of the present invention, it can also make very much
Form belongs within protection of the invention.