Skip to content

Commit

Permalink
Added Custom config (UI only) stereo depth conf. Leave Default stereo…
Browse files Browse the repository at this point in the history
… depth config untouched by the viewer settings.
  • Loading branch information
Filip Jeretina committed Nov 18, 2024
1 parent 2a8a16d commit 80d03be
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
6 changes: 4 additions & 2 deletions crates/re_viewer/src/depthai/depthai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ impl DeviceProperties {
#[derive(serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, Eq, Debug, EnumIter)]
#[allow(non_camel_case_types)]
pub enum DepthProfilePreset {
NONE,
CUSTOM,
DEFAULT,
FACE,
ROBOTICS,
HIGH_FPS,
Expand All @@ -234,7 +235,8 @@ impl Default for DepthProfilePreset {
impl fmt::Display for DepthProfilePreset {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NONE => write!(f, "None"),
Self::DEFAULT => write!(f, "Default"),
Self::CUSTOM => write!(f, "Custom"),
Self::FACE => write!(f, "Face"),
Self::ROBOTICS => write!(f, "Robotics"),
Self::HIGH_FPS => write!(f, "High FPS"),
Expand Down
34 changes: 17 additions & 17 deletions crates/re_viewer/src/ui/device_settings_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,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]"),
Expand Down Expand Up @@ -560,28 +576,12 @@ impl DeviceSettingsPanel {
ctx.depthai_state.set_flood_brightness(device_config.flood_brightness);
}

if stereo.depth_preset == depthai::DepthProfilePreset::NONE { // advanced settings. Leave it out unless no preset is enabled.
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,
"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",
Expand Down
4 changes: 2 additions & 2 deletions rerun_py/depthai_viewer/_backend/device_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ def __init__(self, **v): # type: ignore[no-untyped-def]
getattr(dai.CameraBoardSocket, v["stereo_pair"][1]),
)
if v.get("depth_preset", None) and isinstance(v["depth_preset"], str):
if v["depth_preset"] == "NONE":
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 "NONE",
"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,
Expand Down

0 comments on commit 80d03be

Please sign in to comment.