From 67c9032239093de93624ac60ae0ebebfdc1d76b4 Mon Sep 17 00:00:00 2001 From: ktro2828 Date: Wed, 21 Aug 2024 00:46:14 +0900 Subject: [PATCH] fix: update initialization of `rerun::DepthImage` and `rerun::Image` Signed-off-by: ktro2828 --- .../src/image/compressed_image_display.cpp | 9 ++++----- awviz_plugin/src/image/image_display.cpp | 14 +++++--------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/awviz_plugin/src/image/compressed_image_display.cpp b/awviz_plugin/src/image/compressed_image_display.cpp index 1508eee..0fb2f6a 100644 --- a/awviz_plugin/src/image/compressed_image_display.cpp +++ b/awviz_plugin/src/image/compressed_image_display.cpp @@ -18,6 +18,7 @@ #include +#include #include namespace awviz_plugin @@ -43,17 +44,15 @@ void CompressedImageDisplay::log_message(sensor_msgs::msg::CompressedImage::Cons cv::cvtColor(img, img, cv::COLOR_BGR2RGB); stream_->log( - entity_path.value(), rerun::Image(tensor_shape(img), rerun::TensorBuffer::u8(img))); + entity_path.value(), rerun::Image::from_rgb24(img, rerun::WidthHeight(img.cols, img.rows))); } else { auto img = cv::imdecode(cv::Mat(msg->data), cv::IMREAD_COLOR); cv::Mat depth; img.convertTo(depth, CV_32FC1); stream_->log( - entity_path.value(), rerun::DepthImage( - {static_cast(depth.rows), static_cast(depth.cols)}, - rerun::TensorBuffer::f32(depth)) - .with_meter(1.0)); + entity_path.value(), + rerun::DepthImage(depth.data, rerun::WidthHeight(depth.cols, depth.rows)).with_meter(1.0)); } } } // namespace awviz_plugin diff --git a/awviz_plugin/src/image/image_display.cpp b/awviz_plugin/src/image/image_display.cpp index 2ff89fa..41c5af9 100644 --- a/awviz_plugin/src/image/image_display.cpp +++ b/awviz_plugin/src/image/image_display.cpp @@ -40,23 +40,19 @@ void ImageDisplay::log_message(sensor_msgs::msg::Image::ConstSharedPtr msg) if (msg->encoding == "16UC1") { auto img = cv_bridge::toCvCopy(msg)->image; stream_->log( - entity_path.value(), rerun::DepthImage( - {static_cast(img.rows), static_cast(img.cols)}, - rerun::TensorBuffer::u16(img)) - .with_meter(1000)); + entity_path.value(), + rerun::DepthImage(img.data, rerun::WidthHeight(img.cols, img.rows)).with_meter(1000)); } else if (msg->encoding == "32FC1") { auto img = cv_bridge::toCvCopy(msg)->image; stream_->log( - entity_path.value(), rerun::DepthImage( - {static_cast(img.rows), static_cast(img.cols)}, - rerun::TensorBuffer::f32(img)) - .with_meter(1.0)); + entity_path.value(), + rerun::DepthImage(img.data, rerun::WidthHeight(img.cols, img.rows)).with_meter(1.0)); } else { auto img = cv_bridge::toCvCopy(msg, "rgb8")->image; stream_->log( - entity_path.value(), rerun::Image(tensor_shape(img), rerun::TensorBuffer::u8(img))); + entity_path.value(), rerun::Image::from_rgb24(img, rerun::WidthHeight(img.cols, img.rows))); } } } // namespace awviz_plugin