Display screen brightness adjustment method, electronic device and storage medium

By calculating the brightness interval and calibration coefficient using the brightness data of the previous and current frames in electronic devices, and adjusting the brightness of the display screen, the problem of low camera detection accuracy is solved, and the stable adjustment of the brightness of the display screen is achieved, and the user experience is improved.

CN119252210BActive Publication Date: 2025-08-15HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410427040.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-09
Publication Date
2025-08-15
Estimated Expiration
2044-04-09

AI Technical Summary

Technical Problem

In the prior art, the accuracy of detecting the brightness of ambient light through a camera is low, resulting in unstable adjustment of the display screen brightness of the electronic device and affecting the user experience.

Method used

By acquiring the ambient light brightness detected in the previous frame and the image data of the current frame, calculating the second ambient light brightness, and determining the target brightness interval and calibration coefficient in the correspondence between the preset brightness interval and the calibration coefficient, the display brightness is adjusted to ensure the continuity and accuracy of the adjustment.

Benefits of technology

It improves the accuracy of ambient light brightness detection, ensures smoothness of display brightness adjustment, reduces visual perception changes of users, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119252210B_ABST
    Figure CN119252210B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a method for adjusting the brightness of a display screen, an electronic device, and a storage medium, and relates to the technical field of electronic devices. The method includes: obtaining the first ambient light brightness detected by the target camera of the electronic device in the previous frame. Based on the first brightness interval to which the first ambient light brightness belongs, and the target image data collected by the target camera in the current frame, the second ambient light brightness is calculated. Based on the second ambient light brightness, the target brightness interval of the current frame is determined. In the correspondence between the preset brightness interval and the calibration coefficient, the calibration coefficient corresponding to the target brightness interval is determined to obtain the target calibration coefficient; the multiple brightness intervals in the correspondence are arranged in order from low to high according to the brightness included. Based on the target calibration coefficient and the target image data, the target ambient light brightness of the current frame is calculated. Based on the target ambient light brightness of the current frame, the brightness of the display screen of the electronic device is adjusted. In this way, the user experience can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of electronic equipment, and in particular to a method for adjusting the brightness of a display screen, an electronic device, and a storage medium. Background Art

[0002] Currently, the displays of many electronic devices, including smartphones, tablets, desktop computers, and wearable devices, all feature automatic brightness adjustment. This feature automatically adjusts the display brightness based on ambient light levels to adapt to different light intensity environments, thereby improving the user experience and reducing the power consumption of electronic devices.

[0003] In related art, in order to reduce the cost of electronic devices, a camera (e.g., a front-facing camera) in the electronic device is used instead of an ambient light detection device. In other words, the camera in the electronic device is used to detect the ambient light brightness. The brightness of the electronic device's display screen is then adjusted based on the detected ambient light brightness.

[0004] However, the accuracy of detecting the ambient light brightness through the camera is low, resulting in large changes in the brightness of the electronic device's display screen when the brightness is adjusted, affecting the user experience. Summary of the Invention

[0005] The purpose of the embodiments of the present application is to provide a method for adjusting display brightness, an electronic device, and a storage medium to improve the accuracy of detecting ambient light brightness, thereby minimizing changes in the brightness of the electronic device's display when adjusting the brightness, and improving the user experience. The specific technical solution is as follows:

[0006] In a first aspect, to achieve the above-mentioned objectives, embodiments of the present application provide a method for adjusting the brightness of a display screen, the method being applied to an electronic device, the method comprising:

[0007] Acquire the ambient light brightness detected by the target camera of the electronic device in a previous frame to obtain a first ambient light brightness;

[0008] Calculating a second ambient light brightness based on a first brightness interval to which the first ambient light brightness belongs and target image data captured by the target camera in a current frame;

[0009] Determining a brightness range of the current frame based on the second ambient light brightness to obtain a target brightness range;

[0010] In a preset correspondence between brightness intervals and calibration coefficients, determining the calibration coefficient corresponding to the target brightness interval to obtain the target calibration coefficient; wherein the plurality of brightness intervals in the correspondence are arranged in order from low to high according to the brightness included;

[0011] Calculating the target ambient light brightness of the current frame based on the target calibration coefficient and the target image data;

[0012] Adjust the brightness of the display screen of the electronic device based on the target ambient light brightness of the current frame.

[0013] As can be seen from the above, the technical solution provided by this embodiment determines the target brightness interval of the current frame based on the first brightness interval to which the ambient light brightness detected in the previous frame belongs. The target brightness interval of the current frame and the brightness interval to which the ambient light brightness detected in the previous frame belongs will not cross the brightness interval. Furthermore, the target ambient light brightness of the current frame is determined based on the target brightness interval, so that the target ambient light brightness can be located in the target brightness interval, thereby improving the accuracy of the determined target ambient light brightness. Furthermore, when the display brightness is adjusted based on the target ambient light brightness, the display brightness of the electronic device will not be adjusted across the brightness interval. This can ensure that when the display brightness of the electronic device is adjusted, the change in display brightness is small, thereby improving the user experience.

[0014] In one embodiment of the present application, before calculating the second ambient light brightness based on the first brightness interval to which the first ambient light brightness belongs and the target image data captured by the target camera in the current frame, the method further includes:

[0015] determining whether to switch parameter settings of the target camera from a brightness interval preceding the first brightness interval to the first brightness interval;

[0016] The calculating the second ambient light brightness based on the first brightness interval to which the first ambient light brightness belongs and the target image data collected by the target camera in the current frame includes:

[0017] When the parameter setting of the target camera is not switched from a brightness interval preceding the first brightness interval to the first brightness interval, determining a calibration coefficient corresponding to a brightness interval preceding the first brightness interval in a preset correspondence between brightness intervals and calibration coefficients to obtain a first calibration coefficient;

[0018] The second ambient light brightness is calculated based on the first calibration coefficient and the target image data captured by the target camera in the current frame.

[0019] As can be seen from the above, in the technical solution of this embodiment, the first brightness interval to which the first ambient light brightness detected by the target camera in the previous frame belongs is determined, and when the parameter setting of the target camera is not switched from the previous brightness interval of the first brightness interval to the first brightness interval, the second ambient light brightness for estimating the target brightness interval of the current frame is determined in combination with the previous brightness interval of the first brightness interval. The target brightness interval determined based on the second ambient light brightness will not always be a higher brightness interval, which can avoid the problem that the display brightness cannot be reduced to a lower brightness interval after being adjusted to a higher brightness interval (such as an ultra-high brightness interval), thereby improving the user experience. In addition, the target brightness interval and the first brightness interval will not cross the brightness interval, which can avoid adjusting the display brightness across the brightness interval, so that the user visually perceives a smaller change in the display brightness, that is, the user can adjust the display brightness without perception, thereby improving the user experience.

[0020] In one embodiment of the present application, determining the brightness range of the current frame based on the second ambient light brightness to obtain the target brightness range includes:

[0021] Determining whether the brightness of the second ambient light is within a brightness interval preceding the first brightness interval;

[0022] When the brightness of the second ambient light is in a brightness interval preceding the first brightness interval, determining the brightness interval preceding the first brightness interval as the brightness interval of the current frame to obtain a target brightness interval;

[0023] When the brightness of the second ambient light is not within a brightness interval preceding the first brightness interval, determining whether the brightness of the second ambient light is within the first brightness interval;

[0024] When the brightness of the second ambient light is within the first brightness range, the first brightness range is determined to be the brightness range of the current frame, and a target brightness range is obtained.

[0025] As can be seen from the above, in the technical solution of this embodiment, the second ambient light brightness for estimating the target brightness interval of the current frame is determined in combination with the previous brightness interval of the first brightness interval. Based on the second ambient light brightness, the target brightness interval is determined to be the previous brightness interval of the first brightness interval, or the first brightness interval, so that the target brightness interval will not always be a higher brightness interval, which can avoid the problem that the brightness cannot be reduced to a lower brightness interval after being adjusted to a higher brightness interval (such as after an ultra-high brightness interval), thereby improving the user experience. In addition, the target brightness interval and the first brightness interval will not cross the brightness interval, which can avoid adjusting the brightness of the electronic device's display across the brightness interval, so that the user's visual perception of the display brightness change is small, that is, the user can adjust the display brightness without perception, thereby improving the user experience.

[0026] In one embodiment of the present application, after determining whether the brightness of the second ambient light is within the first brightness range, the method further includes:

[0027] When the brightness of the second ambient light is not within the first brightness range, determining the calibration coefficient corresponding to the first brightness range in a preset correspondence between brightness ranges and calibration coefficients to obtain a second calibration coefficient;

[0028] Calculating a third ambient light brightness based on the second calibration coefficient and the target image data;

[0029] Determining whether the brightness of the third ambient light is within the first brightness range;

[0030] When the brightness of the third ambient light is within the first brightness range, determining the first brightness range as the brightness range of the current frame to obtain a target brightness range;

[0031] When the brightness of the third ambient light is not within the first brightness range, determining whether the brightness of the third ambient light is within a brightness range subsequent to the first brightness range;

[0032] When the brightness of the third ambient light is in a brightness interval subsequent to the first brightness interval, the brightness interval subsequent to the first brightness interval is determined to be the brightness interval of the current frame, and a target brightness interval is obtained.

[0033] As can be seen from the above, in the technical solution of this embodiment, the second ambient light brightness for estimating the target brightness interval of the current frame is determined in combination with the previous brightness interval of the first brightness interval. When the second ambient light brightness is not in the previous brightness interval of the first brightness interval, nor in the first brightness interval, the third ambient light brightness is determined based on the calibration coefficient corresponding to the first brightness interval, and the target brightness interval is determined to be the first brightness interval or the next brightness interval of the first brightness interval based on the third ambient light brightness. This can avoid the problem that the brightness cannot be reduced to a lower brightness interval after being adjusted to a higher brightness interval (such as after an ultra-high brightness interval), thereby improving the user experience. In addition, the target brightness interval and the first brightness interval will not cross the brightness interval, which can avoid adjusting the brightness of the electronic device's display screen across the brightness interval, so that the user's visual perception of the display screen brightness change is small, that is, the user can adjust the display screen brightness without perception, thereby improving the user experience.

[0034] In one embodiment of the present application, before determining whether to switch the parameter setting of the target camera from a brightness interval preceding the first brightness interval to the first brightness interval, the method further includes:

[0035] Determining whether there is a brightness interval before the first brightness interval;

[0036] The determining whether to switch the parameter setting of the target camera from a brightness interval preceding the first brightness interval to the first brightness interval includes:

[0037] When there is a brightness interval preceding the first brightness interval, it is determined whether to switch the parameter setting of the target camera from the brightness interval preceding the first brightness interval to the first brightness interval.

[0038] In one embodiment of the present application, after determining whether there is a brightness interval preceding the first brightness interval, the method further includes:

[0039] When there is no brightness interval before the first brightness interval, in the correspondence between the preset brightness intervals and the calibration coefficients, the calibration coefficient corresponding to the first brightness interval is determined to obtain the second calibration coefficient, and the step of calculating the third ambient light brightness based on the second calibration coefficient and the target image data is performed.

[0040] In one embodiment of the present application, after determining whether the brightness of the third ambient light is in a brightness interval subsequent to the first brightness interval, the method further includes:

[0041] When the brightness of the third ambient light is not in a brightness interval subsequent to the first brightness interval, determining whether the brightness of the third ambient light is lower than a lower limit value of a brightness interval preceding the first brightness interval;

[0042] When the brightness of the third ambient light is lower than the lower limit value of a brightness interval preceding the first brightness interval, the brightness interval preceding the first brightness interval is determined to be the brightness interval of the current frame, and a target brightness interval is obtained.

[0043] As can be seen from the above, the technical solution of this embodiment is that when the third ambient light brightness is neither in the first brightness range nor in the brightness range after the first brightness range. When the third ambient light brightness is lower than the lower limit of the brightness range before the first brightness range, it indicates that the third ambient light brightness range is in the brightness range before the brightness range before the first brightness range. The brightness range before the first brightness range is determined as the target brightness range of the current frame. This can avoid the target brightness range and the first brightness range from overlapping brightness ranges, thereby avoiding adjusting the display brightness across brightness ranges, thereby improving the user experience.

[0044] In one embodiment of the present application, after determining whether the brightness of the third ambient light is lower than a lower limit value of a brightness interval preceding the first brightness interval, the method further includes:

[0045] When the brightness of the third ambient light is not lower than the lower limit value of a brightness interval preceding the first brightness interval, determining whether the brightness of the third ambient light is higher than the upper limit value of a brightness interval following the first brightness interval;

[0046] When the brightness of the third ambient light is higher than the upper limit of a brightness interval following the first brightness interval, the brightness interval following the first brightness interval is determined to be the brightness interval of the current frame, and a target brightness interval is obtained.

[0047] As can be seen from the above, the technical solution of this embodiment is that when the third ambient light brightness is neither in the first brightness range nor in the brightness range following the first brightness range. When the third ambient light brightness is higher than the upper limit of the brightness range following the first brightness range, it indicates that the third ambient light brightness range is in the brightness range following the brightness range following the first brightness range. The brightness range following the first brightness range is determined as the target brightness range of the current frame. This can avoid the determined target brightness range and the first brightness range from intersecting brightness ranges, thereby avoiding adjusting the display brightness across brightness ranges, thereby improving the user experience.

[0048] In one embodiment of the present application, the calculating of the second ambient light brightness based on the first brightness interval to which the first ambient light brightness belongs and the target image data captured by the target camera in the current frame includes:

[0049] When switching the parameter setting of the target camera from a brightness interval preceding the first brightness interval to the first brightness interval, determining the calibration coefficient corresponding to the first brightness interval in a preset correspondence between brightness intervals and calibration coefficients to obtain a second calibration coefficient;

[0050] The second ambient light brightness is calculated based on the second calibration coefficient and the target image data captured by the target camera in the current frame.

[0051] As can be seen from the above, in the technical solution of this embodiment, the first brightness interval to which the first ambient light brightness detected by the target camera in the previous frame belongs is determined. When the parameter setting of the target camera is switched from the brightness interval before the first brightness interval to the first brightness interval, the second ambient light brightness used to estimate the target brightness interval of the current frame is directly determined based on the first brightness interval. Subsequently, the target brightness interval is determined based on the second ambient light brightness. The target brightness interval and the first brightness interval do not cross brightness intervals, which can avoid adjusting the display brightness across brightness intervals. As a result, the user's visual perception of the display brightness is relatively small, that is, the display brightness can be adjusted without the user's perception, thereby improving the user experience.

[0052] In one embodiment of the present application, determining the brightness range of the current frame based on the second ambient light brightness to obtain the target brightness range includes:

[0053] Determining whether the brightness of the second ambient light is within a brightness interval preceding the first brightness interval;

[0054] When the brightness of the second ambient light is in a brightness interval preceding the first brightness interval, determining the brightness interval preceding the first brightness interval as the brightness interval of the current frame to obtain a target brightness interval;

[0055] When the brightness of the second ambient light is not within a brightness interval preceding the first brightness interval, determining whether the brightness of the second ambient light is within the first brightness interval;

[0056] When the brightness of the second ambient light is within the first brightness range, determining the first brightness range as the brightness range of the current frame to obtain a target brightness range;

[0057] When the brightness of the second ambient light is not within the first brightness range, determining whether the brightness of the second ambient light is within a brightness range subsequent to the first brightness range;

[0058] When the brightness of the second ambient light is in a brightness interval subsequent to the first brightness interval, the brightness interval subsequent to the first brightness interval is determined to be the brightness interval of the current frame, and a target brightness interval is obtained.

[0059] As can be seen from the above, in the technical solution of this embodiment, the second ambient light brightness used to estimate the target brightness range of the current frame is determined directly based on the first brightness range. Based on the second ambient light brightness, the target brightness range is sequentially determined to be the brightness range before the first brightness range, the first brightness range, or the brightness range after the first brightness range. This ensures that the target brightness range and the first brightness range do not cross brightness ranges, thus avoiding adjusting the display brightness across brightness ranges. As a result, the user's visual perception of the display brightness is minimal, that is, the display brightness can be adjusted without the user noticing, improving the user experience.

[0060] In one embodiment of the present application, calculating the target ambient light brightness of the current frame based on the target calibration coefficient and the target image data includes:

[0061] The target ambient light brightness of the current frame is calculated based on the target calibration coefficient, the target image data, and a preset formula; wherein the preset formula is:

[0062] Lux=A×R+B

[0063] Lux represents the target ambient light brightness; A represents a target calibration coefficient; B represents another target calibration coefficient; and R represents the target image data.

[0064] In a second aspect, an embodiment of the present application further provides an electronic device, including:

[0065] one or more processors and memory;

[0066] The memory is coupled to the one or more processors, and the memory 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 above-mentioned display screen brightness adjustment method.

[0067] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, comprising a computer program, which, when executed on an electronic device, enables the electronic device to execute the above-mentioned display screen brightness adjustment method.

[0068] In a fourth aspect, an embodiment of the present application further provides a computer program product, which includes executable instructions. When the executable instructions are executed on an electronic device, the electronic device executes the above-mentioned display screen brightness adjustment method.

[0069] In a fifth aspect, an embodiment of the present application further provides a chip system, which is applied to an electronic device. The chip system includes one or more processors, which are used to call computer instructions so that the electronic device inputs data into the chip system, and executes the above-mentioned display brightness adjustment method to process the data and output the processing results.

[0070] The beneficial effects of the solutions provided by the embodiments in the second, third, fourth and fifth aspects can be referred to the beneficial effects of the solutions provided by the embodiments in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0072] Figure 1 A structural diagram of an electronic device provided in an embodiment of the present application;

[0073] Figure 2 A software structure block diagram of an electronic device provided in an embodiment of the present application;

[0074] Figure 3 This is a first ambient light brightness comparison chart provided in an embodiment of the present application;

[0075] Figure 4 A flowchart of a first method for adjusting display screen brightness provided in an embodiment of the present application;

[0076] Figure 5 A flowchart of a second method for adjusting display screen brightness provided in an embodiment of the present application;

[0077] Figure 6 A schematic diagram of the first brightness range provided in an embodiment of the present application;

[0078] Figure 7 A flowchart of a third method for adjusting display screen brightness provided in an embodiment of the present application;

[0079] Figure 8 A schematic diagram of the second brightness range provided in an embodiment of the present application;

[0080] Figure 9 A flowchart of a fourth method for adjusting display screen brightness provided in an embodiment of the present application;

[0081] Figure 10 A flowchart of a fifth method for adjusting display screen brightness provided in an embodiment of the present application;

[0082] Figure 11 A flowchart of a sixth method for adjusting display screen brightness provided in an embodiment of the present application;

[0083] Figure 12 A flowchart of a seventh method for adjusting display screen brightness provided in an embodiment of the present application;

[0084] Figure 13 A flowchart of a method for turning off the screen and disabling the ambient light detection function of the front camera provided in an embodiment of the present application;

[0085] Figure 14 A flowchart of another method for turning off the screen and disabling the ambient light detection function of the front camera provided in an embodiment of the present application;

[0086] Figure 15 A flowchart of a first method for managing an ambient light detection function provided in an embodiment of the present application;

[0087] Figure 16 A flowchart of a second method for managing an ambient light detection function provided in an embodiment of the present application;

[0088] Figure 17 A flowchart of a third method for managing an ambient light detection function provided in an embodiment of the present application;

[0089] Figure 18 A flowchart of a fourth method for managing an ambient light detection function provided in an embodiment of the present application;

[0090] Figure 19 A flowchart of a fifth method for managing an ambient light detection function provided in an embodiment of the present application;

[0091] Figure 20 A flowchart of a sixth method for managing an ambient light detection function provided in an embodiment of the present application;

[0092] Figure 21 A logic block diagram of performance optimization of an electronic device provided in an embodiment of the present application;

[0093] Figure 22 A flowchart of a method for determining ambient light brightness provided in an embodiment of the present application;

[0094] Figure 23 This is a second ambient light brightness comparison chart provided in an embodiment of the present application;

[0095] Figure 24 This is a third ambient light brightness comparison chart provided in an embodiment of the present application;

[0096] Figure 25 A structural diagram of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0097] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0098] In order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. For example, the first instruction and the second instruction are intended to distinguish different user instructions and do not limit their order. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.

[0099] It should be noted that, in this application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. 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 "exemplarily" or "for example" is intended to present the relevant concepts in a concrete manner.

[0100] The display brightness adjustment method provided in the embodiments of the present application is applied to electronic devices. The electronic devices may be mobile phones, tablet computers, personal computers (PCs), car computers, personal digital assistants (PDAs), smart watches, netbooks, wearable devices, augmented reality (AR) devices, virtual reality (VR) devices, robots, smart TVs, and other electronic devices equipped with cameras and displays.

[0101] For example, Figure 1 : A schematic diagram of the structure of an electronic device 100 is shown. The electronic device 100 may include a processor 110, an internal memory 121, a camera 193, a display screen 194, etc. 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 processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processor (NPU), etc. Among them, different processing units may be independent devices or integrated into one or more processors.

[0102] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. When processor 110 needs to use the same instruction or data again, it can directly access the memory, avoiding repeated accesses and reducing processor 110 latency, thereby improving system efficiency.

[0103] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an Inter-Integrated Circuit (I2C) interface, an Inter-Integrated Circuit Sound (I2S) interface, a Pulse Code Modulation (PCM) interface, a Universal Asynchronous Receiver / Transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a General-Purpose Input / Output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and / or a Universal Serial Bus (USB) interface.

[0104] The internal memory 121 can be used to store computer executable program code, which includes instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), 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 memory (Universal Flash Storage, UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor.

[0105] The electronic device 100 can implement display functions through a GPU, a 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 display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a mini-LED, a micro-LED, a micro-o-LED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.

[0106] The electronic device 100 can implement a shooting function through an ISP, camera 193, a video codec, a GPU, a display 194, and an application processor. The ISP is used to process data fed back by the camera 193. For example, when the shutter is opened to take a photo, light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and transformed into a visible image. The ISP can also perform algorithmic optimization on image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be installed in the camera 193. The camera 193 is used to capture still images or videos. An object is projected onto the photosensitive element through the lens, which can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard format such as RGB, YUV, etc. In some embodiments, the electronic device 100 may include one or N cameras 193 , where N is a positive integer greater than one.

[0107] In some embodiments, the electronic device 100 may further include an external memory interface 120, 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, and a user identification module card interface 195. 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, a bone conduction sensor 180M, and the like.

[0108] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage. For example, files such as music and videos can be stored on the external memory card.

[0109] The USB interface 130 is an interface that complies with USB standards and specifications, and may be a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100; can also be used to transfer data between the electronic device 100 and peripheral devices; can also be used to connect headphones to play audio through the headphones; and can also be used to connect other electronic devices, such as AR devices.

[0110] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also provide power to the electronic device via the power management module 141.

[0111] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the display 194, the camera 193, the wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0112] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, the baseband processor, and the like.

[0113] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0114] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0115] The wireless communication module 160 can provide wireless communication solutions applied to the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi network), Bluetooth (BT), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), infrared technology (IR), etc. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0116] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with a network and other devices via wireless communication technologies. The wireless communication technologies may include Global System for Mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM and / or IR technology, etc. The GNSS may include a Global Positioning System (GPS), a Global Navigation Satellite System (GLONASS), a Beidou Navigation Satellite System (BDS), a Quasi-Zenith Satellite System (QZSS) and / or a Satellite Based Augmentation System (SBAS).

[0117] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0118] It will be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components can be implemented in hardware, software, or a combination of software and hardware. In addition, the interface connection relationship between the modules illustrated in the embodiments of the present application is merely a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods from those in the above embodiments, or a combination of multiple interface connection methods.

[0119] The electronic device 100 is installed with a software system that can run on the processor 110. The software system can be an Android system, a Windows system, an IOS system, a Hongmeng system, etc. The architecture adopted by the software system can be a layered architecture, an event-driven architecture, a micro-kernel architecture, a microservice architecture, or a cloud architecture. The embodiment of the present application takes the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100. Figure 2 The Android system can be divided into four layers, from top to bottom: application layer, framework layer (Framework, FWK), hardware abstraction layer (HAL) and kernel layer.

[0120] The application layer can include a range of applications, such as camera, calendar, map, WLAN, music, short message, gallery, call, ambient light detection, face unlock, etc., for direct interaction with the user. These applications can be built-in system applications or non-system applications. These applications can have icons and application interfaces, or they can have application interfaces without icons, or they can have neither icons nor application interfaces.

[0121] The framework layer includes some predefined functions, which can provide application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application programming interfaces provided by the framework layer may include interfaces related to camera services, interfaces related to sensor services, and interfaces related to other services. Interfaces related to different services can be defined as different service modules. For example, interfaces related to sensor services can be defined as sensor service modules, interfaces related to camera services can be defined as camera service modules, and interfaces related to other services can be defined as other service modules (not shown in the figure), etc. Among them, the sensor service module may include sub-modules such as sensor management (SensorManager) and sensor service (SensorService). SensorManager is used to adjust the brightness of the display screen of the electronic device according to the detected ambient light brightness. SensorService is used to implement communication between related applications that need to call sensors in the application layer and Sensor HAL.

[0122] In some embodiments, the sensor service module may be an independent process, and the SensorManager and SensorService may be two threads in the process.

[0123] The camera service module includes sub-modules such as ICameraService and CameraService. CameraService can be used to implement communication between applications in the application layer that need to call the camera (for example, camera applications, face unlocking applications, ambient light detection applications, etc.) and Camera HAL. In some embodiments, the camera service module can be an independent process, and ICameraService and CameraService can be two threads in the process. The electronic device is provided with multiple cameras, and multiple cameras cannot be enabled at the same time, and different functions of the same camera cannot be enabled at the same time. When the front camera is used instead of the ambient light detection device, in order to solve the enabling priority problem of different functions of multiple cameras, the embodiment of the present application modifies the CameraService in the camera service module and adds the judgment logic of the enabling priority of different functions of the camera, so that when two or more camera functions need to be enabled at the same time, one can be enabled according to the judgment logic.

[0124] The hardware abstraction layer is located between the framework layer and the kernel layer, and its purpose is to abstract the hardware. The hardware abstraction layer hides the hardware interface details of a specific platform and provides a virtual hardware platform for the software system, making it hardware-independent and portable on multiple platforms. Depending on the functions implemented, the hardware abstraction layer can be further refined into a camera-related hardware abstraction layer (i.e., the Camera HAL described in subsequent embodiments), a sensor-related hardware abstraction layer (i.e., the Sensor HAL described in subsequent embodiments), etc. The camera-related hardware abstraction layer can be defined as a camera control module, and the sensor-related hardware abstraction layer can be defined as a sensor control module.

[0125] In some embodiments, the camera control module can be an independent process, and the sensor control module can also be an independent process. In order to realize the ambient light detection function of the front camera, the embodiment of the present application modifies the sensor control module (Sensor HAL). Specifically, an ambient light service control submodule (i.e., the CameraLightManager described in subsequent embodiments) is added to the sensor control module. The ambient light service control submodule provides multiple interfaces, including an activation (Active) interface, a deactivation (DeActive) interface, etc. Among them, the Active interface is used to turn on the ambient light detection function of the front camera. The DeActive interface is used to turn off the ambient light detection function of the front camera.

[0126] The embodiment of the present application also modifies the camera control module (Camera HAL). Specifically, a camera function customization submodule (i.e., CamxLightCustom described in subsequent embodiments) is added to the camera control module, and the existing functional submodules in the camera control module (for example, Camera Hardware Interface-Camera Development Kit (CHI-CDK), CAMX, etc.) are modified. Among them, the camera function customization submodule is used to obtain the ambient light brightness detected by the front camera when the front camera is used as an ambient light detection device, and send the ambient light brightness detected by the front camera to the sensor control module, so that the sensor control module reports the ambient light brightness to the sensor service module, thereby adjusting the brightness of the display screen of the electronic device. CHI-CDK is a customizable code implementation set. Based on the original code implementation set of CHI-CDK, the embodiment of the present application adds AIDL (Android Interface Definition Language) service initialization-related code, so that different processes in the electronic device (such as Sensor HAL and Camera HAL) can communicate with each other. Among them, AIDL is used to define the interface between the client and server of the Android system based on Binder communication. Binder is a cross-process communication mechanism of the Android system, which allows communication between different processes and even across devices. CAMX is a code implementation set of a general functional interface. Based on the original code implementation set in CAMX, the embodiment of the present application modifies the first function (i.e., the Open Camera function) and adds a logical branch that can skip configuring the output resources for the front camera. Therefore, when the front camera is used as an ambient light detection device, the process of configuring the output resources for the front camera can be skipped, thereby reducing the power consumption of the front camera and improving the performance of the electronic device.

[0127] The kernel layer is the layer between hardware and software. The kernel layer may include display drivers, camera drivers, audio drivers, sensor drivers, etc. These drivers can drive the display screen, front / rear cameras, audio players, sensors, etc.

[0128] The following describes the application scenarios of the display screen brightness adjustment method provided in the embodiments of the present application.

[0129] In modern life, electronic devices such as smartphones, tablets, and laptops have become indispensable. To meet user needs in varying lighting scenarios, these devices offer automatic brightness adjustment. When the screen is on, the device uses a built-in ambient light sensor to detect the ambient light level. Based on this, the device adjusts the display brightness, ensuring a pleasant viewing experience in varying lighting conditions.

[0130] Although the above method can adjust the brightness of the display screen, it requires an additional ambient light detection device, which increases the cost of the electronic device. Considering that current electronic devices are all equipped with cameras, and most cameras have light source detection functions, when a camera that supports normal mode (i.e., photo mode) is used as an ambient light detection device, the power consumption of the camera that supports normal mode is high, which reduces the performance of the electronic device. With the development of technology, cameras can support multiple modes, including normal mode, ambient light sensor (ALS) mode, ultra low power (ULP) mode, etc., which makes it possible to use cameras as ambient light detection devices.

[0131] In view of this, a method is proposed in which a target camera replaces an ambient light detection device to detect ambient light brightness, and then adjusts the brightness of a display screen based on the ambient light brightness detected by the target camera. The target camera has an ambient light detection function and an image acquisition function, and can be a front camera of an electronic device or a rear camera of an electronic device. Considering that the display screen is set on the upper surface of the electronic device, the front camera is also set on the upper surface of the electronic device and is located on the same side as the display screen, and the ambient light brightness on different sides of the electronic device is different to a certain extent, in order to make the adjusted display screen brightness more in line with the current environment, this application takes the target camera as the front camera as an example for explanation.

[0132] Different calculation formulas are set for different ambient light brightnesses. The calculation formulas include the calibration coefficients described in subsequent embodiments and are used to calculate the corresponding ambient light brightness. If the same calculation formula is used for different ambient light brightnesses, the calculated ambient light brightness will be inaccurate. Accordingly, when detecting the ambient light through the target camera, the brightness range of the raw image data (Raw data) collected by the target camera is determined, and the calculation formula corresponding to the brightness range of the Raw data is used to calculate the ambient light brightness.

[0133] However, if the brightness ranges of different Raw data overlap, an inappropriate formula may be selected when calculating the ambient light brightness, resulting in low accuracy in the determined ambient light brightness and, in turn, non-linear adjustment of the display brightness. For example, directly adjusting the display brightness of an electronic device from a lower brightness to a higher brightness causes the user to visually perceive a large change in the display brightness, affecting the user experience.

[0134] For example, see Table 1, which is an ambient light brightness comparison table of an embodiment of the present application.

[0135] Table 1

[0136] Raw data 0 234 277 777.1 1287 Index 1 -105.13 77.0858 110.5699 500 500 Index2 -502.55 500 683.7856 2825.614 5000 Index3 -552.5 0 4987.45 5000 5000

[0137] Raw data is the original image data. The light signal captured by the target camera is converted into an electrical signal, resulting in a digital signal for each pixel. Based on these digital signals, the output raw data is generated. Index1, Index2, and Index3 correspond to different brightness ranges. For example, Index1 corresponds to the low brightness range, Index2 to the medium brightness range, and Index3 to the high brightness range. The data corresponding to Index1, Index2, and Index3 is the ambient light brightness calculated for the same raw data using the calculation formula corresponding to the brightness range. The unit of ambient light brightness is lux.

[0138] See also Figure 3 , Figure 3 This is a comparison chart of ambient light brightness based on Table 1. The line with the origin represents the relationship between the raw data and the ambient light brightness calculated using the formula for the low brightness range. The line with triangles represents the relationship between the raw data and the ambient light brightness calculated using the formula for the medium brightness range. The line with squares represents the relationship between the raw data and the ambient light brightness calculated using the formula for the high brightness range.

[0139] Based on the above Table 1 and the above Figure 3 It can be seen that using different calculation formulas for the same Raw data can result in significantly different ambient light brightness. For example, when the Raw data is 777.1, the ambient light brightness calculated using the formula corresponding to the low brightness range is 500, while the ambient light brightness calculated using the formula corresponding to the medium brightness range is 2825.614, a significant difference.

[0140] In order to solve the above problems, the method of an embodiment of the present application is used to adjust the brightness of the display screen of an electronic device. The electronic device determines the target brightness interval of the current frame based on the first brightness interval to which the ambient light brightness detected in the previous frame belongs. The target brightness interval of the current frame and the first brightness interval to which the ambient light brightness detected in the previous frame belongs do not cross the brightness interval. Furthermore, the target ambient light brightness of the current frame is determined based on the target brightness interval, so that the target ambient light brightness can be located in the target brightness interval, thereby improving the accuracy of the determined target ambient light brightness. Furthermore, when the display screen brightness is adjusted based on the target ambient light brightness, the display screen brightness of the electronic device will not be adjusted across the brightness interval. This can ensure that when the display screen brightness of the electronic device is adjusted, the change in the display screen brightness is small, thereby improving the user experience.

[0141] Next, the method for adjusting the brightness of the display screen provided by the embodiment of the present application is described in detail through a specific embodiment. In one embodiment of the present application, see Figure 4 , Figure 4 This is a flowchart of a method for adjusting display brightness provided in an embodiment of the present application. The method is applied to an electronic device and may include the following steps:

[0142] S401: Acquire the ambient light brightness detected by a target camera of an electronic device in a previous frame to obtain a first ambient light brightness.

[0143] S402: Calculate the second ambient light brightness based on the first brightness interval to which the first ambient light brightness belongs and target image data captured by the target camera in the current frame.

[0144] S403: Determine a brightness range of the current frame based on the second ambient light brightness to obtain a target brightness range.

[0145] S404: Determine the calibration coefficient corresponding to the target brightness range in the correspondence between the preset brightness ranges and the calibration coefficients to obtain the target calibration coefficient.

[0146] The multiple brightness intervals in the above correspondence are arranged in order from low to high brightness.

[0147] S405: Calculate the target ambient light brightness of the current frame based on the target calibration coefficient and the target image data.

[0148] S406: Adjusting the brightness of the display screen of the electronic device based on the target ambient light brightness of the current frame.

[0149] As can be seen from the above, the technical solution of this embodiment determines the target brightness interval of the current frame based on the first brightness interval to which the ambient light brightness detected in the previous frame belongs. The target brightness interval of the current frame and the brightness interval to which the ambient light brightness detected in the previous frame belongs will not cross the brightness interval. Furthermore, the target ambient light brightness of the current frame is determined based on the target brightness interval, which can make the target ambient light brightness fall within the target brightness interval, thereby improving the accuracy of the determined target ambient light brightness. Furthermore, when the display brightness is adjusted based on the target ambient light brightness, the display brightness of the electronic device will not be adjusted across the brightness interval, which can achieve that when the display brightness of the electronic device is adjusted, the display brightness changes less, thereby improving the user experience.

[0150] With respect to step S401 , the target camera may be a front camera of the electronic device.

[0151] After the electronic device turns on the screen, the ambient light detection function is started, the electronic device powers on the front camera, and turns on the ambient light detection function of the front camera. The screen of the electronic device can be turned on for the first time when the device is turned on, or it can be a non-first time after the device is turned on. If the electronic device is in the off state, the electronic device can be turned on by long pressing the power button to light up the display. If the electronic device is in the on state, the display of the electronic device can be lit by touching the power button, touching the display with a preset gesture (such as double-clicking, etc.), lifting the electronic device, etc. After the electronic device turns on the screen, the front camera is powered on. The front camera can be powered on based on the screen of the electronic device to initialize the front camera, thereby turning on the front camera to detect the ambient light brightness.

[0152] When the electronic device's screen is on, the target camera detects the ambient light brightness in real time and adjusts the display brightness in real time. Accordingly, the electronic device obtains the ambient light brightness detected in the previous frame to obtain a first ambient light brightness. The ambient light brightness detected in the previous frame is calculated based on the raw data captured by the target camera in the previous frame.

[0153] For step S402, multiple brightness intervals are pre-set and arranged in ascending order of the brightness they contain. In one implementation, the brightness intervals include: a low brightness interval, a medium brightness interval, and a high brightness interval. For example, the low brightness interval is [0, 500], the medium brightness interval is [500, 5000], and the high brightness interval is [5000, 10000000].

[0154] For example, the following is a Hyper Text Markup Language (HTML) file for setting multiple brightness intervals.

[0155]

[0156]

[0157] In another implementation, the brightness ranges include low brightness, medium brightness, high brightness, and ultra-high brightness. For example, the low brightness range is [0, 500], the medium brightness range is [500, 5000], the high brightness range is [5000, 10000000], and the ultra-high brightness range is [10000000, 20000000].

[0158] After acquiring the first ambient light brightness, the electronic device determines the brightness interval to which the first ambient light brightness belongs (referred to as the first brightness interval). Furthermore, based on the first brightness interval and the target image data captured by the target camera in the current frame, the electronic device calculates the second ambient light brightness. The second ambient light brightness is the reference ambient light brightness used to determine the target ambient light brightness of the current frame. The target image data is the raw data captured by the target camera in the current frame.

[0159] In some embodiments, Figure 4 Based on Figure 5 Before step S402, the method may further include the following:

[0160] S407: Determine whether the parameter setting of the target camera is switched from the brightness interval before the first brightness interval to the first brightness interval.

[0161] Accordingly, step S402 may include the following steps:

[0162] S4021: When the parameter setting of the target camera is not switched from the brightness interval before the first brightness interval to the first brightness interval, the calibration coefficient corresponding to the brightness interval before the first brightness interval is determined in the correspondence between the preset brightness intervals and the calibration coefficients to obtain the first calibration coefficient.

[0163] S4022: Calculate the second ambient light brightness based on the first calibration coefficient and the target image data captured by the target camera in the current frame.

[0164] Different brightness ranges may correspond to different types of parameter settings for the target camera. The parameter settings may include parameters such as the gain of the target camera.

[0165] For example, in the HTML file for setting brightness ranges, the low brightness range corresponds to one type of parameter setting, and the medium brightness range and high brightness range correspond to another type of parameter setting. Among them, the parameter setting corresponding to the low brightness range is: <settingtype> LOW_LUX_SWITCH< / settingtype> The parameters for the medium brightness range and high brightness range are set as follows: <settingtype> HIGH_LUX_SWITCH< / settingtype> .

[0166] The electronic device can obtain the setting type (SettingType) of the parameter setting of the target camera corresponding to the first brightness interval, and the SettingType of the parameter setting of the target camera corresponding to the brightness interval before the first brightness interval. If the SettingType of the parameter setting of the target camera corresponding to the first brightness interval is different from the SettingType of the parameter setting of the target camera corresponding to the brightness interval before the first brightness interval, it can be determined that the parameter setting of the target camera is switched from the brightness interval before the first brightness interval to the first brightness interval. If the SettingType of the parameter setting of the target camera corresponding to the first brightness interval is the same as the SettingType of the parameter setting of the target camera corresponding to the brightness interval before the first brightness interval, it can be determined that the parameter setting of the target camera is not switched from the brightness interval before the first brightness interval to the first brightness interval.

[0167] For example, see Figure 6 The brightness ranges of ambient light are, in ascending order, low brightness range, medium brightness range, high brightness range, and ultra-high brightness range. The parameter corresponding to the low brightness range is set to Setting 1, while the parameters corresponding to the medium brightness range, high brightness range, and ultra-high brightness range are set to Setting 2.

[0168] The last state (LastState) indicates the first brightness interval to which the first ambient light brightness of the previous frame belongs. Figure 6 The first brightness interval is a high brightness interval, the brightness interval before the first brightness interval is a medium brightness interval, and the parameter setting of the target camera is not switched from the brightness interval before the first brightness interval to the first brightness interval.

[0169] Different brightness intervals may correspond to different types of parameter settings for the target camera. The sensitivity of the target camera is different for different types of parameter settings, and the detected ambient light may also be quite different. If the parameter settings of the target camera are not switched from the brightness interval before the first brightness interval to the first brightness interval, the electronic device may calculate the second ambient light brightness in combination with the previous brightness interval.

[0170] Accordingly, the electronic device determines the calibration coefficient (i.e., the first calibration coefficient) corresponding to the brightness interval before the first brightness interval in the correspondence between the preset brightness intervals and the calibration coefficients. The calibration coefficient is the calibration coefficient in the calculation formula for calculating the ambient light brightness. Furthermore, based on the first calibration coefficient and the target image data captured by the target camera in the current frame, the second ambient light brightness is calculated. The method of calculating the ambient light brightness based on the calibration coefficient and image data can be referred to the relevant description of the subsequent embodiments.

[0171] The corresponding relationship includes calibration coefficients corresponding to different brightness ranges. For example, in the HTML file for setting brightness ranges mentioned above, the calibration parameters corresponding to the low brightness range include: quadraticCoefficient is 0.0, linearCoefficient is 0.7787, and constantTerm is -105.13. The calibration parameters corresponding to the medium brightness range include: quadraticCoefficient is 0.0, linearCoefficient is 4.2828, and constantTerm is -502.55. The calibration parameters corresponding to the high brightness range include: quadraticCoefficient is 0.0, linearCoefficient is 20, and constantTerm is -552.55.

[0172] For example, for Figure 6 In an embodiment, the first brightness interval is a high brightness interval, and the brightness interval preceding the first brightness interval is a medium brightness interval. Parameter settings of the target camera are not switched from the brightness interval preceding the first brightness interval to the first brightness interval. The first calibration coefficient corresponding to the brightness interval preceding the first brightness interval includes a quadraticCoefficient of 0.0, a linearCoefficient of 4.2828, and a constantTerm of -502.55.

[0173] As can be seen from the above, in the technical solution of this embodiment, the first brightness interval to which the first ambient light brightness detected by the target camera in the previous frame belongs is determined, and when the parameter setting of the target camera is not switched from the previous brightness interval of the first brightness interval to the first brightness interval, the second ambient light brightness for estimating the target brightness interval of the current frame is determined in combination with the previous brightness interval of the first brightness interval. The target brightness interval determined based on the second ambient light brightness will not always be a higher brightness interval, which can avoid the problem that the display brightness cannot be reduced to a lower brightness interval after being adjusted to a higher brightness interval (such as an ultra-high brightness interval), thereby improving the user experience. In addition, the target brightness interval and the first brightness interval will not cross the brightness interval, which can avoid adjusting the display brightness across the brightness interval, so that the user visually perceives a smaller change in the display brightness, that is, the user can adjust the display brightness without perception, thereby improving the user experience.

[0174] In some embodiments, Figure 5 Based on Figure 7 , step S402 may include the following steps:

[0175] S4023: When switching the parameter setting of the target camera from the brightness interval before the first brightness interval to the first brightness interval, determine the calibration coefficient corresponding to the first brightness interval in the correspondence between the preset brightness intervals and the calibration coefficients to obtain a second calibration coefficient.

[0176] S4024: Calculate the second ambient light brightness based on the second calibration coefficient and the target image data captured by the target camera in the current frame.

[0177] For example, see Figure 8 The brightness ranges of ambient light are, in ascending order, low brightness range, medium brightness range, high brightness range, and ultra-high brightness range. The parameter corresponding to the low brightness range is set to Setting1, and the parameters corresponding to the medium brightness range, high brightness range, and ultra-high brightness range are set to Setting2.

[0178] The last state (LastState) indicates the first brightness interval to which the first ambient light brightness of the previous frame belongs. Figure 8 The first brightness interval is a medium brightness interval, the brightness interval before the first brightness interval is a low brightness interval, and the parameter setting of the target camera is switched from the brightness interval before the first brightness interval to the first brightness interval.

[0179] Different brightness intervals may correspond to different types of parameter settings for the target camera. The sensitivity of the target camera is different for different types of parameter settings, and the detected ambient light may also be quite different. If the parameter setting of the target camera is switched from the brightness interval before the first brightness interval to the first brightness interval, and the ambient light detected between the brightness interval before the first brightness interval and the first brightness interval is quite different, the electronic device does not need to calculate the second ambient light brightness in combination with the brightness interval before the first brightness interval.

[0180] Accordingly, the electronic device determines the calibration coefficient (i.e., the second calibration coefficient) corresponding to the first brightness interval in the preset correspondence between the brightness interval and the calibration coefficient, and further calculates the second ambient light brightness based on the second calibration coefficient and the target image data captured by the target camera in the current frame.

[0181] For example, for Figure 8 In an embodiment, the first brightness interval is a medium brightness interval, and the first calibration coefficient corresponding to the first brightness interval includes: quadraticCoefficient is 0.0, linearCoefficient is 4.2828, and constantTerm is -502.55.

[0182] As can be seen from the above, in the technical solution of this embodiment, the first brightness interval to which the first ambient light brightness detected by the target camera in the previous frame belongs is determined. When the parameter setting of the target camera is switched from the brightness interval before the first brightness interval to the first brightness interval, the second ambient light brightness used to estimate the target brightness interval of the current frame is directly determined based on the first brightness interval. Subsequently, the target brightness interval is determined based on the second ambient light brightness. The target brightness interval and the first brightness interval do not cross brightness intervals, which can avoid adjusting the display brightness across brightness intervals. As a result, the user's visual perception of the display brightness is relatively small, that is, the display brightness can be adjusted without the user's perception, thereby improving the user experience.

[0183] For step S403 , the target brightness range is the brightness range to which the ambient light brightness of the current frame belongs.

[0184] In some embodiments, when the parameter setting of the target camera is not switched, Figure 5 Based on Figure 9 , step S403 may include the following steps:

[0185] S4031: Determine whether the brightness of the second ambient light is in a brightness interval before the first brightness interval.

[0186] S4032: When the brightness of the second ambient light is in a brightness interval preceding the first brightness interval, determine the brightness interval preceding the first brightness interval as the brightness interval of the current frame, and obtain a target brightness interval.

[0187] S4033: When the brightness of the second ambient light is not in a brightness interval preceding the first brightness interval, determine whether the brightness of the second ambient light is in the first brightness interval.

[0188] S4034: When the brightness of the second ambient light is within the first brightness range, determine the first brightness range as the brightness range of the current frame, and obtain a target brightness range.

[0189] After calculating the second ambient light brightness, to avoid the problem of the display brightness being unable to be lowered to a lower brightness range after being adjusted to a higher brightness range (such as the ultra-high brightness range), a determination is first made as to whether the second ambient light brightness is within the brightness range preceding the first brightness range. If the second ambient light brightness is within the brightness range preceding the first brightness range, the brightness range preceding the first brightness range is determined as the target brightness range for the current frame.

[0190] When the second ambient light brightness is not in the brightness interval before the first brightness interval, it is further determined whether the second ambient light brightness is in the first brightness interval. When the second ambient light brightness is in the first brightness interval, the first brightness interval is determined as the target brightness interval of the current frame.

[0191] For example, Figure 6 In this embodiment, Lux judgment value 1 is the second ambient light brightness calculated using the first calibration coefficient corresponding to the medium brightness interval (i.e., the brightness interval before the first brightness interval). The electronic device uses Lux judgment value 1 to determine whether the target brightness interval of the current frame is the medium brightness interval or the high brightness interval. That is, when Lux judgment value 1 is in the medium brightness interval, the target brightness interval of the current frame is determined to be the medium brightness interval. When Lux judgment value 1 is in the high brightness interval, the target brightness interval of the current frame is determined to be the high brightness interval.

[0192] As can be seen from the above, in the technical solution of this embodiment, the second ambient light brightness for estimating the target brightness interval of the current frame is determined in combination with the previous brightness interval of the first brightness interval. Based on the second ambient light brightness, the target brightness interval is determined to be the previous brightness interval of the first brightness interval, or the first brightness interval, so that the target brightness interval will not always be a higher brightness interval, which can avoid the problem that the brightness cannot be reduced to a lower brightness interval after being adjusted to a higher brightness interval (such as after an ultra-high brightness interval), thereby improving the user experience. In addition, the target brightness interval and the first brightness interval will not cross the brightness interval, which can avoid adjusting the brightness of the electronic device's display across the brightness interval, so that the user's visual perception of the display brightness change is small, that is, the user can adjust the display brightness without perception, thereby improving the user experience.

[0193] In some embodiments, when the second ambient light brightness is not within the first brightness interval, that is, the second ambient light brightness is neither within the brightness interval immediately preceding the first brightness interval nor within the first brightness interval, the electronic device determines the second calibration coefficient corresponding to the first brightness interval in a preset correspondence between brightness intervals and calibration coefficients, and calculates the third ambient light brightness based on the second calibration coefficient and the target image data.

[0194] Furthermore, in order to avoid the problem that the display brightness cannot be reduced to a lower brightness range after being adjusted to a higher brightness range (such as an ultra-high brightness range), the electronic device first determines whether the third ambient light brightness is within the first brightness range. When the third ambient light brightness is within the first brightness range, the first brightness range is determined to be the target brightness range of the current frame. When the third ambient light brightness is not within the first brightness range, the electronic device continues to determine whether the third ambient light brightness is within the brightness range after the first brightness range. When the third ambient light brightness is within the brightness range after the first brightness range, the brightness range after the first brightness range is determined to be the target brightness range of the current frame.

[0195] For example, Figure 6In an embodiment, when the Lux judgment value 1 is neither in the medium brightness range nor in the high brightness range, a second calibration coefficient corresponding to the high brightness range is determined, and the third ambient light brightness is calculated based on the second calibration coefficient and the target image data. Figure 6 Lux judgment value 2 in the is the third ambient light brightness calculated using the second calibration coefficient corresponding to the high brightness range (first brightness range). The electronic device uses Lux judgment value 2 to determine whether the target brightness range of the current frame is the high brightness range or the ultra-high brightness range. That is, when Lux judgment value 2 is in the high brightness range, the target brightness range of the current frame is determined to be the high brightness range. When Lux judgment value 2 is in the ultra-high brightness range, the target brightness range of the current frame is determined to be the ultra-high brightness range.

[0196] As can be seen from the above, in the technical solution of this embodiment, the second ambient light brightness for estimating the target brightness interval of the current frame is determined in combination with the previous brightness interval of the first brightness interval. When the second ambient light brightness is not in the previous brightness interval of the first brightness interval, nor in the first brightness interval, the third ambient light brightness is determined based on the calibration coefficient corresponding to the first brightness interval, and the target brightness interval is determined to be the first brightness interval or the next brightness interval of the first brightness interval based on the third ambient light brightness. This can avoid the problem that the brightness cannot be reduced to a lower brightness interval after being adjusted to a higher brightness interval (such as after an ultra-high brightness interval), thereby improving the user experience. In addition, the target brightness interval and the first brightness interval will not cross the brightness interval, which can avoid adjusting the brightness of the electronic device's display screen across the brightness interval, so that the user's visual perception of the display screen brightness change is small, that is, the user can adjust the display screen brightness without perception, thereby improving the user experience.

[0197] In some embodiments, when the third ambient light brightness is not in the brightness interval following the first brightness interval, that is, the third ambient light brightness is neither in the first brightness interval nor in the brightness interval following the first brightness interval, the third ambient light brightness interval may be in the brightness interval before the brightness interval preceding the first brightness interval, or may be in the brightness interval after the brightness interval following the first brightness interval.

[0198] Correspondingly, the electronic device determines whether the brightness of the third ambient light is lower than the lower limit value of the previous brightness interval of the first brightness interval. When the brightness of the third ambient light is lower than the lower limit value of the previous brightness interval of the first brightness interval, it indicates that the third ambient light brightness interval is located in the brightness interval before the previous brightness interval of the first brightness interval. In order to avoid the determined target brightness interval and the first brightness interval from crossing the brightness interval, and thus avoid adjusting the brightness of the display screen across the brightness interval, the previous brightness interval of the first brightness interval is determined as the target brightness interval of the current frame.

[0199] For example, Figure 6In an embodiment, when the Lux judgment value 1 is neither in the medium brightness range nor in the high brightness range, and the Lux judgment value 2 is neither in the high brightness range nor in the ultra-high brightness range, it is determined whether the Lux judgment value 2 is lower than the lower limit of the medium brightness range.

[0200] If the Lux judgment value 2 is lower than the lower limit of the medium brightness interval, it indicates that the Lux judgment value 2 is located in the brightness interval before the medium brightness interval (such as the low brightness interval). If the brightness interval before the medium brightness interval is determined to be the target brightness interval, it will cause the determined target brightness interval and the first brightness interval to cross the brightness interval, and then cause the brightness of the display screen to be adjusted across the brightness interval. In order to avoid the above problem, the medium brightness interval is determined to be the target brightness interval.

[0201] As can be seen from the above, the technical solution of this embodiment is that when the third ambient light brightness is neither in the first brightness range nor in the brightness range after the first brightness range. When the third ambient light brightness is lower than the lower limit of the brightness range before the first brightness range, it indicates that the third ambient light brightness range is in the brightness range before the brightness range before the first brightness range. The brightness range before the first brightness range is determined as the target brightness range of the current frame. This can avoid the target brightness range and the first brightness range from overlapping brightness ranges, thereby avoiding adjusting the display brightness across brightness ranges, thereby improving the user experience.

[0202] In some embodiments, when the brightness of the third ambient light is not lower than the lower limit value of the brightness interval before the first brightness interval, that is, the brightness of the third ambient light is neither in the first brightness interval, nor in the brightness interval after the first brightness interval, nor in the brightness interval before the brightness interval before the first brightness interval, then the brightness of the third ambient light may be in the brightness interval after the brightness interval after the first brightness interval.

[0203] Correspondingly, the electronic device determines whether the brightness of the third ambient light is higher than the upper limit value of the brightness interval after the first brightness interval. When the brightness of the third ambient light is higher than the upper limit value of the brightness interval after the first brightness interval, it indicates that the brightness interval of the third ambient light is located in the brightness interval after the brightness interval after the first brightness interval. In order to avoid the determined target brightness interval and the first brightness interval from crossing the brightness interval, and thus avoid adjusting the brightness of the display screen across the brightness interval, the brightness interval after the first brightness interval is determined to be the brightness interval of the current frame, and the target brightness interval is obtained.

[0204] For example, Figure 6In an embodiment, when Lux judgment value 1 is neither in the medium brightness range nor in the high brightness range, and Lux judgment value 2 is neither in the high brightness range nor in the ultra-high brightness range, and Lux judgment value 2 is not lower than the lower limit of the medium brightness range, it is determined whether Lux judgment value 2 is higher than the upper limit of the ultra-high brightness range.

[0205] If the Lux judgment value 2 is higher than the upper limit of the ultra-high brightness interval, it indicates that the Lux judgment value 2 is located in the brightness interval after the ultra-high brightness interval. If the brightness interval after the ultra-high brightness interval is determined to be the target brightness interval, it will cause the determined target brightness interval and the first brightness interval to cross the brightness interval, and then cause the brightness of the display screen to be adjusted across the brightness interval. In order to avoid the above problem, the ultra-high brightness interval is determined to be the target brightness interval.

[0206] As can be seen from the above, the technical solution of this embodiment is that when the third ambient light brightness is neither in the first brightness range nor in the brightness range following the first brightness range. When the third ambient light brightness is higher than the upper limit of the brightness range following the first brightness range, it indicates that the third ambient light brightness range is in the brightness range following the brightness range following the first brightness range. The brightness range following the first brightness range is determined as the target brightness range of the current frame. This can avoid the determined target brightness range and the first brightness range from intersecting brightness ranges, thereby avoiding adjusting the display brightness across brightness ranges, thereby improving the user experience.

[0207] In some embodiments, before step S407, the method may further include the following steps: determining whether there is a brightness interval preceding the first brightness interval. If there is a brightness interval preceding the first brightness interval, determining whether to switch parameter settings of the target camera from the brightness interval preceding the first brightness interval to the first brightness interval.

[0208] After determining the first brightness interval to which the first ambient light brightness of the previous frame belongs, the electronic device determines whether there is a brightness interval preceding the first brightness interval. If there is a brightness interval preceding the first brightness interval, the electronic device further determines whether to switch parameter settings of the target camera from the brightness interval preceding the first brightness interval to the first brightness interval. Subsequently, based on whether the parameter settings of the target camera are switched from the brightness interval preceding the first brightness interval to the first brightness interval, the electronic device determines whether to determine the target brightness interval for the current frame in combination with the brightness interval preceding the first brightness interval.

[0209] In some embodiments, after determining whether there is a brightness interval before the first brightness interval, the method may further include the following steps: when there is no brightness interval before the first brightness interval, determining the calibration coefficient corresponding to the first brightness interval in the correspondence between the preset brightness interval and the calibration coefficient, obtaining the second calibration coefficient, and executing the step of calculating the third ambient light brightness based on the second calibration coefficient and the target image data.

[0210] After determining whether there is a brightness interval preceding the first brightness interval, if there is no brightness interval preceding the first brightness interval, then the target brightness interval for the current frame cannot be determined by combining the brightness interval preceding the first brightness interval with the brightness interval. The electronic device directly determines the second calibration coefficient corresponding to the first brightness interval within the preset correspondence between brightness intervals and calibration coefficients, and calculates the third ambient light brightness based on the second calibration coefficient and the target image data. Subsequently, the target brightness interval is determined directly based on the third ambient light brightness. For the specific method of determining the target brightness interval based on the third ambient light brightness, refer to the relevant description of the aforementioned embodiment.

[0211] In some embodiments, when the parameter settings of the target camera are switched, see Figure 10 , step S403 may include the following steps:

[0212] S4035: Determine whether the brightness of the second ambient light is in a brightness interval before the first brightness interval.

[0213] S4036: When the brightness of the second ambient light is in a brightness interval preceding the first brightness interval, determine the brightness interval preceding the first brightness interval as the brightness interval of the current frame, and obtain a target brightness interval.

[0214] S4037: When the brightness of the second ambient light is not in a brightness interval preceding the first brightness interval, determine whether the brightness of the second ambient light is in the first brightness interval.

[0215] S4038: When the brightness of the second ambient light is within the first brightness range, determine the first brightness range as the brightness range of the current frame, and obtain a target brightness range.

[0216] S4039: When the brightness of the second ambient light is not within the first brightness range, determine whether the brightness of the second ambient light is within a brightness range subsequent to the first brightness range.

[0217] S4040: When the brightness of the second ambient light is in a brightness interval subsequent to the first brightness interval, determine the brightness interval subsequent to the first brightness interval as the brightness interval of the current frame, and obtain a target brightness interval.

[0218] After calculating the second ambient light brightness, to avoid the problem of the display brightness being unable to be lowered to a lower brightness range after being adjusted to a higher brightness range (such as the ultra-high brightness range), a determination is first made as to whether the second ambient light brightness is within the brightness range preceding the first brightness range. If the second ambient light brightness is within the brightness range preceding the first brightness range, the brightness range preceding the first brightness range is determined as the target brightness range for the current frame.

[0219] If the second ambient light brightness is not within the brightness interval preceding the first brightness interval, but may be within the first brightness interval or a brightness interval following the first brightness interval, then the determination of whether the second ambient light brightness is within the first brightness interval is continued. If the second ambient light brightness is within the first brightness interval, the first brightness interval is determined as the target brightness interval for the current frame.

[0220] If the second ambient light brightness is not within the first brightness range, the second ambient light brightness may be within a brightness range subsequent to the first brightness range, and further determination is made as to whether the second ambient light brightness is within the brightness range subsequent to the first brightness range. If the second ambient light brightness is within the brightness range subsequent to the first brightness range, the brightness range subsequent to the first brightness range is determined as the target brightness range for the current frame.

[0221] For example, Figure 8 In an embodiment of the present invention, the Lux judgment value is the second ambient light brightness calculated using the second calibration coefficient corresponding to the medium brightness interval (i.e., the first brightness interval). The electronic device uses the Lux judgment value to decide whether the target brightness interval of the current frame is a low brightness interval, a medium brightness interval, or a high brightness interval. That is, when the Lux judgment value is in the low brightness interval, the target brightness interval of the current frame is determined to be the low brightness interval; when the Lux judgment value is in the medium brightness interval, the target brightness interval of the current frame is determined to be the medium brightness interval; and when the Lux judgment value is in the high brightness interval, the target brightness interval of the current frame is determined to be the high brightness interval.

[0222] As can be seen from the above, in the technical solution of this embodiment, the second ambient light brightness used to estimate the target brightness range of the current frame is determined directly based on the first brightness range. Based on the second ambient light brightness, the target brightness range is sequentially determined to be the brightness range before the first brightness range, the first brightness range, or the brightness range after the first brightness range. This ensures that the target brightness range and the first brightness range do not cross brightness ranges, thus avoiding adjusting the display brightness across brightness ranges. As a result, the user's visual perception of the display brightness is minimal, that is, the display brightness can be adjusted without the user noticing, improving the user experience.

[0223] In some embodiments, when the parameter setting of the target camera is switched, the second ambient light brightness is calculated based on the second calibration coefficient corresponding to the first brightness range and the target image data.

[0224] When the second ambient light brightness is not located in the brightness interval before the first brightness interval, nor in the first brightness interval, nor in the brightness interval after the first brightness interval, the second ambient light brightness interval may be located in the brightness interval before the brightness interval before the first brightness interval, or may be located in the brightness interval after the brightness interval after the first brightness interval.

[0225] The electronic device determines whether the brightness of the second ambient light is lower than the lower limit value of the brightness interval before the first brightness interval. When the brightness of the second ambient light is lower than the lower limit value of the brightness interval before the first brightness interval, it indicates that the second ambient light brightness interval is located in the brightness interval before the brightness interval before the first brightness interval. In order to avoid the determined target brightness interval and the first brightness interval from crossing the brightness interval, and thus avoid adjusting the brightness of the display screen across the brightness interval, the brightness interval before the first brightness interval is determined to be the target brightness interval of the current frame.

[0226] When the brightness of the second ambient light is not lower than the lower limit value of the previous brightness interval of the first brightness interval, that is, the brightness of the second ambient light is not located in the previous brightness interval of the first brightness interval, nor in the first brightness interval, nor in the brightness interval after the first brightness interval, nor in the brightness interval before the previous brightness interval of the first brightness interval, then the brightness of the second ambient light may be located in the brightness interval after the brightness interval after the first brightness interval.

[0227] The electronic device determines whether the brightness of the second ambient light is higher than the upper limit value of the brightness interval after the first brightness interval. When the brightness of the second ambient light is higher than the upper limit value of the brightness interval after the first brightness interval, it indicates that the brightness interval of the second ambient light is located in the brightness interval after the brightness interval after the first brightness interval. In order to avoid the determined target brightness interval and the first brightness interval from crossing the brightness interval, and thus avoid adjusting the brightness of the display screen across the brightness interval, the brightness interval after the first brightness interval is determined to be the brightness interval of the current frame, and the target brightness interval is obtained.

[0228] As can be seen from the above, the technical solution of this embodiment, when the parameter settings of the target camera are switched, when the second ambient light brightness is neither in the brightness interval before the first brightness interval, nor in the first brightness interval, nor in the brightness interval after the first brightness interval, when it is determined that the second ambient light brightness is in the brightness interval before the brightness interval before the brightness interval before the first brightness interval, the brightness interval before the first brightness interval is determined to be the target brightness interval. When it is determined that the second ambient light brightness is in the brightness interval after the brightness interval after the first brightness interval, the brightness interval after the first brightness interval is determined to be the target brightness interval, which can avoid the determined target brightness interval and the first brightness interval from crossing the brightness interval, thereby avoiding adjusting the display brightness across brightness intervals, thereby improving the user experience.

[0229] In step S404 and step S405, after determining the target brightness range, the electronic device determines the target calibration coefficient corresponding to the target brightness range in the corresponding relationship between the brightness range and the calibration coefficient. Then, based on the target calibration coefficient and the target image data, the target ambient light brightness of the current frame is determined.

[0230] In some embodiments, step S405 may include the following steps: calculating the target ambient light brightness of the current frame based on the target calibration coefficient, the target image data, and a preset formula. The preset formula is:

[0231] Lux=A×R+B (1)

[0232] Lux represents the target ambient light brightness; A represents a target calibration coefficient; B represents another target calibration coefficient; and R represents the target image data.

[0233] For example, if the target brightness range is a low brightness range, then one target calibration coefficient A in the above formula (1) is linearCoefficient (i.e., 0.7787), and the other target calibration coefficient B is constantTerm (i.e., -105.13). If the target brightness range is a medium brightness range, then A in the above formula (1) is 4.2828 and B is -502.55. If the target brightness range is a medium brightness range, then A in the above formula (1) is 20 and B is -552.55.

[0234] In step S405, after determining the target ambient light brightness, the electronic device adjusts the brightness of the electronic device's display screen based on the target ambient light brightness of the current frame. For example, the electronic device may use the target ambient light brightness as the adjusted display screen brightness. Alternatively, the electronic device may obtain the default brightness of the electronic device's display screen and adjust the default brightness based on the target ambient light brightness to obtain the adjusted display screen brightness.

[0235] In some embodiments, for the Figure 2 For the electronic device of the software system shown, the camera service module can control the opening and closing of the front camera by issuing instructions to the camera control module, and the sensor service module can control the opening and closing of the ambient light detection device by issuing instructions to the sensor control module. 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 the instructions issued by the sensor service module. Since the sensor control module cannot pass the instructions issued by the sensor service module to the front camera, and the camera control module can pass the instructions issued by the camera service module to the front camera, in order to realize the front camera replacing the ambient light detection device, it is necessary to establish a control path between the sensor control module and the camera service module, so as to realize the control of the front camera with the help of the camera service module. In the embodiment of the present application, the sensor control module of the HAL layer can be used as an independent process, and the camera service module of the FWK layer can also be used as an independent process. Therefore, when establishing the control path between the sensor control module of the HAL layer and the camera service module of the FWK layer, it can be established based on the Hardware Interface Definition Language (HIDL) service. Among them, HIDL is used to define the interface between the HAL layer and the FWK layer of the Android system based on Binder communication.

[0236] After opening the control path between the sensor control module and the camera service module, it is also necessary to establish a data path between the sensor control module and the camera 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 sends it to the sensor service module, thereby realizing the adjustment of the display brightness.

[0237] For the process of establishing the data path between the sensor control module and the camera control module, see Figure 11 The embodiment of the present application provides a method for adjusting the brightness of a display screen, which can be performed by Figure 2 The electronic device 100 of the software system shown in the figure executes the method flow provided in the embodiment of the present application, including:

[0238] S1101: Based on the electronic device being powered on, the camera control module initializes the AIDL service.

[0239] In an embodiment of the present application, the camera control module (i.e., Camera HAL) can be an independent process, which can be defined as a camera control process, and the submodules included in the camera control module (such as CHI-CDK, CAMX, CamxLightCustom, etc.) can be different threads in the camera control process. AIDL service initialization can be the process of pulling up the AIDL service. By initializing the AIDL service, communication between the client and the server based on the AIDL service can be achieved. AIDL service initialization can be performed in the camera control module, specifically, it can be performed in the CHI-CDK of the camera control module. The AIDL service can be initialized during the startup of the electronic device, or it can be initialized after startup when the client and server based on the AIDL service need to communicate. The embodiment of the present application does not limit the timing of AIDL service initialization. The process of AIDL service initialization can correspond to Figure 12 Step ① in Figure 12 When the electronic device is turned on, the AIDL service in the CHI-CDK of the Camera HAL is initialized, which can be to pull up the AIDL service.

[0240] In some embodiments, the AIDL service initialization process can be implemented using the following code:

[0241] CamLightAidlImpl::GetInstance()->Init(…).

[0242] S1102: The sensor service module sends a brightness monitoring instruction to the sensor control module.

[0243] In the embodiments of the present application, the sensor service module (i.e., SensorService) can be an independent process, which can be defined as the sensor service process. The submodules included in the sensor service module (such as SensorManager, SensorService, etc.) can be threads in the sensor service process. The sensor control module (i.e., Sensor HAL) can also be an independent process, which can be defined as the sensor control process. The submodules included in the sensor control module (such as CameraLightManager, etc.) can be threads in the sensor control process.

[0244] After the electronic device is powered on, the ambient light detection application in the application layer sends a screen-on message to the sensor service module. This screen-on message may include the package name of the ambient light detection application. This screen-on message is used to instruct the sensor service module to adjust the brightness of the electronic device's display screen. Upon receiving this screen-on message, the sensor service module sends a brightness monitoring instruction to the sensor control module. This brightness monitoring instruction is used to instruct the sensor control module to obtain the ambient light brightness. The brightness monitoring instruction 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 obtained ambient light brightness to the sensor service module.

[0245] In some embodiments, the sensor service module sends the brightness monitoring instruction to the sensor control module by: the sensor service process sends the brightness monitoring instruction to the sensor control process. Figure 12 Specifically, the sensor service module sends the brightness monitoring instruction to the sensor control module. Specifically, the SensorManager in the FWK layer generates a brightness monitoring instruction based on the screen-on message sent by the ambient light detection application in the application layer, and sends the brightness monitoring instruction to the Sensor HAL in the HAL layer through the SensorService.

[0246] S1103: After receiving the brightness monitoring instruction, the sensor control module calls the first interface based on the AIDL service and registers the data callback function in the camera control module.

[0247] After receiving the brightness monitoring instruction, the sensor control module calls the first interface based on the AIDL service and registers the data callback function in the camera control module. It can be based on the brightness monitoring instruction, the sensor control module calls the first interface, and registers the data callback function in the camera control module. It can also be in response to the brightness monitoring instruction, the sensor control module calls the first interface, and registers the data callback function in the camera control module.

[0248] In the computer field, AIDL service is used to achieve communication between different processes. For two processes based on AIDL service communication, one process is used to generate data and can be used as an AIDL server; the other process is used to issue control instructions and receive data and can be used as an AIDL client. In an embodiment of the present application, when the front camera is used instead of the ambient light detection device, the camera control module (Camera HAL) is used to provide ambient light brightness and can be used as an independent process. Therefore, it can be regarded as an AIDL server (referred to as a server in subsequent embodiments); the sensor control module (SensorHAL) is used to receive ambient light brightness and can be regarded as an AIDL client (referred to as a client in subsequent embodiments).

[0249] The first interface may be an Active interface. The Active interface is used to enable the ambient light detection function of the front camera. After the sensor control module calls the Active interface to enable the ambient light detection function of the front camera, the sensor control module may call the Active interface to register a data callback function in the camera control module. The camera control module may use the data callback function to send the ambient light brightness detected by the front camera to the sensor control module, thereby opening up the data path between the camera control module and the sensor control module, making it possible for the front camera to replace the ambient light device.

[0250] In the embodiment of the present application, the sensor control module calls the Active interface. Before registering the data callback function in the camera control module, the Active interface needs to be declared first. Since the Active interface belongs to the AIDL interface, its declaration usually contains two parameters. One can be the client's process ID (Process Identifier, PID), that is, the process ID of the process corresponding to the sensor control module (Sensor HAL) as the client; the other can be the client's callback object (CallBack), that is, the object in the sensor control module used to receive the ambient light brightness. In some embodiments, the callback object corresponds to Figure 12 ReportLuxStatus (report lux status) in.

[0251] The Active interface can be declared using the following code:

[0252]

[0253] Furthermore, based on the declaration content of the Active interface, the sensor control module and the camera control module can respectively register callback interfaces on this end. When the callback interface registrations in the sensor control module and the camera control module are completed, the registration of the data callback function in the camera control module is completed.

[0254] In some embodiments, the sensor control module may register a callback interface in CamLightManager, and the camera control module may register a callback interface in CamxLightCustom.

[0255] The following code can be used when registering the callback interface in the sensor control module:

[0256] CamLightManager::RegisterLuxCb(){

[0257] mCamLightService->RegisterLuxCallback(callingPid,mLuxCallback);

[0258] }

[0259] The following code can be used when registering the callback interface in the camera control module:

[0260] void CamxLightCustom::RegisterLightLuxStatusCb(Callback callback)

[0261] In some embodiments, the sensor control module calls the first interface based on the AIDL service, and the step of registering the data callback function in the camera control module may correspond to Figure 12 Steps ② and ③ specifically include: after the Sensor HAL receives the brightness monitoring instruction, it calls the Active interface in CamLightManager, registers the callback interface in CamLightManager based on the declaration content of the Active interface, and registers the callback interface in CamxLightCustom. When the callback interface registration in CamLightManager and CamxLightCustom is completed, the registration of the data callback function is completed.

[0262] In some embodiments, the data callback function can not only return the ambient light brightness detected by the front camera to the sensor control module when the ambient light detection function of the front camera is enabled; it can also send a notification message to the sensor control module to enable the ambient light detection function of the front camera after the ambient light detection function of the front camera fails to be enabled or is turned off, causing the camera that has failed to enable or is turned off to be turned off.

[0263] In some embodiments, due to the limitations of the photosensitivity 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. In order to improve the accuracy of display brightness adjustment, the camera control module in the embodiment of the present application can also register a data calibration interface function in the callback interface when registering the callback interface. The data calibration function is used to provide a calibration coefficient between the ambient light brightness detected by the front camera and the ambient light brightness in the actual environment. When the ambient light brightness of the front camera is returned based on the callback interface, the ambient light brightness detected by the front camera can be calibrated. The data calibration function can be LuxValueConvert().

[0264] In some embodiments, electronic devices may experience sudden process crashes during operation, and AIDL servers and clients may also experience crashes. In this embodiment of the present application, in order to promptly monitor the crashes of the camera control module (server) and the sensor control module (client), the sensor control module and the camera control module can also register death monitoring objects on their own ends.

[0265] In one implementation, the camera control module can register a first death monitoring object on the local side when registering a callback interface. By registering this first death monitoring object, the camera control module can be monitored for crashes in both screen-on and screen-off scenarios. The sensor control module can register a second death monitoring object on the local side when registering a callback interface. By registering this second death monitoring object, the sensor control module can be monitored for crashes in both screen-on and screen-off scenarios.

[0266] In some embodiments, the Figure 16 Step ① in the process, that is, the first registration and binding death notification, specifically includes: when the Sensor HAL registers the callback interface in CamLightManager, it can register the second death listening object in CamLightManager, so that when the crash event of the Sensor HAL is monitored, a death notification message is generated to notify the Camera HAL; when the Camera HAL registers the callback interface in CamxLightCustom, it can register the first death listening object in CamxLightCustom, so that when the crash event of the Camera HAL is monitored, a death notification message is generated to notify the Sensor HAL.

[0267] In some embodiments, for electronic devices, the front cameras on some electronic devices may support the ambient light detection function, while the front cameras on some electronic devices may not support the ambient light detection function. To avoid enabling the front camera that does not support the ambient light detection function and reduce resource consumption of the electronic device, the sensor control module may obtain the value of the preset flag before calling the first interface to enable the ambient light detection function of the front camera, specifically before executing step S1103, such as when the electronic device is turned on or when a brightness monitoring instruction is received, and then determine whether the front camera of the electronic device supports the ambient light detection function based on the value of the preset flag. If the front camera supports the ambient light detection function, the first interface is called to enable the ambient light detection function of the front camera. If the front camera does not support the ambient light detection function, the first interface is no longer called. The preset flag can be is_ambient_light (is ambient light), which is used to indicate whether the front camera supports the ambient light detection function. The value of the preset flag can be true (correct) or false (false). When the value on the preset flag is true, it can be determined that the front camera supports the ambient light detection function; when the value on the preset flag is false, it can be determined that the front camera does not support the ambient light detection function.

[0268] It should be noted that when the electronic device is not turned off, the data callback function registered in this step can be directly used when the front camera is subsequently called to detect the ambient light brightness without the need for re-registration; when the electronic device is turned off, the data callback function registered in this step will be destroyed. When the electronic device is subsequently turned on again, the above steps S1101 to S1103 need to be executed to register the data callback function.

[0269] S1104: The sensor control module calls the second interface based on the HIDL service and sends a first instruction to the camera service module.

[0270] Typically, cameras include two types: front cameras and rear cameras, and there are at least one front camera and rear camera respectively. Moreover, the front camera and rear camera each have multiple functions, including at least one of a photo taking function, a face unlocking function, and an ambient light detection function. In order to distinguish different types of cameras and different functions of cameras of the same type, the embodiment of the present application abstracts multiple logical cameras according to the type and function of the camera, and each logical camera corresponds to an identifier. For example, based on the photo taking function of the front camera, a logical camera A can be abstracted, and based on the ambient light detection function of the front camera, a logical camera B can be abstracted. Logical camera A and logical camera B can correspond to the same front camera or to different front cameras. For the photo taking function of logical camera A, i.e., the front camera, the identifier set is Camera ID=1, and for the ambient light detection function of logical camera B, i.e., the front camera, the identifier set is Camera ID=4.

[0271] In the embodiment of the present application, the sensor control module can call the first interface to generate the first instruction, and then the second interface sends the first instruction to the camera service module. Among them, the second interface belongs to the interface of the HIDL service, which can be Figure 12 The camera service module can be an independent process, which can be defined as a camera service process. The first instruction can be an Open Camera instruction. The first instruction can include a first identifier, which corresponds to the ambient light detection function of the front camera and can be Camera ID = 4. The first instruction can also include a first package name, which is the package name of the ambient light detection application.

[0272] In some embodiments, the sensor service module calls the second interface to send the first instruction to the camera service module. Figure 12 Step ④ specifically includes: calling the Active interface of CamLightManager in the Sensor HAL, generating a first instruction, and sending the first instruction to the ICameraService in the FWK layer through the libcamera2ndk_vendor interface based on the HIDL service.

[0273] S1105: After receiving the first instruction, the camera service module calls the first function in the camera control module and executes the first function according to the first identifier to control the camera driver to power on the front camera, initialize the camera register and create a reading thread for the ambient light brightness.

[0274] S1106: The camera driver powers on the front camera, initializes the camera registers, and creates a thread for reading ambient light brightness.

[0275] In some embodiments, the operations of powering on the front camera, initializing the camera register, etc. in this step may be a specific process of turning on the front camera, or may be a process of powering on and initializing the front camera.

[0276] Among them, the first function is used to turn on any function of any camera in the electronic device, and the first function can be an Open Camera function. After receiving the first instruction, the camera service module can call the first function in the camera control module and execute the first function according to the first identifier. According to the first identifier, it can be determined that the ambient light detection function of the front camera needs to be turned on. At this time, the front camera will replace the ambient light detection device. When the front camera replaces the ambient light detection device, the front camera needs to detect the ambient light brightness without collecting images. In order to reduce the power consumption of the front camera, the camera service module executes the necessary processes in the first function to turn on the ambient light detection function of the front camera according to the first identifier, such as applying for the chip support library (CSL) resource cache (buffer), powering on the front camera, initializing the camera registers and creating a reading thread for the ambient light brightness, etc., and jumps out of the processes that are not related to turning on the ambient light detection function of the front camera, such as the process of configuring the image output resources. By executing the first function, a corresponding control instruction can be generated, and the control instruction is sent to the camera driver, thereby controlling the camera driver to apply for CSL resource cache for the front camera, power on the front camera, initialize the camera register, create a reading thread, etc. Among them, the created reading thread is used to read and calculate the ambient light brightness detected by the front camera. In some embodiments, the reading thread can be an asynchronous reading thread. In some embodiments, the reading thread can periodically read the ambient light brightness detected by the front camera. Based on the initialization of the camera register, the period of the front camera detecting the ambient light brightness, the frequency of the front camera detecting the ambient light brightness, etc. can be written into the front register to control the operation of the front camera.

[0277] In some embodiments, this step may correspond to Figure 12Step 5 in the preceding section specifically includes: upon receiving the first instruction, calling the Open Camera function in CAMX of the Camera HAL through CameraService, executing the Open Camera function, and sending control instructions to the camera driver through the CamxLightCustom interface, causing the camera driver to apply for a CSL resource cache for the ambient light detection function of the front camera, power on the front camera, initialize the camera registers, create an asynchronous read thread, etc. This in turn causes the camera sensor (Camera Sensor) in the hardware layer (Driver) to begin operation.

[0278] When the method of the embodiment of the present application is used, when the front camera is used instead of the ambient light detection device, no image output resources will be configured for the front camera, and the front camera will not capture images, thereby reducing the resource consumption of the front camera and improving the performance of the electronic device.

[0279] S1107: The camera control module obtains the target ambient light brightness output by the front camera, and sends the target ambient light brightness to the sensor control module through the data callback function.

[0280] The target ambient light brightness is the target ambient light brightness of the current frame determined based on the ambient light brightness detected by the front camera (which may be referred to as the fourth ambient light brightness) according to the method provided in the embodiments of the present application. The fourth ambient light brightness is the raw data collected by the front camera in the aforementioned embodiments.

[0281] In one possible implementation, the camera driver can periodically read the fourth ambient light brightness through a reading thread and send the read fourth ambient light brightness to the camera control module, so that the camera control module can obtain the fourth ambient light brightness output by the front camera. The reading cycle can be 200ms. The camera driver can also periodically read the fourth ambient light brightness detected by the front camera through a reading thread and store the read fourth ambient light brightness in a cache. The camera control module can periodically read the fourth ambient light brightness stored in the cache of the camera driver to obtain the fourth ambient light brightness output by the front camera. In some embodiments, the reading cycle of the camera driver and the reading cycle of the camera control module can be the same or different.

[0282] In some embodiments, the camera control module may send the target ambient light brightness to the sensor control module via a pre-registered data callback function. Specifically, the camera control module may fill the target ambient light brightness into the pre-registered data callback function, and send the target ambient light brightness to the sensor control module via the data callback function.

[0283] Based on the different contents of the target ambient light brightness, the camera control module sends the target ambient light brightness to the sensor control module through a pre-registered data callback function. Specifically, the following methods are included:

[0284] In the first method, the camera control module fills the target ambient light brightness output by the front camera into the data callback function, and sends the target ambient light brightness to the sensor control module through the data callback function.

[0285] In the second method, the camera control module fills the fourth ambient light brightness detected by the front camera and the target ambient light brightness obtained after calibration into the data callback function, and sends the fourth ambient light brightness detected by the front camera and the target ambient light brightness to the sensor control module through the data callback function.

[0286] In the third method, the camera control module fills the fourth ambient light brightness detected by the front camera, the target ambient light brightness obtained after calibration, and the status parameters of the front camera into the data callback function, and through the data callback function, sends the fourth ambient light brightness detected by the front camera, the second ambient light brightness and status parameters to the sensor control module.

[0287] For the third method, the form of the filled data callback function can be:

[0288] pCamxLightCustom->mStatusCb(static_cast <float>(luxValue),luxValueFinal,status);

[0289] Among them, luxValue is the fourth ambient light brightness detected by the front camera, luxValueFinal is the target ambient light brightness, that is, the ambient light brightness output by the front camera, and status is the status parameter of the front camera.

[0290] In some embodiments, three specific implementation methods are listed here. Only one of the methods can be used to return the target ambient light brightness, or multiple methods can be used to return the target ambient light brightness. The target ambient light brightness can be returned in the same method or in different methods each time. For example, the target ambient light brightness can be returned in the first time using the first implementation method, the second time using the second implementation method, the third time using the third implementation method, and so on. Alternatively, the target ambient light brightness can be returned in multiple methods each time, and then the target ambient light brightness returned in multiple methods can be combined.

[0291] S1108: The sensor control module sends the target ambient light brightness to the sensor service module.

[0292] In some embodiments, the ReportLuxStatus object in the sensor control module can receive the target ambient light brightness sent by the camera control module, and then send the target ambient light brightness to the sensor service module.

[0293] In one implementation, when the sensor service module sends a brightness monitoring command to the sensor control module, it registers a callback function in the sensor control module. Through this callback function, the sensor control module can send the target ambient light brightness to the sensor service module. In some embodiments, the sensor control module can fill the target ambient light brightness into the callback function, and through this callback function, send the target ambient light brightness to the sensor control module.

[0294] In another implementation, the sensor service module may periodically read the target ambient light brightness of the sensor control module.

[0295] For the sensor control module's processing logic for the target ambient light brightness, see the following code:

[0296] ::ndk::ScopedAStatus ReportLuxStatus(const LuxStatus&out_data){

[0297] / / Client data processing logic

[0298] }

[0299] In some embodiments, steps S1107 to S1108 may correspond to Figure 12 Steps 5 and 6 in the figure specifically include: CamxLightCustom of Camera HAL obtains the target ambient light brightness output by the front camera, returns the target ambient light brightness to the ReportLuxStatus object in CamLightManager of Sensor HAL through a pre-registered data callback function, and the ReportLuxStatus object reports the target ambient light brightness to SensorManager through SensorService.

[0300] S1109: The sensor service module adjusts the brightness of the display screen of the electronic device based on the target ambient light brightness.

[0301] In one implementation, adjusting the brightness of the display screen may include setting the brightness of the display screen. Specifically, the sensor service module may determine the brightness of the display screen based on the target ambient light brightness, and then set the brightness of the display screen to the determined brightness. The sensor service module may also determine the brightness of the display screen based on historical ambient light brightness and the target ambient light brightness, and then set the brightness of the display screen to the determined brightness.

[0302] In another implementation, adjusting the brightness of the display screen may be to adjust the initial brightness based on the initial brightness of the display screen. The initial brightness may be a brightness value pre-set by a technician. Specifically, the sensor service module may determine the brightness of the display screen based on the target ambient light brightness, and then adjust the brightness of the display screen from the initial brightness to the determined brightness; the sensor service module may also determine the brightness of the display screen based on the historical ambient light brightness and the target ambient light brightness, and then adjust the brightness of the display screen from the initial brightness to the determined brightness. In some embodiments, when adjusting the brightness of the display screen from the initial brightness to the determined brightness, it may be adjusted gradually to avoid excessive brightness changes that affect the user experience.

[0303] In some embodiments, when adjusting the brightness of the display screen, the sensor service may generate a brightness adjustment instruction, and then send the brightness adjustment instruction to the sensor control module. The sensor control module sends the brightness adjustment instruction to the display screen driver, so that the display screen driver executes the brightness adjustment instruction and adjusts the brightness of the display screen.

[0304] 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 initialization process of the AIDL service in step S1101 and the registration process of the data callback function in step S1103, but execute other steps.

[0305] See also Figure 13 The embodiment of the present application provides a method for turning off the ambient light detection function of the front camera when the screen is off. When the screen of the electronic device is off, the method can turn off the ambient light detection function of the front camera to reduce the power consumption of the electronic device. Figure 2 The electronic device 100 of the software system shown in the embodiment of the present application is used as an example, and the method can be used with Figure 11 The display brightness adjustment process shown is independent and has no timing relationship. Figure 11 Executed at any time after step S1105. Figure 13 , the method process provided in the embodiment of the present application includes:

[0306] S1301: After the screen of the electronic device is turned off, the sensor control module calls the third interface based on the AIDL service, and then calls the second interface to send a second instruction to the camera service module.

[0307] In some embodiments, based on the screen of the electronic device being turned off, the sensor service module can receive a screen-off message from the electronic device. After receiving the screen-off message, the sensor service module can send a stop brightness monitoring instruction to the sensor control module. After receiving the stop brightness monitoring instruction, the sensor control module can call a third interface to generate a second instruction, and then call the second interface to send the second instruction to the camera service module. Among them, the third interface can be a DeActive interface, which is used to turn off the ambient light detection function of the front camera. The second instruction can be a CloseCamera (turn off the camera) instruction, including a first identifier, a first package name, etc.

[0308] In some embodiments, this step may correspond to Figure 14 The steps ①②③④ in the figure specifically include: SensorManager receives the screen-off message of the electronic device, generates a stop brightness monitoring instruction, and calls SensorService to send the stop brightness monitoring instruction to Sensor HAL. Sensor HAL calls the DeActive interface of CameraLightManager to generate a Close Camera instruction. The Close Camera instruction includes Camera ID=4 and the package name of the ambient light detection application. Then, libcamera2ndk_vendor is called to send the Close Camera instruction to the CameraService of the FWK layer.

[0309] S1302: After receiving the second instruction, the camera service module calls the second function in the camera control module and executes the second function according to the first identifier to control the camera driver to close the reading thread and power off the front camera.

[0310] S1303: The camera driver closes the reading thread and powers off the front camera.

[0311] After receiving the second instruction, the camera service module calls the second function in the camera control module and executes the second function based on the first identifier. By executing the second function, a corresponding shutdown instruction can be generated and sent to the camera driver. Based on the shutdown instruction, the camera driver shuts down the reading thread, stops reading the ambient light brightness, powers down the front camera, and releases the CSL resource cache requested for the front camera. Furthermore, after the camera driver shuts down the reading thread, the camera control process stops sending the target ambient light brightness to the sensor control module through the data callback function.

[0312] The logic code for disabling the ambient light detection function of the front camera can be:

[0313] CloseCamLightSensor(const struct camera3_device*pCamera3Device,bool&isCamLightId) (Close Camera light id encapsulation function)

[0314] In some embodiments, this step may correspond to Figure 14 Step 5 specifically includes: Based on the Close Camera instruction, the CameraService calls the Close Camera function in the Camera HAL's CAMX. By executing this CloseCamera function, the camera driver shuts down the asynchronous read thread, stops reading ambient light brightness, powers off the front camera, and releases the CSL resource cache allocated for the front camera. Consequently, the camera sensor at the hardware layer (driver) stops functioning.

[0315] Usually, electronic devices are equipped with a front camera and a rear camera. The front camera supports image output mode and ambient light detection mode. The image output mode corresponds to the photo taking function, face unlocking function, etc. of the front camera. In the image output mode, the front camera needs to capture images to meet the user's usage needs. Unlike the image output mode, in the ambient light detection mode, the display brightness is adjusted based on the ambient light brightness output by the front camera in order to improve the user's usage needs, and compared with the image output mode, the user demand is lower. In actual application, the front camera and the rear camera cannot be enabled at the same time, and the image output mode and ambient light detection mode of the front camera cannot be enabled at the same time. In order to solve the problem of camera enabling priority, the embodiment of the present application sets corresponding identifiers for each camera in the electronic device, each identifier corresponds to a logical function of the camera, and sets the conflict judgment logic of the camera identifier, and configures different priorities for different package names, so that the priority of different identifiers can be determined based on the package name priority.

[0316] Specifically, the process of configuring a corresponding identifier for a camera in an electronic device may include: during the electronic device's startup process, the camera control module interacts with the camera driver to obtain the type and function of the camera in the electronic device, then abstracts multiple logical cameras based on the camera type and function, and sets a corresponding identifier for each logical camera. For example, the identifier set for the front camera's photo function is CameraID=1; the identifier set for the front camera's ambient light detection function is CameraID=4.

[0317] The above is the process of setting the flag for the ambient light detection function of the front camera. Please refer to the following code:

[0318]

[0319]

[0320] To ensure normal user use, the embodiment of the present application can configure the lowest priority for the package name of the ambient light detection application, so that when the user wants to open the camera application to take a photo, the photo service can be provided to the user. To facilitate subsequent use, the camera control module can store the set camera identifier and the priority of different package names. Furthermore, the camera control module can send the set camera identifier and the priority of different package names to the camera service module for storage, so that the camera service module can manage the enabling priority of the camera.

[0321] In the embodiment of the present application, the management logic of the camera enabling priority of the camera service module can be: receiving a target instruction, which includes a target identifier and a target package name. After receiving the target instruction, the camera service module queries the camera list, which is used to store the identifiers corresponding to the currently enabled cameras. When the camera list is empty, it can be determined that there is no enabling conflict for the camera, and then based on the target instruction, the function of the camera corresponding to the target identifier is turned on; when the camera list is not empty, it can be determined that there is an enabling conflict for the camera, that is, there is currently an enabled camera, and then based on the target package name and the package name of the currently enabled camera, the priority of the target identifier and the identifier corresponding to the currently enabled camera can be determined. When the priority of the target identifier is lower than the priority of the currently enabled camera, the function of the camera corresponding to the target identifier is no longer turned on; when the priority of the target identifier is higher than the priority of the currently enabled camera, the currently enabled camera is turned off, and then the function of the camera corresponding to the target identifier is turned on.

[0322] The above judgment logic can be seen in the following code:

[0323]

[0324] Among them, ACameraManager_openCamera is the interface function of Open Camera, and buff is PackageName.

[0325] Based on the above judgment logic, Figure 11 Before executing step S1105, the camera service module may query the camera list, and when the camera list is empty, execute step S1105.

[0326] In the embodiment of the present application, for the AIDL service-based client (sensor control module) and server (camera control module), server-side exceptions can include two scenarios: one is the server process crash when the screen-on ambient light detection function is enabled, and the other is the server process crash when the screen-off ambient light detection function is disabled. Client-side exceptions mainly occur when the screen-on ambient light detection function is enabled. For these three scenarios, monitoring can be performed based on the first and second death monitoring objects pre-registered in step S1101, which will be introduced below.

[0327] After the ambient light detection function of the front camera is turned on by executing the above steps S1101 to S1105, during the process of adjusting the brightness of the display screen based on steps S1107 to S1109, when the camera control module does not respond and cannot send the target ambient light brightness output by the front camera to the sensor control module, in response to the abnormal situation of the server side during the process of adjusting the brightness of the display screen of the electronic device, the embodiment of the present application provides a management method for the ambient light detection function, which has Figure 2 The electronic device 100 of the software structure shown in FIG. 1 executes the embodiment of the present application as an example, see Figure 15 The method may be executed after step S1105. The method flow provided in the embodiment of the present application includes:

[0328] S1501: During the process of adjusting the brightness of a display screen of an electronic device, when the camera control module is detected to be unresponsive through a first death monitoring object, the camera control module sends a first death notification message to the sensor control module.

[0329] In some embodiments, this step may correspond to Figure 16 Step ② specifically includes: during the process of adjusting the display brightness of the electronic device, the first death monitoring object (i.e., Death Notifier) monitors the Camera HAL in real time. When it monitors that the Camera HAL is unable to send the target ambient light brightness output by the front camera to the sensor control module and the Sensor HAL, the Camera HAL can call a data callback function (i.e., DeathRecpCallback) to send a first death notification message to the Sensor HAL. The data callback function can be the data callback function registered in step S1101.

[0330] S1502: The sensor control module determines whether the AIDL service is started.

[0331] S1503: When it is determined that the AIDL service is pulled up, the sensor control module executes a call to the first interface, then calls the second interface, and sends a first instruction to the camera service module to enable the ambient light detection function of the front camera.

[0332] Since the camera service module cannot return the target ambient light brightness output by the front camera at this time, it is necessary to re-register the data callback function to ensure that the data path between the camera control module and the sensor control module can transmit data. Enabling the ambient light detection function of the front camera includes: the camera service module calls a first function in the camera control module, executes the first function based on a first identifier, controls the camera driver to apply for a CSL resource cache for ambient light detection for the front camera, powers on the front camera, initializes the camera registers, and creates an asynchronous read thread.

[0333] In some embodiments, this step may correspond to Figure 16 Steps ②-⑥ specifically include: upon receiving the first death notification message, the Sensor HAL determines whether the AIDL service has been started. If the AIDL service has been started, it calls the Active interface, registers a data callback function, and then calls the libcamera2ndk_vendor interface to send a first instruction to the CameraService. This first instruction includes CameraID = 4 and the package name of the ambient light detection application. After receiving the first instruction, the CameraService calls the OpenCamera function in the Camera HAL, executes the OpenCamera function based on CameraID = 4, and then controls the camera driver to apply for the CLS resource cache for CameraID = 4, powers on the front camera, initializes the camera registers, and creates an asynchronous read thread. This causes the Driver's CameraSensor to begin operating. When the target ambient light brightness output by the front camera is read, the Camera HAL fills the target ambient light brightness into the data callback function. The data callback function sends the target ambient light brightness to the Sensor HAL, which then reports it to the SensorService.

[0334] In another embodiment of the present application, when the AIDL service is not started, it is necessary to wait for a preset period of time and then determine again whether the AIDL service is started.

[0335] After the electronic device turns off the screen, after executing the above steps S1301 to S1303, if the ambient light detection function of the front camera cannot be turned off normally, the embodiment of the present application provides a management method for the ambient light detection function in order to solve the problem that the server does not respond after the electronic device turns off the screen. Figure 2 The electronic device 100 of the software structure shown in FIG. 1 executes the embodiment of the present application as an example, see Figure 17 The method may be executed after step S1303. The method flow provided in the embodiment of the present application includes:

[0336] S1701: After the screen of the electronic device is turned off, when the first death monitoring object monitors that the camera control module does not respond, the camera control module sends a second death notification message to the sensor control module.

[0337] In some embodiments, this step corresponds to Figure 18 Step ①, i.e., the first registration and binding of the death notification, specifically includes: after the electronic device screen is turned off, the first death monitoring object (i.e., Death Notifier) detects that the Camera HAL crashes and cannot normally disable the ambient light detection function of the front camera. It can call the data callback function (i.e., Death RecpCallback) to send a second death notification message to the Sensor HAL.

[0338] S1702: After receiving the second death notification message, the sensor control module determines whether the screen of the electronic device is off.

[0339] S1703: When it is determined that the screen of the electronic device is off, the sensor control module calls the first interface and sends an initialization instruction to the camera control module.

[0340] S1704: After receiving the initialization instruction, the camera control module initializes the front camera and the data callback function.

[0341] In some embodiments, this step corresponds to Figure 18 Steps ② and ③ specifically include: after receiving the second death notification message, the Sensor HAL can call the Active interface to initialize the camera registers and data callback functions in the Camera HAL.

[0342] In this scenario, since the display is off and there is no need to adjust the ambient light brightness, the sensor control module no longer enables the front camera, which means that the CameraSensor in the Driver stops working.

[0343] After the ambient light detection function of the front camera is enabled by executing the above steps S1101 to S1105, during the process of adjusting the brightness of the display screen based on steps S1107 to S1109, when the sensor control module cannot turn on the ambient light detection function of the front camera, the embodiment of the present application provides a management method for the ambient light detection function in order to solve the problem that the server does not respond during the process of adjusting the brightness of the display screen of the electronic device. Figure 2 For example, the electronic device with the software structure shown in FIG. Figure 19 , the method process provided in the embodiment of the present application includes:

[0344] S1901: After the screen of the electronic device is turned on, when the second death monitoring object monitors that the sensor control module does not respond, the sensor control module sends a third death notification message to the camera control module.

[0345] In some embodiments, this step corresponds to Figure 20 Step ① specifically includes: after the electronic device turns on the screen, the second death monitoring object monitors the Sensor HAL in real time, and when a crash event of the Sensor HAL is monitored, the data callback function is called to send a third death notification message to the Camera HAL.

[0346] S1902: After receiving the third death notification message, the camera control module closes the reading thread and destroys the data callback function.

[0347] In some embodiments, this step corresponds to Figure 20 Step ② specifically includes: upon receiving the third death notification message, the Camera HAL controls the camera driver to shut down the asynchronous reading thread, stop reading the ambient light brightness, and destroy the data callback function. In other words, it stops reading the ambient light brightness from the CameraSensor in the driver.

[0348] S1903: The sensor control module calls the third interface based on the AIDL service, and then calls the second interface to send a second instruction to the camera service module.

[0349] In some embodiments, this step corresponds to Figure 20 Steps ③ and ④ specifically include: Sensor HAL calls the DeActive interface, and then calls the libcamera2ndk_vendor interface to send a second instruction to CameraService, where the second instruction includes CameraID=4 and the package name of the ambient light detection application.

[0350] S1904: After receiving the second instruction, the camera service module calls the second function in the camera control module and executes the second function according to the first identifier to control the camera driver to close the reading thread and power off the front camera.

[0351] In some embodiments, this step corresponds to Figure 20 Step ⑤ in the above example specifically includes: after receiving the second instruction, the CameraService calls the Camera HAL to control the camera driver to release the CSL resources applied for the function with CameraID=4 and power off the front camera. This causes the CameraSensor in the Driver to stop working.

[0352] S1905: After the sensor control module restarts, it calls the first interface to register the data callback function in the camera control module, and calls the second interface to send a first instruction to the camera service module to enable the ambient light detection function of the front camera.

[0353] In some embodiments, this step corresponds to Figure 20 Step ⑥ specifically includes: the Sensor HAL calls the Active interface, and then calls the libcamera2ndk_vendor interface to send a first instruction to the CameraService, where the first instruction includes CameraID=4 and the package name of the ambient light detection application to enable the ambient light detection function of the front camera.

[0354] Generally, the camera software process is more complex than the physical ambient light software process, and consumes more power. Meeting the performance requirements cannot meet the power consumption requirements, and meeting the power consumption requirements cannot meet the performance requirements. For this reason, the embodiment of the present application will also optimize the display brightness adjustment method in the above embodiment, so as to ensure that the first frame data can be reported in a timely and effective manner under the premise of reducing the function. Figure 21 ,This method mainly involves the following three aspects in terms of reducing power consumption and optimizing ,performance:

[0355] First, streamline the process of OpenCamera function in CAMX

[0356] Regarding the first aspect, the embodiment of the present application customizes the process of the original Open Camera function, adds a branch for jumping out of the image output and distribution flow, and when calling CameraService to call the Open Camera function in the Camera HAL, when the original Open Camera function supports turning on the ambient light detection function of the front camera, the encapsulation function OpenCamLightSensor is called to skip the image output and distribution flow process, saving resource consumption when the front camera is used as an ambient light detection device and improving the performance of the electronic device.

[0357] For the simplified execution process of OpenCamera function, the above Figure 11 The process of adjusting the brightness of the display screen during the startup process is used as an example for explanation. Since the embodiment of the present application needs to turn on the ambient light detection function of the front camera, if the front camera does not support turning on the ambient light detection function of the front camera, it is impossible to enable the ambient light detection function of the front camera by calling the first function. Therefore, after calling the first function, the first sub-function in the first function will also be called to determine whether the front camera supports the ambient light detection function. If the front camera supports the ambient light detection function, the second sub-function in the first function will be called to control the camera driver to power on the front camera, initialize the camera register and create an asynchronous reading thread, so that the CameraSensor in the Driver starts working. By executing this streamlined OpenCamera function, the image output and streaming process can be skipped, the opening time of the ambient light detection function can be shortened, and the performance of the electronic device can be improved.

[0358] The ambient light detection judgment function may be IsSupportCamLightSensor() (supporting the camera brightness sensor), and the ambient light detection sensor function may be OpenCamLightSensor() (opening the camera brightness sensor).

[0359] The code for the logic of judging whether the front camera supports ambient light detection is: static int open(const struct

[0360]

[0361] Of course, if the front camera does not support ambient light detection, you can interact with the camera driver in the kernel layer to control the camera driver to apply for CSL resource cache for the ambient light detection function of the front camera, power on the front camera, initialize the camera registers and allocate streams for the front camera so that the front camera can output images.

[0362] Second, set a higher priority for the reading thread

[0363] Considering that multiple threads may be executed simultaneously in the camera driver, in order to ensure timely reporting of ambient light brightness, a higher priority can be set for the asynchronous thread, so that the execution of the reading thread can be prioritized when resources are limited.

[0364] Third, adaptive switching frequency

[0365] Electronic devices have relatively strict requirements for the first frame data of ambient light brightness (the one frame data here is not the image frame), and generally require it to be reported within 300ms. There are no strict requirements for the second frame data and subsequent frames, and the reporting time of the first frame data depends on the frame rate of the front camera. When the frequency of the front camera is set to a lower frequency to reduce power consumption, it may not be possible to report data within 300 milliseconds because it takes time to detect the ambient light brightness. In order to ensure that the first frame data can be reported in time, an embodiment of the present application provides an adaptive frequency switching method, which records the target number and writes the target number into the camera register. The target number can be the number of times the camera control module of the electronic device reads the ambient light brightness from the front camera after the screen is turned on this time, or it can be the number of times the camera control module of the electronic device reads the ambient light brightness from the front camera after the screen is turned on for the last time. After the electronic device turns off the screen, the target number recorded in the camera register will be cleared. After the front camera is powered on, the camera control module obtains the target number of times from the camera register. When the target number of times is 0, the camera control module writes the first frequency into the camera register, that is, writes it before the second read, and controls the front camera to detect the ambient light brightness according to the first frequency; when the target number of times is greater than 0, the camera control module writes the second frequency into the camera register and controls the front camera to detect the ambient light brightness according to the second frequency, where the first frequency is greater than the second frequency. The frequency at which the front camera detects the ambient light brightness can be determined based on a preset frame rate. For example, the first frequency corresponds to the first preset frame rate, and the second frequency corresponds to the second preset frame rate. The first preset frame rate is higher than the second preset frame rate. The first preset frame rate can be 30fps, and the second preset frame rate can be 5fps or 3fps.

[0366] This optimization method can be executed after step S1105 and before step S1107. By adaptively adjusting the frequency at which the front camera collects ambient light brightness, not only is the first frame data reported in a timely manner, but the power consumption of the electronic device is also reduced.

[0367] See also Figure 22 , Figure 22 A flowchart of a method for determining ambient light brightness provided in an embodiment of the present application, which is applied to electronic devices. First, Index takes CurrentIndex-1 and obtains the current brightness. The current brightness is the ambient light brightness of the previous frame, and the current brightness interval is the brightness interval to which the ambient light brightness of the previous frame belongs (i.e., the first brightness interval). Index represents the brightness interval. Let the current brightness interval be c, and Index takes CurrentIndex-1, which is to determine the brightness interval before the current brightness interval, which is recorded as c-1.

[0368] Then, when Index equals CurrentIndex - 1, determine whether the Type of Index and Index+1 are not equal. Since Index is CurrentIndex - 1, at this point, Index is c-1, and Index+1 is c-1+1 (i.e., c). This means that the Setting Type of the current brightness interval is not equal to that of the previous brightness interval.

[0369] If Index equals CurrentIndex-1, and the Types of Index and Index+1 are not equal, the current brightness range and the previous brightness range have different Setting Types. In other words, the Type of the previous range (previous brightness range c-1) is different from the current range (current brightness range c), then the loop is exited and the current lux is calculated without using the previous coefficient. Instead, the calibration coefficient corresponding to the previous brightness range is used to determine the second ambient light brightness.

[0370] Then, the index is set to Index+1. Since the previous index was Index-1 (i.e., c-1), Index+1 is now c. This means that the calibration coefficient corresponding to the current brightness range (i.e., c) is used to determine the brightness of the second ambient light. A determination is then made as to whether the second ambient light brightness is within the previous brightness range or the current brightness range. If the second ambient light brightness is within the previous brightness range, the previous brightness range is determined to be the target brightness range. If the second ambient light brightness is within the current brightness range, the current brightness range is determined to be the target brightness range.

[0371] Next, the index is set to Index+1. Since the previous index was Index+1 (i.e., c), Index+1 is now c+1. A determination is then made as to whether the second ambient light brightness is within the brightness interval following the current brightness interval (i.e., c+1). If the second ambient light brightness is within the following brightness interval, the following brightness interval is determined to be the target brightness interval.

[0372] Figure 22 In the expression, Index++ means that the first time the Index is calculated, it is Index+1 (i.e., c), and the second time the Index is calculated, it is Index+1 (i.e., c+1).

[0373] If Index equals CurrentIndex-1, and the Types of Index and Index+1 are the same, the current brightness range and the previous brightness range have the same Setting Type. Check whether Index equals current and whether there is a previous range. In other words, check whether Index is c and whether there is a brightness range previous to the current brightness range.

[0374] If the value of Index is c and there is a brightness interval before the current brightness interval (i.e., c-1), if the current brightness is within the previous range (Index-1), CurrentIndex = Index-1 and the loop is exited. In other words, if there is a previous brightness interval, the calibration coefficient corresponding to the previous brightness interval is used to calculate the second ambient light brightness. If the second ambient light brightness is within the previous brightness interval, the previous brightness interval is determined to be the target brightness interval.

[0375] If the value of Index is c and there is no brightness interval before the current brightness interval (i.e., c-1), then the current brightness is determined to be within the range of Index or Index+1, and the corresponding value is assigned to CurrentIndex. In other words, if there is no previous brightness interval, the calibration coefficient corresponding to the current brightness interval is used to calculate the third ambient light brightness. If the third ambient light brightness is within the current brightness interval, the current brightness interval is determined to be the target brightness interval. If the third ambient light brightness is within the next brightness interval, the next brightness interval is determined to be the target brightness interval.

[0376] Furthermore, the target ambient light brightness of the current frame is calculated based on the target calibration coefficient corresponding to the target brightness interval and the target image data collected in the current frame.

[0377] The following combination Figure 23 and Figure 24 ,right Figure 22 The following illustrates the effectiveness of the provided ambient light brightness determination method. The broken line with the origin represents the correspondence between the measured lux detected by the physical device and the simulated positioning lux. The broken line with triangles represents the correspondence between the measured lux detected by the Default (non-implemented) parameters and the simulated positioning lux. The broken lines with squares represent the correspondence between the measured lux detected by the Low, Medium, and High parameters and the simulated positioning lux.

[0378] The measured lux detected by the physical device is the ambient light brightness detected by the ambient light detection device. The measured lux detected by the default parameter is the ambient light brightness determined in accordance with the existing technology. The measured lux detected by the low / medium / high parameters is the ambient light brightness determined in accordance with the existing technology. Figure 22 Provides methods to determine the ambient light intensity.

[0379] according to Figure 23 and Figure 24 Can get, Figure 22 The ambient light brightness determination method provided by the invention is closer to the ambient light brightness detected by the physical device and closer to the simulated ambient light brightness, with higher accuracy. Figure 22 The provided method determines the ambient light brightness and adjusts the display brightness of the electronic device, which can improve the accuracy of adjusting the brightness of the electronic device's display and enhance user experience.

[0380] In a specific implementation, the present application also provides an electronic device, which includes one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute some or all of the steps in the above method embodiment.

[0381] The present application also provides a computer-readable storage medium including a computer program. When the computer program is executed on an electronic device, the electronic device executes some or all of the steps in the above method embodiments. The above storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0382] In a specific implementation, an embodiment of the present application further provides a computer program product, which includes executable instructions. When the executable instructions are executed on an electronic device, the electronic device executes some or all of the steps in the above method embodiment.

[0383] like Figure 25 As shown, the present application also provides a chip system, which is applied to electronic devices. The chip system includes one or more processors 2501. The processor 2501 is used to call computer instructions so that the electronic device inputs the data to be processed into the chip system. The chip system processes the data based on the display brightness adjustment method provided in the embodiment of the present application and outputs the processing results.

[0384] In one possible implementation, the chip system further includes input and output interfaces for inputting and outputting data.

[0385] The various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.

[0386] Program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0387] Program code can be implemented with a high-level programming language or an object-oriented programming language to communicate with the processing system. Where necessary, program code can also be implemented in assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any particular programming language. In either case, the language can be a compiled language or an interpreted language.

[0388] In some cases, the disclosed embodiments can be implemented in hardware, firmware, software or any combination thereof. The disclosed embodiments can also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which can be read and executed by one or more processors. For example, instructions can be distributed over a network or by other computer-readable media. Therefore, machine-readable media can include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including but not limited to, floppy disks, optical disks, optical disks, compact disc read-only memories (Compact Disc Read Only Memory, CD-ROMs), magneto-optical disks, read-only memories, random access memories, erasable programmable read-only memories (Erasable Programmable Read Only Memory, EPROM), electrically erasable programmable read-only memories (Electrically Erasable Programmable Read Only Memory, EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable memories for transmitting information (e.g., carrier waves, infrared signal digital signals, etc.) using the Internet in electrical, optical, acoustic or other forms of propagation signals. Accordingly, machine-readable media includes any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).

[0389] In the accompanying drawings, some structural or method features may be shown in a particular arrangement and / or order. However, it should be understood that such a particular arrangement and / or order may not be required. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the accompanying drawings. In addition, the inclusion of a structural or method feature in a particular figure does not imply that such a feature is required in all embodiments, and in some embodiments, such features may not be included or may be combined with other features.

[0390] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems raised by this application. In addition, in order to highlight the innovative part of this application, the above-mentioned device embodiments of this application do not introduce units / modules that are not closely related to solving the technical problems raised by this application. This does not mean that other units / modules do not exist in the above-mentioned device embodiments.

[0391] It should be noted that in the examples and description of this patent, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further limitations, an element defined by the phrase "including a" does not exclude the presence of other identical elements in the process, method, article or device that includes the element.

[0392] Although the present application has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the application.< / float>

Claims

1. A method for adjusting the brightness of a display screen, characterized in that: The method is applied to an electronic device, and includes: Acquire the ambient light brightness detected by the target camera of the electronic device in a previous frame to obtain a first ambient light brightness; Calculating a second ambient light brightness based on a first brightness interval to which the first ambient light brightness belongs and target image data captured by the target camera in a current frame; Determining a brightness range of the current frame based on the second ambient light brightness to obtain a target brightness range; In a preset correspondence between brightness intervals and calibration coefficients, determining the calibration coefficient corresponding to the target brightness interval to obtain the target calibration coefficient; wherein the plurality of brightness intervals in the correspondence are arranged in order from low to high according to the brightness included; Calculating the target ambient light brightness of the current frame based on the target calibration coefficient and the target image data; Adjust the brightness of the display screen of the electronic device based on the target ambient light brightness of the current frame.

2. The method according to claim 1, characterized in that Before calculating the second ambient light brightness based on the first brightness interval to which the first ambient light brightness belongs and the target image data captured by the target camera in the current frame, the method further includes: determining whether to switch parameter settings of the target camera from a brightness interval preceding the first brightness interval to the first brightness interval; The calculating the second ambient light brightness based on the first brightness interval to which the first ambient light brightness belongs and the target image data collected by the target camera in the current frame includes: When the parameter setting of the target camera is not switched from a brightness interval preceding the first brightness interval to the first brightness interval, determining a calibration coefficient corresponding to a brightness interval preceding the first brightness interval in a preset correspondence between brightness intervals and calibration coefficients to obtain a first calibration coefficient; The second ambient light brightness is calculated based on the first calibration coefficient and the target image data captured by the target camera in the current frame.

3. The method according to claim 2, characterized in that The determining, based on the brightness of the second ambient light, the brightness range of the current frame to obtain a target brightness range includes: Determining whether the brightness of the second ambient light is within a brightness interval preceding the first brightness interval; When the brightness of the second ambient light is in a brightness interval preceding the first brightness interval, determining the brightness interval preceding the first brightness interval as the brightness interval of the current frame to obtain a target brightness interval; When the brightness of the second ambient light is not within a brightness interval preceding the first brightness interval, determining whether the brightness of the second ambient light is within the first brightness interval; When the brightness of the second ambient light is within the first brightness range, the first brightness range is determined to be the brightness range of the current frame, and a target brightness range is obtained.

4. The method according to claim 3, characterized in that After determining whether the brightness of the second ambient light is within the first brightness range, the method further includes: When the brightness of the second ambient light is not within the first brightness range, determining the calibration coefficient corresponding to the first brightness range in a preset correspondence between brightness ranges and calibration coefficients to obtain a second calibration coefficient; Calculating a third ambient light brightness based on the second calibration coefficient and the target image data; Determining whether the brightness of the third ambient light is within the first brightness range; When the brightness of the third ambient light is within the first brightness range, determining the first brightness range as the brightness range of the current frame to obtain a target brightness range; When the brightness of the third ambient light is not within the first brightness range, determining whether the brightness of the third ambient light is within a brightness range subsequent to the first brightness range; When the brightness of the third ambient light is in a brightness interval subsequent to the first brightness interval, the brightness interval subsequent to the first brightness interval is determined to be the brightness interval of the current frame, and a target brightness interval is obtained.

5. The method according to claim 4, characterized in that Before determining whether to switch the parameter setting of the target camera from a brightness interval preceding the first brightness interval to the first brightness interval, the method further includes: Determining whether there is a brightness interval before the first brightness interval; The determining whether to switch the parameter setting of the target camera from a brightness interval preceding the first brightness interval to the first brightness interval includes: When there is a brightness interval preceding the first brightness interval, it is determined whether to switch the parameter setting of the target camera from the brightness interval preceding the first brightness interval to the first brightness interval.

6. The method according to claim 5, characterized in that After determining whether there is a brightness interval preceding the first brightness interval, the method further includes: When there is no brightness interval before the first brightness interval, in the correspondence between the preset brightness intervals and the calibration coefficients, the calibration coefficient corresponding to the first brightness interval is determined to obtain the second calibration coefficient, and the step of calculating the third ambient light brightness based on the second calibration coefficient and the target image data is performed.

7. The method according to claim 4, characterized in that After determining whether the brightness of the third ambient light is in a brightness interval subsequent to the first brightness interval, the method further includes: When the brightness of the third ambient light is not in a brightness interval subsequent to the first brightness interval, determining whether the brightness of the third ambient light is lower than a lower limit value of a brightness interval preceding the first brightness interval; When the brightness of the third ambient light is lower than the lower limit value of a brightness interval preceding the first brightness interval, the brightness interval preceding the first brightness interval is determined to be the brightness interval of the current frame, and a target brightness interval is obtained.

8. The method according to claim 7, characterized in that After determining whether the brightness of the third ambient light is lower than a lower limit value of a brightness interval preceding the first brightness interval, the method further includes: When the brightness of the third ambient light is not lower than the lower limit value of a brightness interval preceding the first brightness interval, determining whether the brightness of the third ambient light is higher than the upper limit value of a brightness interval following the first brightness interval; When the brightness of the third ambient light is higher than the upper limit of a brightness interval following the first brightness interval, the brightness interval following the first brightness interval is determined to be the brightness interval of the current frame, and a target brightness interval is obtained.

9. The method according to claim 2, characterized in that The calculating the second ambient light brightness based on the first brightness interval to which the first ambient light brightness belongs and the target image data collected by the target camera in the current frame includes: When switching the parameter setting of the target camera from a brightness interval preceding the first brightness interval to the first brightness interval, determining the calibration coefficient corresponding to the first brightness interval in a preset correspondence between brightness intervals and calibration coefficients to obtain a second calibration coefficient; The second ambient light brightness is calculated based on the second calibration coefficient and the target image data captured by the target camera in the current frame.

10. The method according to claim 9, characterized in that The determining, based on the brightness of the second ambient light, the brightness range of the current frame to obtain a target brightness range includes: Determining whether the brightness of the second ambient light is within a brightness interval preceding the first brightness interval; When the brightness of the second ambient light is in a brightness interval preceding the first brightness interval, determining the brightness interval preceding the first brightness interval as the brightness interval of the current frame to obtain a target brightness interval; When the brightness of the second ambient light is not within a brightness interval preceding the first brightness interval, determining whether the brightness of the second ambient light is within the first brightness interval; When the brightness of the second ambient light is within the first brightness range, determining the first brightness range as the brightness range of the current frame to obtain a target brightness range; When the brightness of the second ambient light is not within the first brightness range, determining whether the brightness of the second ambient light is within a brightness range subsequent to the first brightness range; When the brightness of the second ambient light is in a brightness interval subsequent to the first brightness interval, the brightness interval subsequent to the first brightness interval is determined to be the brightness interval of the current frame, and a target brightness interval is obtained.

11. The method according to claim 1, wherein The calculating the target ambient light brightness of the current frame based on the target calibration coefficient and the target image data includes: The target ambient light brightness of the current frame is calculated based on the target calibration coefficient, the target image data, and a preset formula; wherein the preset formula is: Lux=A×R+B Lux represents the target ambient light brightness; A represents a target calibration coefficient; B represents another target calibration coefficient; and R represents the target image data.

12. An electronic device, characterized in that: include: one or more processors and memory; The memory is coupled to the one or more processors, and is configured to store computer program codes, where the computer program codes include 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 11.

13. A computer-readable storage medium, characterized in that The invention comprises a computer program, which, when running on an electronic device, causes the electronic device to execute the method according to any one of claims 1 to 11.

14. A computer program product, characterized in that The computer program product comprises executable instructions, and when the executable instructions are executed on an electronic device, the electronic device is caused to perform the method according to any one of claims 1 to 11.

15. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, which are used to call computer instructions to enable the electronic device to input data into the chip system, and execute the method described in any one of claims 1-11 to process the data and output the processing results.

Citation Information

Patent Citations

  • Interface adjustment method, device and terminal

    CN103856823A

  • Screen brightness adjusting method, device, storage medium, and electronic device

    CN109272917A