38 #ifndef PCL_REGISTRATION_CORRESPONDENCE_REJECTION_POLY_H_
39 #define PCL_REGISTRATION_CORRESPONDENCE_REJECTION_POLY_H_
41 #include <pcl/registration/correspondence_rejection.h>
42 #include <pcl/point_cloud.h>
46 namespace registration
63 template <
typename SourceT,
typename TargetT>
71 typedef boost::shared_ptr<CorrespondenceRejectorPoly>
Ptr;
72 typedef boost::shared_ptr<const CorrespondenceRejectorPoly>
ConstPtr;
86 , similarity_threshold_ (0.75f)
87 , similarity_threshold_squared_ (0.75f * 0.75f)
89 rejection_name_ =
"CorrespondenceRejectorPoly";
115 PCL_WARN (
"[pcl::registration::%s::setInputCloud] setInputCloud is deprecated. Please use setInputSource instead.\n",
116 getClassName ().c_str ());
135 cardinality_ = cardinality;
144 return (cardinality_);
154 similarity_threshold_ = similarity_threshold;
155 similarity_threshold_squared_ = similarity_threshold * similarity_threshold;
164 return (similarity_threshold_);
173 iterations_ = iterations;
182 return (iterations_);
193 if (cardinality_ == 2)
195 return (thresholdEdgeLength (corr[ idx[0] ].index_query, corr[ idx[1] ].index_query,
196 corr[ idx[0] ].index_match, corr[ idx[1] ].index_match,
201 for (
int i = 0; i < cardinality_; ++i)
202 if (!thresholdEdgeLength (corr[ idx[i] ].index_query, corr[ idx[(i+1)%cardinality_] ].index_query,
203 corr[ idx[i] ].index_match, corr[ idx[(i+1)%cardinality_] ].index_match,
204 similarity_threshold_squared_))
217 thresholdPolygon (
const std::vector<int>& source_indices,
const std::vector<int>& target_indices)
221 std::vector<int> idx (cardinality_);
222 for (
int i = 0; i < cardinality_; ++i)
224 corr[i].index_query = source_indices[i];
225 corr[i].index_match = target_indices[i];
229 return (thresholdPolygon (corr, idx));
239 getRemainingCorrespondences (*input_correspondences_, correspondences);
248 inline std::vector<int>
252 std::vector<bool> sampled (n,
false);
255 std::vector<int> result;
260 const int idx = (std::rand () % n);
268 result.push_back (idx);
284 const float dx = p2.x - p1.x;
285 const float dy = p2.y - p1.y;
286 const float dz = p2.z - p1.z;
288 return (dx*dx + dy*dy + dz*dz);
307 const float dist_src = computeSquaredDistance ((*input_)[index_query_1], (*input_)[index_query_2]);
309 const float dist_tgt = computeSquaredDistance ((*target_)[index_match_1], (*target_)[index_match_2]);
311 const float edge_sim = (dist_src < dist_tgt ? dist_src / dist_tgt : dist_tgt / dist_src);
313 return (edge_sim >= simsq);
325 computeHistogram (
const std::vector<float>& data,
float lower,
float upper,
int bins);
332 findThresholdOtsu (
const std::vector<int>& histogram);
355 #include <pcl/registration/impl/correspondence_rejection_poly.hpp>
357 #endif // PCL_REGISTRATION_CORRESPONDENCE_REJECTION_POLY_H_