diff --git a/crates/re_viewer/src/ui/data_ui/image.rs b/crates/re_viewer/src/ui/data_ui/image.rs index 1ba57b6f012a..89b1610f2a03 100644 --- a/crates/re_viewer/src/ui/data_ui/image.rs +++ b/crates/re_viewer/src/ui/data_ui/image.rs @@ -568,8 +568,11 @@ fn tensor_pixel_value_ui( _ => { match &tensor.unit { Some(unit) => { - println!("Unit: {unit}"); - tensor.get(&[y, x]).map(|v| format!("Val: {v} {unit}")) + if tensor.dtype().is_float() { + tensor.get(&[y, x]).map(|v| format!("Val: {v:.2} {unit}")) + } else { + tensor.get(&[y, x]).map(|v| format!("Val: {v} {unit}")) + } }, None => { tensor.get(&[y, x]).map(|v| format!("Val: {v}")) diff --git a/rerun_py/depthai_viewer/__init__.py b/rerun_py/depthai_viewer/__init__.py index 7783c10640a8..53d023592f0b 100644 --- a/rerun_py/depthai_viewer/__init__.py +++ b/rerun_py/depthai_viewer/__init__.py @@ -6,7 +6,7 @@ import depthai_viewer_bindings as bindings # type: ignore[attr-defined] from depthai_viewer import _backend -from depthai_viewer.components.tensor import ImageEncoding, Colormap +from depthai_viewer.components.tensor import Colormap, ImageEncoding from depthai_viewer.log import log_cleared from depthai_viewer.log.annotation import ( AnnotationInfo, diff --git a/rerun_py/depthai_viewer/_backend/config_api.py b/rerun_py/depthai_viewer/_backend/config_api.py index 63dd28a08480..075b09519882 100644 --- a/rerun_py/depthai_viewer/_backend/config_api.py +++ b/rerun_py/depthai_viewer/_backend/config_api.py @@ -162,7 +162,10 @@ async def main(port: int = 9001) -> None: def start_api( - _dispatch_action_queue: Queue, _result_queue: Queue, _send_message_queue: Queue, port: int = 9001 # type: ignore[type-arg] + _dispatch_action_queue: Queue, # type: ignore[type-arg] + _result_queue: Queue, # type: ignore[type-arg] + _send_message_queue: Queue, # type: ignore[type-arg] + port: int = 9001, ) -> None: """ Starts the websocket API. diff --git a/rerun_py/depthai_viewer/_backend/device.py b/rerun_py/depthai_viewer/_backend/device.py index 52ea290762f8..a0639d01c5f0 100644 --- a/rerun_py/depthai_viewer/_backend/device.py +++ b/rerun_py/depthai_viewer/_backend/device.py @@ -32,6 +32,7 @@ get_size_from_resolution, size_to_resolution, ) +from depthai_viewer._backend.device_defaults import oak_t_default from depthai_viewer._backend.messages import ( ErrorMessage, InfoMessage, @@ -40,7 +41,6 @@ ) from depthai_viewer._backend.packet_handler import PacketHandler from depthai_viewer._backend.store import Store -from depthai_viewer._backend.device_defaults import oak_t_default class XlinkStatistics: @@ -526,10 +526,10 @@ def update_pipeline(self, runtime_only: bool) -> Message: self.store.send_message_to_frontend( WarningMessage(f"{config.ai_model.camera} is not configured, won't create NNET.") ) - if cam_component and config.ai_model and config.ai_model.path == "age-gender-recognition-retail-0013": + elif config.ai_model.path == "age-gender-recognition-retail-0013": face_detection = self._oak.create_nn("face-detection-retail-0004", cam_component) self._nnet = self._oak.create_nn("age-gender-recognition-retail-0013", input=face_detection) - elif cam_component: + else: self._nnet = self._oak.create_nn(config.ai_model.path, cam_component) if self._nnet: self._queues.append((self._nnet, self._oak.queue(self._nnet.out.main))) diff --git a/rerun_py/depthai_viewer/_backend/device_configuration.py b/rerun_py/depthai_viewer/_backend/device_configuration.py index b14ee504417f..7178d082728e 100644 --- a/rerun_py/depthai_viewer/_backend/device_configuration.py +++ b/rerun_py/depthai_viewer/_backend/device_configuration.py @@ -56,7 +56,9 @@ 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, @@ -270,9 +272,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_t_default.py b/rerun_py/depthai_viewer/_backend/device_defaults/oak_t_default.py index cfdede565f15..47ff3bbe18e3 100644 --- a/rerun_py/depthai_viewer/_backend/device_defaults/oak_t_default.py +++ b/rerun_py/depthai_viewer/_backend/device_defaults/oak_t_default.py @@ -1,9 +1,9 @@ +import depthai as dai from depthai_viewer._backend.device_configuration import ( - PipelineConfiguration, CameraConfiguration, CameraSensorResolution, + PipelineConfiguration, ) -import depthai as dai config = PipelineConfiguration( cameras=[ diff --git a/rerun_py/depthai_viewer/_backend/main.py b/rerun_py/depthai_viewer/_backend/main.py index dcec93ee64b4..eaa3432e0d66 100644 --- a/rerun_py/depthai_viewer/_backend/main.py +++ b/rerun_py/depthai_viewer/_backend/main.py @@ -6,7 +6,6 @@ import sentry_sdk -import depthai_viewer as viewer from depthai_viewer import version as depthai_viewer_version from depthai_viewer._backend.config_api import Action, start_api from depthai_viewer._backend.device import Device diff --git a/rerun_py/depthai_viewer/_backend/packet_handler.py b/rerun_py/depthai_viewer/_backend/packet_handler.py index 180691c37477..ce8362dd4c78 100644 --- a/rerun_py/depthai_viewer/_backend/packet_handler.py +++ b/rerun_py/depthai_viewer/_backend/packet_handler.py @@ -132,7 +132,7 @@ def _on_camera_frame(self, packet: FramePacket, board_socket: dai.CameraBoardSoc ) elif packet.msg.getType() == dai.RawImgFrame.Type.GRAYF16: img = img_frame.view(np.float16).reshape(h, w) - viewer.log_image(entity_path, img, colormap=viewer.Colormap.Magma, unit="degrees ") + viewer.log_image(entity_path, img, colormap=viewer.Colormap.Magma, unit="°C") else: viewer.log_image(entity_path, img_frame) diff --git a/rerun_py/depthai_viewer/components/tensor.py b/rerun_py/depthai_viewer/components/tensor.py index ef355585ec37..a525aa8040ac 100644 --- a/rerun_py/depthai_viewer/components/tensor.py +++ b/rerun_py/depthai_viewer/components/tensor.py @@ -121,7 +121,7 @@ def from_numpy( else: meter = pa.array([meter], mask=[False], type=pa.float32()) - unit = pa.array(["string" if unit is not None else ""], type=pa.string()) + unit = pa.array([unit if unit is not None else ""], type=pa.string()) storage = pa.StructArray.from_arrays( [tensor_id, shape, data, meaning, meter, colormap, unit], diff --git a/rerun_py/depthai_viewer/log/image.py b/rerun_py/depthai_viewer/log/image.py index 42354a50fb96..a2ba0c32e04f 100644 --- a/rerun_py/depthai_viewer/log/image.py +++ b/rerun_py/depthai_viewer/log/image.py @@ -2,9 +2,9 @@ import numpy as np import numpy.typing as npt -from enum import Enum + from depthai_viewer import bindings -from depthai_viewer.components.tensor import ImageEncoding, Colormap +from depthai_viewer.components.tensor import Colormap, ImageEncoding from depthai_viewer.log.error_utils import _send_warning from depthai_viewer.log.log_decorator import log_decorator from depthai_viewer.log.tensor import Tensor, _log_tensor, _to_numpy @@ -46,6 +46,10 @@ def log_image( Path to the image in the space hierarchy. image: A [Tensor][rerun.log.tensor.Tensor] representing the image to log. + colormap: + Optional colormap to apply to single channel images. + unit: + Optional unit of the single channel image. ext: Optional dictionary of extension components. See [rerun.log_extension_components][] timeless: diff --git a/rerun_py/depthai_viewer/log/tensor.py b/rerun_py/depthai_viewer/log/tensor.py index 9b2715534bdc..e24e46a9a999 100644 --- a/rerun_py/depthai_viewer/log/tensor.py +++ b/rerun_py/depthai_viewer/log/tensor.py @@ -5,7 +5,7 @@ from depthai_viewer import bindings from depthai_viewer.components.instance import InstanceArray -from depthai_viewer.components.tensor import ImageEncoding, TensorArray, Colormap +from depthai_viewer.components.tensor import Colormap, ImageEncoding, TensorArray from depthai_viewer.log.error_utils import _send_warning from depthai_viewer.log.extension_components import _add_extension_components from depthai_viewer.log.log_decorator import log_decorator @@ -18,7 +18,8 @@ class TorchTensorLike(Protocol): """Describes what is need from a Torch Tensor to be loggable to Rerun.""" - def numpy(self, force: bool) -> npt.NDArray[Any]: ... + def numpy(self, force: bool) -> npt.NDArray[Any]: + ... Tensor = Union[npt.ArrayLike, TorchTensorLike]