heart_bpm 包允许用户仅使用智能手机的摄像头记录单次血压读数。通过分析摄像头画面中面部颜色的细微变化,它能够估算心率,并提供一种无创的方式来监测心血管健康。该包设计简洁、易于访问,可无缝集成到 Android、iOS 和 Web 平台上的健康类应用中。该包利用计算机视觉技术实时检测脉搏变化,为个人健康追踪提供了一种无需额外硬件的便捷工具。
适合场景
个人心率监测
无创血压估计
健身和健康应用
远程健康检查
每日健康追踪
主要特点
基于摄像头的脉搏检测
实时心率分析
跨平台支持(Android、iOS、Web)
与 Flutter 的简单集成
轻量且高效的处理
适合对象
健康应用开发者
健身爱好者
远程医疗应用
移动健康研究
追踪心血管健康的个人
使用建议
准确性可能因光照和肤色而异
需要稳定的摄像头输入
不是医疗级诊断工具
仅限心率,不直接测量血压
需要用户配合才能获得可靠结果
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
heart_bpm
Widget to measure heart rate in beats per minute using the camera of smartphone.
Working principle
Covering the camera lens with the fingertip enables the camera to
measure the subtle changes in skin tone. These are proportional to
the changes in the blood flow through the arteries just below the
skin of the fingertip. This is in-turn correlated to the heart beats.
Hence, the variations in the skin tone can be approximated to the
instances of heart beats. Measuring the time differences between
the peaks provides Beats per Minute.
These values are not stable and hence, an exponential moving average
filter
is implemented. The smoothing factor α, can be controlled by the
user from the calling widget.
Implementation
To access the camera, the module utilizes the
camera package. Hence, the
requirements to use this package have the same requirements.
Android
Minimum android SDK version: 21
Change the minimum Android sdk version to 21 (or higher) in your
android/app/build.gradle file.
minSdkVersion 21
iOS
iOS 10.0 of higher is needed to use the camera plugin. If compiling
for any version lower than 10.0 make sure to check the iOS version
before using the camera plugin. For example, using the
device_info plugin.
Add two rows to the file ios/Runner/Info.plist:
one with the key Privacy - Camera Usage Description and a usage
description.
and one with the key Privacy - Microphone Usage Description and a
usage description.
Or in text format add the key:
<key>NSCameraUsageDescription</key><string>Heart BPM plugin would like to use camera to measure your heart rate.</string><key>NSMicrophoneUsageDescription</key><string>Can I use the mic please?</string>
The microphone key is required though the feature is not being used
and no audio is enabled in the implementation.
Getting Started
The module can be used simply by accessing it as a widget.
Import the module:
import'package:heart_bpm/heart_bpm.dart';
Access the widget as simply as:
/// list to store raw values inList<SensorValue> data = [];
/// variable to store measured BPM valueint bpmValue;
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
appBar: AppBar(
title: Text('Heart BPM Demo'),
),
body: Column(
children: [
isBPMEnabled ? HeartBPMDialog(
context: context,
onRawData: (value) {
setState(() {
// add raw data points to the list// with a maximum length of 100if (data.length == 100)
data.removeAt(0);
data.add(value);
});
},
onBPM: (value) => setState(() {
bpmValue = value;
}),
)
: SizedBox(),
Center(
child: ElevatedButton.icon(
icon: Icon(Icons.favorite_rounded),
label: Text(isBPMEnabled
? "Stop measurement" : "Measure BPM"),
onPressed: () => setState(() =>
isBPMEnabled = !isBPMEnabled
),
),
),
],
),
);