Degup:用三分鐘測試你能否感知自己心跳的網絡攝影機遊戲
Degup: a three-minute webcam game that checks if you can feel your own heartbeat
Degup 是一款使用一般網絡攝影機的桌面遊戲,透過 Presage SmartSpectra SDK 讀取脈搏和呼吸,讓玩家跟着自己感覺到的心跳按鍵,並比較按鍵與鏡頭偵測到的心跳。每局約三分鐘,結果會顯示同步評分等資料,並可儲存為 PNG 到自己的電腦;遊戲不是健康測試,亦不會上載資料。
This is a submission for the Presage SmartSpectra SDK Challenge
What I Built
Try to tap in time with your own heartbeat, without touching your pulse. I tried for 40 seconds. The app's answer for that round was "No score": the camera saw 41 beats, I tapped 33, and the reading was too weak to judge. That is the run in the video below.
Degup is a desktop game for adults that runs this check with a normal webcam. "Degup" is the Malay word for a heartbeat. The Presage SmartSpectra SDK reads my pulse and my breathing from the camera. The game asks me to tap whenever I feel a beat, then shows my taps next to the beats the camera saw.
One round takes about three minutes.
| Scene | What you do | What the live signal does |
|---|---|---|
| See (30 s) | Watch a lamp on the screen | The lamp pulses once for every beat found in the SDK's pulse waveform |
| Feel (40 s) | The lamp goes dark. Press Space each time you feel a beat | Each tap is placed inside its beat cycle and the pattern is scored |
| Bend (60 s) | Breathe in for 4 seconds and out for 6 | A live chart draws the gap between beats and shades it by your breath |
The result is one card: the sync score, beats seen, taps, how many milliseconds the heart slowed on each out-breath, and the average pulse. You can save the card as a PNG on your own computer. Nothing is uploaded.
Degup is a body-awareness game. It is not a health test, and every result screen says so.
The app is in English and Bahasa Melayu. Every string lives in two language files with the same keys.
Demo
The video is one full run of the app, made in two steps. I filmed my face on my phone for three minutes: sitting still, then tapping the table each time I felt a beat, then breathing in for four seconds and out for six. Degup then read that recording as its camera, through the real SmartSpectra SDK in real time, and my taps were replayed from the tapping sounds in the recording. The run was made on a Linux server with no GPU and recorded with the app's own recorder. The camera preview in the corner is me. Every number on screen is the SDK's output on that recording: 41 beats seen, 33 taps, and no sync score, because the reading was too weak for most of the round.
Three things you will see, so I will say them first. The pulse number starts near 100 and settles around 83 during See. During Feel the hint "The camera is too slow" shows a few times, because the server without a GPU could not always keep 30 frames per second. And the Data panel is not opened in this run. There is no narration and no editing. I have not yet recorded a clean session with a live webcam.
Code
github.com/aimanmalib/degup (MIT)
You can try the full game without a camera or an API key. It runs on a built-in synthetic signal, and every screen is labelled "Simulation". You need Git and Node.js 22.
git clone https://github.com/aimanmalib/degup.git && cd degup && npm ci && DEGUP_SUMBER=sim npm start
On Windows PowerShell:
git clone https://github.com/aimanmalib/degup.git; cd degup; npm ci; $env:DEGUP_SUMBER = "sim"; npm start
There is also a replay mode with one example file. It holds numbers only, no images, and is labelled as a replay.
You can also try the Simulation in a browser with nothing to install: aimanmalib.github.io/degup/sim. It is the same game code on a simulated signal, and every screen says so.
The commit history starts on 8 November and shows the build step by step.
For live mode, get a free key at physiology.presagetech.com, run npm start, open Settings, paste the key and save. The README has the full steps, the Linux sandbox note and the limits.
Where to look:
| File | What it holds |
|---|---|
src/sumber/live.ts |
SDK setup: metric groups, telemetry off, one metrics listener, error mapping |
src/core/beats.ts |
Beat detection on the raw waveform |
src/core/score.ts |
Sync score and the band rules |
src/core/rsa.ts |
Breath and beat-gap maths for Bend |
lang/en.json |
The consent text, word for word |
The repo has 222 unit tests and 25 Electron tests that drive the built app. On my Linux host 23 of the Electron tests run and 2 are skipped.
Variable names and code comments are in Malay, the working language of my studio. The README has a code map and a short glossary for reviewers.
How It Responds to Human Signals
Degup asks the SDK for two metric groups, cardio and breathing. It asks for nothing about the face.
| Live Presage signal | What Degup does with it, in real time |
|---|---|
cardio.arterialPressureTrace |
Finds each heartbeat. Drives the lamp in See, the scoring in Feel and the beat gaps in Bend |
cardio.pulseRate |
The number beside the lamp. Also a self-check: if my own beat count drifts more than 10% from it, those beats are marked noisy and not scored |
breathing.upperTrace |
Shades the Bend chart with my real breath when the trace is steady |
breathing.rate |
With the pulse rate, gives "about N beats per breath" on the result card |
confidence and stable on each sample |
Weak seconds are shaded on the timeline and left out of the score |
validationStatus |
If the face is lost, out of position or joined by a second face for more than 1.5 seconds, the game pauses and says what to fix. Movement and light only show a hint, because weak seconds are already left out of the score |
Finding single beats. The SDK gives a pulse rate, but a game about feeling one beat needs the moment of each beat. So Degup looks for them in the raw waveform. It removes slow drift with a one-second moving average, low-pass filters at 3 Hz, picks peaks above an adaptive threshold, and ignores anything within 330 ms of the last beat. On synthetic signals from 55 to 95 beats per minute the tests require at least 95% of beats found and a median timing error under 40 ms. On my own face, on the still first minute of the phone video, it found 58 beats in 43 seconds of waveform, where the SDK's pulse samples predict 65.7. That misses my own threshold, and the measurements file says so.
Scoring a feeling. The score rewards consistency, not speed. Each tap gets a position inside its beat cycle. If the taps land at the same position again and again, the score is high. If they are spread around the cycle, it is low. The score is the mean resultant length of those positions times 100. A steady lag does not cost points. Cameras add delay and so do fingers.
What a tapper who feels nothing scores. A steady rhythm can fool a score like this, so I measured that on the simulator. In 2,000 simulated rounds, taps at random gaps reached "Some sense" or better in 0.9% of rounds. A steady rhythm at exactly the simulated pulse rate reached "Some sense" or better in 14.6% and "In tune" in 3.5%. The bands are set from those numbers. A round with fewer than 20 taps, or taps that cover less than 30 seconds, gets "Too few taps to tell" and no band. The simulated pulse wanders by a few beats per minute, and that is what throws a steady rhythm off most of the time. The table and the command to repeat it are in docs/MEASUREMENTS.md.
One clock. SDK samples carry timestamps in microseconds since the Unix epoch. Taps are stamped on the same clock. The score does not depend on how fast the video pipeline is.
Breath bends the beat. In Bend the lamp becomes a breathing guide. The chart shows each gap between beats in milliseconds, shaded by breath in and breath out. In the run in the video the card shows 357 ms of slowing on each out-breath, from a reading that was weak for part of the round, so I would not lean on that number. The textbook name for this is respiratory sinus arrhythmia, and most hearts do it. The game shows it and makes no judgement about it.
The integration follows the official electron-quickstart sample. The renderer owns the camera and hands the stream to the SDK.
// src/sumber/live.ts, trimmed, names translated from Malay
const sdk = new SmartSpectraSDK({
apiKey,
requestedMetrics: [...cardioMetrics, ...breathingMetrics],
enableTelemetry: false,
enableAccumulatedOutput: false,
});
sdk.useMediaStream(cameraStream);
sdk.on("metrics", (buf) => emit(decodeMetrics(buf))); // exactly one listener
sdk.on("validationStatus", (code, tUs) => showHint(code, tUs));
sdk.on("insight", () => counts.insight++); // counted, never read
await sdk.start();
What the SDK taught me
-
The
Metricsmessage has nopulsefield in 3.4.0. The proto defines aPulsemessage with a pulse-respiration quotient, and my first build read it. The simulator produced it, so every test passed. A pre-submission review caught it by reading the generated types inside the package. Degup now divides the SDK's pulse rate by its breathing rate, and a test builds a realMetricsobject from the package so the shape cannot drift again. -
Insights fire on their own. With cardio and breathing both requested, the SDK sends vitals snapshots to Presage for LLM Insights without being asked. The first goes out when the pulse rate settles. More follow as the breathing rate and heart rate variability settle, and then one goes out every 60 seconds. Turning telemetry off does not stop them. Degup never calls
requestInsight, but it cannot switch the automatic ones off. So it tells the player before the camera starts, and a Data panel counts every Insight that comes back. In the first-minute test on my phone video, one automatic Insight came back. -
No face, no data. In a 20-second test file that shows only a test pattern, the SDK reported
kNoFaceFound118 times and sent no metrics and no Insights. Degup pauses on that code and says "No face in view". -
The renderer frame loop is the frame-rate budget. In 3.4.0 the SDK's renderer loop draws every camera frame to a canvas, reads it back as full RGBA and posts it to the main process, all on the renderer's main thread. On a machine with no GPU a CPU profile showed
drawImage,getImageDataandpostMessagetaking most of that thread, and only about 21 frames per second reached the SDK. The result was validation code 11 (kFrameRateTooLow) after five seconds and SDK error 8 about five seconds later. Degup now scales frames down before the SDK sees them and keeps their timestamps (sdk.bingkai_sdkin the config). With that and reduced motion, the same machine finished a full round. -
The SDK wants close to 30 frames per second, and the error message does not say so. When I fed it 15 frames per second on purpose, error 8 ("SmartSpectra processing failed") came within 10 seconds. I spent a day changing machines before I read the frame path and measured it. Setting
SMARTSPECTRA_DIAGNOSTICS=1makes the main process log how many frames it received, and that was the fastest way to see the real rate.
Prize Categories
I am entering Most Creative or Delightful Use and Best Thoughtful Real-World Use.
Most Creative or Delightful Use. Most camera-vitals demos show you your numbers. Degup hides them and asks what you feel first. The idea comes from lab work on interoception, the sense of your own body from the inside. Researchers test it with tapping tasks such as the Phase Adjustment Task (Plans et al., 2021), which need a sensor on the body. Here the laptop camera is the sensor. Degup is inspired by that work and is not a validated version of it. The moment the game is built around is the reveal, when your taps appear under the beats and you find out whether you were feeling or guessing.
Three other entries ask a related question, and all three are worth a look. Body Radar asks you to guess a rate before the camera shows it. Feltbeat asks you to count the beats you feel. Practical runs that count as a classroom experiment and checks the camera against a wrist count. Degup asks for the timing of each beat. Its first commit is from 8 November.
Best Thoughtful Real-World Use. Degup is a game, so I am not claiming it fixes a problem in someone's day. The part I think carries over to real products is how it asks for the camera and what it admits. The consent screen names what the SDK sends out, including the automatic Insights. The Data panel counts what happened in this session, not what a policy says should happen. A weak reading is shown as weak, and a round with too little data gets no score. The whole app works in two languages.
Consent and Data Handling
- Consent. The camera stays off until the player has seen seven plain points and ticked "I am 18 or older". "Not now" leaves the camera off. While the camera is on, the top bar says "Camera on" with a button to turn it off, and Esc turns it off at once. One person in the frame. Nothing runs in the background.
- What is measured. Pulse rate, pulse waveform, breathing rate and breathing waveform. The SDK's cardio group also computes heart rate variability; Degup does not show it. Degup does not request face metrics.
- Where video goes. Frames go from the camera into the SDK on the same computer. Presage's SDK privacy policy (3 November 2026, section 3.1) says images and video are processed on the device and are not sent to Presage. Degup does not save or send frames. The optional demo recorder saves a video of the app window, with the camera preview in it, to the local Videos folder, and only when you press Record demo.
- What the SDK sends to Presage. API key and device checks, model downloads, and usage records such as session times and counts (sections 4.3 and 4.4). It also sends derived measurements automatically during each session, namely heart rate, breathing rate and heart rate variability, with a session identifier, so that Presage can generate AI Insights (section 4.2). Presage generates Insights using Anthropic (section 7.1). Developers and end users cannot turn this off at present (section 7.4). Degup sends no prompt text, never requests an Insight, and does not read the Insights that come back. It only counts them.
-
SDK telemetry. Off (
enableTelemetry: false). The policy says this does not turn off authentication, model delivery or Insights. - Retention at Presage. Insights requests and responses are kept while the developer account behind the API key is active, and deleted within 60 days after that account closes (section 10.1). In Degup you use your own free key, so that account is yours.
-
What Degup stores. Two small local files: your settings (language, camera, sound) and your API key, encrypted with Electron
safeStorage. It keeps no scores. A result card is saved only when you press Save, and a demo video only when you press Record demo. "Delete all Degup data" in Settings removes the settings and the key. - AI services. Degup itself calls no AI model. The only AI involved is Presage's automatic Insights described above.
- Limits of use. Degup is not a medical device. It does not diagnose, treat or monitor any condition, and it is not for medical decisions. Presage states that SDK measurements are for general wellness and are not FDA cleared.
Agent Session
I did not embed a session. The build ran as many Claude Code sessions on my own server, and the transcripts carry that server's private setup.
Here is how the work was split. Degup was built with Claude Code. Claude agents, working under my standing project rules, wrote the spec, the code, the tests and the first draft of this post. A separate Claude session reviewed the work before I submitted. I approved the look of the app and filmed my face and my taps on my phone. A Claude session made the demo recording from that phone video on a server, checked the numbers in this post against the session files, and published the post and the video at my instruction.
來源:DEV Community · dev.to
