SmartSpectra C++ SDK
Measure human vitals from video with SmartSpectra C++ SDK.
Loading...
Searching...
No Matches
presage::smartspectra::video_source::CameraTuner Class Reference

Manages automatic camera tuning for optimal image quality. More...

#include <camera_tuner.hpp>

Public Member Functions

 CameraTuner (CameraTunerSettings settings={})
 Construct a camera tuner with specified settings.
absl::Status SetVideoSource (std::shared_ptr< VideoSource > source)
 Set the video source to tune.
std::shared_ptr< VideoSourceGetVideoSource ()
 Get shared pointer to the video source.
absl::Status StartTuning ()
 Start the tuning process.
bool IsTuning () const
 Check if tuning is currently in progress.
TuningStage GetCurrentStage () const
 Get the current tuning stage.
absl::Status ProcessFrame (presage::physiology::StatusCode status_code, int64_t frame_timestamp)
 Process a frame during tuning (synchronous mode).
absl::StatusOr< double > GetTunedExposure () const
 Get the tuned exposure value.
absl::StatusOr< double > GetTunedGain () const
 Get the tuned gain value.
absl::StatusOr< double > GetTunedWhiteBalance () const
 Get the tuned white balance value.
cv::Mat ProcessFrameForDisplay (const cv::Mat &frame) const
 Process a frame for display with optional camera tuning overlay.

Detailed Description

Manages automatic camera tuning for optimal image quality.

The CameraTuner wraps a VideoSource instance and adjusts its exposure, gain, and optionally white balance settings based on feedback from the physiology graph's status codes. It uses binary search algorithms for efficient convergence to optimal settings.

Usage:

  1. Create tuner with desired settings
  2. Transfer VideoSource ownership via SetVideoSource()
  3. Start tuning with StartTuning()
  4. For each frame, call ProcessFrame() with the status code
  5. Check IsTuning() to know when tuning is complete
  6. Retrieve final settings via GetTunedExposure/Gain/WhiteBalance()

Constructor & Destructor Documentation

◆ CameraTuner()

presage::smartspectra::video_source::CameraTuner::CameraTuner ( CameraTunerSettings settings = {})
explicit

Construct a camera tuner with specified settings.

Parameters
settingsConfiguration parameters for tuning process

Member Function Documentation

◆ GetCurrentStage()

TuningStage presage::smartspectra::video_source::CameraTuner::GetCurrentStage ( ) const

Get the current tuning stage.

Returns
Current stage of the tuning process

◆ GetTunedExposure()

absl::StatusOr< double > presage::smartspectra::video_source::CameraTuner::GetTunedExposure ( ) const

Get the tuned exposure value.

Returns
Normalized exposure value [0.0, 1.0] or error if not available

◆ GetTunedGain()

absl::StatusOr< double > presage::smartspectra::video_source::CameraTuner::GetTunedGain ( ) const

Get the tuned gain value.

Returns
Normalized gain value [0.0, 1.0] or error if not available

◆ GetTunedWhiteBalance()

absl::StatusOr< double > presage::smartspectra::video_source::CameraTuner::GetTunedWhiteBalance ( ) const

Get the tuned white balance value.

Returns
Normalized white balance value [0.0, 1.0] or error if not available

◆ GetVideoSource()

std::shared_ptr< VideoSource > presage::smartspectra::video_source::CameraTuner::GetVideoSource ( )

Get shared pointer to the video source.

Returns the shared video source that can be used for frame capture while the tuner adjusts settings.

Returns
Shared pointer to the video source

◆ IsTuning()

bool presage::smartspectra::video_source::CameraTuner::IsTuning ( ) const

Check if tuning is currently in progress.

Returns
true if tuning, false if complete or failed

◆ ProcessFrame()

absl::Status presage::smartspectra::video_source::CameraTuner::ProcessFrame ( presage::physiology::StatusCode status_code,
int64_t frame_timestamp )

Process a frame during tuning (synchronous mode).

Analyzes the status code from the physiology graph and adjusts camera parameters accordingly. Should be called once per frame during tuning.

Parameters
status_codeStatus code from physiology graph
frame_timestampFrame timestamp in microseconds
Returns
Status indicating success or reason for failure

◆ ProcessFrameForDisplay()

cv::Mat presage::smartspectra::video_source::CameraTuner::ProcessFrameForDisplay ( const cv::Mat & frame) const

Process a frame for display with optional camera tuning overlay.

If camera tuning is in progress and render_calibrating_overlay is enabled, renders a semi-transparent overlay with "Tuning camera..." text on the frame.

Parameters
frameInput frame (RGB format)
Returns
Frame with overlay rendered (if applicable), or original frame

◆ SetVideoSource()

absl::Status presage::smartspectra::video_source::CameraTuner::SetVideoSource ( std::shared_ptr< VideoSource > source)

Set the video source to tune.

Shares ownership of the video source with the tuner and validates that it supports the required controls (exposure and gain at minimum).

Parameters
sourceShared pointer to the video source
Returns
Status indicating success or reason for failure

◆ StartTuning()

absl::Status presage::smartspectra::video_source::CameraTuner::StartTuning ( )

Start the tuning process.

Initializes tuning state and begins Stage 0 (auto white balance) or Stage 1 (exposure search) depending on white balance support.

Returns
Status indicating success or reason for failure

The documentation for this class was generated from the following files:
  • smartspectra/video_source/camera_tuner.hpp
  • smartspectra/video_source/camera_tuner.cpp