即時估算器選擇指南
概述
選擇正確的即時估算器對於您應用程式的成功至關重要。本指南幫助您根據具體需求、限制和使用案例做出明智決定。
快速決策樹
詳細比較
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
}
});原因:
- 比較 AI 與訊號處理方法
- 分析不同演算法行為
- 經驗性地了解權衡
- 存取兩者的訊號資料
漸進式網頁應用程式(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
// 之前 (FDA)
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.Fda,
minDuration: 10,
minConfidence: 0.6
}
});
// 之後 (ME-rPPG)
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.MeRppg,
minDuration: 3, // 可以更快
minConfidence: 0.3, // 可以更低
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'
}
});Step 3: Handle Async Initialization
typescript
// ME-rPPG 需要非同步初始化
camera.on('ready', () => {
console.log('ME-rPPG models loaded and ready');
enableStartButton();
});
camera.on('error', (error) => {
console.error('Failed to load ME-rPPG:', error);
// 回退到 FDA 或顯示錯誤
});從 ME-rPPG 切換到 FDA
Step 1: Update Configuration
typescript
// 之前 (ME-rPPG)
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.MeRppg,
minDuration: 3,
minConfidence: 0.3,
modelPath: 'models/me-rppg/model.onnx',
// ... 其他模型路徑
}
});
// 之後 (FDA)
const camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: RealtimeEstimatorType.Fda,
minDuration: 10, // 更長以確保穩定性
minConfidence: 0.6 // 更高閾值
}
});Step 2: Remove Model Files (optional)
bash
# 移除 ME-rPPG 模型以減少套件大小
rm -rf public/models/me-rppgStep 3: Update User Guidance
typescript
// FDA 對動作更敏感
const instructions = [
"保持完全靜止", // 對 FDA 更重要
"測量期間不要說話", // 對 FDA 至關重要
"確保良好、均勻的光線", // 對 FDA 更重要
"等待完整的 10 秒" // FDA 需要更多時間
];執行時切換
您可以通過重新建立相機在執行時切換估算器:
typescript
let currentEstimator: RealtimeEstimatorType = RealtimeEstimatorType.MeRppg;
let camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: currentEstimator
}
});
function switchEstimator(newType: RealtimeEstimatorType) {
// 清理目前相機
camera.destroy();
// 使用不同估算器建立新相機
currentEstimator = newType;
camera = createVitalSignCamera({
realtimeEstimationConfig: {
estimatorType: currentEstimator
}
});
console.log(`已切換到 ${newType} 估算器`);
}
// 使用方式
switchEstimator(RealtimeEstimatorType.Fda);決策檢查清單
使用此檢查清單做出決定:
如果您對大多數問題回答「是」,請選擇 ME-rPPG:
- [ ] 使用者在測量期間可能會移動
- [ ] 光線條件不受控制
- [ ] 您可以下載約 10 MB 的模型
- [ ] 需要開源授權
- [ ] 您想要 AI 驅動功能
- [ ] 目標裝置是現代的 (2020+)
- [ ] 網路連線良好
- [ ] 您優先考慮具挑戰性條件下的準確度
如果您對大多數問題回答「是」,請選擇 FDA:
- [ ] 需要醫療級準確度
- [ ] 即時初始化至關重要
- [ ] 套件大小必須最小
- [ ] 離線能力必不可少
- [ ] 使用者可以在測量期間保持靜止
- [ ] 可以控制光線
- [ ] 需要法規合規
- [ ] 您偏好確定性演算法
混合方法
為了最大靈活性,實作兩者並讓使用者或條件決定:
typescript
function selectEstimator(conditions: {
lighting: 'good' | 'poor';
motion: 'still' | 'moving';
connectivity: 'online' | 'offline';
priority: 'speed' | 'accuracy';
}): RealtimeEstimatorType {
// 離線或連線不良 → FDA
if (conditions.connectivity === 'offline') {
return RealtimeEstimatorType.Fda;
}
// 光線不良或動作 → ME-rPPG
if (conditions.lighting === 'poor' || conditions.motion === 'moving') {
return RealtimeEstimatorType.MeRppg;
}
// 速度優先 → FDA (即時初始化)
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 | 授權要求 |
下一步
檢閱詳細指南:
設定您的估算器:
最佳化效能:
處理邊緣案例: