How to save a depth image as a point cloud?

Typically: "How do I... ", "How can I... " questions
Post Reply
alkrick
Posts: 3
Joined: 19 Apr 2021, 05:04

How to save a depth image as a point cloud?

Post by alkrick »

I am using v4.2.0 and I can't figure out how to output the data collected by the vision sensor.
I understand that it can be outputted as a Point Cloud by applying the sensor matrix transformation to the depth buffer retrieved by sim.getVisionSensorDepthBuffer(), I would appreciate it if someone can tell me how that is realized in Lua. Thanks in advance,

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: How to save a depth image as a point cloud?

Post by fferri »

Hi,

have a look at the model components/sensors/3D laser scanner Fast.ttm.

alkrick
Posts: 3
Joined: 19 Apr 2021, 05:04

Re: How to save a depth image as a point cloud?

Post by alkrick »

Hello, Thanks a lot for your reply

I think I understand most of it, the problem now is exporting it. The sample code from the 3D laser Scanner said that the data needs to be packed into a string first. When I tried to pack the measuredData using the sim.packTable functions I get gibberish encoding and weird symbols. I tried all the packing functions. Do you have any idea why that is happening?

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: How to save a depth image as a point cloud?

Post by coppelia »

There is a simple demo scene located here, doing exactly what you want. That scene will probably be integrated as example scene in next release, in folder scenes/vision.

Cheers

alkrick
Posts: 3
Joined: 19 Apr 2021, 05:04

Re: How to save a depth image as a point cloud?

Post by alkrick »

Thanks a lot for that scene. It however does not explain how to save the point cloud data to an external file. As mentioned above, when I use sim.pack*Table functions with measuredData I get gibberish coding like this:

É?^A^@^@^@@<9a><8f><95>¿^A^@^@^@^@Ü<93><99>?^A^@^@^@ÀÆÃÉ?^A^@^@^@@<9a><8f><95>¿^A^@^@^@^@®Þ<94>?^A^@^@^@ ÈÃÉ?^A^@^@^@<80><9d><8f><95>¿^A^@^@^@ })<90>?^A^@^@^@ ÈÃÉ?^A^@^@^@<80><9d><8f>

Any idea why this is happening?

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: How to save a depth image as a point cloud?

Post by coppelia »

measuredData is a table that contains 3*n coordinates. Simply write that data to file, in your favorite format.

Cheers

Post Reply