#Bytes Array Conversion

1 messages · Page 1 of 1 (latest)

empty girder
#

If you can help out with the conversion / decompression, that'd be great.

spare depot
#

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

ivory charm
empty girder
#

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?

ivory charm
#

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?

empty girder
#

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)

ivory charm
#

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?

empty girder
#

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

ivory charm
empty girder
#

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

ivory charm
#

are you still using that same byte array for testing? Or are you actually getting the compressedimage messages and trying to display that?

#

because right now i think the byte array you were using for testing is broken

empty girder
#

The latter

#

So I'm getting the streamed messaged and using that.

#

Maybe I can change the version of Unity I'm using?