37 #ifndef PCL_RECOGNITION_HYPOTHESIS_VERIFICATION_H_ 38 #define PCL_RECOGNITION_HYPOTHESIS_VERIFICATION_H_ 40 #include <pcl/pcl_macros.h> 41 #include "pcl/recognition/hv/occlusion_reasoning.h" 42 #include "pcl/recognition/impl/hv/occlusion_reasoning.hpp" 44 #include <pcl/search/kdtree.h> 45 #include <pcl/filters/voxel_grid.h> 55 template<
typename ModelT,
typename SceneT>
136 zbuffer_scene_resolution_ = 100;
137 zbuffer_self_occlusion_resolution_ = 150;
138 resolution_ = 0.005f;
139 inliers_threshold_ = static_cast<float>(resolution_);
140 occlusion_cloud_set_ =
false;
141 occlusion_thres_ = 0.005f;
142 normals_set_ =
false;
143 requires_normals_ =
false;
147 return requires_normals_;
165 occlusion_thres_ = t;
174 inliers_threshold_ = r;
197 complete_models_ = complete_models;
208 complete_normal_models_ = complete_models;
221 if(!occlusion_cloud_set_) {
222 PCL_WARN(
"Occlusion cloud not set, using scene_cloud instead...\n");
223 occlusion_cloud_ = scene_cloud_;
226 if (!occlusion_reasoning)
227 visible_models_ = models;
231 if (scene_cloud_ == 0)
233 PCL_ERROR(
"setSceneCloud should be called before adding the model if reasoning about occlusions...");
238 PCL_WARN(
"Scene not organized... filtering using computed depth buffer\n");
247 for (
size_t i = 0; i < models.size (); i++)
254 std::vector<int> indices;
255 zbuffer_self_occlusion.
filter (models[i], indices, 0.005f);
258 if(normals_set_ && requires_normals_) {
261 visible_normal_models_.push_back(filtered_normals);
269 filtered = pcl::occlusion_reasoning::filter<ModelT,SceneT> (occlusion_cloud_, const_filtered, 525.f, occlusion_thres_);
273 zbuffer_scene.
filter (const_filtered, filtered, occlusion_thres_);
276 visible_models_.push_back (filtered);
279 complete_models_ = models;
282 occlusion_cloud_set_ =
false;
283 normals_set_ =
false;
295 complete_models_.clear();
296 visible_models_.clear();
297 visible_normal_models_.clear();
299 scene_cloud_ = scene_cloud;
304 voxel_grid.
setLeafSize (resolution_, resolution_, resolution_);
306 voxel_grid.
filter (*scene_cloud_downsampled_);
310 scene_downsampled_tree_->
setInputCloud(scene_cloud_downsampled_);
315 occlusion_cloud_ = occ_cloud;
316 occlusion_cloud_set_ =
true;
pcl::PointCloud< SceneT >::Ptr scene_cloud_downsampled_
int zbuffer_scene_resolution_
int zbuffer_self_occlusion_resolution_
std::vector< typename pcl::PointCloud< pcl::Normal >::ConstPtr > complete_normal_models_
void addNormalsClouds(std::vector< pcl::PointCloud< pcl::Normal >::ConstPtr > &complete_models)
std::vector< typename pcl::PointCloud< ModelT >::ConstPtr > visible_models_
Class to reason about occlusions.
void setDownsampleAllData(bool downsample)
Set to true if all fields need to be downsampled, or false if just XYZ.
PCL_EXPORTS void copyPointCloud(const pcl::PCLPointCloud2 &cloud_in, const std::vector< int > &indices, pcl::PCLPointCloud2 &cloud_out)
Extract the indices of a given point cloud as a new point cloud.
void setOcclusionThreshold(float t)
void filter(PointCloud &output)
Calls the filtering method and returns the filtered dataset in output.
VoxelGrid assembles a local 3D grid over a given PointCloud, and downsamples + filters the data.
std::vector< typename pcl::PointCloud< pcl::Normal >::ConstPtr > visible_normal_models_
void computeDepthMap(typename pcl::PointCloud< SceneT >::ConstPtr &scene, bool compute_focal=false, bool smooth=false, int wsize=3)
void setResolution(float r)
void setInlierThreshold(float r)
bool isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
void filter(typename pcl::PointCloud< ModelT >::ConstPtr &model, typename pcl::PointCloud< ModelT >::Ptr &filtered, float thres=0.01)
boost::shared_ptr< PointCloud< PointT > > Ptr
Define standard C methods and C++ classes that are common to all methods.
std::vector< bool > mask_
boost::shared_ptr< KdTree< PointT, Tree > > Ptr
std::vector< typename pcl::PointCloud< ModelT >::ConstPtr > complete_models_
void setSceneCloud(const typename pcl::PointCloud< SceneT >::Ptr &scene_cloud)
Abstract class for hypotheses verification methods.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
pcl::PointCloud< SceneT >::ConstPtr occlusion_cloud_
pcl::PointCloud< SceneT >::ConstPtr scene_cloud_
bool getRequiresNormals()
bool occlusion_cloud_set_
void setInputCloud(const PointCloudConstPtr &cloud, const IndicesConstPtr &indices=IndicesConstPtr())
Provide a pointer to the input dataset.
void getMask(std::vector< bool > &mask)
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
void addCompleteModels(std::vector< typename pcl::PointCloud< ModelT >::ConstPtr > &complete_models)
void addModels(std::vector< typename pcl::PointCloud< ModelT >::ConstPtr > &models, bool occlusion_reasoning=false)
void setOcclusionCloud(const typename pcl::PointCloud< SceneT >::Ptr &occ_cloud)
pcl::search::KdTree< SceneT >::Ptr scene_downsampled_tree_
void setLeafSize(const Eigen::Vector4f &leaf_size)
Set the voxel grid leaf size.