跳到正文
DEV Community· Mohammed Ahmad Abbas·· 1 小時前AI 評分32

CodeCalm:由 Presage SmartSpectra SDK 驅動的生物特徵桌面助手

CodeCalm: A Biometric-Driven Desktop Companion Powered by Presage SmartSpectra SDK

AI 導讀

CodeCalm 是一款面向開發者及遠端知識工作者的桌面助手,透過 Presage SmartSpectra SDK,以網絡攝影機非接觸式監測心率、心率變異度、呼吸率及面部疲勞指標。偵測到壓力或疲勞跡象時,程式會調整介面、提供呼吸節奏提示,並建議短暫休息。影片畫面及生理指標均在裝置本機處理,不會儲存或傳送原始影片。

正文

*What I Built
CodeCalm is an intelligent desktop companion built for developers and remote knowledge workers that transforms an ordinary webcam into a continuous, contactless wellness and productivity cockpit.

Powered by the Presage SmartSpectra SDK, CodeCalm reads your real-time physiological signals—including pulse rate, heart rate variability (HRV), respiratory rate, and facial fatigue indicators—completely contact-free, with no wearables required. As you code, debug, or write documentation, the app monitors your cognitive load and stress levels in the background. If it detects climbing heart rate and erratic HRV indicating mounting frustration or fatigue, CodeCalm gently shifts your environment, dims harsh contrasting lighting, triggers a smooth breathing-pacing overlay, and prompts you to take a brief, refreshing micro-break before burnout takes hold.

Demo
Note: A full video walkthrough showcasing live camera stream rPPG signal tracking, real-time chart updates, and dynamic UI theme transitions can be viewed below.

Testing Instructions for Judges:

Clone the public repository and run npm install.

Set your SMARTSPECTRA_API_KEY environment variable.

Run npm start to launch the Electron application.

Ensure good lighting on your face; the dashboard will automatically calibrate and stream live biometrics within 3-5 seconds.

Code
CodeCalm is built on a Node.js and Electron desktop stack, leveraging the native bindings of the SmartSpectra SDK to capture video frames directly from the desktop renderer and process biometric signals in real time.

Here is a core snippet showing how the Electron main process initializes the SmartSpectra SDK and processes streaming video frames:

JavaScript
// main.js - Electron Main Process & Presage SmartSpectra Integration
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
const smartSpectra = require('@presage/smartspectra-sdk');

let mainWindow;

function createWindow() {
mainWindow = new BrowserWindow({
width: 1280,
height: 800,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});

mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html'));

// Initialize SmartSpectra SDK with Developer API Key
smartSpectra.initialize({
apiKey: process.env.SMARTSPECTRA_API_KEY,
region: 'global'
});

setupBiometricPipeline();
}

function setupBiometricPipeline() {
// Receive webcam frames piped securely from the renderer process
ipcMain.on('video-frame-input', async (event, frameData) => {
try {
const result = await smartSpectra.processFrame({
data: frameData.buffer,
width: frameData.width,
height: frameData.height,
timestamp: frameData.timestamp
});

  if (result && result.confidence >= 0.85) {
    const vitals = {
      pulseRate: result.pulseRate,          // Beats per minute (BPM)
      hrvRmssd: result.hrv.rmssd,           // HRV RMSSD indicator
      breathingRate: result.breathingRate,  // Respiration cycles/min
      fatigueScore: result.facialAnalysis.fatigueIndex
    };

    // Broadcast evaluated vitals to the frontend UI
    mainWindow.webContents.send('vitals-update', vitals);
  }
} catch (err) {
  console.error("SmartSpectra processing error:", err);
}

});
}

app.whenReady().then(createWindow);

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
You can explore the complete repository, setup instructions, and UI components on GitHub: github.com/username/code-calm-smartspectra

How It Responds to Human Signals
CodeCalm maps live streaming data from the SmartSpectra SDK into an adaptive, real-time feedback loop:

Pulse & HRV Analysis (rPPG): By analyzing subtle, imperceptible color changes in facial skin pixels caused by blood flow, CodeCalm tracks baseline heart rate and HRV. A sudden spike in pulse paired with a drop in RMSSD triggers an "Overload Alert" state in the UI.

Respiratory Pacing: Chest movement algorithms compute real-time breathing rates. If your breathing rate accelerates past normal thresholds (>22 breaths/min), the app displays a subtle, smooth expanding/contracting visual ring to help pace your breath back down.

Facial Fatigue & Blink Tracking: Utilizing SmartSpectra's facial landmark analysis, the app tracks eye closure frequency and micro-expressions, detecting when you are zoning out or experiencing screen fatigue, and offering a gentle prompt to rest your eyes.

Prize Categories
Best Thoughtful Real-World Use: CodeCalm is designed specifically for developers, engineers, and remote knowledge workers who spend hours in front of screens, often ignoring posture, breathing, and stress buildup until burnout hits. By blending contactless biometrics with non-intrusive ambient feedback, it tackles modern digital fatigue with deep consideration for user comfort, workflow preservation, and privacy.

Consent and Data Handling
100% On-Device Processing: CodeCalm processes all video frames and extracted physiological metrics entirely locally on your machine in real time. Raw video feeds are never saved to disk, logged, cached, or transmitted to any external servers.

Explicit Camera Opt-In: Upon first launch, CodeCalm presents an explicit, non-coercive UI consent modal requiring the user to intentionally grant camera access specifically for contactless signal estimation. You can pause or revoke camera access at any time with a single keyboard shortcut (Cmd/Ctrl + Shift + C).

Telemetry & SDK Compliance: In strict adherence to Presage SDK guidelines, network requests are limited solely to essential SDK initialization and license validation tokens. No personal identifiable information (PII) or raw biometric data leaves the client device.

Agent Session
View Agent Development Transcript & Session Logs (Session transcript detailing architecture planning, SDK integration debugging, and UI implementation).

presagechallenge

presage

ai

devchallenge

來源:DEV Community · dev.to