41 #include "auxiliary.h"
42 #include <pcl/recognition/ransac_based/voxel_structure.h>
43 #include <pcl/recognition/ransac_based/orr_octree.h>
45 #include <pcl/pcl_exports.h>
46 #include <pcl/point_cloud.h>
68 float frac_of_points_for_registration,
void* user_data =
nullptr)
69 : obj_name_(object_name),
70 user_data_ (user_data)
72 octree_.build (points, voxel_size, &normals);
74 const std::vector<ORROctree::Node*>& full_leaves = octree_.getFullLeaves ();
75 if ( full_leaves.empty () )
79 std::vector<ORROctree::Node*>::const_iterator it = full_leaves.begin ();
80 const float *p = (*it)->getData ()->getPoint ();
82 bounds_of_octree_points_[0] = bounds_of_octree_points_[1] = p[0];
83 bounds_of_octree_points_[2] = bounds_of_octree_points_[3] = p[1];
84 bounds_of_octree_points_[4] = bounds_of_octree_points_[5] = p[2];
87 for ( ++it ; it != full_leaves.end () ; ++it )
89 aux::add3 (octree_center_of_mass_, (*it)->getData ()->getPoint ());
93 int num_octree_points =
static_cast<int> (full_leaves.size ());
95 aux::mult3 (octree_center_of_mass_, 1.0f/
static_cast<float> (num_octree_points));
97 int num_points_for_registration =
static_cast<int> (
static_cast<float> (num_octree_points)*frac_of_points_for_registration);
98 points_for_registration_.resize (
static_cast<std::size_t
> (num_points_for_registration));
101 std::vector<int> ids (num_octree_points);
102 for (
int i = 0 ; i < num_octree_points ; ++i )
109 for (
int i = 0 ; i < num_points_for_registration ; ++i )
112 randgen.
setParameters (0,
static_cast<int> (ids.size ()) - 1);
113 int rand_pos = randgen.
run ();
116 aux::copy3 (octree_.getFullLeaves ()[ids[rand_pos]]->getData ()->getPoint (), points_for_registration_[i]);
119 ids.erase (ids.begin() + rand_pos);
127 inline const std::string&
148 return (octree_center_of_mass_);
154 return (bounds_of_octree_points_);
160 return (points_for_registration_);
166 float octree_center_of_mass_[3];
167 float bounds_of_octree_points_[6];
172 using node_data_pair_list = std::list<std::pair<const ORROctree::Node::Data*, const ORROctree::Node::Data*> >;
179 ModelLibrary (
float pair_width,
float voxel_size,
float max_coplanarity_angle = 3.0f*AUX_DEG_TO_RADIANS);
195 max_coplanarity_angle_ = max_coplanarity_angle_degrees*AUX_DEG_TO_RADIANS;
203 ignore_coplanar_opps_ =
true;
211 ignore_coplanar_opps_ =
false;
224 addModel (
const PointCloudIn& points,
const PointCloudN& normals,
const std::string& object_name,
225 float frac_of_points_for_registration,
void* user_data =
nullptr);
228 inline const HashTable&
231 return (hash_table_);
237 std::map<std::string,Model*>::const_iterator it = models_.find (name);
238 if ( it != models_.end () )
244 inline const std::map<std::string,Model*>&
267 int num_of_cells_[3];