22

I'm trying to generate point cloud data from mesh such as (.obj) file of Maya. But, I could find out only the opposite case, point cloud to mesh on the internet. Is there any way to create "point cloud data from mesh" using 3D tools like MeshLab or Maya? (I prefer using MeshLab)

Thanks. :)

Youn A Lee
  • 251
  • 1
  • 2
  • 4

6 Answers6

17

The free and open-source project CloudCompare can load OBJ meshes and then generate point clouds on the mesh, which you can then save in a variety of formats.

Chris4d
  • 595
  • 4
  • 11
  • 1
    This is the best method I've seen so far, good distribution of points and also keeping the RGB values from model. It would be even better if it could keep the normal vectors as well but very few point cloud software supports normal shading at the moment. Method: Import obj, select mesh, Edit/ Edit mesh/ Sample points – Paintoshi Apr 24 '17 at 08:19
  • Hi @David, thanks for the tip. Do you know if there is a way to do this in batch? I have ~80,000 obj files and would like to convert them all... Never mind, I think I found the "sample mesh" command line option, on page 173/181 of the documentation (http://cloudcompare.org/doc/qCC/CloudCompare%20v2.6.1%20-%20User%20manual.pdf). – yuqli Jan 09 '19 at 21:21
  • Just to append to my previous comments for others that reading this thread, I actually found the Point Cloud Library easier to use than Cloud Compare's command line option for this particular task. One thing is Cloud Compare report error when I tried the "-SAVE_CLOUDS" option which is used to save the point cloud, although it generates a .txt file fine. Another thing is although I specify 2048 points, the output contains 2049 points. `pcl_mesh_sampling` feels easier to use. – yuqli Jan 10 '19 at 15:35
7

The Point Cloud Library has a couple of different command-line tools for turning meshes into point clouds, as far as I know by rendering the object into points from a set of views and combining the renderings. e.g. pcl_mesh2pcd, pcl_mesh_sampling

D.J.Duff
  • 1,565
  • 9
  • 14
  • But, I'm trying to do that you told, I have a problem. I want to convert obj mesh to pcd. But pcl_mesh2pcd and pcl_mesh_sampling occur the error(Program just dye...TT). What can I do? – Youn A Lee Dec 05 '14 at 02:35
  • You could try opening another question showing those errors. Perhaps someone else has had a similar problem, perhaps there are some bugs, perhaps some bitrot has set it, etc. Someone should be able to help. I've not personally used these tools, and I don't currently have PCL installed, but I might be able to help if I see the errors. – D.J.Duff Dec 06 '14 at 22:09
  • You might also check out the pcl-users mailing list for similar problems. I remember now that pcl has a new "simulation" library that could be useful for this kind of thing - there might be a tool available that uses that. – D.J.Duff Dec 06 '14 at 22:10
6

Converting a triangulated mesh to a point cloud means that you want make a point sampling on that surface. Depending on the required distribution (e.g. Uniform Montecarlo, Poisson Disk, etc.) there are different algorithms with quite different results. For example if you need well spaced random point you need a poisson disk distribution. You can test some of these algorithms inside meshlab or directly on the your browswer on http://www.meshlabjs.net/ (just load a mesh and type 'sampling' in the search box).

You can find a c++ open source implementation inside the mesh processing vcg library (http://www.vcglib.net) and a description of these algorithm (quite simple to be implemented) in:

Efficient and flexible sampling with blue noise properties of triangular meshes
M Corsini, P Cignoni, R Scopigno
IEEE Transactions on Visualization and Computer Graphics 18 (6), 914-924
http://vcg.isti.cnr.it/Publications/2012/CCS12/

ALoopingIcon
  • 2,218
  • 1
  • 21
  • 30
  • 1
    There is also [PyMeshLab](https://pymeshlab.readthedocs.io/en/latest/), which is a Python binding for MeshLab and replaces the meshlabserver for execution of FilterScripts. – ketza Jan 26 '21 at 16:46
  • Thanks a lot, meshlab just did what I was trying to achieve :) – Nehil Danış Mar 15 '21 at 19:26
2

It's interesting that there aren't any definitive answers to this question on the web.

Conversion from a mesh to a point cloud is not similar to jamming the mesh's vertices into a point cloud! Mesh is a sparse representation of a point cloud. Therefore, to convert a mesh to a point cloud, you need to sample points on the surface of the mesh. PCL has a utility for doing that called pcl_mesh_sampling. The source code is located here.

Basically, the method samples N points uniformly from the surface of the mesh using VTK. It is very effective and you'll get point clouds with any number of points you want.

Maghoumi
  • 3,295
  • 3
  • 33
  • 49
2

I was searching for the similar problem. I needed to project the mesh model in different poses to generate pointcloud data.

And then I found the below project in github. If anyone wants to generate pointclouds (.pcd) from a mesh object (.obj) in various poses, this would help.

This will simulate kinect-format pointcloud for the given mesh object.

https://github.com/jbohg/render_kinect

jackberry
  • 756
  • 7
  • 10
2

I wanted to do the same, but preferred something which can be done easily in Python. I found this post to be really useful. It uses a Python library called pyntcloud. It loads a mesh in .ply format and samples a specified number of points from it randomly such that it covers the surface in a more or less uniform manner. It can be easily adapted for other formats. I have done so for .off files and it works well.

Geetchandra
  • 131
  • 4