diff options
-rw-r--r-- | lri-rs/src/block.rs | 8 | ||||
-rw-r--r-- | lri-rs/src/lib.rs | 22 | ||||
-rw-r--r-- | lri-study/src/main.rs | 10 |
3 files changed, 38 insertions, 2 deletions
diff --git a/lri-rs/src/block.rs b/lri-rs/src/block.rs index 4ee0ea1..5660185 100644 --- a/lri-rs/src/block.rs +++ b/lri-rs/src/block.rs @@ -5,7 +5,7 @@ use lri_proto::{ view_preferences::ViewPreferences, Message as PbMessage, }; -use crate::{CameraId, CameraInfo, ColorInfo, DataFormat, RawData, RawImage, SensorModel}; +use crate::{CameraId, CameraInfo, ColorInfo, DataFormat, HdrMode, RawData, RawImage, SensorModel}; pub(crate) struct Block<'lri> { pub header: Header, @@ -215,6 +215,7 @@ impl<'lri> Block<'lri> { let ViewPreferences { image_integration_time_ns, image_gain, + hdr_mode, .. } = vp; @@ -225,6 +226,10 @@ impl<'lri> Block<'lri> { if let Some(g) = image_gain { ext.image_gain.get_or_insert(g); } + + if let Some(Ok(h)) = hdr_mode.map(|ev| ev.enum_value()) { + ext.hdr = Some(h.into()); + } } } @@ -237,6 +242,7 @@ pub(crate) struct ExtractedData { pub image_gain: Option<f32>, pub image_integration_time: Option<Duration>, pub af_achieved: Option<bool>, + pub hdr: Option<HdrMode>, } pub enum Message { diff --git a/lri-rs/src/lib.rs b/lri-rs/src/lib.rs index 0bc5a11..660a720 100644 --- a/lri-rs/src/lib.rs +++ b/lri-rs/src/lib.rs @@ -4,6 +4,7 @@ use block::{Block, ExtractedData, Header}; use lri_proto::{ camera_id::CameraID as PbCameraID, camera_module::camera_module::surface::FormatType, color_calibration::color_calibration::IlluminantType, + view_preferences::view_preferences::HDRMode, }; mod block; @@ -19,6 +20,7 @@ pub struct LriFile<'lri> { pub image_integration_time: Option<Duration>, pub af_achieved: Option<bool>, pub image_gain: Option<f32>, + pub hdr: Option<HdrMode>, } impl<'lri> LriFile<'lri> { @@ -76,6 +78,7 @@ impl<'lri> LriFile<'lri> { image_integration_time: ext.image_integration_time, af_achieved: ext.af_achieved, image_gain: ext.image_gain, + hdr: ext.hdr, } } @@ -358,3 +361,22 @@ impl From<lri_proto::sensor_type::SensorType> for SensorModel { } } } + +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum HdrMode { + None, + Default, + Natural, + Surreal, +} + +impl From<HDRMode> for HdrMode { + fn from(h: HDRMode) -> Self { + match h { + HDRMode::HDR_MODE_NONE => Self::None, + HDRMode::HDR_MODE_DEFAULT => Self::Default, + HDRMode::HDR_MODE_NATURAL => Self::Natural, + HDRMode::HDR_MODE_SURREAL => Self::Surreal, + } + } +} diff --git a/lri-study/src/main.rs b/lri-study/src/main.rs index 3e3f225..048083b 100644 --- a/lri-study/src/main.rs +++ b/lri-study/src/main.rs @@ -4,7 +4,7 @@ use std::{ }; use camino::Utf8PathBuf; -use lri_rs::{DataFormat, LriFile, SensorModel}; +use lri_rs::{DataFormat, HdrMode, LriFile, SensorModel}; use owo_colors::OwoColorize; const DATA: &'static str = "/Users/gen/thanks_lak"; @@ -78,6 +78,14 @@ fn gather() -> ! { lri.image_gain.unwrap_or_default() ); + match lri.hdr { + None => print!("{} ", "hdr".dimmed()), + Some(HdrMode::None) => print!("{} ", "hdr".blue()), + Some(HdrMode::Default) => print!("hdr "), + Some(HdrMode::Natural) => print!("{} ", "hdr".bright_green()), + Some(HdrMode::Surreal) => print!("{} ", "hdr".bright_magenta()), + } + match lri.af_achieved { None => print!("{} - ", "af".dimmed()), Some(false) => print!("{} - ", "af".red()), |