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>
69 float frac_of_points_for_registration,
void* user_data =
nullptr)
70 : obj_name_(object_name),
71 user_data_ (user_data)
73 octree_.build (points, voxel_size, &normals);
75 const std::vector<ORROctree::Node*>& full_leaves = octree_.getFullLeaves ();
76 if ( full_leaves.empty () )
80 std::vector<ORROctree::Node*>::const_iterator it = full_leaves.begin ();
81 const float *p = (*it)->getData ()->getPoint ();
83 bounds_of_octree_points_[0] = bounds_of_octree_points_[1] = p[0];
84 bounds_of_octree_points_[2] = bounds_of_octree_points_[3] = p[1];
85 bounds_of_octree_points_[4] = bounds_of_octree_points_[5] = p[2];
88 for ( ++it ; it != full_leaves.end () ; ++it )
90 aux::add3 (octree_center_of_mass_, (*it)->getData ()->getPoint ());
94 int num_octree_points = static_cast<int> (full_leaves.size ());
96 aux::mult3 (octree_center_of_mass_, 1.0f/static_cast<float> (num_octree_points));
98 int num_points_for_registration = static_cast<int> (static_cast<float> (num_octree_points)*frac_of_points_for_registration);
99 points_for_registration_.resize (static_cast<std::size_t> (num_points_for_registration));
102 std::vector<int> ids (num_octree_points);
103 for (
int i = 0 ; i < num_octree_points ; ++i )
110 for (
int i = 0 ; i < num_points_for_registration ; ++i )
113 randgen.
setParameters (0, static_cast<int> (ids.size ()) - 1);
114 int rand_pos = randgen.
run ();
117 aux::copy3 (octree_.getFullLeaves ()[ids[rand_pos]]->getData ()->getPoint (), points_for_registration_[i]);
120 ids.erase (ids.begin() + rand_pos);
128 inline const std::string&
149 return (octree_center_of_mass_);
155 return (bounds_of_octree_points_);
161 return (points_for_registration_);
167 float octree_center_of_mass_[3];
168 float bounds_of_octree_points_[6];
173 using node_data_pair_list = std::list<std::pair<const ORROctree::Node::Data*, const ORROctree::Node::Data*> >;
180 ModelLibrary (
float pair_width,
float voxel_size,
float max_coplanarity_angle = 3.0f*AUX_DEG_TO_RADIANS);
196 max_coplanarity_angle_ = max_coplanarity_angle_degrees*AUX_DEG_TO_RADIANS;
204 ignore_coplanar_opps_ =
true;
212 ignore_coplanar_opps_ =
false;
225 addModel (
const PointCloudIn& points,
const PointCloudN& normals,
const std::string& object_name,
226 float frac_of_points_for_registration,
void* user_data =
nullptr);
229 inline const HashTable&
232 return (hash_table_);
238 std::map<std::string,Model*>::const_iterator it = models_.find (name);
239 if ( it != models_.end () )
245 inline const std::map<std::string,Model*>&
268 int num_of_cells_[3];