-
Notifications
You must be signed in to change notification settings - Fork 604
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
cv_bridge: CompressedImage conversions with 16bit grayscale images #206
Comments
Just for the record:
Still not sure, but the difference might be that
According to the documentation, |
I needed to use IMREAD_UNCHANGED for a 16bit CompressedImage from compressedDepth topic. |
What happens with |
Dunno, I don't have the code handy to try. I'll try to remember to give it a try whenever I cross paths with this again. It was quite a pain to get it right. |
Ah ok, don't worry about it. I thought you did this just now. Anyway, thanks for the input. |
@NikolausDemmel I just tried it. |
I have 16bit grayscale images (
mono16
) and would like to convert to and fromCompressedImage
. It seemscv_bridge
is not properly handling this case in most instances.Possibly related:
image_transport
also has issues with decoding 16bit grayscale: ros-perception/image_common#77Python
It looks like
cv2_to_compressed_imgmsg
works correctly and creates 16bit grayscale png images.However,
compressed_imgmsg_to_cv2
has issues. Firstly,imdecode
is given onlyIMREAD_ANYCOLOR
, which means the image is always converted to 8 bit. I thinkIMREAD_UNCHANGED
is what we want here, or at leastIMREAD_ANYCOLOR | IMREAD_ANYDEPTH
(not sure what the difference is between these two cases). Secondly, if a specific encoding is asked for, it later assumes that the result fromimdecode
isbgr8
encoded. Not sure about the color encoding you can expect fromimdecode
, but at least for grayscale it seems wrong, and the actual bitdepth of the input would ideally also be respected here.C++
I didn't try it for C++, but looking at the code, it seems that for neither conversion 16bit is supported.
vision_opencv/cv_bridge/src/cv_bridge.cpp
Lines 480 to 506 in 9d49971
vision_opencv/cv_bridge/src/cv_bridge.cpp
Lines 515 to 536 in 9d49971
The text was updated successfully, but these errors were encountered: