Can we get Image type(16UC1) byte array from the compressed byte array(jpeg compressed)?
Hi,
I am using ROS Sharp to send compressedImages from a ROS Kinetic Ubuntu Xenial workstation with aligned depth to color information. Then, I am using 'OpenCV for Unity' to decode the compressedImage byte array and was hoping to receive 16UC1 data but instead I am receiving 8UC1 data.
So my question is, is it possible to decompress a ROS compressedImage to retrieve back the original Image type byte array? Or will there always be a loss like in my case, i.e. 16UC1 is the original image but the decoded compressedImage is 8UC1 ?
This is certainly possible. Compressed image transport supports 16 bit images. How are you producing the compressed image topic initially and how are you converting it to a cv::Mat in the subscriber?
Firstly, I subscribe to "/camera/aligned_depth_to_color/image_raw/image raw/compressed" topic (originally 16UC1) which is published from realsense ros node.
Then, using OpenCV for Unity I use: imgcodec.imdecode(new MatOfByte(compressedImageData.data), CV_LOAD_IMAGE_ANYDEPTH)
...resulting in a 307200 byte array i.e. 8UC1. The imdecode function I think gives 16-bit values if there is a corresponding depth in the image, else it returns a 8-bit value, when using the CV_LOAD_ANYDEPTH flag. So, if the compressedImage does contain 16-bit values, im not sure why I get 8-bit?