Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented a class to generate point clouds of 3D geometric primitives #508

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,10 @@ set(POINTMATCHER_SRC
pointmatcher/DataPointsFilters/DistanceLimit.cpp
pointmatcher/DataPointsFilters/RemoveSensorBias.cpp
pointmatcher/DataPointsFilters/Sphericality.cpp
pointmatcher/DataPointsFilters/Saliency.cpp
pointmatcher/DataPointsFilters/Saliency.cpp
pointmatcher/DataPointsFilters/SpectralDecomposition.cpp
#PointCloudGenerators
pointmatcher/PointCloudGenerator.cpp
)


Expand Down
50 changes: 50 additions & 0 deletions examples/python/point_cloud_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Code example for ICP generating different shapes using the built-in interface
import os.path

import numpy as np
from pypointmatcher import pointmatcher as pm

PM = pm.PointMatcher
DP = PM.DataPoints
Generator = pm.PointCloudGenerator

# Path of output directory (default: tests/icp_simple/)
# The output directory must already exist
# Leave empty to save in the current directory
output_base_directory = "tests/generator/"

# How many points will each generated shape contain
number_of_points = 10000

# Toggle to switch between 2D and 3D clouds
# Only 3D is currently supported
is_3D = True

if is_3D:
# Load 3D point clouds
ref = DP(DP.load('../data/car_cloud400.csv'))
data = DP(DP.load('../data/car_cloud401.csv'))
test_base = "3D"
translation = np.array([[0], [0], [0]])
rotation = np.array([1, 0, 0, 0], dtype=np.float32)
else:
raise Exception("The Point Cloud Generator only supports 3D shapes")

box = Generator.generateUniformlySampledBox(1.0, 2.0, 3.0, number_of_points, translation, rotation)
circle = Generator.generateUniformlySampledCircle(1.0, number_of_points, translation, rotation)
cylinder = Generator.generateUniformlySampledCylinder(1.0, 2.0, number_of_points, translation, rotation)
plane = Generator.generateUniformlySampledPlane(np.array([1.0, 2.0, 3.0]), number_of_points, translation, rotation)
sphere = Generator.generateUniformlySampledSphere(1.0, number_of_points, translation, rotation)


# Save files to see the results
if not os.path.exists(output_base_directory):
os.makedirs(output_base_directory)

box.save(f"{output_base_directory}box.vtk")
circle.save(f"{output_base_directory}circle.vtk")
cylinder.save(f"{output_base_directory}cylinder.vtk")
plane.save(f"{output_base_directory}plane.vtk")
sphere.save(f"{output_base_directory}sphere.vtk")

print(f"Saved generated shapes into {output_base_directory}")
Loading
Loading