39 #ifndef PCL_RECOGNITION_MODEL_LIBRARY_H_
40 #define PCL_RECOGNITION_MODEL_LIBRARY_H_
42 #include "auxiliary.h"
43 #include <pcl/recognition/ransac_based/voxel_structure.h>
44 #include <pcl/recognition/ransac_based/orr_octree.h>
46 #include <pcl/pcl_exports.h>
47 #include <pcl/point_cloud.h>
70 float frac_of_points_for_registration,
void* user_data = NULL)
71 : obj_name_(object_name),
72 user_data_ (user_data)
74 octree_.build (points, voxel_size, &normals);
76 const std::vector<ORROctree::Node*>& full_leaves = octree_.getFullLeaves ();
77 if ( full_leaves.empty () )
81 std::vector<ORROctree::Node*>::const_iterator it = full_leaves.begin ();
82 const float *p = (*it)->getData ()->getPoint ();
84 bounds_of_octree_points_[0] = bounds_of_octree_points_[1] = p[0];
85 bounds_of_octree_points_[2] = bounds_of_octree_points_[3] = p[1];
86 bounds_of_octree_points_[4] = bounds_of_octree_points_[5] = p[2];
89 for ( ++it ; it != full_leaves.end () ; ++it )
91 aux::add3 (octree_center_of_mass_, (*it)->getData ()->getPoint ());
95 int num_octree_points =
static_cast<int> (full_leaves.size ());
97 aux::mult3 (octree_center_of_mass_, 1.0f/
static_cast<float> (num_octree_points));
99 int num_points_for_registration =
static_cast<int> (
static_cast<float> (num_octree_points)*frac_of_points_for_registration);
100 points_for_registration_.resize (
static_cast<size_t> (num_points_for_registration));
103 std::vector<int> ids (num_octree_points);
104 for (
int i = 0 ; i < num_octree_points ; ++i )
111 for (
int i = 0 ; i < num_points_for_registration ; ++i )
114 randgen.
setParameters (0,
static_cast<int> (ids.size ()) - 1);
115 int rand_pos = randgen.
run ();
118 aux::copy3 (octree_.getFullLeaves ()[ids[rand_pos]]->getData ()->getPoint (), points_for_registration_[i]);
121 ids.erase (ids.begin() + rand_pos);
129 inline const std::string&
150 return (octree_center_of_mass_);
156 return (bounds_of_octree_points_);
162 return (points_for_registration_);
168 float octree_center_of_mass_[3];
169 float bounds_of_octree_points_[6];
174 typedef std::list<std::pair<const ORROctree::Node::Data*, const ORROctree::Node::Data*> >
node_data_pair_list;
181 ModelLibrary (
float pair_width,
float voxel_size,
float max_coplanarity_angle = 3.0f*AUX_DEG_TO_RADIANS);
197 max_coplanarity_angle_ = max_coplanarity_angle_degrees*AUX_DEG_TO_RADIANS;
205 ignore_coplanar_opps_ =
true;
213 ignore_coplanar_opps_ =
false;
226 addModel (
const PointCloudIn& points,
const PointCloudN& normals,
const std::string& object_name,
227 float frac_of_points_for_registration,
void* user_data = NULL);
230 inline const HashTable&
233 return (hash_table_);
239 std::map<std::string,Model*>::const_iterator it = models_.find (name);
240 if ( it != models_.end () )
246 inline const std::map<std::string,Model*>&
269 int num_of_cells_[3];
274 #endif // PCL_RECOGNITION_MODEL_LIBRARY_H_