pcl_utils
Static Public Member Functions | List of all members
utils::PclUtils< T > Class Template Reference

#include <pcl_utils.h>

Static Public Member Functions

static pcl::visualization::PCLVisualizer::Ptr pclViewer ()
 
static pcl::visualization::PCLVisualizer::Ptr pclViewer (typename PclCloud::Ptr &cloud)
 
static void showCloud (typename PclCloud::Ptr &cloud)
 
static void addColoredCloud (pcl::visualization::PCLVisualizer::Ptr &viewer, typename PclCloud::Ptr &cloud, float r=255.0f, float g=0.0f, float b=0.0f)
 
static void downsample (typename PclCloud::Ptr &cloud, typename PclCloud::Ptr &outcloud, const float leaf=0.005f)
 
template<typename PointNT >
static void estimateNormal (typename pcl::PointCloud< PointNT >::Ptr &cloud, typename pcl::PointCloud< PointNT >::Ptr &outcloud, const float radius=0.01)
 
static PclCloud::Ptr cropPointCloud (typename PclCloud::Ptr &cloud, Eigen::Vector2i &topleft, Eigen::Vector2i &bottomright)
 
static PclCloud::Ptr cropPointCloud (typename PclCloud::Ptr &cloud, const Eigen::Vector4i &box)
 
static void filterOutliers (typename PclCloud::Ptr &cloud, std::string axis, float min, float max)
 
static PclCloud::Ptr extractIndices (typename PclCloud::Ptr &cloud, std::vector< int > &indices, bool negative=false, bool keep_organized=false)
 
static PclCloud::Ptr extractIndices (typename PclCloud::Ptr &cloud, pcl::PointIndices::Ptr &indices, bool negative=false, bool keep_organized=false)
 
static void extractIndices (typename PclCloud::Ptr &cloud, pcl::PointIndices::Ptr &indices, typename PclCloud::Ptr &out_cloud, bool negative=false, bool keep_organized=false)
 
static void segmentPlane (typename PclCloud::Ptr &cloud, pcl::ModelCoefficients::Ptr &coeff, pcl::PointIndices::Ptr &inliers)
 
static void filterTableTop (typename PclCloud::Ptr &cloud, float min_table_z, float min_table_x)
 
static void convertToXYZRGB (typename pcl::PointCloud< T > &cloud, Eigen::Vector3i &color, pcl::PointCloud< pcl::PointXYZRGB > &out_cloud)
 
static void cluster (typename PclCloud::Ptr &cloud, std::vector< pcl::PointIndices > &cluster_indices)
 
static Eigen::Vector4i findBox (const pcl::PointIndices &indices, typename PclCloud::Ptr &cloud)
 
static T findNearestNonNan (typename PclCloud::Ptr &cloud, int cx, int cy)
 
static T createPoint (float x, float y, float z)
 
static PclCloud::Ptr createCloud (const Eigen::Ref< const Eigen::MatrixXf > &mat)
 
static Eigen::Matrix< float, 3, 8 > createOrientedBox (typename PclCloud::Ptr &cloud)
 

Detailed Description

template<typename T>
class utils::PclUtils< T >

Utility functions for PCL library

Once the class is templated, the static methods act as common utiltiy functions for that specific type unless it accepts another type.

Member Function Documentation

template<typename T >
static void utils::PclUtils< T >::addColoredCloud ( pcl::visualization::PCLVisualizer::Ptr &  viewer,
typename PclCloud::Ptr &  cloud,
float  r = 255.0f,
float  g = 0.0f,
float  b = 0.0f 
)
inlinestatic

Add pointcloud to the visualizer with colored option. Default color is RED

Parameters
viewerPCL Visualizer object that is created either using pcl-utils or PCL.
cloudInput pointcloud pointer.
rRed component. To choose random color, pass r as any negative number.
gGreen component.
bBlue component.
template<typename T >
static void utils::PclUtils< T >::cluster ( typename PclCloud::Ptr &  cloud,
std::vector< pcl::PointIndices > &  cluster_indices 
)
inlinestatic

Cluster pointcloud by Euclidean distance.

ClusterTolerance: 0.02 // 2cm Min cluster size: 600 Max cluster size: 50000

Parameters
cloudInput pointcloud pointer.
cluster_indicesOutput vector of PointIndices of all the clusters
template<typename T >
static void utils::PclUtils< T >::convertToXYZRGB ( typename pcl::PointCloud< T > &  cloud,
Eigen::Vector3i &  color,
pcl::PointCloud< pcl::PointXYZRGB > &  out_cloud 
)
inlinestatic

Convert XYZ cloud to XYZRGB cloud.

template<typename T >
static PclCloud::Ptr utils::PclUtils< T >::createCloud ( const Eigen::Ref< const Eigen::MatrixXf > &  mat)
inlinestatic

Factory method to create pointcloud from the Eigen matrix

Parameters
matEigen matrix of size 3xn.
Returns
Newly created pointcloud pointer.
template<typename T >
static Eigen::Matrix<float, 3, 8> utils::PclUtils< T >::createOrientedBox ( typename PclCloud::Ptr &  cloud)
inlinestatic

Creates a 3D oriented bounding box around the given pointcloud.

Parameters
cloudInput pointcloud pointer.
Returns
Eigen matrix of size 3x8. Eight point of the cuboid.
template<typename T >
static T utils::PclUtils< T >::createPoint ( float  x,
float  y,
float  z 
)
inlinestatic

Factory method to create a Point of templated type.

Returns
Newly created point.
template<typename T >
static PclCloud::Ptr utils::PclUtils< T >::cropPointCloud ( typename PclCloud::Ptr &  cloud,
Eigen::Vector2i &  topleft,
Eigen::Vector2i &  bottomright 
)
inlinestatic

Crop an organized pointcloud using the given bounding box.

Parameters
cloudInput pointcloud pointer.
topleftEigen vector for (x,y) value to represent topleft corner of the bounding box.
bottomrightEigen vector for bottom-right corner.
Returns
Cropped pointcloud
template<typename T >
static PclCloud::Ptr utils::PclUtils< T >::cropPointCloud ( typename PclCloud::Ptr &  cloud,
const Eigen::Vector4i &  box 
)
inlinestatic

Crop an organized pointcloud using the given bounding box.

Parameters
cloudInput pointcloud pointer.
boxEigen vector that contains (x,y,x2,y2) denoting a bounding box.
Returns
Cropped pointcloud
template<typename T >
static void utils::PclUtils< T >::downsample ( typename PclCloud::Ptr &  cloud,
typename PclCloud::Ptr &  outcloud,
const float  leaf = 0.005f 
)
inlinestatic

Downsample pointcloud using given leaf size.

Refer pcl::VoxelGrid for details.

Parameters
cloudInput pointcloud pointer.
outcloudOutput pointcloud pointer.
leafLeaf size for VoxelGrid downsampling (default is 0.005)
template<typename T >
template<typename PointNT >
static void utils::PclUtils< T >::estimateNormal ( typename pcl::PointCloud< PointNT >::Ptr &  cloud,
typename pcl::PointCloud< PointNT >::Ptr &  outcloud,
const float  radius = 0.01 
)
inlinestatic

Surface normal estimation for the given pointcloud

Refer pcl::NormalEstimationOMP for details

Parameters
cloudInput pointcloud pointer.
outcloudOutput pointcloud pointer.
radiusRadius search parameter for Normal Estimation.
template<typename T >
static PclCloud::Ptr utils::PclUtils< T >::extractIndices ( typename PclCloud::Ptr &  cloud,
std::vector< int > &  indices,
bool  negative = false,
bool  keep_organized = false 
)
inlinestatic

Indices points extractor. Extract the points from the pointcloud based on the input indices.

Parameters
cloudInput pointcloud pointer.
indicesVector of indices of the points in the pointcloud.
negativeIf true, the indices are excluded and remaining points are retained. Default is false.
keep_organizedIf true, the points that does not met the condition will be set to NaN.
Returns
Output cloud after filtering.
template<typename T >
static PclCloud::Ptr utils::PclUtils< T >::extractIndices ( typename PclCloud::Ptr &  cloud,
pcl::PointIndices::Ptr &  indices,
bool  negative = false,
bool  keep_organized = false 
)
inlinestatic

Indices points extractor. Extract the points from the pointcloud based on the input indices.

Parameters
cloudInput pointcloud pointer.
indicesPointIndices object that represents the input indices.
negativeIf true, the indices are excluded and remaining points are retained. Default is false.
keep_organizedIf true, the points that does not met the condition will be set to NaN.
Returns
Output cloud after filtering.
template<typename T >
static void utils::PclUtils< T >::extractIndices ( typename PclCloud::Ptr &  cloud,
pcl::PointIndices::Ptr &  indices,
typename PclCloud::Ptr &  out_cloud,
bool  negative = false,
bool  keep_organized = false 
)
inlinestatic

Indices points extractor. Extract the points from the pointcloud based on the input indices.

Parameters
cloudInput pointcloud pointer.
indicesVector of indices of the points in the pointcloud.
outcloudOutput pointcloud pointer.
negativeIf true, the indices are excluded and remaining points are retained. Default is false.
keep_organizedIf true, the points that does not met the condition will be set to NaN.
template<typename T >
static void utils::PclUtils< T >::filterOutliers ( typename PclCloud::Ptr &  cloud,
std::string  axis,
float  min,
float  max 
)
inlinestatic

Pass-Through filter for any axis. Filters the points that meets the given minmax criteria. Filter is applied on the input pointcloud itself.

Parameters
cloudInput pointcloud pointer.
axisA string denoting the axis. Either "x" / "y" / "z".
minMinimum allowed value for the given axis.
maxMaximum allowed value for the given axis.
template<typename T >
static void utils::PclUtils< T >::filterTableTop ( typename PclCloud::Ptr &  cloud,
float  min_table_z,
float  min_table_x 
)
inlinestatic

Filter out the pointcloud and keep only table-top points.

This utility can be used to filter the objects on top of the table. Input cloud is modified directly.

Parameters
cloudInput pointcloud pointer.
min_table_zMinimum z value to be considered.
min_table_xMinimum x value to be considered.
template<typename T >
static Eigen::Vector4i utils::PclUtils< T >::findBox ( const pcl::PointIndices &  indices,
typename PclCloud::Ptr &  cloud 
)
inlinestatic

Find the enclosing 2D bouding box of the given cluster

Parameters
indicesCluster indices in the pointcloud
cloudInput pointcloud pointer.
Returns
Eigen vector of (x,y,x2,y2) bouding box.
template<typename T >
static T utils::PclUtils< T >::findNearestNonNan ( typename PclCloud::Ptr &  cloud,
int  cx,
int  cy 
)
inlinestatic

Finds the closest Non-NaN point around the given location. Searches for the NonNan point in a circular way by increasing radius on each iteration.

Parameters
cloudInput pointcloud pointer.
cxCenter point x-value.
cyCenter point y-value.
Returns
The closest point.
template<typename T >
static pcl::visualization::PCLVisualizer::Ptr utils::PclUtils< T >::pclViewer ( )
inlinestatic

Creates a PCL Visualizer with general settings such as black background and added coordinate system (xyz axes).

Returns
Created PCL Visualizer
template<typename T >
static pcl::visualization::PCLVisualizer::Ptr utils::PclUtils< T >::pclViewer ( typename PclCloud::Ptr &  cloud)
inlinestatic

Creates a PCL Visualizer with the input cloud added in it.

template<typename T >
static void utils::PclUtils< T >::segmentPlane ( typename PclCloud::Ptr &  cloud,
pcl::ModelCoefficients::Ptr &  coeff,
pcl::PointIndices::Ptr &  inliers 
)
inlinestatic

Fits a plane in the given pointcloud using RANSAC.

Parameters
cloudInput pointcloud pointer.
coeffOutput plane coefficients of the fitten plane.
inliersOutput point indices of the inlier points.
template<typename T >
static void utils::PclUtils< T >::showCloud ( typename PclCloud::Ptr &  cloud)
inlinestatic

Opens the PCL Visualizer and shows up the given point cloud.

Parameters
cloudThe input pointcloud pointer

The documentation for this class was generated from the following file: