From 5e963d8d16584d23390a29103e2bc6b899defb5b Mon Sep 17 00:00:00 2001 From: Ralph Ursprung Date: Mon, 25 Nov 2024 22:19:18 +0100 Subject: [PATCH] `image_view_node`: support bayer images so far bayer images always failed with an error: ``` [ERROR] [..] [image_view_node]: Unable to convert 'bayer_rggb8' image for display: 'cv_bridge.cvtColorForDisplay() does not have an output encoding that is color or mono, and has is bit in depth' ``` the `stereo_view_node` on the other hand already supports bayer images, however it always forcibly converts them to monochrome, even if they are colour images. for now, this adds the same logic for the single-image viewer and thus only partially resolves #1045. --- image_view/src/image_view_node.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/image_view/src/image_view_node.cpp b/image_view/src/image_view_node.cpp index 951eedd9c..c3dc1a388 100644 --- a/image_view/src/image_view_node.cpp +++ b/image_view/src/image_view_node.cpp @@ -216,6 +216,11 @@ void ImageViewNode::imageCb(const sensor_msgs::msg::Image::ConstSharedPtr & msg) std::string encoding = msg->encoding.empty() ? "bgr8" : msg->encoding; + // May want to view raw bayer data + if (encoding.find("bayer") != std::string::npos) { + encoding = "mono8"; + } + queued_image_.set( cv_bridge::cvtColorForDisplay( cv_bridge::toCvShare(msg), encoding, options));