Skip to content

Commit

Permalink
Fixed tiny1c temperature resolution. Bumped depthai tof decoding bran…
Browse files Browse the repository at this point in the history
…ch. Added new filters. Don't fail when sentry init fails. Likely fix viewer crashing when there is no internet available.
  • Loading branch information
zrezke committed May 14, 2024
1 parent 51f682f commit 0b7c955
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 15 deletions.
26 changes: 26 additions & 0 deletions crates/re_viewer/src/depthai/depthai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ pub struct ToFConfig {
enable_temperature_correction: Option<bool>,
enable_wiggle_correction: Option<bool>,
enable_phase_unwrapping: Option<bool>,
enable_phase_shuffle_temporal_filter: Option<bool>,
enable_burst_mode: Option<bool>,
#[serde(skip)]
modified: bool,
}
Expand All @@ -370,6 +372,8 @@ impl Default for ToFConfig {
enable_temperature_correction: None,
enable_wiggle_correction: None,
enable_phase_unwrapping: None,
enable_phase_shuffle_temporal_filter: Some(true),
enable_burst_mode: Some(false),
modified: false,
}
}
Expand Down Expand Up @@ -408,6 +412,14 @@ impl ToFConfig {
self.enable_phase_unwrapping
}

pub fn get_enable_phase_shuffle_temporal_filter(&self) -> Option<bool> {
self.enable_phase_shuffle_temporal_filter
}

pub fn get_enable_burst_mode(&self) -> Option<bool> {
self.enable_burst_mode
}

pub fn set_median_filter(&mut self, median: MedianFilter) {
if self.median != median {
self.modified = true;
Expand Down Expand Up @@ -464,6 +476,20 @@ impl ToFConfig {
self.enable_phase_unwrapping = enable;
}

pub fn set_enable_phase_shuffle_temporal_filter(&mut self, enable: Option<bool>) {
if self.enable_phase_shuffle_temporal_filter != enable {
self.modified = true;
}
self.enable_phase_shuffle_temporal_filter = enable;
}

pub fn set_enable_burst_mode(&mut self, enable: Option<bool>) {
if self.enable_burst_mode != enable {
self.modified = true;
}
self.enable_burst_mode = enable;
}

pub fn is_modified(&self) -> bool {
self.modified
}
Expand Down
29 changes: 29 additions & 0 deletions crates/re_viewer/src/ui/device_settings_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,35 @@ impl DeviceSettingsPanel {
enable_wiggle_correction,
));
}
let mut enable_phase_shuffle_temporal_filter = tof_config
.get_enable_phase_shuffle_temporal_filter()
.unwrap_or(false);
if ctx
.re_ui
.labeled_toggle_switch(
ui,
"Enable phase shuffle temporal filter",
&mut enable_phase_shuffle_temporal_filter,
)
.changed()
{
tof_config.set_enable_phase_shuffle_temporal_filter(Some(
enable_phase_shuffle_temporal_filter,
));
}
let mut enable_burst_mode = tof_config.get_enable_burst_mode().unwrap_or(false);
if ctx
.re_ui
.labeled_toggle_switch(
ui,
"Enable burst mode",
&mut enable_burst_mode,
)
.changed()
{
tof_config.set_enable_burst_mode(Some(enable_burst_mode));
}

})
});
}
Expand Down
6 changes: 3 additions & 3 deletions rerun_py/depthai_viewer/_backend/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
from typing import Dict, List, Optional, Tuple

import depthai as dai
import depthai_viewer as viewer
import numpy as np
from depthai_sdk import OakCamera
from depthai_sdk.classes.packet_handlers import ComponentOutput
from depthai_sdk.components import CameraComponent, NNComponent, StereoComponent
from depthai_sdk.components.tof_component import ToFComponent
from depthai_sdk.components.camera_helper import getClosestIspScale
from depthai_sdk.components.tof_component import Component, ToFComponent
from numpy.typing import NDArray

import depthai_viewer as viewer
from depthai_viewer._backend.device_configuration import (
ALL_NEURAL_NETWORKS,
CameraConfiguration,
Expand Down Expand Up @@ -45,7 +46,6 @@
)
from depthai_viewer._backend.store import Store
from depthai_viewer.install_requirements import model_dir
from numpy.typing import NDArray


class XlinkStatistics:
Expand Down
6 changes: 6 additions & 0 deletions rerun_py/depthai_viewer/_backend/device_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ class ToFConfig(BaseModel): # type: ignore[misc]
enable_optical_correction: Optional[bool] = True
enable_temperature_correction: Optional[bool] = False
enable_wiggle_correction: Optional[bool] = True
enable_phase_shuffle_temporal_filter: Optional[bool] = True
enable_burst_mode: Optional[bool] = False

class Config:
arbitrary_types_allowed = True
Expand All @@ -259,6 +261,8 @@ def dict(self, *args, **kwargs) -> Dict[str, Any]: # type: ignore[no-untyped-de
"enable_temperature_correction": self.enable_temperature_correction,
"enable_wiggle_correction": self.enable_wiggle_correction,
"enable_phase_unwrapping": self.enable_phase_unwrapping,
"enable_phase_shuffle_temporal_filter": self.enable_phase_shuffle_temporal_filter,
"enable_burst_mode": self.enable_burst_mode,
}

def to_dai(self) -> dai.RawToFConfig:
Expand All @@ -271,6 +275,8 @@ def to_dai(self) -> dai.RawToFConfig:
cfg.enableTemperatureCorrection = self.enable_temperature_correction # type: ignore[attr-defined]
cfg.enableWiggleCorrection = self.enable_wiggle_correction # type: ignore[attr-defined]
cfg.enablePhaseUnwrapping = self.enable_phase_unwrapping # type: ignore[attr-defined]
cfg.enablePhaseShuffleTemporalFilter = self.enable_phase_shuffle_temporal_filter # type: ignore[attr-defined]
cfg.enableBurstMode = self.enable_burst_mode # type: ignore[attr-defined]
return cfg


Expand Down
19 changes: 11 additions & 8 deletions rerun_py/depthai_viewer/_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
)
from depthai_viewer._backend.store import Store

sentry_sdk.init( # type: ignore[abstract]
dsn="https://[email protected]/16",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
traces_sample_rate=1.0,
release=f"depthai-viewer@{depthai_viewer_version()}",
)
try:
sentry_sdk.init( # type: ignore[abstract]
dsn="https://[email protected]/16",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
traces_sample_rate=1.0,
release=f"depthai-viewer@{depthai_viewer_version()}",
)
except:
print("Failed to initialize sentry")


class DepthaiViewerBack:
Expand Down
7 changes: 4 additions & 3 deletions rerun_py/depthai_viewer/_backend/packet_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cv2
import depthai as dai
import depthai_viewer as viewer
import numpy as np
from ahrs.filters import Mahony
from depthai_sdk.classes.packets import ( # PointcloudPacket,
Expand All @@ -23,11 +22,13 @@
StereoComponent,
)
from depthai_sdk.components.tof_component import ToFComponent
from numpy.typing import NDArray
from pydantic import BaseModel

import depthai_viewer as viewer
from depthai_viewer._backend.store import Store
from depthai_viewer._backend.topic import Topic
from depthai_viewer.components.rect2d import RectFormat
from numpy.typing import NDArray
from pydantic import BaseModel


class PacketHandlerContext(BaseModel): # type: ignore[misc]
Expand Down
2 changes: 1 addition & 1 deletion rerun_py/depthai_viewer/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.25.0.0.dev0+f1cd4d974e041f1b3ea84480afcdc5a8e3975299
depthai==2.25.0.0.dev0+5411a6b821087908e721eff5b74ac9d91a85de92
websockets
pydantic==1.9
deprecated
Expand Down

0 comments on commit 0b7c955

Please sign in to comment.