Skip to content

Commit

Permalink
image_view_node: support bayer images (backport #1046) (#1058)
Browse files Browse the repository at this point in the history
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.<hr>This is an automatic backport of pull
request #1046 done by [Mergify](https://mergify.com).

Co-authored-by: Ralph Ursprung <[email protected]>
  • Loading branch information
mergify[bot] and rursprung authored Dec 11, 2024
1 parent e8e01b9 commit cc369ca
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions image_view/src/image_view_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit cc369ca

Please sign in to comment.