Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image_view_node: support bayer images #1046

Conversation

rursprung
Copy link
Contributor

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.

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 ros-perception#1045.
Copy link
Member

@mikeferguson mikeferguson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable given what we do in stereo node

@rursprung
Copy link
Contributor Author

i just realised that i was a bit tired when i thought yesterday that it's better to go with mono for now and then figure out colour later on... bayer is of course always colour, so i guess it'd be fine to just always use bgr (both here & in stereo)? if you concur, i can add a commit to this PR which changes it in both places

@mikeferguson
Copy link
Member

bayer is of course always colour, so i guess it'd be fine to just always use bgr (both here & in stereo)

I'm pretty sure this won't show the expected colors you want. I think the trick here is that by casting to 'mono8' we treat the 4 pixels (2 green, 1 red, 1 blue) as a black and white image that is basically 2x the resolution of the actual image and so it looks roughly correct.

If you do test out 'bgr' and it looks OK - please post some screen shots here of the 'mono' and 'bgr' for review (I don't have any bayer cameras around to test with).

@rursprung
Copy link
Contributor Author

ok, i'll do that either tonight or in the coming days.
it might be cleanest to merge this PR for now and then i'll post the information on the issue and raise a new PR?

it did look ok when i tried it (though the colours were off, but that's because i'd need to set white balance & co. in the camera for it to look correct)

@rursprung
Copy link
Contributor Author

If you do test out 'bgr' and it looks OK - please post some screen shots here of the 'mono' and 'bgr' for review (I don't have any bayer cameras around to test with).

i've posted it on the issue: #1045 (comment)

@rursprung
Copy link
Contributor Author

@mikeferguson: any chance that you could merge this?
unless you want me to use bgr8 instead of mono8 (see my screenshots on the issue).

either way it'd be great to get this merged & released soon so that i don't need a local build of the image pipeline to see raw images (while i do have the debayer node in place as well for further processing it's sometimes relevant to inspect the raw images)

@mikeferguson
Copy link
Member

Let's stick with mono8 for now then.

@mikeferguson mikeferguson merged commit 6ff605c into ros-perception:rolling Dec 10, 2024
4 checks passed
@rursprung rursprung deleted the add-mono-bayer-support-to-image-view branch December 10, 2024 23:12
@rursprung
Copy link
Contributor Author

Let's stick with mono8 for now then.

thanks, @mikeferguson! should i create a backport PR for jazzy or do you do this automatically?

should i create a follow-up PR for bgr8 against rolling?

@mikeferguson
Copy link
Member

https://github.com/Mergifyio backport jazzy

Copy link

mergify bot commented Dec 11, 2024

backport jazzy

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Dec 11, 2024
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.

(cherry picked from commit 6ff605c)
@mikeferguson
Copy link
Member

should i create a follow-up PR for bgr8 against rolling?

Are the colors actually accurate? I know you mentioned it wasn't color calibrated, but also, I imagine that having two green channels is maybe part of the issue (my understanding is that the data really isn't bgr8 under the hood, it seems wrong to try and interpret it that way - mono kinda makes sense because you're just casting what is basically BGGR to grayscale)

@rursprung
Copy link
Contributor Author

Are the colors actually accurate? I know you mentioned it wasn't color calibrated, but also, I imagine that having two green channels is maybe part of the issue (my understanding is that the data really isn't bgr8 under the hood, it seems wrong to try and interpret it that way - mono kinda makes sense because you're just casting what is basically BGGR to grayscale)

OpenCV correctly debayers it if you use COLOR_BayerBG2BGR (or the appropriate Bayer.. version). the images looked just fine when i used a colour-corrected version (i just had to enable auto white balance for the camera)

ahcorde pushed a commit that referenced this pull request Dec 11, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

image_view: limited bayer support
2 participants