Proximity detection methods, electronic devices and computer-readable storage media
Patent Information
- Application Number
- CN202411034622.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2044-07-30
AI Technical Summary
然而,TOF摄像头发射的红外光反射回电子设备会对接近光传感器造成干扰,导致上报的接近光状态信息(接近状态或远离状态,即接近检测结果)不准确,从而造成电子设备无法准确进入或解除防误触模式
Smart Images

Figure CN120768976B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to a proximity detection method, electronic device, and computer-readable storage medium. Background Technology
[0002] Currently, electronic devices are equipped with proximity sensors to detect whether an object is approaching. In scenarios involving calls or displaying the lock screen, the electronic device can determine whether to enter anti-mistouch mode based on the proximity sensor's detection result. Typically, when the proximity sensor detects an approaching object, the electronic device will enter anti-mistouch mode, such as turning off the screen, thus preventing accidental screen operations due to user touches.
[0003] With the development of electronic devices, facial recognition is widely used for identity authentication. Time-of-flight (TOF) images are unaffected by most ambient light conditions, making them suitable for unlocking devices. For example, a TOF camera can be used for facial recognition on the lock screen. However, the infrared light emitted by the TOF camera reflects back to the electronic device, interfering with the proximity sensor and causing inaccurate reporting of proximity status information (approaching or receding, i.e., proximity detection result). This can prevent the electronic device from accurately entering or deactivating the anti-mistouch mode. Therefore, the anti-mistouch function in lock screen facial recognition scenarios needs optimization. Summary of the Invention
[0004] To address the aforementioned technical problems, this application provides a proximity detection method, an electronic device, and a computer-readable storage medium. In this method, under TOF infrared interference scenarios, the proximity light parameters when the infrared interference flag is not set are filtered to avoid interference from TOF infrared light on the proximity light (or proximity light sensor), thereby enabling accurate reporting of proximity light status information.
[0005] In a first aspect, embodiments of this application provide a proximity detection method. This method is applied in an electronic device, which includes a proximity light sensor and a time-of-flight (TOF) sensor, wherein the TOF sensor is activated. The method includes: within a first detection period, the electronic device calculates a first proximity light parameter; the electronic device determines that the value of a target flag bit within the first detection period is a first value; wherein the first value indicates that the proximity detection result may not be interfered with by infrared light emitted by a non-proximity light sensor; the electronic device performs filtering processing on the first proximity light parameter and a predetermined number of second proximity light parameters consecutively preceding the first detection period to obtain a target proximity light parameter corresponding to the first detection period; the electronic device determines the proximity detection result corresponding to the first detection period based on the target proximity light parameter and a first threshold value. In this way, in TOF infrared interference scenarios, the proximity light parameters when the infrared interference flag is set are not used. Instead, the proximity light parameters when the infrared interference flag is not set are filtered to obtain the target proximity light parameters, i.e., proximity light parameters that do not interfere with the proximity light. Using these parameters, accurate proximity light status information can be obtained, thus avoiding interference from TOF infrared light and enabling accurate reporting of proximity light status information. This allows for the normal implementation of the anti-mistouch function in lock screen face recognition scenarios. Furthermore, this method is based on the proximity sensor itself, eliminating the need for additional hardware I / O and saving on hardware I / O costs.
[0006] For example, the first value is 0.
[0007] For example, the target flag is the infrared interference flag in the register of the proximity light sensor.
[0008] For example, the detection period is close to the pulse period of the optical sensor.
[0009] According to the first aspect, the electronic device performs median filtering on the first and second proximity light parameters to obtain filtered proximity light parameters; the electronic device then performs mean filtering on the filtered proximity light parameters corresponding to the first detection cycle and on the third proximity light parameters that are consecutively processed by a second preset number of parameters before the first detection cycle to obtain target proximity light parameters corresponding to the first detection cycle; wherein, the third proximity light parameters are proximity light parameters obtained after median filtering. In this way, median filtering can further remove proximity light parameters that are interfered with by infrared light in the environment, and mean filtering on the filtered proximity light parameters can make the proximity light parameters smoother, further reducing noise and thus improving the accuracy of proximity light status information.
[0010] According to the first aspect, or any implementation of the first aspect above, during the second detection cycle, the electronic device further determines that the value of the target flag bit is a second value; wherein the second value is used to indicate that the proximity detection result is interfered with by infrared light emitted by a source other than the proximity light sensor; the electronic device determines that it is currently in a first interference scenario; wherein the first interference scenario is used to indicate that the infrared light emitted by the TOF sensor may interfere with the proximity detection result; acquires the target detection result corresponding to the third detection cycle; wherein the third detection cycle is the detection cycle preceding the second detection cycle; and uses the target detection result as the proximity detection result corresponding to the second detection cycle. In this way, the TOF infrared interference scenario can be identified by the proximity light sensor; the proximity light status information reported when the value of the target flag bit is the second value is consistent with the proximity light status information reported in the previous detection cycle, thereby achieving overall consistency of the proximity light status information and ensuring the reliability and stability of the anti-accidental touch function.
[0011] For example, the second value is 1.
[0012] For example, the first interference scenario is a TOF infrared interference scenario.
[0013] According to the first aspect, or any implementation of the first aspect above, the electronic device acquires a target statistical value; wherein, when the value of the target flag bit is the second value in multiple consecutive detection cycles, the target statistical value is the number of multiple detection cycles; when the target statistical value is less than or equal to a second threshold value, the electronic device determines that it is currently in a first interference scenario. Thus, the TOF infrared interference scenario can be identified directly based on the number of consecutive times the target flag bit value is the second value and the second threshold value.
[0014] According to the first aspect, or any implementation of the first aspect above, during the fourth detection cycle, the electronic device determines that the value of the target flag bit is the second value; the electronic device determines that it is currently in the second interference scenario; wherein, the second interference scenario is used to indicate that infrared light in sunlight may interfere with the proximity detection result; the distance state is taken as the proximity detection result corresponding to the fourth detection cycle. In this way, the proximity light sensor can also identify the sunlight infrared interference scenario, thereby accurately distinguishing between the TOF infrared interference scenario and the sunlight infrared interference scenario, so as to report the corresponding proximity light status information under different infrared interference scenarios, improving the user experience; at the same time, under the sunlight infrared interference scenario, the electronic device will not enter the anti-mistouch mode on the lock screen interface, thereby ensuring normal operation of the user on the lock screen interface.
[0015] For example, the second interference scenario is a solar infrared interference scenario.
[0016] According to the first aspect, or any implementation of the first aspect above, the electronic device acquires a target statistical value; wherein, when the value of the target flag bit is the second value for multiple consecutive detection cycles, the target statistical value is the number of multiple detection cycles; when the target statistical value is greater than the second threshold value, the electronic device determines that it is currently in the second interference scenario. In this way, the solar infrared interference scenario can be identified directly based on the number of consecutive times the target flag bit is the second value and the second threshold value.
[0017] According to the first aspect, or any implementation thereof, each detection cycle includes a first time period and a second time period. During the first time period, the infrared lamp of the proximity sensor is turned off. The electronic device performs current integration on the electrical signal of the infrared light received by the proximity sensor during the first time period to obtain a first integrated value. When the first integrated value is greater than a third threshold value, the electronic device sets the value of the target flag bit to a second value. The second value is used to indicate that the proximity detection result is interfered with by infrared light emitted by a non-proximity sensor. When the first integrated value is less than or equal to the third threshold value, the value of the target flag bit is set to the first value. In this way, when the infrared lamp of the proximity sensor is turned off, by comparing the magnitude of the first integrated value and the third threshold value, the value of the obtained target flag bit can accurately reflect the interference of infrared light in the environment on the proximity light.
[0018] According to the first aspect, or any implementation of the first aspect above, the infrared lamp of the proximity sensor is turned on during the second time period. After setting the value of the target flag bit to the first value, the electronic device also performs current integration on the electrical signal of the infrared light received by the proximity sensor during the second time period to obtain a second integrated value. The electronic device calculates the difference between the second integrated value and the first integrated value to obtain the proximity light parameter corresponding to one detection cycle. In this way, the two integrations only calculate the proximity light parameter for the detection cycle when the infrared interference flag bit is not set, and do not calculate the proximity light parameter for the detection cycle when the infrared interference flag bit is set.
[0019] According to the first aspect, or any implementation of the first aspect above, when the electronic device is in a locked state, the image acquired by the TOF sensor is used for face recognition.
[0020] Secondly, embodiments of this application provide an electronic device. The electronic device includes: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when executed by the one or more processors, the electronic device performs the following steps:
[0021] Within the first detection cycle, the electronic device calculates the first proximity light parameter; the electronic device determines the value of the target flag bit within the first detection cycle as a first value; wherein, the first value is used to indicate that the proximity detection result may not be interfered with by infrared light emitted by non-proximity light sensors; the electronic device performs filtering processing on the first proximity light parameter and a preset number of second proximity light parameters preceding the first detection cycle to obtain the target proximity light parameter corresponding to the first detection cycle; the electronic device determines the proximity detection result corresponding to the first detection cycle based on the target proximity light parameter and a first threshold value.
[0022] According to the second aspect, when a computer program is executed by one or more processors, it causes the electronic device to perform the following steps:
[0023] The electronic device performs median filtering on the first proximity light parameter and the second proximity light parameter to obtain the filtered proximity light parameter; the electronic device performs mean filtering on the filtered proximity light parameter corresponding to the first detection cycle and the third proximity light parameter of the second preset number of consecutive steps before the first detection cycle to obtain the target proximity light parameter corresponding to the first detection cycle; wherein, the third proximity light parameter is the proximity light parameter obtained after median filtering.
[0024] According to the second aspect, or any implementation of the second aspect above, when a computer program is executed by one or more processors, the electronic device further performs the following steps:
[0025] During the second detection cycle, the electronic device further determines that the value of the target flag bit is a second value; wherein the second value is used to indicate that the proximity detection result is interfered with by infrared light emitted by a sensor other than the proximity light sensor; the electronic device determines that it is currently in a first interference scenario; wherein the first interference scenario is used to indicate that the infrared light emitted by the TOF sensor may interfere with the proximity detection result; acquires the target detection result corresponding to the third detection cycle; wherein the third detection cycle is the detection cycle preceding the second detection cycle; and uses the target detection result as the proximity detection result corresponding to the second detection cycle.
[0026] According to the second aspect, or any implementation of the second aspect above, when a computer program is executed by one or more processors, the electronic device further performs the following steps:
[0027] The electronic device acquires a target statistical value; wherein, when the value of the target flag bit is the second value in multiple consecutive detection cycles, the target statistical value is the number of multiple detection cycles; when the target statistical value is less than or equal to the second threshold value, the electronic device determines that it is currently in a first interference scenario.
[0028] According to the second aspect, when a computer program is executed by one or more processors, the electronic device further performs the following steps:
[0029] During the fourth detection cycle, the electronic device determines that the value of the target flag bit is the second value; the electronic device determines that it is currently in the second interference scenario; wherein, the second interference scenario is used to indicate that infrared light in sunlight may interfere with the proximity detection result; the distance state is taken as the proximity detection result corresponding to the fourth detection cycle.
[0030] According to the second aspect, when a computer program is executed by one or more processors, it causes the electronic device to perform the following steps:
[0031] The electronic device acquires the target statistics; where the target flag value is the second value in multiple consecutive detection cycles, the target statistics value is the number of multiple detection cycles; when the target statistics value is greater than the second threshold value, the electronic device determines that it is currently in the second interference scenario.
[0032] According to the second aspect, each detection cycle includes a first time period and a second time period, during which the infrared lamp of the proximity sensor is turned off; when the computer program is executed by one or more processors, the electronic device also performs the following steps:
[0033] The electronic device performs current integration on the electrical signal of infrared light received by the proximity light sensor during the first time period to obtain a first integrated value; when the first integrated value is greater than a third threshold value, the electronic device sets the value of the target flag bit to a second value; the second value is used to indicate that the proximity detection result is interfered with by infrared light emitted by a non-proximity light sensor; when the first integrated value is less than or equal to the third threshold value, the value of the target flag bit is set to the first value.
[0034] According to the second aspect, during the second time period, the infrared light of the proximity sensor is turned on; when the computer program is executed by one or more processors, the electronic device also performs the following steps:
[0035] After setting the target flag to the first value, the electronic device performs current integration on the electrical signal of the infrared light received by the proximity light sensor during the second time period to obtain a second integrated value. The electronic device calculates the difference between the second integrated value and the first integrated value to obtain the proximity light parameter corresponding to one detection cycle.
[0036] The second aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the second aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here.
[0037] Thirdly, embodiments of this application provide a computer-readable storage medium. The computer-readable storage medium includes a computer program that, when executed on an electronic device, causes the electronic device to perform the proximity detection method of the first aspect and any one thereof.
[0038] The third aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the third aspect and any implementation thereof can be found in the technical effects of the first aspect and any implementation thereof, as described above, and will not be repeated here. Attached Figure Description
[0039] Figure 1 This is a schematic diagram illustrating an application scenario;
[0040] Figure 2 This is an example of a schematic diagram showing the operation of a TOF camera and a proximity sensor during face recognition.
[0041] Figure 3 The timing diagram of the TOF infrared light pulse and the proximity light pulse is shown as an example.
[0042] Figure 4 A schematic diagram of the hardware structure of an electronic device as an example;
[0043] Figure 5 A schematic diagram of the software structure of an electronic device as an example;
[0044] Figure 6 This is an exemplary schematic diagram of the operation of a proximity light sensor;
[0045] Figure 7 This is a schematic diagram illustrating the working mode of a proximity light sensor;
[0046] Figure 8 This is an example of a statistical chart of proximity light parameters Pdata collected after the proximity light sensor and TOF camera are obscured in a face recognition scenario on a lock screen interface.
[0047] Figure 9 As an example, in Figure 8 Based on the data statistics of the proximity light parameter Pdata corresponding to the infrared interference marker position, the data was filtered out.
[0048] Figure 10 This is an example of a module interaction diagram;
[0049] Figure 11 This is an example of a module interaction diagram;
[0050] Figure 12 This is an example of a module interaction diagram;
[0051] Figure 13 This is a schematic diagram illustrating an application scenario;
[0052] Figure 14 This is a schematic diagram illustrating an application scenario;
[0053] Figure 15 This is a schematic diagram illustrating an application scenario;
[0054] Figure 16 This is a flowchart illustrating a proximity detection method provided in an embodiment of this application. Detailed Implementation
[0055] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0056] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0057] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first target object" and "second target object," etc., are used to distinguish different target objects, not to describe a specific order of target objects.
[0058] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0059] In the description of the embodiments in this application, unless otherwise stated, "multiple" means two or more. For example, multiple processing units means two or more processing units; multiple systems means two or more systems.
[0060] like Figure 1 The diagram shown is an exemplary application scenario. (Refer to...) Figure 1In (a), the electronic device (such as a mobile phone) is in a screen-off state. Screen-off state can mean that the screen of the electronic device is completely off. In the screen-off state, when the user presses the power button 100, refer to... Figure 1 In step (b), the electronic device's screen lights up and displays the lock screen interface 101. In this application, the lock screen interface 101 refers to an interface where the screen is locked but still lit. The lock screen interface 101 may include information such as time, date, and battery level, and may also include a lock screen animation. In this application scenario, if the user has set up face unlock, pressing the power button 100 can trigger the electronic device's face recognition function. At this time, the TOF camera 102 turns on, captures a face image, and sends the face image to the face recognition module, allowing the face recognition module to use a face recognition algorithm to perform face recognition on the user and determine whether the screen can be unlocked. Simultaneously, the proximity sensor 103 is turned on to detect objects (or objects) approaching or moving away from the electronic device, allowing the electronic device to determine whether to enter the anti-mistouch mode based on the detection result of the proximity sensor 103.
[0061] The following is a brief description of the principle of a proximity sensor detecting the approach of an electronic device. Each pulse cycle of the proximity sensor is divided into a first half-pulse cycle and a second half-pulse cycle. First, during the first half-pulse cycle, the proximity sensor operates at a low level. At this time, the infrared lamp in the proximity sensor is off, and the proximity sensor does not emit infrared light. The proximity sensor may receive infrared light from the environment, and it performs a first current integration on the received infrared light. Then, during the second half-pulse cycle, the proximity sensor operates at a high level and emits infrared light. A portion of the emitted infrared light is reflected back to the proximity sensor. The proximity sensor receives this portion of infrared light, as well as the infrared light from the environment, and performs a second current integration on the received infrared light. The proximity sensor obtains the proximity light parameter based on the difference between the two current integrations. A larger proximity light parameter indicates a greater light intensity, more infrared light reflected back to the proximity sensor, and a closer object to the proximity sensor (or electronic device); conversely, a smaller parameter indicates a farther object from the proximity sensor (or electronic device). Therefore, by setting a threshold, the electronic device compares the calculated proximity light parameter with the set threshold. When the proximity light parameter is greater than the set threshold, the electronic device determines the proximity status information (or proximity detection result) as a proximity state, that is, there is currently an object (or target) approaching the electronic device; when the proximity light parameter is less than or equal to the set threshold, the electronic device determines the proximity status information as a distance state, that is, there is currently no object (or target) approaching the electronic device.
[0062] Reference Figure 1 In step (c), when face recognition fails, the electronic device will display message 104, such as "Recognition failed, double-tap the screen to try again." (Continue to refer to...) Figure 1 In step (c), the user's finger approaches the screen to perform a double-tap operation, triggering the electronic device to re-execute the facial recognition process. When the user's finger approaches or touches the screen, in response to the user's action, the electronic device may display an anti-mistouch icon 105, such as... Figure 1 As shown in (d), the electronic device enters the anti-mistouch mode, preventing the user from operating the lock screen (such as double-tapping or swiping), thus affecting the user's ability to unlock the screen using face recognition again.
[0063] Research has found that the reason for the above problems is: (Refer to...) Figure 2 When a user performs facial recognition on a handheld electronic device, the infrared light emitted by the proximity sensor (i.e., proximity light) is reflected back to the proximity sensor via the face and received. The proximity sensor calculates proximity light status information based on the received infrared light and reports it. Simultaneously, the infrared light emitted by the Time-of-Flight (TOF) camera (specifically, the TOF sensor within the TOF camera) is reflected back to the electronic device via the face. A portion of the reflected infrared light is received by the TOF sensor, while the remaining portion enters the proximity sensor. Combined with... Figure 3 There is a possibility of overlap between the TOF infrared light pulse emitted by the TOF camera and the proximity light pulse emitted by the proximity sensor. Furthermore, TOF infrared light typically uses 940nm infrared light, which can interfere with the proximity sensor. Therefore, when the TOF infrared light pulse overlaps with the proximity light pulse, if the reflected TOF infrared light is received by the proximity sensor, the proximity sensor's integration calculation will be affected by the interference from the TOF infrared light. This interference influences the determination of the proximity status information, affecting the reported proximity status. For example, when a user is performing facial recognition and is far from the electronic device, the proximity light parameter calculated by the proximity sensor should be less than or equal to a set threshold, and the proximity detection result should be a distance. However, due to the interference from the TOF infrared light, the proximity light parameter calculated by the proximity sensor may increase, potentially exceeding the set threshold, causing the proximity sensor to determine a proximity status.
[0064] In addition, from Figure 3As can be seen, there are instances where the TOF infrared light pulse and the proximity light pulse do not overlap. In this case, the proximity light sensor integrates the proximity light, and the resulting proximity light parameters are not affected by the TOF infrared light. Therefore, the proximity light sensor can report a relatively accurate proximity status. Consequently, in a lock screen face recognition scenario, even if the distance between the face and the electronic device screen remains constant, the proximity light sensor may report both proximity and distance, affecting the accidental touch prevention function in this application scenario.
[0065] To address the aforementioned issues, the existing technology assumes the proximity sensor is in a "far away" state by default after the TOF camera is turned on, failing to detect proximity. This causes the anti-accidental touch function to completely fail while the TOF camera is on. Furthermore, this solution requires hardware I / O to synchronize the emission of TOF infrared light and proximity light, increasing hardware costs.
[0066] Based on this, embodiments of this application provide a proximity detection method. The electronic device uses a proximity light sensor to identify TOF infrared interference scenarios. Under TOF infrared interference scenarios, proximity light parameters affected by TOF infrared light interference are filtered out to obtain target proximity light parameters. The proximity detection result is then determined based on these target proximity light parameters. This avoids interference from TOF infrared light on the proximity detection results of the proximity light sensor.
[0067] Figure 4 A schematic diagram of the electronic device 100 is shown. It should be understood that... Figure 4 The electronic device 100 shown is merely an example of an electronic device, and the electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. Figure 4 The various components shown can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.
[0068] Electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.
[0069] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0070] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0071] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0072] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0073] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0074] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0075] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0076] The mobile communication module 150 can provide wireless communication solutions, including 2G / 3G / 4G / 5G, for use on electronic devices 100.
[0077] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc.
[0078] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology.
[0079] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0080] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0081] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.
[0082] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0083] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0084] Camera 193 includes a front-facing camera, which can be a Time-of-Flight (TOF) camera. In this embodiment, the TOF camera includes a TOF sensor. The working principle of a TOF camera is to calculate the distance and depth information of an object by measuring the time of flight of light. Specifically, the TOF camera emits a series of light pulses towards the target object; these light pulses are typically invisible light such as infrared. The light pulses are reflected back from the object's surface and received by the TOF sensor of the TOF camera. By measuring the time difference between the emission and reflection of the light pulses, the TOF sensor can calculate the distance between the object and the camera. Based on the time measurements of multiple light pulses, the TOF camera can generate depth information of the object, thereby constructing a 3D model or depth image.
[0085] The external storage interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external storage interface 120 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.
[0086] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.
[0087] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0088] The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc., which will not be listed here, and this application does not limit them.
[0089] A pressure sensor is used to sense pressure signals and convert them into electrical signals. In some embodiments, the pressure sensor may be located on the display screen 194. There are many types of pressure sensors, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. A capacitive pressure sensor may include at least two parallel plates with conductive material. When force is applied to the pressure sensor, the capacitance between the electrodes changes. The electronic device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to the display screen 194, the electronic device 100 detects the intensity of the touch operation based on the pressure sensor. The electronic device 100 may also calculate the touch position based on the detection signal from the pressure sensor. In some embodiments, touch operations applied to the same touch position but with different touch operation intensities may correspond to different operation commands. For example, when a touch operation with an intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS message is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS message is executed.
[0090] A gyroscope sensor can be used to determine the motion attitude of an electronic device 100. In some embodiments, the gyroscope sensor can determine the angular velocity of the electronic device 100 around three axes (i.e., the x, y, and z axes). The gyroscope sensor can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor detects the angle of the electronic device 100's movement, calculates the distance the lens module needs to compensate based on the angle, and allows the lens to counteract the movement of the electronic device 100 through reverse motion, thus achieving image stabilization. The gyroscope sensor can also be used in navigation and motion-sensing gaming scenarios.
[0091] A distance sensor is used to measure distance. Electronic device 100 can measure distance using infrared or laser. In some embodiments, during a shooting scene, electronic device 100 can utilize the distance sensor to measure distance for rapid focusing.
[0092] The proximity sensor may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The LED may be an infrared LED. The electronic device 100 emits infrared light outward through the LED. The electronic device 100 uses the photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that an object is near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that no object is near the electronic device 100. The electronic device 100 may use the proximity sensor to detect when a user holds the electronic device 100 close to their ear for a phone call, so as to automatically turn off the screen to save power. The proximity sensor can also be used in holster mode and pocket mode for automatic unlocking and screen locking.
[0093] A touch sensor, also known as a "touch panel," can be located on the display screen 194. The touch sensor and display screen 194 together form a touchscreen, also called a "touch screen." The touch sensor detects touch operations applied to or near it. The touch sensor can transmit 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 194. In other embodiments, the touch sensor may also be located on the surface of the electronic device 100, in a different position than the display screen 194.
[0094] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.
[0095] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.
[0096] Figure 5 This is a software structure block diagram of the electronic device 100 according to an embodiment of this application.
[0097] The layered architecture of the electronic device 100 divides the software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android Runtime and system libraries, and the kernel layer.
[0098] The application layer can include a series of application packages.
[0099] like Figure 5 As shown, the application package can include applications such as camera, gallery, lock screen, and Bluetooth. The application package can also include applications such as WLAN, calling, calendar, maps, navigation, music, video, and SMS.
[0100] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0101] like Figure 5 As shown, the application framework layer may include a window manager, content provider, view system, accidental touch prevention mode control module, resource manager, notification manager, etc.
[0102] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0103] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0104] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0105] The accidental touch prevention mode control module is used to control whether the electronic device enters or exits the accidental touch prevention mode. When the electronic device enters the accidental touch prevention mode, user touchscreen operations will not be responded to by the electronic device.
[0106] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0107] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0108] The Android Runtime consists of core libraries and a virtual machine. The Android Runtime is responsible for the scheduling and management of the Android system.
[0109] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0110] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0111] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0112] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0113] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0114] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0115] A 2D graphics engine is a graphics engine for 2D drawing.
[0116] The kernel layer is the layer between hardware and software. It includes at least display drivers, audio drivers, Wi-Fi drivers, and proximity sensor drivers. The hardware includes at least a processor, display screen, Wi-Fi module, and sensors.
[0117] Understandable, Figure 5 The layers in the illustrated software structure and the components contained in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer layers than illustrated, and each layer may include more or fewer components, or combine some components, or split some components, or have different component arrangements; this application does not impose any limitations.
[0118] It is understood that, in order to implement the proximity detection method in the embodiments of this application, the electronic device includes hardware and / or software modules that perform various functions. Based on the algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is implemented in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0119] Before introducing the proximity detection method provided in the embodiments of this application, the working principle of the proximity optical sensor used in the embodiments of this application and the implementation principle of proximity detection will be explained.
[0120] Combination Figures 6-7This section introduces the working principle of a proximity light sensor. A proximity light sensor is a sensor capable of detecting infrared light. When infrared light shines on the proximity light sensor, the photoelectric effect occurs, converting the infrared light signal into an electrical signal. After the proximity light sensor is activated, it integrates the current of the infrared light electrical signal in each pulse cycle. At the end of each pulse cycle, a proximity light parameter Pdata is calculated. Within each pulse cycle, the proximity light sensor has two integration states: First, the proximity light sensor turns off its built-in infrared lamp (VCSEL) for half a pulse cycle. Therefore, during this half-pulse cycle, the infrared light received by the proximity light sensor (infrared light detector) does not include the infrared light from the VCSEL; the proximity light sensor only integrates the current of the infrared light electrical signal from the environment, obtaining an integral value A1. Second, the proximity light sensor turns on the VCSEL for the other half of the pulse cycle. The VCSEL emits infrared light outward through the screen, and the emitted infrared light is reflected by the surface of obstacles. Therefore, within this half-pulse cycle, the infrared light received by the proximity sensor may include not only the infrared light reflected back from the obstacle but also infrared light from the environment. In this embodiment, the infrared light from the environment can be infrared light from sunlight or TOF infrared light emitted by an electronic device. Within this half-pulse cycle, the proximity sensor may also perform current integration on the electrical signal of the reflected VCSEL infrared light to obtain an integral value A2. The closer the proximity sensor is to the obstacle, the more VCSEL infrared light is reflected back to the proximity sensor, and the larger the response value of the infrared light received by the proximity sensor. The larger the response value of the infrared light, the stronger the electrical signal of the infrared light generated by the proximity sensor. Therefore, the closer the proximity sensor is to the obstacle, the more VCSEL infrared light is reflected back to the proximity sensor, and the smaller the response value of the infrared light received by the proximity sensor. The smaller the response value of the infrared light, the weaker the electrical signal of the infrared light generated by the proximity sensor. Therefore, the proximity sensor integrates the electrical signal of the received infrared light using current, resulting in a smaller integrated value A2. After one pulse cycle, the proximity sensor calculates the difference between A2 and A1 to obtain the proximity light parameter Pdata, which is then written into memory. Pdata is larger when the proximity sensor is closer to the object and smaller when it is farther away. In this way, the electronic device can read Pdata and determine the proximity light status information based on its value.
[0121] For example, such as Figure 6As shown in (a), when the proximity sensor's VSCEL is off, the VSCEL does not emit infrared light into the environment. Thus, when the VSCEL is off, the infrared light received by the proximity sensor only includes infrared light from the environment. Figure 6 As shown in (b), when the proximity sensor's VSCEL is activated, the VSCEL emits infrared light into the environment. A portion of this emitted infrared light strikes obstacles, which reflect it back. A portion of this reflected infrared light is then received by the proximity sensor. Additionally, the proximity sensor also receives some infrared light from the environment. Therefore, when the VSCEL is activated, the infrared light received by the proximity sensor includes both ambient infrared light and a portion of the infrared light emitted by the VSCEL reflected back from objects. Figure 7 As shown, the proximity sensor operates periodically, with a duty cycle of 50ms. One duty cycle of the proximity sensor can consist of a pulse cycle, which includes the duration of the proximity sensor operating in a high-level state and the duration of the proximity sensor operating in a low-level state. Figure 7 In the above, the proximity sensor operates for 32µs in both its high-level and low-level states. The high-level state of the proximity sensor corresponds to the above... Figure 6 In diagram (b), the proximity sensor is in the VSCEL-activated state. During the high-level state, the proximity sensor integrates the current of the infrared light emitted by the VSCEL and reflected back from the object, along with the infrared light received from the environment, to obtain an integral value A2. During the low-level state, the proximity sensor integrates the current of the infrared light received from the environment, to obtain an integral value A1. By calculating the difference between A2 and A1, the proximity sensor obtains Pdata corresponding to a single pulse cycle (64µs). The value of Pdata reflects the distance between the electronic device and the object; the closer the electronic device is to the object, the larger Pdata is; the farther the electronic device is from the object, the smaller Pdata is. Therefore, the electronic device can use this Pdata to control whether the anti-accidental touch icon pops up.
[0122] Below, in conjunction with Figures 8-9The implementation principle of proximity detection is introduced below. As mentioned above, the proximity light sensor generates the proximity light parameter Pdata through two integrations: one when the infrared lamp is not emitting, and another when the infrared lamp is emitting. Pdata is the second integrated value minus the first integrated value. During the first integration, the infrared lamp is not emitting, and the proximity light sensor integrates the infrared energy in the environment. Therefore, when the infrared energy in the environment is high, the value obtained from the first integration will be very large. When it exceeds the threshold we set, a flag bit in the proximity light sensor register will be set. We call this flag bit the infrared interference flag bit, which is the target flag bit in this application. Through testing, it was found that when the TOF camera is turned on and interferes with the proximity light integration, the infrared interference flag bit corresponding to one pulse cycle of the proximity light sensor will most likely be set, that is, the value of the target flag bit is the second value, such as 1. There are also cases where the infrared interference flag bit is not set, that is, the value of the target flag bit is the first value, such as 0. In addition, referring to Figure 3 It can be seen that some proximity light pulses overlap with TOF infrared light pulses, but others do not. Therefore, the presence of a TOF camera does not cause the infrared interference flag to remain constantly set, while the infrared light from sunlight interfering with the proximity light integration will cause the infrared interference flag to remain constantly set. Based on this, the setting of the infrared interference flag can be used to identify TOF infrared interference scenarios. Tests revealed that when the TOF camera is off, the proximity light parameter Pdata is around 3000. When the TOF camera is on, the acquired proximity light parameter Pdata shows a large number of values such as... Figure 8 The invalid Pdata shown is comprised of two parts: one part consists of Pdata detected when the infrared interference flag is set, and the other part consists of Pdata detected when some infrared interference flags are not set. Within each detection cycle, Pdata detected when the infrared interference flag is set and Pdata detected when the infrared interference flag is not set can be recorded and marked according to the value of the infrared interference flag. Testing has shown that if the Pdata corresponding to the infrared interference flag being set is filtered out, the following can be obtained: Figure 9 The Pdata data shown is from... Figure 9 It can be seen that sporadic invalid Pdata still exists, meaning Pdata still affected by TOF infrared light interference. This also indicates that even if the infrared interference flag is not set, the corresponding Pdata may still be affected by TOF infrared light interference. Therefore, when it is determined that the infrared interference flag is not set, the proximity light parameters should be further filtered, for example, by using median filtering and mean filtering, to remove all invalid Pdata (Pdata affected by TOF infrared light interference), thereby ensuring the accuracy of the reported proximity light status information and avoiding TOF infrared light interference.
[0123] Based on the above principles, this application provides a proximity detection method. Specifically, the proximity sensor identifies a Time-of-Flight (TOF) infrared interference scene. When the infrared interference flag is not set, the proximity light parameters are filtered to obtain target proximity light parameters unaffected by TOF infrared light interference. Based on these target infrared light parameters, accurate proximity light state information is obtained for accurate reporting of approach or departure status. Furthermore, no hardware I / O is required to synchronize the proximity light pulse and the TOF infrared light pulse, thus saving hardware I / O costs.
[0124] It should be noted that the proximity light parameters corresponding to the infrared interference flag being set are not used in this embodiment. Therefore, only the proximity light parameters corresponding to the infrared interference flag not being set can be calculated, without calculating the proximity light parameters corresponding to the infrared interference flag being set. Thus, the value of the infrared interference flag can be determined in the first half of each detection cycle. When the value of the infrared interference flag indicates that the infrared interference flag is set, the infrared light received in the second half of the cycle will not be integrated. However, when the value of the infrared interference flag indicates that the infrared interference flag is not set, the infrared light received in the second half of the cycle will be integrated to obtain the corresponding proximity light parameters.
[0125] The following uses several specific proximity detection scenarios as examples to explain the proximity detection method provided in the embodiments of this application.
[0126] Scene 1
[0127] In this scenario, the electronic device is in a locked state with the TOF camera activated. Taking one pulse cycle as an example, in the first half of the pulse cycle, the infrared energy in the environment is low and does not exceed the threshold. The proximity light parameter corresponding to this pulse cycle can be calculated based on the integral value of the infrared energy in the first and second half of the cycle. However, considering that the TOF camera is activated, it may still affect the integration result. Therefore, the calculated proximity light parameter is filtered to improve the accuracy of the proximity detection result. In this way, when face recognition fails, the electronic device can respond to the user's double-tap operation and re-attempt face recognition. Alternatively, when face recognition fails, the electronic device can also respond to the user's swipe-up operation, displaying the unlock interface such as pattern, password, or fingerprint, and can execute the unlock function in response to the user's corresponding unlock operation. This avoids the electronic device accidentally entering the anti-mistouch mode and affecting the user's unlocking operation.
[0128] Figure 10 This is a schematic diagram of module interaction provided for an embodiment of this application. (Refer to...) Figure 10 The flow of the proximity detection method provided in this application embodiment specifically includes:
[0129] S1001, The proximity sensor driver determines that the target flag is not set within the current pulse cycle.
[0130] As described above, during the first half of the pulse cycle, the infrared lamp of the proximity sensor is off. The proximity sensor integrates the infrared energy in the environment. When the infrared energy is high, the integrated value is large. When it exceeds a set threshold, the target flag is set to 1, indicating that the target flag is set. At this time, the proximity sensor is interfered with by infrared light in the environment. When the infrared energy is low, the integrated value is small. When it does not exceed the set threshold, the target flag is set to 0, indicating that the target flag is not set. At this time, the proximity sensor may or may not be interfered with by TOF infrared light. Based on this, the proximity sensor driver integrates the infrared energy in the environment during the first half of the current pulse cycle, obtaining an integrated value. The proximity sensor driver compares this integrated value with the set threshold and determines the value of the target flag based on the comparison result. When the proximity sensor driver calculates that the target flag value is 0 in the current pulse cycle, it determines that the target flag is not set in the current pulse cycle.
[0131] Furthermore, in TOF infrared interference scenarios, the infrared interference flag may be set to 1 during certain pulse cycles, indicating that the infrared interference flag may be set. In this embodiment, when the infrared interference flag is set to 1 during a pulse cycle, the proximity sensor driver counts the corresponding pulse cycles and records the count value. For example, the proximity sensor driver can record the count value in a register. When the infrared interference flag is set to 1 for multiple consecutive pulse cycles, the proximity sensor driver accumulates the count value for these multiple consecutive pulse cycles and updates the recorded count value when the count value changes. When the value of the infrared interference flag corresponding to a pulse cycle changes from 1 to 0, the proximity sensor driver interrupts the counting. At this time, to avoid affecting the counting of the pulse cycle corresponding to the next infrared interference flag being set, which could lead to an incorrect determination of the infrared interference scenario, when the infrared interference flag is detected as not set, the proximity sensor resets the count of consecutive pulse cycles in which the infrared interference flag is set to zero, and simultaneously updates the count value recorded in the register to 0. For example, the number of consecutive times the infrared interference flag is set can be cleared only when the value of the infrared interference flag is 0 for the first time after the infrared interference flag has been set consecutively.
[0132] S1002, The proximity sensor driver writes the value of the target flag bit to the target flag bit in the register.
[0133] After the proximity sensor driver calculates the value of the target flag bit, it writes the value of the target flag bit into the target flag bit of the proximity sensor's register. This target flag bit can also be called the infrared interference flag bit. This allows the position of the target flag bit to be recorded.
[0134] S1003. Within the current pulse cycle, the proximity sensor driver calculates the proximity light parameters.
[0135] For example, the current pulse period is divided into a first half pulse period and a second half pulse period. In the first half pulse period, the infrared lamp of the proximity sensor is turned off. The proximity sensor driver performs current integration on the electrical signal of the infrared light received in the first half pulse period to obtain a first integral value. The driver performs current integration on the electrical signal of the infrared light received in the second half pulse period to obtain a second integral value. The proximity sensor driver calculates the difference between the second integral value and the first integral value to obtain the proximity light parameters.
[0136] The proximity light parameters calculated above are the proximity light parameters detected by the proximity light sensor. After filtering, a final proximity light parameter, namely the target proximity light parameter, is obtained. This target proximity light parameter is the proximity light parameter that is not affected by TOF infrared light interference. Then, the proximity light sensor will update the currently detected first proximity light parameter to the target proximity light parameter so that the target proximity light parameter can be used as the input for filtering the proximity light parameter in subsequent pulse cycles.
[0137] S1004 The proximity light sensor driver filters the proximity light parameters to obtain the target proximity light parameters.
[0138] In this embodiment, during each pulse cycle when the value of the infrared interference flag is 0, the proximity sensor driver calculates the proximity light parameters and records the obtained proximity light parameters in the register according to the generation order of the corresponding pulse cycles.
[0139] Within the current pulse cycle, the proximity sensor driver first calculates the proximity light parameters, i.e., the first proximity light parameters, and then retrieves the proximity light parameters corresponding to the previous consecutive pulse cycles from the register, i.e., the second proximity light parameters. The proximity sensor driver performs median filtering on the multiple second and first proximity light parameters to obtain the filtered proximity light parameters corresponding to the current pulse cycle, and records the filtered proximity light parameters in the register (the proximity light parameters calculated within the current pulse cycle are retained to participate in the median filtering of proximity light parameters in subsequent pulse cycles). It should be noted that if the number of proximity light parameters currently calculated by the proximity sensor driver does not reach the number required for median filtering (e.g., five-point median filtering requires five proximity light parameters), the proximity light parameters calculated within the current pulse cycle are used as the filtered proximity light parameters.
[0140] Then, within the current pulse cycle, the proximity sensor driver obtains the filtered proximity light parameters corresponding to the current pulse cycle, and retrieves the filtered proximity light parameters corresponding to the previous multiple pulse cycles from the register, i.e., the third proximity light parameters. The proximity sensor driver performs mean filtering on the multiple third proximity light parameters and the filtered proximity light parameters corresponding to the current pulse cycle to obtain the target proximity light parameters corresponding to the current pulse cycle.
[0141] For example, testing revealed that when the infrared interference flag is not set, there are no consecutive invalid Pdata, or the number of consecutive invalid Pdata is at most two. Therefore, five-point median filtering can be used to filter out the invalid Pdata. Assuming there are two consecutive invalid Pdata (0 and 10000) and three valid Pdata (3000) out of five consecutive Pdata, the specific process of five-point median filtering is as follows: The five Pdata are used as input to the median filtering unit, which sorts them as (0, 3000, 3000, 3000, 10000). The Pdata in the middle position after sorting is output, resulting in 3000, which is a valid Pdata, thus filtering out the invalid Pdata. It should be noted that when there are fewer than five proximity light parameters requiring median filtering, the proximity sensor driver outputs the currently calculated proximity light parameters. When there are five proximity light parameters requiring median filtering, the proximity sensor driver outputs the median of the five proximity light parameters. Subsequently, each time a new proximity light parameter is calculated, the proximity light sensor driver discards the earliest proximity light parameter.
[0142] Next, a mean filter is applied to the multiple filtered proximity light parameters to smooth them out, further reducing noise and improving the accuracy of the proximity light state information. For example, the proximity light sensor driver can receive a maximum of M filtered proximity light parameters. Before the number of filtered proximity light parameters received by the proximity light sensor driver is less than M, the driver calculates the mean of all currently received filtered proximity light parameters to obtain the target proximity light parameter. When the number of filtered proximity light parameters received by the proximity light sensor driver is equal to M, the driver can calculate the mean of the M received filtered proximity light parameters to obtain the target proximity light parameter. Afterward, for each received filtered proximity light parameter, the driver discards the first received filtered proximity light parameter to ensure that the number of received filtered proximity light parameters remains at M. Furthermore, for each received filtered proximity light parameter, the driver can calculate the mean of the M received filtered proximity light parameters, calculate and output the target proximity light parameter. M can be obtained based on historical data, empirical data, or experimental data; this application does not impose any restrictions on this.
[0143] S1005, The proximity sensor driver determines the proximity detection result corresponding to the current pulse cycle based on the target proximity light parameters and the first threshold value.
[0144] For example, when the target proximity light parameter is greater than the first threshold value, the proximity sensor driver determines the proximity detection result corresponding to the current pulse cycle as an approaching state; when the target proximity light parameter is less than or equal to the first threshold value, the proximity sensor driver determines the proximity detection result corresponding to the current pulse cycle as a moving away state.
[0145] S1006, The proximity light sensor driver sends the proximity detection result to the anti-accidental touch mode control module.
[0146] The proximity sensor driver sends the proximity detection results to the anti-accidental touch mode control module to report the proximity light status information.
[0147] S1007, the anti-accidental touch mode control module controls the electronic device to enter or exit the anti-accidental touch mode based on the proximity detection result.
[0148] For example, on the lock screen, when the proximity sensor driver reports a proximity status of "close," the accidental touch prevention mode control module controls the electronic device to enter accidental touch prevention mode. The electronic device will display an accidental touch prevention icon on the lock screen, preventing user operation. Optionally, the accidental touch prevention icon can be forcibly disabled by swiping at a specified location. When the proximity sensor driver reports a distance from the target area, if the electronic device is not currently in accidental touch prevention mode, the accidental touch prevention mode control module will not take any action, the electronic device will not display the accidental touch prevention icon, and the user can operate on the lock screen. When the proximity sensor driver reports a distance from the target area, if the electronic device is currently in accidental touch prevention mode, the accidental touch prevention mode control module controls the electronic device to exit accidental touch prevention mode, the electronic device will disable the accidental touch prevention icon, and the user can operate on the lock screen.
[0149] Scene 2
[0150] In this scenario, the electronic device is in a locked state with the TOF camera activated. Taking one pulse cycle as an example, in the first half of this pulse cycle, the infrared energy in the environment is high, exceeding the threshold. The proximity light parameters calculated based on this are unreliable, so they are not calculated for this pulse cycle. Instead, in this scenario, the current TOF infrared interference scenario is determined by the number of consecutive pulse cycles when the infrared interference flag is 1. The proximity detection result corresponding to the previous pulse cycle is used as the proximity detection result for this pulse cycle, thus ensuring accurate proximity detection even within pulse cycles where the proximity light parameters are unreliable. Therefore, when face recognition fails, the electronic device can respond to the user's double-tap operation and attempt face recognition again. Alternatively, when face recognition fails, the electronic device can also respond to the user's swipe-up operation, displaying the unlock interface (pattern, password, fingerprint, etc.) and executing the corresponding unlock function. This prevents the electronic device from accidentally entering the anti-mistouch mode and affecting the user's unlocking operation.
[0151] Figure 11 This is another schematic diagram of module interaction provided for an embodiment of this application. (Refer to...) Figure 11 The flow of the proximity detection method provided in this application embodiment specifically includes:
[0152] S1101, The proximity sensor driver determines the position of the target marker within the current pulse cycle.
[0153] S1102, The proximity sensor driver writes the value of the target flag bit to the target flag bit in the proximity sensor register.
[0154] S1103, if the number of consecutive times the target marker position is less than or equal to the second threshold value, the proximity sensor driver determines that the current situation is a TOF infrared interference scene.
[0155] When a proximity sensor is subjected to infrared light interference from the environment, the infrared interference flag may be set. Since TOF infrared light does not cause the infrared interference flag to remain set continuously, while sunlight infrared light does, the number of consecutive times the infrared interference flag is set can be used to distinguish between TOF infrared interference scenarios and sunlight infrared interference scenarios. Continuous setting of the infrared interference flag should be understood as the value of the infrared interference flag being 1 for multiple consecutive pulse cycles. Based on this, in one example, the proximity sensor drives the acquisition of target statistics; when the value of the infrared interference flag is 1 for multiple consecutive pulse cycles, the target statistics value is the number of pulse cycles, where "multiple" means at least two. When the value of the infrared interference flag is 0 within a pulse cycle, the target statistics value is 0. Specifically, if the value of the infrared interference flag is 0 in the first pulse cycle and 1 in the second pulse cycle, the target statistics value is updated to 1 in the second pulse cycle. For example, taking a series of pulse cycles including pulse cycle 1, pulse cycle 2, pulse cycle 3, and pulse cycle 4, the proximity sensor driver determines that the infrared interference flag is 0 during pulse cycle 1. The proximity sensor driver does not count during pulse cycle 1, and the target statistical value is 0. The proximity sensor driver determines that the infrared interference flag is 1 during pulse cycle 2. The proximity sensor driver starts counting from pulse cycle 2, obtaining a count value of 1, and records the count value 1 in a register. At this time, the target statistical value is updated to 1. The proximity sensor driver determines that the infrared interference flag is 1 during pulse cycle 3. The proximity sensor driver adds 1 to the count value 1, obtaining a count value 2, and updates the count value 1 in the register with the count value 2. At this time, the target statistical value is updated to 2. Then, if the proximity sensor driver determines that the infrared interference flag is 1 during pulse cycle 4, the proximity sensor driver continues to add 1 to the count value 2, obtaining a count value 3, and updates the count value 2 in the register with the count value 3. At this time, the target statistical value is updated to 3. Additionally, if the proximity sensor driver determines that the infrared interference flag value is 0 within pulse period 4, the proximity sensor driver stops counting and clears the count value 2 in the register. At this time, the target statistics value is updated to 0. Thus, the target statistics value is updated based on the value of the infrared interference flag and the continuity of the pulse period when the infrared interference flag value is 1. When the target statistics value is less than or equal to the second threshold, the proximity sensor driver determines that it is currently in a TOF infrared interference scenario. When the target statistics value is greater than the second threshold, the proximity sensor driver determines that it is currently in a solar infrared interference scenario. Specifically, when the target statistics value is 1, the proximity sensor driver also determines that it is currently in a TOF infrared interference scenario.
[0156] For example, if the target statistics obtained by the proximity sensor driver are N1, and N1 is greater than 0 and less than or equal to the second threshold value, the proximity sensor driver determines that it is currently in a TOF infrared interference scenario. For instance, if the second threshold value is 3, and the proximity sensor driver obtains a target statistics value of 0 in the first pulse cycle, 1 in the second pulse cycle, 2 in the third pulse cycle, and 3 in the fourth pulse cycle, then the proximity sensor driver determines that it is in a TOF infrared interference scenario in the corresponding pulse cycles of the second, third, and fourth pulse cycles. Additionally, if the target statistics obtained by the proximity sensor driver are N2, and N2 is greater than the second threshold value, the proximity sensor driver determines that it is currently in a solar infrared interference scenario. Based on the above example, if the target statistics obtained by the proximity sensor driver in the fifth pulse cycle after the fourth pulse cycle are 4, then the proximity sensor driver determines that it is currently in a solar infrared interference scenario. It should be noted that the second threshold value can be obtained based on test data.
[0157] In another example, when the proximity sensor driver detects that the target flag value is the second value in n out of m consecutive detection cycles, the proximity sensor driver can determine that it is currently in an infrared interference scene, where n is less than m and the n detection cycles are at least partially discontinuous.
[0158] S1104 The proximity sensor driver uses the target detection result corresponding to the previous pulse cycle as the proximity detection result corresponding to the current pulse cycle.
[0159] In the current TOF infrared interference scenario, the proximity sensor driver determines the target marker position. The proximity sensor driver uses the target detection result from the previous pulse cycle as the proximity detection result for the current pulse cycle. For example, if the proximity status information reported in the previous pulse cycle was "close state," then when the infrared interference marker is in position in the current pulse cycle, the proximity sensor driver reports the close state. Since the number of overlaps between the proximity light pulse and the TOF infrared light pulse is relatively small during the entire proximity status detection phase (i.e., fewer pulse cycles corresponding to the infrared interference marker position), the number of times the infrared interference marker is not set is relatively large. Therefore, even during pulse cycles where the infrared interference marker is not set, relatively accurate proximity status information can still be reported. Thus, by reporting the proximity status information from the previous pulse cycle during the pulse cycle when the infrared interference marker is in position, the proximity sensor driver ensures that the proximity status information reported during the pulse cycle when the infrared interference marker is in position is consistent with the proximity status information reported during the pulse cycle when the infrared interference marker is not set, thereby improving the accuracy of the proximity status information reported during the pulse cycle when the infrared interference marker is in position. Optionally, the initial proximity light status information is "away from". For example, when the infrared interference flag is set during the first pulse cycle of the proximity light sensor driver's detection, the proximity light sensor driver reports a "away from" status in the first pulse cycle. Since a pulse cycle is very short, in a TOF infrared interference scenario, a pulse cycle in which the infrared interference flag is not set will quickly appear. At this time, accurate proximity light status information can be calculated, thus allowing accurate proximity light status information to be reported in subsequent pulse cycles when the infrared interference flag is set.
[0160] S1105, the proximity sensor driver sends the proximity detection result to the anti-accidental touch mode control module.
[0161] S1106, The anti-accidental touch mode control module controls the electronic device to enter or exit the anti-accidental touch mode based on the proximity detection result.
[0162] For any parts of this process that are not explained in detail, please refer to the previous text; they will not be repeated here.
[0163] Scene 3
[0164] In this scenario, the electronic device is in a locked state with the TOF camera activated. Taking one pulse cycle as an example, in the first half of this pulse cycle, the infrared energy in the environment is high, exceeding the threshold. The proximity light parameters calculated based on this are unreliable, so they are not calculated for this pulse cycle. Instead, in this scenario, the current situation is determined by the number of consecutive pulse cycles when the infrared interference flag is 1, indicating a solar interference environment. The distance from the target area is used as the detection result for this pulse cycle. Thus, when face recognition fails, the electronic device can respond to the user's double-tap operation and attempt face recognition again. Alternatively, when face recognition fails, the electronic device can also respond to the user's swipe-up operation, displaying the unlock interface (pattern, password, fingerprint, etc.) and executing the corresponding unlock function. This prevents the electronic device from accidentally entering the anti-mistouch mode and affecting the user's unlocking operation.
[0165] Figure 12 This is another schematic diagram of module interaction provided in an embodiment of this application. (Refer to...) Figure 12 The flow of the proximity detection method provided in this application embodiment specifically includes:
[0166] S1501, the proximity light sensor driver determines the position of the target marker within the current pulse cycle.
[0167] S1502, The proximity sensor driver writes the value of the target flag bit to the target flag bit.
[0168] S1503, if the number of consecutive times the target marker position is greater than the second threshold value, the proximity sensor driver determines that the current situation is in a solar infrared interference scenario.
[0169] S1504, The proximity sensor driver uses the distance state as the proximity detection result corresponding to the current pulse period.
[0170] When the infrared interference flag is set consecutively more than the second threshold value, the infrared interference scenario is a solar infrared interference scenario, meaning that the infrared light from sunlight interferes with the proximity sensor. In this case, the proximity sensor driver reports a distance status so that the user can perform normal operations on the lock screen.
[0171] S1505, proximity light sensor driver sends distance status to anti-accidental touch mode control module.
[0172] S1506, the anti-accidental touch mode control module controls the electronic device to turn off the anti-accidental touch mode based on the remote state.
[0173] For any parts of this process that are not explained in detail, please refer to the previous text; they will not be repeated here.
[0174] Based on the above embodiments, this application describes the process of the proximity detection method in conjunction with application scenarios. Specifically... Figure 1 The application scenarios shown are as follows: Figure 13 The diagram illustrates an application scenario using the proximity detection method provided in this embodiment. (Refer to...) Figure 13 In (a), the electronic device (such as a mobile phone) is in a screen-off state. In this screen-off state, when the user presses the power button 100, refer to... Figure 13 In step (b), the electronic device's screen lights up and displays the lock screen interface 101. The TOF camera 102 is activated, capturing the user's facial image and sending it to the facial recognition module. This allows the facial recognition module to use a facial recognition algorithm to identify the user's face and determine if the screen can be unlocked. Simultaneously, the proximity sensor 103 is activated to detect objects approaching or moving away from the electronic device. This allows the electronic device to determine whether to enter the anti-mistouch mode based on the detection results from the proximity sensor 103. In this application scenario, the infrared light emitted by the TOF camera interferes with the proximity sensor. During each pulse cycle of the proximity sensor, the proximity sensor calculates the proximity light parameters and writes the corresponding target flag value to a register. Correspondingly, the proximity sensor driver reads the target flag value from the register. In the first pulse cycle, the target flag value read by the proximity sensor driver is the first value, for example, a value of 1, indicating that the target flag is set. When the proximity sensor driver determines that the number of consecutive times the target flag is set does not exceed a second threshold, it is determined that the current situation is a TOF infrared interference scenario. Subsequently, in this TOF infrared interference scenario, for the case where the target marker is not set, the proximity sensor driver acquires the first proximity light parameter corresponding to the proximity detection result corresponding to the preset detection period, and the second proximity light parameter detected within the current pulse period; wherein, the preset detection period includes four consecutive detection periods before the current pulse period when the target marker is set. The proximity sensor driver filters the first and second proximity light parameters to obtain the target proximity light parameters that are not affected by TOF infrared light interference. Figure 1 In the scenario shown, the target proximity parameter is less than the first threshold. In this case, the proximity sensor driver determines the proximity detection result corresponding to the current pulse cycle as a "far away" state. When the target flag is set, the proximity sensor driver obtains the proximity detection result corresponding to the previous pulse cycle and uses it as the proximity detection result corresponding to the current pulse cycle. Since the proximity detection result is a "far away" state when the target flag is not set, the proximity detection result when the target flag is set is consistent with the proximity detection result when the target flag is not set. Therefore, throughout the entire proximity detection process, the proximity sensor driver always reports a "far away" state. (Refer to...) Figure 13In step (c), when face recognition fails, the electronic device will display message 104, such as "Recognition failed, double-tap the screen to try again." (Continue to refer to...) Figure 13 In step (c), the user's finger approaches the screen to perform a double-tap operation, triggering the electronic device to re-execute the face recognition process. When the user's finger approaches or touches the screen, in response to the user's action, the electronic device will not display the anti-accidental touch icon on the lock screen, but will instead display prompt message 106, such as "Recognizing face." Figure 13 (d) At this point, the user can use the face unlock function again.
[0175] against Figure 1 The application scenarios shown are as follows: Figure 13 The diagram illustrates another application scenario using the proximity detection method provided in this embodiment. Figure 13 The application scenarios shown are different, referring to Figure 13 In (c) and (d), when face recognition fails and the electronic device prompts the user to double-tap the screen to try again, the user can slide the screen (such as swiping up or down) to display other unlock interfaces, such as pattern unlock interface 107, password unlock interface, fingerprint unlock interface, etc., depending on the unlock settings.
[0176] In addition, regarding Figure 1 The application scenarios shown are as follows: Figure 15 The diagram illustrates another application scenario using the proximity detection method provided in this embodiment. Figure 13 The application scenarios shown are different, referring to Figure 15 In (a), when the user presses the power button 100, the electronic device displays an always-on display interface 108, which may include information such as date, time and battery level.
[0177] It should be noted that the above application scenario is implemented when the distance between the user's face and the screen is greater than the threshold set by the proximity sensor. When the distance between the user's face and the screen is less than or equal to the threshold set by the proximity sensor, the proximity sensor can normally report the proximity status using the proximity detection method provided in this embodiment.
[0178] In addition, it should be noted that the proximity detection method provided in this application embodiment is not only applicable to the situation where the face occludes the TOF camera and proximity sensor in the lock screen interface face recognition scenario, but also applicable to the situation where other light-blocking objects (such as hands) occlude the TOF camera and proximity sensor in the lock screen interface face recognition scenario.
[0179] like Figure 16 The diagram shown is a schematic flowchart of a proximity detection method provided in an embodiment of this application. (Refer to...) Figure 16 The flow of the proximity detection method provided in this application embodiment specifically includes:
[0180] S1601. During the first detection cycle, the electronic device calculates the first proximity light parameter.
[0181] S1602. The electronic device determines that the value of the target flag bit in the first detection cycle is the first value.
[0182] The first value indicates that the proximity detection result may not be interfered with by infrared light emitted by non-proximity light sensors.
[0183] S1603. The electronic device filters the first proximity light parameter and a preset number of second proximity light parameters that are consecutively set before the first detection cycle to obtain a target proximity light parameter corresponding to the first detection cycle.
[0184] S1604. The electronic device determines the proximity detection result corresponding to the first detection cycle based on the target proximity light parameters and the first threshold value.
[0185] For example, the electronic device performs median filtering on the first and second proximity light parameters to obtain filtered proximity light parameters; the electronic device then performs mean filtering on the filtered proximity light parameters corresponding to the first detection cycle and the third proximity light parameters consecutively for a second preset number of cycles before the first detection cycle to obtain target proximity light parameters corresponding to the first detection cycle; wherein, the third proximity light parameters are proximity light parameters obtained after median filtering. In this way, median filtering can further remove proximity light parameters interfered with by infrared light in the environment, and mean filtering on the filtered proximity light parameters can make the proximity light parameters smoother, further reducing noise and thus improving the accuracy of proximity light status information.
[0186] For example, during the second detection cycle, the electronic device further determines that the target flag bit is a second value; wherein the second value is used to indicate that the proximity detection result is interfered with by infrared light emitted by a source other than the proximity light sensor; the electronic device determines that it is currently in a first interference scenario; wherein the first interference scenario is used to indicate that the infrared light emitted by the TOF sensor may interfere with the proximity detection result; acquires the target detection result corresponding to the third detection cycle; wherein the third detection cycle is the detection cycle preceding the second detection cycle; and uses the target detection result as the proximity detection result corresponding to the second detection cycle. In this way, the TOF infrared interference scenario can be identified by the proximity light sensor; the proximity light status information reported when the target flag bit is a second value is consistent with the proximity light status information reported in the previous detection cycle, thereby achieving overall consistency of the proximity light status information and ensuring the reliability and stability of the anti-accidental touch function.
[0187] For example, the electronic device acquires a target statistical value; wherein, when the value of the target flag bit is the second value for multiple consecutive detection cycles, the target statistical value is the number of multiple detection cycles; when the target statistical value is less than or equal to a second threshold value, the electronic device determines that it is currently in a first interference scenario. Thus, the TOF infrared interference scenario can be identified directly based on the number of consecutive times the target flag bit value is the second value and the second threshold value.
[0188] For example, during the fourth detection cycle, the electronic device determines that the value of the target flag bit is the second value; the electronic device determines that it is currently in a second interference scenario; wherein, the second interference scenario is used to indicate that infrared light in sunlight may interfere with the proximity detection result; the distance state is taken as the proximity detection result corresponding to the fourth detection cycle. In this way, the proximity light sensor can also identify the sunlight infrared interference scenario, thereby accurately distinguishing between the TOF infrared interference scenario and the sunlight infrared interference scenario, so as to report the corresponding proximity light status information under different infrared interference scenarios, improving the user experience; at the same time, under the sunlight infrared interference scenario, the electronic device will not enter the anti-mistouch mode on the lock screen interface, thereby ensuring normal operation of the user on the lock screen interface.
[0189] For example, the electronic device acquires a target statistical value; wherein, when the value of the target flag bit is the second value for multiple consecutive detection cycles, the target statistical value is the number of multiple detection cycles; when the target statistical value is greater than a second threshold value, the electronic device determines that it is currently in a second interference scenario. In this way, the solar infrared interference scenario can be identified directly based on the number of consecutive times the target flag bit is the second value and the second threshold value.
[0190] For example, each detection cycle includes a first time period and a second time period. During the first time period, the infrared lamp of the proximity sensor is turned off. The electronic device performs current integration on the electrical signal of the infrared light received by the proximity sensor during the first time period to obtain a first integrated value. When the first integrated value is greater than a third threshold value, the electronic device sets the value of the target flag bit to a second value. The second value is used to indicate that the proximity detection result is interfered with by infrared light emitted by non-proximity sensors. When the first integrated value is less than or equal to the third threshold value, the value of the target flag bit is set to the first value. In this way, when the infrared lamp of the proximity sensor is turned off, by comparing the magnitude of the first integrated value and the third threshold value, the value of the obtained target flag bit can accurately reflect the interference of infrared light in the environment on the proximity light.
[0191] For example, during the second time period, the infrared lamp of the proximity sensor is turned on; after setting the target flag bit to a first value, the electronic device also performs current integration on the electrical signal of the infrared light received by the proximity sensor during the second time period to obtain a second integrated value; the electronic device calculates the difference between the second integrated value and the first integrated value to obtain the proximity light parameter corresponding to one detection cycle. In this way, the two integrations only calculate the proximity light parameter for the detection cycle when the infrared interference flag bit is not set, and do not calculate the proximity light parameter for the detection cycle when the infrared interference flag bit is set.
[0192] For example, the detection cycle includes a first time period during which the infrared lamp of the proximity sensor is turned off. The electronic device integrates the electrical signal of the infrared light received in the first time period to obtain a first integrated value. When the first integrated value is greater than a third threshold value, the electronic device determines that the value of the target flag is a second value. When the first integrated value is less than or equal to the third threshold value, the value of the target flag is the first value. In this way, when the infrared lamp of the proximity sensor is turned off, by comparing the first integrated value with the third threshold value, the value of the target flag can accurately reflect the interference of infrared light in the environment on the proximity light.
[0193] For example, the detection period also includes a second time period in which the electronic device is in a locked state, and the images acquired by the TOF sensor are used for face recognition.
[0194] For any parts of this process that are not explained in detail, please refer to the foregoing embodiments, which will not be repeated here.
[0195] This embodiment also provides a computer storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the proximity detection method in the above embodiment.
[0196] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement the proximity detection method in the above embodiment.
[0197] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the proximity detection method in the above method embodiments.
[0198] In this embodiment, the electronic devices (such as mobile phones), computer storage media, computer program products, or chips are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0199] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0200] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0201] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A proximity detection method, characterized in that, The method is applied in an electronic device, which includes a proximity sensor and a time-of-flight (TOF) sensor, wherein the TOF sensor is activated; the electronic device is in a locked state, and the image acquired by the TOF sensor is used for face recognition; the method includes: Within the first detection cycle, the first proximity light parameters are calculated; The value of the target flag bit within the first detection period is determined to be a first value; wherein, the first value is used to indicate that the proximity detection result may not be interfered with by infrared light emitted by a source other than the proximity light sensor; The first proximity light parameter and the second proximity light parameter that are consecutively a first preset number before the first detection cycle are filtered to obtain the target proximity light parameter corresponding to the first detection cycle. Based on the target proximity light parameters and the first threshold value, determine the proximity detection result corresponding to the first detection cycle; The first proximity light parameter and a first preset number of second proximity light parameters preceding the first detection cycle are filtered to obtain the target proximity light parameter corresponding to the first detection cycle, including: The first proximity light parameter and the second proximity light parameter are subjected to median filtering to obtain the filtered proximity light parameter; The filtered proximity light parameters corresponding to the first detection cycle and the third proximity light parameters that are consecutively processed by a second preset number of steps before the first detection cycle are subjected to mean filtering to obtain the target proximity light parameters corresponding to the first detection cycle; wherein, the third proximity light parameters are proximity light parameters obtained by the median filtering process.
2. The method according to claim 1, characterized in that, The method further includes: During the second detection cycle, the value of the target flag is determined to be a second value; wherein, the second value is used to indicate that the proximity detection result is interfered with by infrared light not emitted by the proximity light sensor; The current situation is determined to be a first interference scenario; wherein, the first interference scenario is used to indicate that the infrared light emitted by the TOF sensor may interfere with the proximity detection result; Obtain the target detection result corresponding to the third detection cycle; wherein, the third detection cycle is the detection cycle preceding the second detection cycle; The target detection result is taken as the proximity detection result corresponding to the second detection cycle.
3. The method according to claim 2, characterized in that, The current situation is determined to be the first interference scenario, including: Obtain target statistical values; wherein, when the value of the target flag bit is the second value in multiple consecutive detection cycles, the target statistical value is the number of multiple detection cycles; When the target statistical value is less than or equal to the second threshold value, it is determined that the current situation is the first interference scenario.
4. The method according to claim 1, characterized in that, The method further includes: During the fourth detection cycle, the value of the target flag is determined to be a second value; wherein, the second value is used to indicate that the proximity detection result is interfered with by infrared light not emitted by the proximity light sensor; The current location is determined to be in a second interference scenario; wherein, the second interference scenario is used to indicate that infrared light in sunlight may interfere with the proximity detection results; The distance state is taken as the proximity detection result corresponding to the fourth detection cycle.
5. The method according to claim 4, characterized in that, It has been determined that we are currently in the second interference scenario, including: Obtain target statistical values; wherein, when the value of the target flag bit is the second value in multiple consecutive detection cycles, the target statistical value is the number of multiple detection cycles; When the target statistical value is greater than the second threshold value, it is determined that the current situation is the second interference scenario.
6. The method according to claim 1, characterized in that, Each detection cycle includes a first time period and a second time period, during which the infrared light of the proximity sensor is turned off; The method further includes: The electrical signal of the infrared light received by the proximity sensor during the first time period is integrated by current to obtain a first integral value; When the first integral value is greater than the third threshold value, the value of the target flag is set to the second value; the second value is used to indicate that the proximity detection result is interfered with by infrared light not emitted by the proximity light sensor. When the first integral value is less than or equal to the third threshold value, the value of the target flag is set to the first value.
7. The method according to claim 6, characterized in that, During the second time period, the infrared light of the proximity sensor is turned on; After setting the value of the target flag to the first value, the method further includes: The electrical signal of the infrared light received by the proximity sensor during the second time period is integrated by current to obtain a second integral value; The difference between the second integral value and the first integral value is calculated to obtain the proximity light parameter corresponding to one detection cycle.
8. An electronic device, characterized in that, include: One or more processors; Memory; And one or more computer programs, wherein the one or more computer programs are stored on the memory, and when the computer programs are executed by the one or more processors, cause the electronic device to perform the proximity detection method as described in any one of claims 1-7.
9. A computer-readable storage medium comprising a computer program, characterized in that, When the computer program is run on an electronic device, the electronic device performs the proximity detection method as described in any one of claims 1-7.
Citation Information
Patent Citations
Screen-off control method and device for mobile terminal
CN106791120A
Approach detection method and device, electronic device, storage medium and equipment
CN108983250A
Proximity detection method and electronic equipment
CN116699716A