C++ Implementation of pointcloud generation from mesh sampling methods.
So far, the following samplers have been implemented:
- Weighted random sampling: generates a given number of points uniformely distributed according to triangle areas. See this blog post for details on the method.
It is provided as-is, and could probably be optimized should the need arise. Feel free to submit merge requests.
# Setup the mirror
curl -1sLf 'https://dl.cloudsmith.io/public/mc-rtc/stable/setup.deb.sh' | sudo -E bash
# Install packages
sudo apt install libmesh-sampling-dev
Requirements:
- cmake >3.11
- Eigen3
- libqhull-dev
If you do not already have a recent cmake installation (>3.11), you will need to install it. On Ubuntu bionic, this can be done by adding the official Kitware PPA, and updating cmake
For bionic:
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update
For xenial:
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial-rc main'
sudo apt-get update
Then install cmake
sudo apt install cmake
You can now build and install this package
git clone --recursive https://github.com/jrl-umi3218/mesh_sampling.git
cd mesh_sampling
mkdir build && cd build
cmake ..
make
sudo make install
A simple binary executable mesh_sampling
is provided. It'll convert any model supported by ASSIMP into its corresponding pointcloud with a given number of points. The command line is of the general form:
- From file to file
mesh_sampling /path/to/model.<supported_mesh_format> --out /path/to/cloud/cloud.<supported_cloud_format> --type xyz_rgb_normal --samples 10000 --binary
- From folder to folder
Here the default cloud format is .qc
. For all files in /path/to/models
a file /path/to/cloud/filename.qc
will be generated.
mesh_sampling /path/to/models --out /path/to/cloud --type xyz_rgb_normal --samples 10000 --binary
Where:
supported_mesh_format
is one of the mesh format supported byASSIMP
(commonly DAE, STL, OBJ)supported_cloud_format
is a PCL formal (pcd
orply
), or qhull's format (qc
)
See mesh_sampling --help
for more options.
Example:
mesh_sampling --in /path/to/model.dae --out /tmp/cloud.pcd --type xyz_rgb_normal --samples 10000 --binary
pcl_viewer /tmp/cloud.pcd -normals_scale 5 -normals 1
To generate convex files, you need to add --convex
option to the command line. The convex file will be generated in the specified folder as filename-ch.txt
.
- From file
mesh_sampling --in /path/to/model.<supported_mesh_format> --out /tmp/test.qc --convex /path --type xyz --samples 10000
- From folder (check all files with respect to the supported extensions ".ply", ".pcd", ".qc", ".stl")
mesh_sampling --in /path/to/models --out /tmp --convex /tmp --type xyz --samples 10000
Cloud saving is optional, you can remove
--out
option to avoid it.