-
Notifications
You must be signed in to change notification settings - Fork 595
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
Converting ROS message with "8UC1" encoding to "mono8" fails. #175
Comments
This is because 8UC and mono8 are not recognized as the same encoding. |
Thanks for the quick investigation and PRs! |
I'll explain the error format: 8UC1 is not a color format, it just says that the image has one channel of size 8bit. Think about it this way: it does not make sense to convert 8UC3 to RGB as you don't know what you store in your 3 channels (could be BGR, YUV whatever). Same here, maybe your 1 channel is grayscale, maybe intensity, maybe it's not even color, it's a depth image. |
I would not take that risk: typing is what makes ROS strong so you should make sure your driver returns the proper type. |
@vrabaud, I see your point. I can ofc try to push for a change in the driver upstream. However, sometimes you don't have control over your data source. I would also argue that it still can make sense to interpret something like a depth image encoded as 8UC1 as a greyscale image and do operations on that, so how would you implement that as opposed to https://github.com/ethz-asl/kalibr/blob/a43a7b29bc43410b8a39a7f89d4c333d9cdad1f1/aslam_offline_calibration/kalibr/python/kalibr_common/ImageDatasetReader.py#L135-L137? Does OpenCV distinguish between different single channel formats? |
To answer my own question, it looks like converting from So in the linked example, one could write instead of
simply
right? |
Indeed the data representation is the same. The operation is more like downcasting. Where you can declare the datatype to be mono8 which is a subset of 8UC with specific semantic meaning. A conversion method should be relatively easy to implement, which simply changes the declared datatype on an assertion from the developer that says it's grayscale. Which would be useful if the datasource cannot be updated, or you want to play fast and loose with the data (but you're being explicit in your code, and the tools can enforce correctness). |
@NikolausDemmel , right, in your case, that would work. But your driver should really return a "mono8" |
Without this Kalibr errors when reading datasets where the image encoding is "8UC1". See ros-perception/vision_opencv#175 for an explanation.
what's the official solution to this? |
I have ROS image messages with "8UC1" encoding (recorded from an Intel RealSense ZR300 with their driver http://wiki.ros.org/realsense_camera). I want to calibrate the camera using the Kalibr Toolbox, but I face an exception that traces back to the cv_bridge conversion.
Is the following expected to fail?
I would have thought that "8UC1" is a valid encoding (according to http://docs.ros.org/api/sensor_msgs/html/msg/Image.html and http://docs.ros.org/kinetic/api/sensor_msgs/html/image__encodings_8h_source.html it is). Also, the Kalibr implementation seems to expect that this is working (see https://github.com/ethz-asl/kalibr/blob/a43a7b29bc43410b8a39a7f89d4c333d9cdad1f1/aslam_offline_calibration/kalibr/python/kalibr_common/ImageDatasetReader.py#L135-L137).
Is this something that maybe used to work?
I'm using the latest released version on ROS Kinetic / Ubuntu 16.04.
The text was updated successfully, but these errors were encountered: