[go: up one dir, main page]

CN115705726A - A face recognition method and device - Google Patents

A face recognition method and device Download PDF

Info

Publication number
CN115705726A
CN115705726A CN202110921586.5A CN202110921586A CN115705726A CN 115705726 A CN115705726 A CN 115705726A CN 202110921586 A CN202110921586 A CN 202110921586A CN 115705726 A CN115705726 A CN 115705726A
Authority
CN
China
Prior art keywords
face recognition
camera
transmitter
module
sends
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110921586.5A
Other languages
Chinese (zh)
Inventor
吕建明
袁江峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202110921586.5A priority Critical patent/CN115705726A/en
Publication of CN115705726A publication Critical patent/CN115705726A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Studio Devices (AREA)

Abstract

The embodiment of the application provides a face recognition method and device, relates to the field of terminals, and can improve the safety of face recognition. The method is applied to electronic equipment, the electronic equipment comprises a TOF camera module, the TOF camera module comprises an emitter used for emitting optical signals and an image sensor used for receiving reflected light and imaging, and the method comprises the following steps: receiving a first operation of a user, wherein the first operation is used for triggering face recognition; controlling the emitter to operate at a first light intensity; determining whether the transmitter is in a normal operating state; under the condition that the emitter is in a normal working state, controlling the emitter to work at a second light intensity, wherein the second light intensity is greater than the first light intensity; controlling an image sensor to collect image data; face recognition is performed based on the image data. Wherein determining whether the transmitter is in a normal operating state may be determined by the camera HAL in the electronic device by the camera driving module from operating state parameters of the transmitter obtained by the transmitter.

Description

一种人脸识别方法和装置A face recognition method and device

技术领域technical field

本申请涉及终端领域,尤其涉及一种人脸识别方法和装置。The present application relates to the field of terminals, and in particular to a face recognition method and device.

背景技术Background technique

目前,人脸识别被广泛用于电子设备进行身份认证的场景。目前的人脸识别采用的是平面(2D)人脸特征检测的技术,提取的人脸特征为2D特征,容易受到虚假攻击(例如,通过机主的照片进行冒充),安全性不高。At present, face recognition is widely used in scenarios where electronic devices perform identity authentication. The current face recognition adopts the technology of plane (2D) face feature detection, and the extracted face features are 2D features, which are vulnerable to false attacks (for example, impersonating through the owner's photo), and the security is not high.

发明内容Contents of the invention

本申请实施例提供一种人脸识别方法和装置,能够提高人脸识别的安全性。Embodiments of the present application provide a face recognition method and device, which can improve the security of face recognition.

第一方面,本申请实施例提供一种人脸识别方法,应用于电子设备,电子设备包括飞行时间TOF摄像头模组,TOF摄像头模组包括用于发射光信号的发射器和用于接收反射光和成像的图像传感器,方法包括:接收用户的第一操作,第一操作用于触发人脸识别;控制发射器以第一光强度工作;确定发射器是否处于正常工作状态;在发射器处于正常工作状态的情况下,控制发射器以第二光强度工作,第二光强度大于第一光强度;控制图像传感器采集图像数据;基于图像数据执行人脸识别。In the first aspect, the embodiment of the present application provides a face recognition method, which is applied to electronic equipment. The electronic equipment includes a time-of-flight TOF camera module, and the TOF camera module includes a transmitter for emitting optical signals and a transmitter for receiving reflected light. and an imaging image sensor, the method includes: receiving a user's first operation, the first operation is used to trigger face recognition; controlling the transmitter to work with a first light intensity; determining whether the transmitter is in a normal working state; In the working state, the transmitter is controlled to work with the second light intensity, and the second light intensity is greater than the first light intensity; the image sensor is controlled to collect image data; face recognition is performed based on the image data.

基于本申请实施例提供的方法,确定发射器以第一光强度工作时是否处于正常工作状态,若发射器处于正常工作状态,再控制发射器以第二光强度工作。第二光强度大于第一光强度。由于第一光强度较小,第一光强度不会对人眼造成伤害,可以保证人眼安全。若发射器可以正常工作发射第一光强度的光信号,说明发射器是完好的,未损坏的,这样电子设备可以正常控制发射器,发射器以较大的第二光强度工作时,也可以保证人眼安全,不会出现由于损坏导致发射出伤害人眼的光信号的问题。并且,发射器以第二光强度工作时,可以保证图像传感器采集到更加准确的图像数据,从而可以更加准确的进行人脸识别。Based on the method provided by the embodiment of the present application, it is determined whether the transmitter is in a normal working state when it is working with the first light intensity, and if the transmitter is in the normal working state, then control the transmitter to work with the second light intensity. The second light intensity is greater than the first light intensity. Since the first light intensity is relatively small, the first light intensity will not cause damage to human eyes, which can ensure the safety of human eyes. If the transmitter can work normally and emit an optical signal with the first light intensity, it means that the transmitter is intact and not damaged, so that the electronic equipment can normally control the transmitter, and when the transmitter works with a larger second light intensity, it can also Ensure the safety of human eyes, and there will be no problem of emitting light signals that hurt human eyes due to damage. Moreover, when the emitter works with the second light intensity, it can ensure that the image sensor collects more accurate image data, so that face recognition can be performed more accurately.

另外,TOF摄像头模组采集到的图像数据是3D的人脸数据,相比2D的人脸数据,根据3D的人脸数据进行人脸识别更加安全和准确。In addition, the image data collected by the TOF camera module is 3D face data. Compared with 2D face data, face recognition based on 3D face data is safer and more accurate.

在一种可能的实现方式中,发射器工作在第一电流值时发射的光信号为第一光强度,发射器工作在第二电流值时发射的光信号为第二光强度,第二电流值大于第一电流值。也就是说,发射器工作的电流值越大,发射器发射的光信号的光强度越大。In a possible implementation, the light signal emitted by the transmitter when it works at the first current value is the first light intensity, the light signal emitted by the transmitter when it works at the second current value is the second light intensity, and the second current value is greater than the first current value. That is to say, the greater the current value of the transmitter, the greater the light intensity of the optical signal emitted by the transmitter.

在一种可能的实现方式中,确定发射器是否处于正常工作状态包括:确定发射器的第一参数,第一参数用于指示发射器的工作状态;若第一参数用于指示发射器的工作状态为正常工作状态,确定发射器处于正常工作状态;若第一参数用于指示发射器的工作状态为异常工作状态,确定发射器处于异常工作状态。发射器的第一参数可以是发射器工作在第一电流值,发送第一光强度的光信号后生成的。In a possible implementation manner, determining whether the transmitter is in a normal working state includes: determining a first parameter of the transmitter, where the first parameter is used to indicate the working state of the transmitter; if the first parameter is used to indicate the working state of the transmitter If the state is a normal working state, it is determined that the transmitter is in a normal working state; if the first parameter is used to indicate that the working state of the transmitter is an abnormal working state, it is determined that the transmitter is in an abnormal working state. The first parameter of the transmitter may be generated after the transmitter operates at a first current value and sends an optical signal with a first light intensity.

在一种可能的实现方式中,方法还包括:在发射器处于异常工作状态的情况下,控制发射器以第三光强度工作,第三光强度为0;控制图像传感器采集图像数据;基于图像数据执行人脸识别。由于发射器处于异常工作状态,此时发射器可以不工作,这样可以避免出现由于发射器损坏导致发射出伤害人眼的光信号的问题。In a possible implementation, the method further includes: when the transmitter is in an abnormal working state, controlling the transmitter to work with a third light intensity, where the third light intensity is 0; controlling the image sensor to collect image data; The data performs face recognition. Since the transmitter is in an abnormal working state, the transmitter may not work at this time, so that the problem of emitting light signals that are harmful to human eyes due to damage to the transmitter can be avoided.

在一种可能的实现方式中,基于图像数据执行人脸识别包括:基于图像数据获取灰度图和深度图;基于灰度图进行人脸对比,基于深度图进行防伪检测,得到人脸识别结果。若人脸对比结果满足第一预设条件,防伪检测结果满足第二预设条件,可以认为人脸识别结果为成功,从而可以执行解锁等操作。In a possible implementation, performing face recognition based on image data includes: obtaining a grayscale image and a depth image based on the image data; performing face comparison based on the grayscale image, performing anti-counterfeiting detection based on the depth image, and obtaining a face recognition result . If the face comparison result satisfies the first preset condition and the anti-counterfeiting detection result satisfies the second preset condition, the face recognition result can be considered successful, and operations such as unlocking can be performed.

在一种可能的实现方式中,第一操作包括用于解锁电子设备的操作,用于在线支付的操作,用于录入人脸的操作,或者用于安全注册或登录应用程序的操作。第一操作例如可以是按压电源键、点击、滑动等操作,本申请不做限定。In a possible implementation manner, the first operation includes an operation for unlocking an electronic device, an operation for online payment, an operation for entering a face, or an operation for securely registering or logging into an application program. For example, the first operation may be an operation such as pressing a power button, clicking, or sliding, which is not limited in this application.

在一种可能的实现方式中,方法还包括:根据人脸识别结果确定是否执行解锁;若人脸识别结果为成功,则执行解锁;若人脸识别结果为失败,不执行解锁或显示解锁失败;或者根据人脸识别结果确定是否执行支付;若人脸识别结果为成功,则执行支付;若人脸识别结果为失败,不执行支付或显示支付失败;或者根据人脸识别结果确定是否执行人脸录入;若人脸识别结果为成功,则执行人脸录入;若人脸识别结果为失败,不执行人脸录入或显示人脸录入失败;或者根据人脸识别结果确定是否执行注册或登录;若人脸识别结果为成功,则执行注册或登录;若人脸识别结果为失败,不执行注册或登录或显示注册或登录失败。即本申请可以应用在支付或转账时(例如,用户在支付应用/理财应用/聊天应用/购物应用(例如,

Figure BDA0003207610360000021
)中进行支付或转账操作)的人脸识别,用户在安全注册或登录应用程序的人脸安全验证(例如,用户在
Figure BDA0003207610360000022
中进行注册或登录操作)等场景中,本申请不做限定。In a possible implementation, the method further includes: determining whether to perform unlocking according to the face recognition result; if the face recognition result is successful, performing unlocking; if the face recognition result is failure, not performing unlocking or displaying that unlocking failed ; Or determine whether to execute the payment according to the face recognition result; if the face recognition result is successful, execute the payment; if the face recognition result is a failure, do not execute the payment or display payment failure; Face registration; if the face recognition result is successful, face registration will be performed; if the face recognition result is a failure, face registration will not be performed or face registration failure will be displayed; or whether to perform registration or login is determined according to the face recognition result; If the face recognition result is successful, perform registration or login; if the face recognition result is failure, do not perform registration or login or display registration or login failure. That is, this application can be applied in payment or transfer (for example, the user is in the payment application/finance application/chat application/shopping application (for example,
Figure BDA0003207610360000021
), face recognition for payment or transfer operations in ), and face security verification for users to securely register or log in to the application (for example, users in
Figure BDA0003207610360000022
In scenarios such as registration or login operations in the middle, this application does not make limitations.

在一种可能的实现方式中,方法还包括:在发射器处于异常工作状态的情况下,向用户提示解锁失败;或者向用户提示支付失败;或者向用户提示人脸录入失败;或者向用户提示注册或登录失败。由于发射器处于异常工作状态,此时发射器不工作,因此无法成功识别人脸,但可以避免出现由于发射器损坏导致发射出伤害人眼的光信号的问题。In a possible implementation, the method further includes: when the transmitter is in an abnormal working state, prompting the user that the unlocking fails; or prompting the user that the payment fails; or prompting the user that the face registration fails; or prompting the user Registration or login failed. Because the transmitter is in an abnormal working state, the transmitter is not working at this time, so the face cannot be successfully recognized, but the problem of emitting light signals that are harmful to human eyes due to damage to the transmitter can be avoided.

在一种可能的实现方式中,电子设备包含相机硬件抽象层HAL和摄像头驱动模块,相机HAL包括传感器节点,控制发射器以第一光强度工作包括:传感器节点确定摄像头模组的工作模式为第一工作模式;第一工作模式用于指示发射器工作在第一电流值;传感器节点将第一工作模式的配置参数发送到摄像头驱动模块;摄像头驱动模块将第一工作模式的配置参数写入TOF摄像头模组的寄存器中;摄像头驱动模块向传感器节点发送配置参数写入完成的消息;响应于接收配置参数写入完成的消息,传感器节点向摄像头驱动模块发送第一启动命令;摄像头驱动模块向TOF摄像头模组发送第二启动命令;发射器以第一电流值工作,发射器以第一电流值工作时发射的光信号为第一光强度。这样,通过电子设备中的相机HAL(其中包括传感器节点)和摄像头驱动模块可以控制发射器以第一光强度工作。In a possible implementation, the electronic device includes a camera hardware abstraction layer HAL and a camera driver module, the camera HAL includes a sensor node, and controlling the transmitter to work with the first light intensity includes: the sensor node determines that the camera module works in the first mode One working mode; the first working mode is used to instruct the transmitter to work at the first current value; the sensor node sends the configuration parameters of the first working mode to the camera driver module; the camera driver module writes the configuration parameters of the first working mode into the TOF In the register of the camera module; the camera driver module sends a message that the configuration parameter is written to the sensor node; in response to receiving the message that the configuration parameter is written, the sensor node sends the first start command to the camera driver module; the camera driver module sends the TOF The camera module sends a second startup command; the transmitter works with the first current value, and the light signal emitted by the transmitter when it works with the first current value is the first light intensity. In this way, the transmitter can be controlled to work with the first light intensity through the camera HAL (including the sensor node) and the camera driving module in the electronic device.

在一种可能的实现方式中,电子设备还包括第一应用、人脸识别软件开发工具包SDK、人脸识别服务、人脸识别控制模块和相机服务,接收用户的第一操作之后,方法还包括:第一应用调用人脸识别SDK进行人脸识别;第一应用对应于第一操作,第一应用包括锁屏应用、购物应用、聊天应用或理财应用;人脸识别SDK向人脸识别服务发送人脸识别的请求;人脸识别的请求中携带人脸识别类型的标识、图像的分辨率大小和数据流格式;人脸识别服务向人脸识别控制模块发送人脸识别的请求;人脸识别控制模块根据人脸识别的请求匹配摄像头模组;人脸识别控制模块向相机服务发送打开摄像头模组的第一请求;打开摄像头模组的第一请求中携带安全标识、摄像头模组的标识ID、图像的分辨率和数据流格式;安全标识用于申请安全内存;相机服务向相机HAL发送打开摄像头模组的第二请求,第二请求中携带安全标识、摄像头模组的标识ID、图像的分辨率和数据流格式。这样,相机HAL中的传感器节点可以得到安全标识、摄像头模组的标识ID、图像的分辨率和数据流格式等信息,后续可以根据这些信息确定摄像头模组的工作模式。In a possible implementation manner, the electronic device further includes a first application, a face recognition software development kit SDK, a face recognition service, a face recognition control module, and a camera service. After receiving the user's first operation, the method further Including: the first application calls the face recognition SDK to perform face recognition; the first application corresponds to the first operation, and the first application includes a lock screen application, a shopping application, a chat application or a wealth management application; Send a face recognition request; the face recognition request carries the identity of the face recognition type, the resolution size of the image and the data stream format; the face recognition service sends the face recognition request to the face recognition control module; The recognition control module matches the camera module according to the face recognition request; the face recognition control module sends the first request to open the camera module to the camera service; the first request to open the camera module carries the security identification and the identification of the camera module ID, image resolution, and data stream format; the security ID is used to apply for secure memory; the camera service sends a second request to the camera HAL to open the camera module, and the second request carries the security ID, the ID of the camera module, and the image resolution and data stream format. In this way, the sensor nodes in the camera HAL can obtain information such as the security identification, the identification ID of the camera module, the resolution of the image, and the format of the data stream, and then determine the working mode of the camera module based on these information.

在一种可能的实现方式中,传感器节点确定摄像头模组的工作模式为第一工作模式,具体包括:传感器节点根据图像的分辨率、数据流格式和预设规则确定摄像头模组的工作模式为第一工作模式。这样,传感器节点可以确定出摄像头模组的工作模式为第一工作模式。In a possible implementation manner, the sensor node determines that the working mode of the camera module is the first working mode, which specifically includes: the sensor node determines that the working mode of the camera module is The first working mode. In this way, the sensor node can determine that the working mode of the camera module is the first working mode.

在一种可能的实现方式中,相机服务向相机HAL发送打开摄像头模组的第二请求之后,方法还包括:相机HAL根据摄像头模组的ID、图像的分辨率和数据流格式创建用于传输数据流和控制流的通路;相机HAL向相机服务返回创建通路的结果;创建通路的结果为成功;相机服务向人脸识别控制模块返回摄像头模组打开完成的消息;人脸识别控制模块向相机服务发送数据请求,数据请求用于获取数据流;相机服务调用相机HAL获取数据流。In a possible implementation, after the camera service sends the second request to the camera HAL to open the camera module, the method further includes: the camera HAL creates a file for transmission according to the camera module ID, image resolution, and data stream format. The path of data flow and control flow; the camera HAL returns the result of creating the path to the camera service; the result of creating the path is success; the camera service returns the message that the camera module is opened to the face recognition control module; the face recognition control module sends a message to the camera The service sends a data request, and the data request is used to obtain the data stream; the camera service calls the camera HAL to obtain the data stream.

在一种可能的实现方式中,发射器以第一电流值工作之后,方法还包括:图像传感器在第一工作模式对应的曝光时间内获取光信号;基于接收到的光信号,图像传感器获取第一图像数据。In a possible implementation manner, after the transmitter works at the first current value, the method further includes: the image sensor acquires an optical signal within the exposure time corresponding to the first working mode; based on the received optical signal, the image sensor acquires the second - image data.

在一种可能的实现方式中,图像传感器获取第一图像数据之后,方法还包括:图像传感器向发射器发送获取第一参数的请求;图像传感器从发射器接收第一参数;图像传感器基于第一图像数据和第一参数,得到第一原始RAW Data;第一参数用于指示发射器在第一电流值下的工作状态。In a possible implementation manner, after the image sensor acquires the first image data, the method further includes: the image sensor sends a request for acquiring the first parameter to the transmitter; the image sensor receives the first parameter from the transmitter; the image sensor receives the first parameter based on the first The image data and the first parameter are used to obtain the first original RAW Data; the first parameter is used to indicate the working state of the transmitter under the first current value.

在一种可能的实现方式中,电子设备还包括图像处理模块、第一内存和人脸识别TA,确定发射器是否处于正常工作状态包括:图像传感器基于第一图像数据和第一参数,得到第一原始RAW Data之后,图像传感器将第一RAW Data发送到图像处理模块;图像处理模块将第一RAW Data发送至第一内存中存储,第一内存对应第一FD;图像处理模块将第一FD发送至摄像头驱动模块;摄像头驱动模块将第一FD发送至相机HAL;响应于接收到第一FD,相机HAL向摄像头驱动模块发送读取第一参数的请求,第一参数用于指示发射器的工作状态;摄像头驱动模块从发射器的寄存器读取第一参数,并向相机HAL的传感器节点发送第一参数;相机HAL根据第一参数确定发射器是否处于正常工作状态。In a possible implementation manner, the electronic device further includes an image processing module, a first memory, and a face recognition TA, and determining whether the transmitter is in a normal working state includes: the image sensor obtains the first image data and the first parameter based on the first After the original RAW Data, the image sensor sends the first RAW Data to the image processing module; the image processing module sends the first RAW Data to the first memory for storage, and the first memory corresponds to the first FD; the image processing module sends the first FD Send to the camera driver module; the camera driver module sends the first FD to the camera HAL; in response to receiving the first FD, the camera HAL sends a request to read the first parameter to the camera driver module, and the first parameter is used to indicate the transmitter. Working state: the camera driver module reads the first parameter from the register of the transmitter, and sends the first parameter to the sensor node of the camera HAL; the camera HAL determines whether the transmitter is in a normal working state according to the first parameter.

在一种可能的实现方式中,相机HAL根据第一参数确定发射器是否处于正常工作状态,具体包括:若第一参数用于指示发射器的工作状态为正常工作状态,相机HAL确定发射器处于正常工作状态;若第一参数用于指示发射器的工作状态为异常工作状态,相机HAL确定发射器处于异常工作状态。这样,人脸识别可以根据第一RAW Data中的第一参数确定出发射器是否处于正常工作状态。In a possible implementation manner, the camera HAL determines whether the transmitter is in a normal working state according to the first parameter, which specifically includes: if the first parameter is used to indicate that the working state of the transmitter is a normal working state, the camera HAL determines that the transmitter is in a normal working state. Normal working state; if the first parameter is used to indicate that the working state of the transmitter is an abnormal working state, the camera HAL determines that the transmitter is in an abnormal working state. In this way, face recognition can determine whether the transmitter is in a normal working state according to the first parameter in the first RAW Data.

在一种可能的实现方式中,控制发射器以第二光强度工作,包括:若发射器的工作状态为正常工作状态,相机HAL确定摄像头模组的工作模式为第二工作模式,第二工作模式用于指示发射器工作在第二电流值;相机HAL将第二工作模式的配置参数发送到摄像头驱动模块;摄像头驱动模块将第二工作模式的配置参数写入TOF摄像头模组的寄存器中;摄像头驱动模块向传感器节点发送配置参数写入完成的消息;响应于接收配置参数写入完成的消息,传感器节点向摄像头驱动模块发送第三启动命令;摄像头驱动模块向TOF摄像头模组发送第四启动命令;发射器以第二电流值工作,发射器以第二电流值工作时发射的光信号为第二光强度。这样,相机HAL可以根据发射器的正常工作状态确定摄像头模组的工作模式为第二工作模式。通过电子设备中的相机HAL(其中包括传感器节点)和摄像头驱动模块可以控制发射器以第二光强度工作。In a possible implementation manner, controlling the transmitter to work with the second light intensity includes: if the working state of the transmitter is the normal working state, the camera HAL determines that the working mode of the camera module is the second working mode, and the second working mode The mode is used to indicate that the transmitter works at the second current value; the camera HAL sends the configuration parameters of the second working mode to the camera driver module; the camera driver module writes the configuration parameters of the second working mode into the register of the TOF camera module; The camera driver module sends a message that the configuration parameter writing is completed to the sensor node; in response to receiving the message that the configuration parameter is written, the sensor node sends the third startup command to the camera driver module; the camera driver module sends the fourth startup command to the TOF camera module command; the transmitter works with the second current value, and the light signal emitted when the transmitter works with the second current value is the second light intensity. In this way, the camera HAL can determine that the working mode of the camera module is the second working mode according to the normal working state of the transmitter. The transmitter can be controlled to work with the second light intensity through the camera HAL (including the sensor node) and the camera driver module in the electronic device.

在一种可能的实现方式中,发射器以第二电流值工作之后,控制图像传感器采集图像数据,具体包括:图像传感器在第二工作模式对应的曝光时间内获取光信号;基于接收到的光信号,图像传感器获取第二图像数据。In a possible implementation manner, after the transmitter works at the second current value, controlling the image sensor to collect image data specifically includes: the image sensor acquires the light signal within the exposure time corresponding to the second working mode; signal, the image sensor acquires the second image data.

在一种可能的实现方式中,图像传感器获取第二图像数据之后,方法还包括:图像传感器向发射器发送获取第二参数的请求;图像传感器从发射器接收第二参数;图像传感器基于第一图像数据和第二参数,得到第二RAW Data;第二参数用于指示发射器在第二电流值下的工作状态。In a possible implementation manner, after the image sensor acquires the second image data, the method further includes: the image sensor sends a request for acquiring the second parameter to the transmitter; the image sensor receives the second parameter from the transmitter; the image sensor based on the first The image data and the second parameter are used to obtain the second RAW Data; the second parameter is used to indicate the working state of the transmitter under the second current value.

在一种可能的实现方式中,电子设备还包括第二内存和人脸识别可信应用TA,基于图像数据执行人脸识别包括:图像传感器将第二RAW Data发送至图像处理模块;图像处理模块将第二RAW Data发送至第二内存中存储;第二内存对应第二FD;人脸识别TA根据第二FD从第二内存中读取第二RAW Data;人脸识别TA根据第二RAW Data中的图像数据获取第一灰度图和第一深度图;人脸识别TA根据第一灰度图进行人脸对比,根据第一深度图进行防伪检测,得到人脸识别结果。这样,人脸识别TA可以根据第二RAW Data确定出人脸识别结果。In a possible implementation, the electronic device further includes a second memory and a face recognition trusted application TA, and performing face recognition based on image data includes: the image sensor sends the second RAW Data to the image processing module; the image processing module Send the second RAW Data to the second memory for storage; the second memory corresponds to the second FD; the face recognition TA reads the second RAW Data from the second memory according to the second FD; the face recognition TA reads the second RAW Data according to the second RAW Data The first grayscale image and the first depth image are obtained from the image data in the image data; the face recognition TA performs face comparison according to the first grayscale image, and conducts anti-counterfeiting detection according to the first depth image to obtain the face recognition result. In this way, the face recognition TA can determine the face recognition result according to the second RAW Data.

在一种可能的实现方式中,图像处理模块将第二RAW Data发送至第二内存中存储之后,方法还包括:图像处理模块将第二FD发送至摄像头驱动模块;摄像头驱动模块将第二FD发送至相机HAL;相机HAL通过预设接口将第二FD发送至相机服务;相机服务将第二FD发送至人脸识别控制模块;人脸识别控制模块将第二FD发送至人脸识别TA。这样,人脸识别TA可以得到第二FD,从而可以根据第二FD读取第二RAW Data。In a possible implementation manner, after the image processing module sends the second RAW Data to the second memory for storage, the method further includes: the image processing module sends the second FD to the camera driver module; the camera driver module sends the second FD Send to the camera HAL; the camera HAL sends the second FD to the camera service through the preset interface; the camera service sends the second FD to the face recognition control module; the face recognition control module sends the second FD to the face recognition TA. In this way, the face recognition TA can obtain the second FD, so that the second RAW Data can be read according to the second FD.

在一种可能的实现方式中,方法还包括:人脸识别TA将人脸识别结果发送至人脸识别控制模块;人脸识别控制模块将人脸识别结果发送至人脸识别服务;人脸识别服务将人脸识别结果发送至人脸识别SDK;人脸识别SDK将人脸识别结果发送至第一应用;响应于接收人脸识别结果,第一应用执行解锁,人脸识别结果为成功。这样,当人脸识别结果为成功时,可以成功解锁。In a possible implementation, the method further includes: the face recognition TA sends the face recognition result to the face recognition control module; the face recognition control module sends the face recognition result to the face recognition service; The service sends the face recognition result to the face recognition SDK; the face recognition SDK sends the face recognition result to the first application; in response to receiving the face recognition result, the first application performs unlocking, and the face recognition result is successful. In this way, when the face recognition result is successful, it can be successfully unlocked.

在一种可能的实现方式中,在发射器处于异常工作状态的情况下,控制发射器以第三光强度工作,具体包括:响应于接收发射器的工作状态为异常工作状态,相机HAL确定摄像头模组的工作模式为第三工作模式,第三工作模式用于指示发射器工作在第三电流值,第三电流值为0;相机HAL将第三工作模式的配置参数发送到摄像头驱动模块;摄像头驱动模块将第三工作模式的配置参数写入TOF摄像头模组的寄存器中;摄像头驱动模块向传感器节点发送配置参数写入完成的消息;响应于接收配置参数写入完成的消息,传感器节点向摄像头驱动模块发送第五启动命令;摄像头驱动模块向TOF摄像头模组发送第六启动命令;发射器不工作。由于发射器处于异常工作状态,此时发射器不工作,可以避免出现由于发射器损坏导致发射出伤害人眼的光信号的问题。In a possible implementation manner, when the transmitter is in an abnormal working state, controlling the transmitter to work with the third light intensity specifically includes: in response to receiving that the working state of the transmitter is an abnormal working state, the camera HAL determines that the camera The working mode of the module is the third working mode, the third working mode is used to instruct the transmitter to work at the third current value, and the third current value is 0; the camera HAL sends the configuration parameters of the third working mode to the camera driver module; The camera driver module writes the configuration parameters of the third working mode into the register of the TOF camera module; the camera driver module sends a message that the configuration parameters are written to the sensor node; in response to receiving the message that the configuration parameters are written, the sensor node sends The camera driver module sends the fifth startup command; the camera driver module sends the sixth startup command to the TOF camera module; the transmitter does not work. Because the transmitter is in an abnormal working state, the transmitter does not work at this time, which can avoid the problem of emitting light signals that are harmful to human eyes due to damage to the transmitter.

在一种可能的实现方式中,发射器不工作之后,方法还包括:图像传感器在第三工作模式对应的曝光时间内接收光信号;基于接收到的光信号,图像传感器获取第三图像数据。In a possible implementation manner, after the transmitter does not work, the method further includes: the image sensor receives an optical signal within an exposure time corresponding to the third working mode; based on the received optical signal, the image sensor acquires third image data.

在一种可能的实现方式中,方法还包括:人脸识别TA基于第三图像数据获取第二灰度图和第二深度图;基于第二灰度图进行人脸对比,基于第二深度图进行防伪检测,得到人脸识别结果为失败。由于发射器不工作(不通电、不发光)时,图像传感器得到的图像数据(第三图像数据)通常是无清晰人脸图像的“黑图”,因此人脸识别结果为失败。In a possible implementation manner, the method further includes: the face recognition TA acquires a second grayscale image and a second depth image based on the third image data; performing face comparison based on the second grayscale image, and Perform anti-counterfeiting detection, and the face recognition result is failed. Since the transmitter is not working (no electricity, no light), the image data (third image data) obtained by the image sensor is usually a "black image" without a clear face image, so the face recognition result is a failure.

在一种可能的实现方式中,方法还包括:人脸识别TA将人脸识别结果发送至人脸识别控制模块;人脸识别控制模块将人脸识别结果发送至人脸识别服务;人脸识别服务将人脸识别结果发送至人脸识别SDK;人脸识别SDK将人脸识别结果发送至第一应用;响应于接收人脸识别结果,第一应用不执行解锁或显示解锁失败,人脸识别结果为失败。由于发射器处于异常工作状态,此时发射器不工作,因此人脸识别结果为失败,从而解锁失败,但这样可以避免出现由于发射器损坏导致发射出伤害人眼的光信号的问题。In a possible implementation, the method further includes: the face recognition TA sends the face recognition result to the face recognition control module; the face recognition control module sends the face recognition result to the face recognition service; The service sends the face recognition result to the face recognition SDK; the face recognition SDK sends the face recognition result to the first application; in response to receiving the face recognition result, the first application does not perform unlocking or displays that the unlocking failed, and the face recognition The result is failure. Because the transmitter is in an abnormal working state, the transmitter is not working at this time, so the face recognition result is a failure, and thus the unlocking fails, but this can avoid the problem of emitting light signals that are harmful to human eyes due to damage to the transmitter.

第二方面,本申请提供一种芯片系统,该芯片系统包括一个或多个接口电路和一个或多个处理器。该接口电路和处理器通过线路互联。上述芯片系统可以应用于包括通信模块和存储器的电子设备。该接口电路用于从电子设备的存储器接收信号,并向处理器发送接收到的信号,该信号包括存储器中存储的计算机指令。当处理器执行该计算机指令时,电子设备可以执行如第一方面及其任一种可能的设计方式所述的方法。In a second aspect, the present application provides a chip system, which includes one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected by wires. The system-on-a-chip described above can be applied to an electronic device including a communication module and a memory. The interface circuit is for receiving signals from the memory of the electronic device and sending the received signals to the processor, the signals including computer instructions stored in the memory. When the processor executes the computer instruction, the electronic device can execute the method described in the first aspect and any possible design manner thereof.

第三方面,本申请提供一种计算机可读存储介质,该计算机可读存储介质包括计算机指令。当计算机指令在电子设备(如手机)上运行时,使得该电子设备执行如第一方面及其任一种可能的设计方式所述的方法。In a third aspect, the present application provides a computer-readable storage medium, where the computer-readable storage medium includes computer instructions. When the computer instructions are run on the electronic device (such as a mobile phone), the electronic device is made to execute the method described in the first aspect and any possible design manner thereof.

第四方面,本申请提供一种计算机程序产品,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如第一方面及其任一种可能的设计方式所述的方法。In a fourth aspect, the present application provides a computer program product. When the computer program product runs on a computer, the computer executes the method described in the first aspect and any possible design manner thereof.

第五方面,本申请实施例提供了一种人脸识别装置,包括处理器,处理器和存储器耦合,存储器存储有程序指令,当存储器存储的程序指令被处理器执行时使得所述装置实现上述第一方面及其任一种可能的设计方式所述的方法。所述装置可以为电子设备或服务器设备;或可以为电子设备或服务器设备中的一个组成部分,如芯片。In the fifth aspect, the embodiment of the present application provides a face recognition device, including a processor, the processor is coupled to a memory, and the memory stores program instructions, and when the program instructions stored in the memory are executed by the processor, the device realizes the above-mentioned The method described in the first aspect and any possible design manner thereof. The apparatus may be an electronic device or a server device; or may be a component of the electronic device or the server device, such as a chip.

第六方面,本申请实施例提供了一种人脸识别装置,所述装置可以按照功能划分为不同的逻辑单元或模块,各单元或模块执行不同的功能,以使得所述装置执行上述第一方面及其任一种可能的设计方式所述的方法。In the sixth aspect, the embodiment of the present application provides a face recognition device. The device can be divided into different logical units or modules according to functions, and each unit or module performs different functions, so that the device can perform the above-mentioned first The method described in the aspect and any possible design manner thereof.

可以理解地,上述提供的第二方面所述的芯片系统,第三方面所述的计算机可读存储介质,第四方面所述的计算机程序产品及第五方面、第六方面所述的装置所能达到的有益效果,可参考如第一方面及其任一种可能的设计方式中的有益效果,此处不再赘述。It can be understood that the chip system described in the second aspect provided above, the computer-readable storage medium described in the third aspect, the computer program product described in the fourth aspect, and the devices described in the fifth aspect and the sixth aspect provide For the beneficial effects that can be achieved, reference can be made to the beneficial effects in the first aspect and any possible design manner thereof, and details will not be repeated here.

附图说明Description of drawings

图1为本申请实施例提供的一种电子设备的结构示意图;FIG. 1 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;

图2为本申请实施例提供的一种TOF成像技术的原理示意图;Fig. 2 is a schematic diagram of the principle of a TOF imaging technology provided by the embodiment of the present application;

图3为本申请实施例提供的一种软件模块架构示意图;FIG. 3 is a schematic diagram of a software module architecture provided by an embodiment of the present application;

图4为本申请实施例提供的一种软件模块间的交互示意图;FIG. 4 is a schematic diagram of interaction between software modules provided by an embodiment of the present application;

图5为本申请实施例提供的又一种软件模块间的交互示意图;Fig. 5 is another schematic diagram of interaction between software modules provided by the embodiment of the present application;

图6为本申请实施例提供的一种信号交互示意图;FIG. 6 is a schematic diagram of signal interaction provided by an embodiment of the present application;

图7为本申请实施例提供的一种显示示意图;FIG. 7 is a schematic display diagram provided by an embodiment of the present application;

图8为本申请实施例提供的又一种显示示意图;FIG. 8 is another schematic display diagram provided by the embodiment of the present application;

图9为本申请实施例提供的又一种显示示意图;FIG. 9 is another schematic display diagram provided by the embodiment of the present application;

图10为本申请实施例提供的又一种信号交互示意图;FIG. 10 is another schematic diagram of signal interaction provided by the embodiment of the present application;

图11为本申请实施例提供的一种芯片结构示意图。FIG. 11 is a schematic diagram of a chip structure provided by an embodiment of the present application.

具体实施方式Detailed ways

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。其中,在本申请的描述中,除非另有说明,“至少一个”是指一个或多个,“多个”是指两个或多于两个。另外,为了便于清楚描述本申请实施例的技术方案,在本申请的实施例中,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. Wherein, in the description of the present application, unless otherwise specified, "at least one" refers to one or more, and "multiple" refers to two or more than two. In addition, in order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with basically the same function and effect. Those skilled in the art can understand that words such as "first" and "second" do not limit the number and execution order, and words such as "first" and "second" do not necessarily limit the difference.

为了下述各实施例的描述清楚简洁,首先给出相关概念或技术的简要介绍:In order to make the description of the following embodiments clear and concise, a brief introduction of related concepts or technologies is given first:

通用运行环境(rich execution environment,REE),也可以称为富执行环境或普通执行环境或不可信执行环境,是指移动端的系统运行环境,其中可以运行Android、IOS和Linux等操作系统。REE的开放和扩展性好但安全性不高。Rich execution environment (REE), also known as rich execution environment, common execution environment or untrusted execution environment, refers to the system operating environment of the mobile terminal, in which operating systems such as Android, IOS, and Linux can run. REE has good openness and scalability but not high security.

可信执行环境(trusted execution environment,TEE),也可以称安全侧或安全区,是需要授权才能访问的区域。TEE与REE共存于电子设备中的运行环境,其通过硬件的支撑,实现与REE的隔离,具有安全能力并且能够抵御常规REE侧易遭受的软件攻击。TEE有自身的运行空间,定义了严格的保护措施,因此,比REE的安全级别更高,能够保护TEE中的资产(assets),如数据,软件等,免受软件攻击,抵抗特定类型的安全威胁。A trusted execution environment (TEE), also called a secure side or a secure zone, is an area that requires authorization to access. TEE and REE coexist in the operating environment of electronic equipment. It is isolated from REE through hardware support, has security capabilities, and can resist software attacks that conventional REEs are vulnerable 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 (assets) in TEE, such as data, software, etc., from software attacks and resist specific types of security. threaten.

REE+TEE架构,是指通过TEE与REE结合共同为应用提供服务的架构。也就是说,TEE与REE共同存在于电子设备中。示例性的,TEE通过硬件的支撑,可实现与REE相隔离的运行机制。TEE有自身的运行空间,比REE的安全级别更高,能够保护TEE中的资产(如数据,软件等)免受软件攻击。只有授权的安全软件才能在TEE中执行,同时它也保护了安全软件的资源和数据的机密性。相比REE,由于其隔离和权限控制等保护机制,TEE能够更好的保护数据和资源的安全性。The REE+TEE architecture refers to the architecture that provides services for applications through the combination of TEE and REE. That is to say, TEE and REE co-exist in electronic equipment. Exemplarily, the TEE can implement an operating mechanism isolated from the REE through the support of hardware. TEE has its own operating space and has a higher security level than REE, which 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 resources and data of 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.

TA,即可信应用,是运行在TEE中的应用,能够为运行在TEE之外的CA提供安全服务,如输入密码,生成交易签名,人脸识别等。TA, that is, a trusted application, is an application running in the TEE, which can provide security services for the CA running outside the TEE, such as entering passwords, generating transaction signatures, face recognition, etc.

CA,即客户端应用。CA通常指运行在REE中的应用。CA可以通过客户端(Client)应用程序编程接口(application programming interface,API)对TA进行调用并指示TA执行相应的安全操作。CA, the client application. CA usually refers to the application running in REE. The CA can call the TA through a client (Client) application programming interface (application programming interface, API) and instruct the TA to perform corresponding security operations.

软件开发工具包(software development kit,SDK):广义上指辅助开发某一类软件的相关文档、范例和工具的集合。Software development kit (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.

RAW Data,即原始数据,可以理解为“未经加工和未经压缩的数据”。本申请实施例中,RAW Data可以是指TOF摄像头将捕捉到的光源信号转化为数字信号的原始数据。RAWData中还记录有相机拍摄所产生的一些元数据(Metadata)。RAW Data, that is, 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 camera converts the captured light source signal into a digital signal. Some metadata (Metadata) generated by camera shooting is also recorded in RAWData.

元数据,又可以称为中介数据、中继数据,是用于描述数据的数据(data aboutdata),主要是描述数据属性(property)的信息。本申请实施例中,Metadata可以指示摄像头的工作模式,打光电流值大小,TOF摄像头器件工作状态、曝光值等信息。Metadata, also known as intermediary data or relay data, is data used to describe data (data about data), mainly information describing data attributes (property). In the embodiment of the present application, the Metadata can indicate the working mode of the camera, the value of the photoelectric current, the working status of the TOF camera device, the exposure value and other information.

TOF摄像头(TOF摄像头模组),可以包括发射器(TX)和接收器(RX),TX用于发射红外光或激光脉冲,RX用于接收反射光并成像。由于TX可以自主发射光信号用于成像,因此TOF图像不受环境中大多数光线的影响,这样,将TOF图像应用在解锁业务中,能够提高人脸识别的安全性。The TOF camera (TOF camera module) can include a transmitter (TX) and a receiver (RX). TX is used to emit infrared light or laser pulses, and RX is used to receive reflected light and image it. Since the TX can autonomously emit light signals for imaging, TOF images are not affected by most light in the environment. In this way, the application of TOF images in unlocking services can improve the security of face recognition.

飞行时间(time of flight,TOF)成像技术,是指由一组人眼看不到的红外光(或激光脉冲)向外发射,遇到物体后反射,反射到摄像头结束,计算从发射到反射回摄像头的时间差或相位差,并将数据收集起来,形成一组距离深度数据,从而得到一个立体的3D模型的成像技术。也即,TOF成像技术是在传统的2D XY轴的成像基础上,加入来自Z轴方向的深度信息,最终生成3D的图像信息。Time of flight (TOF) imaging technology refers to a group of infrared light (or laser pulses) invisible to the human eye that is emitted outwards, reflected after encountering an object, reflected to the end of the camera, and calculated from emission to reflection. The time difference or phase difference of the camera, and the data are collected to form a set of distance and depth data, so as to obtain a three-dimensional 3D model imaging technology. That is to say, TOF imaging technology is based on the traditional 2D XY axis imaging, adding depth information from the Z axis direction, and finally generating 3D image information.

采用TOF成像技术时,需要向人脸投射红外光、激光等,为了人眼的安全,需要对TX发射的光的光功率进行检测,以保证在人眼安全范围内,避免TX发射的光信号伤害人眼。When using TOF imaging technology, it is necessary to project infrared light, laser, etc. to the face. For the safety of human eyes, it is necessary to detect the optical power of the light emitted by TX to ensure that the optical signal emitted by TX is within the safe range of human eyes. Injury to the human eye.

本申请实施例提供一种人脸识别方法,使用TOF摄像头采集图像,TOF摄像头可以先工作在人眼安全模式以确定TX是否异常,若TX正常工作,可以正常使用TOF摄像头采集图像,这样能够保证TX发射的光的光功率在人眼安全范围内。若TX异常,可以关闭TX,以避免TX发射的光信号伤害人眼。The embodiment of the present application provides a face recognition method, which uses a TOF camera to collect images. The TOF camera can first work in the eye-safe mode to determine whether the TX is abnormal. If the TX works normally, the TOF camera can be used to collect images normally, which can ensure The optical power of the light emitted by the TX is within the range of human eye safety. If TX is abnormal, TX can be turned off to avoid the optical signal emitted by TX from hurting human eyes.

图1为本申请实施例提供的一种电子设备100的结构示意图。FIG. 1 is a schematic structural diagram of an electronic device 100 provided in an embodiment of the present application.

如图1所示,电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。As shown in FIG. 1 , the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charging management module 140, a power management module 141, and a battery 142 , antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193 , a display screen 194, and a subscriber identification module (subscriber identification module, SIM) card interface 195, etc.

其中,传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。Among them, the sensor module 180 may include a pressure sensor 180A, a gyro 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 environmental Light sensor 180L, bone conduction sensor 180M, etc.

可以理解的是,本实施例示意的结构并不构成对电子设备100的具体限定。在另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structure shown 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, or combine certain components, or separate certain components, or arrange different components. The illustrated components can be realized in hardware, software or a combination of software and hardware.

处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processingunit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (graphics processing unit, GPU), an image signal processor ( image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU), etc. . Wherein, different processing units may be independent devices, or may be integrated in one or more processors.

控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The controller may be the nerve center and command center of the electronic device 100 . The controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.

处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated access is avoided, and the waiting time of the processor 110 is reduced, thereby improving the efficiency of the system.

在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuitsound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purposeinput/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。In some embodiments, processor 110 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuitsound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver (universal asynchronous receiver) /transmitter, UART) interface, mobile industry processor interface (mobile industry processor interface, MIPI), general-purpose input and output (general-purpose input/output, GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and/or A universal serial bus (universal serial bus, USB) interface, etc.

可以理解的是,本实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules shown in this embodiment is only for schematic illustration, and does not constitute a structural limitation of the electronic device 100 . In other embodiments, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

充电管理模块140用于从充电器接收充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备供电。The charging management module 140 is configured to receive a charging input from a charger. While the charging management module 140 is charging the battery 142 , it can also provide power for electronic devices through the power management module 141 .

电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,外部存储器,显示屏194,摄像头193,和无线通信模块160等供电。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 . The power management module 141 receives the input from the battery 142 and/or the charging management module 140 to provide power for the processor 110 , the internal memory 121 , the external memory, the display screen 194 , the camera 193 , and the wireless communication module 160 . In some other embodiments, the power management module 141 may also be disposed in the processor 110 . In some other embodiments, the power management module 141 and the charging management module 140 may also be set in the same device.

电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。The wireless communication function of the electronic device 100 can be realized by the antenna 1 , the antenna 2 , the mobile communication module 150 , the wireless communication module 160 , a modem processor, a baseband processor, and the like.

天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: Antenna 1 can be multiplexed as a diversity antenna of a wireless local area network.

移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。The mobile communication module 150 can provide wireless communication solutions including 2G/3G/4G/5G applied on the electronic device 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA) and the like. The mobile communication module 150 can receive electromagnetic waves through the antenna 1, filter and amplify the received electromagnetic waves, and send them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signals modulated by the modem processor, and convert them into electromagnetic waves through the antenna 1 for radiation.

调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。A modem processor may include a modulator and a demodulator. Wherein, the modulator is used for modulating the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator sends the demodulated low-frequency baseband signal to the baseband processor for processing. The low-frequency baseband signal is passed to the application processor after being processed by the baseband processor. The application processor outputs sound signals through audio equipment (not limited to speaker 170A, receiver 170B, etc.), or displays images or videos through display screen 194 .

无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wirelesslocal area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (wireless local area networks, WLAN) (such as wireless fidelity (wireless fidelity, Wi-Fi) network), bluetooth (bluetooth, BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency-modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 . The wireless communication module 160 can also receive the signal to be sent from the processor 110 , frequency-modulate it, amplify it, and convert it into electromagnetic waves through the antenna 2 for radiation.

在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络以及其他设备通信。所述无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(codedivision multiple access,CDMA),宽带码分多址(wideband code division multipleaccess,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。所述GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidounavigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellitesystem,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。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 (general packet radio service, GPRS), code division multiple access (codedivision multiple access, CDMA), wideband code Wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM , and/or IR technology, etc. The GNSS may include a global positioning system (global positioning system, GPS), a global navigation satellite system (global navigation satellite system, GLONASS), a Beidou satellite navigation system (beidounavigation satellite system, BDS), a quasi-zenith satellite system (quasi- zenith satellite system (QZSS) and/or satellite based augmentation systems (SBAS).

电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 realizes the display function through the GPU, the display screen 194 , and the application processor. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

显示屏194用于显示图像,视频等。该显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),发光二极管(light-emitting diode,LED),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。The display screen 194 is used to display images, videos and the like. The display screen 194 includes a display panel. The display panel can adopt liquid crystal display (liquid crystal display, LCD), light-emitting diode (light-emitting diode, LED), organic light-emitting diode (organic light-emitting diode, OLED), active matrix organic light-emitting diode or active matrix Organic light-emitting diode (active-matrix organic light emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED )wait.

电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。ISP用于处理摄像头193反馈的数据。摄像头193用于捕获静态图像或视频。数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。The electronic device 100 can realize the shooting function through the ISP, the camera 193 , the video codec, the GPU, the display screen 194 and the application processor. The ISP is used for processing the data fed back by the camera 193 . Camera 193 is used to capture still images or video. Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in various encoding formats, for example: moving picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

摄像头193可以包括1~N个。例如电子设备可以包括2个前置摄像头和4个后置摄像头。其中,前置摄像头中可以包括TOF摄像头。TOF摄像头包括TX和RX,TX可以用于发射光信号(红外光或激光脉冲),RX可以用于接收成像。TX例如可以为红外光发射器。RX例如可以为互补金属氧化物半导体(complementary metal oxide semiconductor,CMOS)或者电荷耦合器件(charge coupled device,CCD)图像感应器。The cameras 193 may include 1 to N number. For example, an electronic device may include 2 front cameras and 4 rear cameras. Wherein, the front camera may include a TOF camera. The TOF camera includes TX and RX, TX can be used to transmit optical 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.

示例性的,如图2中的(a)所示,可以通过TOF摄像头的光发射器(Tx)向被测目标(例如,用户)连续发送光信号(红外光或激光脉冲),在TOF摄像头的传感器端(Rx)接收被测目标返回的光信号,如图2中的(b)所示,根据发射和接收光信号的相位差(延迟)可以得到被测目标的深度信息。Exemplarily, as shown in (a) in Figure 2, the light signal (infrared light or laser pulse) can be continuously sent to the target (for example, user) through the optical transmitter (Tx) of the TOF camera, and the TOF camera The sensor end (Rx) of the sensor receives the light signal returned by the measured target, as shown in (b) in Figure 2, and the depth information of the measured target can be obtained according to the phase difference (delay) of the transmitted and received light signals.

其中,Tx和Rx可以通过总线进行信息交互。例如,Rx可以通过总线(例如,串行外设接口(Serial Peripheral Interface,SPI)总线)向Tx发送配置参数,该配置参数用于指示Tx对应的寄存器的地址和针对该寄存器的值。例如Tx对应的寄存器的地址可以是0x11,0x11对应的存储空间中可以存储电流值。Tx可以基于相应的配置参数工作在相应电流值下从而发射出相应光强度的光信号。Rx可以基于发射器发出的相应强度的光信号的反射光获取相应的图像数据。需要说明的是,Tx工作在不同的电流值下,可以发射出不同光强度的光信号。例如,Tx工作在第一电流值下,可以发射出第一光强度的光信号。Tx工作在第二电流值下,可以发射出第二光强度的光信号。第二电流值大于第一电流值。第二光强度大于第一光强度。Rx基于不同强度的光信号的反射光获取的图像数据也是不同的。例如,当Tx工作在第一电流值下,发射出第一光强度的光信时,Rx在相应的曝光时间内获取第一图像数据;Tx工作在第二电流值下,发射出第二光强度的光信号时,Rx在相应的曝光时间内获取第二图像数据;第二图像数据与第一图像数据不同。Among them, Tx and Rx can exchange information through the bus. For example, Rx may send a configuration parameter to Tx through a bus (for example, a serial peripheral interface (Serial Peripheral Interface, SPI) bus), where the configuration parameter is 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 may be 0x11, and the storage space corresponding to 0x11 may store the current value. Tx can work at a corresponding current value based on a corresponding configuration parameter so as to emit an optical signal with a corresponding light intensity. Rx can acquire corresponding image data based on the reflected light of the light signal of corresponding intensity emitted by the transmitter. It should be noted that the Tx can emit light signals with different light intensities when working at different current values. For example, Tx works at the first current value and can emit an optical signal with the first light intensity. Tx works at the second current value, and can emit an optical signal with a second optical intensity. The second current value is greater than the first current value. The second light intensity is greater than the first light intensity. The image data acquired by the Rx based on the reflected light of the light signal with different intensities is also different. For example, when Tx works at the first current value and emits an optical signal of the first light intensity, Rx acquires the first image data within the corresponding exposure time; Tx works at the second current value and emits the second light intensity When the optical signal is light, Rx acquires the second image data within the corresponding exposure time; the second image data is different from the first image data.

Tx工作在相应电流值下时,可以判断自身的工作状态,工作状态可以是正常或异常。Rx可以通过总线向Tx请求Tx的工作状态,Tx可以通过总线向Rx反馈自身的工作状态(例如,正常or异常),从而Rx可以获取Tx的工作状态。Rx可以将Tx的工作状态和自身的工作状态以及两者的工作模式打包在第一数据包(例如,Metadata)中。Rx还可以将Metadata和基于反射光获取的图像数据打包在第二数据包(例如,RAW Data)中。When Tx works under the corresponding current value, it can judge its own working state, which can be normal or abnormal. Rx can request the working state of Tx to Tx through the bus, and Tx can feed back its own working state (for example, normal or abnormal) to Rx through the bus, so that Rx can obtain the working state of Tx. Rx may pack the working status of Tx, its own working status and the working modes of both into the first data packet (for example, Metadata). Rx may also pack Metadata and image data obtained based on reflected light into a second data packet (for example, RAW Data).

NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。The NPU is a neural-network (NN) computing processor. By referring to the structure of biological neural networks, such as the transfer mode between neurons in the human brain, it can quickly process input information and continuously learn by itself. Applications such as intelligent cognition of the electronic device 100 can be realized through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.

外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。内部存储器121可以用于存储计算机可执行程序代码,所述可执行程序代码包括指令。处理器110通过运行存储在内部存储器121的指令,从而执行电子设备100的各种功能应用以及数据处理。例如,在本申请实施例中,处理器110可以通过执行存储在内部存储器121中的指令,内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 . The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. Such as saving music, video and other files in the external memory card. The internal memory 121 may be used to store computer-executable program codes including instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by executing instructions stored in the internal memory 121 . For example, in the embodiment of the present application, the processor 110 may execute instructions stored in the internal memory 121, and the internal memory 121 may include a program storage area and a data storage area. Wherein, the stored program area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.) and the like. The storage data area can store data created during the use of the electronic device 100 (such as audio data, phonebook, etc.) and the like. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (universal flash storage, UFS) and the like.

电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 can implement audio functions through the audio module 170 , the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. Such as music playback, recording, etc.

音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。耳机接口170D用于连接有线耳机。The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal. The audio module 170 may also be used to encode and decode audio signals. Speaker 170A, also referred to as a "horn", is used to convert audio electrical signals into sound signals. Receiver 170B, also called "earpiece", is used to convert audio electrical signals into sound signals. The microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. The earphone interface 170D is used for connecting wired earphones.

按键190包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。SIM卡接口195用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或N个SIM卡接口,N为大于1的正整数。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。The keys 190 include a power key, a volume key and the like. The key 190 may be a mechanical key. It can also be a touch button. The electronic device 100 can receive key input and generate key signal input related to user settings and function control of the electronic device 100 . The motor 191 can generate a vibrating reminder. The motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. The indicator 192 can be an indicator light, and can be used to indicate charging status, power change, and can also be used to indicate messages, missed calls, notifications, and the like. The SIM card interface 195 is used for connecting a SIM card. The SIM card can be connected and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195 . The electronic device 100 may support 1 or N SIM card interfaces, where N is a positive integer greater than 1. SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on.

以下实施例中的方法均可以在具有上述硬件结构的电子设备100中实现。The methods in the following embodiments can all be implemented in the electronic device 100 having the above hardware structure.

上述电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。The software system of the above-mentioned electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the software structure of the electronic device 100 is exemplarily described by taking an Android system with a layered architecture as an example.

分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过接口通信。在一些实施例中,Android系统可以包括应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,硬件抽象层(hardware abstraction layer,HAL)以及内核层。需要说明的是,本申请实施例以Android系统举例来说明,在其他操作系统中(例如鸿蒙系统,IOS系统等),只要各个功能模块实现的功能和本申请的实施例类似也能实现本申请的方案。The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate with each other through interfaces. In some embodiments, the Android system may include an application program layer, an application program framework layer, an Android runtime (Android runtime) and a system library, a hardware abstraction layer (hardware abstraction layer, HAL) and a kernel layer. It should be noted that the embodiment of the present application is illustrated with the Android system as an example. In other operating systems (such as Hongmeng system, IOS system, etc.), as long as the functions realized by each functional module are similar to the embodiments of the present application, the present application can also be implemented. scheme.

其中,应用程序层可以包括一系列应用程序包。Wherein, the application program layer may include a series of application program packages.

如图3所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息、锁屏应用、设置应用等应用程序。当然,应用程序层还可以包括其他应用程序包,例如支付应用,购物应用、银行应用等,本申请不做限定。As shown in FIG. 3 , the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, lock screen application, and setting application. Of course, the application layer may also include other application packages, such as payment applications, shopping applications, bank applications, etc., which are not limited in this application.

其中,设置应用具有录入人脸的功能,该录入的人脸用于人脸解锁。锁屏应用具有响应于用户的解锁操作(例如,按压电源键)进行解锁的功能。锁屏应用可以进行人脸解锁、指纹解锁、密码解锁等解锁处理,本申请实施例主要以人脸解锁为例进行说明。Wherein, the setting application has a function of recording a face, and the recorded face is used for face unlocking. The lock screen application has a function of unlocking in response to a user's unlocking operation (for example, pressing a power key). The screen lock application can perform unlocking processes such as face unlocking, fingerprint unlocking, and password unlocking. This embodiment of the present application mainly uses face unlocking as an example for illustration.

应用程序框架层为应用程序层的应用程序提供应用编程接口(applicationprogramming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。例如可以包括活动管理器、窗口管理器,内容提供器,视图系统,资源管理器,通知管理器,相机服务(Camera Service)和人脸识别服务等,本申请实施例对此不做任何限制。The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications 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 (Camera Service) and a face recognition service, etc., which are not limited in this embodiment of the present application.

系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),OpenGL ES,SGL等。A system library can include multiple function modules. For example: surface manager (surface manager), media library (Media Libraries), OpenGL ES, SGL, etc.

表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.

媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。The media library supports playback and recording of various commonly used audio and video formats, as well as still 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用于实现三维图形绘图,图像渲染,合成,和图层处理等。OpenGL ES is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

SGL是2D绘图的绘图引擎。SGL is a graphics engine for 2D graphics.

安卓运行时(Android Runtime)包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。Android Runtime (Android Runtime) includes core library and virtual machine. The Android runtime is responsible for the scheduling and management of the Android system. The core library consists of two parts: one part is the function function that the java language needs to call, and the other part is the core library of Android. The application layer and the application framework layer run in virtual machines. The virtual machine executes the java files of the application program layer and the application program framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

HAL层是对Linux内核驱动程序的封装,向上提供接口,屏蔽低层硬件的实现细节。The HAL layer is the encapsulation of the Linux kernel driver, provides an interface upwards, and shields the implementation details of the low-level hardware.

HAL层中可以包括Wi-Fi HAL,音频(audio)HAL,相机HAL(Camera HAL)和人脸识别控制模块(Face CA)等。The HAL layer can include Wi-Fi HAL, audio (audio) HAL, camera HAL (Camera HAL) and face recognition control module (Face CA), etc.

其中,相机HAL是Camera的核心软件框架,相机HAL中可以包括传感器节点(sensornode)和图像前处理(image front end,IFE)节点(IFE node)。传感器节点和IFE节点是相机HAL创建的图像数据和控制指令传输通路(也可以称为传输管道)中的组件(节点)。Wherein, the camera HAL is the core software framework of the Camera, and the camera HAL may include a sensor node (sensornode) and an image front end (image front end, IFE) node (IFE node). The sensor node and the IFE node are the components (nodes) in the image data and control instruction transmission path (also called the transmission pipeline) created by the camera HAL.

人脸识别控制模块是人脸识别的核心软件框架/应用。The face recognition control module is the core software framework/application of face recognition.

人脸可信应用(Face Trusted Application,Face TA):运行在TEE环境下的用于人脸识别的应用。本申请实施例中,将Face TA称为人脸识别TA。Face Trusted Application (Face TA): an application for face recognition running in the TEE environment. In this embodiment of the present application, Face TA is referred to as a face recognition TA.

内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。The kernel layer is the layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver.

其中,摄像头驱动是Camera器件的驱动层,主要负责和硬件的交互。Among them, the camera driver is the driver layer of the Camera device, which is mainly responsible for the interaction with the hardware.

硬件层包括显示器、TOF摄像头、IFE模块和安全内存(Secure Buffer)等。The hardware layer includes display, TOF camera, IFE module and secure memory (Secure Buffer), etc.

其中,安全内存是指具有安全保护功能的内存,可以用于存放TOF摄像头采集的raw data。Among them, the secure memory refers to the memory with security protection function, which can be used to store the raw data collected by the TOF camera.

TOF摄像头,也可以称为TOF传感器(TOF sensor),可以包括发射器(TX)和接收器(RX),TX用于发射红外光或激光脉冲,RX用于接收反射光并成像。A TOF camera, also known as a TOF sensor (TOF sensor), can include a transmitter (TX) and a receiver (RX). TX is used to emit infrared light or laser pulses, and RX is used to receive reflected light and image it.

IFE模块(IFE-Lite):可以称为图像前处理模块,可以用于转发图像数据,转发过程中不对图像数据进行处理。IFE module (IFE-Lite): It can be called an image pre-processing module, which can be used to forward image data, and the image data is not processed during the forwarding process.

下面对本申请实施例提供的人脸识别方法所涉及的软件模块和模块间的交互进行说明。如图4所示,应用层中的锁屏应用可以与人脸识别SDK交互,人脸识别SDK可以通过调用预设的应用程序接口(application programming interface,API)接口与框架层中的人脸识别服务交互,人脸识别服务可以与HAL层中的人脸识别控制模块交互,人脸识别控制模块可以通过框架层中的相机服务与HAL层中的相机HAL交互,或者,人脸识别控制模块可以直接与HAL层中的相机HAL交互。相机HAL中可以包括传感器节点和IFE节点。传感器节点可以与内核层中的摄像头驱动模块交互,摄像头驱动模块可以用于驱动硬件层中的TOF摄像头以默认的工作模式(例如,人眼安全模式,具体可以参见下文S112中的说明)采集图像数据。IFE模块可以将TOF摄像头采集的图像数据存储至安全内存中。TOF摄像头采集的图像数据在安全内存中的存储位置,可以使用文件描述符(file descriptor,FD)表示。IFE模块可以将图像数据的FD(例如,FD1)发送至摄像头驱动模块,摄像头驱动模块可以将FD1传递到相机HAL的IFE节点,IFE节点接收到FD1后,可以将FD1传递到相机HAL的传感器节点,传感器节点接收到FD1后,触发读取TOF摄像头工作状态的流程。即传感器节点可以通过摄像头驱动模块读取TOF摄像头的工作状态寄存器(即用于存储TOF摄像头的工作状态的寄存器),根据工作状态寄存器的值确定人眼安全检测结果,并根据人眼安全检测结果切换TOF摄像头的工作模式。TOF摄像头的工作模式切换后,相机HAL可以继续与摄像头驱动模块交互,使得摄像头驱动模块可以驱动TOF摄像头以切换后的工作模块(例如,人脸ID模式,具体可以参见下文S112中的说明)采集图像数据,该图像数据可以存储在安全内存中,该图像数据对应的FD(例如,FD2)可以通过IFE模块、摄像头驱动模块、IFE节点、相机服务和人脸控制模块传递到人脸识别TA,人脸识别TA可以根据FD2从安全内存中读取图像数据并进行处理,将处理结果(人脸识别成功或人脸识别失败)反馈给人脸识别控制模块。人脸识别控制模块可以通过人脸识别服务、人脸识别SDK将处理结果反馈给锁屏应用,以便锁屏应用确定是否解锁(若人脸识别成功,解锁;若人脸识别失败,不解锁,即解锁失败)。其中,图4中的实线箭头可以用于表示控制流,虚线箭头可以用于表示数据流。The following describes the software modules involved in the face recognition method provided by the embodiment of the present application and the interaction between the modules. As shown in Figure 4, the lock screen application in the application layer can interact with the face recognition SDK, and the face recognition SDK can communicate with the face recognition in the framework layer by calling a preset application programming interface (application programming interface, API) interface Service interaction, the face recognition service can interact with the face recognition control module in the HAL layer, 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 Interact directly with the camera HAL in the HAL layer. The camera HAL can 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 images in the default working mode (for example, the human eye safety mode, please refer to the description in S112 below) data. The IFE module can store the image data collected by the TOF camera into a 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 (file descriptor, FD). The IFE module can send the FD (for example, FD1) of image data to the camera driver module, and the camera driver module can pass FD1 to the IFE node of the camera HAL. After the IFE node receives FD1, it can pass FD1 to the sensor node of the camera HAL. , after the sensor node receives FD1, it triggers the process of reading the working status of the TOF camera. That is, the sensor node can read the working state register of the TOF camera (that is, the register used to store the working state of the TOF camera) through the camera driver module, determine the human eye safety detection result according to the value of the working state register, and according to the human eye safety detection result Switch the working mode of the TOF camera. After the working mode of the TOF camera is switched, the camera HAL can continue to interact with the camera driver module, so that the camera driver module can drive the TOF camera to capture data from the switched working module (for example, face ID mode, please refer to the description in S112 below) Image data, the image data can be stored in the safety memory, the FD (for example, FD2) corresponding to the image data can be passed to the face recognition TA through the IFE module, the camera driver module, the IFE node, the camera service and the face control module, The face recognition TA can read image data from the safety memory according to FD2 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 results 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 the face recognition is successful, unlock; if the face recognition fails, not unlock, i.e. unlocking failed). Wherein, the solid line arrows in FIG. 4 may be used to represent the control flow, and the dotted line arrows may be used to represent the data flow.

具体的,如图5所示,相机HAL中的传感器节点可以用于选择TOF摄像头的工作模式,包括人眼安全模式(第一工作模式)、人脸ID模式(第二工作模式)和TX关闭模式(第三工作模式)等,各种工作模式的具体可以参见下文S112中的说明。TOF摄像头默认的初始工作模式可以为人眼安全模式。当TOF摄像头工作在人眼安全模式时,可以从内存中读取产线标定的人眼安全安全电流值(第一电流值),根据该电流值更新人眼安全模式配置,并可以将人眼安全模式的配置参数发送至摄像头驱动模块。摄像头驱动模块可以用于驱动硬件层中的TOF摄像头以默认的工作模式(例如,人眼安全模式,具体可以参见下文S112中的说明)采集图像数据。TOF摄像头采集的图像数据在安全内存中的存储位置,可以使用FD表示。IFE模块可以将图像数据的FD(例如,FD1)发送至摄像头驱动模块,摄像头驱动模块可以将FD1传递到相机HAL的IFE节点,IFE节点接收到FD1后,可以将FD1传递到相机HAL的传感器节点,传感器节点可以通过摄像头驱动模块读取TOF摄像头的工作状态寄存器(即用于存储TOF摄像头的工作状态的寄存器),根据工作状态寄存器的值确定人眼安全检测结果。在得到人眼安全检测结果后,可以进行模式切换处理。具体的,若人眼安全检测结果为成功,TOF摄像头可以切换到人脸ID模式。若人眼安全检测结果失败,TOF摄像头可以切换到TX关闭模式。这样,可以保证人眼安全。Specifically, as shown in Figure 5, the sensor node in the camera HAL can be used to select the working mode of the TOF camera, including eye-safe mode (first working mode), face ID mode (second working mode) and TX off mode (the third working mode), etc., for details of various working modes, please refer to the description in S112 below. The default initial working mode of the TOF camera can be eye-safe mode. When the TOF camera works in the eye-safe mode, it can read the eye-safe safety current value (first current value) calibrated by the production line from the memory, update the eye-safe mode configuration according to the current value, and set the human eye The configuration parameters of the safe mode are sent to the camera driver module. The camera driver module can be used to drive the TOF camera in the hardware layer to collect image data in a default working mode (eg, eye-safe mode, for details, refer to the description in S112 below). The storage location of the image data collected by the TOF camera in the secure memory can be represented by FD. The IFE module can send the FD (for example, FD1) of image data to the camera driver module, and the camera driver module can pass FD1 to the IFE node of the camera HAL. After the IFE node receives FD1, it can pass FD1 to the sensor node of the camera HAL. , the sensor node can read the working status register of the TOF camera (that is, the register used to store the working status of the TOF camera) through the camera driver module, and determine the human eye safety detection result according to the value of the working status register. After the human eye safety detection result is obtained, the mode switching process can be performed. Specifically, if the eye safety detection result is successful, the TOF camera can switch to the face ID mode. If the human eye safety detection result fails, the TOF camera can switch to the TX off mode. In this way, the safety of human eyes can be guaranteed.

为了便于理解,以下结合附图对本申请实施例提供的方法进行具体介绍。For ease of understanding, the method provided in the embodiment of the present application will be specifically introduced below in conjunction with the accompanying drawings.

如图6所示,本申请实施例提供一种基于TOF图像的人眼安全检测和人脸识别的方法,流程如下:As shown in Figure 6, the embodiment of the present application provides a method for eye safety detection and face recognition based on TOF images, and the process is as follows:

S101、锁屏应用调用人脸识别SDK进行人脸识别。S101. The lock screen application invokes the face recognition SDK to perform face recognition.

检测到用户的解锁操作(第一操作)时,锁屏应用调用人脸识别SDK进行人脸识别。其中,用户的解锁操作包括用户拿起手机,或者按下电源键,或者在屏幕上操作(点击、滑动等),或者拔出充电线等操作。When the user's unlocking operation (the first operation) is detected, the lock screen application invokes the face recognition SDK to perform face recognition. Wherein, the user's unlocking operation includes the user picking up the mobile phone, or pressing the power button, or operating (clicking, sliding, etc.) on the screen, or pulling out the charging cable and other operations.

同时,锁屏应用可以向人脸识别SDK注册一个回调,注册该回调的作用是当人脸识别SDK获得人脸识别结果后,可以向锁屏应用返回该人脸识别结果。At the same time, the lock screen application can register a callback with the face recognition SDK. The function of registering this callback is that after the face recognition SDK obtains the face recognition result, it can return the face recognition result to the lock screen application.

S102、人脸识别SDK向人脸识别服务发送人脸识别的请求。S102. The face recognition SDK sends a face recognition request to the face recognition service.

其中,人脸识别的请求中携带人脸识别类型的标识、图像的分辨率大小和数据流格式。其中,人脸识别类型包括2D人脸识别类型(例如,可以对应标识0)和3D人脸识别类型(例如,可以对应标识1)。Wherein, the face recognition request carries the identification of the face recognition type, the resolution size of the image and the data stream format. Wherein, the face recognition type includes a 2D face recognition type (for example, may correspond to an identifier 0) and a 3D face recognition type (for example, may correspond to an identifier 1).

示例性的,人脸识别的请求中携带的人脸识别类型可以为1(即3D人脸识别类型),图像的分辨率大小可以为1280x2898像素(pixel),数据流格式可以为原始图像格式(rawimage format,RAW)16。Exemplarily, the face recognition type carried in the face recognition request may be 1 (that is, the 3D face recognition type), the resolution of the image may be 1280x2898 pixels (pixel), and the data stream format may be the original image format ( raw image format, RAW) 16.

同时,人脸识别SDK可以向人脸识别服务注册一个回调,注册该回调的作用是当人脸识别服务获得人脸比对结果后,可以向人脸识别SDK返回该人脸识别结果。At the same time, the face recognition SDK can register a callback with the face recognition service. The function of registering this 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.

S103、人脸识别服务向人脸识别控制模块发送人脸识别的请求。S103. The face recognition service sends a face recognition request to the face recognition control module.

人脸识别的请求可以参考S102的描述,在此不做赘述。For the face recognition request, please refer to the description of S102, which will not be repeated here.

也就是说,人脸识别SDK可以通过人脸识别服务通知人脸识别控制模块执行人脸识别。人脸识别服务可以将从人脸识别SDK接收到的人脸识别的请求发送给人脸识别控制模块。That is to say, 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 to the face recognition control module. The function of registering this 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. .

S104、响应于接收到人脸识别的请求,人脸识别控制模块根据人脸识别的请求匹配摄像头。S104. In response to receiving the face recognition request, the face recognition control module matches the camera according to the face recognition request.

具体的,人脸识别控制模块可以从人脸识别的请求中获得人脸识别类型的标识、图像的分辨率大小和数据流格式,通过从相机服务查询摄像头能力确定匹配的摄像头。Specifically, the face recognition control module can obtain the identity of the face recognition type, image resolution and data stream format from the face recognition request, and determine the matching camera by querying the camera capabilities from the camera service.

应该理解的是,电子设备开机过程中,相机服务可以向相机HAL发送摄像头能力查询请求,摄像头能力查询请求用于请求查询电子设备支持的摄像头能力。相机HAL接收到摄像头能力查询请求后,可以将电子设备支持的摄像头的能力发送给相机服务,相机服务可以将接收到的电子设备支持的摄像头的能力存储起来。其中,电子设备支持的摄像头能力包括各摄像头的摄像头标识(identity,ID)、支持的最大分辨率大小、数据流的格式和摄像头是否支持采集深度信息等。It should be understood that, during the boot process of the electronic device, the camera service may send a camera capability query request to the camera HAL, and the camera capability query request is used to query the camera capability supported by the electronic device. After receiving the camera capability query request, the camera HAL may send the camera capability supported by the electronic device to the camera service, and the camera service may store the received camera capability supported by the electronic device. Among them, the camera capabilities supported by the electronic device include the camera identification (identity, ID) of each camera, the maximum supported resolution size, the format of the data stream, and whether the camera supports collecting depth information, etc.

示例性的,假设手机上安装有三个摄像头,该三个摄像头的能力信息可以如表1所示:Exemplarily, assuming that there are three cameras installed on the mobile phone, the capability information of the three cameras may be shown in Table 1:

表1Table 1

摄像头IDcamera ID 安装位置installation location 支持的最大分辨率Supported maximum resolution 数据流格式data stream format 深度信息depth information 11 后置rear 4096x3072pixel4096x3072pixel YUYYUY Nono 22 前置Front 3264x2448 pixel3264x2448 pixel YUYYUY Nono 33 前置Front 1280x2898 pixel1280x2898 pixel RAW16RAW16 YesYes

其中,摄像头ID为3的摄像头是TOF摄像头,支持采集深度信息。摄像头ID为1和2的摄像头是普通摄像头,不支持采集深度信息。当然,手机上可以安装更多前置或后置摄像头,例如手机可以安装2个前置摄像头和4个后置摄像头。Among them, the camera whose camera ID is 3 is a TOF camera, which supports collecting depth information. Cameras with camera IDs 1 and 2 are common cameras and do not support collecting depth information. Of course, more front or rear cameras can be installed on the mobile phone, for example, two front cameras and four rear cameras can be installed on the mobile phone.

人脸识别控制模块可以向相机服务发送摄像头能力查询请求,相机服务可以向将电子设备支持的摄像头的能力发送给人脸识别控制模块,人脸识别控制模块可以根据电子设备支持的摄像头的能力确定匹配的摄像头,例如可以确定匹配的摄像头是ID为3的摄像头(即TOF摄像头)。The face recognition control module can send a camera capability query request to the camera service, and the camera service can send the capability of the camera supported by the electronic device to the face recognition control module, and the face recognition control module can determine according to the capability of the camera supported by the electronic device For a matched camera, for example, it may be determined that the matched camera is a camera with an ID of 3 (that is, a TOF camera).

需要说明的是,表1仅是一种示例,每个摄像头对应的数据流格式可以包括多种。例如,摄像头标识为1的摄像头不仅可以对应YUY的数据流格式,还可以对应RAW16的数据流格式,本申请不做限定。It should be noted that Table 1 is only an example, and the data stream formats corresponding to each camera may include multiple types. For example, the camera whose camera ID is 1 may not only correspond to the YUY data stream format, but may also correspond to the RAW16 data stream format, which is not limited in this application.

S105、人脸识别控制模块向相机服务发送打开相机(Camera)的请求。S105. The face recognition control module sends a request to open the camera (Camera) to the camera service.

示例性的,人脸识别控制模块可以通过供应商原生开发套件(vendor nativedevelopment kit,VNDK)接口向相机服务发送用于打开Camera的请求。其中,用于打开Camera的请求中携带安全标识、摄像头ID、分辨率的大小和数据流格式等信息。其中,安全标识用于指示将数据存储在安全Buffer中。也就是说,安全标识可以用于申请一块安全内存,后续用于存储摄像头采集的数据。例如,安全标识可以为1或0,1表示将数据存储在安全Buffer,0表示将数据存储在非安全Buffer。Exemplarily, the face recognition control module may send a request for opening the Camera to the camera service through a vendor native development kit (vendor native development kit, VNDK) interface. Wherein, the request for opening the Camera carries information such as a security identifier, a camera ID, a size of a resolution, and a data stream format. Wherein, the security identifier is used to indicate that the data is stored in the security Buffer. That is to say, the security mark can be used to apply for a piece of security memory, which is then used to store the data collected by the camera. For example, the security flag can be 1 or 0, 1 means storing data in a secure buffer, and 0 means storing data in a non-secure buffer.

示例性的,用于打开Camera的请求中携带的安全标识可以为1(即将数据存储在安全Buffer),图像的分辨率大小可以为1280x2898 pixel,数据流格式可以为RAW16,摄像头ID可以为3。Exemplarily, the security identifier carried in the request for opening the Camera may be 1 (that is, the data is stored in a security buffer), the resolution of the image may be 1280x2898 pixel, the data stream format may be RAW16, and the camera ID may be 3.

同时,人脸识别控制模块可以向Camera服务注册一个回调,注册该回调是用于在相机服务完成camera打开后通知人脸识别控制模块Camera打开完成。At the same time, the face recognition control module can register a callback to the Camera service, and the registered callback is used to notify the face recognition control module that the camera is opened after the camera service is completed.

S106、响应于接收到打开Camera的请求,相机服务向相机HAL发送打开Camera的请求,打开Camera的请求携带安全标识、摄像头ID、分辨率的大小和数据流格式等信息。S106. In response to receiving the request for opening the Camera, the camera service sends a request for opening the Camera to the camera HAL, and the request for opening the Camera carries information such as security identification, camera ID, resolution size, and data stream format.

相机服务调用相机HAL的过程中,相机服务可以向相机HAL发送安全标识、摄像头ID、图像的分辨率、数据流格式等信息。相机HAL可以将安全标识、摄像头ID、图像的分辨率、数据流格式等信息缓存预设时间。When the camera service calls the camera HAL, the camera service can send information such as the security ID, camera ID, image resolution, and data stream format to the camera HAL. The camera HAL can cache information such as security identification, camera ID, image resolution, and data stream format for a preset time.

同时,相机服务可以向相机HAL注册回调,该回调用于相机HAL将创建通路的结果通知相机服务。At the same time, the camera service can register a callback with the camera HAL, and the callback is used for the camera HAL to notify the camera service of the result of creating the channel.

S107、相机HAL根据摄像头ID、图像的分辨率和数据流格式创建对应的通路。S107. The camera HAL creates a corresponding channel according to the camera ID, image resolution and data stream format.

相机HAL可以根据摄像头ID、分辨率和数据流格式选择可用的节点,再根据可用的节点创建相应的通路。示例性的,若分辨率为1280x2898 pixel,数据流格式是RAW16,摄像头ID为3,则可以确定选择传感器节点和IFE节点。这是由于传感器节点和IFE节点可以支持传输摄像头ID为3的摄像头采集到的分辨率为1280x2898 pixel、数据流格式是RAW 16的数据。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, if the resolution is 1280x2898 pixel, the data stream format is RAW16, and the camera ID is 3, then it can be determined to select the sensor node and the IFE node. This is because the sensor node and the IFE node can support the transmission of the data collected by the camera whose ID is 3 with a resolution of 1280x2898 pixel and a data stream format of RAW 16.

其中,传感器节点对应的通路可以为:传感器节点-摄像头驱动-TOF摄像头-IFE模块-安全内存组成的通路。IFE节点对应的通路可以为:IFE模块(携带FD)-摄像头驱动-IFE节点组成的通路。相机HAL可以在HAL层将传感器节点的输出端口和IFE节点的输入端口进行连接。从而传感器节点对应的通路和IFE节点对应的通路可以组成一条闭环的通路。通路创建完成后,通路中的硬件完成上电(即硬件电路通电)等待数据请求。Wherein, the path corresponding to the sensor node may be: a path composed of sensor node-camera driver-TOF camera-IFE module-secure memory. The path corresponding to the IFE node may be: a path composed of an IFE module (carrying an 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, the hardware in the path is powered on (that is, the hardware circuit is powered on) and waits for data requests.

S108、相机HAL向相机服务返回创建通路的结果。S108. The camera HAL returns the path creation result to the camera service.

其中,创建通路的结果可以是成功或失败。若创建通路的结果是失败,相机HAL通知相机服务通路创建失败。若创建通路的结果是成功,相机HAL通知相机服务通路创建成功,可以继续执行S109及其后续步骤。Wherein, the result of creating the path can be success or failure. If the result of creating the path is a failure, the camera HAL notifies the camera service of the path creation failure. If the result of creating the path is successful, the camera HAL notifies the camera service that the path is successfully created, and S109 and its subsequent steps can be continued.

S109、响应于接收到通路创建成功的通知,相机服务向人脸识别控制模块返回相机打开完成的消息。S109. In response to receiving the notification that the path is successfully created, the camera service returns a message that the camera is opened to the face recognition control module.

可以理解的是,相机打开完成是指相机进行拍照或摄像前的准备工作(例如,相机参数配置、上电等准备工作)已完成。It can be understood that the completion of opening the camera refers to the completion of preparatory work (for example, camera parameter configuration, power-on and other preparatory work) before the camera takes pictures or takes pictures.

S110、响应于接收到相机打开完成的消息,人脸识别控制模块向相机服务发送数据请求。S110. In response to receiving the message that the opening of the camera is completed, the face recognition control module sends a data request to the camera service.

其中,数据请求用于请求获取相机的数据流。Among them, the data request is used to request to obtain the data stream of the camera.

S111、响应于接收到人脸识别控制模块发送的数据请求,相机服务调用相机HAL获取数据流。S111. In response to receiving the data request sent by the face recognition control module, the camera service calls the camera HAL to obtain a data stream.

S112、相机HAL通过传感器节点进行摄像头工作模式选择。S112. The camera HAL selects the working mode of the camera through the sensor node.

具体的,传感器节点可以通过S106中缓存的相机分辨率和数据流格式选择传感器节点对应的摄像头工作模式。示例性的,传感器节点可以通过查表(例如,表2)选择传感器节点对应的摄像头工作模式。Specifically, the sensor node can select the camera working mode corresponding to the sensor node through the camera resolution and data stream format cached in S106. Exemplarily, the sensor node may select the camera working mode corresponding to the sensor node by looking up a table (for example, Table 2).

表2Table 2

Figure BDA0003207610360000151
Figure BDA0003207610360000151

其中,人眼安全模式(EyeSafe Mode),是指TOF摄像头的Tx工作在一个小电流(小于预设阈值的电流,第一电流值)下的模式,人眼安全模式用于检查TOF摄像头是否有损坏。人脸ID模式(Face ID Mode),是TOF摄像头的Tx工作在一个正常电流(第二电流值,预设阈值范围内)的模式,人脸ID模式用于进行安全人脸解锁和安全支付等场景。其中,第二电流值大于第一电流值。TX关闭模式(Tx OFF Mode),是指TOF摄像头的Tx不通电(从而不发光)的模式,TX关闭模式用于检测到TOF摄像头的Tx器件损坏或无法正常工作的情况下。这是由于Tx器件损坏的情况下仍通电使用可能会对人眼产生不利影响,因此当检测到TOF摄像头的Tx器件损坏时,采用TX关闭模式使得Tx器件不通电,从而避免对人眼造成伤害。Among them, the eye safety mode (EyeSafe Mode) refers to the mode in which the Tx of the TOF camera works under a small current (current less than the preset threshold, the first current value). The eye safety mode is used to check whether the TOF camera has damage. Face ID mode (Face ID Mode) is a mode in which the Tx of the TOF camera works at a normal current (the second current value, within the preset threshold range). The Face ID mode is used for safe face unlocking and safe payment, etc. Scenes. Wherein, the second current value is greater than the first current value. TX off mode (Tx OFF Mode) refers to the mode in which the Tx of the TOF camera is not powered (so that it does not emit light). The TX off mode is used to detect that the Tx device of the TOF camera is damaged or cannot work normally. This is because the use of power on 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 prevent the Tx device from being powered on, thereby avoiding damage to the human eye. .

当然,摄像头的工作模式还可以包括更多,本申请不做限定。Certainly, the working mode of the camera may include more, which is not limited in this application.

根据表2可知,在图像的分辨率的最大值为1280x2898 pixel,数据流格式为Raw时,摄像头工作模式可以包括人眼安全模式、人脸ID模式、TX关闭模式等。传感器节点可以默认摄像头的初始工作模式为人眼安全模式。当摄像头工作模式为人眼安全模式时,传感器节点可以从内存(例如,oeminfo)中读取产线标定的人眼安全电流值(即对人眼没有伤害的电流值),根据人眼安全电流值更新TOF摄像头的人眼安全模式设置(setting)。例如,可以通过查表的方式获取TOF摄像头的电流寄存器的地址,将人眼安全电流值写入TOF摄像头的电流寄存器中。应该理解的是,传感器节点可以存储有TOF摄像头的各个寄存器的地址,TOF摄像头的各个寄存器的地址可以如表3所示。According to Table 2, when the maximum resolution of the image is 1280x2898 pixel and the data stream format is Raw, the working modes of the camera can include eye safety mode, face ID mode, TX off mode, etc. The sensor node can default the initial working mode of the camera to be the human eye safety mode. When the working mode of the camera is eye-safe mode, the sensor node can read the eye-safe current value calibrated by the production line (that is, the current value that is not harmful to human eyes) from the memory (for example, oeminfo), and according to the eye-safe current value Update the eye-safe mode setting of the TOF camera. For example, the address of the current register of the TOF camera can be obtained by means of table lookup, and the eye-safe current value can be written into the current register of the TOF camera. It should be understood that the sensor node may store the addresses of the registers of the TOF camera, and the addresses of the registers of the TOF camera may be shown in Table 3.

表3table 3

寄存器标识Register ID 存储数据类型storage data type 地址address 11 电流electric current 0x10x1 22 分辨率resolution 0x20x2 33 数据流格式data stream format 0x30x3 44 TOF摄像头器件工作状态Working status of TOF camera device 0x40x4 55 TOF摄像头的工作模式Working mode of TOF camera 0x50x5

示例性的,通过查询表3,可以确定电流值对应的寄存器的地址为0x1,从而可以将人眼安全电流值写入0x1对应的存储空间中。Exemplarily, by looking up Table 3, it can be determined that the address of the register corresponding to the current value is 0x1, so that the eye-safe current value can be written into the storage space corresponding to 0x1.

S113、传感器节点将人眼安全模式的配置参数发送到Kernel层的摄像头驱动(Camera Driver)模块。S113. The sensor node sends the configuration parameters of the eye safety mode to the camera driver (Camera Driver) module at the Kernel layer.

示例性的,人眼安全模式的配置参数可以为:电流值为700mA,IR灰度图曝光时间为10μs,depth图曝光时间为10μs。Exemplarily, the configuration parameters of the eye-safe mode may be: the current value is 700 mA, the exposure time of the IR grayscale image is 10 μs, and the exposure time of the depth image is 10 μs.

S114a、摄像头驱动模块将人眼安全模式的配置参数写入(更新)到TOF摄像头的寄存器中。S114a, the camera driver module writes (updates) the configuration parameters of the eye safety mode into the register of the TOF camera.

也即,摄像头驱动模块可以向TOF摄像头发送人眼安全模式的配置参数。That is, the camera driver module can send configuration parameters of the eye safety mode to the TOF camera.

示例性的,摄像头驱动模块可以通过集成电路总线(inter-integrated circuit,I2C)将人眼安全模式的配置参数写入TOF摄像头的RX的寄存器中。RX的寄存器对应的地址可以是0x01。RX对应的寄存器可以包括多个,本申请不做限定。即可以通过I2C向TOF摄像头的RX发送人眼安全模式的配置参数。其中,人眼安全模式的配置参数包括针对RX和TX的配置参数。例如,针对TX的配置参数可以是第一电流值。针对RX的配置参数可以是曝光时间。RX可以将TX对应的配置参数通过SPI总线写入TX对应的寄存器。TX对应的寄存器的地址可以是0x11。TX对应的寄存器可以包括多个,本申请不做限定。Exemplarily, the camera driver module may write the configuration parameters of the eye safety mode into the RX register of the TOF camera through an integrated circuit bus (inter-integrated circuit, I2C). The address corresponding to the RX register can be 0x01. There may be multiple registers corresponding to RX, which are not limited in this application. That is, the configuration parameters of the eye safety mode can be sent to the RX of the TOF camera through I2C. Wherein, the configuration parameters of the eye safety mode include configuration parameters for RX and TX. For example, the configuration parameter for TX may be the first current value. A configuration parameter for RX may be exposure time. RX can write the configuration parameters corresponding to TX into the registers corresponding to TX through the SPI bus. The address of the register corresponding to TX may be 0x11. There may be multiple registers corresponding to TX, which is not limited in this application.

S114b、摄像头驱动模块向TOF摄像头发送启动(stream on)命令/指令(第二启动命令)。S114b. The camera driver module sends a start (stream on) command/instruction (second start command) to the TOF camera.

stream on命令用于驱动TOF摄像头进行数据采集。The stream on command is used to drive the TOF camera for data collection.

需要说明的是,S114b之前,S114a之后,摄像头驱动模块还可以向传感器节点发送配置参数写入完成的消息;响应于接收配置参数写入完成的消息,传感器节点向摄像头驱动模块发送启动命令(第一启动命令)。It should be noted that before S114b and after S114a, the camera driver module can also send a message that the configuration parameters are written to the sensor node; in response to receiving the message that the configuration parameters are written, the sensor node sends a startup command to the camera driver module (section a start command).

S115、响应于接收到stream on命令,TOF摄像头基于人眼安全模式采集RAW Data1。S115. In response to receiving the stream on command, the TOF camera collects RAW Data1 based on the human eye safety mode.

具体的,响应于接收到stream on命令,RX可以向TX发送发光信号的请求,TX工作在对应的电流值(第一电流值)下发送第一光强度的光信号;RX在相应的曝光时间(例如,10us)接收光信号,RX接收到的光信号中包括第一光强度的光信号的反射光。基于接收到的光信号,RX获取第一图像数据。Specifically, in response to receiving the stream on command, RX can send a request for a light-emitting signal to TX, and TX works at a corresponding current value (first current value) to send an optical signal of the first light intensity; (for example, 10 us) to receive an optical signal, and the optical signal received by the RX includes reflected light of the optical signal with the first light intensity. Based on the received light signal, the RX acquires first image data.

也就是说,RAW Data 1(原始数据1)是指TOF摄像头的Tx工作在产线标定的人眼安全电流值向人脸发射光信号时,TOF摄像头的Rx接收反射光并成像得到的图像数据(第一图像数据)。其中,Tx工作在产线标定的人眼安全电流值时发射光信号为第一光强度。That is to say, RAW Data 1 (raw data 1) refers to the image data obtained by the Rx of the TOF camera receiving reflected light and imaging when the Tx of the TOF camera is working at the eye safety current value calibrated by the production line to emit light signals to the face (first image data). Wherein, when Tx works at the eye-safe current value calibrated by the production line, the emitted light signal is the first light intensity.

其中,RAW Data中包含Metadata。示例性的,Metadata保存有当前TOF摄像头的工作模式(例如,人眼安全模式),打光电流值大小(例如,产线标定的人眼安全电流值),TOF摄像头器件工作状态(例如,正常or异常)和图曝光值(例如,10μs)等信息。Among them, RAW Data contains Metadata. Exemplarily, Metadata saves the working mode of the current TOF camera (for example, eye-safe mode), the size of the light current value (for example, the eye-safe current value calibrated by the production line), and the working status of the TOF camera device (for example, normal or anomalies) and map exposure values (eg, 10μs) and other information.

S116、TOF摄像头将基于人眼安全模式采集到的RAW Data 1发送到IFE模块。S116. The TOF camera sends the RAW Data 1 collected based on the human eye safety mode to the IFE module.

示例性的,TOF摄像头可以通过移动产业处理器接口(mobile indμstryprocessor interface,MIPI)将TOF摄像头采集的RAW Data 1传输到IFE模块。IFE模块也可以称为图像前处理模块(IFE-Lite),IFE模块可以不对RAW Data 1进行处理。Exemplarily, the TOF camera can transmit the RAW Data 1 collected by the TOF camera to the IFE module through a mobile industry processor interface (mobile indμstryprocessor interface, MIPI). The IFE module may also be called an image pre-processing module (IFE-Lite), and the IFE module may not process the RAW Data 1.

S117、IFE模块将RAW Data 1发送至安全内存(Secure Buffer)中存储。S117. The IFE module sends the RAW Data 1 to a secure memory (Secure Buffer) for storage.

TOF摄像头基于人眼安全模式采集的RAW Data 1在安全内存中的存储位置可以使用FD1表示。The storage location of the RAW Data 1 collected by the TOF camera based on the eye-safe mode in the secure memory can be represented by FD1.

示例性的,当FD1为69时,可以表示存储位置为XX安全内存;当FD1为96时,可以表示存储位置为YY非安全内存(普通内存)。Exemplarily, when FD1 is 69, it may indicate that the storage location is XX secure memory; when FD1 is 96, it may indicate that the storage location is YY non-secure memory (ordinary memory).

S118、IFE模块将FD1发送至摄像头驱动模块。S118. The IFE module sends FD1 to the camera driver module.

S119、摄像头驱动模块将FD1发送至IFE节点。S119. The camera driver module sends FD1 to the IFE node.

S120、IFE节点将FD1发送至相机HAL的传感器节点。S120. The IFE node sends FD1 to the sensor node of the camera HAL.

S121、响应于接收到FD1,传感器节点向摄像头驱动模块发送读取工作状态寄存器的请求,该请求中携带工作状态寄存器的地址。S121. In response to receiving FD1, the sensor node sends a request for reading the working status register to the camera driver module, and the request carries the address of the working status register.

该读取寄存器的请求用于请求摄像头驱动模块读取存储TOF摄像头的工作状态的寄存器的值。The request for reading the register is used to request the camera driver module to read the value of the register storing the working state of the TOF camera.

S122、摄像头驱动模块根据工作状态寄存器的地址读取工作状态寄存器的值。S122. The camera driver module reads the value of the working status register according to the address of the working status register.

工作状态寄存器可以设置在TOF摄像头上,因此摄像头驱动模块可以根据工作状态寄存器的地址从TOF摄像头中读取相应寄存器的值。The working status register can be set on the TOF camera, so the camera driver module can read the value of the corresponding register from the TOF camera according to the address of the working status register.

需要说明的是,工作状态寄存器中存储有TOF摄像头的工作状态。TOF摄像头的工作状态可以用0或1表示,0可以表示工作状态为异常,1可以表示工作状态为异常。It should be noted that the working status of the TOF camera is stored in the working status register. The working status of the TOF camera can be represented by 0 or 1, 0 can indicate that the working status is abnormal, and 1 can indicate that the working status is abnormal.

S123、摄像头驱动模块向相机HAL的传感器节点发送工作状态寄存器的值。S123. The camera driver module sends the value of the working status register to the sensor node of the camera HAL.

S124、相机HAL的传感器节点根据工作状态寄存器的值计算人眼安全检测结果。S124. The sensor node of the camera HAL calculates an eye safety detection result according to the value of the working state register.

若器件工作状态正常(例如工作状态寄存器的值为0),人眼安全检测结果为安全/正常(或者说人眼安全检测成功)。若器件工作状态异常(例如工作状态寄存器的值为1),人眼安全检测结果为不安全/异常(或者说人眼安全检测失败)。If the working status of the device is normal (for example, the value of the working status register is 0), the eye safety detection result is safe/normal (or the human eye safety detection is successful). If the working status of the device is abnormal (for example, the value of the working status register is 1), the eye safety detection result is unsafe/abnormal (or the human eye safety detection fails).

S125、相机HAL的传感器节点基于人眼安全检测结果确定TOF摄像头的工作模式。S125. The sensor node of the camera HAL determines the working mode of the TOF camera based on the human eye safety detection result.

若人眼安全检测结果为安全(正常),则确定TOF摄像头的工作模式为人脸ID模式;若人眼安全检测结果为不安全(异常),则确定TOF摄像头的工作模式为TX关闭模式。If the human eye safety detection result is safe (normal), the working mode of the TOF camera is determined to be the face ID mode; if the human eye safety detection result is unsafe (abnormal), then the working mode of the TOF camera is determined to be the TX off mode.

需要说明的是,传感器节点中可以存储有人脸ID模式和TX关闭模式对应的配置参数。It should be noted that configuration parameters corresponding to the face ID mode and the TX off mode may be stored in the sensor node.

示例性的,人脸ID模式对应的配置参数可以为:电流值(第二电流值)为2800mA,IR灰度图曝光时间为500μs,depth为yes,图曝光时间为800μs。TXOFF模式对应的配置参数可以为:电流值(第三电流值)为0mA,IR灰度图曝光时间为10μs,depth为no,图曝光时间为10μs。Exemplarily, the configuration parameters corresponding to the face ID mode may be: the current value (second current value) is 2800mA, the exposure time of the IR grayscale image is 500 μs, the depth is yes, and the image exposure time is 800 μs. The configuration parameters corresponding to the TXOFF mode can be: the current value (the third current value) is 0mA, the exposure time of the IR grayscale image is 10μs, the depth is no, and the image exposure time is 10μs.

需要说明的是,本申请实施例不限定S101-S125的执行顺序。在一些实施例中,S101-S107执行完毕后,可以直接执行S112-S124,S124之后再执行S108-S111,S111之后可以再执行S125。当然,S101-S125还可以有其他的组合顺序,以保证相机HAL的传感器节点可以获取人眼安全检测结果,从而确定TOF摄像头的工作模式,本申请在此不做一一赘述。It should be noted that, the embodiment of the present application does not limit the execution sequence of S101-S125. In some embodiments, after S101-S107 is executed, S112-S124 may be executed directly, S108-S111 may be executed after S124, and S125 may be executed after S111. Of course, S101-S125 can also have other combinations, so as to ensure that the sensor node of the camera HAL can obtain the human eye safety detection results, so as to determine the working mode of the TOF camera, and this application will not repeat them here.

下面以传感器节点确定的TOF摄像头的工作模式为人脸ID模式为例进行说明,S125之后,还可以包括S126-S142:The following takes the working mode of the TOF camera determined by the sensor node as the face ID mode as an example. After S125, S126-S142 can also be included:

S126、传感器节点将人脸ID模式的配置参数发送到摄像头驱动模块。S126. The sensor node sends the configuration parameters of the face ID mode to the camera driver module.

S127、摄像头驱动模块将人脸ID模式的配置参数写入TOF摄像头的寄存器中,以驱动TOF摄像头基于人脸ID模式进行数据采集。S127. The camera driver module writes the configuration parameters of the face ID mode into the registers of the TOF camera, so as to drive the TOF camera to collect data based on the face ID mode.

也即,摄像头驱动模块可以向TOF摄像头发送人脸ID模式的配置参数。That is, the camera driver module can send configuration parameters of the face ID mode to the TOF camera.

示例性的,摄像头驱动模块可以通过I2C将人脸ID模式的配置参数写入TOF摄像头寄存器中。也即,摄像头驱动模块可以通过I2C向TOF摄像头发送人脸ID模式的配置参数。Exemplarily, the camera driver module can write the configuration parameters of the face ID mode into the register of the TOF camera through I2C. That is, the camera driver module can send configuration parameters of the face ID mode to the TOF camera through I2C.

S128、TOF摄像头基于人脸ID模式采集RAW Data 2。S128. The TOF camera collects RAW Data 2 based on the face ID mode.

其中,RAW Data 2可以是TOF摄像头的Tx工作在第二电流值(例如,2800mA)向人脸发射光信号时,TOF摄像头的Rx接收反射光并成像得到的图像数据(第二图像数据)。TOF摄像头的Tx工作在第二电流值时发射的光信号为第二光强度。第二光强度大于第一光强度。Wherein, RAW Data 2 may be the image data (second image data) obtained by receiving the reflected light and imaging the Rx of the TOF camera when the Tx of the TOF camera works at the second current value (for example, 2800mA) to emit light signals to the face. When the Tx of the TOF camera works at the second current value, the light signal emitted is the second light intensity. The second light intensity is greater than the first light intensity.

其中,RAW Data 2中包含Metadata。示例性的,Metadata保存有当前TOF摄像头的工作模式(例如,人脸ID模式),打光电流值大小(例如,2800mA),TOF摄像头器件工作状态(例如,正常)和图曝光时间(例如,800μs)等信息。Among them, RAW Data 2 contains Metadata. Exemplarily, Metadata saves the working mode of the current TOF camera (for example, face ID mode), the size of the light current value (for example, 2800mA), the working state of the TOF camera device (for example, normal) and the exposure time of the image (for example, 800μs) and other information.

S129、TOF摄像头将RAW Data 2发送至IFE模块。S129. The TOF camera sends RAW Data 2 to the IFE module.

示例性的,TOF摄像头可以通过MIPI将TOF摄像头基于人脸ID模式采集的RAWData2传输到IFE模块。Exemplarily, the TOF camera can transmit the RAWData2 collected by the TOF camera based on the face ID mode to the IFE module through MIPI.

S130、IFE模块将RAW Data 2发送至安全内存中存储。S130. The IFE module sends the RAW Data 2 to a safe memory for storage.

TOF摄像头基于人脸ID模式采集的RAW Data 2在安全内存中的存储位置可以使用FD2表示。The storage location of the RAW Data 2 collected by the TOF camera based on the face ID mode in the secure memory can be represented by FD2.

本步骤中的FD2与S117中的FD1可以相同或不同。本步骤中的FD2与S117中的FD1相同时,即TOF摄像头基于人脸ID模式采集的RAW Data 2与S117中TOF摄像头基于人眼安全模式采集的RAW Data 1被存入同一块安全内存。可以将S117中TOF摄像头基于人眼安全模式采集的RAW Data 1删除掉,从而TOF摄像头基于人脸ID模式采集的RAW Data 2可以被重新存入安全内存。在FD2与FD1不同的情况下,TOF摄像头基于人脸ID模式采集的RAW Data 2与S117中TOF摄像头基于人眼安全模式采集的RAW Data 1可以被存入不同的安全内存。FD2 in this step may be the same as or different from FD1 in S117. When FD2 in this step is the same as FD1 in S117, that is, the RAW Data 2 collected by the TOF camera based on the face ID mode and the RAW Data 1 collected by the TOF camera based on the eye-safe mode in S117 are stored in the same safe memory. The RAW Data 1 collected by the TOF camera based on the human eye safety mode in S117 can be deleted, so that the RAW Data 2 collected by the TOF camera based on the face ID mode can be stored in the safe memory again. When FD2 is different from FD1, the RAW Data 2 collected by the TOF camera based on the face ID mode and the RAW Data 1 collected by the TOF camera based on the human eye safety mode in S117 can be stored in different secure memories.

S131、IFE模块将FD2发送至摄像头驱动模块。S131. The IFE module sends FD2 to the camera driver module.

S132、摄像头驱动模块将FD2发送给IFE节点。S132. The camera driver module sends FD2 to the IFE node.

S133、IFE节点通过相机HAL的接口将FD2发送给相机服务。S133. The IFE node sends the FD2 to the camera service through the interface of the camera HAL.

S134、相机服务将FD2发送至人脸识别控制模块。S134. The camera service sends FD2 to the face recognition control module.

S135、人脸识别控制模块将FD2发送至人脸识别TA。S135. The face recognition control module sends FD2 to the face recognition TA.

S136、人脸识别TA根据FD2从安全内存中读取RAW Data 2。S136. The face recognition TA reads the RAW Data 2 from the safety memory according to the FD2.

S137、人脸识别TA根据RAW Data 2得到人脸识别结果。S137. The face recognition TA obtains a face recognition result according to the RAW Data 2 .

具体的,人脸识别TA可以从RAW Data 2中的Metadata获取TOF摄像头的工作模式,例如可以是人脸ID模式。然后,人脸识别TA可以通过TOF算法对RAW Data 2中的第二图像数据进行处理得到第一灰度图和第一深度图,再通过人脸ID算法基于第一灰度图进行人脸识别,基于第一深度图和防伪检测,从而得到人脸识别结果。Specifically, the face recognition TA can obtain the working mode of the TOF camera from the Metadata in RAW Data 2, for example, it can be a face ID mode. Then, the face recognition TA can process the second image data in RAW Data 2 through the TOF algorithm to obtain the first grayscale image and the first depth image, and then perform face recognition based on the first grayscale image through the face ID algorithm , based on the first depth map and anti-counterfeiting detection, the face recognition result is obtained.

需要说明的是,人脸识别TA中还存储有用户之前录入的人脸信息,TOF算法可以将用户录入的人脸信息转化成灰度图和深度图。若当前采集的人脸信息(TOF摄像头基于人脸ID模式采集的RAW Data,即RAW Data 2)与之前录入的人脸信息(即用户进行人脸录入操作时电子设备采集到的RAW Data)对应的灰度图匹配,可以认为是同一个用户(即进行录入人脸的操作和进行解锁的操作的是同一个用户),并且,若当前采集的人脸信息包括深度信息,可以认为当前用户是真实可信的(非照片、视频等伪装),此时可以认为当前用户的人脸安全,即人脸识别结果为成功。若当前采集的人脸信息(TOF摄像头基于人脸ID模式采集的RAW Data,即RAW Data 2)与之前录入的人脸信息(即用户进行人脸录入操作时电子设备采集到的RAW Data)对应的灰度图不匹配,或者,若当前采集的人脸信息不包括深度信息,认为当前用户的人脸不安全,即人脸识别结果为失败。It should be noted that the face recognition TA also stores the face information entered by the user before, 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 (the RAW Data collected by the TOF camera based on the face ID mode, that is, RAW Data 2) corresponds to the previously entered face information (that is, the RAW Data collected by the electronic device when the user performs the face entry operation) It can be considered as the same user (that is, the operation of entering the face and the operation of unlocking are the same user), and if the currently collected face information includes depth information, it can be considered that the current user is Authentic and credible (not disguised by photos, videos, etc.), at this time, the face of the current user can be considered safe, that is, the face recognition result is successful. If the currently collected face information (the RAW Data collected by the TOF camera based on the face ID mode, that is, RAW Data 2) corresponds to the previously entered face information (that is, the RAW Data collected by the electronic device when the user performs the face entry operation) or, if the currently collected face information does not include depth information, it is considered that the current user's face is not safe, that is, the face recognition result is a failure.

S138、人脸识别TA将人脸识别结果发送至人脸识别控制模块。S138. The face recognition TA sends the face recognition result to the face recognition control module.

S139、人脸识别控制模块将人脸识别结果发送至人脸识别服务。S139. The face recognition control module sends the face recognition result to the face recognition service.

人脸识别控制模块可以基于之前(S103中)人脸识别服务注册的回调,将人脸识别结果(成功或失败)传递到人脸识别服务。The face recognition control module may transmit the face recognition result (success or failure) to the face recognition service based on the callback registered by the face recognition service before (in S103).

S140、人脸识别服务将人脸识别结果传递到人脸识别SDK。S140. The face recognition service transmits the face recognition result to the face recognition SDK.

人脸识别服务基于之前(S102中)人脸识别SDK注册的回调,将人脸识别结果(成功或失败)传递到人脸识别SDK。The face recognition service transmits the face recognition result (success or failure) to the face recognition SDK based on the callback registered by the face recognition SDK before (in S102).

S141、人脸识别SDK将人脸识别结果传递到锁屏应用。S141. The face recognition SDK transmits the face recognition result to the lock screen application.

人脸识别SDK基于之前(S101中)锁屏应用注册的回调,将人脸识别结果(成功或失败)传递到锁屏应用。The face recognition SDK transmits the face recognition result (success or failure) to the lock screen application based on the callback registered by the previous (in S101 ) lock screen application.

S142、锁屏应用根据人脸识别结果决定是否解锁。S142. The screen lock application determines whether to unlock according to the face recognition result.

若人脸识别结果为成功,锁屏应用可以成功解锁,从而电子设备可以显示桌面或者应用(系统应用或第三方应用)的界面。若人脸识别结果为失败,锁屏应用不解锁,即人脸解锁失败。人脸解锁失败后,锁屏应用可以在人脸识别失败的一段时间内(例如,5分钟)禁用人脸识别功能。If the face recognition result is successful, the lock screen application can be successfully unlocked, so that the electronic device can display a desktop or an application (system application or third-party application) interface. If the face recognition result is failure, the lock screen application will not be unlocked, that is, face unlocking fails. After the face unlock fails, the lock screen application can disable the face recognition function within a period of time (for example, 5 minutes) during which the face recognition fails.

示例性的,若用户设置了人脸解锁,如图7中的(a)所示,当用户拿起手机进行人脸识别时,响应于用户拿起手机的操作,如图7中的(b)所示,手机可以显示锁屏界面701,手机在进行人脸识别过程中可以在锁屏界面701显示解锁图标702和提示文字“正在识别人脸”703。Exemplarily, if the user sets face unlocking, as shown in (a) in Figure 7, when the user picks up the mobile phone for face recognition, in response to the user's operation of picking up the mobile phone, as shown in (b) in Figure 7 ), the mobile phone can display a lock screen interface 701, and the mobile phone can display an unlock icon 702 and a prompt text "recognizing face" 703 on the lock screen interface 701 during the face recognition process.

若人脸识别成功,如图8中的(a)所示,可以显示界面704,界面704中可以包括解锁图标705(呈打开状,可以形象地提示用户人脸解锁成功)以及提示文字“上滑进入”706,响应于用户的上滑操作,手机可以显示桌面或者应用(系统应用或第三方应用)的界面。或者,如图8中的(b)所示,若人脸识别成功,无需用户额外操作,手机可以直接解锁,即可以立即显示桌面707(或者直接显示应用的界面)。If the face recognition is successful, as shown in (a) in Figure 8, an interface 704 can be displayed, which can include an unlock icon 705 (in an open state, which can visually prompt the user that the face unlock is successful) and the prompt text "up "Slide to enter" 706, in response to the user's sliding up operation, the mobile phone can display the interface of the desktop or application (system application or third-party application). Or, as shown in (b) in FIG. 8 , if the face recognition is successful, the mobile phone can be directly unlocked without any additional operation by the user, that is, the desktop 707 can be displayed immediately (or the interface of the application can be directly displayed).

若人脸识别失败,如图9中的(a)所示,可以显示界面708,界面708中可以包括解锁图标709(呈关闭状,可以形象地提示用户人脸未解锁成功)以及提示文字“未识别成功,双击屏幕重试”710,响应于用户的双击操作,手机可以再次进行人脸识别(即再次采集用户的人脸信息进行比对和防伪判断)。或者,响应于用户在界面708中的上滑操作,如图9中的(b)所示,手机可以显示界面711,进入界面711后手机可以再次进行人脸识别,界面711中可以包括人脸识别图标712和提示文字“正在进行人脸识别”713,若仍未识别成功,如图9中的(c)所示,手机可以显示界面714,界面714中可以包括提示文字“未识别成功,点击此处重试”715,用户可以点击相应位置重新触发人脸识别,或者也可以通过软键盘716输入密码进行解锁,避免一直无法识别成功导致用户体验低的问题。If the face recognition fails, as shown in (a) in Figure 9, an interface 708 can be displayed, which can include an unlock icon 709 (in a closed shape, which can visually prompt the user that the user's face has not been unlocked successfully) and the prompt text " Unrecognized, double-click the screen to try again" 710, in response to the user's double-click operation, the mobile phone can perform face recognition again (that is, collect the user's face information again for comparison and anti-counterfeiting judgment). Or, in response to the user's upward sliding operation on the interface 708, as shown in (b) in Figure 9, the mobile phone can display an interface 711, and after entering the interface 711, the mobile phone can perform face recognition again, and the interface 711 can include a face If the identification icon 712 and the prompt text "face recognition in progress" 713 are still not recognized successfully, as shown in (c) in Figure 9, the mobile phone can display an interface 714, which can include the prompt text "unrecognized successfully, Click here to try again" 715, the user can click on the corresponding position to re-trigger face recognition, or can also enter the password through the soft keyboard 716 to unlock, avoiding the problem of poor user experience caused by failure to identify successfully.

需要说明的是,上述实施例是以锁屏应用进行人脸解锁的方法流程为例对TOF摄像头的工作模式选择进行说明的,TOF摄像头的工作模式选择也可以应用在支付或转账时(例如,用户在支付应用/理财应用/聊天应用/购物应用(例如,

Figure BDA0003207610360000191
)中进行支付或转账操作)的人脸识别,用户在安全注册或登录应用程序的人脸安全验证(例如,用户在
Figure BDA0003207610360000192
中进行注册或登录操作)等场景中,本申请不做限定。即可以将锁屏应用替换为购物应用、聊天应用、支付应用、银行应用或理财应用等,本申请不做限定。It should be noted that, the above-mentioned embodiment takes the method flow of face unlocking by the lock screen application as an example to illustrate the selection of the working mode of the TOF camera, and the selection of the working mode of the TOF camera can also be applied to payment or transfer (for example, The user is in the payment application/finance application/chat application/shopping application (for example,
Figure BDA0003207610360000191
), face recognition for payment or transfer operations in ), face security verification for users to securely register or log in to the application (for example, users in
Figure BDA0003207610360000192
In the scenarios such as registering or logging in), this application does not limit it. That is, the lock screen application may be replaced with a shopping application, a chat application, a payment application, a banking application, or a wealth management application, which is not limited in this application.

下面以传感器节点确定的TOF摄像头的工作模式为TX关闭模式为例进行说明,如图10所示,S125之后,还可以包括S150-S167:The following takes the working mode of the TOF camera determined by the sensor node as the TX off mode as an example. As shown in Figure 10, after S125, S150-S167 can also be included:

S150、相机HAL的传感器节点基于人眼安全检测结果确定TOF摄像头的工作模式为TX关闭模式。S150. The sensor node of the camera HAL determines that the working mode of the TOF camera is the TX off mode based on the human eye safety detection result.

S151、传感器节点将TX关闭模式的配置参数发送到摄像头驱动模块。S151. The sensor node sends configuration parameters of the TX off mode to the camera driver module.

S152、摄像头驱动模块将TX关闭模式的配置参数写入(更新)到TOF摄像头的寄存器中,以驱动TOF摄像头进行数据采集。S152. The camera driver module writes (updates) the configuration parameters of the TX off mode into the register of the TOF camera, so as to drive the TOF camera for data collection.

也即,摄像头驱动模块可以向TOF摄像头发送TX关闭模式的配置参数。That is, the camera driver module can send configuration parameters of the TX off mode to the TOF camera.

示例性的,摄像头驱动模块可以通过I2C将TX关闭模式的配置参数写入TOF摄像头寄存器中。即通过I2C向TOF摄像头发送TX关闭模式的配置参数。Exemplarily, the camera driver module can write the configuration parameters of the TX off mode into the register of the TOF camera through I2C. That is, send the configuration parameters of the TX off mode to the TOF camera through I2C.

S153、TOF摄像头基于TX关闭模式采集RAW Data 3。S153, the TOF camera collects RAW Data 3 based on the TX off mode.

其中,RAW Data 3可以是TOF摄像头的Tx不通电不发光时,TOF摄像头的Rx接收反射光(无发射光或环境发射光)并成像得到的图像数据(第三图像数据),通常是无清晰人脸图像的“黑图”。Among them, RAW Data 3 can be the image data (third image data) obtained by imaging the Rx of the TOF camera after receiving reflected light (no emitted light or ambient emitted light) when the Tx of the TOF camera is not powered on and does not emit light, usually without clarity. A "black map" of face images.

其中,RAW Data 3中包含Metadata。示例性的,Metadata保存有当前TOF摄像头的工作模式(例如,TX关闭模式),打光电流值(第三电流值)大小(例如,0mA),TOF摄像头器件工作状态(例如,异常)和图曝光时间(例如,10μs)等信息。Among them, RAW Data 3 contains Metadata. Exemplary, Metadata saves the working mode (for example, TX off mode) of current TOF camera, the size (for example, 0mA) of light current value (third current value), TOF camera device working state (for example, abnormal) and graph Exposure time (for example, 10μs) and other information.

S154、TOF摄像头将RAW Data 3传输到IFE模块。S154, the TOF camera transmits RAW Data 3 to the IFE module.

示例性的,TOF摄像头可以通过MIPI将TOF摄像头采集的RAW Data 3传输到IFE模块。Exemplarily, the TOF camera can transmit the RAW Data 3 collected by the TOF camera to the IFE module through MIPI.

S155、IFE模块将RAW Data 3发送至安全内存中存储。S155. The IFE module sends the RAW Data 3 to a safe memory for storage.

TOF摄像头基于TX关闭模式采集的RAW Data 3在安全内存中的存储位置可以使用FD3表示。The storage location of the RAW Data 3 collected by the TOF camera based on the TX off mode in the secure memory can be represented by FD3.

本步骤中的FD3与S117中的FD1可以相同或不同。本步骤中的FD3与S117中的FD1相同时,即TOF摄像头基于TX关闭模式采集的RAW Data 3与S117中TOF摄像头基于人眼安全模式采集的RAW Data 1被存入同一块安全内存。可以将S117中TOF摄像头基于人眼安全模式采集的RAW Data 1删除掉,从而TOF摄像头基于TX关闭模式采集的RAW Data 3可以被重新存入安全内存。在FD3与FD1不同的情况下,TOF摄像头基于TX关闭模式采集的RAW Data 3与S117中TOF摄像头基于人眼安全模式采集的RAW Data 1可以被存入不同的安全内存。FD3 in this step may be the same as or different from FD1 in S117. When FD3 in this step is the same as FD1 in S117, that is, the RAW Data 3 collected by the TOF camera based on the TX off mode and the RAW Data 1 collected by the TOF camera based on the eye-safe mode in S117 are stored in the same safe memory. The RAW Data 1 collected by the TOF camera in S117 based on the eye-safe mode can be deleted, so that the RAW Data 3 collected by the TOF camera based on the TX off mode can be stored in the safe memory again. When FD3 is different from FD1, the RAW Data 3 collected by the TOF camera based on the TX off mode and the RAW Data 1 collected by the TOF camera in the S117 based on the eye-safe mode can be stored in different secure memories.

S156、IFE模块将FD3发送至摄像头驱动模块。S156. The IFE module sends FD3 to the camera driver module.

S157、摄像头驱动模块将FD3发送给IFE节点。S157. The camera driver module sends FD3 to the IFE node.

S158、IFE节点通过相机HAL的接口将FD3发送给相机服务。S158. The IFE node sends the FD3 to the camera service through the interface of the camera HAL.

S159、相机服务将FD3发送至人脸识别控制模块。S159. The camera service sends the FD3 to the face recognition control module.

S160、人脸识别控制模块将FD3发送至人脸识别TA。S160. The face recognition control module sends FD3 to the face recognition TA.

S161、人脸识别TA根据FD3从安全内存中读取RAW Data 3。S161. The face recognition TA reads the RAW Data 3 from the safety memory according to the FD3.

S162、人脸识别TA根据RAW Data 3得到人脸识别结果。S162. The face recognition TA obtains a face recognition result according to the RAW Data 3 .

具体的,人脸识别TA可以从TOF摄像头基于Tx关闭模式采集的RAW Data 3中的Metadata数据获取当前是Tx关闭模式,然后通过TOF算法基于第三图像数据得到第二灰度图和第二深度图,通过人脸ID算法基于第二灰度图进行人脸识别,基于第二深度图进行防伪检测,得到人脸识别结果。Specifically, the face recognition TA can obtain the current Tx off mode from the Metadata data in RAW Data 3 collected by the TOF camera based on the Tx off mode, and then use the TOF algorithm to obtain the second grayscale image and the second depth based on the third image data In the figure, face recognition is performed based on the second grayscale image through the face ID algorithm, anti-counterfeiting detection is performed based on the second depth image, and the face recognition result is obtained.

需要说明的是,TOF摄像头工作在TX关闭模式下时,人脸识别结果为失败。这是由于TOF摄像头在TX关闭模式下无法发射光线,因此TOF摄像头无法采集到清晰的人脸图像,即使当前解锁的用户是认证过的用户(即机主),人脸识别结果仍为失败。It should be noted that when the TOF camera works in the TX off mode, the face recognition result is a failure. This is because the TOF camera cannot emit light in the TX off mode, so the TOF camera cannot collect a clear face image. Even if the currently unlocked user is an authenticated user (ie the owner), the face recognition result is still a failure.

S163、人脸识别TA将人脸识别结果(为失败)传递到人脸识别控制模块。S163. The face recognition TA transmits the face recognition result (failed) to the face recognition control module.

即人脸识别TA可以通知人脸识别控制模块人脸识别结果为失败。That is, the face recognition TA can notify the face recognition control module that the face recognition result is failure.

S164、人脸识别控制模块将人脸识别结果(为失败)传递到人脸识别服务。S164. The face recognition control module transmits the face recognition result (failed) to the face recognition service.

人脸识别控制模块基于之前人脸识别服务注册的回调,将人脸识别结果(为失败)传递到人脸识别服务。即人脸识别控制模块通知人脸识别服务人脸识别结果为失败。The face recognition control module transmits the face recognition result (failed) to the face recognition service based on the callback registered by the face recognition service before. That is, the face recognition control module notifies the face recognition service that the face recognition result is failure.

S165、人脸识别服务将人脸识别结果(为失败)传递到人脸识别SDK。S165. The face recognition service transmits the face recognition result (failed) to the face recognition SDK.

人脸识别服务基于之前人脸识别SDK注册的回调,将人脸识别结果(为失败)传递到人脸识别SDK。即人脸识别服务可以通知人脸识别SDK人脸识别结果为失败。The face recognition service passes the face recognition result (failure) to the face recognition SDK based on the callback registered by the face recognition SDK. That is, the face recognition service can notify the face recognition SDK that the face recognition result is a failure.

S166、人脸识别SDK将人脸识别结果(为失败)传递到锁屏应用。S166. The face recognition SDK transmits the face recognition result (failed) to the lock screen application.

人脸识别SDK基于之前锁屏应用注册的回调,将人脸识别结果(为失败)传递到锁屏应用。即人脸识别SDK可以通知锁屏应用人脸识别结果为失败。The Face Recognition SDK passes the face recognition result (failure) to the lock screen application based on the callback registered by the previous lock screen application. That is, the face recognition SDK can notify the lock screen application that the face recognition result is a failure.

S167、锁屏应用根据人脸识别结果(为失败)决定不解锁。S167. The screen lock application decides not to unlock according to the face recognition result (failed).

由于人脸识别结果为失败,因此锁屏应用不解锁。Since the face recognition result is failed, the lock screen application is not unlocked.

示例性的,若人脸识别失败,如图9中的(a)所示,可以显示界面708,界面708中可以包括解锁图标709(呈关闭状,可以形象地提示用户人脸未解锁成功)以及提示文字“未识别成功,双击屏幕重试”710,响应于用户的双击操作,手机可以再次进行人脸识别(即再次采集用户的人脸信息进行比对和防伪判断)。或者,响应于用户在界面708中的上滑操作,手机可以显示界面711,进入界面711后手机可以再次进行人脸识别,界面711中可以包括人脸识别图标712和提示文字“正在进行人脸识别”713,若仍未识别成功,手机可以显示界面714,界面714中可以包括提示文字“未识别成功,点击此处重试”715,用户可以点击相应位置重新触发人脸识别,或者也可以通过软键盘716输入密码进行解锁,避免一直无法识别成功导致用户体验低的问题。Exemplarily, if the face recognition fails, as shown in (a) in FIG. 9 , an interface 708 can be displayed, and the interface 708 can include an unlock icon 709 (closed, which can visually prompt the user that the face is not unlocked successfully) And prompt text "recognized successfully, double-tap the screen to try again" 710, in response to the user's double-tap operation, the mobile phone can perform face recognition again (that is, collect the user's face information again for comparison and anti-counterfeiting judgment). Or, in response to the user's sliding up operation on the interface 708, the mobile phone can display an interface 711. After entering the interface 711, the mobile phone can perform face recognition again. The interface 711 can include a face recognition icon 712 and a prompt text "Face recognition is in progress Recognition" 713, if the recognition is still not successful, the mobile phone can display an interface 714, which can include the prompt text "not recognized successfully, click here to try again" 715, the user can click on the corresponding position to re-trigger face recognition, or can Enter the password through the soft keyboard 716 to unlock, avoiding the problem of poor user experience caused by failure to identify successfully.

本申请一些实施例提供了一种电子设备,该电子设备可以包括:触摸屏、存储器和一个或多个处理器。该触摸屏、存储器和处理器耦合。该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令。当处理器执行计算机指令时,电子设备可执行上述方法实施例中电子设备执行的各个功能或者步骤。该电子设备的结构可以参考图1所示的电子设备100的结构。Some embodiments of the present application provide an electronic device, and the electronic device may include: a touch screen, a memory, and one or more processors. The touch screen, memory and processor are coupled. The memory is used to store computer program code comprising computer instructions. When the processor executes the computer instructions, the electronic device can execute various functions or steps performed by the electronic device in the foregoing method embodiments. For the structure of the electronic device, reference may be made to the structure of the electronic device 100 shown in FIG. 1 .

本申请实施例还提供一种芯片系统(例如,片上系统(system on a chip,SoC)),如图11所示,该芯片系统包括至少一个处理器1101和至少一个接口电路1102。处理器1101和接口电路1102可通过线路互联。例如,接口电路1102可用于从其它装置(例如电子设备的存储器)接收信号。又例如,接口电路1102可用于向其它装置(例如处理器1101或者电子设备的触摸屏)发送信号。示例性的,接口电路1102可读取存储器中存储的指令,并将该指令发送给处理器1101。当所述指令被处理器1101执行时,可使得电子设备执行上述实施例中的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。The embodiment of the present application also provides a chip system (for example, a system on a chip (SoC)), as shown in FIG. 11 , the chip system includes at least one processor 1101 and at least one interface circuit 1102 . The processor 1101 and the interface circuit 1102 may be interconnected through wires. For example, interface circuitry 1102 may be used to receive signals from other devices, such as memory of an electronic device. For another example, the interface circuit 1102 may be used to send signals to other devices (such as the processor 1101 or a touch screen of an electronic device). Exemplarily, the interface circuit 1102 can read instructions stored in the memory, and send the instructions to the processor 1101 . When the instructions are executed by the processor 1101, the electronic device may be made to execute various steps in the foregoing embodiments. Of course, the chip system may also include other discrete devices, which is not specifically limited in this embodiment of the present application.

本申请实施例还提供一种TOF摄像头,该TOF摄像头可以用于实现上述实施例中人眼安全模式、人脸ID模式和TX关闭模式等,安装有该TOF摄像头的电子设备可以执行上述方法实施例中电子设备执行的各个功能或者步骤。The embodiment of the present application also provides a TOF camera, which can be used to implement the human eye safety mode, face ID mode, and TX off mode in the above embodiments, and the electronic device installed with the TOF camera can execute the above method. Each function or step performed by the electronic device in the example.

本申请实施例还提供一种计算机可读存储介质,该计算机可读存储介质包括计算机指令,当所述计算机指令在上述电子设备上运行时,使得该电子设备执行上述方法实施例中电子设备执行的各个功能或者步骤。An embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium includes computer instructions, and when the computer instructions are run on the above-mentioned electronic device, the electronic device is made to execute the electronic device in the above-mentioned method embodiment. each function or step.

本申请实施例还提供一种计算机程序产品,当所述计算机程序产品在电子设备上运行时,使得所述电子设备执行上述方法实施例中电子设备执行的各个功能或者步骤。An embodiment of the present application further provides a computer program product, which, when running on an electronic device, causes the electronic device to perform the various functions or steps performed by the electronic device in the foregoing method embodiments.

通过以上实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of the description, only the division of the above functional modules is used as an example for illustration. In practical applications, the above functions can be assigned by Completion of different functional modules means that the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.

在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be Incorporation or may be integrated into another device, or some features may be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.

所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The unit described as a separate component may or may not be physically separated, and the component displayed as a unit may be one physical unit or multiple physical units, that is, it may be located in one place, or may be distributed to multiple different places . Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(read only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the software product is stored in a storage medium Among them, several instructions are included to make a device (which may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the methods described in the various embodiments of the present application. The above-mentioned storage medium includes: U disk, mobile hard disk, read only memory (read only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk, and other various media that can store program codes.

以上内容,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above content is only the specific implementation of the application, but the protection scope of the application is not limited thereto, and any changes or replacements within the technical scope disclosed in the application shall be covered within the protection scope of the application. Therefore, the protection scope of the present application should be determined by the protection scope of the claims.

Claims (29)

1. A face recognition method is applied to electronic equipment, the electronic equipment comprises a time of flight (TOF) camera module, the TOF camera module comprises a transmitter used for transmitting optical signals and an image sensor used for receiving reflected light and imaging, and the method comprises the following steps:
receiving a first operation of a user, wherein the first operation is used for triggering face recognition;
controlling the transmitter to operate at a first light intensity;
determining whether the transmitter is in a normal operating state;
under the condition that the emitter is in a normal working state, controlling the emitter to work at a second light intensity, wherein the second light intensity is greater than the first light intensity;
controlling the image sensor to acquire image data;
performing the face recognition based on the image data.
2. The method of claim 1,
the light signal emitted when the emitter works at a first current value is the first light intensity, the light signal emitted when the emitter works at a second current value is the second light intensity, and the second current value is larger than the first current value.
3. The method of claim 1 or 2, wherein said determining whether the transmitter is in a normal operating state comprises:
determining a first parameter of the transmitter, the first parameter being indicative of an operating state of the transmitter;
if the first parameter is used for indicating that the working state of the transmitter is a normal working state, determining that the transmitter is in the normal working state; and if the first parameter is used for indicating that the working state of the transmitter is an abnormal working state, determining that the transmitter is in the abnormal working state.
4. The method according to any one of claims 1-3, further comprising:
under the condition that the emitter is in an abnormal working state, controlling the emitter to work at a third light intensity, wherein the third light intensity is 0;
controlling the image sensor to acquire image data;
performing the face recognition based on the image data.
5. The method of any of claims 1-4, wherein the performing the face recognition based on the image data comprises:
acquiring a gray scale map and a depth map based on the image data;
and comparing the human face based on the gray image, and performing anti-counterfeiting detection based on the depth image to obtain a human face recognition result.
6. The method according to any one of claims 1 to 5,
the first operation comprises an operation for unlocking the electronic equipment, an operation for online payment, an operation for entering a human face, or an operation for safely registering or logging in an application program.
7. The method of claim 5 or 6, further comprising:
determining whether to execute unlocking according to the face recognition result;
if the face recognition result is successful, unlocking is executed;
if the face recognition result is failure, unlocking is not executed or unlocking failure is displayed; or
Determining whether to execute payment according to the face recognition result;
if the face recognition result is successful, executing payment;
if the face recognition result is failure, not executing payment or displaying payment failure; or
Determining whether to execute face input according to the face recognition result;
if the face recognition result is successful, executing face input;
if the face recognition result is failure, not executing face input or displaying the face input failure; or
Determining whether to execute registration or login according to the face recognition result;
if the face recognition result is successful, performing registration or login;
and if the face recognition result is failure, not executing registration or login or displaying registration or login failure.
8. The method of claim 4, further comprising:
when the emitter is in an abnormal working state, prompting the user that the unlocking is failed; or prompt the user for payment failure; or prompting the user that the face input fails; or prompt the user for registration or login failure.
9. The method of any of claims 1-8, wherein the electronic device comprises a camera Hardware Abstraction Layer (HAL) and a camera driver module, wherein the camera HAL comprises a sensor node, and wherein controlling the transmitter to operate at a first light intensity comprises:
the sensor node determines that the working mode of the camera module is a first working mode; the first operating mode is used for indicating the transmitter to operate at a first current value;
the sensor node sends the configuration parameters of the first working mode to the camera driving module;
the camera driving module writes the configuration parameters of the first working mode into a register of the TOF camera module;
the camera driving module sends a message of completing configuration parameter writing to the sensor node;
in response to receiving the message that the writing of the configuration parameters is completed, the sensor node sends a first starting command to the camera driving module;
the camera driving module sends a second starting command to the TOF camera module;
the emitter works at the first current value, and the light signal emitted when the emitter works at the first current value is the first light intensity.
10. The method of claim 9, wherein the electronic device further comprises a first application, a face recognition Software Development Kit (SDK), a face recognition service, a face recognition control module, and a camera service, and wherein after receiving the first operation by the user, the method further comprises:
the first application calls the face recognition SDK to perform face recognition; the first application corresponds to the first operation, and the first application comprises a screen locking application, a shopping application, a chat application or a financing application;
the face recognition SDK sends a face recognition request to the face recognition service; the request of the face recognition carries the identification of the face recognition type, the resolution of the image and the data stream format;
the face recognition service sends the face recognition request to the face recognition control module;
the face recognition control module is matched with a camera module according to the face recognition request;
the face recognition control module sends a first request for opening a camera module to the camera service; the first request for opening the camera module carries a security identifier, an identifier ID of the camera module, the resolution of an image and a data stream format; the security identification is used for applying for a secure memory;
and the camera service sends a second request for opening a camera module to the camera HAL, wherein the second request carries the security identifier, the identifier ID of the camera module, the resolution of the image and the data stream format.
11. The method according to claim 10, wherein the determining, by the sensor node, that the working mode of the camera module is the first working mode specifically includes:
and the sensor node determines that the working mode of the camera module is a first working mode according to the resolution of the image, the data stream format and a preset rule.
12. Method according to claim 10 or 11, wherein after the camera service sends the camera HAL a second request to open a camera module, the method further comprises:
the camera HAL creates a path for transmitting data stream and control stream according to the ID of the camera module, the resolution of the image and the data stream format;
the camera HAL returns the result of creating a path to the camera service; the result of the creation of the path is successful;
the camera service returns a message of completing opening of the camera module to the face recognition control module;
the face recognition control module sends a data request to the camera service, wherein the data request is used for acquiring a data stream;
the camera service invokes the camera HAL to acquire a data stream.
13. The method of any of claims 9-12, wherein after the transmitter is operated at the first current value, the method further comprises:
the image sensor acquires an optical signal within the exposure time corresponding to the first working mode;
based on the received light signal, the image sensor acquires first image data.
14. The method of claim 13, wherein after the image sensor acquires the first image data, the method further comprises:
the image sensor sends a request for acquiring a first parameter to the transmitter;
the image sensor receiving the first parameter from the transmitter;
the image sensor obtains a first original RAW Data based on the first image Data and the first parameter; the first parameter is used for indicating the working state of the transmitter under the first current value.
15. The method of claim 14, wherein the electronic device further comprises an image processing module and a first memory, and wherein determining whether the transmitter is in a normal operating state comprises:
after the image sensor obtains first original RAW Data based on the first image Data and the first parameter, the image sensor sends the first RAW Data to the image processing module;
the image processing module sends the first RAW Data to the first memory for storage, and the first memory corresponds to the first FD;
the image processing module sends the first FD to the camera driving module;
the camera driving module sends the first FD to the camera HAL;
in response to receiving the first FD, the camera HAL sends a request to the camera drive module to read a first parameter indicating an operating status of the transmitter;
the camera driver module reads the first parameter from the register of the transmitter and sends the first parameter to the sensor node of the camera HAL;
the camera HAL determines whether the transmitter is in a normal operating state based on the first parameter.
16. The method as claimed in claim 15, wherein the determining, by the camera HAL, whether the transmitter is in a normal operating state according to the first parameter comprises:
if the first parameter is used for indicating that the working state of the transmitter is a normal working state, the camera HAL determines that the transmitter is in the normal working state;
and if the first parameter is used for indicating that the working state of the transmitter is an abnormal working state, the camera HAL determines that the transmitter is in the abnormal working state.
17. The method of claim 15 or 16, wherein said controlling said emitter to operate at a second light intensity comprises:
if the working state of the emitter is a normal working state, the camera HAL determines that the working mode of the camera module is a second working mode, and the second working mode is used for indicating that the emitter works at a second current value;
the camera HAL sends the configuration parameters of the second working mode to the camera driving module;
the camera driving module writes the configuration parameters of the second working mode into a register of the TOF camera module;
the camera driving module sends a message of completing configuration parameter writing to the sensor node;
in response to receiving the message that the writing of the configuration parameters is completed, the sensor node sends a third starting command to the camera driving module;
the camera driving module sends a fourth starting command to the TOF camera module;
the emitter works at the second current value, and the optical signal emitted when the emitter works at the second current value is the second light intensity.
18. The method of claim 17, wherein controlling the image sensor to acquire image data after the transmitter operates at the second current value comprises:
the image sensor acquires an optical signal within the exposure time corresponding to the second working mode;
based on the received light signal, the image sensor acquires second image data.
19. The method of claim 18, wherein after the image sensor acquires the second image data, the method further comprises:
the image sensor sends a request for acquiring a second parameter to the transmitter;
the image sensor receiving the second parameter from the transmitter;
the image sensor obtains second RAW Data based on the first image Data and the second parameter; the second parameter is used for indicating the working state of the transmitter under the second current value.
20. The method of claim 19, wherein the electronic device further comprises a second memory and a face recognition Trusted Application (TA), and wherein performing the face recognition based on the image data comprises:
the image sensor sends the second RAW Data to the image processing module;
the image processing module sends the second RAW Data to the second memory for storage; the second memory corresponds to a second FD;
the face recognition TA reads the second RAW Data from the second memory according to the second FD;
the face recognition TA acquires a first gray scale image and a first depth image according to the image Data in the second RAW Data;
and the face identification TA compares the face according to the first gray image and performs anti-counterfeiting detection according to the first depth image to obtain a face identification result.
21. The method of claim 20, wherein after the image processing module sends the second RAW Data to a second memory for storage, the method further comprises:
the image processing module sends the second FD to the camera driving module;
the camera driving module sends the second FD to a camera HAL;
the camera HAL sends the second FD to a camera service through a preset interface;
the camera service sends the second FD to the face recognition control module;
and the face recognition control module sends the second FD to a face recognition TA.
22. The method according to claim 20 or 21, further comprising:
the face recognition TA sends the face recognition result to the face recognition control module;
the face recognition control module sends the face recognition result to a face recognition service;
the face recognition service sends the face recognition result to a face recognition SDK;
the face recognition SDK sends the face recognition result to the first application;
and responding to the received face recognition result, and the first application executes unlocking, wherein the face recognition result is successful.
23. The method according to claim 15 or 16, wherein the controlling the emitter to operate at a third light intensity in case the emitter is in an abnormal operating state specifically comprises:
in response to receiving that the working state of the transmitter is an abnormal working state, the camera HAL determines that the working mode of the camera module is a third working mode, where the third working mode is used to indicate that the transmitter works at a third current value, and the third current value is 0;
the camera HAL sends the configuration parameters of the third working mode to the camera driving module;
the camera driving module writes the configuration parameters of the third working mode into a register of the TOF camera module;
the camera driving module sends a message of completing configuration parameter writing to the sensor node;
in response to receiving the message that the writing of the configuration parameters is completed, the sensor node sends a fifth starting command to the camera driving module;
the camera driving module sends a sixth starting command to the TOF camera module;
the transmitter is not operating.
24. The method of claim 23, wherein after the transmitter is not operating, the method further comprises:
the image sensor receives an optical signal within the exposure time corresponding to the third working mode;
based on the received light signal, the image sensor acquires third image data.
25. The method of claim 24, further comprising:
the face recognition TA acquires a second gray map and a second depth map based on the third image data;
and comparing the face based on the second gray image, and performing anti-counterfeiting detection based on the second depth image to obtain a face recognition result which is a failure.
26. The method of claim 25, further comprising:
the face recognition TA sends the face recognition result to the face recognition control module;
the face recognition control module sends the face recognition result to a face recognition service;
the face recognition service sends the face recognition result to a face recognition SDK;
the face recognition SDK sends the face recognition result to the first application;
and responding to the received face recognition result, the first application does not execute unlocking or display unlocking failure, and the face recognition result is failure.
27. An electronic device, characterized in that the electronic device comprises: a wireless communication module, memory, and one or more processors; the wireless communication module, the memory and the processor are coupled;
wherein the memory is to store computer program code comprising computer instructions; the computer instructions, when executed by the processor, cause the electronic device to perform the method of any of claims 1-26.
28. A computer-readable storage medium comprising computer instructions;
the computer instructions, when executed on an electronic device, cause the electronic device to perform the method of any of claims 1-26.
29. A chip system, comprising one or more interface circuits and one or more processors; the interface circuit and the processor are interconnected through a line;
the chip system is applied to an electronic device comprising a communication module and a memory; the interface circuit is configured to receive signals from the memory and to transmit the signals to the processor, the signals including computer instructions stored in the memory; the electronic device, when the processor executes the computer instructions, performs the method of any of claims 1-26.
CN202110921586.5A 2021-08-11 2021-08-11 A face recognition method and device Pending CN115705726A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110921586.5A CN115705726A (en) 2021-08-11 2021-08-11 A face recognition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110921586.5A CN115705726A (en) 2021-08-11 2021-08-11 A face recognition method and device

Publications (1)

Publication Number Publication Date
CN115705726A true CN115705726A (en) 2023-02-17

Family

ID=85180702

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110921586.5A Pending CN115705726A (en) 2021-08-11 2021-08-11 A face recognition method and device

Country Status (1)

Country Link
CN (1) CN115705726A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080072236A1 (en) * 2005-03-10 2008-03-20 Pope Steven L Data processing system
US9109886B1 (en) * 2012-10-09 2015-08-18 Amazon Technologies, Inc. Time-of-flight of light calibration
CN108769509A (en) * 2018-04-28 2018-11-06 Oppo广东移动通信有限公司 Method, device, electronic device and storage medium for controlling camera
CN109635539A (en) * 2018-10-30 2019-04-16 华为技术有限公司 A kind of face identification method and electronic equipment
CN109932828A (en) * 2019-02-01 2019-06-25 杭州驭光光电科技有限公司 Light projection method and light projecting apparatus
CN111626282A (en) * 2020-05-12 2020-09-04 深圳阜时科技有限公司 Image sensing device and electronic apparatus
WO2020243901A1 (en) * 2019-06-04 2020-12-10 Texas Instruments Incorporated An optical time of flight sensor for navigation systems in robotic applications
CN113807172B (en) * 2021-08-11 2022-10-18 荣耀终端有限公司 A face recognition method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080072236A1 (en) * 2005-03-10 2008-03-20 Pope Steven L Data processing system
US9109886B1 (en) * 2012-10-09 2015-08-18 Amazon Technologies, Inc. Time-of-flight of light calibration
CN108769509A (en) * 2018-04-28 2018-11-06 Oppo广东移动通信有限公司 Method, device, electronic device and storage medium for controlling camera
CN109635539A (en) * 2018-10-30 2019-04-16 华为技术有限公司 A kind of face identification method and electronic equipment
CN109932828A (en) * 2019-02-01 2019-06-25 杭州驭光光电科技有限公司 Light projection method and light projecting apparatus
WO2020243901A1 (en) * 2019-06-04 2020-12-10 Texas Instruments Incorporated An optical time of flight sensor for navigation systems in robotic applications
CN111626282A (en) * 2020-05-12 2020-09-04 深圳阜时科技有限公司 Image sensing device and electronic apparatus
CN113807172B (en) * 2021-08-11 2022-10-18 荣耀终端有限公司 A face recognition method and device

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
THORBEN WÜBBENHORST ET AL.: "Synchronization of Multiple Time-of-Flight Cameras Using Photodiodes", 《2020 IEEE SENSORS》, 9 December 2020 (2020-12-09), pages 1 - 4 *
张献忠等: "《操作系统教程》", 28 February 2006, 中国电力出版社, pages: 245 - 248 *
罗光华等: "《Android移动应用开发》", 30 November 2012, 东软电子出版社, pages: 232 *
陈岩等: "基于WinCE&CMOS图像传感器的人脸图像采集系统设计", 《仪表技术与传感器》, no. 12, 15 December 2013 (2013-12-15), pages 164 - 167 *

Similar Documents

Publication Publication Date Title
WO2023015958A1 (en) Facial recognition method and apparatus
CN114863510B (en) A face recognition method and device
CN114531541B (en) Method and device for controlling camera module
US20230262065A1 (en) Atomic Ability Invoking Method and Terminal Device
EP4361954A1 (en) Object reconstruction method and related device
CN112835495B (en) Method and device for opening application program and terminal equipment
CN115391849A (en) Method and device for storing ciphertext
US20240370537A1 (en) Cross-Device Authentication Method and Apparatus
CN115309547B (en) Method and device for processing asynchronous binder call
WO2024037032A1 (en) Account login method and electronic device
CN114726950A (en) Opening method and device of camera module
CN116704571B (en) Face recognition method, electronic device and readable storage medium
CN115705749B (en) A face recognition method and device
CN115705726A (en) A face recognition method and device
CN116704572B (en) Eye movement tracking method and device based on depth camera
CN116382810A (en) Method for starting META mode, electronic device and storage medium
CN116055233A (en) A method, terminal, and system for network distribution of Internet of Things devices
CN119251447A (en) Face recognition method and electronic device
CN120337270A (en) Face recognition method, electronic device, chip system and storage medium
CN117711032B (en) Fingerprint identification method and electronic equipment
CN115952564B (en) Data writing method and terminal equipment
CN116033341B (en) Methods and devices for triggering fence events
CN114490006B (en) Task determination method, device, equipment and storage medium
CN119251649A (en) Image processing method and electronic device
CN116127475A (en) A method and device for protecting in-process data

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Country or region after: China

Address after: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040

Applicant after: Honor Terminal Co.,Ltd.

Address before: 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong

Applicant before: Honor Device Co.,Ltd.

Country or region before: China