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

decode images in mode IMREAD_UNCHANGED #228

Merged
merged 1 commit into from
Oct 11, 2021

Conversation

christian-rauch
Copy link
Contributor

@christian-rauch christian-rauch commented Jun 20, 2018

This PR changes the decoding mode from IMREAD_ANYCOLOR to IMREAD_UNCHANGED.
With IMREAD_ANYCOLOR decompressing a 16bit png image results in an 8bit image.

Solves issues: #206

This is a simple example of the conversion problem:

#!/usr/bin/env python3
from cv_bridge import CvBridge
import numpy as np
# create a 16bit depth image
im0 = np.empty(shape=(100, 100), dtype=np.uint16)
im0[:] = 2500 # 2.5m
print("original:", np.max(im0), im0.dtype)
# convert to compressed message
msg = CvBridge().cv2_to_compressed_imgmsg(im0, dst_format = "png")
# convert back to numpy array
im1 = CvBridge().compressed_imgmsg_to_cv2(msg)
print("converted:", np.max(im1), im1.dtype)
print("match?", np.all(im0==im1))

This example simply creates a 16bit depth image with the constant value of 2500mm and then convert this to a sensor_msgs/CompressedImage and back to a numpy array.

Currently, this conversion is broken:

original: 2500 uint16
converted: 9 uint8
match? False

This PR fixes this so that the content in im0 and im1 is identical:

original: 2500 uint16
converted: 2500 uint16
match? True

@christian-rauch
Copy link
Contributor Author

@vrabaud Can you comment on this?

@christian-rauch
Copy link
Contributor Author

Is this repo still maintained?
Can the maintainer (@vrabaud) or one of the latest commiters (@mjcarroll @mikaelarguedas @gaoethan ) please comment on this? This is a very annoying issue that produces wrong depth images and basically makes compressed depth images useless on python.

@christian-rauch
Copy link
Contributor Author

@mjcarroll Can you please have a look at this? It's a very annoying issue and the fix is quite simple and should not have an effect on other image decoding parts.

@mjcarroll
Copy link
Contributor

This looks reasonable, would you have any objection targeting to noetic?

@christian-rauch
Copy link
Contributor Author

christian-rauch commented Nov 11, 2019

No. But I would like to additionally target melodic to have a benefit from my PR :-)

Edit: I don't see a noetic branch in the repo. I am happy to create a second PR for neotic if the branch becomes available. But I also would like to have this fix in melodic.

@christian-rauch
Copy link
Contributor Author

@mjcarroll Would you consider merging this into melodic for now? I can cherry-pick it, once a noetic branch has been created.

@christian-rauch
Copy link
Contributor Author

ping @mjcarroll Can you merge this?

@christian-rauch christian-rauch changed the base branch from melodic to noetic July 8, 2020 10:55
@christian-rauch
Copy link
Contributor Author

@mjcarroll What is missing to get this merged?

@christian-rauch
Copy link
Contributor Author

@mjcarroll @vrabaud Can you please comment on this? This is a very annoying issue and seems easy to fix.

@christian-rauch
Copy link
Contributor Author

@mjcarroll @vrabaud Seriously, is there any reason why this fix does not get merged? It's unbelievable that reading compressed depth images in 16bit png format is still not possible!

If you do not have the capacity to maintain cv_bridge anymore, can you please designate a new maintainer that can fix critical bugs like this one instead of letting the project rotting away? This is a core ROS package and I would expect a certain quality from it.

@mjcarroll mjcarroll merged commit eeaf346 into ros-perception:noetic Oct 11, 2021
@mjcarroll
Copy link
Contributor

If you do not have the capacity to maintain cv_bridge anymore, can you please designate a new maintainer that can fix critical bugs like this one instead of letting the project rotting away? This is a core ROS package and I would expect a certain quality from it.

I don't believe that @vrabaud has been around for some time.

I would be happy to share maintainership with interested parties. I would like to see this be well maintained, but it is currently far down my priority list. Feel free to follow up with me via email.

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.

None yet

2 participants