x

Welcome to IT Leader Assistant!
Please Log In!

Create an account

How convert ROS camera image into a matrix

Maksim Shalamov
11-16-2020 12:59
How convert ROS camera image into a matrix
Starting to work with ROS, several times I read on the forums questions about how to work with an image that comes from a ROS camera (sensor_msgs / Image.msg). Let’s consider of them.
Its format may be unusual (you can familiarize yourself with it on the link). However, working with this format is no more difficult than with any two-dimensional array.
For basic operations, we need the height, step and data fields. Further, if you are used to representing the image as a matrix, then height is the number of lines in the image, step is the number of columns. The color of a pixel is in the values of data containing the R, G, B. Thus, in each line, there are three consecutive values per pixel. The image for this article depicts this in detail in the form of a matrix. After that, you can analyze the image based on your needs. For example: I had an 800x800 image and step 2400 (step / width == 3).
If you have any questions or comments, you can use the feedback form to contact us:

Comments

To add a comment please log in

Stay tuned and subsribe

Last blog articles