Page 1 of 1

Save Greyscale Image from Vision Sensor

Posted: 18 Feb 2019, 13:20
by mirovoellmy
Hi,
I'm trying to record a greyscale vision sensor and save some images to drive using sim.saveImage().
The documentation describes that the the function can only handle rgb and rgbd images. Did I miss something or do I have to manually convert my greyscale [res_x * res_y] image to a rgb [res_x * res_y * 3] image everytime I want to save an image?

If yes, it would be nice to have an option in the saveImage() function so it can also save grayscale images. :)

Thanks

Miro

Re: Save Greyscale Image from Vision Sensor

Posted: 20 Feb 2019, 13:43
by coppelia
Hello,

you can use sim.transformBuffer for that:

Code: Select all

rgbImage=sim.transformBuffer(greyImage,sim.buffer_uint8,1,0,sim.buffer_uint8rgb)
Cheers

Re: Save Greyscale Image from Vision Sensor

Posted: 12 May 2020, 12:15
by ales_v
Hello,

I would like to ask if there is an oportunity to save grayscale image (monocolor or 8bit depth).

My goal is to have a small file but in good quality.

Thank you

Re: Save Greyscale Image from Vision Sensor

Posted: 12 May 2020, 13:48
by coppelia
Hello,

as of CoppeliaSim 4.0.0, this is unfortunately not possible. But in next release you'll be able to do that with, e.g.:

Code: Select all

        local img,resX,resY=sim.getVisionSensorCharImage(visionSensorHandle)
        img=sim.transformBuffer(img,sim.buffer_uint8rgb,1,0,sim.buffer_uint8)
        sim.saveImage(img,{resX,resY},2,"testImg.png",100)
Cheers

Re: Save Greyscale Image from Vision Sensor

Posted: 26 Sep 2020, 00:33
by lynsdu
hi there,

I am currently using b0 remote API with C++ on visual studio, do you know how to save an image from the vision sensor?

Code: Select all

int visionsensor = b0RemoteApi::readInt(client.simxGetObjectHandle("Vision_sensor", client.simxServiceCall()), 1);
std::vector<msgpack::object>* imginfo = client.simxGetVisionSensorImage(visionsensor, 0, client.simxServiceCall());
b0RemoteApi::print(imginfo);
I have been checking examples but with any clue how to use functions to save it as an image. could you please provide some examples for that?

thanks.

Re: Save Greyscale Image from Vision Sensor

Posted: 28 Sep 2020, 06:42
by coppelia
Hello,

to save an image from CoppeliaSim is quite immediate with the sim.saveImage function. From an external application, you'll have to use your own or a third-library routines to handle that. Here if you use Qt.

Cheers

Re: Save Greyscale Image from Vision Sensor

Posted: 01 Sep 2022, 14:50
by ask4jubad
Hello Coppelia,

When one uses sim.saveImage where does the image reside?

I can seem to find it - perhaps it's not working for me. I don't get any error, so I am not sure if the saveImage works or not.

From either the external script or within an actuation function in my simulator, I run this:

Code: Select all

local img, resX, resY, sim.getVisionSensorCharImage(visionSensorHandle) -- in external python script, there is no keyword local though
sim.saveImage(img, {resX, resY}, 0, "test.png", 100) -- i've also tried [resX, resY] and I can't remember which combination returns an error.

Re: Save Greyscale Image from Vision Sensor

Posted: 02 Sep 2022, 12:20
by coppelia
Hello,

as far as I know, this will place the file in the CoppeliaSim folder. Best is to specify an absolute path.

Cheers