Gazebo | Ignition | Community
Ask Your Question

how to read images from a camera in the Gazebo?

asked 2017-08-14 05:06:58 -0600

langong gravatar image

hi, everyone, I have the same problem with this, I want to read the images from a camera in the gazebo 6.5, and input the images to the c++ program of image processing. I try to follow the above tips to change the code of CameraDump::OnNewFrame(), but I it is not working. So, can anybody give me hands or show me how you did it? Thanks a lot!

edit retag flag offensive close merge delete


actually, my question is about the example mentioned in the answer

langong gravatar imagelangong ( 2017-08-14 08:49:27 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-08-14 19:13:47 -0600

iche033 gravatar image

the image data is given by the unsigned char *_image variable. You also get width, height, and format (R8G8B8 for a standard camera) information in the callback, you should be able to feed those to your image processing program.

edit flag offensive delete link more


hi, I am going to use GetImageData (gazebo 6.5) to read the images, But now, I don't know how to use this function, I didn't find any example. Can you show me an example? or do you have any ideas for my problem. Thank you very much!

langong gravatar imagelangong ( 2017-08-15 01:56:11 -0600 )edit

my problem is I don't know how to get the image data, I try to follow the above link, but it is not working. can you help me?

langong gravatar imagelangong ( 2017-08-15 02:08:29 -0600 )edit

I would suggest to use the plugin and get the image data that way. You have a pointer to the image data in memory. Can you describe what you mean by not working? Does this example save frames in the tmp folder?

iche033 gravatar imageiche033 ( 2017-08-15 12:00:37 -0600 )edit

hi, Now, the and is working, The image was saved in the folder and the camera was moving. But, I want to read image data in memory, not save in disk. Because I need image data to do image processing real time. Does the function GetImageData() read image data? I try to using GetImageData() to read image data, but it always returns NULL. Maybe I do not know how to use GetImageData(). Can help me? Thanks a lot!

langong gravatar imagelangong ( 2017-08-16 03:40:21 -0600 )edit

another question: how can I change the update rate of saving the image in the For instance, save an image per 0.5 seconds.

langong gravatar imagelangong ( 2017-08-16 08:47:07 -0600 )edit

if you look at camera_dump, it calls this->parentSensor->GetCamera()->SaveFrame and pass in the _image data. So just modify the plugin to not call that function and it won't save to disk. To change update rate, edit the world file and change the update rate for the camera sensor.

iche033 gravatar imageiche033 ( 2017-08-16 12:10:11 -0600 )edit

it is working. Thank you very much.

langong gravatar imagelangong ( 2017-08-21 10:19:56 -0600 )edit

Question Tools

1 follower


Asked: 2017-08-14 05:06:58 -0600

Seen: 4,086 times

Last updated: Aug 14 '17