即时估算器选择指南
概述
选择正确的即时估算器对于您应用程序的成功至关重要。本指南帮助您根据具体需求、限制和使用案例做出明智决定。
快速决策树
详细比较
ME-rPPG 估算器(预设)
最适合:
- 消费者健身和健康应用程序
- 具挑战性的光线或动作条件
- AI 稳健性有价值的应用程序
- 需要开源的项目
- 具有良好连接的高端装置
选择 ME-rPPG 如果:
- ✅ 使用者在测量期间可能会轻微移动
- ✅ 光线条件变化显著
- ✅ 您可以下载約 10 MB 的模型
- ✅ 需要开源授权
- ✅ 您想要最先进的 AI 准确度
避免使用 ME-rPPG 如果:
- ❌ 您需要即时初始化
- ❌ 套件大小至关重要 (< 1 MB)
- ❌ 立即需要离线优先
- ❌ 目标装置内存有限
- ❌ 网络连接缓慢很常见
FDA 估算器
最适合:
- 医疗和健康照护应用程序
- 法规合规要求
- 资源受限的环境
- 嵌入式系统和 IoT 装置
- 需要即时启动的应用程序
选择 FDA 如果:
- ✅ 需要医疗级准确度
- ✅ 您需要即时初始化
- ✅ 套件大小必须最小
- ✅ 离线能力至关重要
- ✅ 可接受专有知识产权保护
避免使用 FDA 如果:
- ❌ 使用者会大幅移动
- ❌ 光线条件不受控制
- ❌ 您需要最大动作容忍度
- ❌ 需要开源授权
- ❌ 偏好 AI 驱动功能
功能比较矩阵
| 功能 | ME-rPPG | FDA | 优胜者 |
|---|---|---|---|
| 准确度(理想条件) | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | 🤝 平手 |
| 准确度(动作) | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 🤖 ME-rPPG |
| 准确度(不良光线) | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 🤖 ME-rPPG |
| 初始化速度 | ⭐⭐⭐ (1-2s) | ⭐⭐⭐⭐⭐ (instant) | 📈 FDA |
| 处理速度 | ⭐⭐⭐⭐ (10-30ms) | ⭐⭐⭐⭐ (5-10ms) | 📈 FDA |
| 套件大小 | ⭐⭐⭐ (~10 MB) | ⭐⭐⭐⭐⭐ (~100 KB) | 📈 FDA |
| 内存使用量 | ⭐⭐⭐ (~4 MB) | ⭐⭐⭐⭐⭐ (<200 KB) | 📈 FDA |
| 设置复杂度 | ⭐⭐⭐ (models required) | ⭐⭐⭐⭐⭐ (zero config) | 📈 FDA |
| 授权 | ⭐⭐⭐⭐⭐ (open-source) | ⭐⭐⭐ (proprietary) | 🤖 ME-rPPG |
| 动作容忍度 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 🤖 ME-rPPG |
| 光线容忍度 | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | 🤖 ME-rPPG |
| 第一个结果 | ~3 seconds | ~5 seconds | 🤖 ME-rPPG |
| 最佳准确度 | ~10 seconds | ~10 seconds | 🤝 平手 |
使用案例建议
医疗保健应用程序
建议: FDA 估算器
typescript
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.Fda,
earlyEstimation: false, // 等待完整准确度
minDuration: 10,
minConfidence: 0.7, // 高阈值
debug: false
}
});原因:
- 医疗级准确度
- 法规合规友好
- 确定性结果
- 无外部依赖
- 即时初始化
健身與健康应用程序
建议: ME-rPPG Estimator
typescript
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.MeRppg,
earlyEstimation: true,
minDuration: 3,
minConfidence: 0.3,
debug: false
}
});原因:
- 优秀的动作容忍度(使用者可能活跃)
- 对变化光线稳健
- 快速初始结果
- 最先进的 AI 准确度
- 开源授权
移动应用程序(iOS/Android)
建议: ME-rPPG Estimator
原因:
- 使用者经常移动装置
- 光线变化(室内/室外)
- 现代手机具有良好连接
- 内存通常可用
- Users expect AI-powered features
替代方案: FDA 估算器 (for medical apps or limited connectivity)
嵌入式系统與物联网
建议: FDA 估算器
typescript
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.Fda,
earlyEstimation: true,
minDuration: 5,
minConfidence: 0.5,
debug: false
}
});原因:
- 最小内存占用
- 不需要下载模型
- 即时初始化
- 立即离线工作
- 更小的套件大小
研究與开发
建议: Both (for comparison)
typescript
// Test both estimators
const meRppgCamera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.MeRppg,
debug: true
}
});
const fdaCamera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.Fda,
debug: true
}
});原因:
- Compare AI vs signal processing approaches
- Analyze different algorithm behaviors
- Understand trade-offs empirically
- Access to signal data from both
渐进式网页应用程序(PWA)
建议: ME-rPPG Estimator (with FDA fallback)
typescript
async function createEstimator() {
// Try ME-rPPG first
try {
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.MeRppg,
debug: true
}
});
// Wait for models to load
await new Promise(resolve => setTimeout(resolve, 2000));
return camera;
} catch (error) {
console.warn('ME-rPPG failed, falling back to FDA:', error);
// Fallback to FDA
return createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.Fda,
debug: true
}
});
}
}性能比较
初始化时间
处理性能
| 指标 | ME-rPPG | FDA |
|---|---|---|
| 帧处理 | 10-30ms | 5-10ms |
| 第一个结果 | ~3 秒 | ~5 秒 |
| 最佳准确度 | ~10 秒 | ~10 秒 |
| CPU 使用量 | 中等-高 | 中等 |
| 内存使用量 | ~4 MB | <200 KB |
不同条件下的准确度
| 条件 | ME-rPPG | FDA |
|---|---|---|
| 理想(静止,良好光线) | ±2 BPM | ±2 BPM |
| 轻微动作 | ±2-3 BPM | ±3-5 BPM |
| 中等动作 | ±3-5 BPM | ±5-10 BPM |
| 不良光线 | ±2-4 BPM | ±4-8 BPM |
| 说话 | ±3-5 BPM | ±5-10 BPM |
迁移指南
从 FDA 切换到 ME-rPPG
步骤 1:添加模型文件
bash
# 将 ME-rPPG 模型复制到公共目录
cp -r node_modules/ts-vital-sign-camera/public/models/me-rppg public/models/步骤 2:更新配置
typescript
// Before (FDA)
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.Fda,
minDuration: 10,
minConfidence: 0.6
}
});
// After (ME-rPPG)
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.MeRppg,
minDuration: 3, // Can be faster
minConfidence: 0.3, // Can be lower
modelPath: 'models/me-rppg/model.onnx',
statePath: 'models/me-rppg/state.json',
welchPath: 'models/me-rppg/welch_psd.onnx',
hrPath: 'models/me-rppg/get_hr.onnx'
}
});步骤 3:处理异步初始化
typescript
// ME-rPPG requires async initialization
camera.on('ready', () => {
console.log('ME-rPPG models loaded and ready');
enableStartButton();
});
camera.on('error', (error) => {
console.error('Failed to load ME-rPPG:', error);
// Fallback to FDA or show error
});从 ME-rPPG 切换到 FDA
步骤 1:更新配置
typescript
// Before (ME-rPPG)
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.MeRppg,
minDuration: 3,
minConfidence: 0.3,
modelPath: 'models/me-rppg/model.onnx',
// ... other model paths
}
});
// After (FDA)
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.Fda,
minDuration: 10, // Longer for stability
minConfidence: 0.6 // Higher threshold
}
});步骤 2:移除模型文件(可选)
bash
# 移除 ME-rPPG 模型以减少套件大小
rm -rf public/models/me-rppg步骤 3:更新用户指导
typescript
// FDA is more sensitive to motion
const instructions = [
"Stay completely still", // More important for FDA
"Don't talk during measurement", // Critical for FDA
"Ensure good, even lighting", // More important for FDA
"Wait for full 10 seconds" // FDA needs more time
];运行时切换
您可以通过重新创建相机在运行时切换估算器:
typescript
let currentEstimator: RealtimeEstimatorType = RealtimeEstimatorType.MeRppg;
let camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: currentEstimator
}
});
function switchEstimator(newType: RealtimeEstimatorType) {
// Clean up current camera
camera.destroy();
// Create new camera with different estimator
currentEstimator = newType;
camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: currentEstimator
}
});
console.log(`Switched to ${newType} estimator`);
}
// Usage
switchEstimator(RealtimeEstimatorType.Fda);决策检查清单
Use this checklist to make your decision:
Choose ME-rPPG if you answer "Yes" to most:
- [ ] Users may move during measurement
- [ ] 光线条件不受控制
- [ ] 您可以下载約 10 MB 的模型
- [ ] 需要开源授权
- [ ] 您想要 AI 驱动功能
- [ ] 目标设备是现代的 (2020+)
- [ ] 网络连接良好
- [ ] 您优先考虑具挑战性条件下的准确度
Choose FDA if you answer "Yes" to most:
- [ ] 需要医疗级准确度
- [ ] 即时初始化至关重要
- [ ] 套件大小必须最小
- [ ] 离线能力必不可少
- [ ] 用户可以在测量期间保持静止
- [ ] 可以控制光线
- [ ] 需要法规合规
- [ ] 您偏好确定性算法
混合方法
为了最大灵活性,实现两者并让用户或条件决定:
typescript
function selectEstimator(conditions: {
lighting: 'good' | 'poor';
motion: 'still' | 'moving';
connectivity: 'online' | 'offline';
priority: 'speed' | 'accuracy';
}): RealtimeEstimatorType {
// Offline or poor connectivity → FDA
if (conditions.connectivity === 'offline') {
return RealtimeEstimatorType.Fda;
}
// Poor lighting or motion → ME-rPPG
if (conditions.lighting === 'poor' || conditions.motion === 'moving') {
return RealtimeEstimatorType.MeRppg;
}
// Speed priority → FDA (instant init)
if (conditions.priority === 'speed') {
return RealtimeEstimatorType.Fda;
}
// 默认为 ME-rPPG 以获得最佳整体体验
return RealtimeEstimatorType.MeRppg;
}
// 使用方式
const estimatorType = selectEstimator({
lighting: detectLightingConditions(),
motion: detectMotionLevel(),
connectivity: navigator.onLine ? 'online' : 'offline',
priority: 'accuracy'
});
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType
}
});摘要
| 情景 | 建议 | 原因 |
|---|---|---|
| 医疗应用程序 | FDA | 法规合规、确定性 |
| 健身应用程序 | ME-rPPG | 动作容忍度、AI 稳健性 |
| 移动应用程序 | ME-rPPG | 变化条件、现代设备 |
| 嵌入式系统 | FDA | 最小资源、即时初始化 |
| PWA | ME-rPPG + FDA 回退 | 最佳体验与安全网 |
| 研究 | 两者 | 比较方法 |
| 离线优先 | FDA | 无模型下载 |
| 开源项目 | ME-rPPG | 授权要求 |
下一步
Review Detailed Guides:
Configure Your Estimator:
Optimize Performance:
Handle Edge Cases: