Ambient light brightness detection method and related device
By analyzing the distance between the highlights and the center point in the camera image data and correcting the ambient light data, the problem of inaccurate detection of the ambient light is solved, and a more stable ambient light brightness detection and a better user experience is achieved.
Patent Information
- Application Number
- CN202410397645.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-02
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2044-04-02
AI Technical Summary
In electronic devices, the brightness value fluctuates greatly when the camera detects the brightness of the ambient light, which is not accurate enough, which affects the user experience.
By analyzing the image data collected by the camera, finding the brightest or brightest points, correcting the detected ambient light data based on the distance between the highlights and the center point of the image, and using distance-related compensation values to stabilize the ambient light data.
Reduces fluctuations in ambient light data, more stable output results, and improves the accuracy and user experience of ambient light brightness detection.
Smart Images

Figure CN119274513B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to a method for detecting ambient light brightness and related devices. Background Art
[0002] Some electronic devices have displays that automatically adjust their brightness based on the ambient light level, thereby reducing power consumption.
[0003] However, in some implementations, the brightness value of the ambient light detected by the electronic device fluctuates greatly and is not accurate enough, which reduces the user experience. Summary of the Invention
[0004] The ambient light brightness detection method and related device provided in the embodiments of the present application can find the brightest or relatively bright points in the image by analyzing the image data collected by the camera. These bright spots are most likely the positions of the light sources. In order to reduce the influence of the light source position on the ambient light data, the detected ambient light data can be corrected based on the distance between the bright spot and the center point of the image, so that the ambient light data detected by the camera fluctuates less and the output result is relatively stable.
[0005] In a first aspect, an embodiment of the present application provides a method for detecting ambient light brightness, the method comprising:
[0006] Based on a first image captured by the camera, first data indicating ambient light brightness is obtained; the first data is compensated by a first value to obtain a first ambient light brightness, wherein the first value is related to a first distance, which includes the distance between the brightest point in the first image and the center point of the first image; based on a second image captured by the camera, second data indicating ambient light brightness is obtained; the second data is compensated by a second value to obtain a second ambient light brightness, wherein the second value is related to a second distance, which includes the distance between the brightest point in the second image and the center point of the second image, the second distance being greater than the first distance, and the second value being greater than the first value. In this way, the detected ambient light data is corrected based on the distance between the brightest point and the center point of the image, resulting in less fluctuation in the ambient light data detected by the camera and a relatively stable output result.
[0007] In one possible implementation, the first value is linearly correlated with the first distance, and the coefficient of the first distance is a positive number. When the first distance is short, the camera can detect ambient light with high accuracy, so less compensation for ambient light can be applied, and the first value can be small. When the first distance is long, the camera can detect ambient light with low accuracy, so more compensation for ambient light can be applied, and the first value can be large. In this way, the detected ambient light data can be corrected based on the first distance, resulting in less fluctuation in the ambient light data detected by the camera and a relatively stable output result.
[0008] In one possible implementation, the first value satisfies the following formula:
[0009] raw_data2=k×d+raw_data.
[0010] Wherein, raw_data2 is the first value, d is the first distance, k is the coefficient of the first distance, and raw_data is the first data. Different k values can be set for different ambient light brightnesses, so that corresponding adjustments can be made to different ambient light levels, thereby more accurately compensating for the ambient light brightness.
[0011] In one possible implementation, before compensating the first data for the first value to obtain the first ambient light brightness, the method further includes: determining a coefficient for the first distance; and compensating the first data for the first value to obtain the first ambient light brightness includes: obtaining the first value based on the first distance and the coefficient for the first distance, and compensating the first data for the first value to obtain the first ambient light brightness. In this way, determining an appropriate coefficient for the first distance allows for more accurate compensation of the first data, resulting in a first ambient light brightness consistent with the actual environment, thereby improving the accuracy of display brightness adjustment and enhancing the user experience.
[0012] In one possible implementation, determining a coefficient for the first distance includes calculating a third ambient light brightness, where the third ambient light brightness is related to the first data. If the third ambient light brightness falls within a first range, the coefficient for the first distance is the first coefficient; alternatively, if the third ambient light brightness falls within a second range, the coefficient for the first distance is the second coefficient; alternatively, if the third ambient light brightness falls within a third range, the coefficient for the first distance is the third coefficient. The ambient light brightness in the first range is lower than that in the second range, and the ambient light brightness in the second range is lower than that in the third range. The first, second, and third coefficients are all different. Different ranges correspond to different ambient light brightnesses. For example, the first range may correspond to scenes with low ambient light brightness; the second range may correspond to scenes with high ambient light brightness; and the third range may correspond to scenes with high ambient light brightness. In this way, different coefficients can be set for different ambient light brightnesses, making corresponding adjustments for different environments and thus more accurately compensating for ambient light brightness. Furthermore, since electronic devices often use lux values to measure ambient light brightness, using lux values for data calibration is more convenient for electronic devices and can be easily applied to production lines.
[0013] In one possible implementation, the brightness of the third ambient light satisfies the following formula:
[0014] lux0=calibration coefficient×LuxValueConvert(raw_data).
[0015] Here, lux0 is the third ambient light brightness, raw_data is the first data, and LuxValueConvert is a data calibration function used to calibrate the difference between the first data and the actual ambient light brightness. The calibration coefficient is used to calibrate the difference between the camera and a standard camera. Using this formula to calculate the initial lux value eliminates the need to calculate the distance from the brightest point to the center point or consider the default coefficient value corresponding to the distance from the brightest point to the center point, reducing the computing power of the electronic device and improving its execution efficiency.
[0016] In one possible implementation, the brightness of the third ambient light satisfies the following formula:
[0017] lux0=calibration coefficient×LuxValueConvert(k0×d+raw_data).
[0018] Where lux0 is the third ambient light brightness, d is the first distance, k0 is the default coefficient, raw_data is the first data, and LuxValueConvert is a data calibration function used to calibrate the difference between the first data and the actual ambient light brightness. The calibration coefficient is used to calibrate the difference between the camera and a standard camera. Using the formula with the default coefficient to calculate the initial lux value takes into account the effect of the distance from the brightest point to the center point on the ambient light brightness, allowing for a more accurate calculation of the current ambient light brightness, i.e., the initial lux value. This allows for a more reasonable assessment of whether the default coefficients are being used to calculate the ambient light brightness.
[0019] In one possible implementation, the coefficient of the first distance is related to the first data. Since the first data is obtained first and the first value is calculated later, the coefficient of the first distance determined based on the first data does not need to use the default coefficient or calculate the initial lux value. Instead, the corresponding coefficient can be determined based on the interval of the first data. This reduces the number of lux value calculations, reduces the computing power of the electronic device, and improves the operating efficiency of the electronic device.
[0020] In one possible implementation, if the first data belongs to the fourth range, the coefficient of the first distance is the fourth coefficient; or, if the first ambient light brightness belongs to the fifth range, the coefficient of the first distance is the fifth coefficient; or, if the first ambient light brightness belongs to the sixth range, the coefficient of the first distance is the sixth coefficient; wherein, the ambient light brightness of the fourth range is less than the ambient light brightness of the fifth range, and the ambient light brightness of the fifth range is less than the ambient light brightness of the sixth range, and the fourth coefficient, the fifth coefficient, and the sixth coefficient are all different. Different ranges of the first data can correspond to different ambient light brightnesses. For example, the fourth range can correspond to a scene with darker ambient light brightness; the fifth range can correspond to a scene with brighter ambient light brightness; and the sixth range can correspond to a scene with high ambient light brightness. In this way, different coefficients can be set for different ranges of the first data, thereby making corresponding adjustments to different environments and more accurately compensating for the ambient light brightness.
[0021] In one possible implementation, the brightness of the first ambient light satisfies the following formula:
[0022] lux = calibration coefficient × LuxValueConvert(raw_data2).
[0023] Here, lux is the first ambient light brightness, raw_data2 is the first value, and LuxValueConvert is a data calibration function used to calibrate the difference between the first value and the ambient light brightness in the actual environment. The calibration coefficient is used to calibrate the difference between the camera and a standard camera. In this way, the electronic device can perform ambient light compensation on the raw data raw_data collected by the front camera to obtain raw_data2, and then calibrate raw_data2 to obtain the lux value, thereby reducing the differences in the front camera's hardware components and calibrating the difference between the ambient light brightness detected by the front camera and the ambient light brightness in the actual environment, thereby improving the accuracy of the front camera's detection of ambient light brightness.
[0024] In one possible implementation, an electronic device includes a camera service module, a sensor service module, a camera control module, a sensor control module, and a camera driver. Before obtaining first data indicating ambient light brightness based on a first image captured by the camera, the electronic device further includes: issuing a brightness monitoring instruction to the sensor control module based on the sensor service module; invoking a first interface based on an Android Interface Definition Language (AIDL) service based on the brightness monitoring instruction, the first interface being used to register a callback function in the camera control module; invoking a second interface based on a Hardware Abstraction Layer (HIDL) service based on the sensor control module to transmit a first instruction to the camera service module, the first instruction being used to instruct the camera to capture an image and obtain data indicating ambient light brightness; invoking a first function in the camera control module based on the first instruction; and executing the first function in the camera control module to control the camera driver to power on the camera, initialize camera registers, and create a thread for reading ambient light brightness. When the front camera is used in place of the ambient light detection device, image output resources are not allocated for the front camera, and the front camera does not capture images for display on the display screen. This reduces resource consumption of the front camera, thereby improving the performance of the electronic device.
[0025] In one possible implementation, after obtaining first data indicating ambient light brightness based on a first image captured by a camera, the method further includes: reporting the first data to a camera control module based on a camera driver; and compensating the first data by a first value to obtain the first ambient light brightness, including: compensating the first data by the first value to obtain the first ambient light brightness based on the camera control module, the sensor control module, or the camera driver. In this way, when the distance between the brightest point of the raw data and the center point of the raw data is small, less ambient light brightness compensation can be used. When the distance between the brightest point of the raw data and the center point of the raw data is large, more ambient light brightness compensation can be used.
[0026] In a second aspect, an embodiment of the present application provides an apparatus for detecting ambient light brightness, which may be an electronic device or a chip or chip system within an electronic device. The apparatus may include a processing unit. The processing unit is configured to implement any processing-related method performed by the electronic device in the first aspect or any possible implementation of the first aspect. When the apparatus is an electronic device, the processing unit may be a processor. The apparatus may also include a storage unit, which may be a memory. The storage unit is configured to store instructions, and the processing unit executes the instructions stored in the storage unit to enable the electronic device to implement the method described in the first aspect or any possible implementation of the first aspect. When the apparatus is a chip or chip system within an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit to enable the electronic device to implement the method described in the first aspect or any possible implementation of the first aspect. The storage unit may be a storage unit within the chip (e.g., a register, a cache, etc.) or a storage unit within the electronic device located outside the chip (e.g., a read-only memory, a random access memory, etc.).
[0027] Exemplarily, the processing unit is used to obtain first data indicating the brightness of ambient light based on a first image captured by a camera; is also used to compensate the first data for a first value to obtain the first ambient light brightness; is used to obtain second data indicating the brightness of ambient light based on a second image captured by the camera; and is also used to compensate the second data for a second value to obtain the second ambient light brightness.
[0028] In a possible implementation, the first value is linearly correlated with the first distance, and a coefficient of the first distance is a positive number.
[0029] In one possible implementation, the first value satisfies the following formula:
[0030] raw_data2=k×d+raw_data.
[0031] Among them, raw_data2 is the first value, d is the first distance, k is the coefficient of the first distance, and raw_data is the first data.
[0032] In one possible implementation, the processing unit is configured to determine a coefficient of the first distance; and further configured to obtain a first value based on the first distance and the coefficient of the first distance, and compensate the first data with the first value to obtain a first ambient light brightness.
[0033] In one possible implementation, the processing unit is used to calculate the brightness of the third ambient light; and is also used to determine that if the brightness of the third ambient light belongs to the first range, the coefficient of the first distance is the first coefficient; or, if the brightness of the third ambient light belongs to the second range, the coefficient of the first distance is the second coefficient; or, if the brightness of the third ambient light belongs to the third range, the coefficient of the first distance is the third coefficient.
[0034] In one possible implementation, the brightness of the third ambient light satisfies the following formula:
[0035] lux0=calibration coefficient×LuxValueConvert(raw_data).
[0036] Wherein, lux0 is the third ambient light brightness, raw_data is the first data, LuxValueConvert is a data calibration function used to calibrate the difference between the first data and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
[0037] In one possible implementation, the brightness of the third ambient light satisfies the following formula:
[0038] lux0=calibration coefficient×LuxValueConvert(k0×d+raw_data).
[0039] Where lux0 is the third ambient light brightness, d is the first distance, k0 is the default coefficient, raw_data is the first data, LuxValueConvert is a data calibration function used to calibrate the difference between the first data and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
[0040] In a possible implementation manner, the coefficient of the first distance is related to the first data.
[0041] In one possible implementation, if the first data belongs to the fourth range, the coefficient of the first distance is the fourth coefficient; or, if the first ambient light brightness belongs to the fifth range, the coefficient of the first distance is the fifth coefficient; or, if the first ambient light brightness belongs to the sixth range, the coefficient of the first distance is the sixth coefficient.
[0042] In one possible implementation, the brightness of the first ambient light satisfies the following formula:
[0043] lux = calibration coefficient × LuxValueConvert(raw_data2).
[0044] Wherein, lux is the first ambient light brightness, raw_data2 is the first value, LuxValueConvert is a data calibration function used to calibrate the difference between the first value and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
[0045] In one possible implementation, the processing unit is used to send a brightness monitoring instruction to the sensor control module based on the sensor service module; it is also used to call a first interface based on the Android interface definition language AIDL service based on the brightness monitoring instruction based on the sensor control module; specifically, it is also used to call a second interface based on the hardware abstraction layer interface definition language HIDL service based on the sensor control module to pass a first instruction to the camera service module; it is also used to call a first function in the camera control module based on the first instruction based on the camera service module; and it is also used to execute the first function based on the camera control module to control the camera driver to power on the camera, initialize the camera registers, and create a reading thread for the ambient light brightness.
[0046] In one possible implementation, the processing unit is used to report first data to the camera control module based on the camera driver; and is also used to compensate the first data with a first value based on the camera control module, the sensor control module or the camera driver to obtain a first ambient light brightness.
[0047] In a third aspect, an embodiment of the present application provides an electronic device comprising one or more processors and a memory, the memory being coupled to the one or more processors, the memory being used to store computer program code, the computer program code comprising computer instructions, and the one or more processors calling the computer instructions to enable the electronic device to execute the method described in the first aspect or any possible implementation of the first aspect.
[0048] In a fourth aspect, the present application provides a chip or chip system, which is applied to an electronic device, the chip or chip system including one or more processors and a communication interface, the communication interface and at least one processor being interconnected by a line, and the one or more processors being used to invoke computer instructions to cause the electronic device to execute the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip may be an input / output interface, a pin, or a circuit, etc.
[0049] In one possible implementation, the chip or chip system described above in this application further includes at least one memory, in which instructions are stored. The memory may be a storage unit within the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).
[0050] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect or any possible implementation of the first aspect.
[0051] In a sixth aspect, an embodiment of the present application provides a computer program product, which includes a computer program code. When the computer program code runs on an electronic device, the electronic device executes the method described in the first aspect or any possible implementation of the first aspect.
[0052] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0054] Figure 2 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0055] Figure 3 A schematic diagram comparing the field of view angles of a camera and an ambient light detection device provided in an embodiment of the present application;
[0056] Figure 4 A schematic diagram of the field of view angle test results of a camera and an ambient light detection device provided in an embodiment of the present application;
[0057] Figure 5 A schematic diagram of fluctuations in ambient light brightness values of a camera provided in an embodiment of the present application;
[0058] Figure 6 A line graph showing the movement of a light source and the change in ambient light brightness provided in an embodiment of the present application;
[0059] Figure 7 A schematic diagram of a flow chart of a method for detecting ambient light brightness provided in an embodiment of the present application;
[0060] Figure 8 A schematic diagram of data interaction between a camera control module and a sensor control module provided in an embodiment of the present application;
[0061] Figure 9 A schematic diagram of a method for detecting ambient light brightness provided in an embodiment of the present application;
[0062] Figure 10A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] To facilitate a clear description of the technical solutions of the embodiments of the present application, some of the terms and technologies involved in the embodiments of the present application are briefly introduced below:
[0064] 1. FOV: Field of view (FOV) indicates the maximum angle range that a camera can capture. If the subject is within this angle range, the camera can capture it. If the subject is outside this angle range, the camera cannot capture it. Generally speaking, a larger camera's FOV has a wider range and a shorter focal length; a smaller camera's FOV has a smaller range and a longer focal length.
[0065] 2. Terminology
[0066] In the embodiments of this application, terms such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. For example, the terms "first chip" and "second chip" are used solely to distinguish between different chips and do not define their order. Those skilled in the art will understand that terms such as "first" and "second" do not define the quantity or execution order, and do not necessarily define differences.
[0067] It should be noted that in the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0068] In the embodiments of the present application, "at least one" refers to one or more, and "more" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, c can be single or multiple.
[0069] 3. Electronic devices
[0070] The electronic device of the embodiment of the present application may also be a terminal device in any form. For example, the electronic device may include: a mobile phone, a tablet computer, a PDA, a laptop computer, a mobile internet device (MID), a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, a wireless terminal in a smart home, a cellular phone, a cordless phone, a session initiation protocol (SIP) phone, a wireless local loop (WLL) station, a personal digital assistant (PDA), a handheld device with wireless communication function, a computing device or other processing device connected to a wireless modem, an in-vehicle device, a wearable device, an electronic device in a 5G network or a future evolved public land mobile communication network (PLMN) Mobile network, PLMN) and other electronic devices, and the embodiments of the present application are not limited to this.
[0071] As an example and not a limitation, in the embodiments of the present application, the electronic device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include those that are fully functional, large in size, and can achieve complete or partial functions without relying on smartphones, such as smart watches or smart glasses, as well as those that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.
[0072] In addition, in the embodiment of the present application, the electronic device can also be an electronic device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection.
[0073] The electronic devices in the embodiments of the present application may also be referred to as: user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc.
[0074] In the embodiments of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory (also known as main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.
[0075] For example, Figure 1 A schematic structural diagram of an electronic device is shown.
[0076] The electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0077] It is understood that the structures illustrated in the embodiments of the present application do not constitute specific limitations on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0078] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors. The controller may generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.
[0079] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory may store instructions or data that the processor 110 has just used or is reusing. If the processor 110 needs to use the instruction or data again, it may be directly called from the above-mentioned memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system. For example, in an embodiment of the present application, the processor 110 may be used to process the activation of the ambient light detection function, compensate for the ambient light, adjust the brightness of the display screen, etc.
[0080] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only for illustrative purposes and does not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.
[0081] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function, etc. The data storage area may store data created during the use of the electronic device, etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor. For example, in an embodiment of the present application, the internal memory 121 can be used to store a camera to replace the ambient light detection device to collect the ambient light brightness and related codes for compensating for the ambient light.
[0082] The sensor module 180 may include a distance sensor, a temperature sensor, or an ambient light sensor, among others.
[0083] The electronic device can implement display functions through the use of a GPU, display screen 194, and an application processor. The GPU is a microprocessor for image processing that connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information. The electronic device can implement camera functions through the use of an ISP, camera 193, video codec, GPU, display screen 194, and application processor.
[0084] In some embodiments, the electronic device may include 1 or N cameras 193, where N is a positive integer greater than 1. The camera 193 may be used to capture still images or videos. For example, in the embodiment of the present application, the camera 193 may have an ambient light detection function and an image acquisition function.
[0085] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device may include one or N display screens 194, where N is a positive integer greater than one.
[0086] Figure 2 This is a block diagram of the software structure of an electronic device in an embodiment of the present application. The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers: the application layer, the application framework layer, the hardware abstraction layer (HAL), and the kernel layer.
[0087] The application layer can also be called the application layer, which can include a series of application packages. Figure 2 As shown, the application package may include applications such as a camera, an ambient light detection application, etc. Applications may include system applications and third-party applications.
[0088] The application framework layer can also be called the Framework layer, FWK layer, or framework layer. The Framework layer can provide an application programming interface (API) and programming framework for the application layer applications. The Framework layer can include some predefined functions.
[0089] The API provided by the Framework layer may include interfaces related to camera services, sensor services, and other services. Different service-related interfaces can be defined as different service modules. For example, the interface related to camera services can be defined as a camera service module, the interface related to sensor services can be defined as a sensor service module, and the interfaces related to other services can be defined as other service modules (not shown in the figure).
[0090] The camera service module can include submodules such as ICameraService and CameraService. CameraService can be used to implement communication between applications that need to call the camera in the application layer and the camera control module of the HAL layer.
[0091] Among them, applications that need to call the camera may include camera applications, face unlock applications, ambient light detection applications, etc. The ambient light detection application can be used to detect whether the display of the electronic device is on or off, and can also transmit a screen-on message to the sensor service module. The ambient light detection application can be a system application or a third-party application, which is not limited in the embodiments of this application.
[0092] The sensor service module can include submodules such as SensorManager and SensorService. The SensorManager can be used to adjust the brightness of the electronic device's display based on the detected ambient light level. The SensorService enables communication between applications that require sensor calls in the application layer and the sensor control module in the hardware abstraction layer (HAL). The Android runtime includes a core library and a virtual machine. The Android runtime is responsible for controlling and managing the Android system.
[0093] The Hardware Abstraction Layer (HAL) is an abstract structure between the kernel layer and the Android runtime. It encapsulates hardware drivers and provides a unified interface for upper-layer applications to call.
[0094] The hardware abstraction layer may include a camera control module, a sensor control module, and other control modules.
[0095] In an embodiment of the present application, the camera control module may include a camera function customization submodule, a CHI-CDK submodule, a CAMX submodule, and the like. The camera function customization submodule is used to obtain the ambient light brightness detected by the camera when the camera is used as an ambient light detection device and transmit the ambient light brightness to the sensor control module. The CHI-CDK submodule includes a customizable code implementation set that enables communication between different modules within the electronic device. The CAMX submodule includes a code implementation set of a universal functional interface that enables skipping the process of configuring image output resources for the camera.
[0096] The sensor control module may include an ambient light service control submodule, which provides multiple interfaces, including an Active interface and a DeActive interface. The Active interface can be used to enable the camera's ambient light detection function, while the DeActive interface can be used to disable the camera's ambient light detection function.
[0097] The kernel layer is the layer between hardware and software. The kernel layer may include display drivers, camera drivers, sensor drivers, etc.
[0098] It should be noted that the embodiments of the present application are only illustrated using the Android system as an example. In other operating systems (such as Windows system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those in the embodiments of the present application, the solutions of the present application can also be implemented.
[0099] Some electronic devices have displays that automatically adjust their brightness based on ambient light levels. This feature automatically adjusts the display's brightness to suit different lighting conditions, improving the user experience and reducing power consumption.
[0100] In some implementations, an ambient light detection device can be configured in the electronic device. When the electronic device's screen is on, the ambient light detection device can detect the ambient light brightness. The electronic device can then adjust the brightness of the display screen based on the ambient light brightness detected by the ambient light detection device. However, this method of detecting ambient light brightness requires the electronic device to be equipped with an additional ambient light detection device, increasing the cost of the electronic device.
[0101] In other implementations, for electronic devices equipped with cameras, since the cameras can also have an ambient light brightness detection function, the cameras can be used on the electronic devices to replace the ambient light detection devices, thereby reducing the cost of using the devices.
[0102] However, due to the differences in hardware structure between cameras and ambient light detection devices, as well as the differences in the positions of cameras and ambient light detection devices on electronic devices, the field of view of some cameras in detecting ambient light is smaller than the field of view of ambient light detection devices in detecting ambient light. As a result, when the user flips or moves the electronic device, the brightness value of the ambient light detected by the camera fluctuates greatly.
[0103] For example, Figure 3 As shown, Figure 3 a is a schematic diagram of the field of view angle θ1 of the camera 301 when receiving ambient light, Figure 3 b is a schematic diagram of the field of view angle θ2 of the ambient light detection device 302 when receiving ambient light.
[0104] It is understood that the camera in the electronic device may include a front camera, a rear camera, etc. Considering that the display screen is provided on the upper surface of the electronic device, the front camera is also provided on the upper surface of the electronic device, located on the same side as the display screen, and the ambient light brightness on different sides of the electronic device is somewhat different. In order to make the adjusted display screen brightness more suitable for the current environment, this application is described using the front camera as an example.
[0105] from Figure 3It can be seen that the device 3011 for detecting ambient light in the front camera 301 is usually located at the bottom of the front camera 301, and the diameter of the lens 3012 of the front camera 301 is small. When the device 3011 receives ambient light, part of the light will be blocked by the lens 3012, making the field of view angle θ1 of the device 3011 smaller. It can also be understood that the field of view angle θ1 of the front camera 301 is smaller.
[0106] The ambient light detection device 302 is generally located near the display screen of the electronic device, for example, at the top of the display screen, or adjacent to the front camera. It is understood that the specific location of the ambient light detection device 302 may vary in different electronic devices, and the embodiments of the present application do not limit the specific location of the ambient light detection device 302. When the ambient light detection device 302 receives ambient light, the field of view angle θ2 of the ambient light detection device 302 is larger because the ambient light detection device 302 is less obscured by other hardware devices.
[0107] Figure 4 The figure shows a comparison of the field of view angles of the front camera and the ambient light detection device. The horizontal axis in the figure is the receiving angle of the ambient light, and the vertical axis is the relative response. Relative response can be understood as a relative concept. For example, taking a direct light environment with an intensity of 100 as an example, the relative response of the front camera can be understood as the percentage of the intensity of the light received by the front camera relative to the intensity of 100, and the relative response of the ambient light detection device can be understood as the percentage of the intensity of the direct light received by the ambient light detection device relative to the intensity of 100.
[0108] After testing, it was found that the angle at which the front camera receives ambient light is around ±45°, which means the field of view of the front camera is around 90°. The angle at which the ambient light detection device receives ambient light is around ±90°, which means the field of view of the ambient light detection device is around 180°. In other words, the field of view of the front camera is smaller than that of the ambient light detection device. In the same environment, due to the smaller field of view of the front camera, the brightness value of the ambient light detected by the front camera fluctuates greatly when the user flips or moves the electronic device.
[0109] like Figure 5 As shown in Figure 2, it is assumed that there are light sources A, B, and C in an environment. Figure 5 In a, due to the small field of view of the front camera, light sources A and B are within the field of view of the front camera, while light source C is not within the field of view of the front camera. Figure 5 In b, since the field of view of the ambient light detection device is large, light source A, light source B and light source C are all located within the field of view of the ambient light detection device.
[0110] When the electronic device is turned over, Figure 5 In c, due to the small field of view of the front camera, light source A is not within the field of view of the front camera, while light sources B and C are within the field of view of the front camera. Figure 5 In d, since the field of view of the ambient light detection device is large, light sources A, B and C are still within the field of view of the ambient light detection device.
[0111] It can be seen from this that due to the change in the position of the light source, the impact on the front camera detecting ambient light is greater, and the impact on the ambient light detection device detecting ambient light is smaller, causing the brightness value of the ambient light detected by the front camera to fluctuate greatly, while the brightness value of the ambient light detected by the ambient light detection device is relatively stable.
[0112] In view of this, the ambient light brightness detection method provided in the embodiment of the present application can find the brightest or relatively bright points in the image by analyzing the image data collected by the camera. These bright spots are most likely the positions of the light sources. In order to reduce the impact of the light source position on the ambient light data, the detected ambient light data can be corrected based on the distance between the bright spot and the center point of the image, so that the ambient light data detected by the camera fluctuates less and the output results are relatively stable.
[0113] In a possible scenario, the electronic device can be placed in a scene with relatively stable ambient light. For example, there is a strip of light above a certain space as a light source, and the display screen of the electronic device faces the light source. The electronic device can collect original images through the front camera.
[0114] The front camera may include a complementary metal oxide semiconductor (CMOS) sensor, which can convert the optical information received by the front camera into a raw image. The raw image may be composed of a number of pixels. For example, the CMOS sensor can generate a raw image of 16×12=192 pixels. The value of each pixel in the raw image can represent the brightness of the pixel. Based on the brightness value of the pixel in the raw image, the electronic device can obtain raw data raw_data reflecting the image brightness.
[0115] In the embodiments of the present application, the original image may be an image that reflects the brightness of the ambient light, that is, an image that reflects the brightness of the ambient light. The original image may include an image for display on a display screen, or may include a low-pixel image that is not for display on a display screen, that is, an image that is not for user viewing.
[0116] It is understandable that, because the image displayed on the display screen has a higher pixel count, in order to reduce the image's memory usage on the electronic device, the front-facing camera may not capture the image for display on the display screen. The original image captured by the front-facing camera may have lower pixel counts. For example, the original image's pixel count may be smaller than the minimum pixel count of the image displayed on the display screen. In this way, the original image can serve only as raw data for the electronic device to analyze ambient light brightness. By using an image with smaller pixel counts, the electronic device's memory can be reduced, thereby improving its operating efficiency.
[0117] Optionally, the original data raw_data can be obtained by averaging the brightness values of all or part of the pixels in the original image, or by performing other operations on the brightness values of all or part of the pixels in the original image, which is not limited in the embodiments of the present application.
[0118] Based on the reading mechanism inside the CMOS sensor, the raw data raw_data read by the electronic device may be as shown in the following Table 1. The raw data raw_data in Table 1 may also be understood as a data matrix.
[0119] Table 1
[0120] 18 18 19 22 34 36 37 43 37 46 48 49 255 42 31 28 18 19 20 25 38 41 42 51 44 59 57 146 255 44 30 28 18 19 20 29 43 47 48 58 53 64 63 255 148 42 30 28 18 19 20 31 48 52 56 62 65 72 66 255 61 38 31 30 19 19 20 33 54 56 64 61 84 87 212 255 57 35 32 30 19 19 21 35 56 57 72 65 94 102 255 115 49 36 34 30 19 20 21 31 48 55 75 72 101 118 255 77 43 37 35 28 18 19 20 26 39 55 67 78 101 255 255 64 40 37 34 28 18 19 20 23 48 62 55 78 91 255 89 49 39 38 31 28 18 19 20 22 51 62 52 68 96 255 66 40 38 35 30 27 18 19 19 21 39 59 56 62 255 195 47 37 36 31 29 26 18 19 19 20 28 49 52 46 255 55 38 36 34 30 28 25
[0121] It should be noted that in the raw data collected by the front camera, the light source is located near the lower right corner of the center of the raw data. As can be seen from Table 1, the pixels in the bold part of the data are also located in the local area near the lower right corner of the center of the overall pixels. These bold pixels are relatively large, indicating that the brightness of these areas in the raw data is also relatively high.
[0122] The electronic device can convert the raw data raw_data collected by the front camera into a lux value, where the lux value can represent the illumination intensity of the ambient light. Both the raw data raw_data and the lux value can represent the brightness of the ambient light. When the raw_data increases, the lux value will also increase. The increase ratio of the two can be the same or different, which is not limited in the embodiments of the present application.
[0123] In a possible implementation, the conversion relationship between raw_data and lux value can satisfy the following formula:
[0124] lux = production line calibration coefficient × LuxValueConvert(raw_data).
[0125] Among them, the production line calibration coefficient is used to calibrate the difference between the front camera in the electronic device and the ideal camera. Among them, the ideal camera can also be called a standard camera. Exemplarily, before the electronic device leaves the factory, the front camera in the electronic device can be tested and compared with the standard camera. If there is no difference or the difference is small between the front camera and the standard camera, the production line calibration coefficient can be 1; if there is a deviation between the front camera and the standard camera, the production line calibration coefficient can be greater than 1 or less than 1. In this way, through the production line calibration coefficient, the electronic device can calibrate the hardware difference between the front camera and the standard camera, thereby reducing the difference in the hardware components of the front camera and improving the accuracy of the front camera in detecting the ambient light brightness.
[0126] The LuxValueConvert function is a data calibration function used to calibrate the difference between the ambient light brightness detected by the front camera and the ambient light brightness in the actual environment. In some scenarios, the LuxValueConvert function can also be called a conversion function because it can convert raw data into lux values.
[0127] For example, the LuxValueConvert function can substitute raw_data into an expected function to obtain the ambient brightness information lux, wherein the expected function can be obtained by fitting the test data.
[0128] In a possible implementation, a standard light box can be used in the laboratory to measure ambient brightness, with units accurate to 1 lux. By gradually increasing the ambient brightness, the corresponding raw data can be obtained. After acquiring a large amount of data, function fitting can be performed to evaluate and select the most appropriate fitting function type and function coefficients.
[0129] However, due to the limited light sensitivity of the front camera itself, there is a certain error between the ambient light brightness detected by the front camera and the ambient light brightness in the actual environment. For example, when the ambient light is stable, for example, when the ambient light brightness raw_data value is 400, the electronic device can be turned over and the ambient light brightness detected by the front camera can be tested.
[0130] Ideally, for scenes with stable ambient light, the raw_data value of the ambient light brightness detected by the front camera should be stable around 400 and should not change significantly when the electronic device is flipped.
[0131] However, in actual testing, we can get Figure 6The line graph of the light source position movement and the raw_data value change is shown. It is understood that the light source position can be understood as the distance between the brightest or relatively bright point in the original image and the center point of the original image, or it can be understood as the distance between the brightest point with the largest or larger pixel value in the original data and the center point of the original data in pixel units. For ease of description, the embodiment of the present application takes the brightest point in the original data as an example for explanation. Among them, Figure 6 The horizontal axis is the distance between the brightest point in the original data and the center point of the original data. Figure 6 The vertical axis is the raw_data value of the ambient light brightness detected by the camera.
[0132] As can be seen from the figure, when the distance between the brightest point in the raw data and the center point of the raw data is 0, that is, when the brightest point is at the center point of the raw data, it can be said that the light source is facing the front camera. At this time, the ambient light brightness raw_data value detected by the front camera is close to the theoretical value of 400, and the detection result is more accurate.
[0133] As the brightest point in the raw data moves away from the center point of the raw data, the vertical angle between the corresponding light source and the front camera gradually increases, and the ambient light brightness raw_data value detected by the front camera gradually decreases. This increases the error between the ambient light brightness detected by the front camera and the theoretical value of 400. For example, when the distance between the brightest point in the raw data and the center point of the raw data is 10, the ambient light brightness raw_data value detected by the front camera is around 250, which is significantly different from the theoretical value of 400. In other words, the position of the light source has a significant impact on the fluctuation of the ambient light brightness detected by the front camera.
[0134] To compensate for ambient light fluctuations caused by flipping or moving the electronic device, the raw data collected by the front camera can be calibrated before calculating the lux brightness value. This ensures that the front camera remains stable when detecting ambient light brightness, thereby improving the accuracy of display brightness adjustment.
[0135] according to Figure 6 From the line graph, we can see that the data fluctuation of the ambient light brightness detected by the front camera can satisfy the following formula:
[0136] y=-16.318x+407.14.
[0137] Where y is the ambient light brightness value, and x is the distance between the brightest point of the original data and the center point of the original data.
[0138] According to the above formula, the distance between the brightest point of the original data and the center point of the original data is inversely proportional to the ambient light brightness value. Therefore, the embodiment of the present application can compensate for the ambient light brightness based on the distance between the brightest point of the original data and the center point of the original data.
[0139] For example, when the distance between the brightest point in the raw data and the center point of the raw data is small, the front camera detects the ambient light brightness with high accuracy, and less ambient light compensation can be applied. When the distance between the brightest point in the raw data and the center point of the raw data is large, the front camera detects the ambient light brightness with low accuracy, and more ambient light compensation can be applied. Therefore, reverse compensation for ambient light can be performed based on the above formula.
[0140] For example, the specific ambient light brightness compensation can satisfy the following formula:
[0141] raw_data2=16.318×d+raw_data.
[0142] Wherein, raw_data2 is the value after ambient light brightness compensation is performed on the original data, d is the distance between the brightest point of the original data and the center point of the original data, and raw_data is the original data.
[0143] In a possible implementation, the electronic device can determine the brightest point in the original data based on the data in Table 1. The specific code implementation is as follows:
[0144]
[0145]
[0146] Among them, the findMaxWindow function is a function for determining the brightest point in the original data. In the parameters of the findMaxWindow function, data[][COLS] is used to represent the two-dimensional matrix of the original data raw_data, *maxSum is used to record the maximum window sum, *maxRow is used to record the horizontal position of the brightest point in the original data, and *maxCol is used to record the vertical position of the brightest point in the original data.
[0147] It can be understood from the above code that this embodiment of the application loops through the raw data using each 3×3 data set to find the location of the brightest point. This is because the 3×3 data set can include a center point. By comparing the brightness of the center point of each data set at various locations in the raw data, the location of the brightest point in the raw data can be determined.
[0148] Optionally, the location of the brightest point in the original data can be found using data of sizes such as 2×2, 4×4, or 5×5, which is not limited in this embodiment of the present application. However, since it is inconvenient to determine the location of the center point in 2×2 and 4×4 data, and the calculation dimension of each data set of 5×5 data is larger for 16×12 pixel original data, which increases the computing power of the electronic device, this embodiment of the present application uses data of size 3×3 as an example for illustrative purposes.
[0149] After determining the brightest point in the raw data, the electronic device can calculate the distance d between the brightest point and the center point of the raw data. Distance d can also be understood as the distance in pixels from the brightest point to the center point of the raw data. For example, in the 16×12 pixel raw data above, the horizontal position of the center point in the raw data is 8, and the vertical position of the center point in the raw data is 6.
[0150] Then the distance d from the brightest point to the center point of the original data can satisfy the following formula:
[0151]
[0152] Optionally, when calculating raw_data2, the incident angle from the brightest point to the camera may be used instead of the distance d for calculation, which is not limited in the embodiment of the present application.
[0153] It should be noted that the coefficient 16.318 in the compensation formula for calculating the ambient light brightness raw_data2 is obtained by testing under a certain ambient light brightness scenario (for example, an ambient light brightness of 400). Different coefficient values can be obtained under different ambient light brightness. Therefore, the specific value of the coefficient is not limited in the embodiments of the present application.
[0154] Testing has shown that the value raw_data2 after ambient light compensation of the raw data is positively correlated with the distance from the brightest point to the center point, and also with the raw data raw_data. If the raw data raw_data remains unchanged, the greater the distance from the brightest point to the center point, the larger the value raw_data2 after ambient light compensation of the raw data. If the distance from the brightest point to the center point remains unchanged, the larger the raw data raw_data, the larger the value raw_data2 after ambient light compensation of the raw data.
[0155] The positive correlation between raw_data2 and the distance from the brightest point to the center point may include a linear correlation, an exponential correlation, etc. between raw_data2 and the distance from the brightest point to the center point, which is not limited in the present embodiment. Taking the linear correlation between raw_data2 and the distance from the brightest point to the center point as an example, the ambient light compensation can satisfy the following formula:
[0156] raw_data2=k×d+raw_data.
[0157] Wherein, raw_data2 is the value after ambient light brightness compensation of the original data, d is the distance between the brightest point of the original data and the center point of the original data, k is the coefficient corresponding to the distance from the brightest point to the center point, and k is a positive number, and raw_data is the original data.
[0158] When determining the coefficient corresponding to the distance from the brightest point to the center point, in one possible implementation, the electronic device can segment the ambient light lux value. For example, when the lux value is in a first range, the first coefficient can be used to calculate raw_data2; when the lux value is in a second range, the second coefficient can be used to calculate raw_data2; when the lux value is in a third range, the third coefficient can be used to calculate raw_data2, and so on. This embodiment of the application does not specifically limit the lux value segmentation and coefficient values.
[0159] For example, the lux value in the first range could be [0,500), corresponding to scenes with low ambient light brightness; the lux value in the second range could be [500,5000), corresponding to scenes with brighter ambient light brightness; and the lux value in the third range could be [5000,20000], corresponding to scenes with high ambient light brightness. In this way, different coefficients can be set for different ambient light brightness levels, making corresponding adjustments for different environments, thereby more accurately compensating for ambient light brightness.
[0160] Taking the segmentation of the ambient light brightness lux value as an example, since the raw_data2 value is calculated first and the lux value is calculated later, the electronic device can first calculate the initial lux value and determine the coefficient corresponding to the distance from the brightest point to the center point based on the initial lux value, that is, the coefficient used to calculate raw_data2.
[0161] In one possible implementation of calculating the initial lux value, the initial lux value can satisfy the following formula:
[0162] lux0=calibration coefficient×LuxValueConvert(raw_data).
[0163] Where lux0 is the initial lux value, raw_data is the raw data, LuxValueConvert is the data calibration function, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
[0164] It is understandable that using the above formula to calculate the initial lux value does not require calculating the distance from the brightest point to the center point, nor does it require considering the value of the default coefficient corresponding to the distance from the brightest point to the center point, thereby reducing the computing power of the electronic device and improving the execution efficiency of the electronic device.
[0165] In another possible implementation method for calculating the initial lux value, the electronic device may first calculate the initial lux value using a default coefficient. The initial lux value may satisfy the following formula:
[0166] lux0=calibration coefficient×LuxValueConvert(k0×d+raw_data).
[0167] Where lux0 is the initial lux value, d is the distance from the brightest point to the center point, k0 is the default coefficient, and raw_data is the original data.
[0168] Furthermore, the electronic device can determine whether the default coefficient used is reasonable based on the segmented interval of the initial lux value. The default coefficient can be set based on experience and can be the first coefficient, the second coefficient, the third coefficient, or other values, which are not limited in the present embodiment.
[0169] It is understandable that using the formula containing the default coefficient to calculate the initial lux value can more accurately calculate the current ambient light brightness, that is, the initial lux value, because it takes into account the influence of the distance from the brightest point to the center point on the ambient light brightness. This can more reasonably determine whether the current use of the default coefficient to calculate the ambient light brightness is reasonable.
[0170] For example, if the calculated initial lux value is in the first range, if the default coefficient is equal to the first coefficient, or if it is closest to the first coefficient compared to the second and third coefficients, then the default coefficient is reasonable and can accurately and effectively compensate for the current ambient light brightness.
[0171] If the default coefficient is not equal to the first coefficient, and compared with the first coefficient, the default coefficient is closest to the second coefficient or the third coefficient, it means that the current use of the default coefficient is not reasonable and cannot compensate for the ambient light brightness more accurately and effectively. The electronic device can further use the second coefficient or the third coefficient closest to the default coefficient to recalculate the lux value.
[0172] For example, when the calculated lux value falls within the second range, the second range corresponds to the second coefficient, indicating that the second coefficient is more appropriate and can accurately and effectively compensate for the current ambient light brightness. This ensures that the front camera maintains stable ambient light detection, improves the accuracy of display brightness adjustment, and enhances the user experience.
[0173] When the interval of the calculated lux value is in the third interval, the third interval does not correspond to the second coefficient, which means that the use of the second coefficient is not reasonable. The electronic device can then use the third coefficient to calculate the lux value again until the interval of the lux value calculated by the electronic device corresponds to the coefficient used by the electronic device.
[0174] As you can understand, the calculation method for initial lux values in other ranges is similar to the above logic and will not be repeated here. Since electronic devices often use lux values to measure ambient light brightness, using lux values for data calibration is more convenient for electronic devices and can be easily applied to production lines.
[0175] In another possible implementation, the electronic device may also segment the ambient light brightness raw_data. The embodiment of the present application does not limit the specific interval division of raw_data and the value of the corresponding coefficient.
[0176] It can be understood that since the raw_data data is obtained first and the raw_data2 value is calculated later, when the ambient light brightness raw_data is segmented, there is no need to use the default coefficient. The corresponding coefficient can be determined according to the interval in which the raw_data value is located. This can reduce the number of times the lux value is calculated, reduce the computing power of the electronic device, and improve the operating efficiency of the electronic device.
[0177] Figure 7 A flow chart of a method for detecting ambient light brightness according to an embodiment of the present application is shown.
[0178] S701. After the screen of the electronic device is turned on, the ambient light detection function is started.
[0179] After the electronic device turns on the screen, the ambient light detection function can be activated. The electronic device can power on the front camera and initialize the front camera to turn on the front camera, and then perform step S702 to detect the ambient light brightness through the front camera.
[0180] S702: The electronic device detects ambient light brightness through the front camera.
[0181] After the front camera is powered on, the ambient light detection function of the front camera is turned on. The electronic device can detect the ambient light brightness of the environment where the electronic device is located through the front camera, thereby executing step S703 to compensate for the ambient light brightness.
[0182] S703: The electronic device compensates for the ambient light brightness.
[0183] The specific implementation of ambient light compensation can refer to the description of the above embodiments, such as reverse compensation of ambient light based on the ambient light compensation formula, and will not be repeated here. In this way, when the distance between the brightest point of the raw data and the center point of the raw data is small, less ambient light compensation can be performed. When the distance between the brightest point of the raw data and the center point of the raw data is large, more ambient light compensation can be performed.
[0184] After the ambient light brightness is compensated, step S704 may be executed to automatically adjust the brightness of the display screen.
[0185] S704: Based on the compensated ambient light brightness, the electronic device adjusts the display brightness.
[0186] In a possible implementation, the ambient light brightness detected by the front camera can be based on the raw data (raw_data) output by the front camera. The electronic device can perform ambient light brightness compensation on the raw data and generate an ambient light brightness lux value. The electronic device can then adjust the display brightness based on the lux value. For example, the electronic device can use the lux value as the adjusted display brightness; or the electronic device can obtain the default brightness of the electronic device's display and adjust the default brightness based on the lux value to obtain the adjusted display brightness.
[0187] It is understood that the camera service module of the Framework layer can control the opening and closing of the front camera by issuing instructions to the camera control module of the HAL layer. The sensor service module of the Framework layer can control the opening and closing of the ambient light detection device by issuing instructions to the sensor control module of the HAL layer. When the front camera is used instead of the ambient light detection device, the opening and closing of the front camera needs to be controlled by instructions issued by the sensor service module.
[0188] Since the sensor control module cannot pass the instructions issued by the sensor service module to the front camera, while the camera control module can pass the instructions issued by the camera service module to the front camera, in order to enable the front camera to replace the ambient light detection device, it is necessary to establish a control path between the camera service module and the sensor control module, so as to control the front camera with the help of the camera service module.
[0189] It is understood that the camera service module can be run as an independent process, and the sensor control module can also be run as an independent process. Therefore, when establishing the control path between the camera service module and the sensor control module, it can be established based on the Hardware Abstraction Layer Interface Definition Language (HIDL) service. The HIDL service can be used to define the interface between the Framework layer and the HAL layer based on Binder communication.
[0190] After establishing the control path between the camera service module and the sensor control module, it is also necessary to establish a data path between the camera control module and the sensor control module. Therefore, after turning on the ambient light detection function of the front camera, the camera control module can transmit the ambient light brightness detected by the front camera to the sensor control module, and then the sensor control module reports it to the sensor service module, thereby realizing the adjustment of the display brightness.
[0191] Figure 8 A schematic diagram of data interaction between the camera control module and the sensor control module is shown.
[0192] S801. The camera control module initializes the Android Interface Definition Language (AIDL) service.
[0193] Initializing the AIDL service may include starting the AIDL service. By initializing the AIDL service, communication between the camera control module and the sensor control module may be established. In a possible implementation, the camera control module may initialize the AIDL service in the CHK-CDK submodule.
[0194] It is understandable that the camera control module can initialize the AIDL service during the startup process of the electronic device, or initialize the AIDL service when communication is required between the camera control module and the sensor control module. The embodiment of the present application does not limit the timing of initializing the AIDL service.
[0195] S802: The sensor service module sends a brightness monitoring instruction to the sensor control module.
[0196] After the electronic device is turned on, the ambient light detection application in the application layer can transmit a screen-lighting message to the sensor service module. The screen-lighting message can include the package name of the ambient light detection application. The screen-lighting message can be used to instruct the sensor service module to adjust the brightness of the electronic device display.
[0197] After the sensor service module receives the screen-on message, it can issue a brightness monitoring command to the sensor control module. This brightness monitoring command can be used to instruct the sensor control module to obtain the ambient light brightness. This brightness monitoring command can be in the form of a callback function, so that after the sensor control module obtains the ambient light brightness, it can return the ambient light brightness to the sensor service module.
[0198] In a possible implementation, the SensorManager of the sensor service module can generate a brightness monitoring instruction based on the screen-on message transmitted by the ambient light detection application. The SensorService of the sensor service module can send the brightness monitoring instruction to the sensor control module.
[0199] S803: The sensor control module calls the first interface and registers a data callback function in the camera control module.
[0200] After the sensor control module receives the brightness monitoring instruction, it can call the first interface based on the AIDL service and register the data callback function in the camera control module. The first interface can be used to enable the ambient light detection function of the front camera, and the first interface can include the Active interface of the ambient light service control submodule.
[0201] It is understood that the sensor control module needs to declare the first interface before calling it and registering the data callback function in the camera control module. In a possible implementation, the camera control module and the sensor control module can each register callback interfaces. Once the callback interfaces in the camera control module and the sensor control module are registered, the data callback function in the camera control module is registered. Alternatively, the camera control module can register the callback interface in the camera function customization submodule, and the sensor control module can register the callback interface in the ambient light service control submodule.
[0202] After the sensor control module calls the first interface to turn on the ambient light detection function of the front camera, the sensor control module can register a data callback function in the camera control module. Through the data callback function, the camera control module can transmit the ambient light brightness detected by the front camera to the sensor control module, thereby establishing a data path between the camera control module and the sensor control module, so that the front camera can replace the ambient light device.
[0203] S804: The sensor control module calls the second interface to transmit the first instruction to the camera service module.
[0204] Typically, cameras include two types: front-facing cameras and rear-facing cameras, with at least one front camera and at least one rear camera. Furthermore, the front-facing camera and the rear-facing camera each have multiple functions, including at least one of a photo taking function, a face unlocking function, and an ambient light detection function. To distinguish between different types of cameras and different functions of the same type of camera, the embodiments of the present application can abstract multiple logical cameras based on the camera type and function, with each logical camera corresponding to an identifier.
[0205] For example, based on the front camera's photo function, logical camera A can be abstracted; based on the front camera's ambient light detection function, logical camera B can be abstracted. Logical camera A and logical camera B can correspond to the same front camera or different front cameras. In this embodiment of the application, the photo function of logical camera A, i.e., the front camera, can be identified as Camera ID = 1, and the ambient light detection function of logical camera B, i.e., the front camera, can be identified as Camera ID = 4.
[0206] In an embodiment of the present application, the sensor control module may generate a first instruction through a first interface, and then transmit the first instruction to the camera service module through a second interface.
[0207] The second interface may include a libcamera2ndk_vendor interface of the sensor control module, etc. The first instruction may include an Open Camera instruction. The first instruction may include a first identifier corresponding to the ambient light detection function of the front camera, for example, Camera ID = 4. The first instruction may also include a first package name, which may be the package name of the ambient light detection application.
[0208] S805: The camera service module calls the first function of the camera control module to control the camera driver to power on the front camera, initialize the camera registers, and create a reading thread for the ambient light brightness.
[0209] S806: The camera control module powers on the front camera, initializes the camera registers, and creates a thread for reading ambient light brightness.
[0210] It is understandable that the processes of powering on the front camera, initializing the camera register, etc. may include the relevant processes of turning on the front camera, and may also include the process of powering on and initializing the front camera.
[0211] In a possible implementation, after receiving a first instruction, the CameraService of the camera service module can call a first function based on a first identifier in the first instruction to enable the ambient light detection function of the front camera. In this way, the front camera can be used in place of the ambient light detection device. The first function can be used to enable any function of any camera in the electronic device and can include the Open Camera function in CAMX of the camera control module.
[0212] When the front camera is used instead of the ambient light detection device, the front camera needs to detect the ambient light brightness without capturing images. To reduce the power consumption of the front camera, the camera service module can call the first function based on the first identifier to call the process related to turning on the ambient light detection function of the front camera, such as applying for resource cache, powering on the front camera, initializing the camera register, creating a thread to read the ambient light brightness, etc. The camera service module can skip processes unrelated to turning on the ambient light detection function of the front camera, such as the process of configuring image output resources.
[0213] The camera control module can generate corresponding control instructions by executing the first function. The camera control module can also send the control instructions to the camera driver, thereby controlling the camera driver to apply for resource buffering for the front camera, power on the front camera, initialize camera registers, create a reading thread, etc.
[0214] The created read thread can be used to read and calculate the ambient light brightness detected by the front camera. Optionally, the read thread can periodically read the ambient light brightness detected by the front camera. Based on the initialization of the camera register, the read thread can write the period of the front camera detecting the ambient light brightness, the frequency of the front camera detecting the ambient light brightness, etc. into the register, thereby controlling the operation of the front camera.
[0215] In the embodiment of the present application, when the front camera is used instead of the ambient light detection device, no image output resources are allocated to the front camera, and the front camera does not capture images for display on the display screen. This can reduce the resource consumption of the front camera, thereby improving the performance of the electronic device.
[0216] S807 : The camera driver reports raw data raw_data to the camera control module.
[0217] The camera driver can obtain the original image captured by the front camera and read the raw data raw_data of the original image.
[0218] After obtaining the raw data raw_data, the camera driver may report the raw data raw_data to the camera control module.
[0219] S808: The camera control module performs ambient light brightness compensation and / or calibration on the raw data raw_data.
[0220] The camera control module's implementation of ambient light compensation and / or calibration of the raw data raw_data can be referenced to the description in the above-described embodiments, such as performing ambient light compensation on the raw data raw_data based on an ambient light compensation formula, and will not be further described. Because the camera control module is located at the hardware abstraction layer, it facilitates business logic processing of the data collected by the camera. This facilitates functional differentiation between different products at the hardware abstraction layer and facilitates the use of mathematical libraries for floating-point operations, thereby improving the computing speed of the electronic device.
[0221] Thus, when the distance between the brightest point of the original data and the center point of the original data is small, less ambient light brightness can be compensated. When the distance between the brightest point of the original data and the center point of the original data is large, more ambient light brightness can be compensated.
[0222] Optionally, ambient light compensation and / or calibration of the raw data (raw_data) can also be implemented in the camera driver module. After the camera driver obtains the raw data (raw_data), it can perform ambient light compensation and / or calibration on the raw data to obtain the ambient light lux value. Because the kernel layer supports overriding the raw_data_read function, placing the processing of the raw data (raw_data) within the raw_data_read function makes it easier to implement ambient light compensation and / or calibration of the raw data (raw_data).
[0223] Optionally, ambient light brightness compensation and / or calibration of the raw data raw_data can also be implemented in the sensor control module. After the camera control module obtains the raw data raw_data, it can report the raw data raw_data to the sensor control module. Furthermore, the sensor control module can perform ambient light brightness compensation and / or calibration on the raw data raw_data to obtain the ambient light brightness lux value. In this way, since Raw_dara belongs to ambient light brightness information, and the brightness adjustment of the display screen of the electronic device is implemented through the sensor service module, in terms of business logic, ambient light brightness compensation and / or calibration of the raw data raw_data is implemented in the sensor control module, which facilitates the interaction of upper-layer services and data transmission between the hardware abstraction layer and the framework layer.
[0224] The module for specifically implementing ambient light brightness compensation and / or ambient light brightness calibration is not limited in the embodiments of the present application.
[0225] S809: The camera control module transmits the ambient light brightness lux value to the sensor control module through the data callback function.
[0226] It can be understood that the ambient light brightness lux value can be generated by the camera control module based on the raw data raw_data.
[0227] In one possible implementation, the ambient light brightness lux value may include the ambient light brightness obtained after performing ambient light brightness compensation on the raw data raw_data using a light compensation formula and / or calibrating the raw data raw_data using a data calibration function. The specific calculation formulas for ambient light brightness compensation and calibration can be referred to Figure 6 The relevant description of the corresponding embodiment will not be repeated here.
[0228] In another possible implementation, the ambient light brightness lux value can also be generated based on the raw data raw_data and the state parameters of the front camera, which may include the available state of the ambient light detection function of the front camera and the unavailable state of the ambient light detection function of the front camera.
[0229] It should be noted that in the embodiments of the present application, the ambient light lux value and the raw data raw_data may not be the same brightness value, but rather represent a type of brightness value. For example, the raw data raw_data may represent the brightness values output by the front camera at different times; the ambient light lux value may represent the brightness values transmitted by the camera control module to the sensor control module at different times.
[0230] In one possible implementation, the camera driver can periodically obtain raw data detected by the front camera through a read thread and report the raw data to the camera control module, so that the camera control module can obtain the raw data output by the front camera. The read cycle may include 200ms, and the specific read cycle is not limited in this embodiment of the application.
[0231] In another possible implementation, the camera driver can also periodically obtain raw data detected by the front camera through a read thread and store the raw data in a cache. The camera control module can periodically read the raw data from the cache. Optionally, the camera driver's read cycle can be the same as or different from the camera control module's read cycle.
[0232] After acquiring the raw data (raw_data), the camera function customization submodule of the camera control module generates an ambient light lux value based on the raw data. This value is then passed to the ambient light service control submodule of the sensor control module via a pre-registered data callback function. This allows the sensor control module to report the ambient light lux value to the sensor service module, thereby adjusting the brightness of the electronic device's display.
[0233] S810: The sensor control module reports the ambient light brightness lux value to the sensor service module.
[0234] In one possible implementation, when the sensor service module sends a brightness monitoring instruction to the sensor control module, a callback function can be registered in the sensor control module. Through the callback function, the sensor control module can report the ambient light brightness lux value to the sensor service module.
[0235] In another possible implementation, the sensor service module may periodically read the ambient light brightness lux value of the sensor control module.
[0236] S811. The sensor service module adjusts the brightness of the display screen of the electronic device based on the ambient light lux value.
[0237] In a possible implementation, adjusting the brightness of the display screen may be setting the brightness of the display screen.
[0238] For example, the sensor service module can determine the brightness of the display screen based on the ambient light lux value, and then set the brightness of the display screen to the determined brightness. The sensor service module can also determine the brightness of the display screen based on historical ambient light brightness and the ambient light lux value, and then set the brightness of the display screen to the determined brightness.
[0239] In another possible implementation, adjusting the brightness of the display screen may be adjusting the initial brightness based on the initial brightness of the display screen, wherein the initial brightness may be a brightness value preset by a developer.
[0240] For example, the sensor service module can determine the brightness of the display screen based on the ambient light lux value, and then adjust the brightness of the display screen from the initial brightness to the determined brightness. The sensor service module can also determine the brightness of the display screen based on historical ambient light brightness and the ambient light lux value, and then adjust the brightness of the display screen from the initial brightness to the determined brightness.
[0241] Optionally, when adjusting the brightness of the display screen of the electronic device, it can be adjusted gradually, which can avoid excessive brightness changes that affect the user experience.
[0242] In a possible implementation, when adjusting the display screen brightness, the sensor service module can generate a brightness adjustment instruction and then send the brightness adjustment instruction to the sensor control module. The sensor control module can pass the brightness adjustment instruction to the display screen driver, so that the display screen driver can adjust the display screen brightness based on the brightness adjustment instruction.
[0243] It is understandable that the above description uses the example of the electronic device turning on the screen for the first time when the screen is turned on. When the electronic device turns on the screen for a non-first time, the electronic device may not execute the process of initializing the AIDL service in step S801 and the process of registering the data callback function in step S803.
[0244] In an embodiment of the present application, when verifying whether an electronic device is currently using the ambient light brightness detection method of the embodiment of the present application, in a possible implementation, it is possible to first determine whether the electronic device can currently automatically adjust the light by blocking the front camera. If the brightness of the display screen of the electronic device remains unchanged or does not change significantly after blocking the front camera, it means that the electronic device is currently unable to automatically adjust the light, and the ambient light brightness detection method of the embodiment of the present application is not used. If the brightness of the display screen of the electronic device becomes dim after blocking the front camera, it means that the electronic device can currently automatically adjust the light, and it is possible that the ambient light brightness detection method of the embodiment of the present application is used, which requires further verification.
[0245] When the front camera is blocked and the electronic device can automatically adjust the light, it can be determined whether the front camera is powered on. For example, a multimeter can be used to detect whether the front camera is powered on.
[0246] When the front camera is powered on, it can be further verified whether the front camera is used to replace the ambient light detection device to detect the ambient light brightness. For example, the electronic device can read the raw data collected by the front camera based on the IIC protocol. The raw data can also be called IIC data. The IIC data can include raw_data, so that the change of raw_data with the ambient light brightness can be analyzed. If raw_data can change with the change of ambient light brightness, it means that the electronic device uses the front camera instead of the ambient light detection device to detect the ambient light brightness.
[0247] If it is determined that the front-facing camera will be used instead of the ambient light detection device to detect ambient light brightness, the electronic device can be flipped or moved in a scene where the ambient light brightness remains unchanged to adjust the angle at which the light source enters the front-facing camera, thereby obtaining raw data on ambient light brightness corresponding to different light source positions. If the raw data is related to different field of view angles of the front-facing camera, it indicates that the electronic device is currently using the ambient light brightness detection method of the present invention.
[0248] The following describes the method of the embodiment of the present application in detail through specific embodiments. The following embodiments can be combined with each other or implemented independently, and the same or similar concepts or processes may not be repeated in some embodiments.
[0249] Figure 9 The following is a method for detecting ambient light brightness according to an embodiment of the present application. The method includes:
[0250] S901: Obtain first data indicating ambient light brightness based on a first image captured by a camera.
[0251] In the embodiment of the present application, the camera may include a front camera of the electronic device, or may include a rear camera of the electronic device, etc., which is not limited in the embodiment of the present application.
[0252] The first data may include the original data raw_data in the above embodiment, and the first data may be understood as the original data corresponding to the first image.
[0253] The first image may be an image used to reflect the brightness of the ambient light, that is, an image used to reflect the brightness of the ambient light. The first image may include an image for display on a display screen, or may include an image with lower pixels that is not used for display on a display screen, that is, an image that is not used for user browsing.
[0254] It is understandable that, because the image displayed on the display screen has a relatively high pixel count, in order to reduce the image's memory usage on the electronic device, the front-facing camera may not capture the image for display on the display screen. The first image captured by the front-facing camera may have a lower pixel count. For example, the pixel count of the first image may be smaller than the minimum pixel count of the image displayed on the display screen. In this way, the first image can serve as raw data for the electronic device to analyze ambient light brightness. By using an image with a smaller pixel count, a smaller memory capacity can be occupied by the electronic device, thereby improving the operating efficiency of the electronic device.
[0255] S902 : Compensate the first data by a first value to obtain a first ambient light brightness, wherein the first value is related to a first distance, and the first distance includes a distance between a brightest point in the first image and a center point of the first image.
[0256] In an embodiment of the present application, the first ambient light brightness may include the lux value in the above embodiment, and the electronic device may calculate the first ambient light brightness based on the first data. In the process of calculating the first ambient light brightness, due to the limitations of the camera's own light sensitivity accuracy, there may be a certain error between the ambient light brightness detected by the camera and the ambient light brightness in the actual environment. Therefore, the electronic device may perform ambient light compensation on the first data so that the ambient light brightness detected by the camera can be output stably.
[0257] The first value can be understood as the value after ambient light brightness compensation is performed on the first data. The first value can include raw_data2 in the above embodiment. The specific process of calculating raw_data2 can refer to the relevant description in the above embodiment and is not repeated here. The first value being related to the first distance can include the first value being linearly related to the first distance, or the first value being exponentially related to the first distance, etc., which is not limited in the present embodiment.
[0258] It will be appreciated that the first compensation value is proportional to the distance between the brightest point in the first image and the center point of the first image. When the distance between the brightest point and the center point is small, the camera detects ambient light brightness with high accuracy, so less ambient light compensation can be applied, and the first value can be small. When the distance between the brightest point and the center point is large, the camera detects ambient light brightness with low accuracy, so more ambient light compensation can be applied, and the first value can be large.
[0259] S903: Obtain second data indicating the brightness of ambient light based on the second image captured by the camera.
[0260] In the embodiment of the present application, the second image is similar to the first image. The second image may also be an image used to reflect the brightness of the ambient light, which will not be described in detail.
[0261] The second data can be understood as original data corresponding to the second image.
[0262] S904. Compensate the second data with a second value to obtain a second ambient light brightness, where the second value is related to a second distance, the second distance includes a distance between a brightest point in the second image and a center point of the second image, the second distance is greater than the first distance, and the second value is greater than the first value.
[0263] In the embodiment of the present application, the second ambient light brightness may include a lux value, and the electronic device may calculate the second ambient light brightness based on the second data. In the process of calculating the second ambient light brightness, due to the limitations of the camera's own light sensitivity accuracy, there may be a certain error between the ambient light brightness detected by the camera and the ambient light brightness in the actual environment. Therefore, the electronic device may perform ambient light compensation on the second data so that the ambient light brightness detected by the camera can be output stably.
[0264] The second value can be understood as the value after the second data is compensated for ambient light brightness. The second value can include raw_data2 in the above embodiment. The specific process of calculating raw_data2 can refer to the relevant description in the above embodiment and will not be repeated here.
[0265] The second value being related to the second distance may include the second value being linearly related to the second distance, or the second value being exponentially related to the second distance, etc., which is not limited in the embodiments of the present application.
[0266] It will be appreciated that the second compensation value is proportional to the distance between the brightest point in the second image and the center point of the second image. When the distance between the brightest point and the center point is small, the camera detects ambient light brightness with high accuracy, so less ambient light compensation can be applied, and the second value can be small. When the distance between the brightest point and the center point is large, the camera detects ambient light brightness with low accuracy, so more ambient light compensation can be applied, and the second value can be large.
[0267] The ambient light brightness detection method provided in the embodiment of the present application can find the brightest or relatively bright points in the image by analyzing the image data collected by the camera. These bright spots are most likely the positions of the light sources. In order to reduce the influence of the light source position on the ambient light data, the detected ambient light data can be corrected based on the distance between the bright spot and the center point of the image, so that the ambient light data detected by the camera fluctuates less and the output result is relatively stable.
[0268] Optional, in Figure 9 On the basis of the corresponding embodiment, the first value is linearly correlated with the first distance, and the coefficient of the first distance is a positive number.
[0269] In the embodiment of the present application, the first value is linearly correlated with the first distance and the coefficient of the first distance is a positive number, which can be understood as the first value being proportional to the first distance. Therefore, when the first distance is smaller, the first value is smaller; when the first distance is larger, the first value is also larger.
[0270] When the first distance is short, the camera can detect ambient light with high accuracy, so less compensation can be made for the ambient light, and the first value can be small. When the first distance is long, the camera can detect ambient light with low accuracy, so more compensation can be made for the ambient light, and the first value can be large. In this way, the detected ambient light data can be corrected based on the first distance, resulting in less fluctuation in the ambient light data detected by the camera and a relatively stable output result.
[0271] Optional, in Figure 9 Based on the corresponding embodiment, the first value satisfies the following formula:
[0272] raw_data2=k×d+raw_data.
[0273] Among them, raw_data2 is the first value, d is the first distance, k is the coefficient of the first distance, and raw_data is the first data.
[0274] In the embodiment of the present application, the formula of the first value raw_data2 can refer to the relevant description in the above embodiment and will not be repeated here.
[0275] It can be understood that the k value can be set to a fixed value, which can be an empirical value preset in the electronic device. The k value can also be set to different values according to the ambient light brightness. For example, different ambient light brightness can correspond to different k values, or different ambient light brightness ranges can correspond to different k values. Exemplarily, the k value can include 16.318 in the above embodiment, etc. The specific value of k is not limited in the embodiment of this application.
[0276] Different k values can be set for different ambient light brightness, so that corresponding adjustments can be made to different ambient light, thereby compensating for the ambient light brightness more accurately.
[0277] Optional, in Figure 9 On the basis of the corresponding embodiment, before compensating the first data for the first value to obtain the first ambient light brightness, it may also include: determining the coefficient of the first distance; compensating the first data for the first value to obtain the first ambient light brightness may include: obtaining the first value based on the first distance and the coefficient of the first distance, compensating the first data for the first value to obtain the first ambient light brightness.
[0278] In the embodiment of the present application, before compensating the first data with the first value, it is known from the formula corresponding to the first value that the coefficient of the first distance needs to be determined first. The specific value of the coefficient of the first distance can be referred to the description in the above embodiment and will not be repeated here.
[0279] It can be understood that different values of the coefficient of the first distance will result in different compensated first values. Therefore, the coefficient of the first distance can be determined based on the ambient light brightness lux value, or based on the first data, or based on other data, which is not limited in the embodiments of the present application.
[0280] By determining a suitable coefficient of the first distance, the first data can be compensated more accurately to obtain a first ambient light brightness that matches the actual environment, thereby improving the accuracy of display brightness adjustment and enhancing the user experience.
[0281] Optional, in Figure 9 Based on the corresponding embodiment, determining the coefficient of the first distance may include: calculating the third ambient light brightness, where the third ambient light brightness is related to the first data; if the third ambient light brightness belongs to the first range, the coefficient of the first distance is the first coefficient; or, if the third ambient light brightness belongs to the second range, the coefficient of the first distance is the second coefficient; or, if the third ambient light brightness belongs to the third range, the coefficient of the first distance is the third coefficient; wherein, the ambient light brightness of the first range is less than the ambient light brightness of the second range, the ambient light brightness of the second range is less than the ambient light brightness of the third range, and the first coefficient, the second coefficient and the third coefficient are all different.
[0282] In the embodiment of the present application, the third ambient light brightness may include a lux value for representing the ambient light brightness. The third ambient light brightness may be used as a lux value for determining a coefficient of the first distance before calculating the first ambient light brightness.
[0283] The coefficient of the first distance can be determined based on the brightness of the third ambient light. The electronic device can divide the brightness of the third ambient light into different brightness ranges. The brightness of the third ambient light can be divided into one or more brightness ranges. The specific ranges of the divisions are not limited in the embodiments of the present application.
[0284] For example, taking the third ambient light brightness as being divided into three ranges, the first range may include [0, 500) in the above embodiment, the second range may include [500, 5000) in the above embodiment, and the third range may include [5000, 20000] in the above embodiment.
[0285] It's understandable that different ranges correspond to different ambient light levels. For example, the first range can correspond to scenes with low ambient light levels; the second range can correspond to scenes with brighter ambient light levels; and the third range can correspond to scenes with high ambient light levels. This allows different coefficients to be set for different ambient light levels, allowing for adjustments to be made for different environments, resulting in more accurate compensation for ambient light levels. Furthermore, since electronic devices often use lux values to measure ambient light brightness, using lux values for data calibration is more convenient for electronic devices and can be easily applied to production lines.
[0286] Optional, in Figure 9 Based on the corresponding embodiment, the brightness of the third ambient light satisfies the following formula:
[0287] lux0=calibration coefficient×LuxValueConvert(raw_data).
[0288] Wherein, lux0 is the third ambient light brightness, raw_data is the first data, LuxValueConvert is a data calibration function used to calibrate the difference between the first data and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
[0289] In the embodiment of the present application, the third ambient light brightness can be obtained based on the first data. The third ambient light brightness can include the initial lux value in the above embodiment.
[0290] It is understandable that when using this formula to calculate the initial lux value, there is no need to calculate the distance from the brightest point to the center point, nor is there any need to consider the value of the default coefficient corresponding to the distance from the brightest point to the center point, which reduces the computing power of the electronic device and improves the execution efficiency of the electronic device.
[0291] Optional, in Figure 9 Based on the corresponding embodiment, the brightness of the third ambient light satisfies the following formula:
[0292] lux0=calibration coefficient×LuxValueConvert(k0×d+raw_data).
[0293] Where lux0 is the third ambient light brightness, d is the first distance, k0 is the default coefficient, raw_data is the first data, LuxValueConvert is a data calibration function used to calibrate the difference between the first data and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
[0294] In the embodiment of the present application, the default coefficient can be set based on experience, and the default coefficient can be the same as or different from the first coefficient, the second coefficient, or the third coefficient.
[0295] It is understandable that using the formula containing the default coefficient to calculate the initial lux value can more accurately calculate the current ambient light brightness, that is, the initial lux value, because it takes into account the influence of the distance from the brightest point to the center point on the ambient light brightness. This can more reasonably determine whether the current use of the default coefficient to calculate the ambient light brightness is reasonable.
[0296] Optional, in Figure 9 On the basis of the corresponding embodiment, the coefficient of the first distance is related to the first data.
[0297] In the embodiment of the present application, since the first data is obtained first and the first value is calculated later, the coefficient of the first distance is determined according to the first data, and there is no need to use the default coefficient or calculate the initial lux value. The corresponding coefficient can be determined according to the interval in which the first data is located. This can reduce the number of times the lux value is calculated, reduce the computing power of the electronic device, and improve the operating efficiency of the electronic device.
[0298] Optional, in Figure 9 On the basis of the corresponding embodiment, if the first data belongs to the fourth range, the coefficient of the first distance is the fourth coefficient; or, if the first ambient light brightness belongs to the fifth range, the coefficient of the first distance is the fifth coefficient; or, if the first ambient light brightness belongs to the sixth range, the coefficient of the first distance is the sixth coefficient; wherein, the ambient light brightness of the fourth range is less than the ambient light brightness of the fifth range, and the ambient light brightness of the fifth range is less than the ambient light brightness of the sixth range, and the fourth coefficient, the fifth coefficient and the sixth coefficient are all different.
[0299] In an embodiment of the present application, the fourth coefficient may be the same as or different from the first coefficient, the second coefficient or the third coefficient; the fifth coefficient may be the same as or different from the first coefficient, the second coefficient or the third coefficient; the sixth coefficient may be the same as or different from the first coefficient, the second coefficient or the third coefficient, and the fourth coefficient, the fifth coefficient and the sixth coefficient are all different.
[0300] It is understood that different ranges of the first data may correspond to different ambient light levels. For example, the fourth range may correspond to scenes with low ambient light levels; the fifth range may correspond to scenes with high ambient light levels; and the sixth range may correspond to scenes with high ambient light levels. In this way, different coefficients may be set for different ranges of the first data, thereby making corresponding adjustments for different environments and more accurately compensating for ambient light levels.
[0301] Optional, in Figure 9 Based on the corresponding embodiment, the brightness of the first ambient light satisfies the following formula:
[0302] lux = calibration coefficient × LuxValueConvert(raw_data2).
[0303] Wherein, lux is the first ambient light brightness, raw_data2 is the first value, LuxValueConvert is a data calibration function used to calibrate the difference between the first value and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
[0304] In the embodiment of the present application, the brightness of the first ambient light can refer to the relevant description of the formula corresponding to the conversion relationship between raw_data and lux value in the above embodiment, and will not be repeated here.
[0305] As can be seen from this formula, the electronic device can perform ambient light compensation on the raw data raw_data collected by the front camera to obtain raw_data2, and calibrate raw_data2 to obtain the lux value, thereby reducing the differences in the hardware components of the front camera, calibrating the difference in ambient light brightness detected by the front camera and the ambient light brightness in the actual environment, and improving the accuracy of the front camera's detection of ambient light brightness.
[0306] Optional, in Figure 9Based on the corresponding embodiments, the electronic device includes a camera service module, a sensor service module, a camera control module, a sensor control module, and a camera driver. Before obtaining the first data for indicating the brightness of the ambient light based on the first image captured by the camera, it may also include: sending a brightness monitoring instruction to the sensor control module based on the sensor service module; calling the first interface based on the Android interface definition language AIDL service based on the brightness monitoring instruction based on the sensor control module, and the first interface is used to register a callback function in the camera control module; calling the second interface based on the hardware abstraction layer interface definition language HIDL service based on the sensor control module, and passing the first instruction to the camera service module, the first instruction is used to instruct the camera to capture an image and obtain data for indicating the brightness of the ambient light; calling the first function in the camera control module based on the first instruction based on the camera service module; executing the first function based on the camera control module to control the camera driver to power on the camera, initialize the camera register and create a reading thread for the ambient light brightness.
[0307] In the embodiment of the present application, the interaction process between the specific camera service module, sensor service module, camera control module, sensor control module, and camera driver modules can refer to Figure 8 The relevant descriptions in the corresponding embodiments are omitted here.
[0308] Specifically, the description of sending a brightness monitoring instruction to the sensor control module based on the sensor service module can be referred to in step S802. The description of calling the first interface based on the sensor control module can be referred to in step S803. The description of passing the first instruction to the camera service module based on the calling of the second interface based on the sensor control module can be referred to in step S804. The description of calling the first function in the camera control module based on the first instruction based on the camera service module can be referred to in step S805. The description of executing the first function based on the camera control module to control the camera driver to power on the camera, initialize the camera registers, and create a thread for reading the ambient light brightness can be referred to in step S806.
[0309] It is understandable that when the front camera is used in place of the ambient light detection device, no image output resources are allocated to the front camera, and the front camera does not capture images for display on the display. This can reduce resource consumption of the front camera and thus improve the performance of the electronic device.
[0310] Optional, in Figure 9On the basis of the corresponding embodiment, after obtaining the first data for indicating the brightness of the ambient light based on the first image captured by the camera, it can also include: reporting the first data to the camera control module based on the camera driver; compensating the first data by the first value to obtain the first ambient light brightness, including: compensating the first data by the first value based on the camera control module, the sensor control module or the camera driver to obtain the first ambient light brightness.
[0311] In this embodiment of the present application, the camera driver reports the first data to the camera control module, as described in step S807. The camera control module, sensor control module, or camera driver compensates the first data for the first value to obtain the first ambient light brightness, as described in step S808.
[0312] Thus, when the distance between the brightest point of the original data and the center point of the original data is small, less ambient light brightness can be compensated. When the distance between the brightest point of the original data and the center point of the original data is large, more ambient light brightness can be compensated.
[0313] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0314] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of method. In order to realize the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily appreciate that, in combination with the method steps of each example described in the embodiment disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in a hardware or computer software driven hardware manner depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0315] The embodiment of the present application can divide the functional modules of the device implementing the method according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. In actual implementation, there may be other division methods.
[0316] like Figure 10 FIG. 1 is a schematic diagram of the structure of a chip provided in an embodiment of the present application. The chip 1000 includes one or more (including two) processors 1001 , a communication line 1002 , a communication interface 1003 , and a memory 1004 .
[0317] In some embodiments, the memory 1004 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.
[0318] The method described in the above embodiment of the present application can be applied to the processor 1001, or implemented by the processor 1001. The processor 1001 may be an integrated circuit chip with signal processing capabilities. During the implementation process, each step of the above method can be completed by an integrated logic circuit of the hardware in the processor 1001 or an instruction in the form of software. The above-mentioned processor 1001 can be a general-purpose processor (for example, a microprocessor or a conventional processor), a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates, transistor logic devices or discrete hardware components. The processor 1001 can implement or execute the methods, steps and logic block diagrams related to each processing disclosed in the embodiment of the present application.
[0319] The steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. Among them, the software module can be located in a storage medium mature in the art such as a random access memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable read only memory (EEPROM). The storage medium is located in the memory 1004, and the processor 1001 reads the information in the memory 1004 and completes the steps of the above method in combination with its hardware.
[0320] The processor 1001 , the memory 1004 , and the communication interface 1003 can communicate with each other via the communication line 1002 .
[0321] In the above embodiment, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory or downloaded and installed in the memory in the form of software.
[0322] The present application also provides a computer program product including one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. For example, the available medium can include magnetic media (e.g., floppy disk, hard disk or tape), optical media (e.g., digital versatile disc (DVD)), or semiconductor media (e.g., solid state disk (SSD)).
[0323] The present application also provides a computer-readable storage medium. The methods described in the above embodiments can be implemented in whole or in part via software, hardware, firmware, or any combination thereof. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one location to another. The storage medium can be any target medium that can be accessed by a computer.
[0324] As one possible design, computer-readable media may include compact disc read-only memory (CD-ROM), RAM, ROM, EEPROM, or other optical disc storage; computer-readable media may include magnetic disk storage or other magnetic disk storage devices. Moreover, any connecting line may also be appropriately referred to as a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk, and Blu-ray disc, where disks typically reproduce data magnetically, while discs reproduce data optically using lasers.
[0325] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
Claims
1. A method for detecting ambient light brightness, characterized in that: The method comprises: Obtaining first data indicating ambient light brightness based on a first image captured by a camera; Compensating the first data to obtain a first value, and obtaining a first ambient light brightness according to the first value, wherein the first value is positively correlated with a first distance, and the first distance includes a distance between a brightest point in the first image and a center point of the first image; obtaining second data indicating the brightness of ambient light based on a second image captured by the camera; The second data is compensated to obtain a second value, and a second ambient light brightness is obtained according to the second value, wherein the second value is positively correlated with a second distance, the second distance includes the distance between the brightest point in the second image and the center point of the second image, the second distance is greater than the first distance, and the second value is greater than the first value.
2. The method according to claim 1, characterized in that The first value is linearly correlated with the first distance, and a coefficient of the first distance is a positive number.
3. The method according to claim 2, characterized in that The first value satisfies the following formula: Among them, raw_data2 is the first value, d is the first distance, k is the coefficient of the first distance, and raw_data is the first data.
4. The method according to claim 3, characterized in that Before compensating the first data to obtain a first value and obtaining a first ambient light brightness according to the first value, the method further includes: determining a coefficient of the first distance; compensating the first data to obtain a first value; The compensating the first data to obtain a first value, and obtaining a first ambient light brightness according to the first value, includes: The first data is compensated to obtain the first value, and the first ambient light brightness is obtained according to the first value, wherein the first value is obtained based on the first distance and a coefficient of the first distance.
5. The method according to claim 4, characterized in that The coefficient for determining the first distance includes: calculating a third ambient light brightness, where the third ambient light brightness is related to the first data; If the brightness of the third ambient light belongs to the first range, the coefficient of the first distance is the first coefficient; Alternatively, if the third ambient light brightness falls within the second range, the coefficient of the first distance is the second coefficient; Alternatively, if the third ambient light brightness belongs to a third range, the coefficient of the first distance is a third coefficient; The ambient light brightness in the first range is smaller than the ambient light brightness in the second range, the ambient light brightness in the second range is smaller than the ambient light brightness in the third range, and the first coefficient, the second coefficient and the third coefficient are all different.
6. The method according to claim 5, characterized in that The third ambient light brightness satisfies the following formula: ; Among them, lux0 is the third ambient light brightness, raw_data is the first data, LuxValueConvert is a data calibration function used to calibrate the difference between the first data and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
7. The method according to claim 5, characterized in that The third ambient light brightness satisfies the following formula: ; Among them, lux0 is the third ambient light brightness, d is the first distance, k0 is the default coefficient, raw_data is the first data, LuxValueConvert is a data calibration function used to calibrate the difference between the first data and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
8. The method according to claim 3, characterized in that The coefficient of the first distance is related to the first data.
9. The method according to claim 8, characterized in that If the brightness of the first ambient light falls within a fourth range, the coefficient of the first distance is a fourth coefficient; Alternatively, if the brightness of the first ambient light belongs to the fifth range, the coefficient of the first distance is the fifth coefficient; Alternatively, if the brightness of the first ambient light belongs to the sixth range, the coefficient of the first distance is the sixth coefficient; The ambient light brightness in the fourth range is smaller than the ambient light brightness in the fifth range, the ambient light brightness in the fifth range is smaller than the ambient light brightness in the sixth range, and the fourth coefficient, the fifth coefficient, and the sixth coefficient are all different.
10. The method according to any one of claims 1 to 9, characterized in that The first ambient light brightness satisfies the following formula: ; Among them, lux is the first ambient light brightness, raw_data2 is the first value, LuxValueConvert is a data calibration function used to calibrate the difference between the first value and the ambient light brightness in the actual environment, and the calibration coefficient is used to calibrate the difference between the camera and the standard camera.
11. The method according to any one of claims 1 to 9, characterized in that The electronic device includes a camera service module, a sensor service module, a camera control module, a sensor control module, and a camera driver. Before obtaining first data indicating the brightness of ambient light based on a first image captured by the camera, the electronic device further includes: Sending a brightness monitoring instruction to the sensor control module based on the sensor service module; Based on the brightness monitoring instruction, the sensor control module calls a first interface based on the Android Interface Definition Language AIDL service, where the first interface is used to register a callback function in the camera control module; Calling a second interface based on a hardware abstraction layer interface definition language (HIDL) service based on the sensor control module to transmit a first instruction to the camera service module, where the first instruction is used to instruct the camera to capture an image and obtain data indicating the brightness of the ambient light; Based on the first instruction, the camera service module calls a first function in the camera control module; The first function is executed based on the camera control module to control the camera driver to power on the camera, initialize the camera register and create a reading thread for the ambient light brightness.
12. The method according to claim 11, characterized in that After obtaining first data indicating the brightness of ambient light based on the first image captured by the camera, the method further includes: Reporting the first data to the camera control module based on the camera driver; Compensating the first data by a first value to obtain a first ambient light brightness includes: Based on the camera control module, the sensor control module or the camera driver, the first data is compensated with the first value to obtain the first ambient light brightness.
13. An electronic device, characterized in that: The electronic device includes: one or more processors and memory; The memory is coupled to the one or more processors, and is used to store computer program code, where the computer program code includes computer instructions. The one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 1 to 12.
14. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that The computer-readable storage medium includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 12.
16. A computer program product, characterized in that The computer program product comprises a computer program code, and when the computer program code is run on an electronic device, the electronic device is enabled to perform the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Screen brightness adjusting method and device, terminal and storage medium
CN115831076A
Alignment factor for ambient lighting calibration
US20120019494A1