From 9ec20fe693176df7c7c4c8afb27c671be7bf221b Mon Sep 17 00:00:00 2001 From: Filip Jeretina <59307111+zrezke@users.noreply.github.com> Date: Tue, 26 Nov 2024 23:56:44 +0100 Subject: [PATCH] Release 0.2.7 (#77) * Exposed Stereo Depth presets. * Handle edge case where only one output is handled y the sdk. Applicable for OAK-T * TMP: Disable aarch build * Added Custom config (UI only) stereo depth conf. Leave Default stereo depth config untouched by the viewer settings. * Depthai 2.29 * Bump to version 0.2.7. Fix OAK-D-SR-PoE crash after latest syncing changes. * CHANGELOG * Re-enable aarch64 linux build. --------- Co-authored-by: Filip Jeretina --- .github/workflows/python.yml | 58 +++---- CHANGELOG.md | 5 + Cargo.lock | 70 ++++---- Cargo.toml | 54 +++--- crates/re_viewer/src/depthai/depthai.rs | 24 ++- .../re_viewer/src/ui/device_settings_panel.rs | 158 +++++++++--------- rerun_py/depthai_viewer/_backend/device.py | 41 +++-- .../_backend/device_configuration.py | 21 ++- .../device_defaults/oak_d_generic_default.py | 8 +- .../device_defaults/oak_d_lr_default.py | 4 +- .../device_defaults/oak_d_sr_default.py | 3 +- rerun_py/depthai_viewer/requirements.txt | 2 +- 12 files changed, 248 insertions(+), 200 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 74d200333b5c..abb337bc96da 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -28,36 +28,36 @@ jobs: name: Python lints (black, mypy, flake8) runs-on: ubuntu-latest steps: - - name: Skip lints - run: | + - name: Skip lints + run: | echo "Skipping lints" - # - uses: actions/checkout@v3 - - # - uses: extractions/setup-just@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # just-version: 1.5 - - # - name: Set up Python - # uses: actions/setup-python@v4 - # with: - # python-version: ${{ env.PYTHON_VERSION }} - # cache: "pip" - # cache-dependency-path: "rerun_py/requirements-lint.txt" - - # - name: Install Python dependencies - # run: | - # pip install --upgrade pip - # pip install -r rerun_py/requirements-lint.txt - - # - name: Lint Python - # run: | - # just py-lint - - # - name: Check requirements - # run: | - # just py-requirements + # - uses: actions/checkout@v3 + + # - uses: extractions/setup-just@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # just-version: 1.5 + + # - name: Set up Python + # uses: actions/setup-python@v4 + # with: + # python-version: ${{ env.PYTHON_VERSION }} + # cache: "pip" + # cache-dependency-path: "rerun_py/requirements-lint.txt" + + # - name: Install Python dependencies + # run: | + # pip install --upgrade pip + # pip install -r rerun_py/requirements-lint.txt + + # - name: Lint Python + # run: | + # just py-lint + + # - name: Check requirements + # run: | + # just py-requirements # --------------------------------------------------------------------------- diff --git a/CHANGELOG.md b/CHANGELOG.md index 7918ca182c6e..853b00ae72ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Depthai Viewer changelog +## 0.2.7 +- Added stereo depth presets! +- Fixed syncing +- Support latest OAK-T + ## 0.2.6 - Fix regression: Without an active stereo config the viewer would crash diff --git a/Cargo.lock b/Cargo.lock index 2dab633f3d49..f14654c3d5b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,7 +174,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "api_demo" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", "clap 4.4.11", @@ -1390,7 +1390,7 @@ dependencies = [ [[package]] name = "depthai-viewer" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", "backtrace", @@ -1495,7 +1495,7 @@ dependencies = [ [[package]] name = "dna" -version = "0.2.5" +version = "0.2.7" dependencies = [ "depthai-viewer", "itertools", @@ -3105,7 +3105,7 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minimal" -version = "0.2.5" +version = "0.2.7" dependencies = [ "depthai-viewer", ] @@ -3118,7 +3118,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "minimal_options" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", "clap 4.4.11", @@ -3599,7 +3599,7 @@ dependencies = [ [[package]] name = "objectron" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", "clap 4.4.11", @@ -4324,7 +4324,7 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "raw_mesh" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", "bytes", @@ -4371,7 +4371,7 @@ dependencies = [ [[package]] name = "re_analytics" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", "crossbeam", @@ -4392,7 +4392,7 @@ dependencies = [ [[package]] name = "re_arrow_store" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "anyhow", @@ -4419,7 +4419,7 @@ dependencies = [ [[package]] name = "re_build_build_info" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", "time", @@ -4427,18 +4427,18 @@ dependencies = [ [[package]] name = "re_build_info" -version = "0.2.5" +version = "0.2.7" [[package]] name = "re_build_web_viewer" -version = "0.2.5" +version = "0.2.7" dependencies = [ "cargo_metadata", ] [[package]] name = "re_data_store" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "criterion", @@ -4461,14 +4461,14 @@ dependencies = [ [[package]] name = "re_error" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", ] [[package]] name = "re_format" -version = "0.2.5" +version = "0.2.7" dependencies = [ "arrow2", "arrow2_convert", @@ -4478,7 +4478,7 @@ dependencies = [ [[package]] name = "re_int_histogram" -version = "0.2.5" +version = "0.2.7" dependencies = [ "criterion", "insta", @@ -4489,7 +4489,7 @@ dependencies = [ [[package]] name = "re_log" -version = "0.2.5" +version = "0.2.7" dependencies = [ "env_logger", "js-sys", @@ -4502,7 +4502,7 @@ dependencies = [ [[package]] name = "re_log_encoding" -version = "0.2.5" +version = "0.2.7" dependencies = [ "criterion", "ehttp", @@ -4527,7 +4527,7 @@ dependencies = [ [[package]] name = "re_log_types" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "array-init", @@ -4566,7 +4566,7 @@ dependencies = [ [[package]] name = "re_memory" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "backtrace", @@ -4586,7 +4586,7 @@ dependencies = [ [[package]] name = "re_query" -version = "0.2.5" +version = "0.2.7" dependencies = [ "arrow2", "criterion", @@ -4604,7 +4604,7 @@ dependencies = [ [[package]] name = "re_renderer" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "anyhow", @@ -4657,7 +4657,7 @@ dependencies = [ [[package]] name = "re_sdk" -version = "0.2.5" +version = "0.2.7" dependencies = [ "arrow2_convert", "document-features", @@ -4677,7 +4677,7 @@ dependencies = [ [[package]] name = "re_sdk_comms" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "anyhow", @@ -4693,7 +4693,7 @@ dependencies = [ [[package]] name = "re_smart_channel" -version = "0.2.5" +version = "0.2.7" dependencies = [ "crossbeam", "instant", @@ -4701,7 +4701,7 @@ dependencies = [ [[package]] name = "re_string_interner" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "nohash-hasher", @@ -4712,7 +4712,7 @@ dependencies = [ [[package]] name = "re_tensor_ops" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "ndarray", @@ -4722,7 +4722,7 @@ dependencies = [ [[package]] name = "re_tuid" -version = "0.2.5" +version = "0.2.7" dependencies = [ "arrow2", "arrow2_convert", @@ -4736,7 +4736,7 @@ dependencies = [ [[package]] name = "re_ui" -version = "0.2.5" +version = "0.2.7" dependencies = [ "eframe", "egui", @@ -4755,7 +4755,7 @@ dependencies = [ [[package]] name = "re_viewer" -version = "0.2.5" +version = "0.2.7" dependencies = [ "ahash", "anyhow", @@ -4830,7 +4830,7 @@ dependencies = [ [[package]] name = "re_web_viewer_server" -version = "0.2.5" +version = "0.2.7" dependencies = [ "cargo_metadata", "ctrlc", @@ -4847,7 +4847,7 @@ dependencies = [ [[package]] name = "re_ws_comms" -version = "0.2.5" +version = "0.2.7" dependencies = [ "anyhow", "bincode", @@ -4987,7 +4987,7 @@ dependencies = [ [[package]] name = "rerun_py" -version = "0.2.5" +version = "0.2.7" dependencies = [ "arrow2", "depthai-viewer", @@ -5106,7 +5106,7 @@ dependencies = [ [[package]] name = "run_wasm" -version = "0.2.5" +version = "0.2.7" dependencies = [ "cargo-run-wasm", "pico-args", @@ -5876,7 +5876,7 @@ dependencies = [ [[package]] name = "test_image_memory" -version = "0.2.5" +version = "0.2.7" dependencies = [ "depthai-viewer", "mimalloc", diff --git a/Cargo.toml b/Cargo.toml index 7c2cfd6dca7d..571a6e41de2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,39 +16,39 @@ include = ["../../LICENSE-APACHE", "../../LICENSE-MIT", "**/*.rs", "Cargo.toml"] license = "MIT OR Apache-2.0" repository = "https://github.com/rerun-io/rerun" rust-version = "1.74" -version = "0.2.5" +version = "0.2.7" [workspace.dependencies] # When using alpha-release, always use exact version, e.g. `version = "=0.x.y-alpha.z" # This is because we treat alpha-releases as incompatible, but semver doesn't. # In particular: if we compile rerun 0.3.0-alpha.0 we only want it to use # re_log_types 0.3.0-alpha.0, NOT 0.3.0-alpha.4 even though it is newer and semver-compatible. -re_sdk_comms = { path = "crates/re_sdk_comms", version = "0.2.5" } -re_analytics = { path = "crates/re_analytics", version = "0.2.5" } -re_arrow_store = { path = "crates/re_arrow_store", version = "0.2.5" } -re_build_build_info = { path = "crates/re_build_build_info", version = "0.2.5" } -re_build_info = { path = "crates/re_build_info", version = "0.2.5" } -re_build_web_viewer = { path = "crates/re_build_web_viewer", version = "0.2.5", default-features = false } -re_data_store = { path = "crates/re_data_store", version = "0.2.5" } -re_error = { path = "crates/re_error", version = "0.2.5" } -re_format = { path = "crates/re_format", version = "0.2.5" } -re_int_histogram = { path = "crates/re_int_histogram", version = "0.2.5" } -re_log = { path = "crates/re_log", version = "0.2.5" } -re_log_encoding = { path = "crates/re_log_encoding", version = "0.2.5" } -re_log_types = { path = "crates/re_log_types", version = "0.2.5" } -re_memory = { path = "crates/re_memory", version = "0.2.5" } -re_query = { path = "crates/re_query", version = "0.2.5" } -re_renderer = { path = "crates/re_renderer", version = "0.2.5", default-features = false } -re_sdk = { path = "crates/re_sdk", version = "0.2.5" } -re_smart_channel = { path = "crates/re_smart_channel", version = "0.2.5" } -re_string_interner = { path = "crates/re_string_interner", version = "0.2.5" } -re_tensor_ops = { path = "crates/re_tensor_ops", version = "0.2.5" } -re_tuid = { path = "crates/re_tuid", version = "0.2.5" } -re_ui = { path = "crates/re_ui", version = "0.2.5" } -re_viewer = { path = "crates/re_viewer", version = "0.2.5", default-features = false } -re_web_viewer_server = { path = "crates/re_web_viewer_server", version = "0.2.5" } -re_ws_comms = { path = "crates/re_ws_comms", version = "0.2.5" } -depthai-viewer = { path = "crates/rerun", version = "0.2.5" } +re_sdk_comms = { path = "crates/re_sdk_comms", version = "0.2.7" } +re_analytics = { path = "crates/re_analytics", version = "0.2.7" } +re_arrow_store = { path = "crates/re_arrow_store", version = "0.2.7" } +re_build_build_info = { path = "crates/re_build_build_info", version = "0.2.7" } +re_build_info = { path = "crates/re_build_info", version = "0.2.7" } +re_build_web_viewer = { path = "crates/re_build_web_viewer", version = "0.2.7", default-features = false } +re_data_store = { path = "crates/re_data_store", version = "0.2.7" } +re_error = { path = "crates/re_error", version = "0.2.7" } +re_format = { path = "crates/re_format", version = "0.2.7" } +re_int_histogram = { path = "crates/re_int_histogram", version = "0.2.7" } +re_log = { path = "crates/re_log", version = "0.2.7" } +re_log_encoding = { path = "crates/re_log_encoding", version = "0.2.7" } +re_log_types = { path = "crates/re_log_types", version = "0.2.7" } +re_memory = { path = "crates/re_memory", version = "0.2.7" } +re_query = { path = "crates/re_query", version = "0.2.7" } +re_renderer = { path = "crates/re_renderer", version = "0.2.7", default-features = false } +re_sdk = { path = "crates/re_sdk", version = "0.2.7" } +re_smart_channel = { path = "crates/re_smart_channel", version = "0.2.7" } +re_string_interner = { path = "crates/re_string_interner", version = "0.2.7" } +re_tensor_ops = { path = "crates/re_tensor_ops", version = "0.2.7" } +re_tuid = { path = "crates/re_tuid", version = "0.2.7" } +re_ui = { path = "crates/re_ui", version = "0.2.7" } +re_viewer = { path = "crates/re_viewer", version = "0.2.7", default-features = false } +re_web_viewer_server = { path = "crates/re_web_viewer_server", version = "0.2.7" } +re_ws_comms = { path = "crates/re_ws_comms", version = "0.2.7" } +depthai-viewer = { path = "crates/rerun", version = "0.2.7" } ahash = "0.8" anyhow = "1.0" diff --git a/crates/re_viewer/src/depthai/depthai.rs b/crates/re_viewer/src/depthai/depthai.rs index acd1b39b2b9b..4d7dbce51f24 100644 --- a/crates/re_viewer/src/depthai/depthai.rs +++ b/crates/re_viewer/src/depthai/depthai.rs @@ -51,7 +51,7 @@ impl CameraConfig { } } -#[derive(serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, EnumIter, Debug)] +#[derive(serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, Eq, EnumIter, Debug)] #[allow(non_camel_case_types)] pub enum CameraBoardSocket { AUTO, @@ -212,29 +212,39 @@ impl DeviceProperties { } } -#[derive(serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq)] +#[derive(serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, Eq, Debug, EnumIter)] #[allow(non_camel_case_types)] pub enum DepthProfilePreset { + CUSTOM, + DEFAULT, + FACE, + ROBOTICS, + HIGH_DETAIL, HIGH_DENSITY, HIGH_ACCURACY, } impl Default for DepthProfilePreset { fn default() -> Self { - Self::HIGH_DENSITY + Self::FACE } } impl fmt::Display for DepthProfilePreset { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + Self::DEFAULT => write!(f, "Default"), + Self::CUSTOM => write!(f, "Custom"), + Self::FACE => write!(f, "Face"), + Self::ROBOTICS => write!(f, "Robotics"), + Self::HIGH_DETAIL => write!(f, "High Detail"), Self::HIGH_DENSITY => write!(f, "High Density"), Self::HIGH_ACCURACY => write!(f, "High Accuracy"), } } } -#[derive(serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, Debug, EnumIter)] +#[derive(serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, Eq, Debug, EnumIter)] #[allow(non_camel_case_types)] pub enum MedianFilter { MEDIAN_OFF, @@ -249,8 +259,9 @@ impl Default for MedianFilter { } } -#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, Debug)] +#[derive(serde::Deserialize, serde::Serialize, Clone, PartialEq, Eq, Debug)] pub struct StereoDepthConfig { + pub depth_preset: DepthProfilePreset, pub median: MedianFilter, pub lr_check: bool, pub lrc_threshold: u64, @@ -265,6 +276,7 @@ pub struct StereoDepthConfig { impl Default for StereoDepthConfig { fn default() -> Self { Self { + depth_preset: DepthProfilePreset::default(), median: MedianFilter::default(), lr_check: true, lrc_threshold: 5, @@ -288,6 +300,8 @@ impl StereoDepthConfig { && self.align == other.align && self.extended_disparity == other.extended_disparity && self.subpixel_disparity == other.subpixel_disparity + && self.stereo_pair == other.stereo_pair + && self.depth_preset == other.depth_preset && self != other } } diff --git a/crates/re_viewer/src/ui/device_settings_panel.rs b/crates/re_viewer/src/ui/device_settings_panel.rs index 5fa2a28dd296..c0dc16877e0d 100644 --- a/crates/re_viewer/src/ui/device_settings_panel.rs +++ b/crates/re_viewer/src/ui/device_settings_panel.rs @@ -371,7 +371,8 @@ impl DeviceSettingsPanel { enable_phase_shuffle_temporal_filter, )); } - let mut enable_burst_mode = tof_config.get_enable_burst_mode().unwrap_or(false); + let mut enable_burst_mode = + tof_config.get_enable_burst_mode().unwrap_or(false); if ctx .re_ui .labeled_toggle_switch( @@ -383,7 +384,6 @@ impl DeviceSettingsPanel { { tof_config.set_enable_burst_mode(Some(enable_burst_mode)); } - }) }); } @@ -486,7 +486,7 @@ impl DeviceSettingsPanel { ctx.depthai_state.selected_device.has_stereo_pairs(), |ui| { egui::CollapsingHeader::new( - egui::RichText::new("Depth Settings").color(text_color), + egui::RichText::new("Stereo depth settings").color(text_color), ) .open( if !ctx.depthai_state.selected_device.has_stereo_pairs() { @@ -498,6 +498,11 @@ impl DeviceSettingsPanel { .show(ui, |ui| { ui.vertical(|ui| { ui.set_width(CONFIG_UI_WIDTH); + ctx.re_ui.labeled_combo_box(ui, "Preset", format!("{}", stereo.depth_preset), false, true, |ui| { + for preset in depthai::DepthProfilePreset::iter() { + ui.selectable_value(&mut stereo.depth_preset, preset, format!("{preset}")); + } + }); let (cam1, cam2) = stereo.stereo_pair; ctx.re_ui.labeled_combo_box( ui, @@ -527,6 +532,22 @@ impl DeviceSettingsPanel { } }, ); + ctx.re_ui.labeled_combo_box( + ui, + "Align to", + stereo.align.display_name(ctx.depthai_state.get_connected_cameras()), + false, + true, + |ui| { + for align in ctx.depthai_state.get_connected_cameras() { + ui.selectable_value( + &mut stereo.align, + align.board_socket, + align.board_socket.display_name(ctx.depthai_state.get_connected_cameras()), + ); + } + }, + ); let dot_drag = ctx.re_ui.labeled_dragvalue( ui, egui::Id::from("Dot brightness [mA]"), @@ -554,78 +575,65 @@ impl DeviceSettingsPanel { // Dragging isn't ongoing, but the value changed ctx.depthai_state.set_flood_brightness(device_config.flood_brightness); } - ctx.re_ui.labeled_toggle_switch( - ui, - "LR Check", - &mut stereo.lr_check, - ); - ctx.re_ui.labeled_combo_box( - ui, - "Align to", - stereo.align.display_name(ctx.depthai_state.get_connected_cameras()), - false, - true, - |ui| { - for align in ctx.depthai_state.get_connected_cameras() { - ui.selectable_value( - &mut stereo.align, - align.board_socket, - align.board_socket.display_name(ctx.depthai_state.get_connected_cameras()), - ); - } - }, - ); - ctx.re_ui.labeled_combo_box( - ui, - "Median Filter", - format!("{:?}", stereo.median), - false, - true, - |ui| { - for filter in depthai::MedianFilter::iter() - { - ui.selectable_value( - &mut stereo.median, - filter, - format!("{filter:?}"), - ); - } - }, - ); - ctx.re_ui.labeled_dragvalue( - ui, - egui::Id::from("LR Threshold"), - Some(100.0), - "LR Threshold", - &mut stereo.lrc_threshold, - 0..=10, - ); - ctx.re_ui.labeled_toggle_switch( - ui, - "Extended Disparity", - &mut stereo.extended_disparity, - ); - ctx.re_ui.labeled_toggle_switch( - ui, - "Subpixel Disparity", - &mut stereo.subpixel_disparity, - ); - ctx.re_ui.labeled_dragvalue( - ui, - egui::Id::from("Sigma"), - Some(100.0), - "Sigma", - &mut stereo.sigma, - 0..=65535, - ); - ctx.re_ui.labeled_dragvalue( - ui, - egui::Id::from("Confidence"), - Some(100.0), - "Confidence", - &mut stereo.confidence, - 0..=255, - ); + + if stereo.depth_preset == depthai::DepthProfilePreset::CUSTOM { // advanced settings. Leave it out unless no preset is enabled. + ctx.re_ui.labeled_toggle_switch( + ui, + "LR Check", + &mut stereo.lr_check, + ); + ctx.re_ui.labeled_combo_box( + ui, + "Median Filter", + format!("{:?}", stereo.median), + false, + true, + |ui| { + for filter in depthai::MedianFilter::iter() + { + ui.selectable_value( + &mut stereo.median, + filter, + format!("{filter:?}"), + ); + } + }, + ); + ctx.re_ui.labeled_dragvalue( + ui, + egui::Id::from("LR Threshold"), + Some(100.0), + "LR Threshold", + &mut stereo.lrc_threshold, + 0..=10, + ); + ctx.re_ui.labeled_toggle_switch( + ui, + "Extended Disparity", + &mut stereo.extended_disparity, + ); + ctx.re_ui.labeled_toggle_switch( + ui, + "Subpixel Disparity", + &mut stereo.subpixel_disparity, + ); + ctx.re_ui.labeled_dragvalue( + ui, + egui::Id::from("Sigma"), + Some(100.0), + "Sigma", + &mut stereo.sigma, + 0..=65535, + ); + ctx.re_ui.labeled_dragvalue( + ui, + egui::Id::from("Confidence"), + Some(100.0), + "Confidence", + &mut stereo.confidence, + 0..=255, + ); + } ctx.re_ui.labeled_toggle_switch( ui, "Depth enabled", diff --git a/rerun_py/depthai_viewer/_backend/device.py b/rerun_py/depthai_viewer/_backend/device.py index f20859c85472..930f439a2e4f 100644 --- a/rerun_py/depthai_viewer/_backend/device.py +++ b/rerun_py/depthai_viewer/_backend/device.py @@ -418,9 +418,11 @@ def update_pipeline(self, runtime_only: bool) -> Message: create_tof_on = None for cam in config.cameras: print("Creating camera: ", cam) - - camera_features = next(filter(lambda feat: feat.socket == cam.board_socket, connected_camera_features)) - + try: + camera_features = next(filter(lambda feat: feat.socket == cam.board_socket, connected_camera_features)) + except StopIteration: + self.store.send_message_to_frontend(WarningMessage(f"Failed to find cam {cam.board_socket}")) + continue # When the resolution is too small, the ISP needs to scale it down res_x, res_y = get_size_from_resolution(cam.resolution) @@ -503,7 +505,7 @@ def update_pipeline(self, runtime_only: bool) -> Message: self._component_outputs.items(), ) ) - tof_align = tof_align[0][0] if tof_align else None + tof_align = tof_align[0][1]["component"] if tof_align else None sdk_cam = self._oak.create_tof(create_tof_on, tof_align) self._tof_component = sdk_cam self._component_outputs["tof"] = {"component": sdk_cam, "out": sdk_cam.out.main.set_name("tof")} @@ -531,18 +533,22 @@ def update_pipeline(self, runtime_only: bool) -> Message: print("Right cam width > 1280, setting isp scale to get 800") right_cam.config_color_camera(isp_scale=calculate_isp_scale(right_cam.node.getResolutionWidth())) self._stereo = self._oak.create_stereo(left=left_cam, right=right_cam, name="depth") - + if config.stereo.depth_preset: + self._stereo.node.setDefaultProfilePreset(config.stereo.depth_preset) align_component = self._get_component_by_socket(config.stereo.align) if not align_component: return ErrorMessage(f"{config.stereo.align} is not configured. Couldn't create stereo pair.") - self._stereo.config_stereo( - lr_check=config.stereo.lr_check, - subpixel=config.stereo.subpixel_disparity, - confidence=config.stereo.confidence, - align=align_component, - lr_check_threshold=config.stereo.lrc_threshold, - median=config.stereo.median, - ) + if config.stereo.depth_preset is None: + self._stereo.config_stereo( + lr_check=config.stereo.lr_check, + subpixel=config.stereo.subpixel_disparity, + confidence=config.stereo.confidence, + align=align_component, + lr_check_threshold=config.stereo.lrc_threshold, + median=config.stereo.median, + ) + else: + self._stereo.config_stereo(align=align_component) aligned_camera = self._get_camera_config_by_socket(config, config.stereo.align) if not aligned_camera: @@ -664,8 +670,13 @@ def update(self) -> None: if not hasattr(self, "_queue"): return packets: Dict[str, Any] = self._queue.get_nowait() - for name, packet in packets.items(): - self._packet_handler.log_packet(self._component_outputs[name]["component"], packet) + if not isinstance(packets, dict): # Edge case when the sdk q was built with only one component output. + self._packet_handler.log_packet( + self._component_outputs[list(self._component_outputs.keys())[0]]["component"], packets + ) + else: + for name, packet in packets.items(): + self._packet_handler.log_packet(self._component_outputs[name]["component"], packet) except QueueEmpty: pass diff --git a/rerun_py/depthai_viewer/_backend/device_configuration.py b/rerun_py/depthai_viewer/_backend/device_configuration.py index 0fe023ead605..894b516cb25c 100644 --- a/rerun_py/depthai_viewer/_backend/device_configuration.py +++ b/rerun_py/depthai_viewer/_backend/device_configuration.py @@ -11,6 +11,7 @@ class StereoDepthConfiguration(BaseModel): # type: ignore[misc] + depth_preset: Optional[dai.node.StereoDepth.PresetMode] = None median: Optional[dai.MedianFilter] = dai.MedianFilter.KERNEL_7x7 lr_check: Optional[bool] = True lrc_threshold: int = 5 # 0..10 @@ -25,7 +26,7 @@ class StereoDepthConfiguration(BaseModel): # type: ignore[misc] class Config: arbitrary_types_allowed = True - def __init__(self, **v) -> None: # type: ignore[no-untyped-def] + def __init__(self, **v): # type: ignore[no-untyped-def] if v.get("median", None) and isinstance(v["median"], str): v["median"] = getattr(dai.MedianFilter, v["median"]) if v.get("align", None) and isinstance(v["align"], str): @@ -35,10 +36,16 @@ def __init__(self, **v) -> None: # type: ignore[no-untyped-def] getattr(dai.CameraBoardSocket, v["stereo_pair"][0]), getattr(dai.CameraBoardSocket, v["stereo_pair"][1]), ) - return super().__init__(**v) # type: ignore[no-any-return] + if v.get("depth_preset", None) and isinstance(v["depth_preset"], str): + if v["depth_preset"] == "CUSTOM": + v["depth_preset"] = None + else: + v["depth_preset"] = getattr(dai.node.StereoDepth.PresetMode, v["depth_preset"]) + super().__init__(**v) def dict(self, *args, **kwargs) -> Dict[str, Any]: # type: ignore[no-untyped-def] return { + "depth_preset": self.depth_preset.name if self.depth_preset else "CUSTOM", "median": self.median.name if self.median else None, "lr_check": self.lr_check, "lrc_threshold": self.lrc_threshold, @@ -56,9 +63,7 @@ def to_runtime_controls(self) -> Dict[str, Any]: "align": ( "RECTIFIED_LEFT" if self.align == dai.CameraBoardSocket.LEFT - else "RECTIFIED_RIGHT" - if self.align == dai.CameraBoardSocket.RIGHT - else "CENTER" + else "RECTIFIED_RIGHT" if self.align == dai.CameraBoardSocket.RIGHT else "CENTER" ), "lr_check": self.lr_check, "lrc_check_threshold": self.lrc_threshold, @@ -335,9 +340,9 @@ class DeviceProperties(BaseModel): # type: ignore[misc] id: str cameras: List[CameraFeatures] = [] imu: Optional[ImuKind] - stereo_pairs: List[ - Tuple[dai.CameraBoardSocket, dai.CameraBoardSocket] - ] = [] # Which cameras can be paired for stereo + stereo_pairs: List[Tuple[dai.CameraBoardSocket, dai.CameraBoardSocket]] = ( + [] + ) # Which cameras can be paired for stereo default_stereo_pair: Optional[Tuple[dai.CameraBoardSocket, dai.CameraBoardSocket]] = None info: DeviceInfo = DeviceInfo() diff --git a/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_generic_default.py b/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_generic_default.py index f13c1d546353..8bba439db0b9 100644 --- a/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_generic_default.py +++ b/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_generic_default.py @@ -18,7 +18,7 @@ ), CameraConfiguration( fps=15, - resolution=CameraSensorResolution.THE_480_P, + resolution=CameraSensorResolution.THE_400_P, kind=dai.CameraSensorType.COLOR, board_socket=dai.CameraBoardSocket.CAM_B, stream_enabled=True, @@ -26,7 +26,7 @@ ), CameraConfiguration( fps=15, - resolution=CameraSensorResolution.THE_480_P, + resolution=CameraSensorResolution.THE_400_P, kind=dai.CameraSensorType.COLOR, board_socket=dai.CameraBoardSocket.CAM_C, stream_enabled=True, @@ -34,7 +34,9 @@ ), ], stereo=StereoDepthConfiguration( - align=dai.CameraBoardSocket.CAM_A, stereo_pair=(dai.CameraBoardSocket.CAM_B, dai.CameraBoardSocket.CAM_C) + align=dai.CameraBoardSocket.CAM_A, + stereo_pair=(dai.CameraBoardSocket.CAM_B, dai.CameraBoardSocket.CAM_C), + depth_preset=dai.node.StereoDepth.PresetMode.ROBOTICS, ), ai_model=AiModelConfiguration(camera=dai.CameraBoardSocket.CAM_A), ) diff --git a/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_lr_default.py b/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_lr_default.py index e4bec40e671b..bad062ba114d 100644 --- a/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_lr_default.py +++ b/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_lr_default.py @@ -33,7 +33,9 @@ ), ], stereo=StereoDepthConfiguration( - align=dai.CameraBoardSocket.CAM_A, stereo_pair=(dai.CameraBoardSocket.CAM_B, dai.CameraBoardSocket.CAM_C) + align=dai.CameraBoardSocket.CAM_A, + stereo_pair=(dai.CameraBoardSocket.CAM_B, dai.CameraBoardSocket.CAM_C), + depth_preset=dai.node.StereoDepth.PresetMode.ROBOTICS, ), ai_model=None, ) diff --git a/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_sr_default.py b/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_sr_default.py index 39b22002f52d..b6a1f31f5815 100644 --- a/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_sr_default.py +++ b/rerun_py/depthai_viewer/_backend/device_defaults/oak_d_sr_default.py @@ -27,7 +27,8 @@ ), ], stereo=StereoDepthConfiguration( - align=dai.CameraBoardSocket.CAM_B, stereo_pair=(dai.CameraBoardSocket.CAM_B, dai.CameraBoardSocket.CAM_C) + align=dai.CameraBoardSocket.CAM_B, + stereo_pair=(dai.CameraBoardSocket.CAM_B, dai.CameraBoardSocket.CAM_C), ), ai_model=AiModelConfiguration(camera=dai.CameraBoardSocket.CAM_B), ) diff --git a/rerun_py/depthai_viewer/requirements.txt b/rerun_py/depthai_viewer/requirements.txt index abedd9f30ffb..afea774b16b3 100644 --- a/rerun_py/depthai_viewer/requirements.txt +++ b/rerun_py/depthai_viewer/requirements.txt @@ -4,7 +4,7 @@ setuptools ahrs # depthai_sdk conflicts with depthai, so it's installed seperatelly in __main__.py --extra-index-url https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local -depthai==2.28 +depthai==2.29.0.0 websockets pydantic==1.9 deprecated