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


asked 2021-06-17 01:32:13 -0500

jenanaputra gravatar image

This is my first time dealing with sensor_msgs/Image. I am using ros melodic in ubuntu 18.04. I tried to subscribe the content of sensor_msgs/Image and tried to visualize the data from the msg for validating the image. it cunfused me when I print the width, height , and the size of the matrice data in sensor_msgs/Image. Why is the size value of matrice data in that msg different with height x width value ? Could anyone explain me about this ? (As I know the data is in the type of std::vector so I want to arrange it by dividing the data to an array[height][width] so I can validate and visualize those datas in Matlab)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-06-17 03:41:39 -0500

Webadone gravatar image

I'm not an expert to that so maybe I'm wrong. When looking at the documentation

It actually mentions that

uint32 step           # Full row length in bytes
uint8[] data          # actual matrix data, size is (step * rows)

the size is step * rows no height x width. The reason for that is probably the fact that for each pixel you might not just have 1 byte but 3 bytes (e.g RBG).

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2021-06-17 01:32:13 -0500

Seen: 976 times

Last updated: Jun 17 '21