Robotics StackExchange | Archived questions

How to get image without storing into disk from gazebo ?

After previous issue : http://answers.gazebosim.org/question/16154/some-issues-about-the-images-capture-in-gazebo/ .I can get images from gazebo by the instructions from sloretz. However, I can only save these images in a certain directory, it may too slow for me to fetch them. Is there any way to save these images in memory or get these images directly by C or other languages ? All in all, I can not let this images pass through the disk because it is too slow. Could any one give me a hand? Thank you very much!

Asked by shin on 2017-05-20 09:43:18 UTC

Comments

check out the camera plugin that comes with the ASL rotors package, it sends the images raw via a ros topic and therefore should be a good starting ground for your application.

Asked by Xaser on 2017-05-21 03:32:18 UTC

Answers

Writing a camera plugin would enable to use the image data any way you like, including passing it to another process in memory. This example shows how to create a plugin. You can copy/paste the example and then change the code in CameraDump::OnNewFrame() to pass via memory to another process.

-- edit --

Sounds like you're getting the image using ImageData(). It returns an array of length ImageByteSize(). The format depends on the return value of ImageFormat().

Asked by sloretz on 2017-05-22 09:10:30 UTC

Comments

I used to try similar way, but the world file post an error that :undefined symbol: _ZTIN6gazebo12CameraPluginE

Asked by shin on 2017-05-22 20:56:16 UTC

Oh, I have solved the above problem by changing the CMake file, but I get the image data with the function ImageData(), and I try many ways to decode this data, but I can not make it. Could you tell me what the data means? How to decode it into a image?

Asked by shin on 2017-05-23 06:25:31 UTC

What's the value returned by ImageFormat()?

Asked by sloretz on 2017-05-23 09:14:54 UTC

The value is R8G8B8

Asked by shin on 2017-05-23 10:17:54 UTC

I believe that one is 3 bytes per pixel: first byte is red component, second byte is green component, 3rd byte is blue component. It's in row-major order: first pixel is the top left corner of the image, last pixel is the bottom right corner.

Asked by sloretz on 2017-05-23 10:46:53 UTC

After I get the image data, how can I transfer it into the origin image? Maybe with C or Python? I try to use PIL lib to implement this, but I get a wrong image even if I know its format. Could you suggest a way to deal with this requirement?

Asked by shin on 2017-05-23 10:48:19 UTC

What is "the origin image"?

Asked by sloretz on 2017-05-23 10:52:55 UTC

I take a picture using camera sensor, and I want to load it in another program, and I can not read the image from disk because it is too slow. So the origin image is the image captured by camera sensor.

Asked by shin on 2017-05-23 19:46:00 UTC

Oh, I have known how to recover the origin image by the raw image data, the only problem left is that how can I send this raw data out? By now, I can only get the data when the plugin invokes its function on each update time, what I can do is output it into console or files, but I want to directly send it to another program like C or Python. Could you tell me whether there is a way to implement this?

Asked by shin on 2017-05-25 07:40:00 UTC

hi, I have the same problem with you, I want to read the images from a camera in the gazebo, and input the images to the 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 you show me how you did it? my email is lanmessi@hotmail.com

Asked by langong on 2017-08-10 10:42:36 UTC

my camera_dump plugin is not working, I set the std::cout code to check is it working. And it output nothing. But the camera_move plugin is working, the camera is moving. How about you?

Asked by langong on 2017-08-11 11:11:01 UTC

hi, I have the same problem with you, I want to read the images from a camera in the gazebo, and input the images to the 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 you show me how you did it? my email is lanmessi@hotmail.com

Asked by langong on 2017-08-11 07:05:33 UTC

Comments