Home | Tutorials | Wiki | Issues
Ask Your Question
1

How to get image without storing into disk from gazebo ?

asked 2017-05-20 09:43:18 -0600

shin gravatar image

updated 2017-05-21 19:53:57 -0600

After previous issue : http://answers.gazebosim.org/question... .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!

edit retag flag offensive close merge delete

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.

Xaser gravatar imageXaser ( 2017-05-21 03:32:18 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-08-11 07:05:33 -0600

langong gravatar image

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

edit flag offensive delete link more
0

answered 2017-05-22 09:10:30 -0600

sloretz gravatar image

updated 2017-05-23 09:13:56 -0600

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().

edit flag offensive delete link more

Comments

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

shin gravatar imageshin ( 2017-05-22 20:56:16 -0600 )edit

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?

shin gravatar imageshin ( 2017-05-23 06:25:31 -0600 )edit

What's the value returned by ImageFormat()?

sloretz gravatar imagesloretz ( 2017-05-23 09:14:54 -0600 )edit

The value is R8G8B8

shin gravatar imageshin ( 2017-05-23 10:17:54 -0600 )edit

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.

sloretz gravatar imagesloretz ( 2017-05-23 10:46:53 -0600 )edit

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?

shin gravatar imageshin ( 2017-05-23 10:48:19 -0600 )edit

What is "the origin image"?

sloretz gravatar imagesloretz ( 2017-05-23 10:52:55 -0600 )edit

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.

shin gravatar imageshin ( 2017-05-23 19:46:00 -0600 )edit

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?

shin gravatar imageshin ( 2017-05-25 07:40:00 -0600 )edit

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

langong gravatar imagelangong ( 2017-08-10 10:42:36 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-05-20 09:43:18 -0600

Seen: 409 times

Last updated: Aug 11