#Bytes Array Conversion
1 messages · Page 1 of 1 (latest)
Data compression - it’s a daunting subject. It is completely fundamental to our lives though very few of us actually understand it. We all use compression software such as 7-zip or gzip to compress our data, often compressing text files to 30% of their original size or less. Learn more about data co
not sure what your original question was
but heres this
conversion + compression/decompression all there
if you need more compression, you do delta compression, which might have some loss to it
not sure if this is what you're looking for
i have absolutely no information about the byte array except for the numbers in the array. if you wanna provide the link where you got that array or explain how you got it, then it would be easier to figure out
This is essentially the message the object gets every update.
(For the record here, think of messages like a simplified struct / class)
Doing a bit more digging revealed this sample code for CV2 use with the compressed image message.
Bringing this up as reference for how the message is typically used with regards to the data parameter
And a bit more digging revealed the info regarding the formatting for the image sent
imgcomp =
ROS CompressedImage message with properties:
MessageType: 'sensor_msgs/CompressedImage'
Header: [1x1 Header]
Format: 'bgr8; jpeg compressed bgr8'
Data: [30376x1 uint8]
So it's a bgr8 image, essentially.
(Which is why, as shown above with CV2's sample, there was no conversion needed; CV2 has bgr8 by default)
So maybe it's Unity getting confused trying to read the uint8[] array (that's a bgr8 image) as a uint32[] array (rgb32 image)?
Thus why Unity can't output the image out of the box and shows that red question mark.
I did manage to find this post on Stack Overflow... With no responses...
Is there any way to change the color formatting of a texture2d variable?
okay so I just want to make sure I am completely understanding this, you are getting a cv2 image as a byte array and trying to display that as a texture2d in unity, correct?
I'm getting a ROS topic which contains the uint8[] data variable, and I'm trying to display it as a texture2d in unity.
(Brought up CV2 just for reference and the possible explanation of the formatting, my project doesn't involve CV2; apologies about the confusion)
where is the original image that is being converted to your byte array coming from? and how is it being converted to the byte array?
Basically it's from a live video feed from a drone; and the camera sensor is publishing the data to a topic that sends out the message.
From there I'm using ROS Sharp to take in the published message
so after doing more reading and testing, it looks like it shouldn't need any sort of conversion or anything like that. So this byte array you are using for testing is likely the issue. Are you absolutely certain it is a valid image?
I was able to find this https://github.com/siemens/ros-sharp/blob/master/Unity3D/Assets/RosSharp/Scripts/RosBridgeClient/RosCommuncation/ImageSubscriber.cs and all they are doing is calling the LoadImage extension method then applying the texture
Yeah a peer of mine used the same code base
Kind of odd, since the topics remain the same.
Copied the code once more, still getting the same question mark