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;
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)
232 if (scene_cloud_ ==
nullptr)
234 PCL_ERROR(
"setSceneCloud should be called before adding the model if reasoning about occlusions...\n");
237 if (!occlusion_cloud_->isOrganized ())
239 PCL_WARN(
"Scene not organized... filtering using computed depth buffer\n");
243 if (!occlusion_cloud_->isOrganized ())
248 for (std::size_t i = 0; i <
models.
size (); i++)
259 if(normals_set_ && requires_normals_) {
268 if (occlusion_cloud_->isOrganized ())
270 filtered = pcl::occlusion_reasoning::filter<ModelT,SceneT> (occlusion_cloud_,
const_filtered, 525.f, 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();
305 voxel_grid.setLeafSize (resolution_, resolution_, resolution_);
307 voxel_grid.filter (*scene_cloud_downsampled_);
311 scene_downsampled_tree_->setInputCloud(scene_cloud_downsampled_);
317 occlusion_cloud_set_ =
true;
Iterator class for point clouds with or without given indices.
std::size_t size() const
Size of the range the iterator is going through.
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_
shared_ptr< PointCloud< PointT > > Ptr
shared_ptr< const PointCloud< PointT > > ConstPtr
Class to reason about occlusions.
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
shared_ptr< KdTree< PointT, Tree > > Ptr
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.
Defines all the PCL and non-PCL macros used.