Demonstration notebook: How PCL.jl works

PCL.jl is a Julia interface to the Point Cloud Library (PCL): https://github.com/r9y9/PCL.jl.

In [1]:
ENV["PCLJL_VERBOSE"] = 0
using PCL
using Cxx

Read PCD file

In [2]:
pcd_file = Pkg.dir("PCL", "test", "data", "table_scene_lms400.pcd")
# pcd_file = Pkg.dir("PCL", "test", "data", "milk_cartoon_all_small_clorox.pcd")
cloud = pcl.PointCloud{pcl.PointXYZ}(pcd_file);

StatisticalOutlierRemoval

In [3]:
cloud_filtered = pcl.PointCloud{pcl.PointXYZ}()

sor = pcl.StatisticalOutlierRemoval{pcl.PointXYZ}()
pcl.setInputCloud(sor, cloud)
pcl.setMeanK(sor, 50)
pcl.setStddevMulThresh(sor, 1.0)
pcl.filter(sor, cloud_filtered)

println("PointCloud before filtering: $(length(cloud)) data points")
println("PointCloud before filtering: $(length(cloud_filtered)) data points")
PointCloud before filtering: 460400 data points

PCLVisualizer with off-screen rendering

In [4]:
viewer = pcl.PCLVisualizer("pcl visualizeer", create_interactor=false)
pcl.addCoordinateSystem(viewer, 0.2)
pcl.setCameraPosition(viewer, 0,0,1, 0,0,0)
pcl.setOffScreenRendering(viewer, true)

# Add point clouds
red_handler = pcl.PointCloudColorHandlerCustom(cloud, 255, 0, 0)
green_handler = pcl.PointCloudColorHandlerCustom(cloud, 0, 255, 0)
pcl.addPointCloud(viewer, cloud, red_handler, id="cloud")
pcl.addPointCloud(viewer, cloud_filtered, green_handler, id="cloud_filtered")
Out[4]:
true
PointCloud before filtering: 451410 data points
In [5]:
data = pcl.renderedData(viewer)
display("text/html", "<img src=data:image/png;base64,$(base64encode(data))>")
In [6]:
# Zoom againt Z-axis
pcl.setCameraPosition(viewer, 0,0,0.5, 0,0,0)
data = pcl.renderedData(viewer)
display("text/html", "<img src=data:image/png;base64,$(base64encode(data))>")