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)
72 octree_.build (points, voxel_size, &normals);
74 const std::vector<ORROctree::Node*>& full_leaves =
octree_.getFullLeaves ();
75 if ( full_leaves.empty () )
79 auto it = full_leaves.begin ();
80 const float *p = (*it)->getData ()->getPoint ();
87 for ( ++it ; it != full_leaves.end () ; ++it )
93 int num_octree_points =
static_cast<int> (full_leaves.size ());
97 int num_points_for_registration =
static_cast<int> (
static_cast<float> (num_octree_points)*frac_of_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 ();
119 ids.erase (ids.begin() + rand_pos);
125 inline const std::string&
170 using node_data_pair_list = std::list<std::pair<const ORROctree::Node::Data*, const ORROctree::Node::Data*> >;
177 ModelLibrary (
float pair_width,
float voxel_size,
float max_coplanarity_angle = 3.0f*AUX_DEG_TO_RADIANS);
223 float frac_of_points_for_registration,
void* user_data =
nullptr);
242 inline const std::map<std::string,Model*>&
PointCloud represents the base class in PCL for storing collections of 3D points.
Stores some information about the model.
float bounds_of_octree_points_[6]
const PointCloudIn & getPointsForRegistration() const
void * getUserData() const
const std::string & getObjectName() const
const std::string obj_name_
const float * getBoundsOfOctreePoints() const
float octree_center_of_mass_[3]
Model(const PointCloudIn &points, const PointCloudN &normals, float voxel_size, const std::string &object_name, float frac_of_points_for_registration, void *user_data=nullptr)
const float * getOctreeCenterOfMass() const
PointCloudIn points_for_registration_
const ORROctree & getOctree() const
const std::map< std::string, Model * > & getModels() const
pcl::PointCloud< pcl::Normal > PointCloudN
float max_coplanarity_angle_
pcl::PointCloud< pcl::PointXYZ > PointCloudIn
void clear()
Removes all models from the library and destroys the hash table.
bool ignore_coplanar_opps_
void removeAllModels()
Removes all models from the library and clears the hash table.
bool addModel(const PointCloudIn &points, const PointCloudN &normals, const std::string &object_name, float frac_of_points_for_registration, void *user_data=nullptr)
Adds a model to the hash table.
ModelLibrary(float pair_width, float voxel_size, float max_coplanarity_angle=3.0f *AUX_DEG_TO_RADIANS)
This class is used by 'ObjRecRANSAC' to maintain the object models to be recognized.
void setMaxCoplanarityAngleDegrees(float max_coplanarity_angle_degrees)
This is a threshold.
const Model * getModel(const std::string &name) const
void ignoreCoplanarPointPairsOff()
Call this method in order to add all point pairs (co-planar as well) to the hash table.
bool addToHashTable(Model *model, const ORROctree::Node::Data *data1, const ORROctree::Node::Data *data2)
Returns true if the oriented point pair was added to the hash table and false otherwise.
std::map< const Model *, node_data_pair_list > HashTableCell
std::list< std::pair< const ORROctree::Node::Data *, const ORROctree::Node::Data * > > node_data_pair_list
VoxelStructure< HashTableCell, float > HashTable
void ignoreCoplanarPointPairsOn()
Call this method in order NOT to add co-planar point pairs to the hash table.
std::map< std::string, Model * > models_
const HashTable & getHashTable() const
Returns the hash table built by this instance.
That's a very specialized and simple octree class.
This class is a box in R3 built of voxels ordered in a regular rectangular grid.
Defines all the PCL implemented PointT point type structures.
void expandBoundingBoxToContainPoint(T bbox[6], const T p[3])
Expands the bounding box 'bbox' such that it contains the point 'p'.
void mult3(T *v, T scalar)
v = scalar*v.
void add3(T a[3], const T b[3])
a += b
void copy3(const T src[3], T dst[3])
dst = src
CloudGenerator class generates a point cloud using some random number generator.