From 2e98e669e7ad4d593b2a75d4fa827c82ae6d84f6 Mon Sep 17 00:00:00 2001 From: Bobby Date: Wed, 12 Nov 2025 09:34:52 -0600 Subject: [PATCH 1/2] Updated SmartSpectra cpp Readme --- cpp/README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/cpp/README.md b/cpp/README.md index b6df459..4de3bc1 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -124,7 +124,8 @@ int main(int argc, char** argv) { // Configure camera (defaults work for most cases) settings.video_source.device_index = 0; - settings.video_source.resolution_selection_mode = video_source::ResolutionSelectionMode::Auto; + // NOTE: If capture_width and/or capture_height is + // modified the HUD will also need to be changed settings.video_source.capture_width_px = 1280; settings.video_source.capture_height_px = 720; settings.video_source.codec = presage::camera::CaptureCodec::MJPG; @@ -148,12 +149,22 @@ int main(int argc, char** argv) { auto hud = std::make_unique(10, 0, 1260, 400); // Set up callbacks + // NOTE: If code in callbacks adds more than 75ms of delay it might affect + // incoming data. auto status = container->SetOnCoreMetricsOutput( [&hud](const presage::physiology::MetricsBuffer& metrics, int64_t timestamp) { - int pulse = static_cast(metrics.pulse().strict().value()); - int breathing = static_cast(metrics.breathing().strict().value()); + float pulse; + float breathing; + if (!metrics.pulse().rate().empty()){ + pulse = metrics.pulse().rate().rbegin()->value(); + } + if (!metrics.breathing().rate().empty()){ + breathing = metrics.breathing().rate().rbegin()->value(); + } - std::cout << "Vitals - Pulse: " << pulse << " BPM, Breathing: " << breathing << " BPM\n"; + if (!metrics.pulse().rate().empty() && !metrics.breathing().rate().empty()){ + std::cout << "Vitals - Pulse: " << pulse << " BPM, Breathing: " << breathing << " BPM\n"; + } hud->UpdateWithNewMetrics(metrics); return absl::OkStatus(); } @@ -200,7 +211,7 @@ int main(int argc, char** argv) { return 1; } - std::cout << "Ready! Press 'q' to quit.\n"; + std::cout << "Ready! Press 's' to start/stop recording data.\nPress 'q' to quit.\n"; if (auto status = container->Run(); !status.ok()) { std::cerr << "Processing failed: " << status.message() << "\n"; return 1; @@ -261,6 +272,12 @@ export SMARTSPECTRA_API_KEY=YOUR_KEY ![SmartSpectra C++ SDK Demo](docs/images/cpp-quickstart.gif) +### Keyboard Shortcuts +During the run of any example, use the following keyboard shortcuts: +- `q` or `ESC`: exit +- `s`: start/stop recording data (**webcam input / streaming** mode only) +- `e`: lock/unlock exposure (**webcam input / streaming** mode only) + ### Try the Pre-built Examples ```shell From 686aaa901d7b84808247a687e5fb7a027a5301f6 Mon Sep 17 00:00:00 2001 From: Bobby Date: Wed, 12 Nov 2025 10:02:02 -0600 Subject: [PATCH 2/2] Updated callback comment --- cpp/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpp/README.md b/cpp/README.md index 4de3bc1..8f275cb 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -149,8 +149,10 @@ int main(int argc, char** argv) { auto hud = std::make_unique(10, 0, 1260, 400); // Set up callbacks - // NOTE: If code in callbacks adds more than 75ms of delay it might affect - // incoming data. + // NOTE: These callbacks are designed to be lightweight. + // Any heavy post-processing or network communication should be performed outside these + // callbacks (in asynchronous threads when necessary) + // Delays of 25ms+ might affect incoming data auto status = container->SetOnCoreMetricsOutput( [&hud](const presage::physiology::MetricsBuffer& metrics, int64_t timestamp) { float pulse;