Method for ultrasonically measuring heart rate via finger, apparatus for ultrasonically measuring heart rate via finger, electronic device, and storage medium
A method and apparatus for ultrasonically measuring a heart rate via a finger, and an electronic device are provided. The method includes: acquiring, when the finger presses the screen, a correspondence function between an echo signal and a fly time, and determining a target fly time based on the correspondence function, wherein the fly time is time elapsed from transmission to reception of an ultrasonic signal; transmitting the ultrasonic signal to the finger, receiving a current echo frame returned from the finger and carrying fingerprint information of the finger based on the target fly time; determining a time domain sampling signal based on an inter-frame difference between the current echo frame and a reference frame; and calculating a heart rate value based on the time domain sampling signal. Through the above steps, heart rate measurement can be achieved through a finger based on an ultrasonic fingerprint apparatus.
1 . A method for ultrasonically measuring a heart rate via a finger, being applied to an ultrasonic fingerprint apparatus, the ultrasonic fingerprint apparatus being arranged below a cover sheet of an electronic device to implement under-display ultrasonic fingerprint identification, the method comprising:
acquiring, when the finger presses a screen, a correspondence function between an echo signal and a fly time, and determining a target fly time based on the correspondence function, wherein the fly time is a time elapsed from transmission to reception of an ultrasonic signal;
transmitting the ultrasonic signal to the finger, and receiving a current echo frame that is returned from the finger and carries fingerprint information of the finger based on the target fly time;
determining a time domain sampling signal based on an inter-frame difference between the current echo frame and a reference frame; and
calculating a heart rate value based on the time domain sampling signal;
wherein the method further comprises:
calculating a difference between pixel points of the current echo frame and corresponding pixel points of a last echo frame as an inter-frame difference between the current echo frame and the last echo frame; and
using, in response to the inter-frame difference between the current echo frame and the last echo frame satisfying an inter-frame difference threshold, the current echo frame as the reference frame.
2 . The method according to claim 1 , wherein the determining the target fly time based on the correspondence function comprises:
determining a peak value of the correspondence function based on the correspondence function; and
determining the target fly time based on the peak value of the correspondence function, wherein the target fly time is a fly time corresponding to the obtaining of a maximum echo signal.
3 . The method according to claim 1 , wherein the using, in response to the inter-frame difference between the current echo frame and the last echo frame satisfying the inter-frame difference threshold, the current echo frame as the reference frame comprises:
maintaining a continuous count value of current echo frames that satisfy the inter-frame difference threshold;
comparing the continuous count value with a count threshold; and
updating the reference frame by using, based on the comparison showing that the continuous count value satisfies a count threshold, any one of the current echo frames that satisfy the inter-frame difference threshold and correspond to the continuous count value as the reference frame.
4 . The method according to claim 3 , wherein the determining the time domain sampling signal based on the inter-frame difference between the current echo frame and the reference frame comprises:
calculating a reference difference between the current echo frame and the reference frame, and using the reference difference as time domain sampling data of the current echo frame; and
determining the time domain sampling signal based on the time domain sampling data.
5 . The method according to claim 4 , wherein the using the reference difference as the time domain sampling data of the current echo frame comprises:
comparing the reference difference with a reference difference threshold; and
determining, based on the comparison showing that the reference difference satisfies a reference difference threshold, the reference difference as the time domain sampling data of the current echo frame.
6 . The method according to claim 5 , wherein the calculating the heart rate value based on the time domain sampling signal comprises:
filtering the time domain sampling signal to obtain a filtered time domain sampling signal; and
calculating the heart rate value based on the filtered time domain sampling signal.
7 . An electronic device, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface are configured to communicate with each other through the communication bus; the memory is configured to store at least one executable instruction, and the executable instruction causes the processor to execute a method for ultrasonically measuring a heart rate via a finger, being applied to an ultrasonic fingerprint apparatus, the ultrasonic fingerprint apparatus being arranged below a cover sheet of the electronic device to implement under-display ultrasonic fingerprint identification, the method comprising:
acquiring, when the finger presses a screen, a correspondence function between an echo signal and a fly time, and determining a target fly time based on the correspondence function, wherein the fly time is a time elapsed from transmission to reception of an ultrasonic signal;
transmitting the ultrasonic signal to the finger, and receiving a current echo frame that is returned from the finger and carries fingerprint information of the finger based on the target fly time;
determining a time domain sampling signal based on an inter-frame difference between the current echo frame and a reference frame; and
calculating a heart rate value based on the time domain sampling signal;
wherein the method further comprises:
calculating a difference between pixel points of the current echo frame and corresponding pixel points of a last echo frame as an inter-frame difference between the current echo frame and the last echo frame; and
using, in response to the inter-frame difference between the current echo frame and the last echo frame satisfying an inter-frame difference threshold, the current echo frame as the reference frame.
8 . The electronic device according to claim 7 , wherein the determining the target fly time based on the correspondence function comprises:
determining a peak value of the correspondence function based on the correspondence function; and
determining the target fly time based on the peak value of the correspondence function, wherein the target fly time is a fly time corresponding to the obtaining of a maximum echo signal.
9 . The electronic device according to claim 7 , wherein the using, in response to the inter-frame difference between the current echo frame and the last echo frame satisfying the inter-frame difference threshold, the current echo frame as the reference frame comprises:
maintaining a continuous count value of current echo frames that satisfy the inter-frame difference threshold;
comparing the continuous count value with a count threshold; and
updating the reference frame by using, based on the comparison showing that the continuous count value satisfies a count threshold, any one of the current echo frames that satisfy the inter-frame difference threshold and correspond to the continuous count value as the reference frame.
10 . The electronic device according to claim 9 , wherein the determining the time domain sampling signal based on the inter-frame difference between the current echo frame and the reference frame comprises:
calculating a reference difference between the current echo frame and the reference frame, and using the reference difference as time domain sampling data of the current echo frame; and
determining the time domain sampling signal based on the time domain sampling data.
11 . The electronic device according to claim 10 , wherein the using the reference difference as the time domain sampling data of the current echo frame comprises:
comparing the reference difference with a reference difference threshold; and
determining, based on the comparison showing that the reference difference satisfies a reference difference threshold, the reference difference as the time domain sampling data of the current echo frame.
12 . The electronic device according to claim 11 , wherein the calculating the heart rate value based on the time domain sampling signal comprises:
filtering the time domain sampling signal to obtain a filtered time domain sampling signal; and
calculating the heart rate value based on the filtered time domain sampling signal.