From a4ea0a12deca3470ea63ba6306f7ae036647360d Mon Sep 17 00:00:00 2001 From: ban-k-ai <152968466+ban-k-ai@users.noreply.github.com> Date: Fri, 8 Dec 2023 15:27:59 +0100 Subject: [PATCH] UI changes (#36) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixed wrong timestamp in xlink plot * WIP add support for tof (oak d sr poe) * Accommodate new sdk, make tof stream show up, more or less properly. Still need to fix a few gui bugs. * UI changes * device setting ui changes * xlink timestamp fix * dependency installer ui respect style * more information when downloading blobs fails * fix formatting --------- Co-authored-by: Tomáš Kubíček Co-authored-by: zrezke --- crates/re_ui/src/lib.rs | 28 +++++--- crates/re_viewer/src/app.rs | 35 +++++----- .../src/depthai/dependency_installer.rs | 67 +++++++++++-------- crates/re_viewer/src/native.rs | 45 ++++++------- crates/re_viewer/src/ui/blueprint.rs | 3 +- .../re_viewer/src/ui/device_settings_panel.rs | 40 +++++------ crates/re_viewer/src/ui/stats_panel.rs | 42 ++++++------ crates/re_viewer/src/ui/viewport.rs | 50 +++++++------- rerun_py/depthai_viewer/_backend/device.py | 13 ++-- .../_backend/device_configuration.py | 12 ++-- .../depthai_viewer/_backend/packet_handler.py | 3 +- .../depthai_viewer/install_requirements.py | 31 +++++++-- 12 files changed, 212 insertions(+), 157 deletions(-) diff --git a/crates/re_ui/src/lib.rs b/crates/re_ui/src/lib.rs index 9bf3a0d58683..3f15e4ae099e 100644 --- a/crates/re_ui/src/lib.rs +++ b/crates/re_ui/src/lib.rs @@ -83,12 +83,18 @@ pub struct ReUi { impl ReUi { /// Create [`ReUi`] and apply style to the given egui context. pub fn load_and_apply(egui_ctx: &egui::Context) -> Self { - Self { + let re_ui = Self { egui_ctx: egui_ctx.clone(), design_tokens: DesignTokens::load_and_apply(egui_ctx), static_image_cache: Arc::new(Mutex::new(StaticImageCache::default())), delayed_drag_values: Default::default(), - } + }; + //This is probably not the best place to set the visuals but it will do for now + let mut visuals = egui::Visuals::dark(); + + visuals.selection.bg_fill = Color32::from_rgb(88, 12, 236); + re_ui.egui_ctx.set_visuals(visuals); + re_ui } pub fn rerun_logo(&self) -> Arc { @@ -169,6 +175,7 @@ impl ReUi { menu_contents: impl FnOnce(&mut egui::Ui) -> R, ) { let align = egui::Align::Center; + let text_color = ui.style().visuals.weak_text_color(); let layout = if left_to_right { egui::Layout::left_to_right(align) } else { @@ -177,7 +184,7 @@ impl ReUi { ui.with_layout(layout, |ui| { if left_to_right { - ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900)); + ui.label(egui::RichText::new(label).color(text_color)); } if wrap { ui.add_sized( @@ -203,12 +210,13 @@ impl ReUi { } if !left_to_right { - ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900)); + ui.label(egui::RichText::new(label).color(text_color)); } }); } pub fn labeled_checkbox(&self, ui: &mut egui::Ui, label: &str, value: &mut bool) { + let text_color = ui.style().visuals.weak_text_color(); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { ui.add_sized( [Self::box_width(), Self::box_height()], @@ -219,7 +227,7 @@ impl ReUi { .response }, ); - ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900)); + ui.label(egui::RichText::new(label).color(text_color)); }); } @@ -283,6 +291,7 @@ impl ReUi { Num: egui::emath::Numeric, { let mut borrow_map = self.delayed_drag_values.borrow_mut(); + let text_color = ui.style().visuals.weak_text_color(); let state = borrow_map.entry(id).or_insert(DelayedDragState { delay_ms: delay.unwrap_or(0.0), last_update: instant::Instant::now(), @@ -294,7 +303,7 @@ impl ReUi { [Self::box_width(), Self::box_height()], egui::DragValue::new(&mut state.value).clamp_range(range), ); - ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900)); + ui.label(egui::RichText::new(label).color(text_color)); response }) .inner; @@ -308,6 +317,7 @@ impl ReUi { } pub fn labeled_toggle_switch(&self, ui: &mut egui::Ui, label: &str, value: &mut bool) { + let text_color = ui.style().visuals.weak_text_color(); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { ui.add_sized( [Self::box_width(), Self::box_height()], @@ -318,16 +328,18 @@ impl ReUi { .response }, ); - ui.label(egui::RichText::new(label).color(self.design_tokens.gray_900)); + ui.label(egui::RichText::new(label).color(text_color)); }); } pub fn top_panel_frame(&self) -> egui::Frame { let mut frame = egui::Frame { inner_margin: Self::top_bar_margin(), - fill: self.design_tokens.top_bar_color, + fill: self.egui_ctx.style().visuals.panel_fill, + // fill: self.design_tokens.top_bar_color, ..Default::default() }; + if CUSTOM_WINDOW_DECORATIONS { frame.rounding.nw = Self::native_window_rounding(); frame.rounding.ne = Self::native_window_rounding(); diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index a3a40e814e0b..d1e8db00470e 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -641,7 +641,8 @@ impl eframe::App for App { file_saver_progress_ui(egui_ctx, self); // toasts for background file saver - let mut main_panel_frame = egui::Frame::default(); + let mut main_panel_frame = egui::Frame::default().fill(egui_ctx.style().visuals.panel_fill); + if re_ui::CUSTOM_WINDOW_DECORATIONS { // Add some margin so that we can later paint an outline around it all. main_panel_frame.inner_margin = 1.0.into(); @@ -1424,22 +1425,22 @@ fn top_bar_ui( let extra_margin = (ui.available_height() - 24.0) / 2.0; ui.add_space(extra_margin); } - let mut blueprint_panel_expanded = blueprint.blueprint_panel_expanded; - if app - .re_ui - .medium_icon_toggle_button( - ui, - &re_ui::icons::LEFT_PANEL_TOGGLE, - &mut blueprint_panel_expanded, - ) - .on_hover_text(format!( - "Toggle Blueprint View{}", - Command::ToggleBlueprintPanel.format_shortcut_tooltip_suffix(ui.ctx()) - )) - .clicked() - { - app.pending_commands.push(Command::ToggleBlueprintPanel); - } + // let mut blueprint_panel_expanded = blueprint.blueprint_panel_expanded; + // if app + // .re_ui + // .medium_icon_toggle_button( + // ui, + // &re_ui::icons::LEFT_PANEL_TOGGLE, + // &mut blueprint_panel_expanded, + // ) + // .on_hover_text(format!( + // "Toggle Blueprint View{}", + // Command::ToggleBlueprintPanel.format_shortcut_tooltip_suffix(ui.ctx()) + // )) + // .clicked() + // { + // app.pending_commands.push(Command::ToggleBlueprintPanel); + // } if cfg!(debug_assertions) && app.state.app_options.show_metrics { ui.vertical_centered(|ui| { diff --git a/crates/re_viewer/src/depthai/dependency_installer.rs b/crates/re_viewer/src/depthai/dependency_installer.rs index 25335a443655..d0ffce6b3d2d 100644 --- a/crates/re_viewer/src/depthai/dependency_installer.rs +++ b/crates/re_viewer/src/depthai/dependency_installer.rs @@ -189,8 +189,9 @@ impl DependencyInstaller { } pub fn show(&mut self, re_ui: &re_ui::ReUi, ui: &mut egui::Ui) { + let panel_color = ui.style().visuals.panel_fill; let frame = egui::Frame::default() - .fill(egui::Color32::WHITE) + .fill(panel_color) .stroke(egui::Stroke::new(1.0, egui::Color32::GRAY)) .inner_margin(egui::Margin::symmetric(16.0, 0.0)) .rounding(8.0); @@ -202,11 +203,13 @@ impl DependencyInstaller { .resizable(true) .default_height(600.0) .show(ui.ctx(), |ui| { - let frame = egui::Frame::default().inner_margin(egui::Margin { - top: 24.0, - bottom: 4.0, - ..0.0.into() - }); + let frame = egui::Frame::default() + .fill(panel_color) + .inner_margin(egui::Margin { + top: 24.0, + bottom: 4.0, + ..0.0.into() + }); egui::TopBottomPanel::top("header") .frame(frame) .show_separator_line(false) @@ -248,33 +251,41 @@ impl DependencyInstaller { .show_inside(ui, |_| ()); let frame = egui::Frame::default() - .fill(egui::Color32::WHITE) + .fill(panel_color) .rounding(4.0) .stroke(egui::Stroke::new(1.0, re_ui.design_tokens.gray_400)) .inner_margin(egui::Margin::same(12.0)); - egui::CollapsingHeader::new("Details").default_open(true).show_unindented(ui, |ui| { - egui::CentralPanel::default() - .frame(frame) - .show_inside(ui, |ui| { - ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| { - if re_ui.small_icon_button(ui, &re_ui::icons::COPY).clicked() { - crate::misc::Clipboard::with(|clipboard| { - clipboard.set_text(self.stdio.clone()); - }); - } + egui::CollapsingHeader::new("Details") + .default_open(true) + .show_unindented(ui, |ui| { + egui::CentralPanel::default() + .frame(frame) + .show_inside(ui, |ui| { + ui.with_layout( + egui::Layout::right_to_left(egui::Align::TOP), + |ui| { + if re_ui + .small_icon_button(ui, &re_ui::icons::COPY) + .clicked() + { + crate::misc::Clipboard::with(|clipboard| { + clipboard.set_text(self.stdio.clone()); + }); + } + }, + ); + re_ui.styled_scrollbar( + ui, + re_ui::ScrollAreaDirection::Both, + [false; 2], + true, + |ui| { + ui.label(&self.stdio); + }, + ); }); - re_ui.styled_scrollbar( - ui, - re_ui::ScrollAreaDirection::Both, - [false; 2], - true, - |ui| { - ui.label(&self.stdio); - }, - ); - }); - }); + }); }); } diff --git a/crates/re_viewer/src/native.rs b/crates/re_viewer/src/native.rs index 37edb5399def..75b14136432d 100644 --- a/crates/re_viewer/src/native.rs +++ b/crates/re_viewer/src/native.rs @@ -1,9 +1,8 @@ -use re_log_types::LogMsg; use crate::APPLICATION_NAME; +use re_log_types::LogMsg; -type AppCreator = Box< - dyn FnOnce(&eframe::CreationContext<'_>, re_ui::ReUi) -> Box ->; +type AppCreator = + Box, re_ui::ReUi) -> Box>; // NOTE: the name of this function is hard-coded in `crates/rerun/src/crash_handler.rs`! pub fn run_native_app(app_creator: AppCreator) -> eframe::Result<()> { @@ -18,9 +17,13 @@ pub fn run_native_app(app_creator: AppCreator) -> eframe::Result<()> { decorated: !re_ui::CUSTOM_WINDOW_DECORATIONS, // To have rounded corners we need transparency: transparent: re_ui::CUSTOM_WINDOW_DECORATIONS, - + // icon_data: Some(eframe::IconData { + // rgba: re_ui::icons::APP_ICON.png_bytes.to_vec(), + // width: 96, + // height: 96, + // }), follow_system_theme: false, - default_theme: eframe::Theme::Light, + default_theme: eframe::Theme::Dark, renderer: eframe::Renderer::Wgpu, wgpu_options: crate::wgpu_options(), @@ -36,7 +39,7 @@ pub fn run_native_app(app_creator: AppCreator) -> eframe::Result<()> { Box::new(move |cc| { let re_ui = crate::customize_eframe(cc); app_creator(cc, re_ui) - }) + }), ) } @@ -44,25 +47,21 @@ pub fn run_native_viewer_with_messages( build_info: re_build_info::BuildInfo, app_env: crate::AppEnvironment, startup_options: crate::StartupOptions, - log_messages: Vec + log_messages: Vec, ) -> eframe::Result<()> { let (tx, rx) = re_smart_channel::smart_channel(re_smart_channel::Source::Sdk); for log_msg in log_messages { tx.send(log_msg).ok(); } - run_native_app( - Box::new(move |cc, re_ui| { - Box::new( - crate::App::from_receiver( - build_info, - &app_env, - startup_options, - re_ui, - cc.storage, - rx, - std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)) - ) - ) - }) - ) + run_native_app(Box::new(move |cc, re_ui| { + Box::new(crate::App::from_receiver( + build_info, + &app_env, + startup_options, + re_ui, + cc.storage, + rx, + std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)), + )) + })) } diff --git a/crates/re_viewer/src/ui/blueprint.rs b/crates/re_viewer/src/ui/blueprint.rs index 969fb15465f5..21dbcf773d4d 100644 --- a/crates/re_viewer/src/ui/blueprint.rs +++ b/crates/re_viewer/src/ui/blueprint.rs @@ -18,7 +18,7 @@ impl Blueprint { pub fn new(egui_ctx: &egui::Context) -> Self { let screen_size = egui_ctx.screen_rect().size(); Self { - blueprint_panel_expanded: true, + blueprint_panel_expanded: false, selection_panel_expanded: true, time_panel_expanded: screen_size.y > 600.0, viewport: Default::default(), @@ -27,7 +27,6 @@ impl Blueprint { pub fn blueprint_panel_and_viewport(&mut self, ctx: &mut ViewerContext<'_>, ui: &mut egui::Ui) { crate::profile_function!(); - let spaces_info = SpaceInfoCollection::new(&ctx.log_db.entity_db); self.viewport.on_frame_start(ctx, &spaces_info); diff --git a/crates/re_viewer/src/ui/device_settings_panel.rs b/crates/re_viewer/src/ui/device_settings_panel.rs index 1d18bfa77a4f..bb58ae97fb60 100644 --- a/crates/re_viewer/src/ui/device_settings_panel.rs +++ b/crates/re_viewer/src/ui/device_settings_panel.rs @@ -10,7 +10,7 @@ use strum::IntoEnumIterator; // Needed for enum::iter() #[serde(default)] pub(crate) struct DeviceSettingsPanel {} -const CONFIG_UI_WIDTH: f32 = 224.0; +const CONFIG_UI_WIDTH: f32 = 280.0; impl DeviceSettingsPanel { #[allow(clippy::unused_self)] @@ -26,12 +26,14 @@ impl DeviceSettingsPanel { egui::CentralPanel::default() .frame(egui::Frame { inner_margin: egui::Margin::same(0.0), - fill: egui::Color32::WHITE, + fill: ui.visuals().panel_fill, + // fill: egui::Color32::WHITE, ..Default::default() }) .show_inside(ui, |ui| { (egui::Frame { inner_margin: egui::Margin::same(re_ui::ReUi::view_padding()), + fill: ui.visuals().panel_fill, ..Default::default() }) .show(ui, |ui| { @@ -163,9 +165,10 @@ impl DeviceSettingsPanel { camera_features: &depthai::CameraFeatures, camera_config: &mut depthai::CameraConfig, ) { - let primary_700 = ctx.re_ui.design_tokens.primary_700; + // let text_color = ctx.re_ui.design_tokens.primary_700; + let text_color = ui.style().visuals.strong_text_color(); egui::CollapsingHeader::new( - egui::RichText::new(camera_features.board_socket.display_name(ctx)).color(primary_700), + egui::RichText::new(camera_features.board_socket.display_name(ctx)).color(text_color), ) .default_open(true) .show(ui, |ui| { @@ -204,14 +207,16 @@ impl DeviceSettingsPanel { 0..=camera_features.max_fps, ); ctx.re_ui - .labeled_checkbox(ui, "Stream", &mut camera_config.stream_enabled); + .labeled_toggle_switch(ui, "Stream", &mut camera_config.stream_enabled); }); }); } fn device_configuration_ui(ctx: &mut ViewerContext<'_>, ui: &mut egui::Ui) { let mut device_config = ctx.depthai_state.modified_device_config.clone(); - let primary_700 = ctx.re_ui.design_tokens.primary_700; + + let text_color = ui.style().visuals.strong_text_color(); + // let text_color = ctx.re_ui.design_tokens.primary_700; let connected_cameras = ctx.depthai_state.get_connected_cameras().clone(); ctx.re_ui.styled_scrollbar( @@ -221,7 +226,7 @@ impl DeviceSettingsPanel { false, |ui| { (egui::Frame { - fill: ctx.re_ui.design_tokens.gray_50, + fill: ui.style().visuals.panel_fill, inner_margin: egui::Margin::symmetric(30.0, 21.0), ..Default::default() }) @@ -240,7 +245,7 @@ impl DeviceSettingsPanel { } ui.collapsing( - egui::RichText::new("AI settings").color(primary_700), + egui::RichText::new("AI settings").color(text_color), |ui| { ui.vertical(|ui| { ui.set_width(CONFIG_UI_WIDTH); @@ -295,7 +300,7 @@ impl DeviceSettingsPanel { ctx.depthai_state.selected_device.has_stereo_pairs(), |ui| { egui::CollapsingHeader::new( - egui::RichText::new("Depth Settings").color(primary_700), + egui::RichText::new("Depth Settings").color(text_color), ) .open( if !ctx.depthai_state.selected_device.has_stereo_pairs() { @@ -336,7 +341,7 @@ impl DeviceSettingsPanel { } }, ); - ctx.re_ui.labeled_checkbox( + ctx.re_ui.labeled_toggle_switch( ui, "LR Check", &mut depth.lr_check, @@ -382,12 +387,12 @@ impl DeviceSettingsPanel { &mut depth.lrc_threshold, 0..=10, ); - ctx.re_ui.labeled_checkbox( + ctx.re_ui.labeled_toggle_switch( ui, "Extended Disparity", &mut depth.extended_disparity, ); - ctx.re_ui.labeled_checkbox( + ctx.re_ui.labeled_toggle_switch( ui, "Subpixel Disparity", &mut depth.subpixel_disparity, @@ -464,14 +469,11 @@ impl DeviceSettingsPanel { ui.add_enabled_ui(apply_enabled, |ui| { ui.scope(|ui| { let mut style = ui.style_mut().clone(); + let color = style.visuals.selection.bg_fill; + //TODO(tomas):Investigate whether this could be default button style if apply_enabled { - let color = - ctx.re_ui.design_tokens.primary_bg_color; - let hover_color = - ctx.re_ui.design_tokens.primary_hover_bg_color; - style.visuals.widgets.hovered.bg_fill = hover_color; - style.visuals.widgets.hovered.weak_bg_fill = - hover_color; + style.visuals.widgets.hovered.bg_fill = color; + style.visuals.widgets.hovered.weak_bg_fill = color; style.visuals.widgets.inactive.bg_fill = color; style.visuals.widgets.inactive.weak_bg_fill = color; style.visuals.widgets.inactive.fg_stroke.color = diff --git a/crates/re_viewer/src/ui/stats_panel.rs b/crates/re_viewer/src/ui/stats_panel.rs index d6038cb08ff2..3f0f6c98567f 100644 --- a/crates/re_viewer/src/ui/stats_panel.rs +++ b/crates/re_viewer/src/ui/stats_panel.rs @@ -132,6 +132,7 @@ impl StatsPanelState { if xlink_stats.timestamp == then { return; } + written = (written - total_written) / (xlink_stats.timestamp - then); read = (read - total_read) / (xlink_stats.timestamp - then); } @@ -145,21 +146,23 @@ impl StatsPanelState { (xlink_stats.bytes_read / 1e6 as i64) as f64, ], ); - self.avg_xlink_stats_plot_history.add( - xlink_stats.timestamp, - [ - self.xlink_stats_history - .iter() - .map(|(_, [written, _, _, _])| written) - .sum::() - / self.xlink_stats_history.len() as f64, - self.xlink_stats_history - .iter() - .map(|(_, [_, read, _, _])| read) - .sum::() - / self.xlink_stats_history.len() as f64, - ], - ); + let written_sum = self + .xlink_stats_history + .iter() + .map(|(_, [written, _, _, _])| written) + .sum::(); + let read_sum = self + .xlink_stats_history + .iter() + .map(|(_, [_, read, _, _])| read) + .sum::(); + let history_len = self.xlink_stats_history.len() as f64; + + let written_avg = written_sum / history_len; + let read_avg = read_sum / history_len; + + self.avg_xlink_stats_plot_history + .add(now, [written_avg, read_avg]); }); } } @@ -233,16 +236,17 @@ impl<'a, 'b> StatsTabs<'a, 'b> { inner_margin: egui::Margin::same(re_ui::ReUi::view_padding()), ..Default::default() } - .show(ui, |ui| { + .show(ui, |ui| + { let (history, display_name, unit) = ( &mut self.state.avg_xlink_stats_plot_history, "XLink throughput", "", ); let Some(latest) = history.latest() else { - ui.label(format!("No {display_name} data yet")); - return; - }; + ui.label(format!("No {display_name} data yet")); + return; + }; ui.label(format!( "{display_name}: avg. Sent from device {:.2} MB/s, avg. Sent to Device: {:.2} MB/s", latest[0], latest[1] diff --git a/crates/re_viewer/src/ui/viewport.rs b/crates/re_viewer/src/ui/viewport.rs index 172b7051bd36..018b3191493b 100644 --- a/crates/re_viewer/src/ui/viewport.rs +++ b/crates/re_viewer/src/ui/viewport.rs @@ -824,31 +824,31 @@ fn space_view_options_ui( return; }; - if ctx - .re_ui - .small_icon_button(ui, &re_ui::icons::ADD) - .clicked() - { - // Create a new space view that is identical to this one - let new_sv = space_view.duplicate(ctx); - let id = new_sv.id.clone(); - viewport.add_space_view(new_sv); - viewport - .has_been_user_edited - .insert(viewport.space_views[&id].space_path.clone(), true); - } - - if ctx - .re_ui - .small_icon_button(ui, &re_ui::icons::REMOVE) - .clicked() - { - viewport.has_been_user_edited.insert( - viewport.space_views[&space_view_id].space_path.clone(), - true, - ); - viewport.remove(&space_view_id); - } + // if ctx + // .re_ui + // .small_icon_button(ui, &re_ui::icons::ADD) + // .clicked() + // { + // // Create a new space view that is identical to this one + // let new_sv = space_view.duplicate(ctx); + // let id = new_sv.id.clone(); + // viewport.add_space_view(new_sv); + // viewport + // .has_been_user_edited + // .insert(viewport.space_views[&id].space_path.clone(), true); + // } + + // if ctx + // .re_ui + // .small_icon_button(ui, &re_ui::icons::REMOVE) + // .clicked() + // { + // viewport.has_been_user_edited.insert( + // viewport.space_views[&space_view_id].space_path.clone(), + // true, + // ); + // viewport.remove(&space_view_id); + // } // Show help last, since not all space views have help text help_text_ui(ui, &space_view); diff --git a/rerun_py/depthai_viewer/_backend/device.py b/rerun_py/depthai_viewer/_backend/device.py index a4604c3afa61..f22388e80518 100644 --- a/rerun_py/depthai_viewer/_backend/device.py +++ b/rerun_py/depthai_viewer/_backend/device.py @@ -254,7 +254,9 @@ def reconnect_to_oak(self) -> Message: timeout_start = time.time() while time.time() - timeout_start < 10: available_devices = [ - device.getMxId() for device in dai.Device.getAllAvailableDevices() # type: ignore[call-arg] + # type: ignore[call-arg] + device.getMxId() + for device in dai.Device.getAllAvailableDevices() ] if self.id in available_devices: break @@ -413,7 +415,8 @@ def update_pipeline(self, runtime_only: bool) -> Message: # In case of ISP scaling, don't change the sensor resolution in the pipeline config # to keep it logical for the user in the UI - sensor_resolution: Optional[CameraSensorResolution] = cam.resolution # None for ToF + # None for ToF + sensor_resolution: Optional[CameraSensorResolution] = cam.resolution if not does_sensor_support_resolution: smallest_supported_resolution = [ config for config in camera_features.configs if config.type == camera_features.supportedTypes[0] @@ -434,7 +437,8 @@ def update_pipeline(self, runtime_only: bool) -> Message: elif sensor_resolution is not None: sdk_cam = self._oak.create_camera( cam.board_socket, - sensor_resolution.as_sdk_resolution(), # type: ignore[union-attr] + # type: ignore[union-attr] + sensor_resolution.as_sdk_resolution(), cam.fps, encode=self.use_encoding, ) @@ -532,7 +536,8 @@ def update_pipeline(self, runtime_only: bool) -> Message: if running: self._pipeline_start_t = time.time() self._sys_info_q = self._oak.device.getOutputQueue("sys_logger", 1, False) - self.store.set_pipeline_config(config) # We might have modified the config, so store it + # We might have modified the config, so store it + self.store.set_pipeline_config(config) try: self._oak.poll() except RuntimeError: diff --git a/rerun_py/depthai_viewer/_backend/device_configuration.py b/rerun_py/depthai_viewer/_backend/device_configuration.py index 652db3f73742..73835f918d4b 100644 --- a/rerun_py/depthai_viewer/_backend/device_configuration.py +++ b/rerun_py/depthai_viewer/_backend/device_configuration.py @@ -193,7 +193,8 @@ def dict(self, *args, **kwargs) -> Dict[str, Any]: # type: ignore[no-untyped-de } @classmethod - def create_left(cls, **kwargs) -> "CameraConfiguration": # type: ignore[no-untyped-def] + # type: ignore[no-untyped-def] + def create_left(cls, **kwargs) -> "CameraConfiguration": if not kwargs.get("kind", None): kwargs["kind"] = dai.CameraSensorType.MONO if not kwargs.get("resolution", None): @@ -201,7 +202,8 @@ def create_left(cls, **kwargs) -> "CameraConfiguration": # type: ignore[no-unty return cls(board_socket="LEFT", **kwargs) @classmethod - def create_right(cls, **kwargs) -> "CameraConfiguration": # type: ignore[no-untyped-def] + # type: ignore[no-untyped-def] + def create_right(cls, **kwargs) -> "CameraConfiguration": if not kwargs.get("kind", None): kwargs["kind"] = dai.CameraSensorType.MONO if not kwargs.get("resolution", None): @@ -209,7 +211,8 @@ def create_right(cls, **kwargs) -> "CameraConfiguration": # type: ignore[no-unt return cls(board_socket="RIGHT", **kwargs) @classmethod - def create_color(cls, **kwargs) -> "CameraConfiguration": # type: ignore[no-untyped-def] + # type: ignore[no-untyped-def] + def create_color(cls, **kwargs) -> "CameraConfiguration": if not kwargs.get("kind", None): kwargs["kind"] = dai.CameraSensorType.COLOR if not kwargs.get("resolution", None): @@ -310,7 +313,8 @@ def dict(self, *args, **kwargs) -> Dict[str, Any]: # type: ignore[no-untyped-de (1920, 1080): CameraSensorResolution.THE_1080_P, (1920, 1200): CameraSensorResolution.THE_1200_P, # AR0234 (3840, 2160): CameraSensorResolution.THE_4_K, - (4000, 3000): CameraSensorResolution.THE_4000X3000, # IMX582 with binning enabled + # IMX582 with binning enabled + (4000, 3000): CameraSensorResolution.THE_4000X3000, (4056, 3040): CameraSensorResolution.THE_12_MP, # IMX378, IMX477, IMX577 (4208, 3120): CameraSensorResolution.THE_13_MP, # AR214 (5312, 6000): CameraSensorResolution.THE_5312X6000, # IMX582 cropped diff --git a/rerun_py/depthai_viewer/_backend/packet_handler.py b/rerun_py/depthai_viewer/_backend/packet_handler.py index 3c74dab6b3b4..e025262bd815 100644 --- a/rerun_py/depthai_viewer/_backend/packet_handler.py +++ b/rerun_py/depthai_viewer/_backend/packet_handler.py @@ -46,7 +46,8 @@ def reset(self) -> None: def set_camera_intrinsics_getter( self, camera_intrinsics_getter: Callable[[dai.CameraBoardSocket, int, int], NDArray[np.float32]] ) -> None: - self._get_camera_intrinsics = camera_intrinsics_getter # type: ignore[assignment, misc] + # type: ignore[assignment, misc] + self._get_camera_intrinsics = camera_intrinsics_getter def log_packet( self, diff --git a/rerun_py/depthai_viewer/install_requirements.py b/rerun_py/depthai_viewer/install_requirements.py index 6631be283196..d810ccade7e4 100644 --- a/rerun_py/depthai_viewer/install_requirements.py +++ b/rerun_py/depthai_viewer/install_requirements.py @@ -7,7 +7,8 @@ import traceback from typing import Any, Dict -from depthai_viewer import version as depthai_viewer_version # type: ignore[attr-defined] +# type: ignore[attr-defined] +from depthai_viewer import version as depthai_viewer_version script_path = os.path.dirname(os.path.abspath(__file__)) venv_dir = os.path.join(script_path, "venv-" + depthai_viewer_version()) @@ -87,7 +88,8 @@ def create_venv_and_install_dependencies() -> None: "-m", "pip", "install", - "depthai-sdk==1.13.1.dev0+b0340e0c4ad869711d7d5fff48e41c46fe41f475" "--extra-index-url", + "depthai-sdk==1.13.1.dev0+b0340e0c4ad869711d7d5fff48e41c46fe41f475", + "--extra-index-url", "https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local/", # "git+https://github.com/luxonis/depthai@develop#subdirectory=depthai_sdk", ], @@ -111,11 +113,26 @@ def create_venv_and_install_dependencies() -> None: env = os.environ.copy() env["PYTHONPATH"] = venv_packages_dir # Download blobs - subprocess.run( - [sys.executable, "-c", "from depthai_viewer.install_requirements import download_blobs; download_blobs()"], - check=True, - env=env, - ) + try: + subprocess.run( + [ + sys.executable, + "-c", + "from depthai_viewer.install_requirements import download_blobs; download_blobs()", + ], + check=True, + env=env, + capture_output=True, + ) + except subprocess.CalledProcessError as e: + print("stderr") + print(e.stderr.decode("utf-8")) + print("stdout") + print(e.stdout.decode("utf-8")) + print("output") + print(e.output.decode("utf-8")) + + raise e # Restore original SIGINT handler signal.signal(signal.SIGINT, original_sigint_handler)