Ask Your Question

How to interpret data matrix in sensor_msgs/Image?

asked 2016-07-20 11:38:24 -0500

skr_robo gravatar image

updated 2016-07-21 11:35:17 -0500

I am subscribing to the topic /camera/depth/image_rect_color in the package zed-ros-wrapper to obtain depth information using a zed camera. Right now, my subscriber looks at a random pixel and reads the depth information. Is there any way to find out which pixel corresponds to what element(index) in the matrix?

Also if I run rostopic echo /camera/depth/image_rect_color, I find that the encoding is 32FC1. But the data matrix is int (I believe unit8 denotes int). Also, I haven't seen any value above 255. So, the matrix looks like 8UC1. What am I missing here or how does a 32FC1 matrix looks like?

Edit: I meant uint8, not unit8. Sorry about that (Thanks to NEngelhard).

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-07-20 15:35:03 -0500

NEngelhard gravatar image

"unit8 denotes int" No uint8 is a Byte (8 Bits..). If you have a look a the image data type, you see that the data is always kept in a byte-array which is the most basic data type available. So the data-array is nothing else but just a pointer to the memory in which the image is stored. This data is then interpreted according to your image type. If you have a float, a block of four consecutive bytes in read as a single float value.

edit flag offensive delete link more


But just like float32 says that it is a 32 bit float type, doesn't uint8 say that it is an 8 bit int type? I think you may be right about saying that four consecutive bytes correspond to one value in the depth image. But are you saying that the array is made of pointers, not actual data?

skr_robo gravatar image skr_robo  ( 2016-07-21 11:33:59 -0500 )edit

"say that it is an 8 bit int type" That's somehow correct. But there can be a difference in what you tell the compiler and how in fact the data is used.

NEngelhard gravatar image NEngelhard  ( 2016-07-21 11:37:35 -0500 )edit

I have understood completely that the four bytes combine to form the 32 bit float information I am looking for. Thanks a lot for that. How can I know if this is a pointer or the actual depth information ? I am not able to understand why would you say it is an array of pointers? Sorry for being noob.

skr_robo gravatar image skr_robo  ( 2016-07-21 12:16:46 -0500 )edit

"why would you say it is an array of pointers" I never said that. If you request an array in C++, you get a pointer (the ->data) to the memory location where the first element of this array is stored.

NEngelhard gravatar image NEngelhard  ( 2016-07-22 02:20:26 -0500 )edit

Okay I get it now. Thank you.

skr_robo gravatar image skr_robo  ( 2016-07-22 11:29:08 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2016-07-20 11:38:24 -0500

Seen: 635 times

Last updated: Jul 21 '16