Point Cloud Library (PCL)
1.14.1-dev
|
This is a RANSAC-based 3D object recognition method. More...
#include <pcl/recognition/ransac_based/obj_rec_ransac.h>
Classes | |
class | HypothesisCreator |
class | OrientedPointPair |
class | Output |
This is an output item of the ObjRecRANSAC::recognize() method. More... | |
Public Types | |
using | PointCloudIn = ModelLibrary::PointCloudIn |
using | PointCloudN = ModelLibrary::PointCloudN |
using | BVHH = BVH< Hypothesis * > |
using | HypothesisOctree = SimpleOctree< Hypothesis, HypothesisCreator, float > |
Public Member Functions | |
ObjRecRANSAC (float pair_width, float voxel_size) | |
Constructor with some important parameters which can not be changed once an instance of that class is created. More... | |
virtual | ~ObjRecRANSAC () |
void | clear () |
Removes all models from the model library and releases some memory dynamically allocated by this instance. More... | |
void | setMaxCoplanarityAngleDegrees (float max_coplanarity_angle_degrees) |
This is a threshold. More... | |
void | setSceneBoundsEnlargementFactor (float value) |
void | ignoreCoplanarPointPairsOn () |
Default is on. More... | |
void | ignoreCoplanarPointPairsOff () |
Default is on. More... | |
void | icpHypothesesRefinementOn () |
void | icpHypothesesRefinementOff () |
bool | addModel (const PointCloudIn &points, const PointCloudN &normals, const std::string &object_name, void *user_data=nullptr) |
Add an object model to be recognized. More... | |
void | recognize (const PointCloudIn &scene, const PointCloudN &normals, std::list< ObjRecRANSAC::Output > &recognized_objects, double success_probability=0.99) |
This method performs the recognition of the models loaded to the model library with the method addModel(). More... | |
void | enterTestModeSampleOPP () |
void | enterTestModeTestHypotheses () |
void | leaveTestMode () |
const std::list< ObjRecRANSAC::OrientedPointPair > & | getSampledOrientedPointPairs () const |
This function is useful for testing purposes. More... | |
const std::vector< Hypothesis > & | getAcceptedHypotheses () const |
This function is useful for testing purposes. More... | |
void | getAcceptedHypotheses (std::vector< Hypothesis > &out) const |
This function is useful for testing purposes. More... | |
const pcl::recognition::ModelLibrary::HashTable & | getHashTable () const |
Returns the hash table in the model library. More... | |
const ModelLibrary & | getModelLibrary () const |
const ModelLibrary::Model * | getModel (const std::string &name) const |
const ORROctree & | getSceneOctree () const |
RigidTransformSpace & | getRigidTransformSpace () |
float | getPairWidth () const |
Protected Types | |
enum | Recognition_Mode { SAMPLE_OPP , TEST_HYPOTHESES , FULL_RECOGNITION } |
Protected Member Functions | |
int | computeNumberOfIterations (double success_probability) const |
void | clearTestData () |
void | sampleOrientedPointPairs (int num_iterations, const std::vector< ORROctree::Node * > &full_scene_leaves, std::list< OrientedPointPair > &output) const |
int | generateHypotheses (const std::list< OrientedPointPair > &pairs, std::list< HypothesisBase > &out) const |
int | groupHypotheses (std::list< HypothesisBase > &hypotheses, int num_hypotheses, RigidTransformSpace &transform_space, HypothesisOctree &grouped_hypotheses) const |
Groups close hypotheses in 'hypotheses'. More... | |
void | testHypothesis (Hypothesis *hypothesis, int &match, int &penalty) const |
void | testHypothesisNormalBased (Hypothesis *hypothesis, float &match) const |
void | buildGraphOfCloseHypotheses (HypothesisOctree &hypotheses, ORRGraph< Hypothesis > &graph) const |
void | filterGraphOfCloseHypotheses (ORRGraph< Hypothesis > &graph, std::vector< Hypothesis > &out) const |
void | buildGraphOfConflictingHypotheses (const BVHH &bvh, ORRGraph< Hypothesis * > &graph) const |
void | filterGraphOfConflictingHypotheses (ORRGraph< Hypothesis * > &graph, std::list< ObjRecRANSAC::Output > &recognized_objects) const |
void | computeRigidTransform (const float *a1, const float *a1_n, const float *b1, const float *b1_n, const float *a2, const float *a2_n, const float *b2, const float *b2_n, float *rigid_transform) const |
Computes the rigid transform that maps the line (a1, b1) to (a2, b2). More... | |
Static Protected Member Functions | |
static void | compute_oriented_point_pair_signature (const float *p1, const float *n1, const float *p2, const float *n2, float signature[3]) |
Computes the signature of the oriented point pair ((p1, n1), (p2, n2)) consisting of the angles between. More... | |
Protected Attributes | |
float | pair_width_ |
float | voxel_size_ |
float | position_discretization_ |
float | rotation_discretization_ |
float | abs_zdist_thresh_ |
float | relative_obj_size_ {0.05f} |
float | visibility_ {0.2f} |
float | relative_num_of_illegal_pts_ {0.02f} |
float | intersection_fraction_ {0.03f} |
float | max_coplanarity_angle_ |
float | scene_bounds_enlargement_factor_ {0.25f} |
bool | ignore_coplanar_opps_ {true} |
float | frac_of_points_for_icp_refinement_ {0.3f} |
bool | do_icp_hypotheses_refinement_ {true} |
ModelLibrary | model_library_ |
ORROctree | scene_octree_ |
ORROctreeZProjection | scene_octree_proj_ |
RigidTransformSpace | transform_space_ |
TrimmedICP< pcl::PointXYZ, float > | trimmed_icp_ |
PointCloudIn::Ptr | scene_octree_points_ |
std::list< OrientedPointPair > | sampled_oriented_point_pairs_ |
std::vector< Hypothesis > | accepted_hypotheses_ |
Recognition_Mode | rec_mode_ {ObjRecRANSAC::FULL_RECOGNITION} |
Friends | |
class | ModelLibrary |
This is a RANSAC-based 3D object recognition method.
Do the following to use it: (i) call addModel() k times with k different models representing the objects to be recognized and (ii) call recognize() with the 3D scene in which the objects should be recognized. Recognition means both object identification and pose (position + orientation) estimation. Check the method descriptions for more details.
Definition at line 83 of file obj_rec_ransac.h.
using pcl::recognition::ObjRecRANSAC::BVHH = BVH<Hypothesis *> |
Definition at line 89 of file obj_rec_ransac.h.
using pcl::recognition::ObjRecRANSAC::HypothesisOctree = SimpleOctree<Hypothesis, HypothesisCreator, float> |
Definition at line 139 of file obj_rec_ransac.h.
Definition at line 86 of file obj_rec_ransac.h.
Definition at line 87 of file obj_rec_ransac.h.
|
protected |
Enumerator | |
---|---|
SAMPLE_OPP | |
TEST_HYPOTHESES | |
FULL_RECOGNITION |
Definition at line 323 of file obj_rec_ransac.h.
pcl::recognition::ObjRecRANSAC::ObjRecRANSAC | ( | float | pair_width, |
float | voxel_size | ||
) |
Constructor with some important parameters which can not be changed once an instance of that class is created.
[in] | pair_width | should be roughly half the extent of the visible object part. This means, for each object point p there should be (at least) one point q (from the same object) such that ||p - q|| <= pair_width. Tradeoff: smaller values allow for detection in more occluded scenes but lead to more imprecise alignment. Bigger values lead to better alignment but require large visible object parts (i.e., less occlusion). |
[in] | voxel_size | is the size of the leafs of the octree, i.e., the "size" of the discretization. Tradeoff: High values lead to less computation time but ignore object details. Small values allow to better distinguish between objects, but will introduce more holes in the resulting "voxel-surface" (especially for a sparsely sampled scene). |
|
inlinevirtual |
Definition at line 152 of file obj_rec_ransac.h.
|
inline |
Add an object model to be recognized.
[in] | points | are the object points. |
[in] | normals | at each point. |
[in] | object_name | is an identifier for the object. If that object is detected in the scene 'object_name' is returned by the recognition method and you know which object has been detected. Note that 'object_name' has to be unique! |
[in] | user_data | is a pointer to some data (can be NULL) |
The method returns true if the model was successfully added to the model library and false otherwise (e.g., if 'object_name' is already in use).
Definition at line 227 of file obj_rec_ransac.h.
|
protected |
|
protected |
|
inline |
Removes all models from the model library and releases some memory dynamically allocated by this instance.
Definition at line 160 of file obj_rec_ransac.h.
|
inlineprotected |
Definition at line 343 of file obj_rec_ransac.h.
|
inlinestaticprotected |
Computes the signature of the oriented point pair ((p1, n1), (p2, n2)) consisting of the angles between.
p1 | ||
n1 | ||
p2 | ||
n2 | ||
[out] | signature | is an array of three doubles saving the three angles in the order shown above. |
Definition at line 439 of file obj_rec_ransac.h.
References pcl::recognition::aux::clamp(), pcl::recognition::aux::dot3(), and pcl::recognition::aux::normalize3().
|
inlineprotected |
Definition at line 328 of file obj_rec_ransac.h.
|
inlineprotected |
Computes the rigid transform that maps the line (a1, b1) to (a2, b2).
The computation is based on the corresponding points 'a1' <-> 'a2' and 'b1' <-> 'b2' and the normals 'a1_n', 'b1_n', 'a2_n', and 'b2_n'. The result is saved in 'rigid_transform' which is an array of length 12. The first 9 elements are the rotational part (row major order) and the last 3 are the translation.
Definition at line 386 of file obj_rec_ransac.h.
References pcl::recognition::aux::cross3(), pcl::recognition::aux::diff3(), pcl::recognition::aux::mult3x3(), pcl::recognition::aux::normalize3(), pcl::recognition::aux::projectOnPlane3(), and pcl::recognition::aux::sum3().
|
inline |
Definition at line 244 of file obj_rec_ransac.h.
References SAMPLE_OPP.
|
inline |
Definition at line 250 of file obj_rec_ransac.h.
References TEST_HYPOTHESES.
|
protected |
|
protected |
|
protected |
|
inline |
This function is useful for testing purposes.
It returns the accepted hypotheses generated during the recognition process. Makes sense only if some of the testing modes are active.
Definition at line 272 of file obj_rec_ransac.h.
|
inline |
This function is useful for testing purposes.
It returns the accepted hypotheses generated during the recognition process. Makes sense only if some of the testing modes are active.
Definition at line 280 of file obj_rec_ransac.h.
|
inline |
Returns the hash table in the model library.
Definition at line 287 of file obj_rec_ransac.h.
|
inline |
Definition at line 299 of file obj_rec_ransac.h.
|
inline |
Definition at line 293 of file obj_rec_ransac.h.
|
inline |
Definition at line 317 of file obj_rec_ransac.h.
|
inline |
Definition at line 311 of file obj_rec_ransac.h.
|
inline |
This function is useful for testing purposes.
It returns the oriented point pairs which were sampled from the scene during the recognition process. Makes sense only if some of the testing modes are active.
Definition at line 264 of file obj_rec_ransac.h.
|
inline |
Definition at line 305 of file obj_rec_ransac.h.
|
protected |
Groups close hypotheses in 'hypotheses'.
Saves a representative for each group in 'out'. Returns the number of hypotheses after grouping.
|
inline |
Definition at line 210 of file obj_rec_ransac.h.
|
inline |
Definition at line 204 of file obj_rec_ransac.h.
|
inline |
Default is on.
This method calls the corresponding method of the model library.
Definition at line 197 of file obj_rec_ransac.h.
|
inline |
Default is on.
This method calls the corresponding method of the model library.
Definition at line 189 of file obj_rec_ransac.h.
|
inline |
Definition at line 256 of file obj_rec_ransac.h.
References FULL_RECOGNITION.
void pcl::recognition::ObjRecRANSAC::recognize | ( | const PointCloudIn & | scene, |
const PointCloudN & | normals, | ||
std::list< ObjRecRANSAC::Output > & | recognized_objects, | ||
double | success_probability = 0.99 |
||
) |
This method performs the recognition of the models loaded to the model library with the method addModel().
[in] | scene | is the 3d scene in which the object should be recognized. |
[in] | normals | are the scene normals. |
[out] | recognized_objects | is the list of output items each one containing the recognized model instance, its name, the aligning rigid transform and the match confidence (see ObjRecRANSAC::Output for further explanations). |
[in] | success_probability | is the user-defined probability of detecting all objects in the scene. |
|
protected |
|
inline |
This is a threshold.
The larger the value the more point pairs will be considered as co-planar and will be ignored in the off-line model pre-processing and in the online recognition phases. This makes sense only if "ignore co-planar points" is on. Call this method before calling addModel. This method calls the corresponding method of the model library.
Definition at line 175 of file obj_rec_ransac.h.
|
inline |
Definition at line 182 of file obj_rec_ransac.h.
|
inlineprotected |
|
inlineprotected |
|
friend |
Definition at line 325 of file obj_rec_ransac.h.
|
protected |
Definition at line 456 of file obj_rec_ransac.h.
|
protected |
Definition at line 475 of file obj_rec_ransac.h.
|
protected |
Definition at line 465 of file obj_rec_ransac.h.
|
protected |
Definition at line 464 of file obj_rec_ransac.h.
|
protected |
Definition at line 463 of file obj_rec_ransac.h.
|
protected |
Definition at line 460 of file obj_rec_ransac.h.
|
protected |
Definition at line 461 of file obj_rec_ransac.h.
|
protected |
Definition at line 467 of file obj_rec_ransac.h.
|
protected |
Definition at line 452 of file obj_rec_ransac.h.
|
protected |
Definition at line 454 of file obj_rec_ransac.h.
|
protected |
Definition at line 476 of file obj_rec_ransac.h.
|
protected |
Definition at line 459 of file obj_rec_ransac.h.
|
protected |
Definition at line 457 of file obj_rec_ransac.h.
|
protected |
Definition at line 455 of file obj_rec_ransac.h.
|
protected |
Definition at line 474 of file obj_rec_ransac.h.
|
protected |
Definition at line 462 of file obj_rec_ransac.h.
|
protected |
Definition at line 468 of file obj_rec_ransac.h.
|
protected |
Definition at line 472 of file obj_rec_ransac.h.
|
protected |
Definition at line 469 of file obj_rec_ransac.h.
|
protected |
Definition at line 470 of file obj_rec_ransac.h.
|
protected |
Definition at line 471 of file obj_rec_ransac.h.
|
protected |
Definition at line 458 of file obj_rec_ransac.h.
|
protected |
Definition at line 453 of file obj_rec_ransac.h.