且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS的心率检测算法

更新时间:2023-02-26 16:12:04

在这个问题的答案是一点点参与其中,因为你需要做几件事情来处理信号,并没有单一的正确的方式做本。但是,对于您的过滤器要使用带通滤波器。这种类型的过滤器允许您指定一个范围,在高端和低端都接受两种频率。对于一个人的心脏跳动,我们知道这些界限应该是(不低于40 BPM和不高于250 BPM),因此我们可以创建一个消除了这个范围以外的频率的过滤器。过滤器也移动数据以在零为中心,所以峰值检测变得更加容易。该过滤器会给你一个更平稳的信号,即使用户增加/减少他们的手指pressure(在一定程度上)。在此之后,额外的平滑和异常值去除也需要发生

The answer to this question is a little bit involved, as you need to do several things to process the signal and there is no single "right" way to do this. However, for your filter you want to use a band-pass filter. This type of filter allows you to specify a range of frequencies that are accepted both at the high and low ends. For a human heart beat, we know what these bounds should be (no less than 40 bpm and no higher than 250 bpm) so we can create a filter that removes frequencies outside of this range. The filter also moves the data to be centered at zero, so peak detection becomes much easier. This filter will give you a much more smooth signal, even if your users increases/decreases their finger pressure (to a certain degree). After that, additional smoothing and outlier removal will also need to happen.

带通滤波器,我已经使用特定类型的巴特沃斯滤波器。这是一个小参与手工,因为根据你是在收集数据的频率更换过滤器来创建。幸运的是,有一个网站,可以帮助此这里一>。如果你是在每秒30帧收集数据,则频率为30赫兹。

A specific type of band-pass filter that I have used is a butterworth filter. This is a little involved to create by hand since the filter changes based on the frequency you are collecting your data at. Fortunately, there is a website that can help with this here. If you are collecting your data at 30 fps, then the frequency will be 30 hz.

我已经创建了一个包装了这一切在一起,并检测用户的心脏率不够好,包括它在我的iOS应用商店的应用程序的项目。我做了心脏速率检测code,适用于 github上

I have created a project that wraps all of this together and detects a user's heart rate well enough to include it in my app on the iOS app store. I have made the heart rate detection code available on github.