40 #include "pcl/recognition/hv/occlusion_reasoning.h"
41 #include "pcl/recognition/impl/hv/occlusion_reasoning.hpp"
42 #include <pcl/search/kdtree.h>
43 #include <pcl/filters/voxel_grid.h>
53 template<
typename ModelT,
typename SceneT>
134 zbuffer_scene_resolution_ = 100;
135 zbuffer_self_occlusion_resolution_ = 150;
136 resolution_ = 0.005f;
137 inliers_threshold_ =
static_cast<float>(resolution_);
138 occlusion_cloud_set_ =
false;
139 occlusion_thres_ = 0.005f;
140 normals_set_ =
false;
141 requires_normals_ =
false;
148 return requires_normals_;
166 occlusion_thres_ = t;
175 inliers_threshold_ = r;
198 complete_models_ = complete_models;
209 complete_normal_models_ = complete_models;
222 if(!occlusion_cloud_set_) {
223 PCL_WARN(
"Occlusion cloud not set, using scene_cloud instead...\n");
224 occlusion_cloud_ = scene_cloud_;
227 if (!occlusion_reasoning)
228 visible_models_ = models;
232 if (scene_cloud_ ==
nullptr)
234 PCL_ERROR(
"setSceneCloud should be called before adding the model if reasoning about occlusions...\n");
239 PCL_WARN(
"Scene not organized... filtering using computed depth buffer\n");
248 for (std::size_t i = 0; i < models.size (); i++)
256 zbuffer_self_occlusion.
filter (models[i], indices, 0.005f);
259 if(normals_set_ && requires_normals_) {
262 visible_normal_models_.push_back(filtered_normals);
270 filtered = pcl::occlusion_reasoning::filter<ModelT,SceneT> (occlusion_cloud_, const_filtered, 525.f, occlusion_thres_);
274 zbuffer_scene.
filter (const_filtered, filtered, occlusion_thres_);
277 visible_models_.push_back (filtered);
280 complete_models_ = models;
283 occlusion_cloud_set_ =
false;
284 normals_set_ =
false;
296 complete_models_.clear();
297 visible_models_.clear();
298 visible_normal_models_.clear();
300 scene_cloud_ = scene_cloud;
305 voxel_grid.
setLeafSize (resolution_, resolution_, resolution_);
307 voxel_grid.
filter (*scene_cloud_downsampled_);
311 scene_downsampled_tree_->
setInputCloud(scene_cloud_downsampled_);
316 occlusion_cloud_ = occ_cloud;
317 occlusion_cloud_set_ =
true;
void filter(PointCloud &output)
Calls the filtering method and returns the filtered dataset in output.
Abstract class for hypotheses verification methods.
bool occlusion_cloud_set_
pcl::PointCloud< SceneT >::Ptr scene_cloud_downsampled_
void addModels(std::vector< typename pcl::PointCloud< ModelT >::ConstPtr > &models, bool occlusion_reasoning=false)
std::vector< bool > mask_
void setSceneCloud(const typename pcl::PointCloud< SceneT >::Ptr &scene_cloud)
void setOcclusionCloud(const typename pcl::PointCloud< SceneT >::Ptr &occ_cloud)
void setInlierThreshold(float r)
pcl::search::KdTree< SceneT >::Ptr scene_downsampled_tree_
void getMask(std::vector< bool > &mask)
virtual ~HypothesisVerification()=default
pcl::PointCloud< SceneT >::ConstPtr scene_cloud_
void setResolution(float r)
std::vector< typename pcl::PointCloud< ModelT >::ConstPtr > complete_models_
pcl::PointCloud< SceneT >::ConstPtr occlusion_cloud_
void addCompleteModels(std::vector< typename pcl::PointCloud< ModelT >::ConstPtr > &complete_models)
std::vector< typename pcl::PointCloud< pcl::Normal >::ConstPtr > complete_normal_models_
bool getRequiresNormals()
int zbuffer_scene_resolution_
int zbuffer_self_occlusion_resolution_
void addNormalsClouds(std::vector< pcl::PointCloud< pcl::Normal >::ConstPtr > &complete_models)
std::vector< typename pcl::PointCloud< pcl::Normal >::ConstPtr > visible_normal_models_
void setOcclusionThreshold(float t)
std::vector< typename pcl::PointCloud< ModelT >::ConstPtr > visible_models_
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
bool isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
void setDownsampleAllData(bool downsample)
Set to true if all fields need to be downsampled, or false if just XYZ.
void setLeafSize(const Eigen::Vector4f &leaf_size)
Set the voxel grid leaf size.
Class to reason about occlusions.
void computeDepthMap(typename pcl::PointCloud< SceneT >::ConstPtr &scene, bool compute_focal=false, bool smooth=false, int wsize=3)
void filter(typename pcl::PointCloud< ModelT >::ConstPtr &model, typename pcl::PointCloud< ModelT >::Ptr &filtered, float thres=0.01)
shared_ptr< KdTree< PointT, Tree > > Ptr
bool setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr()) override
Provide a pointer to the input dataset.
void copyPointCloud(const pcl::PointCloud< PointInT > &cloud_in, pcl::PointCloud< PointOutT > &cloud_out)
Copy all the fields from a given point cloud into a new point cloud.
IndicesAllocator<> Indices
Type used for indices in PCL.
Defines all the PCL and non-PCL macros used.