ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

What is the exact format and size of Image() object?

asked 2021-08-24 05:12:59 -0500

Tejas Rao gravatar image

I cannot figure out what is the exact format of the sensor_msg Image() file. When I issue the command:

rostopic echo /camera/image_raw

I get a massive output consisting of thousands of numbers in an array. However, when I look up the documentation, there is supposed to be a heading, height, width, etc and the actual data. I have never been able to find the header or any other parameter from the output. I also cannot figure out just how large the file is. This makes it difficult to manipulate and transport the data. Can someone please help me out?

edit retag flag offensive close merge delete

Comments

1

The rostopic --help output may offer some guidance here:

  --nostr               exclude string fields
  --noarr               exclude arrays

if you add --noarr to your rostopic echo command, you'll be able to see the header and other non-array fields.

there is supposed to be a heading

probably a typo, but there is a header field. Not heading.

This makes it difficult to manipulate and transport the data.

A general usability suggestion: if you can accept the OpenCV dependency, try to consume sensor_msgs/Image messages using image_transport subscribers and convert messages to their OpenCV representation. That will make it much easier to work with them.

Working directly with the serialised form (in the form of sensor_msgs/Image) might not be the most efficient (from a usability perspective).

gvdhoorn gravatar image gvdhoorn  ( 2021-08-24 05:37:26 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-08-24 05:25:33 -0500

Ranjit Kathiriya gravatar image

updated 2021-08-24 05:35:25 -0500

Hello Tejas,

exact size of Image.

a. first way to get size. You can also get size from http://docs.ros.org/en/melodic/api/se... by selecting this variable in your code.

uint32 height
uint32 width

Note: rostopic echo /camera/image_raw You are getting full sensor_msgs/Image data over here but each image has a huge matrix so you are not able to view the full message properly from your terminal.

b. second way to get size.

Just check if you are getting the camera_info topic. You can get this by typing rostopic list then try to view information of that you will get all details like height, width and other details which you required.

rostopic echo  <camers-info-topic>#/camera/color/camera_info

exact format

Have a look at this link you will get exact formate of an image message in ROS.

http://docs.ros.org/en/melodic/api/se...

edit flag offensive delete link more

Comments

Thanks, this helped a lot!

Tejas Rao gravatar image Tejas Rao  ( 2021-08-25 05:34:32 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-08-24 05:12:59 -0500

Seen: 1,849 times

Last updated: Aug 24 '21