40 #include <pcl/memory.h>
41 #include <pcl/pcl_config.h>
42 #include <pcl/point_types.h>
43 #include <pcl/filters/filter_indices.h>
75 template <
typename Po
intT>
84 using Ptr = shared_ptr<FrustumCulling<PointT> >;
85 using ConstPtr = shared_ptr<const FrustumCulling<PointT> >;
92 , camera_pose_ (
Eigen::Matrix4f::Identity ())
118 camera_pose_ = camera_pose;
125 return (camera_pose_);
135 if (hfov <= 0 || hfov >= 180)
137 throw PCLException (
"Horizontal field of view should be between 0 and 180(excluded).",
138 "frustum_culling.h",
"setHorizontalFOV");
140 fov_left_bound_ = -hfov / 2;
141 fov_right_bound_ = hfov / 2;
157 if (fov_left_bound <= -90 || fov_right_bound >= 90 || fov_left_bound >= fov_right_bound)
159 throw PCLException (
"Horizontal field of view bounds should be between -90 and 90(excluded). "
160 "And left bound should be smaller than right bound.",
161 "frustum_culling.h",
"setHorizontalFOV");
163 fov_left_bound_ = fov_left_bound;
164 fov_right_bound_ = fov_right_bound;
171 if (std::fabs(fov_right_bound_) != std::fabs(fov_left_bound_)) {
172 PCL_WARN(
"Your horizontal field of view is asymmetrical: "
173 "left bound's absolute value(%f) != right bound's absolute value(%f)! "
174 "Please use getHorizontalFOV (float& fov_left_bound, float& fov_right_bound) instead.\n",
175 std::fabs(fov_left_bound_), std::fabs(fov_right_bound_));
177 return (fov_right_bound_ - fov_left_bound_);
184 fov_left_bound = fov_left_bound_;
185 fov_right_bound = fov_right_bound_;
195 if (vfov <= 0 || vfov >= 180)
197 throw PCLException (
"Vertical field of view should be between 0 and 180(excluded).",
198 "frustum_culling.h",
"setVerticalFOV");
200 fov_lower_bound_ = -vfov / 2;
201 fov_upper_bound_ = vfov / 2;
217 if (fov_lower_bound <= -90 || fov_upper_bound >= 90 || fov_lower_bound >= fov_upper_bound)
219 throw PCLException (
"Vertical field of view bounds should be between -90 and 90(excluded). "
220 "And lower bound should be smaller than upper bound.",
221 "frustum_culling.h",
"setVerticalFOV");
223 fov_lower_bound_ = fov_lower_bound;
224 fov_upper_bound_ = fov_upper_bound;
231 if (std::fabs(fov_upper_bound_) != std::fabs(fov_lower_bound_)) {
232 PCL_WARN(
"Your vertical field of view is asymmetrical: "
233 "lower bound's absolute value(%f) != upper bound's absolute value(%f)! "
234 "Please use getVerticalFOV (float& fov_lower_bound, float& fov_upper_bound) instead.\n",
235 std::fabs(fov_lower_bound_), std::fabs(fov_upper_bound_));
237 return (fov_upper_bound_ - fov_lower_bound_);
244 fov_lower_bound = fov_lower_bound_;
245 fov_upper_bound = fov_upper_bound_;
256 throw PCLException (
"Near plane distance should be greater than or equal to 0.",
257 "frustum_culling.h",
"setNearPlaneDistance");
278 throw PCLException (
"Far plane distance should be greater than 0.",
279 "frustum_culling.h",
"setFarPlaneDistance");
305 if ((roi_x > 1.0f) || (roi_x < 0.0f) ||
306 (roi_y > 1.0f) || (roi_y < 0.0f) ||
307 (roi_w <= 0.0f) || (roi_w > 1.0f) ||
308 (roi_h <= 0.0f) || (roi_h > 1.0f))
310 throw PCLException (
"ROI X-Y values should be between 0 and 1. "
311 "Width and height must not be zero.",
312 "frustum_culling.h",
"setRegionOfInterest");
354 Eigen::Matrix4f camera_pose_;
356 float fov_left_bound_{-30.0f};
358 float fov_right_bound_{30.0f};
360 float fov_lower_bound_{-30.0f};
362 float fov_upper_bound_{30.0f};
364 float np_dist_{0.1f};
366 float fp_dist_{5.0f};
381 #ifdef PCL_NO_PRECOMPILE
382 #include <pcl/filters/impl/frustum_culling.hpp>
void setVerticalFOV(float vfov)
Set the vertical field of view for the camera in degrees.
shared_ptr< PointCloud< PointT > > Ptr
A base class for all pcl exceptions which inherits from std::runtime_error.
float getNearPlaneDistance() const
Get the near plane distance.
void getVerticalFOV(float &fov_lower_bound, float &fov_upper_bound) const
Get the vertical field of view for the camera in degrees.
void getHorizontalFOV(float &fov_left_bound, float &fov_right_bound) const
Get the horizontal field of view for the camera in degrees.
void setFarPlaneDistance(float fp_dist)
Set the far plane distance.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
float getVerticalFOV() const
Get the vertical field of view for the camera in degrees.
void setHorizontalFOV(float fov_left_bound, float fov_right_bound)
Set the horizontal field of view for the camera in degrees.
FilterIndices represents the base class for filters that are about binary point removal.
void setCameraPose(const Eigen::Matrix4f &camera_pose)
Set the pose of the camera w.r.t the origin.
Filter represents the base filter class.
shared_ptr< Filter< PointT > > Ptr
void setNearPlaneDistance(float np_dist)
Set the near plane distance.
typename PointCloud::Ptr PointCloudPtr
IndicesAllocator<> Indices
Type used for indices in PCL.
void setRegionOfInterest(float roi_x, float roi_y, float roi_w, float roi_h)
Set the region of interest (ROI) in normalized values.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
void applyFilter(Indices &indices) override
Sample of point indices.
void getRegionOfInterest(float &roi_x, float &roi_y, float &roi_w, float &roi_h) const
Get the region of interest (ROI) in normalized values.
FrustumCulling filters points inside a frustum given by pose and field of view of the camera...
shared_ptr< const PointCloud< PointT > > ConstPtr
void setHorizontalFOV(float hfov)
Set the horizontal field of view for the camera in degrees.
FrustumCulling(bool extract_removed_indices=false)
float getHorizontalFOV() const
Get the horizontal field of view for the camera in degrees.
std::string filter_name_
The filter name.
shared_ptr< const Filter< PointT > > ConstPtr
A point structure representing Euclidean xyz coordinates, and the RGB color.
Eigen::Matrix4f getCameraPose() const
Get the pose of the camera w.r.t the origin.
void setVerticalFOV(float fov_lower_bound, float fov_upper_bound)
Set the vertical field of view for the camera in degrees.
typename PointCloud::ConstPtr PointCloudConstPtr
float getFarPlaneDistance() const
Get the far plane distance.