Face recognition method, electronic device and readable storage medium

By configuring the initial configuration parameters on the TOF sensor and determining the working mode based on the operation results, the face recognition process is optimized, the problem of time-consuming TOF camera mode switching is solved, and the efficiency and user experience of face recognition are significantly improved.

CN116704571BActive Publication Date: 2024-09-24HONOR DEVICE CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202211209219.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-30
Publication Date
2024-09-24
Estimated Expiration
2042-09-30

AI Technical Summary

Technical Problem

The process of switching existing smart terminals from eye-safe mode to face recognition mode on the TOF camera is complicated and time-consuming, resulting in a poor face recognition experience for users.

Method used

After configuring the initial configuration parameters on the TOF sensor, the target working mode is determined based on the operation results, and image data is collected for face recognition in this mode, which optimizes the face recognition process and shortens the time-consuming face recognition.

Benefits of technology

It improves the efficiency of face recognition and reduces the waiting time for face recognition from 140ms to 70ms, improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116704571B
    Figure CN116704571B
Patent Text Reader

Abstract

The present application relates to the field of terminal technology, and provides a face recognition method, an electronic device, and a readable storage medium. The method is applied to an electronic device, and the electronic device includes a TOF sensor and a camera driver module. The method includes: configuring initial configuration parameters for the TOF sensor through a first path, controlling the TOF sensor to operate based on the initial configuration parameters, obtaining operation results from the TOF sensor through a second path, and then determining the target operating mode of the TOF sensor according to the operation results and controlling the TOF sensor to collect image data in the target operating mode and then perform face recognition. Compared with the existing face recognition method, when configuring the initial configuration parameters for the TOF sensor, the present application controls the TOF sensor to operate based on the initial configuration parameters, and then selects the next operating mode of the TOF sensor based on the operation results and performs subsequent face recognition operations, thereby optimizing the face recognition process and shortening the time consumption of face recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of terminal technology, and in particular to a face recognition method, an electronic device and a readable storage medium. Background Art

[0002] At present, most smart terminals are equipped with 3D TOF for face unlocking. 3D TOF face unlocking uses TOF camera imaging, which is specifically a group of infrared light (laser pulses) invisible to the human eye that is emitted outward, reflected after encountering an object, and reflected to the camera. The time difference or phase difference from emission to reflection back to the camera is calculated, and the data is collected to form a set of distance depth data, thereby obtaining a three-dimensional 3D model imaging technology.

[0003] Since TOF images are not affected by most light, applying TOF images to unlocking services can improve security. However, since TOF imaging will be actively illuminated, eye safety must be ensured. Therefore, existing smart terminals will configure the TOF camera to eye safety mode by default after it is powered on. When performing 3D TOF face unlocking, the process of switching the TOF camera from eye safety mode to face recognition mode is relatively complicated and time-consuming, and the user's face recognition experience is not high. Summary of the invention

[0004] The present application provides a face recognition method, an electronic device and a readable storage medium, the purpose of which is to optimize the face recognition process and reduce the waiting time for face recognition.

[0005] In a first aspect, the present application provides a face recognition method, which is applied to an electronic device, wherein the electronic device includes a TOF sensor and a camera driver module, and the method includes: configuring initial configuration parameters for the TOF sensor through a first path, wherein the first path is a first bus connected between the camera driver module and the TOF sensor; controlling the TOF sensor to operate based on the initial configuration parameters; obtaining an operation result from the TOF sensor through a second path, wherein the second path is a second bus connected between the camera driver module and the TOF sensor, wherein the first bus is different from the second bus; determining a target operating mode of the TOF sensor according to the operation result; controlling the TOF sensor to collect image data in the target operating mode; and performing face recognition based on the image data.

[0006] Compared with the existing face recognition technology, the face recognition method provided by the present application is that the TOF sensor collects image data after completing the initialization configuration, that is, completing the initialization configuration of the eye-safe mode, and then checks the device status of the TOF sensor according to the collected image data, and performs mode switching and face recognition based on the inspection results. When configuring the initial configuration parameters for the TOF sensor, the present application controls the TOF sensor to operate based on the initial configuration parameters, and then selects the next working mode of the TOF sensor based on the operating results and performs subsequent face recognition operations, thereby optimizing the face recognition process and shortening the time consumed by face recognition.

[0007] In a possible implementation, the first path is used by the camera driving module to write data to the TOF sensor, and the second path is used by the camera driving module to read data from the TOF sensor.

[0008] In another possible implementation, both the first bus and the second bus are I2C buses.

[0009] In another possible implementation, configuring the initial configuration parameters for the TOF sensor through the first path includes: sending an initialization command to the camera driver module, so that the camera driver module configures the initial configuration parameters for the TOF sensor through the first path based on the initialization command, and the initial configuration parameters are used to control the TOF sensor to operate in an eye-safe mode.

[0010] In another possible implementation, controlling the TOF sensor to operate based on the initial configuration parameters includes: reading a first current value and an exposure value in the initial configuration parameters; controlling the TOF sensor to operate for a preset time period based on the first current value and the exposure value, the first current value being less than a normal operating current value of the TOF sensor.

[0011] In another possible implementation, the TOF sensor includes a transmitter for emitting a light signal, and controlling the TOF sensor to operate for a preset time based on the first current value and the exposure value includes: controlling the transmitter in the TOF sensor to operate for a preset time at a first light intensity based on the first current value and the exposure value.

[0012] In another possible implementation, after controlling the TOF sensor to operate based on the initialization configuration parameters, the method further includes: writing the operating result into a register through the first path, and the register is set in the TOF sensor.

[0013] In another possible implementation, before configuring the initial configuration parameters for the TOF sensor through the first path, the steps include: acquiring sensor parameters corresponding to the TOF sensor; reading an initialization flag of the TOF sensor from the sensor parameters; determining whether the TOF sensor supports an eye-safe mode according to the initialization flag; and when the TOF sensor supports the eye-safe mode, executing the step of configuring the initial configuration parameters for the TOF sensor through the first path.

[0014] In another possible implementation, before obtaining the sensor parameters corresponding to the TOF sensor, the steps include: obtaining the sensor parameters corresponding to the image sensor when the image sensor is powered on; reading a data stream format field in the sensor parameters; determining whether the image sensor is a TOF sensor according to the data stream format field; and if so, executing the step of obtaining the sensor parameters corresponding to the TOF sensor.

[0015] In another possible implementation, acquiring the image data collected by the TOF sensor in the target operating mode includes: acquiring a first frame of image data collected by the TOF sensor in the target operating mode; performing face recognition based on the image data includes: performing face recognition based on the first frame of image data.

[0016] In another possible implementation, performing face recognition based on the first frame image data includes: acquiring a grayscale image and a depth map based on the first frame image data; performing face comparison based on the grayscale image, and performing anti-counterfeiting detection based on the depth map to obtain a face recognition result.

[0017] In another possible implementation, after performing face recognition based on the image data, the method includes: determining whether to perform unlocking according to the face recognition result; if the face recognition result is a successful recognition, performing unlocking; if the face recognition result is a failed recognition, not performing unlocking or displaying an unlocking failure prompt.

[0018] In a second aspect, the present application provides an electronic device, including:

[0019] 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 the one or more computer programs include instructions, which, when executed by the electronic device, enable the electronic device to perform a face recognition method as described in any one of the first aspect or possible implementations of the first aspect.

[0020] In a third aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor executes a face recognition method as described in any one of the first aspect or possible implementations of the first aspect.

[0021] In a fourth aspect, the present application provides a chip, comprising a processor and a data interface, wherein the processor reads instructions stored in a memory through the data interface to execute the face recognition method described in any one of the first aspect or possible implementations of the first aspect.

[0022] Optionally, as a possible implementation, the chip may further include a memory, in which instructions are stored, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to execute the face recognition method described in any one of the first aspect or the possible implementations of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0024] Figure 2 A schematic diagram of the principle of a TOF imaging technology provided in an embodiment of the present application;

[0025] Figure 3 A schematic diagram of a software module architecture provided for an embodiment of the present application;

[0026] Figure 4 A schematic diagram of interaction between software modules provided in an embodiment of the present application;

[0027] Figure 5 A schematic diagram of interaction between another software module provided in an embodiment of the present application;

[0028] Figure 6 A signal interaction diagram provided in an embodiment of the present application;

[0029] Figure 7 A schematic diagram of a scenario provided for an embodiment of the present application;

[0030] Figure 8 Another signal interaction schematic diagram provided for an embodiment of the present application;

[0031] Fig. 9 A schematic diagram of a chip structure provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] The terms "first", "second", "third", etc. in the specification, claims and drawings of this application are used to distinguish different objects rather than to limit a specific order.

[0033] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0034] In order to make the description of the following embodiments clear and concise, a brief introduction to the relevant concepts or technologies is first given:

[0035] Rich Execution Environment (REE), also known as ordinary execution environment or untrusted execution environment, refers to the system operating environment of the mobile terminal, which can run operating systems such as Android, IOS and Linux. REE has good openness and scalability but low security.

[0036] Trusted Execution Environment (TEE), also known as the security side or security zone, is an area that requires authorization to access. TEE is an operating environment in which REE coexists with REE in electronic devices. It is isolated from REE through hardware support, has security capabilities, and can resist software attacks that conventional REE sides are susceptible to. TEE has its own operating space and defines strict protection measures. Therefore, it has a higher security level than REE and can protect assets in TEE, such as data and software, from software attacks and resist specific types of security threats.

[0037] REE+TEE architecture refers to an architecture that provides services for applications through the combination of TEE and REE. In other words, TEE and REE exist together in electronic devices. For example, TEE can implement an operating mechanism isolated from REE through hardware support. TEE has its own operating space, with a higher security level than REE, and can protect assets in TEE (such as data, software, etc.) from software attacks. Only authorized security software can be executed in TEE, and it also protects the confidentiality of the resources and data of the security software. Compared with REE, TEE can better protect the security of data and resources due to its protection mechanisms such as isolation and permission control.

[0038] TA, or trusted application, is an application running in TEE that can provide security services to CA running outside TEE, such as password input, transaction signature generation, face recognition, etc.

[0039] CA, or client application. CA usually refers to an application running in REE. CA can call TA through the client application programming interface (API) and instruct TA to perform corresponding security operations.

[0040] Software Development Kit (SDK): In a broad sense, it refers to a collection of related documents, examples, and tools that assist in the development of a certain type of software.

[0041] RAW Data, or raw data, can be understood as "unprocessed and uncompressed data". In the embodiment of the present application, RAW Data may refer to the raw data that the TOF sensor (TOF camera) converts the captured light source signal into a digital signal. RAW Data also records some metadata generated by the camera shooting.

[0042] Metadata, also known as intermediary data or relay data, is data about data, mainly information describing data properties. In the embodiment of the present application, Metadata can indicate the camera's operating mode, photocurrent value, device operating status of the TOF camera, exposure value, and other information.

[0043] TOF camera (TOF camera module, TOF sensor) can include a transmitter (TX) and a receiver (RX), TX is used to transmit infrared light or laser pulses, and RX is used to receive reflected light and form an image. Since TX can autonomously emit light signals for imaging, TOF images are not affected by most light in the environment. In this way, applying TOF images to unlocking services can improve the security of face recognition.

[0044] Time of Flight (TOF) imaging technology refers to an imaging technology that uses a group of infrared light (or laser pulses) that are invisible to the human eye to be emitted outward, reflected after encountering an object, and reflected to the camera. The time difference or phase difference from emission to reflection back to the camera is calculated, and the data is collected to form a set of distance and depth data, thereby obtaining a three-dimensional 3D model. In other words, TOF imaging technology is based on traditional 2D XY axis imaging, adding depth information from the Z axis direction, and finally generating 3D image information.

[0045] EyeSafe Mode: Eyesafe Mode is a mode in which the TOF Tx operates at a small current (i.e., the first current value described below) and is used to check whether the TOF device is damaged (normal or abnormal).

[0046] FaceID Mode: Face recognition mode, Face ID mode, is a mode in which TOF Tx operates at a normal current (i.e. the normal current value described below) and is used for secure face unlocking and payment.

[0047] Tx OFF Mode: TOF Tx non-luminous mode. When the TOF sensor detects damage (abnormality) of the device, it switches to this mode, and its operating current is 0 (ie, the second current value described below).

[0048] When using TOF imaging technology, it is necessary to project infrared light, laser, etc. onto the human face. For the safety of human eyes, it is necessary to detect the optical power of the light emitted by TX to ensure that it is within the safety range of human eyes and avoid the optical signal emitted by TX from damaging the human eyes.

[0049] The embodiment of the present application provides a face recognition method. During the initialization configuration process of the TOF sensor, the TOF sensor is configured with initial configuration parameters through the first channel, and then the TOF sensor is controlled to run based on the initial configuration parameters. If the TOF sensor can operate normally, it indicates that TX can operate normally and the TOF camera can be used normally to collect images; if the TOF sensor cannot operate normally, it indicates that TX is abnormal and TX can be turned off to avoid the light signal emitted by TX from damaging the human eye. After the TOF sensor runs for a period of time based on the initial configuration parameters, the operation result can be read through the second channel, and then the target operating mode (FaceID mode or Tx OFF mode) of the TOF sensor is determined according to the operation result, and then the image data collected by the TOF sensor in the target operating mode (FaceID mode or Tx OFF mode) is obtained, and finally face recognition is performed based on the image data. Among them, the first channel is a first bus connected between the camera driver module and the TOF sensor, and the second channel is a second bus connected between the camera driver module and the TOF sensor, and the first bus is different from the second bus.

[0050] like Figure 1 As shown, Figure 1An example diagram of the composition of an electronic device provided in the present application, the 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, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a Subscriber Identification Module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

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

[0052] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

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

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

[0055] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

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

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

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

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

[0060] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

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

[0062] The electronic device 100 can realize the shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor. The ISP is used to process data fed back by the camera 193. The camera 193 is used to capture static images or videos. The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0063] The camera 193 may include 1 to N cameras. For example, the electronic device may include 2 front cameras and 4 rear cameras. Among them, the front camera may include a TOF camera. The TOF camera includes TX and RX, TX can be used to transmit light signals (infrared light or laser pulses), and RX can be used to receive imaging. TX can be, for example, an infrared light transmitter. RX can be, for example, a complementary metal oxide semiconductor (CMOS) or a charge coupled device (CCD) image sensor.

[0064] For example, Figure 2 As shown in (a) in FIG. 1 , the light transmitter (Tx) of the TOF camera can continuously send light signals (infrared light or laser pulses) to the target to be measured (for example, the user), and the sensor end (Rx) of the TOF camera receives the light signal returned by the target to be measured, as shown in FIG. Figure 2 As shown in (b) in FIG. 1 , the depth information of the target can be obtained based on the phase difference (delay) between the transmitted and received light signals.

[0065] Among them, Tx and Rx can exchange information through a bus. For example, Rx can send configuration parameters to Tx through a bus (for example, a serial peripheral interface (SPI) bus), and the configuration parameters are used to indicate the address of the register corresponding to Tx and the value of the register. For example, the address of the register corresponding to Tx can be 0x11, and the current value can be stored in the storage space corresponding to 0x11. Tx can operate at a corresponding current value based on the corresponding configuration parameters to emit a light signal of a corresponding light intensity. Rx can obtain corresponding image data based on the reflected light of the light signal of the corresponding intensity emitted by the transmitter.

[0066] It should be noted that when Tx works at different current values, it can emit light signals of different light intensities. For example, when Tx works at a first current value, it can emit a light signal of a first light intensity. When Tx works at a normal current value, it can emit a light signal of a second light intensity. The normal current value is greater than the first current value, and the second light intensity is greater than the first light intensity. The image data acquired by Rx based on the reflected light of light signals of different intensities is also different. For example, when Tx works at a first current value and emits a light signal of a first light intensity, Rx acquires first image data within a corresponding exposure time; when Tx works at a normal current value and emits a light signal of a second light intensity, Rx acquires second image data within a corresponding exposure time; the second image data is different from the first image data.

[0067] When Tx operates at the corresponding current value, it can determine its own working state, and the working state (that is, the operating result) can be normal or abnormal. Rx can request the working state of Tx from Tx through the I2C bus, and Tx can feedback its own working state (for example, normal or abnormal) to Rx through the I2C bus, so that Rx can obtain the working state of Tx. Rx can package the working state of Tx and its own working state and the working modes of both in a first data packet (for example, Metadata). Rx can also package Metadata and image data obtained based on reflected light in a second data packet (for example, RAW Data).

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

[0069] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oled, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0070] A series of graphical user interfaces (GUIs) can be displayed on the display screen 194 of the electronic device 100, and these GUIs are the main screens of the electronic device 100. Generally speaking, the size of the display screen 194 of the electronic device 100 is fixed, and only limited controls can be displayed on the display screen 194 of the electronic device 100. A control is a GUI element, which is a software component included in an application that controls all data processed by the application and interactive operations on these data. Users can interact with the controls through direct manipulation to read or edit relevant information of the application. Generally speaking, controls can include visual interface elements such as icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc. For example, in an embodiment of the present application, the display screen 194 can display virtual buttons (one-key arrangement, start arrangement, scene arrangement).

[0071] In addition, an operating system runs on the above components, such as Hongmeng system, iOS operating system, Android open source operating system, Windows operating system, etc. Applications can be installed and run on the operating system.

[0072] The methods in the following embodiments can all be implemented in the electronic device 100 having the above hardware structure.

[0073] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present invention takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.

[0074] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through interfaces. In some embodiments, the Android system may include an application layer, an application framework layer, an Android runtime (Android runtime) and a system library, a hardware abstraction layer (HAL) and a kernel layer. It should be noted that the embodiments of the present application are illustrated by taking the Android system as an example. In other operating systems (such as Hongmeng system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those of the embodiments of the present application, the solutions of the present application can also be implemented.

[0075] Among them, the application layer can include a series of application packages.

[0076] like Figure 3As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, lock screen application, setting application, etc. Of course, the application layer may also include other application packages, such as payment application, shopping application, banking application, chat application or financial application, etc., which are not limited in this application.

[0077] Among them, the setting application has the function of recording a face, and the recorded face is used for face unlocking. The lock screen application has the function of unlocking in response to the user's unlocking operation (for example, pressing the power button). The lock screen application can perform unlocking processes such as face unlocking, fingerprint unlocking, and password unlocking. The embodiment of this application mainly takes face unlocking as an example for explanation.

[0078] The application framework layer provides an application programming interface (API) and a programming framework for the application programs in the application layer. The application framework layer includes some predefined functions. For example, it may include an activity manager, a window manager, a content provider, a view system, a resource manager, a notification manager, a camera service, and a face recognition service, etc., and the embodiments of the present application do not impose any restrictions on this.

[0079] The system library can include multiple functional modules. For example: surface manager, media library, OpenGL ES, SGL, etc. The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. OpenGL ES is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc. SGL is a drawing engine for 2D drawing.

[0080] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0081] The HAL layer is an encapsulation of the Linux kernel driver, providing an interface to the upper layer and shielding the implementation details of the low-level hardware.

[0082] The HAL layer may include Wi-Fi HAL, audio HAL, camera HAL, and face recognition control module (Face CA).

[0083] Among them, the camera HAL is the core software framework of the Camera, which can include sensor nodes and image front end (IFE) nodes. The sensor node and IFE node are components (nodes) in the image data and control instruction transmission path (also called transmission pipeline) created by the camera HAL.

[0084] The face recognition control module is the core software framework / application of face recognition.

[0085] Face Trusted Application (Face TA): an application for face recognition running in a TEE environment. In the embodiment of the present application, Face TA is referred to as a face recognition TA.

[0086] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.

[0087] Among them, the camera driver is the driver layer of the Camera device, which is mainly responsible for the interaction with the hardware.

[0088] The hardware layer includes display, TOF camera, IFE module and secure memory (Secure Buffer), etc.

[0089] Among them, secure memory refers to memory with security protection function, which can be used to store RAW Data collected by TOF camera.

[0090] A TOF sensor, also known as a TOF camera, may include a transmitter (TX) and a receiver (RX), wherein TX is used to transmit infrared light or laser pulses, and RX is used to receive reflected light and form an image.

[0091] IFE module (IFE-Lite): can be called an image pre-processing module, which can be used to forward image data without processing the image data during the forwarding process.

[0092] The following describes the software modules and the interactions between the modules involved in the face recognition method provided in the embodiment of the present application. Figure 4As shown, the lock screen application in the application layer can interact with the face recognition SDK, and the face recognition SDK can interact with the face recognition service in the framework layer by calling the preset application programming interface (Application Programming Interface, API) interface, and the face recognition service can interact with the face recognition control module in the HAL layer, and the face recognition control module can interact with the camera HAL in the HAL layer through the camera service in the framework layer, or the face recognition control module can directly interact with the camera HAL in the HAL layer. The camera HAL may include sensor nodes and IFE nodes. The sensor node can interact with the camera driver module in the kernel layer, and the camera driver module can be used to drive the TOF camera in the hardware layer to collect image data in the default working mode (for example, human eye safety mode), and the camera driver module can also write the hardware parameters corresponding to the IFE module to the IFE module for hardware initialization and parameter configuration. The camera driver module can also configure the initial configuration parameters of the TOF camera to the register of the TOF sensor through the first path, and can also read the operation results of the TOF camera through the second path after the TOF camera runs for a period of time based on these initial configuration parameters in the register. Correspondingly, the sensor node can also obtain the above operation results through the camera driver module.

[0093] In addition, the IFE module can store the image data collected by the TOF camera in the secure memory. The storage location of the image data collected by the TOF camera in the secure memory can be represented by a file descriptor (FD). The IFE module can send the FD of the image data to the camera driver module, the camera driver module can pass the FD to the IFE node of the camera HAL, the IFE node can pass the FD to the camera service, the camera service can pass the FD to the face recognition control module, the face recognition control module can pass the FD to the face recognition TA, the face recognition TA can read the image data from the secure memory according to the FD, process the image data, and can send the processing results to the face recognition control module, the face recognition control module can continue to interact with the camera HAL through the camera service to switch the working mode of the TOF camera. The camera HAL can continue to interact with the camera driver module, so that the camera driver module can drive the TOF camera to collect image data in the switched working module (for example, face ID mode or Tx OFF mode). The FD corresponding to the image data can continue to be passed to the face recognition TA through the IFE module, camera driver module, IFE node, camera service and face control module. The face recognition TA can read the image data again and process it, and feed back the processing result (face recognition success or face recognition failure) to the face recognition control module. The face recognition control module can feed back the processing result to the lock screen application through the face recognition service and face recognition SDK, so that the lock screen application can determine whether to unlock (if face recognition is successful, unlock; if face recognition fails, do not unlock, that is, unlocking fails). Among them, Figure 4 The solid arrows in the figure can be used to represent control flow, and the dashed arrows can be used to represent data flow.

[0094] Specifically, Figure 5As shown, the sensor node in the camera HAL can be used to determine whether the TOF camera supports the human eye safety mode after the TOF camera is powered on. If it does, the initial configuration parameters such as the current value (no harm to the human eye) and exposure value calibrated by the production line are read from the memory (or OEMInfo), and then these initial configuration parameters are written into the register of the TOF camera through the first path (the default working mode of the TOF camera can be the human eye safety mode, and its corresponding parameters are the initial configuration parameters). After that, the TOF camera runs for a short period of time (very short time) according to the initial configuration parameters configured in the register. During the operation, the TOF sensor can complete the inspection of its own device status (for example, normal or abnormal), and write the status inspection result, that is, the above-mentioned operation result, into the register of the TOF sensor. Then, the sensor node reads the operation result from the TOF sensor register through the second path, and selects the next working mode of the TOF sensor (for example, FaceID mode or TxOFF mode) based on the operation result. After the working mode is selected, the sensor node will drive the TOF camera through the camera driver module to collect image data in the selected target working mode, and then perform face recognition based on the image data.

[0095] Since the initial configuration parameters are configured for the TOF sensor, that is, the TOF sensor is controlled to operate based on the initial configuration parameters, and then the next working mode of the TOF sensor is selected based on the operating results and subsequent face recognition operations are performed, compared to the existing face recognition technology, the TOF sensor completes the initialization configuration (that is, completes the initialization configuration of the human eye safety mode) and then collects image data, and then checks the device operating status of the TOF sensor according to the collected image data, and switches the mode based on the inspection results. The above method of the present application optimizes the face recognition process, shortens the time of face recognition (approximately from 140ms to 70ms), and improves the user's face recognition experience.

[0096] For ease of understanding, the following Figure 6 ~Attached Figure 8 The face recognition method provided in the embodiment of the present application is specifically introduced.

[0097] like Figure 6 As shown, the embodiment of the present application provides a face recognition method, and the specific process is as follows:

[0098] Step S8: when the image sensor is powered on, obtaining sensor parameters corresponding to the image sensor;

[0099] It should be understood that, usually, there are multiple image sensors (cameras) integrated in electronic devices, and different image sensors may have different functions or capabilities. For other types of image sensors other than TOF sensors, since they do not include a transmitter (TX) for emitting infrared light or laser pulses, even when the device is damaged, it will not cause harm to the human eye, and thus there is no need to perform eye safety detection on them, thus avoiding the waste of computing resources of electronic devices. Therefore, when the image sensor in the electronic device is powered on, the sensor node of this embodiment will first determine whether the image sensor is a TOF sensor.

[0100] It should be noted that the functions or capabilities of image sensors can be characterized by parameters such as the sensor ID, supported resolution size, data stream format, depth information and / or initialization flag of each image sensor (i.e., the above-mentioned sensor parameters). These sensor parameters are usually stored in the camera HAL. During the startup of the electronic device, the camera service will request the camera HAL to query the capabilities of the image sensors (e.g., cameras) supported by the electronic device. After receiving the request, the camera HAL sends the image sensor capabilities (i.e., the above-mentioned sensor parameters) of the image sensors supported by the electronic device to the camera service for storage.

[0101] Step S9: Read the data stream format field in the sensor parameters;

[0102] Step S10: judging whether the image sensor is a TOF sensor according to the data stream format field;

[0103] Step S11: If yes, proceed to step S12;

[0104] It should be noted that the data stream format field may represent the data stream format supported by the image sensor. Exemplarily, the data stream format field includes but is not limited to: YUY or RAW16.

[0105] The "Y" in YUV stands for luminance (Luminance or Luma), which is the grayscale value; while "U" and "V" stand for chrominance (Chrominance or Chroma), which is used to describe the color and saturation of the image and is used to specify the color of the pixel. Similar to the RGB format, YUV is a pixel format that represents the luminance parameter and the chrominance parameter separately. RAW16 refers to 16-bit RAW, which is a 16-bit original image file format.

[0106] Typically, the data stream format configured for a TOF camera is RAW16, so the sensor node can read the data stream format field corresponding to the image sensor from the acquired sensor parameters, and then determine whether the image sensor is a TOF sensor based on whether the data stream format field is RAW16.

[0107] As a possible implementation method, in some electronic devices, the data stream format corresponding to some other types of image sensors other than TOF sensors is not necessarily RAW16, but the biggest difference between these image sensors and TOF sensors is that the former cannot collect depth data, while the latter can collect depth data of objects through TOF imaging technology. Therefore, the sensor node can also read the depth information from the above sensor parameters, such as Depth: NO or YES, and then determine whether the image sensor is a TOF sensor based on the depth information.

[0108] Of course, as another possible implementation, the sensor node can also determine whether the image sensor is a TOF sensor based on the data stream format field and depth information or other sensor parameters in the sensor parameters. For example, if the data stream format corresponding to image sensor A is RAW16 and the depth information Depth: YES, it can be determined that image sensor A is a TOF sensor.

[0109] In specific implementation, after the sensor node determines that the TOF sensor is a TOF sensor, it can further determine whether the image sensor (ie, the TOF sensor) supports the eye-safe mode, that is, execute the following steps S12-S14.

[0110] Step S12: reading the initialization identifier of the TOF sensor from the sensor parameters;

[0111] It should be noted that the initialization flag may be marking information used to characterize whether the TOF sensor supports the eye-safe mode or whether it supports the initialization of the eye-safe mode. Exemplarily, the initialization flag may be Initial: NO or YES. Among them, Initial: YES indicates that the TOF sensor supports the eye-safe mode; Initial: NO indicates that the TOF sensor does not support the eye-safe mode. In this embodiment, the above initialization flag can be read from the sensor parameters.

[0112] Step S13: determining whether the TOF sensor supports the eye-safe mode according to the initialization flag;

[0113] Step S14: When the TOF sensor supports the eye-safe mode, execute step S15;

[0114] In specific implementation, when the sensor node obtains the initialization mark Initial: NO, it indicates that the TOF sensor does not support the eye-safe mode, and the subsequent eye-safe initialization configuration operation can be stopped at this time; conversely, when the sensor node obtains the initialization mark Initial: YES, it indicates that the TOF sensor supports the eye-safe mode, and the following steps S15-S20 can be executed.

[0115] Step S15: configuring initial configuration parameters for the TOF sensor through a first path, wherein the first path is a first bus connected between the camera driving module and the TOF sensor.

[0116] It should be understood that the so-called initialization is to assign variables to default values, including setting the state of the initialized object to the default state (generally achieved by setting the parameters of the initialized object). In this application, the above-mentioned initial configuration parameters may be the configuration parameters required to be used when the TOF sensor is powered on to perform the initialization of the eye-safe mode. These initial configuration parameters are used to control the TOF sensor to operate in the eye-safe mode. Exemplarily, the above-mentioned initial configuration parameters include current value, exposure value, exposure time and / or light intensity, etc.

[0117] It should be noted that if Figure 4 As shown, the first path is a first bus connected between the camera driver module and the TOF sensor, and the first path is used to transfer data between the camera driver module and the TOF sensor. Exemplarily, the transferred data can be control flow data, that is, data or data sequence that arranges program elements in a certain order to determine the order of program execution.

[0118] In this embodiment, the first bus may be any bus capable of bidirectionally transmitting data or controlling flow data, such as an I2C bus or an SPI bus. The selection of a specific bus model may be determined according to actual conditions, and this embodiment does not impose any restrictions on this.

[0119] As a possible implementation manner, in this embodiment, the first path is used for the camera driver module to write data to the TOF sensor, for example, the initial configuration parameters are written into the register of the TOF sensor through the first path.

[0120] As another possible implementation method, the sensor node in this embodiment can send an initialization command to the camera driver module, so that the camera driver module configures initial configuration parameters for the TOF sensor through the first path based on the initialization command, wherein the initial configuration parameters are used to control the TOF sensor to operate in an eye-safe mode.

[0121] It should be noted that the above initialization command may be an instruction for controlling the TOF sensor to perform eye-safe initialization, and the command includes initial configuration parameters and some control instructions instructing the TOF sensor to initialize based on these parameters.

[0122] In the specific implementation, the sensor node first reads the initial configuration parameters (eye-safe mode) from the memory of the electronic device, and then sends the initial configuration parameters to the camera driver module. The camera driver module integrates these initial configuration parameters into the initialization command through the first path and writes them into the register of the TOF sensor, and then executes the following step S16.

[0123] Step S16: Controlling the TOF sensor to operate based on the initial configuration parameters.

[0124] It should be noted that in order to protect the human eye from being harmed by the infrared light emitted by the damaged TOF sensor, in this embodiment, the electronic device needs to check the device status (normal or abnormal) of the TOF sensor before performing face recognition unlocking. If the status is normal, it means that the TOF sensor can work normally and can work in FaceID mode; if the status is abnormal, it means that the TOF sensor cannot work normally and can work in TxOFF mode to avoid harming the human eye. Therefore, the operating results of the OF sensor when running based on the initial configuration parameters become the basis for the mode in which the TOF sensor will work next.

[0125] It should be understood that the purpose of controlling the TOF sensor to run based on the initial configuration parameters is to detect whether the TOF sensor can run normally after completing the initialization configuration according to these initial configuration parameters, and obtain the operation results. In specific implementation, the camera HAL reads the above initial configuration parameters through the sensor node (the current value is read from the memory or oeminfo), and then sends these initial configuration parameters to the camera driver module of the kernel layer through the first path. The camera driver module updates the initial configuration parameters of the human eye safety mode to the register of the TOF sensor (exemplarily, it can be written via I2C). After the configuration is completed, when the TOF sensor receives the control instruction sent by the sensor node, it will run for a short period of time (very short time) with a smaller current (i.e., the first current value) based on these initial configuration parameters. During the operation, the TOF sensor can complete the inspection of the working status (for example, normal or abnormal).

[0126] As a possible implementation method, the sensor node can read the first current value and exposure value in the initial configuration parameters; and then control the TOF sensor to run for a preset time based on the first current value and exposure value, wherein the first current value is less than the normal operating current value of the TOF sensor.

[0127] It should be noted that the above-mentioned first current value is the photocurrent value corresponding to the transmitter (TX) in the TOF sensor in the eye-safe mode. The photocurrent value is relatively small, and can be, for example, about 700mA, which is less than the normal working current value (2800mA) of the transmitter (TX) in the TOF sensor. Of course, the present embodiment does not limit the specific numerical value of the above-mentioned first current value, as long as it can ensure that it does not harm the human eye and supports the TOF sensor to complete its own device status check. Specifically, the sensor node can control the transmitter in the TOF sensor to run for a preset time at the first light intensity based on the first current value and the exposure value. It should be noted that the infrared light emitted by the TOF sensor based on the first light intensity is harmless to the human eye. At the same time, the setting of the above-mentioned preset time should not be too long, and it can support the TOF sensor to complete its own device status check. Exemplarily, the sensor node can read the first current value of 700mA and the exposure value of 10μs in the initial configuration parameters, and then control the TOF sensor to work for a preset time at the first current value of 700mA and the exposure value of 10μs.

[0128] As another possible implementation, the sensor node may control the transmitter in the TOF sensor to operate at the first light intensity for a preset time based on the first current value and the exposure value. It should be noted that the infrared light emitted by the TOF sensor based on the first light intensity is harmless to human eyes.

[0129] As another possible implementation, after the operation based on the initial configuration parameters is completed, the TOF sensor can also write the operation results into the register through the first path, wherein the register can be set in the TOF sensor. Although the TOF sensor does not output the image data collected during the operation based on the initial configuration parameters, this part of the image data also involves user privacy data. In this embodiment, these image data and the operation results are stored in the register together to ensure data security.

[0130] Step S17: acquiring an operation result from the TOF sensor through a second path, wherein the second path is a second bus connected between the camera driving module and the TOF sensor, wherein the first bus is different from the second bus;

[0131] Step S18: determining a target operating mode of the TOF sensor according to the operating result;

[0132] It should be noted that if Figure 4As shown, the second path is a second bus connected between the camera driver module and the TOF sensor, and the second path is used to transfer data between the camera driver module and the TOF sensor. Exemplarily, the data transferred can be control stream data. The above-mentioned second bus can be any bus that can bidirectionally transfer data or control stream data, such as an I2C bus or an SPI bus. The selection of a specific bus model can be determined according to actual conditions, and this embodiment does not limit this. In this embodiment, the first bus and the second bus can be different buses.

[0133] As a possible implementation, considering that the physical structure of the I2C bus is simpler than other bidirectional data transmission buses (only two wires, SCL and SDA), preferably, in this embodiment, the first bus and the second bus may be I2C buses.

[0134] As another possible implementation, in this embodiment, the second path is used by the camera driving module to read data from the TOF sensor, for example, the operation result is read from the register of the TOF sensor through the second path.

[0135] As mentioned above, the operation result of the TOF sensor will determine the next working mode of the TOF sensor. When the operation result is normal, the camera HAL will configure the target working mode of the TOF sensor to Face ID Mode through the sensor node. Conversely, when the status check result is abnormal, the camera HAL will configure the target working mode of the TOF sensor to TX OFF Mode through the sensor node.

[0136] It should be understood that the Face ID Mode is a mode in which the Tx of the TOF camera works at a normal current value (or within its range), and the Face ID Mode can be used for scenarios such as secure face unlocking and secure payment. Among them, the normal current value is greater than the first current value. The TX OFF Mode refers to a mode in which the Tx of the TOF camera is not powered (and thus does not emit light). The TX OFF Mode is used to detect when the Tx device of the TOF camera is damaged or cannot work properly. This is because the use of power when the Tx device is damaged may have an adverse effect on the human eye. Therefore, when the Tx device of the TOF camera is detected to be damaged, the TX OFF Mode is used to make the Tx device not powered, thereby avoiding damage to the human eye. The EyeSafe Mode refers to a mode in which the Tx of the TOF camera works at a small current (that is, the first current value, which is less than the normal current value). The EyeSafe Mode is used to check whether the TOF camera is damaged, that is, to detect whether the state of the TOF sensor is normal or abnormal. Of course, the working mode of the camera can also include more, which is not limited in this application.

[0137] In another possible implementation, when the operation result is normal, the target operation mode of the TOF sensor is determined to be the first operation mode, and the first operation mode is used to indicate that the TOF sensor operates at a normal current value. The first operation mode may be the above-mentioned Face ID Mode, and the normal current value is the current value required for the TOF Tx to operate normally.

[0138] In another possible implementation, when the operation result is abnormal, the target operation mode of the TOF sensor is determined to be a second operation mode, and the second operation mode is used to indicate that the TOF sensor operates at a second current value, and the second current value is lower than a preset current value. The second operation mode can be the above-mentioned TX off mode (TxOFF Mode), and the preset current value can be 0 or close to 0, so that the TOF Tx does not emit light to protect the safety of human eyes.

[0139] Step S19: controlling the TOF sensor to collect image data in the target working mode;

[0140] It should be understood that the sensor node may store operating parameters (configuration parameters) corresponding to different operating modes of the TOF sensor. Exemplarily, the operating parameters corresponding to the eye-safe mode may be: current value (first current value) is 700mA, IR grayscale image exposure time is 10μs, and depth image exposure time is 10μs. The operating parameters corresponding to the FaceID mode may be: current value (normal current value) 2800mA, IR grayscale image exposure time 500μs, depth image exposure time 800μs. The operating parameters corresponding to the TxOFF mode may be: current value (second current value) 0mA, IR grayscale image exposure time 0μs, depth image exposure time 0μs. Under different operating parameters, there are differences in the image data collected by the TOF sensor, which will lead to different final face recognition results.

[0141] In specific implementation, the sensor node sends the configuration parameters of the target working mode to the camera driver module, and the camera driver module writes the configuration parameters of the target working mode into the register of the TOF sensor through the first path to drive the TOF sensor to collect image data based on the target working mode. The camera driver module sends a start (stream on) command / instruction to the TOF sensor. The stream on command is used to drive the TOF sensor to collect data. In response to the received stream on command, the TOF sensor will collect RAW Data (including image data) based on the target working mode.

[0142] Specifically, in response to receiving the stream on command, RX can send a request for a light signal to TX, and TX works at a corresponding current value to send a light signal of a corresponding light intensity; RX receives the light signal at a corresponding exposure time (exposure value, for example, 10us), and the light signal received by RX includes reflected light of the light signal of the corresponding light intensity. Based on the received light signal, RX acquires image data.

[0143] As an implementation of this step, the target working mode of the TOF sensor determined by the sensor node as the FaceID mode (face ID mode) is taken as an example to illustrate the above step S19. Accordingly, the above step S19 may include steps S191 to S194:

[0144] Step S191: The sensor node sends the configuration parameters of the face ID mode to the camera driver module.

[0145] Step S192: The camera driving module writes the configuration parameters of the face ID mode into the register of the TOF sensor to drive the TOF sensor to collect image data based on the face ID mode.

[0146] It should be understood that the camera driver module can send the configuration parameters of the face ID mode to the TOF sensor. Exemplarily, the camera driver module can write the configuration parameters of the face ID mode to the register of the TOF sensor via the I2C bus. That is, the camera driver module can send the configuration parameters of the face ID mode to the TOF sensor via the I2C bus.

[0147] Step S193: The TOF sensor collects RAW Data 1 based on the face ID mode.

[0148] RAW Data 1 may be image data (first image data) obtained when the TOF sensor's Tx operates at a normal current value (e.g., 2800 mA) to transmit a light signal to a human face, and the TOF sensor's Rx receives reflected light and forms an image. The light signal emitted when the TOF sensor's Tx operates at a normal current value is a second light intensity. The second light intensity is greater than the light signal emitted when the Tx operates at the first current value, i.e., the first light intensity.

[0149] RAW Data 1 includes Metadata. For example, Metadata stores information such as the current working mode of the TOF sensor (e.g., face ID mode), the photocurrent value (e.g., 2800mA), the device working state of the TOF sensor (e.g., normal), and the image exposure time (e.g., 800μs).

[0150] Step S194: The TOF sensor sends RAW Data 1 to the IFE module.

[0151] Exemplarily, the TOF sensor can transmit RAWData1 collected by the TOF sensor based on the face ID mode to the IFE module through MIPI. The IFE module sends RAW Data 1 to the secure memory for storage. The storage location of RAW Data 1 collected by the TOF sensor based on the face ID mode in the secure memory can be represented by FD1.

[0152] As another implementation of this step, the above step S19 is described by taking the target working mode of the TOF sensor determined by the sensor node as the TxOFF mode as an example. Accordingly, the above step S19 may also include steps S191' to S194':

[0153] Step S191 ′: the sensor node sends the configuration parameters of the Tx off mode to the camera driver module.

[0154] Step S192 ′: the camera driving module writes (updates) the configuration parameters of the Tx off mode into the register of the TOF sensor to drive the TOF sensor to collect data.

[0155] That is, the camera driver module can send the configuration parameters of the Tx off mode to the TOF sensor. Exemplarily, the camera driver module can write the configuration parameters of the Tx off mode into the TOF sensor register via the I2C bus. That is, the configuration parameters of the Tx off mode are sent to the TOF sensor via the I2C bus.

[0156] Step S193 ′: the TOF sensor collects RAW Data 2 based on the Tx off mode.

[0157] Among them, RAW Data 2 can be the image data (second image data) obtained by imaging the reflected light (no emitted light or ambient emitted light) received by the Rx of the TOF sensor when the Tx of the TOF sensor is not powered on and does not emit light. It is usually a "black image" without a clear face image.

[0158] RAW Data 2 includes Metadata. For example, Metadata stores information such as the current working mode of the TOF sensor (e.g., Tx off mode), the photocurrent value (second current value) (e.g., 0 mA), the device working state of the TOF sensor (e.g., abnormal), and the image exposure time (e.g., 10 us).

[0159] Step S194 ′: the TOF sensor transmits RAW Data 2 to the IFE module.

[0160] Exemplarily, the TOF sensor can transmit RAW Data 2 collected by the TOF sensor to the IFE module via MIPI. The IFE module sends RAW Data 2 to the secure memory for storage. The storage location of RAW Data 2 collected by the TOF sensor based on the Tx off mode in the secure memory can be represented by FD2.

[0161] Step S20: performing face recognition based on the image data.

[0162] In specific implementation, the face recognition TA can obtain the working mode of the TOF camera (for example, FaceID mode or TxOFF mode) from the Metadata in the collected RAW Data 1 or RAW Data 2. Then the face recognition TA can process the first image data in RAW Data 1 or the second image data in RAW Data 2 through the TOF algorithm to obtain a grayscale image and a depth map, and then perform face recognition based on the grayscale image through the face ID algorithm, and obtain the face recognition result based on the depth map and anti-counterfeiting detection.

[0163] In actual applications, before executing the above step S20, the IFE module needs to send FD1 or FD2 to the camera driver module. The camera driver module sends FD1 or FD2 to the IFE node. The IFE node sends FD1 or FD2 to the camera service through the interface of the camera HAL. The camera service sends FD1 or FD2 to the face recognition control module. The face recognition control module sends FD1 or FD2 to the face recognition TA. The face recognition TA reads RAW Data 1 or RAW Data 2 from the secure memory according to FD1 or FD2. The face recognition TA performs face recognition according to RAW Data 1 or RAW Data 2 to obtain a face recognition result.

[0164] It should be noted that the face recognition TA also stores the face information previously entered by the user, and the TOF algorithm can convert the face information entered by the user into a grayscale image and a depth image. If the currently collected face information (RAW Data collected by the TOF camera based on the face ID mode, i.e. RAW Data 1) matches the grayscale image corresponding to the previously entered face information (i.e. RAW Data collected by the electronic device when the user performs the face entry operation), it can be considered that they are the same user (i.e. the same user performs the face entry operation and the unlocking operation), and if the currently collected face information includes depth information, it can be considered that the current user is authentic and trustworthy (not disguised by photos, videos, etc.), and the face of the current user can be considered safe, i.e. the face recognition result is successful. If the currently collected facial information does not match the grayscale image corresponding to the previously entered facial information (that is, the RAW Data collected by the electronic device when the user performs a facial entry operation), or if the currently collected facial information does not include depth information (for example, when unlocking through a photo or video, the facial information does not include depth information), the current user's face is considered unsafe, that is, the facial recognition result is a failure.

[0165] In addition, if the above-mentioned image data is the second image data in RAW Data 2, the face recognition TA can obtain the current Tx off mode from the Metadata data in RAW Data 2 collected by the TOF sensor based on the Tx off mode, and then obtain the grayscale image and depth map based on the second image data through the TOF algorithm, and then perform face recognition based on the grayscale image and anti-counterfeiting detection based on the depth map through the face ID algorithm to obtain the face recognition result.

[0166] It should be noted that when the TOF sensor works in Tx off mode, the face recognition result is failed. This is because the TOF sensor cannot emit light in Tx off mode, so the TOF sensor cannot collect clear face images. Even if the user currently unlocking is an authenticated user (i.e. the owner), the face recognition result is still failed.

[0167] In specific implementation, the face recognition TA passes the face recognition result (success or failure) to the face recognition control module. That is, the face recognition TA can notify the face recognition control module whether the face recognition result is successful or failed. The face recognition control module passes the face recognition result (success or failure) to the face recognition service. The face recognition control module passes the face recognition result (success or failure) to the face recognition service based on the callback previously registered by the face recognition service. That is, the face recognition control module notifies the face recognition service that the face recognition result is (success or failure). The face recognition service passes the face recognition result (success or failure) to the face recognition SDK. The face recognition service passes the face recognition result (success or failure) to the face recognition SDK based on the callback previously registered by the face recognition SDK. That is, the face recognition service can notify the face recognition SDK that the face recognition result is (success or failure). The face recognition SDK passes the face recognition result (success or failure) to the lock screen application. The face recognition SDK passes the face recognition result (success or failure) to the lock screen application based on the callback previously registered by the lock screen application. That is, the face recognition SDK can notify the lock screen application of the face recognition result as success or failure. The lock screen application decides whether to unlock the device based on the face recognition result (success or failure).

[0168] Correspondingly, if the face recognition result is a successful recognition, unlocking is performed; if the face recognition result is a failed recognition, unlocking is not performed or an unlocking failure prompt is displayed. Specifically, if the face recognition result is successful, the lock screen application can be successfully unlocked, so that the electronic device can display the desktop or application (system application or third-party application) interface. If the face recognition result is a failure, the lock screen application is not unlocked, that is, the face unlocking fails. After the face unlocking fails, the lock screen application can disable the face recognition function within a period of time (for example, 3 minutes) when the face recognition fails. Exemplarily, if the user sets face unlocking, such as Figure 7 As shown in (a) of FIG. 1 , when the user picks up the mobile phone for face recognition, in response to the user picking up the mobile phone, as shown in FIG. 1 , Figure 7 As shown in (b) in FIG. 7 , the mobile phone may display a lock screen interface 701 . During the face recognition process, the mobile phone may display an unlock icon 702 and a prompt text “face recognition in progress” 703 on the lock screen interface 701 .

[0169] The face recognition method provided in the present embodiment is compared with the prior art in which the TOF sensor receives a start (stream on) command / instruction to collect data after completing the initialization configuration, and then sends the collected image data to the IFE module, the IFE module sends the FD of the image data to the camera service through the interface of the camera HAL, the camera service sends the FD to the FACE CA, the FACE CA sends the FD of the image data to the FACE TA, and the FACE TA reads the image data according to the FD of the image data and performs a human eye safety detection, that is, a normal or abnormal detection of the TOF sensor, and then determines the next working mode of the TOF sensor based on the detection result, and finally performs face recognition based on the determined working mode. The above method of the present embodiment uses the second path to directly read the operation result from the register of the TOF sensor through the camera driver module, and then determines the target working mode of the TOF sensor according to the operation result, and then controls the TOF sensor to collect image data and face recognition in the target working mode, which greatly improves the efficiency of face recognition and reduces the time consumption of face recognition.

[0170] In order to further improve the efficiency of face recognition, in a possible implementation, the TOF sensor sends RAW Data 1 or RAW Data 2 collected based on the target working mode to the IFE module. Exemplarily, the TOF sensor can transmit RAW Data 1 or RAW Data 2 collected by the TOF sensor to the IFE module through the mobile industry processor interface MIPI. The IFE module sends RAW Data 1 or RAW Data 2 to the secure memory (Secure Buffer) for storage. The IFE module sends FD1 or FD2 to the camera driver module. The camera driver module sends FD1 or FD2 to the IFE node. The IFE node sends FD1 or FD2 to the camera service through the interface of the camera HAL. The camera service sends FD1 or FD2 to the face recognition control module. The face recognition control module sends FD1 or FD2 to the face recognition TA (FACE TA). The face recognition TA reads the first frame of image data contained in RAW Data 1 or RAW Data 2 from the secure memory according to FD1 or FD2, and then performs face recognition based on the first frame of image data.

[0171] It should be noted that the first frame of image data, that is, the first frame of image (FaceID first frame or TxOFF first frame) collected after the TOF sensor starts streaming (executes the stream on command), uses the first frame of image data to perform face recognition, which advances the time of unlocking the first frame.

[0172] Of course, when the face recognition TA performs face recognition based on image data, it does not have to be performed based on the first frame of image data. It can also perform face recognition based on any one of the relatively front frames of images collected after the TOF sensor starts streaming (stream on). In practical applications, which frame of image data the face recognition TA uses for face recognition may depend on whether the final face recognition unlocking time is less than the unlocking time that can be achieved by the prior art. The purpose of using the first frame of image data for face recognition is to shorten the face recognition time as much as possible and improve the user experience, and it does not specifically limit the solution. Specifically, the face recognition TA can obtain a grayscale image and a depth map based on the first frame of image data through the TOF algorithm, and then perform face recognition based on the grayscale image through the face ID algorithm, and perform anti-counterfeiting detection based on the depth map to obtain a face recognition result.

[0173] like Figure 8 As shown, in another possible implementation, before the image sensor is powered on, the electronic device of this embodiment will further perform the following operations:

[0174] Step S1: The lock screen application calls the face recognition SDK to perform face recognition.

[0175] In specific implementation, when the user's unlocking operation is detected (the user picks up the phone, presses the power button, or operates on the screen (clicks, slides, etc.)), the lock screen application calls the face recognition SDK for face recognition. At the same time, the lock screen application can register a callback with the face recognition SDK. The purpose of registering this callback is that when the face recognition SDK obtains the face recognition result, it can return the face recognition result to the lock screen application.

[0176] Step S2: The face recognition SDK sends a face recognition request to the face recognition service.

[0177] Among them, the request for face recognition carries the identifier of the face recognition type, the resolution size of the image, and the data stream format. Among them, the face recognition type includes a 2D face recognition type (for example, it can correspond to the identifier 0) and a 3D face recognition type (for example, it can correspond to the identifier 1). Exemplarily, the face recognition type carried in the request for face recognition can be 1 (i.e., a 3D face recognition type), the resolution size of the image can be 1280x2898 pixels (pixel), and the data stream format can be the raw image format RAW. At the same time, the face recognition SDK can register a callback with the face recognition service. The purpose of registering the callback is that when the face recognition service obtains the face comparison result, it can return the face recognition result to the face recognition SDK.

[0178] Step S3: The face recognition service sends a face recognition request to the face recognition control module.

[0179] In specific implementation, the face recognition SDK can notify the face recognition control module to perform face recognition through the face recognition service. The face recognition service can send the face recognition request received from the face recognition SDK to the face recognition control module. At the same time, the face recognition service can register a callback with the face recognition control module. The purpose of registering the callback is that when the face recognition control module obtains the face comparison result, it can return the face comparison result to the face recognition service.

[0180] Step S4: In response to receiving the face recognition request, the face recognition control module matches the camera according to the face recognition request.

[0181] Specifically, the face recognition control module can obtain the face recognition type identifier, image resolution size and data stream format from the face recognition request, and determine the matching camera by querying the camera capability from the camera service.

[0182] It should be understood that during the startup of the electronic device, the camera service can send a camera capability query request to the camera HAL, and the camera capability query request is used to request the camera capabilities supported by the electronic device. After the camera HAL receives the camera capability query request, it can send the capabilities of the cameras supported by the electronic device to the camera service, and the camera service can store the received capabilities of the cameras supported by the electronic device. Among them, the camera capabilities supported by the electronic device include the camera identification ID of each camera, the maximum resolution size supported, the format of the data stream, and whether the camera supports the acquisition of depth information (also whether it includes a TOF camera), etc.

[0183] The face recognition control module can send a camera capability query request to the camera service, and the camera service can send the capabilities of the cameras supported by the electronic device to the face recognition control module. The face recognition control module can determine a matching camera based on the capabilities of the cameras supported by the electronic device.

[0184] Step S5: The face recognition control module sends a request to open the camera to the camera service.

[0185] Exemplarily, the face recognition control module can send a request to open the Camera to the camera service through the Vendor Native Development Kit (VNDK) interface. The request to open the Camera carries information such as the security identifier, camera ID, resolution size, and data stream format. The security identifier is used to indicate that the data is stored in a secure buffer. In other words, the security identifier can be used to apply for a secure memory, which is subsequently used to store data collected by the camera. For example, the security identifier can be 1 or 0, 1 means that the data is stored in a secure buffer, and 0 means that the data is stored in an unsecure buffer. At the same time, the face recognition control module can register a callback with the Camera service. The purpose of registering the callback is to notify the face recognition control module that the Camera is opened after the camera service completes the camera opening.

[0186] Step S6: In response to receiving the request to open the Camera, the camera service sends a request to open the Camera to the camera HAL. The request to open the Camera carries information such as the security identifier, camera ID, resolution size, and data stream format.

[0187] When the camera service calls the camera HAL, the camera service can send information such as security identification, camera ID, image resolution, data stream format, etc. to the camera HAL. The camera HAL can cache information such as security identification, camera ID, image resolution, data stream format, etc. for a preset time. At the same time, the camera service can register a callback with the camera HAL, which is used by the camera HAL to notify the camera service of the result of creating the channel.

[0188] Step S7: The camera HAL creates a corresponding channel according to the camera ID, image resolution and data stream format.

[0189] The camera HAL can select available nodes according to the camera ID, resolution and data stream format, and then create corresponding paths according to the available nodes. Exemplarily, the path corresponding to the sensor node can be: a path consisting of sensor node □ camera driver □ TOF camera □ IFE module □ secure memory. The path corresponding to the IFE node can be: a path consisting of IFE module (carrying FD) □ camera driver □ IFE node. The camera HAL can connect the output port of the sensor node and the input port of the IFE node at the HAL layer. Thus, the path corresponding to the sensor node and the path corresponding to the IFE node can form a closed-loop path. After the path is created, wait for the hardware in the path to be powered on (that is, the hardware circuit is powered on, such as the image sensor is powered on), and wait for data requests.

[0190] It should be noted that the above steps S1-S7 are the prerequisite steps of steps S8-S20 of the face recognition method provided in this embodiment. Steps S1-S20 constitute the complete process from the user picking up the electronic device to the electronic device performing face recognition. Through the above method, the face recognition method provided in this embodiment improves the efficiency of face recognition and reduces the time consumption of face recognition.

[0191] The present application also provides a TOF camera, which can be used to implement the eye safety mode, face ID mode and TX off mode in the above embodiments, and an electronic device equipped with the TOF camera can perform the various functions or steps performed by the electronic device in the above method embodiments.

[0192] The present application also provides an electronic device, comprising: 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 the one or more computer programs include instructions, which, when executed by the electronic device, enable the electronic device to perform a face recognition method as described in any one of the first aspect or possible implementations of the first aspect.

[0193] It should be understood that the electronic device here is embodied in the form of a functional module. The term "module" here can be implemented in the form of software and / or hardware, without specific limitation. For example, a "module" can be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a proprietary processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a merged logic circuit, and / or other suitable components that support the described functions.

[0194] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the processor executes a face recognition method as described in any one of the first aspect or possible implementations of the first aspect.

[0195] The present application also provides a chip, which includes a processor and a data interface, and the processor reads instructions stored in a memory through the data interface to execute the face recognition method described in any one of the first aspect or possible implementations of the first aspect.

[0196] like Fig. 9As shown, the chip includes at least one processor 901 and at least one data interface 902. The processor 901 and the data interface 902 can be interconnected via lines. For example, the data interface 902 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the data interface 902 can be used to send signals to other devices (such as a processor 901 or a touch screen of an electronic device). Exemplarily, the data interface 902 can read instructions stored in the memory and send the instructions to the processor 901. When the instructions are executed by the processor 901, the electronic device can execute the various steps in the above embodiments. Of course, the chip system may also include other discrete devices, which are not specifically limited in the embodiments of the present application.

[0197] Optionally, the chip may further include a memory storing instructions, and the processor is used to execute the instructions stored in the memory. When the instructions are executed, the processor is used to execute the face recognition method described in any one of the first aspect or possible implementation methods of the first aspect.

[0198] The memory can be a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), a magnetic disk storage medium or other magnetic storage device, or it can also be any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer.

[0199] In the embodiments of the present application, "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. A and B may be singular or plural. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a□b, a□c, b□c, or a□b□c, where a, b, c can be single or multiple.

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

[0201] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0202] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.

[0203] The above is only a specific implementation of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A face recognition method, the method is applied to an electronic device, the electronic device includes a TOF sensor and a camera driving module, characterized in that: The method comprises: Sending an initialization command to the camera driver module, so that the camera driver module configures initial configuration parameters for the TOF sensor through a first path based on the initialization command, wherein the initial configuration parameters are used to control the TOF sensor to operate in an eye-safe mode, wherein the first path is a first bus connected between the camera driver module and the TOF sensor, and the first path is used for the camera driver module to write data to the TOF sensor; Controlling the TOF sensor to operate based on the initial configuration parameters; Obtaining an operation result from the TOF sensor through a second path, wherein the second path is a second bus connected between the camera driving module and the TOF sensor, and the second path is used for the camera driving module to read data from the TOF sensor, wherein the first bus is different from the second bus; Determining a target operating mode of the TOF sensor according to the operating result; Control the TOF sensor to collect image data in the target working mode; Perform face recognition based on the image data.

2. The face recognition method according to claim 1, characterized in that: The first bus and the second bus are both I2C buses.

3. The face recognition method according to claim 1, characterized in that: The controlling the TOF sensor to operate based on the initial configuration parameters includes: Reading a first current value and an exposure value in the initial configuration parameters; The TOF sensor is controlled to operate for a preset time period based on the first current value and the exposure value, wherein the first current value is less than a normal operating current value of the TOF sensor.

4. The face recognition method according to claim 3, characterized in that: The TOF sensor includes a transmitter for transmitting a light signal, and the controlling the TOF sensor to operate for a preset time period based on the first current value and the exposure value includes: The emitter in the TOF sensor is controlled to operate at a first light intensity for a preset time period based on the first current value and the exposure value.

5. The face recognition method according to claim 1, characterized in that: After the TOF sensor is controlled to operate based on the initialization configuration parameters, the method includes: The operation result is written into a register through the first path, and the register is set in the TOF sensor.

6. The face recognition method according to claim 1, characterized in that: Before configuring the initial configuration parameters for the TOF sensor through the first path, the method includes: Obtain sensor parameters corresponding to the TOF sensor; Reading an initialization flag of the TOF sensor from the sensor parameters; Determining whether the TOF sensor supports an eye-safe mode according to the initialization flag; When the TOF sensor supports the eye-safe mode, the step of configuring initial configuration parameters for the TOF sensor through the first path is performed.

7. The face recognition method according to claim 6, characterized in that: Before obtaining the sensor parameters corresponding to the TOF sensor, the method includes: When the image sensor is powered on, obtaining sensor parameters corresponding to the image sensor; Reading a data stream format field in the sensor parameters; Determine whether the image sensor is a TOF sensor according to the data stream format field; If yes, execute the step of obtaining the sensor parameters corresponding to the TOF sensor.

8. The face recognition method according to any one of claims 1 to 7, characterized in that: The acquiring of image data collected by the TOF sensor in the target working mode includes: Acquire a first frame of image data collected by the TOF sensor in the target working mode; The performing face recognition based on the image data comprises: Perform face recognition based on the first frame of image data.

9. The face recognition method according to claim 8, characterized in that: The performing face recognition based on the first frame of image data includes: Acquire a grayscale image and a depth image based on the first frame of image data; Face comparison is performed based on the grayscale image, and anti-counterfeiting detection is performed based on the depth image to obtain a face recognition result.

10. The face recognition method according to any one of claims 1 to 9, characterized in that: After performing face recognition based on the image data, the method includes: Determine whether to perform unlocking based on the face recognition result; If the face recognition result is successful, unlocking is performed; If the face recognition result is a recognition failure, unlocking is not performed or an unlocking failure prompt is displayed.

11. 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 in the memory, and the one or more computer programs include instructions, which, when executed by the electronic device, enable the electronic device to perform the face recognition method as described in any one of claims 1 to 10.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the face recognition method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Systems and methods for safe and reliable autonomous vehicles

    CN111587407A

  • Face recognition method and device based on TOF camera module

    CN113239828A

  • Vehicle lock control system, vehicle lock control method and vehicle

    CN113421358A

  • Control method and device of vehicle-mounted face recognition equipment

    CN113561908A

  • Face recognition method and device

    CN113807172A