Hello,
I would like to ask if there is a way to save 4 channel image with depth information as a 4th channel.
I tried to make a custom buffer which get together color image and depth from vision sensor, but I am not successful with transformation to image.
colorBuffer = sim.getVisionSensorImage(cameras[2])
depthBuffer = sim.getVisionSensorDepthBuffer(cameras[2])
table.move(depthBuffer, 1, #depthBuffer, #colorBuffer + 1, colorBuffer)
packedImage = sim.packTable(colorBuffer,0)
imageBuffer,res = sim.loadImage(1,packedImage)
and then I would like to use sim.saveImage.
Is there some better way or could someone help me with right formats of the buffers, because it is quite hard to debug this in Lua.
Thank you
Save RGB-D image as RGBA
Re: Save RGB-D image as RGBA
Hello,
why not something along those lines?
Cheers
why not something along those lines?
Code: Select all
local colorBuffer,resX,resY = sim.getVisionSensorImage(cameraHandle)
local depthBuffer = sim.getVisionSensorDepthBuffer(cameraHandle)
local rgbd={}
for j=0,#resY-1,1 do
for i=0,#resX-1,1 do
rgbd[4*(j*resX+i)+1]=colorBuffer[3*(j*resX+i)+1]*255
rgbd[4*(j*resX+i)+2]=colorBuffer[3*(j*resX+i)+2]*255
rgbd[4*(j*resX+i)+3]=colorBuffer[3*(j*resX+i)+3]*255
rgbd[4*(j*resX+i)+4]=depthBuffer[j*resX+i+1]*255
end
end
local rgba_img=sim.packUInt8Table(rgbd)