Point Cloud Library (PCL)  1.14.0-dev
List of all members | Public Types | Public Member Functions | Protected Member Functions
pcl::FrustumCulling< PointT > Class Template Reference

FrustumCulling filters points inside a frustum given by pose and field of view of the camera. More...

#include <pcl/filters/frustum_culling.h>

+ Inheritance diagram for pcl::FrustumCulling< PointT >:
+ Collaboration diagram for pcl::FrustumCulling< PointT >:

Public Types

using Ptr = shared_ptr< FrustumCulling< PointT > >
 
using ConstPtr = shared_ptr< const FrustumCulling< PointT > >
 
- Public Types inherited from pcl::FilterIndices< PointT >
using PointCloud = pcl::PointCloud< PointT >
 
using Ptr = shared_ptr< FilterIndices< PointT > >
 
using ConstPtr = shared_ptr< const FilterIndices< PointT > >
 
- Public Types inherited from pcl::Filter< PointT >
using Ptr = shared_ptr< Filter< PointT > >
 
using ConstPtr = shared_ptr< const Filter< PointT > >
 
using PointCloud = pcl::PointCloud< PointT >
 
using PointCloudPtr = typename PointCloud::Ptr
 
using PointCloudConstPtr = typename PointCloud::ConstPtr
 
- Public Types inherited from pcl::PCLBase< PointT >
using PointCloud = pcl::PointCloud< PointT >
 
using PointCloudPtr = typename PointCloud::Ptr
 
using PointCloudConstPtr = typename PointCloud::ConstPtr
 
using PointIndicesPtr = PointIndices::Ptr
 
using PointIndicesConstPtr = PointIndices::ConstPtr
 

Public Member Functions

 FrustumCulling (bool extract_removed_indices=false)
 
void setCameraPose (const Eigen::Matrix4f &camera_pose)
 Set the pose of the camera w.r.t the origin. More...
 
Eigen::Matrix4f getCameraPose () const
 Get the pose of the camera w.r.t the origin. More...
 
void setHorizontalFOV (float hfov)
 Set the horizontal field of view for the camera in degrees. More...
 
void setHorizontalFOV (float fov_left_bound, float fov_right_bound)
 Set the horizontal field of view for the camera in degrees. More...
 
float getHorizontalFOV () const
 Get the horizontal field of view for the camera in degrees. More...
 
void getHorizontalFOV (float &fov_left_bound, float &fov_right_bound) const
 Get the horizontal field of view for the camera in degrees. More...
 
void setVerticalFOV (float vfov)
 Set the vertical field of view for the camera in degrees. More...
 
void setVerticalFOV (float fov_lower_bound, float fov_upper_bound)
 Set the vertical field of view for the camera in degrees. More...
 
float getVerticalFOV () const
 Get the vertical field of view for the camera in degrees. More...
 
void getVerticalFOV (float &fov_lower_bound, float &fov_upper_bound) const
 Get the vertical field of view for the camera in degrees. More...
 
void setNearPlaneDistance (float np_dist)
 Set the near plane distance. More...
 
float getNearPlaneDistance () const
 Get the near plane distance. More...
 
void setFarPlaneDistance (float fp_dist)
 Set the far plane distance. More...
 
float getFarPlaneDistance () const
 Get the far plane distance. More...
 
void setRegionOfInterest (float roi_x, float roi_y, float roi_w, float roi_h)
 Set the region of interest (ROI) in normalized values. More...
 
void getRegionOfInterest (float &roi_x, float &roi_y, float &roi_w, float &roi_h) const
 Get the region of interest (ROI) in normalized values. More...
 
- Public Member Functions inherited from pcl::FilterIndices< PointT >
 FilterIndices (bool extract_removed_indices=false)
 Constructor. More...
 
void filter (Indices &indices)
 Calls the filtering method and returns the filtered point cloud indices. More...
 
void setNegative (bool negative)
 Set whether the regular conditions for points filtering should apply, or the inverted conditions. More...
 
bool getNegative () const
 Get whether the regular conditions for points filtering should apply, or the inverted conditions. More...
 
void setKeepOrganized (bool keep_organized)
 Set whether the filtered points should be kept and set to the value given through setUserFilterValue (default: NaN), or removed from the PointCloud, thus potentially breaking its organized structure. More...
 
bool getKeepOrganized () const
 Get whether the filtered points should be kept and set to the value given through setUserFilterValue (default = NaN), or removed from the PointCloud, thus potentially breaking its organized structure. More...
 
void setUserFilterValue (float value)
 Provide a value that the filtered points should be set to instead of removing them. More...
 
- Public Member Functions inherited from pcl::Filter< PointT >
 Filter (bool extract_removed_indices=false)
 Empty constructor. More...
 
IndicesConstPtr const getRemovedIndices () const
 Get the point indices being removed. More...
 
void getRemovedIndices (PointIndices &pi)
 Get the point indices being removed. More...
 
void filter (PointCloud &output)
 Calls the filtering method and returns the filtered dataset in output. More...
 
- Public Member Functions inherited from pcl::PCLBase< PointT >
 PCLBase ()
 Empty constructor. More...
 
 PCLBase (const PCLBase &base)
 Copy constructor. More...
 
virtual ~PCLBase ()=default
 Destructor. More...
 
virtual void setInputCloud (const PointCloudConstPtr &cloud)
 Provide a pointer to the input dataset. More...
 
PointCloudConstPtr const getInputCloud () const
 Get a pointer to the input point cloud dataset. More...
 
virtual void setIndices (const IndicesPtr &indices)
 Provide a pointer to the vector of indices that represents the input data. More...
 
virtual void setIndices (const IndicesConstPtr &indices)
 Provide a pointer to the vector of indices that represents the input data. More...
 
virtual void setIndices (const PointIndicesConstPtr &indices)
 Provide a pointer to the vector of indices that represents the input data. More...
 
virtual void setIndices (std::size_t row_start, std::size_t col_start, std::size_t nb_rows, std::size_t nb_cols)
 Set the indices for the points laying within an interest region of the point cloud. More...
 
IndicesPtr getIndices ()
 Get a pointer to the vector of indices used. More...
 
IndicesConstPtr const getIndices () const
 Get a pointer to the vector of indices used. More...
 
const PointToperator[] (std::size_t pos) const
 Override PointCloud operator[] to shorten code. More...
 

Protected Member Functions

void applyFilter (Indices &indices) override
 Sample of point indices. More...
 
- Protected Member Functions inherited from pcl::FilterIndices< PointT >
void applyFilter (PointCloud &output) override
 Abstract filter method for point cloud. More...
 
- Protected Member Functions inherited from pcl::Filter< PointT >
const std::string & getClassName () const
 Get a string representation of the name of this class. More...
 
- Protected Member Functions inherited from pcl::PCLBase< PointT >
bool initCompute ()
 This method should get called before starting the actual computation. More...
 
bool deinitCompute ()
 This method should get called after finishing the actual computation. More...
 

Additional Inherited Members

- Protected Attributes inherited from pcl::FilterIndices< PointT >
bool negative_ {false}
 False = normal filter behavior (default), true = inverted behavior. More...
 
bool keep_organized_ {false}
 False = remove points (default), true = redefine points, keep structure. More...
 
float user_filter_value_
 The user given value that the filtered point dimensions should be set to (default = NaN). More...
 
- Protected Attributes inherited from pcl::Filter< PointT >
IndicesPtr removed_indices_
 Indices of the points that are removed. More...
 
std::string filter_name_
 The filter name. More...
 
bool extract_removed_indices_
 Set to true if we want to return the indices of the removed points. More...
 
- Protected Attributes inherited from pcl::PCLBase< PointT >
PointCloudConstPtr input_
 The input point cloud dataset. More...
 
IndicesPtr indices_
 A pointer to the vector of point indices to use. More...
 
bool use_indices_
 Set to true if point indices are used. More...
 
bool fake_indices_
 If no set of indices are given, we construct a set of fake indices that mimic the input PointCloud. More...
 

Detailed Description

template<typename PointT>
class pcl::FrustumCulling< PointT >

FrustumCulling filters points inside a frustum given by pose and field of view of the camera.

Code example:

// .. read or fill the source cloud
fc.setInputCloud (source);
Eigen::Matrix4f camera_pose;
// .. read or input the camera pose from a registration algorithm.
fc.setCameraPose (camera_pose);
fc.filter (target);
void filter(Indices &indices)
Calls the filtering method and returns the filtered point cloud indices.
FrustumCulling filters points inside a frustum given by pose and field of view of the camera.
void setNearPlaneDistance(float np_dist)
Set the near plane distance.
void setVerticalFOV(float vfov)
Set the vertical field of view for the camera in degrees.
void setFarPlaneDistance(float fp_dist)
Set the far plane distance.
void setHorizontalFOV(float hfov)
Set the horizontal field of view for the camera in degrees.
void setCameraPose(const Eigen::Matrix4f &camera_pose)
Set the pose of the camera w.r.t the origin.
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
Definition: pcl_base.hpp:65
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:413
Author
Aravindhan K Krishnan

Definition at line 76 of file frustum_culling.h.

Member Typedef Documentation

◆ ConstPtr

template<typename PointT >
using pcl::FrustumCulling< PointT >::ConstPtr = shared_ptr<const FrustumCulling<PointT> >

Definition at line 85 of file frustum_culling.h.

◆ Ptr

template<typename PointT >
using pcl::FrustumCulling< PointT >::Ptr = shared_ptr<FrustumCulling<PointT> >

Definition at line 84 of file frustum_culling.h.

Constructor & Destructor Documentation

◆ FrustumCulling()

template<typename PointT >
pcl::FrustumCulling< PointT >::FrustumCulling ( bool  extract_removed_indices = false)
inline

Definition at line 90 of file frustum_culling.h.

References pcl::Filter< PointT >::filter_name_.

Member Function Documentation

◆ applyFilter()

template<typename PointT >
void pcl::FrustumCulling< PointT >::applyFilter ( Indices indices)
overrideprotectedvirtual

Sample of point indices.

Parameters
[out]indicesthe resultant point cloud indices

Implements pcl::FilterIndices< PointT >.

Definition at line 46 of file frustum_culling.hpp.

References M_PI.

◆ getCameraPose()

template<typename PointT >
Eigen::Matrix4f pcl::FrustumCulling< PointT >::getCameraPose ( ) const
inline

Get the pose of the camera w.r.t the origin.

Definition at line 123 of file frustum_culling.h.

◆ getFarPlaneDistance()

template<typename PointT >
float pcl::FrustumCulling< PointT >::getFarPlaneDistance ( ) const
inline

Get the far plane distance.

Definition at line 286 of file frustum_culling.h.

◆ getHorizontalFOV() [1/2]

template<typename PointT >
float pcl::FrustumCulling< PointT >::getHorizontalFOV ( ) const
inline

Get the horizontal field of view for the camera in degrees.

Definition at line 169 of file frustum_culling.h.

◆ getHorizontalFOV() [2/2]

template<typename PointT >
void pcl::FrustumCulling< PointT >::getHorizontalFOV ( float &  fov_left_bound,
float &  fov_right_bound 
) const
inline

Get the horizontal field of view for the camera in degrees.

Definition at line 182 of file frustum_culling.h.

◆ getNearPlaneDistance()

template<typename PointT >
float pcl::FrustumCulling< PointT >::getNearPlaneDistance ( ) const
inline

Get the near plane distance.

Definition at line 264 of file frustum_culling.h.

◆ getRegionOfInterest()

template<typename PointT >
void pcl::FrustumCulling< PointT >::getRegionOfInterest ( float &  roi_x,
float &  roi_y,
float &  roi_w,
float &  roi_h 
) const
inline

Get the region of interest (ROI) in normalized values.

Parameters
[in]roi_xX center position of ROI
[in]roi_yY center position of ROI
[in]roi_wWidth of ROI
[in]roi_hHeight of ROI

Definition at line 327 of file frustum_culling.h.

◆ getVerticalFOV() [1/2]

template<typename PointT >
float pcl::FrustumCulling< PointT >::getVerticalFOV ( ) const
inline

Get the vertical field of view for the camera in degrees.

Definition at line 229 of file frustum_culling.h.

◆ getVerticalFOV() [2/2]

template<typename PointT >
void pcl::FrustumCulling< PointT >::getVerticalFOV ( float &  fov_lower_bound,
float &  fov_upper_bound 
) const
inline

Get the vertical field of view for the camera in degrees.

Definition at line 242 of file frustum_culling.h.

◆ setCameraPose()

template<typename PointT >
void pcl::FrustumCulling< PointT >::setCameraPose ( const Eigen::Matrix4f &  camera_pose)
inline

Set the pose of the camera w.r.t the origin.

Parameters
[in]camera_posethe camera pose

Note: This assumes a coordinate system where X is forward, Y is up, and Z is right. To convert from the traditional camera coordinate system (X right, Y down, Z forward), one can use:

Eigen::Matrix4f pose_orig = //pose in camera coordinates
Eigen::Matrix4f cam2robot;
cam2robot << 0, 0, 1, 0
0,-1, 0, 0
1, 0, 0, 0
0, 0, 0, 1;
Eigen::Matrix4f pose_new = pose_orig * cam2robot;
fc.setCameraPose (pose_new);

Definition at line 116 of file frustum_culling.h.

◆ setFarPlaneDistance()

template<typename PointT >
void pcl::FrustumCulling< PointT >::setFarPlaneDistance ( float  fp_dist)
inline

Set the far plane distance.

Parameters
[in]fp_distthe far plane distance. You can set this to std::numeric_limits<float>::max(), then points will not be filtered by the far plane.

Definition at line 274 of file frustum_culling.h.

◆ setHorizontalFOV() [1/2]

template<typename PointT >
void pcl::FrustumCulling< PointT >::setHorizontalFOV ( float  fov_left_bound,
float  fov_right_bound 
)
inline

Set the horizontal field of view for the camera in degrees.

Parameters
[in]fov_left_boundthe left bound of horizontal field of view
[in]fov_right_boundthe right bound of horizontal field of view Note: Bounds can be either positive or negative values. Negative value means the camera would look to its left, and positive value means the camera would look to its right. In general cases, fov_left_bound should be set to a negative value, if it is set to a positive value, the camera would only look to its right. Also note that setHorizontalFOV(-30.0, 30.0) is equivalent to setHorizontalFOV(60.0).

Definition at line 155 of file frustum_culling.h.

◆ setHorizontalFOV() [2/2]

template<typename PointT >
void pcl::FrustumCulling< PointT >::setHorizontalFOV ( float  hfov)
inline

Set the horizontal field of view for the camera in degrees.

Parameters
[in]hfovthe field of view Note: setHorizontalFOV(60.0) is equivalent to setHorizontalFOV(-30.0, 30.0).

Definition at line 133 of file frustum_culling.h.

◆ setNearPlaneDistance()

template<typename PointT >
void pcl::FrustumCulling< PointT >::setNearPlaneDistance ( float  np_dist)
inline

Set the near plane distance.

Parameters
[in]np_distthe near plane distance. You can set this to 0 to disable near-plane filtering and extract a rectangular pyramid instead of a frustum.

Definition at line 252 of file frustum_culling.h.

◆ setRegionOfInterest()

template<typename PointT >
void pcl::FrustumCulling< PointT >::setRegionOfInterest ( float  roi_x,
float  roi_y,
float  roi_w,
float  roi_h 
)
inline

Set the region of interest (ROI) in normalized values.

Default value of ROI: roi_{x, y} = 0.5, roi_{w, h} = 1.0 This corresponds to maximal FoV and returns all the points in the frustum Can be used to cut out objects based on 2D bounding boxes by object detection.

Parameters
[in]roi_xX center position of ROI
[in]roi_yY center position of ROI
[in]roi_wWidth of ROI
[in]roi_hHeight of ROI

Definition at line 303 of file frustum_culling.h.

◆ setVerticalFOV() [1/2]

template<typename PointT >
void pcl::FrustumCulling< PointT >::setVerticalFOV ( float  fov_lower_bound,
float  fov_upper_bound 
)
inline

Set the vertical field of view for the camera in degrees.

Parameters
[in]fov_lower_boundthe lower bound of vertical field of view
[in]fov_upper_boundthe upper bound of vertical field of view Note: Bounds can be either positive or negative values. Negative value means the camera would look down, and positive value means the camera would look up. In general cases, fov_lower_bound should be set to a negative value, if it is set to a positive value, the camera would only look up. Also note that setVerticalFOV(-30.0, 30.0) is equivalent to setVerticalFOV(60.0).

Definition at line 215 of file frustum_culling.h.

◆ setVerticalFOV() [2/2]

template<typename PointT >
void pcl::FrustumCulling< PointT >::setVerticalFOV ( float  vfov)
inline

Set the vertical field of view for the camera in degrees.

Parameters
[in]vfovthe field of view Note: setVerticalFOV(60.0) is equivalent to setVerticalFOV(-30.0, 30.0).

Definition at line 193 of file frustum_culling.h.


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