Method and electronic device for detecting ambient light

By reusing the photosensitive function of the camera, it solves the layout and accuracy problems of traditional ambient light detection devices on mobile phones, achieves more accurate ambient light detection, and reduces the impact and cost on the layout of mobile phones.

CN117938996BActive Publication Date: 2024-10-29HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311848233.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-28
Publication Date
2024-10-29
Estimated Expiration
2043-12-28

AI Technical Summary

Technical Problem

When traditional ambient light detection devices are set up on mobile phones, they will affect the appearance layout and internal circuit layout, and the detection data will be inaccurate, which may lead to errors in screen brightness adjustment, especially in low-light environments.

Method used

The photosensitive function of the camera is reused, and the naked data is collected and processed by the camera in ambient light mode to obtain the target ambient light parameters. The ambient light sensing device and its supporting processing circuit are directly removed from the electronic device to avoid the influence of traditional ambient light devices.

Benefits of technology

It achieves more accurate ambient light detection, reduces the impact on the appearance and internal layout of the mobile phone, and improves detection accuracy and cost-effectiveness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117938996B_ABST
    Figure CN117938996B_ABST
Patent Text Reader

Abstract

The present application provides a method and electronic device for detecting ambient light, the electronic device includes a first camera, the working mode of the first camera includes a camera mode and an ambient light mode, the method includes: when it is detected that the working mode of the first camera is the ambient light mode, the first communication path between the first camera and the processor is opened, the first communication path is used to represent the communication path corresponding to the ambient light mode; the first camera is used to collect raw data of ambient light in the ambient light mode, the raw data is used to represent the initial data of ambient light collected by the first camera; the raw data is sent to the processor by the first communication path; the processor is used to process the raw data to obtain the target ambient light parameters. This solution replaces the solution of collecting ambient light using an independent ambient light device by multiplexing the light sensing function of the camera, and this solution can simplify the ambient light device and its supporting accessories and circuits on the whole machine.
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 detecting ambient light and an electronic equipment. Background Art

[0002] Current mobile phones are equipped with ambient light devices to detect ambient light and automatically adjust the screen brightness based on the ambient light detection. Most ambient light devices are set on the top or bottom of the phone. They look like a small hole on the phone shell, called a light receiving hole. The light receiving hole also requires various supporting devices such as light guides, viewing angles, and glass cover plates, and the corresponding processing circuit must be set on the printed circuit board (PCB) of the electronic device. Some ambient light devices are also set on the front of the phone, that is, below the screen, which occupies the screen display area, and the influence of the screen's own light will also cause the detected ambient light data to be inaccurate. Some ambient light devices are set on the back of the phone, which will also affect the layout of all devices on the back of the phone, because when set on the back, we must consider whether the light receiving hole will be blocked when the user holds it in his hand, as well as the layout of the rear camera, flashlight, etc. on the back. Especially when there is a flashlight, the light receiving hole will use the brightness of the flashlight as ambient light to adjust the screen brightness, causing the phone to mistakenly judge that it is in a very bright environment even though it is in a dark environment, causing the phone screen brightness to be adjusted to too high a brightness during automatic adjustment, affecting the user experience. Some ambient light device light receiving holes are located in the narrow slit area of ​​the screen glass, which results in a limited light receiving optical path and higher process requirements.

[0003] In short, in traditional solutions, it is necessary to set up an ambient light device to detect ambient light in order to achieve automatic adjustment of screen brightness, but these methods have their own shortcomings and have a great impact on the appearance layout of the mobile phone and the layout of the internal circuit board. Summary of the invention

[0004] The present application provides a method for detecting ambient light and an electronic device, which realizes the detection of ambient light by multiplexing the photosensitivity function of a camera, so that the ambient light device can be removed from the electronic device.

[0005] In a first aspect, a method for detecting ambient light is provided, which is applied to an electronic device, wherein the electronic device includes a first camera, and the working modes of the first camera include a camera mode and an ambient light mode. The method includes: when it is detected that the working mode of the first camera is the ambient light mode, a first communication path between the first camera and a processor is opened, the first communication path is used to represent the communication path corresponding to the ambient light mode; using the first camera to collect raw data of ambient light in the ambient light mode, the raw data is used to represent the initial data of the ambient light collected by the first camera; using the first communication path to send the raw data to the processor; using the processor to process the raw data to obtain target ambient light parameters.

[0006] In the technical solution of the present application, the ambient light sensing function in the camera with both image sensing and ambient light sensing functions is reused to make the camera work in the ambient light mode to collect raw data, and the target ambient light parameters are obtained after processing the raw data. Since the camera has natural advantages in area and layout position compared to traditional ambient light devices, and the advantage of not being affected by occlusion when sensing light, the light receiving area is larger, and there is no need to set up various supporting devices of traditional ambient light devices such as light receiving holes and light receiving columns, and there is no need to perform complex calculations such as compensation for screen light of traditional ambient light devices. In addition, the solution directly allows at least one camera in the electronic device to work in both camera mode and ambient light mode, which is equivalent to superimposing the ambient light detection function on other functional devices, so that the ambient light sensing device and its supporting processing circuit can be directly removed from the electronic device, avoiding the influence of traditional ambient light devices on PCB layout, overall layout, and overall appearance.

[0007] In combination with the first aspect, in certain implementations of the first aspect, when it is detected that the working mode of the first camera is the ambient light mode, switching the communication path between the first camera and the processor to the path corresponding to the ambient light mode may include: configuring the interface of the second communication path between the first camera and the processor from the default integrated circuit (I2C) interface to a general input output (GPIO) interface, and the second communication path is the communication path corresponding to the camera mode; setting the GPIO interface of the second communication path to a high impedance state. In this implementation, while ensuring that the first communication path is open, other communication paths are blocked, so the second communication path is blocked, and the blocking method is to configure the interface of the second communication path to a GPIO interface and then set it to a high impedance state.

[0008] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: when it is detected that the working mode of the first camera is the camera mode, the second communication path is turned on, and the interface of the first communication path is configured from the default I2C interface to the GPIO interface; the GPIO interface of the first communication path is set to a high impedance state. In this implementation, when the working mode of the camera is the camera mode, that is, when the camera is being called by the foreground application, it is equivalent to pausing the function of ambient light detection, so the second communication path is used to transmit image data, and the first communication path is blocked. In this implementation, while ensuring that the second communication path is turned on, other communication paths are blocked, so the first communication path is blocked, and the blocking method is to configure the interface of the first communication path to the GPIO interface and then set it to a high impedance state.

[0009] In combination with the first aspect, in certain implementations of the first aspect, the first camera includes a first pixel set, the camera mode corresponds to the first pixel set, the first pixel set includes a second pixel set, the ambient light mode corresponds to the second pixel set, the pixels in the second pixel set are used to perceive images and light, the other pixels in the first pixel set except the second pixel set are used to perceive images, and the pixels in the second pixel set are evenly distributed in the first pixel set. In this implementation, the function and distribution requirements of the pixels of the first camera are given, and the pixels that can perceive light refer to the pixels with ALS function, and these pixels are evenly distributed in all the pixels of the camera, and these pixels have two perception capabilities, which are used to perceive images in the camera mode and to perceive light in the ambient light mode.

[0010] In conjunction with the first aspect, in certain implementations of the first aspect, when the processor is used to process the raw data to obtain the target ambient light parameters, the method may include: substituting the raw data into a parameter fitting curve to calculate the target ambient light parameters, where the parameter fitting curve is obtained by fitting the ambient light data collected under multiple known illuminations with multiple known illuminations. In this implementation, the ambient light parameters are calculated with the help of the parameter fitting curve.

[0011] In combination with the first aspect, in certain implementations of the first aspect, the parameter fitting curve includes a first curve and a second curve, the first curve corresponds to a first illumination interval, the second curve corresponds to a second illumination interval, and the maximum illumination in the first illumination interval is less than or equal to the minimum illumination in the second illumination interval; when substituting the bare data into the parameter fitting curve to calculate the target ambient light parameters, it may include: when it is determined that the bare data corresponds to the first illumination interval, substituting the ambient light data into the first curve to calculate the target ambient light parameters; or, when it is determined that the bare data corresponds to the second illumination interval, substituting the ambient light data into the second curve to calculate the target ambient light parameters. In this example, according to the different characteristics of different illumination intervals, multiple fitting curves are set for each interval, which can make the fitting curve more accurate and the calculation result more accurate.

[0012] It can be understood that in this example, the parameter fitting curve is not a curve close to a straight line, but a curve with a high curvature. Therefore, the inflection point of the curve (the place with the highest curvature) can be determined to divide the two illumination intervals with the illumination corresponding thereto as the boundary, and then the two different illumination intervals are respectively fitted with curves to obtain two fitting curves. It should also be understood that based on such processing logic, the full illumination interval can also be divided into three or more fine illumination intervals, and a curve is fitted for each interval.

[0013] In combination with the first aspect, in certain implementations of the first aspect, when substituting the raw data into the parameter fitting curve to calculate the target ambient light parameters, the method may include: substituting the raw data into the parameter fitting curve to calculate the initial ambient light parameters; and using the calibration coefficient of the first camera and the initial ambient light parameters to obtain the target ambient light parameters. In this example, by introducing the calibration coefficient, the deviation caused by the differences between different electronic devices is eliminated, further improving the accuracy of the detection results.

[0014] In this example, when there is only one parameter fitting curve, the raw data is substituted into the parameter fitting curve to calculate the above initial ambient light parameters; or, when the parameter fitting curve includes the above first curve and the second curve, the raw data is substituted into the first curve or the second curve to calculate the above initial ambient light parameters. It should also be understood that when the parameter fitting curve includes three or more fitting curves, the fitting curve corresponding to the raw data is determined and then substituted into the fitting curve to obtain the above initial ambient light parameters, so it will not be repeated.

[0015] In combination with the first aspect, in some implementations of the first aspect, the method further includes: obtaining a first ambient light parameter corresponding to the standard camera at the first illumination, and obtaining a second ambient light parameter corresponding to the first camera at the first illumination, the first ambient light parameter being obtained by using a parameter fitting curve and the bare data collected by the standard camera at the first illumination, and the second ambient light parameter being obtained by using a parameter fitting curve and the bare data collected by the first camera at the first illumination; and determining a calibration coefficient of the first camera using the first ambient light parameter and the second ambient light parameter. In this example, the calibration coefficient is determined based on the difference between the ambient light parameters (not bare data) output by the standard camera (reference camera) and the first camera after the parameter fitting curve calculation at the same illumination, rather than determining the calibration coefficient based on the difference in bare data, so that the calibration coefficient can be made more accurate. The reason is that both the first ambient light parameter and the second ambient light parameter are obtained after the parameter fitting curve calculation, which has been improved in accuracy compared to bare data, and the calibration occurs after the parameter fitting curve calculation, rather than calibration at the bare data stage, so the calibration coefficient is determined by selecting the most recent data before calibration, which can make the calibration coefficient more accurate.

[0016] In this example, assuming that there is one parameter fitting curve, the first ambient light parameter is obtained by calculating the parameter fitting curve based on the raw data collected by the standard camera under the first illumination, and the second ambient light parameter is obtained by calculating the parameter fitting curve based on the raw data collected by the first camera under the first illumination; assuming that there are multiple parameter fitting curves, the first ambient light parameter is obtained by first determining the illumination range to which the raw data collected by the standard camera under the first illumination belongs, then selecting the corresponding parameter fitting curve, and then calculating the collected raw data using the selected parameter fitting curve; the second ambient light parameter is obtained by first determining the illumination range to which the raw data collected by the first camera under the first illumination belongs, then selecting the corresponding parameter fitting curve, and then calculating the collected raw data using the selected parameter fitting curve.

[0017] In combination with the first aspect, in certain implementations of the first aspect, the method further includes: determining the weight of each pixel in the second pixel set according to the contribution of each pixel in the second pixel set in the first camera to the overall output data of the first camera, thereby obtaining a weight matrix corresponding to the second pixel set; when using the first camera to collect raw data of ambient light in ambient light mode, it may include: using each pixel in the second pixel set in the first camera to collect first data, the first data includes the data of ambient light collected by each pixel; multiplying the first data by the weight matrix to obtain raw data. In this implementation, the influence of each pixel on the collection result is refined, so for ultra-low illumination intervals and ultra-high pixel intervals, the raw data can still be relatively accurate, and the situation found in actual experiments that the raw data for ultra-low illumination such as 1lux, 3lux and 5lux are equal will not occur.

[0018] In a second aspect, a device for detecting ambient light is provided, the device comprising a unit composed of software and / or hardware for executing any one of the methods of the first aspect.

[0019] In a third aspect, an electronic device is provided, comprising a memory, one or more processors, and a computer program stored in the memory and executable on the processors, wherein when the one or more processors execute the computer program, the electronic device is enabled to implement any one of the methods of the first aspect.

[0020] In a fourth aspect, a chip is provided, comprising a processor, wherein the processor is used to read and execute a computer program stored in a memory, and when the computer program is executed by the processor, the electronic device in which the chip is located can implement any one of the methods of the first aspect.

[0021] Optionally, the chip also includes a memory, and the memory is electrically connected to the processor.

[0022] Optionally, the chip may also include a communication interface.

[0023] According to a fifth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by an electronic device, any one of the methods according to the first aspect can be implemented.

[0024] In a sixth aspect, a computer program product is provided, which includes a computer program, and when the computer program is executed by an electronic device, it can implement any one of the methods of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a schematic diagram of the structure of a traditional under-screen positive ambient light device.

[0026] Figure 2 This is a schematic diagram of the distribution of pixels of a dual-working mode camera according to an embodiment of the present application.

[0027] Figure 3 It is a schematic architecture diagram of a hardware circuit for ambient light detection in an embodiment of the present application.

[0028] Figure 4 It is a schematic flowchart of a method for switching camera working modes in an embodiment of the present application.

[0029] Figure 5 It is a schematic flow chart of a method for detecting ambient light according to an embodiment of the present application.

[0030] Figure 6 3 is a comparison chart of the test results of the ambient light detection solution of the embodiment of the present application and the traditional ambient light detection solution under the same conditions.

[0031] Figure 7 This is a comparison chart of the test results of the ambient light detection solution of the embodiment of the present application and the ambient light detection solutions of other manufacturers under the same conditions.

[0032] Figure 8 Schematic diagram of the illumination simulation intensity according to an embodiment of the present application.

[0033] Fig. 9 It is a schematic diagram comparing the overall machine layout of the present application solution and the traditional solution.

[0034] Fig.10 It is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0035] The scheme of the embodiment of the present application is introduced below with reference to the accompanying drawings.

[0036] In traditional ambient light detection solutions, it is necessary to use a physical ambient light device installed on the electronic device. In the entire electronic device system, the physical ambient light device is an independent electronic component, so it is necessary to consider its layout on the PCB and the impact of this physical device on the overall architecture. From the common layouts mentioned above, it can be seen that no matter where the layout is, there will be various defects, such as light leakage, poor layout, etc. Table 1 gives examples of the layout and defects of several common ambient light devices.

[0037] Table 1

[0038]

[0039] As shown in Table 1, the narrow slit ambient light process has many requirements and is difficult to debug. A light guide column needs to be set up to eject the ambient light, and there is a risk of hole blockage. The ambient light emitted from under the screen is in the non-operable area (AA). Due to the small area of ​​the non-AA area, it is difficult to layout an ambient light device, and because it will be affected by the screen light, it is also necessary to consider the compensation of light leakage. The ambient light under the screen removed by AA requires a complex algorithm to compensate for the influence of light leakage. In addition, setting an ambient light device under the AA area will more or less affect the touch function and display of the screen. The problems with other solutions for setting ambient light devices are not listed one by one.

[0040] Figure 1 This is a schematic diagram of the structure of a traditional under-screen positive ambient light device. Figure 1 As shown in (a), in the under-screen ambient light solution, the ambient light device, that is, the ambient light sensor (ALS), is provided with a light receiving hole, and a middle frame, a light-homogenizing film, and a copper foil (super-clean foam (SCF)) are provided at the light receiving hole. A backplane (BP) for support, a polyimide film (PF) for plastic sealing, a thin film field effect transistor (TFT) of a display driving circuit, and a screen (organic light-emitting diode, OLED) are also provided above the light receiving hole. A corrosion-resistant encapsulation layer (TFE), a touch sensor (TP sensor), a polarizer, an optically clear adhesive (OCA) and a glass cover (CG) are provided above the screen.

[0041] Ambient light is the light that shines into the light receiving hole from above the CG. However, since the screen itself also emits light, Figure 1 As shown in (b), the light emitted by the screen is transmitted in the penel layer (the general term for all layers between CG and SCF), that is, it is transmitted between the CG and SCF copper foil layers. When passing through the light receiving hole, the light leaks to the ALS device, resulting in the ambient light data collected during the ALS period actually consisting of two parts. One part is the actual ambient light vertically irradiated through the CG glass, and the other part is the leakage light emitted by the screen. This results in inaccurate detected ambient light data. If light leakage compensation is performed, that is, to remove the influence of the screen light, other supporting processing methods and processing algorithms need to be set up, which is complicated and inaccurate.

[0042] In addition to the fact that the data collection of the above-mentioned ambient light devices will be inaccurate due to the influence of screen light, all ambient light devices have the problem of affecting the PCB layout and the overall layout. As the requirements for the refinement of the overall appearance of the whole machine become higher and higher, the layout space of the ambient light devices is compressed smaller and smaller, and it is urgent to find an ambient light solution with better collection effect and less impact on the PCB layout and the overall layout.

[0043] In response to the above problems, the present application provides a new solution for detecting ambient light, which replaces the solution of using a physical ambient light device to collect ambient light by multiplexing the photosensitivity function of the camera device. This solution can simplify the entire machine by one physical device, that is, directly remove the ambient light device. In addition, since this solution reuses the camera device, its overall layout position has an inherent advantage in terms of ambient light characteristics, because the camera head will be arranged in the most suitable position of the whole machine to ensure the camera's shooting performance. This solution does not require the setting of an independent light guide column, does not require the addition of a uniform light film, does not require the separate debugging of ink, does not need to be affected by the light leakage of the screen, and does not need to be forced to use an extremely small light receiving hole, so it has the advantages of low cost, high reliability, and good consistency of effect. In addition, there is no impact on the PCB layout and the overall layout.

[0044] Figure 2 Schematic diagram of pixel distribution of a dual working mode camera in an embodiment of the present application. Figure 2 As shown, the camera includes X*Y pixels, all of which can sense images, and the camera also includes X0*Y0 pixels, which can sense images as well as light. In other words, the camera includes X0*Y0 pixels with ALS function, which are evenly distributed among all pixels (X*Y pixels).

[0045] Since the area of ​​the camera is dozens to hundreds of times larger than the traditional light-receiving hole, and the pixels of these ALS functions are evenly distributed among all the pixels of the camera, the data for collecting ambient light will be more accurate.

[0046] When the camera is used to shoot, all pixels will be used to collect images. When the camera is used to detect ambient light, all ALS pixels can be used to detect ambient light. Figure 2 The working modes of the camera shown include camera mode and ambient light mode. In camera mode, images are collected, and in ambient light mode, ambient light data are collected.

[0047] In an example, X is 8192, Y is 6144, X0 is 16, and Y0 is 12, that is, 16*12=192 light-sensitive pixels are evenly distributed in the total pixel size of 8198*6144.

[0048] It should be understood that Figure 2 The camera shown is a new type of camera that has the functions of sensing images and sensing light. It is a new type of camera that has just been developed recently. This application is based on the birth of this new camera, and uses its light sensing function to replace the photosensitivity function of the original ambient light device. It should also be understood that the solution of the embodiment of the present application needs to be based on a camera with a photosensitivity function to be implemented. If there is no such camera, the solution of the embodiment of the present application cannot be used.

[0049] Figure 3 is a schematic diagram of the hardware circuit architecture of an ambient light detection embodiment of the present application. Figure 3 As shown, the processor module, that is, the chip (system on chip, SOC) is used to process various data from the camera and can be used to send some control instructions to control the camera operation. The camera module is used to collect images or ambient light.

[0050] The SOC includes a sensor hub (SH) and an application processor (AP). In camera mode, the camera transmits the collected image data to the AP for processing. In ambient light mode, the camera transmits the collected ambient light data to the SH for processing. The camera interface includes a serial clock interface (SCL) and a serial data interface (SDA). The camera interface SCL is connected to the serial clock interface SCL0 of the SH and the serial clock interface SCL1 of the AP, respectively. The camera interface SDA is connected to the serial data interface SDA0 of the SH and the serial data interface SDA1 of the AP, respectively.

[0051] In camera mode, the camera and AP communicate through their two sets of interfaces connected separately, and in ambient light mode, the camera and SH communicate through their two sets of interfaces connected separately. The path between AP and camera can be regarded as an example of the second communication path below, and the path between SH and camera can be regarded as an example of the first communication path below.

[0052] In electronic devices, interfaces can correspond to two modes: inter-integrated circuit (I2C) and general-purpose input / output (GPIO) interface, and the interfaces of the above two communication paths will work in I2C mode by default, and I2C cannot be set to a high-impedance state (equivalent to blocking signal transmission, or understood as preventing signal reflection). Therefore, in an embodiment of the present application, when one of the paths needs to be set to a high-impedance state, it is necessary to first configure the interface on this path from the default I2C mode to the GPIO mode, and then set the interface in the GPIO mode to a high-impedance state.

[0053] Figure 4 is a schematic flow chart of a method for switching camera working modes in an embodiment of the present application. Figure 4 Each step is described below. Figure 4 It can be considered to be correct Figure 3 A method for switching the working mode of the camera in the circuit shown.

[0054] S401, identifying the working mode of the camera.

[0055] It should be understood that since the camera of an electronic device is in camera mode by default when it is called by a camera application, the camera will work in camera mode as long as it is called by a camera application or other third-party application that needs to take pictures or scan codes, and will work in ambient light mode at other times. In other words, ambient light mode is a working mode other than camera mode and does not require mode judgment.

[0056] In one implementation, when it is detected that the camera is called by the foreground application, the working mode of the camera is determined to be the camera mode; or, when it is detected that the camera is not called by the foreground application, the working mode of the camera is determined to be the ambient light mode. In this implementation, the working mode of the camera is determined based on whether the camera is called by the foreground application, which is convenient and easy to implement.

[0057] S402: When the working mode of the camera is the ambient light mode, the interface of the AP processor is configured from the default I2C interface to the GPIO interface.

[0058] S403: Set the GPIO interface of the AP processor to a high impedance state.

[0059] That is, in the ambient light mode, the communication path between the camera and the AP processor is blocked through steps S402 and S403.

[0060] S404: The camera works in the ambient light mode, collects ambient light data, and transmits the data to the SH processor.

[0061] S405: When the working mode of the camera is the camera mode, the interface of the SH processor is configured from the default I2C interface to the GPIO interface.

[0062] S406: Set the GPIO interface of the SH processor to a high impedance state.

[0063] That is, in the camera mode, the communication path between the camera and the SH processor is blocked through steps S405 and S406.

[0064] S407: The camera works in camera mode, collects image data, and transmits it to the AP processor.

[0065] Figure 4 An example of a switching scheme for working modes is given.

[0066] Figure 5 is a schematic flow chart of a method for detecting ambient light according to an embodiment of the present application. Figure 5 The various steps are introduced as shown. The solution can be applied to electronic devices with cameras such as mobile phones and tablet computers. The solution can be used to optimize electronic devices provided with ambient light devices, so that the ambient light devices on the electronic devices can be directly optimized.

[0067] The electronic device includes a first camera, and the working mode of the first camera includes a camera mode and an ambient light mode. The first camera can be a front camera or a rear camera. The first camera can be Figure 2 or Figure 3 The first camera can be Figure 4 Camera.

[0068] S501: When it is detected that the working mode of the first camera is the ambient light mode, a first communication path between the first camera and the processor is opened.

[0069] The first communication path is used to indicate a communication path corresponding to the ambient light mode.

[0070] The processor here can be Figure 3 In the SOC, the first communication path can be Figure 3 The path between the camera and the SH processor.

[0071] In one implementation, step S501 may include: configuring the interface of the second communication path between the first camera and the processor from the default I2C interface to a GPIO interface, the second communication path being the communication path corresponding to the camera mode; and setting the GPIO interface of the second communication path to a high impedance state. In this implementation, while ensuring that the first communication path is open, other communication paths are blocked, so the second communication path is blocked, and the blocking method is to configure the interface of the second communication path to a GPIO interface and then set it to a high impedance state. The second communication path can be Figure 3 The above configuration of the interface of the second communication path from the default I2C interface to the GPIO interface refers to configuring the interface on the processor side of the second communication path from the default I2C interface to the GPIO interface, and does not include the configuration of the interface on the camera side, because the camera is in working mode regardless of whether it is ambient light mode or camera mode, and its interface needs to be used, so the interface of the camera will not be set to a high-impedance state. Similarly, the above setting of the GPIO interface of the second communication path to a high-impedance state refers to setting the interface on the processor side of the second communication path to a high-impedance state, and does not set the interface on the camera side to a high-impedance state. Figure 4 Steps S402 and S403 in FIG. 4 can be regarded as an example of this implementation method.

[0072] In another implementation, the method further includes: when it is detected that the working mode of the first camera is the camera mode, the second communication path is turned on, and the interface of the first communication path is configured from the default I2C interface to the GPIO interface; the GPIO interface of the first communication path is set to a high-impedance state. In this implementation, when the working mode of the camera is the camera mode, that is, when the camera is being called by the foreground application, it is equivalent to pausing the ambient light detection function, so the second communication path is used to transmit image data, and the first communication path is blocked. In this implementation, while ensuring that the second communication path is turned on, other communication paths are blocked, so the first communication path is blocked, and the blocking method is to configure the interface of the first communication path to the GPIO interface and then set it to a high-impedance state. The first communication path can be Figure 3The above configuration of the interface of the first communication path from the default I2C interface to the GPIO interface refers to configuring the interface on the processor side of the first communication path from the default I2C interface to the GPIO interface, and does not include the configuration of the interface on the camera side, because the camera is in working mode regardless of whether it is ambient light mode or camera mode, and its interface needs to be used, so the interface of the camera will not be set to a high-impedance state. Similarly, the above setting of the GPIO interface of the first communication path to a high-impedance state refers to setting the interface on the processor side of the second communication path to a high-impedance state, and does not set the interface on the camera side to a high-impedance state. Figure 4 Steps S405 and S406 in can be regarded as an example of this implementation method.

[0073] In one implementation, the first camera includes a first pixel set, the camera mode corresponds to the first pixel set, the first pixel set includes a second pixel set, the ambient light mode corresponds to the second pixel set, the pixels in the second pixel set are used to sense images and light, the other pixels in the first pixel set except the second pixel set are used to sense images, and the pixels in the second pixel set are evenly distributed in the first pixel set. In this implementation, the function and distribution requirements of the pixels of the first camera are given, and the pixels that can sense light refer to the pixels with ALS function, and these pixels are evenly distributed in all the pixels of the camera, and these pixels have two sensing capabilities, which are used to sense images in the camera mode and to sense light in the ambient light mode. Figure 2 The X*Y pixel points in can be regarded as an example of the first pixel point set, and the X0*Y0 pixel points can be regarded as an example of the second pixel point set.

[0074] S502: Collect raw data of ambient light using the first camera in ambient light mode.

[0075] The raw data is used to represent the initial data of the ambient light collected by the first camera.

[0076] When the camera is illuminated by external light, the pixels of the ALS function of the camera will sense the light, and the camera will directly output raw data, that is, rawdata.

[0077] It should be understood that the process of converting the sensed light into raw data inside the camera is not the focus of the embodiments of the present application. This is developed by the camera manufacturer. The embodiments of the present application only need to be able to obtain these raw data.

[0078] It should be understood that these raw data may be data without physical meaning, so some processing is needed to obtain the real parameters of the ambient light, that is, to obtain the illumination of the ambient light.

[0079] In one implementation, the data collected by all ALS pixels in the camera can be preprocessed to obtain the above-mentioned raw data. The preprocessing includes constructing the data collected by all ALS pixels in the camera into an initial data set, and then multiplying the initial data set by a weight matrix to obtain the above-mentioned raw data. The weight matrix is ​​determined by evaluating the contribution of each ALS pixel to photosensitivity among all ALS pixels after performing a lighting test on the camera. It can be understood that this implementation is mainly aimed at the problem that different illuminations cannot be distinguished in the ultra-low illumination range, that is, the problem that the camera cannot accurately perceive the illumination below 5lux in Table 2 below. After the above-mentioned preprocessing is performed by introducing the weight matrix, this part can also be accurately perceived. The relevant content will be explained again below and will not be repeated here.

[0080] S503: Send the raw data to the processor using the first communication path.

[0081] After the raw data are collected, the raw data may be sent to the processor via the first communication path, so as to facilitate subsequent processing by the processor.

[0082] S504: Process the raw data using a processor to obtain target ambient light parameters.

[0083] After receiving the raw data, the processor can perform some processing to obtain the target ambient light parameters, that is, the ambient light illumination corresponding to the raw data.

[0084] The mapping relationship curve (mathematical expression, equation, calculation formula) between the raw data and the actual ambient light parameters can be obtained by performing a test under known illumination conditions and then performing curve fitting. After the curve is fitted, any raw data collected can be substituted into the fitted curve to calculate the actual illumination corresponding to the raw data.

[0085] In one implementation, the raw data of the camera can be collected under different illuminations, and the average of the raw data under the same illumination point is taken as the independent variable, and the target illumination LUX is used as the variable for curve fitting. In this implementation, it is equivalent to processing the raw data to a certain extent, eliminating the differences between different light sources under the same illumination.

[0086] Here, different light sources mainly refer to different color temperatures. In one example, different light sources may include cold white light, white light, and yellow light. In another example, different light sources may include A light (standard illuminant A, light emitted by a complete radiator at 2856K), C light (standard illuminant C, average daylight with a correlated color temperature of approximately 6774K, and light color similar to daylight in a cloudy sky) and D light (standard illuminant D65, daylight with a correlated color temperature of approximately 6504K). However, it should be understood that different light sources in other combinations may also be used, and there is no limitation. For example, different light sources may also include daylight, lamplight, and moonlight. For another example, different light sources may also include standard illuminant B, direct sunlight with a correlated color temperature of approximately 4874K. However, it should be understood that the more types of different light sources are included, the more accurate it is after taking the average as an independent variable. It should also be understood that when selecting different light sources, it is also necessary to select in combination with the use scenarios of the electronic device. For example, when the electronic device is a mobile phone, due to its portability, there are many use scenarios, but for electronic devices such as laptops that are mainly used indoors, the consideration of outdoor direct sunlight can be weakened. That is to say, when taking the average value of the bare data corresponding to different light sources at the same illumination point, the method of first screening and then averaging can be adopted. According to the usage scenarios of the electronic device, only the bare data under the light sources of the commonly used scenarios of the electronic device can be selected to take the average value.

[0087] In one implementation, step S503 may include: substituting the raw data into a parameter fitting curve to calculate the target ambient light parameters, where the parameter fitting curve is obtained by fitting the ambient light data collected under multiple known illuminances (lux) with multiple known illuminances. In this implementation, the ambient light parameters are calculated with the help of the parameter fitting curve.

[0088] Table 2 is a set of test data of an embodiment of the present application, which is performed under the default gain and exposure time conditions. Table 2 is obtained by collecting data under three light sources: A light, C light and D light. The point lux in Table 2 can be understood as a known illuminance, and the illuminance meter report value can be understood as the average value of the lux at the same point under different light sources. Rawdata is the bare data corresponding to each point lux, which is obtained by averaging the bare data collected under different light sources for each point lux. The calibrated lux report value can be understood as the value obtained after substituting rawdata into the fitting curve, which can be understood here as the target ambient light parameter or initial ambient light parameter mentioned below. The accuracy after calibration is the ratio between the calibrated lux report value and the illuminance meter report value.

[0089] The parameter fitting curve used in Table 2 is LUX = (10.238*rawdata-1327.8)*calibration coefficient, where the calibration coefficient is determined based on the numerical difference between the current camera and the standard camera. It should be understood that there is no limitation on the coefficient of the parameter fitting curve, which is obtained by fitting the test data in Table 2, that is, the parameter fitting curve is obtained by fitting the rawdata and the illuminance meter value, and then each rawdata can be re-substituted into the parameter fitting curve to obtain the calibrated lux value. Or it can be understood that the LUX in the parameter fitting curve is the calibrated lux value.

[0090] Table 2

[0091]

[0092] As can be seen from Table 2, although the fitting accuracy is relatively high for most lux points, the accuracy in the low illumination range is low. For example, the accuracy after calibration at 30lux and 40lux is higher than 30%. When the lux of the point is lower than 5lux, the accuracy after calibration uses the absolute error. Although the accuracy is within the acceptable range of the human eye, the absolute error is large. As can be seen from Table 2, the rawdata below 5lux is unchanged, resulting in the unchanged lux value after calibration. It can be understood that the lower limit of the perceived light of this camera is 3lux, and the illumination below 3lux is recognized as 3lux.

[0093] In practical applications, the range requirement for accuracy after calibration can be determined based on the comfort level of the human eye. For example, the accuracy range can be required to be within ±30%, that is, [-30%, +30%].

[0094] In order to further improve the accuracy, the problem of inaccurate perception below 5 lux in Table 2 is solved by setting a weight matrix for preprocessing.

[0095] In one implementation, the method further includes: determining the weight of each pixel in the second pixel set according to the contribution of each pixel in the second pixel set in the first camera to the overall output data of the first camera, thereby obtaining a weight matrix corresponding to the second pixel set; when using the first camera to collect raw data of ambient light in ambient light mode, it may include: using each pixel in the second pixel set in the first camera to collect first data, the first data includes the data of ambient light collected by each pixel, and multiplying the first data with the weight matrix to obtain the raw data. In this implementation, the influence of each pixel on the collection result is refined, so for ultra-low illumination ranges and ultra-high pixel ranges, the raw data can still be relatively accurate, and the situation where the raw data of 1lux, 3lux and 5lux in Table 2 are equal (all 138.06) will not occur. After experimental testing, after using the above implementation method to introduce the weight matrix to obtain the raw data, the raw data of 1lux, 3lux and 5lux in Table 2 are 16.4617, 16.7128 and 16.8567 respectively. The change trend of the raw data is more in line with the actual illumination change trend.

[0096] Figure 8 Schematic diagram of the illumination simulation intensity of the embodiment of the present application. Figure 8 As shown in (a), it can be seen that under the same light intensity, the photosensitivity results at different pixel points are different. The horizontal axis is the horizontal coordinate from the center point, and the vertical axis is the vertical coordinate from the center point. The distribution of pixel points is not uniformly distributed in a circular ring with the center point as the center, but may be evenly distributed in rows and columns in a square or rectangle, such as Figure 2 As shown in , it is evenly distributed in a rectangular shape. Figure 8 As shown in (b), a bar chart of the photosensitivity data at different diameters is obtained by taking the distance center point as the center of the circle. It can be seen that the contribution does not strictly increase linearly with increasing distance.

[0097] based on Figure 8 It can be seen that the above implementation method of constructing a weight matrix based on evaluating the contribution of each pixel to the output is more accurate.

[0098] It should also be noted that in addition to the above-mentioned implementation method to determine the weight based on the contribution of each pixel to the photosensitivity result, the weights of other pixels can also be set based on the distance from the center point, but this method of setting weights is more suitable for traditional ambient light devices, but not very suitable for the camera of this application. Because the light-receiving hole of the traditional ambient light device is very small, the distance between all photosensitizing points and the center point is not too far, and the closer the photosensitizing point is to the center, the more accurate it is. However, the photosensitivity in this application uses a camera, which has a relatively large area and is relatively uniform, so there is no such thing as a more important center point. Therefore, if the method of setting weights based on the center point is still used, the weight matrix will inevitably be inaccurate, but the accuracy is still improved compared to the case where the weight matrix is ​​not considered.

[0099] In order to further improve the accuracy, the curve can be fitted in sections, that is, the curve can be fitted in sections according to the different characteristics of different illumination intervals.

[0100] In one example, the parameter fitting curve may include a first curve and a second curve, the first curve corresponds to a first illumination interval, the second curve corresponds to a second illumination interval, and the maximum illumination in the first illumination interval is less than or equal to the minimum illumination in the second illumination interval; the above-mentioned substituting the bare data into the parameter fitting curve to calculate the target ambient light parameters includes: when it is determined that the bare data corresponds to the first illumination interval, substituting the ambient light data into the first curve to calculate the target ambient light parameters; or, when it is determined that the bare data corresponds to the second illumination interval, substituting the ambient light data into the second curve to calculate the target ambient light parameters. In this example, according to the different characteristics of different illumination intervals, multiple fitting curves are set for each interval, which can make the fitting curve more accurate and the calculation result more accurate.

[0101] It can be understood that in this example, the parameter fitting curve is not a curve close to a straight line, but a curve with a high curvature. Therefore, the inflection point of the curve (the place with the highest curvature) can be determined to divide the two illumination intervals with the illumination corresponding thereto as the boundary, and then the two different illumination intervals are respectively fitted with curves to obtain two fitting curves. It should also be understood that based on such processing logic, the full illumination interval can also be divided into three or more fine illumination intervals, and a curve is fitted for each interval.

[0102] In one example, the first illumination interval is less than or equal to 600 lux, and the first curve is represented by LUX=1.6466*bare data-218.7; the second illumination interval is greater than 600 lux, and the second curve is represented by LUX=10.238*bare data-1327.8. It should be understood that the 600 lux here is determined by observing and drawing the curve based on the actual test data in Table 2 above, and other values ​​can also be selected. According to the first curve and the second curve provided in this example, the data shown in Table 3 were obtained through experiments. The illuminance meter values ​​in Table 3 can refer to the relevant introduction in Table 2. The bare data in Table 3 can be regarded as the rawdata in Table 2, that is, the initial data collected by the camera. The target ambient light parameters are the ambient light parameters output by the electronic device. The accuracy is obtained based on the difference between the illuminance meter value and the target ambient light parameter. The accuracy of the point position 5lux and below, that is, the illuminance meter value 4.93 and below in Table 3, is expressed by absolute difference. When the point position is above 5lux, the accuracy is expressed by error, that is, the absolute difference between the target ambient light parameter and the illuminance meter value in the illuminance meter value. The LUX in the fitting curve formula in Table 3 corresponds to the target ambient light parameter.

[0103] Table 3

[0104]

[0105] It can be seen from Table 3 that the target ambient light parameters below 5 lux are no longer fixed, but closer to the actual value (illuminance meter value), and the accuracy of 30 lux (illuminance meter value 29.58) is within ±30%. All the accuracies in Table 3 are within ±30%.

[0106] It should be noted that the collected raw data may be a value without physical meaning, but the corresponding illumination interval can be roughly estimated, so in the above example, the illumination interval corresponding to the raw data can be determined. However, in actual applications, the numerical intervals of the raw data corresponding to the two illumination intervals can also be directly determined. When determining the illumination interval corresponding to the raw data, the corresponding illumination interval can be determined by determining the numerical interval of the raw data in which the raw data is located.

[0107] In another example, when the raw data is substituted into the parameter fitting curve to calculate the target ambient light parameters, it may include: substituting the raw data into the parameter fitting curve to calculate the initial ambient light parameters; using the calibration coefficient of the first camera and the initial ambient light parameters to obtain the target ambient light parameters. In this example, by introducing the calibration coefficient, the deviation caused by the differences between different electronic devices is eliminated, and the accuracy of the detection results is further improved.

[0108] In this example, when there is only one parameter fitting curve, the raw data is substituted into the parameter fitting curve to calculate the above initial ambient light parameters; or, when the parameter fitting curve includes the above first curve and the second curve, the raw data is substituted into the first curve or the second curve to calculate the above initial ambient light parameters. It should also be understood that when the parameter fitting curve includes three or more fitting curves, the fitting curve corresponding to the raw data is determined and then substituted into the fitting curve to obtain the above initial ambient light parameters, so it will not be repeated.

[0109] In another example, the method further includes: obtaining a first ambient light parameter corresponding to the standard camera at the first illumination, and obtaining a second ambient light parameter corresponding to the first camera at the first illumination, the first ambient light parameter being obtained by using a parameter fitting curve and the bare data collected by the standard camera at the first illumination, and the second ambient light parameter being obtained by using a parameter fitting curve and the bare data collected by the first camera at the first illumination; and determining a calibration coefficient of the first camera using the first ambient light parameter and the second ambient light parameter. In this example, the calibration coefficient is determined based on the difference between the ambient light parameters (not bare data) output by the standard camera (reference camera) and the first camera after the parameter fitting curve calculation under the same illumination, rather than determining the calibration coefficient based on the difference in bare data, so that the calibration coefficient can be made more accurate. The reason is that both the first ambient light parameter and the second ambient light parameter are obtained after the parameter fitting curve calculation, which has been improved in accuracy compared to bare data, and the calibration occurs after the parameter fitting curve calculation, rather than calibration at the bare data stage, so the calibration coefficient is determined by selecting the most recent data before calibration, so that the calibration coefficient can be made more accurate.

[0110] In this example, assuming that there is one parameter fitting curve, the first ambient light parameter is obtained by calculating the parameter fitting curve based on the raw data collected by the standard camera under the first illumination, and the second ambient light parameter is obtained by calculating the parameter fitting curve based on the raw data collected by the first camera under the first illumination; assuming that there are multiple parameter fitting curves, the first ambient light parameter is obtained by first determining the illumination range to which the raw data collected by the standard camera under the first illumination belongs, then selecting the corresponding parameter fitting curve, and then calculating the collected raw data using the selected parameter fitting curve; the second ambient light parameter is obtained by first determining the illumination range to which the raw data collected by the first camera under the first illumination belongs, then selecting the corresponding parameter fitting curve, and then calculating the collected raw data using the selected parameter fitting curve.

[0111] Combining the assumptions of actual values, let's explain. Assume that the first illumination is 100 lux, the raw data collected by the standard camera is 213, the raw data collected by the first camera is 212, and there is one parameter fitting curve. The first ambient light parameter calculated by the parameter fitting curve is 96, and the second ambient light parameter is 94. It can be determined that the calibration coefficient is 94 / 96, and the standard coefficient is 0.98. Assume that the first illumination is 100 lux, the raw data collected by the standard camera is 213, and the raw data collected by the first camera is 212. There are two parameter fitting curves, namely curve #1 and curve #2. It is determined that the raw data collected by the standard camera corresponds to the illumination interval of curve #1, and the first ambient light parameter calculated by curve #1 is 98, and it is determined that the raw data collected by the first camera corresponds to curve #1, and the second ambient light parameter calculated by curve #1 is 93. It can be determined that the calibration coefficient is 93 / 98, and the standard coefficient is 0.95. It should also be understood that in this hypothetical example, the calibration coefficient can also be 96 / 94 and 98 / 93. When the calibration coefficient is used subsequently, the only difference is whether to multiply or divide the calibration coefficient based on the initial ambient light parameter. This hypothetical example is for the convenience of understanding the method for determining the calibration coefficient in the embodiments of the present application, and there is no limitation on the specific value.

[0112] The following is a comparison of the results of the method for determining the calibration coefficient in the traditional solution and the method for determining the calibration coefficient in the present application in combination with Table 4 and Table 5.

[0113] Table 4

[0114]

[0115] Table 4 is a calibration scheme for traditional physical ambient light devices. It can be seen that the calibration coefficient is determined by the ratio of the raw data output by the ambient light device and the raw data of the standard ambient light device. However, since the calibration is substituted into the fitting curve for calculation, the accuracy of the final ambient light parameters is reduced, which can be understood as the limited calibration effect. In addition, since the raw data and the final ambient light parameters are not in a very good linear relationship, determining the calibration coefficient directly based on the raw data will result in a high accuracy for the selected raw data for calibration, but when other raw data are calibrated according to this calibration coefficient, the accuracy cannot be guaranteed.

[0116] The gold machine in Table 4 can be understood as a standard machine, that is, a standard electronic device, and the ambient light device in the gold machine is a standard ambient light device. The machine to be tested is an electronic device to be tested, and the machine to be tested includes the ambient light device to be tested. For the illumination point of 2500lux, the raw data output by the standard ambient light device in the gold machine is 400. Assuming that the conversion formula is LUX = 10.238*raw data-1327.8, then the lux value before calibration can be obtained = 10.238*400-1327.8 = 2767, and the accuracy before calibration is 10.68. Based on the fact that the gold machine does not need calibration, it is determined that the lux after calibration is 2767, and the accuracy after calibration is still 10.68%. For the machine to be tested, at the illumination point of 2500lux, the raw data output by the ambient light device to be tested in the machine to be tested is 420. Substituting it into the above conversion formula, the lux reported value before calibration is 2972, and the accuracy before calibration is 18.80%. The calibration coefficient is determined to be 400 / 420 (the bare data of the gold machine at this illumination point / the bare data of the machine to be tested) = 0.95. The lux reported value after calibration = 10.238*420*0.95-1327.8 = 2767. The accuracy after calibration is 10.68%, which is the same as the accuracy of the gold machine at this point. However, for the machine to be tested, at the illumination point of 30lux, the raw data output by the ambient light device to be tested in the machine to be tested is 133. Substituting it into the above conversion formula, the lux value before calibration is 33, the accuracy before calibration is 10%, the calibration coefficient is 400 / 420=0.95, the lux value after calibration = 10.238*133*0.95-1327.8=-34, and the accuracy after calibration is -213%. The accuracy after calibration is reduced, that is, the error becomes larger. The reason is that the calibration coefficient determined based on the raw data cannot adapt to the calculation of the subsequent parameter fitting curve, resulting in the calibration coefficient being valid only for the selected illumination point used to determine the calibration coefficient, but for other illumination points, it cannot be guaranteed that the accuracy will be improved after calibration.

[0117] In view of the above problems, the calibration scheme adopted by the present application is to calibrate based on the parameters output by the fitted dotted line, and output the target ambient light parameters after calibration. Table 5 is a scheme for calibrating the camera under the scheme of the embodiment of the present application.

[0118] Table 5

[0119]

[0120] As can be seen from Table 5, the calibration coefficient is determined by the ratio of the initial ambient light parameters obtained by calculating the parameter fitting curve using the raw data output by the camera and the initial ambient light parameters obtained by calculating the same parameter fitting curve using the raw data output by the standard camera. It can be understood that the traditional solution is to calibrate first and then enter the conversion formula, while the solution of the present application is to first substitute the fitting curve and then calibrate on the output value. The solution of the present application is no longer affected by subsequent calculations during calibration, so the calibration is more accurate. Because it can be considered that there is a good linear relationship between the initial ambient light parameters and the target ambient light parameters.

[0121] The gold machine in Table 5 can be understood as a standard machine, that is, a standard electronic device, and the camera in the gold machine is a standard camera (an example of the above-mentioned standard camera). The machine to be tested is the electronic device to be tested, and the machine to be tested includes the camera to be tested. For the illumination point of 2500lux, the raw data output by the standard camera in the gold machine is 400. Assuming that the fitting curve formula uses LUX=10.238*raw data-1327.8, then the lux value before calibration can be obtained = 10.238*400-1327.8=2767, and the accuracy before calibration is 10.68. Based on the fact that the gold machine does not need calibration, it is determined that the lux after calibration is 2767, and the accuracy after calibration is still 10.68%. For the machine to be tested, at the illumination point of 2500lux, the raw data output by the camera to be tested in the machine to be tested is 420. Substituting it into the above fitting curve formula, the lux value before calibration is 2972, and the accuracy before calibration is 18.80%. The calibration coefficient is determined to be 2767 / 2972 (the bare data of the gold machine at this illumination point / the bare data of the machine to be tested) = 0.93, and the lux value after calibration = 2972*0.93 = 2767, and the accuracy after calibration is 10.68%, which is the same as the accuracy of the gold machine at this point. At the illumination point of 30lux, the raw data output by the camera to be tested in the machine to be tested is 133. Substituting it into the above fitting curve formula, the lux value before calibration is 33, and the accuracy before calibration is 10%. The calibration coefficient is 0.93, and the lux value after calibration = 33*0.93 = 30.69, and the accuracy after calibration is 2%. The accuracy after calibration is improved, that is, the error is reduced. The reason is that the calibration coefficient determined based on the ambient light parameters output by the fitting curve has a good linear relationship between the values ​​before and after calibration. The calibration coefficient can be adapted to all other illumination points, thereby ensuring that the accuracy after calibration will be improved.

[0122] Figure 5The scheme shown mainly reuses the ambient light sensing function in the camera that has both image sensing and ambient light sensing functions, so that the camera can work in the ambient light mode to collect raw data, and obtain the target ambient light parameters after processing the raw data. Since the camera has natural advantages in area and layout position compared to traditional ambient light devices, and is not affected by occlusion when sensing light, the light receiving area is larger, and there is no need to set up various supporting devices of traditional ambient light devices such as light receiving holes and light receiving columns, and there is no need to perform complex calculations such as screen light compensation for traditional ambient light devices. In addition, this scheme directly allows at least one camera in the electronic device to work in both camera mode and ambient light mode, which is equivalent to superimposing the ambient light detection function on other functional devices, so that the ambient light sensing device and its supporting processing circuit can be directly removed from the electronic device, avoiding the influence of traditional ambient light devices on PCB layout, overall layout, and overall appearance.

[0123] It should be noted that in the scheme of the present application, it is implemented based on a camera with two functions. If it is a traditional camera that can only perceive images, the scheme of the embodiment of the present application cannot be implemented. Although some manufacturers have tried to directly use traditional cameras to collect images, and then determine the ambient light after image analysis, this has resulted in the camera having to run in the background all the time, and the image analysis algorithm is very complex, and the processor resources are also very large, resulting in the need for the background to always collect images, perform image analysis operations, and determine ambient light, which is bound to lead to the use of other applications, which may cause jamming, as well as excessive power consumption, and greater damage to the life of electronic equipment. Therefore, in the scheme of the present application, this improved scheme is abandoned, and instead a camera with two functions, namely, the image perception function and the light perception function, is used to implement the scheme of the present application using its light perception function.

[0124] Figure 6 This is a comparison chart of the test results of the ambient light detection scheme of the embodiment of the present application and the traditional ambient light detection scheme under the same conditions. For example, in the same test environment, the electronic device of the embodiment of the present application is used to collect the ambient light parameters of the final output of the electronic device under different illuminations, and the ambient light parameters are plotted in combination with the data output by the camera. Figure 6 Curve B in FIG. 1 and the electronic device using the traditional physical ambient light device collects the ambient light parameters of the electronic device under different illuminations, and draws the final output of the electronic device in combination with the data output during the physical ambient light. Figure 6 Curve A in . Figure 6The horizontal axis is rawdata, and the vertical axis is the target ambient light parameter. Curve A is a test curve obtained based on a physical ambient light device in a traditional ambient light detection scheme, and curve B is a test curve obtained based on a camera with a photosensitivity function in the ambient light detection scheme of this application. It can be seen that the two curves almost overlap, which fully demonstrates that the effect achieved by the scheme of this application is sufficient to match the effect of the traditional ambient light detection scheme, so directly removing the physical ambient light device can still use the scheme of the embodiment of this application to detect relatively accurate ambient light. In addition, curve C and curve D correspond to +30% accuracy and -30% accuracy respectively, that is, as long as curve B is between curve C and curve D, the accuracy of the scheme can be guaranteed to meet the requirements.

[0125] Figure 7 This is a comparison chart of the test results of the ambient light detection solution of the embodiment of the present application and the ambient light detection solutions of other manufacturers under the same conditions. Figure 7 (a) shows a comparison chart of the test results of this application solution and manufacturer A under the same light environment C. Figure 7 (b) shows a comparison chart of the test results of this application solution and manufacturer A under the same light environment D. Figure 7 (c) shows a comparison chart of the test results of the present application and that of manufacturer A under the same light environment A. It can be seen that under different light environments, the test results of the present application are good compared with the test results of the same physical environment light device. Figure 7 (d) shows a comparison chart of the test results of the present application and manufacturer S under the same C light environment. Figure 7 (e) shows a comparison chart of the test results of the present application and manufacturer S under the same D light environment. Figure 7 (f) shows a comparison chart of the test results of the present application and that of manufacturer S under the same light environment A. It can be seen that under different light environments, the test results of the present application are good compared with the test results of the same physical environment light device. Figure 7 It can also be seen from (a) and (d), (b) and (e), (c) and (f) that under the same lighting environment, the solution of the embodiment of the present application can achieve equivalent test results compared with different physical environment light devices.

[0126] Fig. 9 It is a schematic diagram comparing the overall machine layout of the present application solution and the traditional solution. Fig. 9 (a) shows the overall layout of a traditional electronic device. The top of the electronic device includes a very small light receiving hole, which is smaller than the hole of the speaker. Below the light receiving hole is the ambient light device. The front camera on the screen can only be used for shooting (taking pictures, recording videos or scanning codes, etc.). However, it should be understood that Fig. 9 The rear camera of the traditional electronic device shown in (a) can also only be used for taking pictures. Fig. 9 The overall layout of the electronic device of the embodiment of the present application is shown in (b). There is no light receiving hole or ambient light device anywhere on the electronic device. The front camera of the electronic device can be used for both shooting and detecting ambient light. However, it should be understood that in addition to setting the dual-mode camera (a camera with both image perception and light perception functions) as the front camera, it can also be set as a rear camera. In other words, the above-mentioned first camera in the electronic device of the embodiment of the present application can also be a rear camera.

[0127] It should also be understood that Fig. 9 The speaker holes shown in (a) and (b) are for the purpose of distinguishing the light receiving holes from other openings. In fact, the speaker holes may not be set at the top (the top of the housing), but may also be set at the top of the screen in the same direction as the screen. Fig. 9 The light receiving hole shown in (a) is also located at the top as an example. In fact, it may also be located at other positions, which will not be listed one by one. Fig. 9 Mainly for illustration, the solution of the embodiment of the present application attaches ambient light detection to the camera for execution, thereby eliminating independent ambient light devices and supporting accessories and processing circuits from the entire device.

[0128] The above mainly introduces the method of the embodiment of the present application in conjunction with the accompanying drawings. It should be understood that although the steps in the flowcharts involved in the above embodiments are shown in sequence, these steps are not necessarily performed in sequence in the order shown in the figure. Unless clearly stated in this article, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with other steps or at least a part of the steps or stages in other steps. The device of the embodiment of the present application is introduced below in conjunction with the accompanying drawings.

[0129] Fig.10 Schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. Fig.10As shown, the electronic device 900 may include a processor 910, an external memory interface 920, an internal memory 921, a universal serial bus (USB) interface 930, a charging management module 940, a power management module 941, a battery 942, an antenna 1, an antenna 2, a mobile communication module 950, a wireless communication module 960, a sensor module 980, a camera 993, a display screen 994, etc. Among them, the sensor module 980 may include a pressure sensor 980A, a touch sensor 980K, etc.

[0130] It should be noted that the electronic device 900 does not include an ambient light sensor, that is, the sensor module 980 does not include an ambient light sensor.

[0131] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 900. In other embodiments of the present application, the electronic device 900 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0132] For example, Fig.10 The processor 910 shown may include one or more processing units, for example, the processor 910 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0133] The controller may be the nerve center and command center of the electronic device 900. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0134] The processor 910 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 910 is a cache memory. The memory may store instructions or data that the processor 910 has just used or cyclically used. If the processor 910 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 910, and thus improves the efficiency of the system.

[0135] In some embodiments, the processor 910 may include one or more interfaces. The interface 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, etc.

[0136] In some embodiments, the I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). The processor 910 may include multiple groups of I2C buses. The processor 910 may be coupled to the touch sensor 980K, the charger, the flash, the camera 993, etc. through different I2C bus interfaces. For example, the processor 910 may be coupled to the touch sensor 980K through the I2C interface, so that the processor 910 communicates with the touch sensor 980K through the I2C bus interface to realize the touch function of the electronic device 900.

[0137] In some embodiments, the UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. The UART interface is generally used to connect the processor 910 and the wireless communication module 960. For example, the processor 910 communicates with the Bluetooth module in the wireless communication module 960 through the UART interface to implement the Bluetooth function.

[0138] In some embodiments, the MIPI interface can be used to connect the processor 910 with peripheral devices such as the display screen 994 and the camera 993. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. The processor 910 and the camera 993 communicate through the CSI interface to realize the shooting function of the electronic device 900. The processor 910 and the display screen 994 communicate through the DSI interface to realize the display function of the electronic device 900.

[0139] In some embodiments, the GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. The GPIO interface can be used to connect the processor 910 with the camera 993, the display 994, the wireless communication module 960, the sensor module 980, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0140] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 900. In other embodiments of the present application, the electronic device 900 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0141] In the embodiments of the present application, the interface for communication between the processor 910 and the camera 993 is mainly configured as an I2C interface by default, and can be configured as a GPIO interface to switch the working mode and communication path of the camera.

[0142] The electronic device 900 implements the display function through a GPU, a display screen 994, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 994 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 910 may include one or more GPUs, which execute program instructions to generate or change display information.

[0143] The display screen 994 is used to display images, videos, etc. The display screen 994 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), Mini-LED, Micro-Led, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 900 may include 1 or N display screens 994, where N is a positive integer greater than 1.

[0144] The electronic device 900 can realize the shooting function through an ISP, a camera 993, a video codec, a GPU, a display screen 994, and an application processor.

[0145] ISP is used to process the data fed back by camera 993. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 993.

[0146] The camera 993 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted 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 RGB, YUV or other format. In some embodiments, the electronic device 900 may include 1 or N cameras 993, where N is a positive integer greater than 1.

[0147] The internal memory 921 can be used to store computer executable program codes, and the executable program codes include instructions. The processor 910 executes various functional applications and data processing of the electronic device 900 by running the instructions stored in the internal memory 921. The internal memory 921 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 900 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 921 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0148] The pressure sensor 980A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 980A can be set on the display screen 994. There are many types of pressure sensors 980A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 980A, the capacitance between the electrodes changes. The electronic device 900 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 994, the electronic device 900 detects the touch operation intensity according to the pressure sensor 980A. The electronic device 900 can also calculate the touch position according to the detection signal of the pressure sensor 980A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example, when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0149] The touch sensor 980K is also called a "touch panel". The touch sensor 980K can be set on the display screen 994, and the touch sensor 980K and the display screen 994 form a touch screen, also called a "touch screen". The touch sensor 980K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 994. In other embodiments, the touch sensor 980K can also be set on the surface of the electronic device 900, which is different from the position of the display screen 994.

[0150] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0151] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0152] The embodiment of the present application also provides an electronic device, which includes: one or more processors, a memory, and a computer program stored in the memory and executable on the one or more processors, wherein the one or more processors execute the computer program so that the electronic device can implement the steps in any of the above methods. The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by the electronic device, the steps in each of the above method embodiments can be implemented.

[0153] Computer-readable media may include at least: any entity or device capable of carrying computer program codes to a camera / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk, or an optical disk. In some jurisdictions, based on legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0154] The present application embodiment provides a computer program product, which includes a computer program, and when the computer program is executed by an electronic device, the steps in the above-mentioned method embodiments can be implemented. The computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form.

[0155] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0156] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0157] In the embodiments provided in the present application, it should be understood that the disclosed devices / equipment and methods can be implemented in other ways. For example, the device / equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0158] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0159] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0160] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0161] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0162] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0163] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for detecting ambient light, applied to electronic equipment, It is characterized in that The electronic device includes a first camera, the working mode of the first camera includes a camera mode and an ambient light mode, and the method includes: When it is detected that the working mode of the first camera is the ambient light mode, a first communication path between the first camera and the processor is opened, and other communication paths except the first communication path are blocked; the first communication path is used to indicate a communication path corresponding to the ambient light mode; Using the first camera to collect raw data of ambient light in an ambient light mode, the raw data is used to represent initial data of the ambient light collected by the first camera; sending the raw data to the processor using the first communication path; When it is determined that the bare data corresponds to the first illumination interval, the bare data is substituted into the first curve to calculate the target ambient light parameter; or, When it is determined that the bare data corresponds to the second illumination interval, the bare data is substituted into the second curve to calculate the target ambient light parameter; the first curve is a parameter fitting curve corresponding to the first illumination interval, the second curve is a parameter fitting curve corresponding to the second illumination interval, the maximum illumination in the first illumination interval is less than or equal to the minimum illumination in the second illumination interval; the dividing point between the first illumination interval and the second illumination interval is determined according to the inflection point of the parameter fitting curve corresponding to the full illumination interval; the parameter fitting curve is obtained by fitting the ambient light data collected under multiple known illuminations lux with the multiple known illuminations; When substituting the raw data into the first curve or the second curve, the method further includes: Substituting the raw data into the first curve or the second curve to calculate and obtain initial ambient light parameters; The target ambient light parameter is obtained by using the calibration coefficient of the first camera and the initial ambient light parameter.

2. The method according to claim 1, It is characterized in that When it is detected that the working mode of the first camera is the ambient light mode, opening the first communication path between the first camera and the processor and blocking other communication paths except the first communication path include: configuring the interface of the second communication path between the first camera and the processor from a default integrated circuit I2C interface to a general purpose input and output GPIO interface, the second communication path being the communication path corresponding to the camera mode; The GPIO interface of the second communication path is set to a high impedance state.

3. The method according to claim 2, It is characterized in that The method further comprises: When it is detected that the working mode of the first camera is the camera mode, the second communication path is enabled, and the interface of the first communication path is configured from the default I2C interface to the GPIO interface; The GPIO interface of the first communication path is set to a high impedance state.

4. The method according to any one of claims 1 to 3, It is characterized in that The first camera includes a first pixel set, the camera mode corresponds to the first pixel set, the first pixel set includes a second pixel set, the ambient light mode corresponds to the second pixel set, the pixels in the second pixel set are used to perceive images and light, the other pixels in the first pixel set except the second pixel set are used to perceive images, and the pixels in the second pixel set are evenly distributed in the first pixel set.

5. The method according to any one of claims 1 to 3, It is characterized in that The method further comprises: Acquire a first ambient light parameter corresponding to a standard camera under a first illumination, and acquire a second ambient light parameter corresponding to the first camera under the first illumination; the first ambient light parameter is obtained by using a parameter fitting curve and bare data collected by the standard camera under the first illumination, and the second ambient light parameter is obtained by using a parameter fitting curve and bare data collected by the first camera under the first illumination; A calibration coefficient of the first camera is determined using the first ambient light parameter and the second ambient light parameter.

6. The method according to claim 4, It is characterized in that The method further comprises: Determine the weight of each pixel in the second pixel set according to the contribution of each pixel in the second pixel set in the first camera to the overall output data of the first camera, so as to obtain a weight matrix corresponding to the second pixel set; The collecting raw data of ambient light by using the first camera in the ambient light mode includes: Using each pixel in the second pixel set in the first camera to collect first data, the first data includes data of ambient light collected by each pixel; The raw data is obtained by multiplying the first data by the weight matrix.

7. An electronic device comprising a memory, one or more processors, and a computer program stored in the memory and executable on the processors, It is characterized in that When the one or more processors execute the computer program, the electronic device implements the method according to any one of claims 1 to 6.

8. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by an electronic device, the method according to any one of claims 1 to 6 is implemented.

9. A chip comprising a processor for reading and executing a computer program stored in a memory, It is characterized in that When the computer program is executed by the processor, the electronic device where the chip is located implements the method according to any one of claims 1 to 6.

10. A computer program product, the computer program product comprising a computer program, It is characterized in that When the computer program is executed by an electronic device, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Ambient light detection method and terminal

    CN113923422A

  • TOF sensing module and electronic equipment

    CN116359945A