38 #ifndef PCL_SAMPLE_CONSENSUS_MODEL_CONE_H_
39 #define PCL_SAMPLE_CONSENSUS_MODEL_CONE_H_
43 #include <boost/thread/mutex.hpp>
65 template <
typename Po
intT,
typename Po
intNT>
80 typedef boost::shared_ptr<SampleConsensusModelCone>
Ptr;
86 SampleConsensusModel<
PointT> (cloud), axis_ (Eigen::Vector3f::Zero ()), eps_angle_ (0), min_angle_ (-std::numeric_limits<double>::max()), max_angle_ (std::numeric_limits<double>::max()),
97 axis_ (Eigen::Vector3f::Zero ()), eps_angle_ (0), min_angle_ (-std::numeric_limits<double>::max()), max_angle_ (std::numeric_limits<double>::max()),
118 axis_ = source.axis_;
119 eps_angle_ = source.eps_angle_;
120 min_angle_ = source.min_angle_;
121 max_angle_ = source.max_angle_;
122 tmp_inliers_ = source.tmp_inliers_;
140 setAxis (
const Eigen::Vector3f &ax) { axis_ = ax; }
143 inline Eigen::Vector3f
154 min_angle_ = min_angle;
155 max_angle_ = max_angle;
165 min_angle = min_angle_;
166 max_angle = max_angle_;
177 Eigen::VectorXf &model_coefficients);
185 std::vector<double> &distances);
194 const double threshold,
195 std::vector<int> &inliers);
205 const double threshold);
216 const Eigen::VectorXf &model_coefficients,
217 Eigen::VectorXf &optimized_coefficients);
228 const Eigen::VectorXf &model_coefficients,
230 bool copy_data_fields =
true);
239 const Eigen::VectorXf &model_coefficients,
240 const double threshold);
252 pointToAxisDistance (
const Eigen::Vector4f &pt,
const Eigen::VectorXf &model_coefficients);
256 getName ()
const {
return (
"SampleConsensusModelCone"); }
263 isModelValid (
const Eigen::VectorXf &model_coefficients);
270 isSampleGood (
const std::vector<int> &samples)
const;
274 Eigen::Vector3f axis_;
284 const std::vector<int> *tmp_inliers_;
286 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
287 #pragma GCC diagnostic ignored "-Weffc++"
298 pcl::Functor<float> (m_data_points), model_ (model) {}
306 operator() (
const Eigen::VectorXf &x, Eigen::VectorXf &fvec)
const
308 Eigen::Vector4f apex (x[0], x[1], x[2], 0);
309 Eigen::Vector4f axis_dir (x[3], x[4], x[5], 0);
310 float opening_angle = x[6];
312 float apexdotdir = apex.dot (axis_dir);
313 float dirdotdir = 1.0f / axis_dir.dot (axis_dir);
315 for (
int i = 0; i <
values (); ++i)
318 Eigen::Vector4f pt (model_->input_->points[(*model_->tmp_inliers_)[i]].x,
319 model_->input_->points[(*model_->tmp_inliers_)[i]].y,
320 model_->input_->points[(*model_->tmp_inliers_)[i]].z, 0);
323 float k = (pt.dot (axis_dir) - apexdotdir) * dirdotdir;
324 Eigen::Vector4f pt_proj = apex + k * axis_dir;
327 Eigen::Vector4f height = apex-pt_proj;
328 float actual_cone_radius = tanf (opening_angle) * height.norm ();
337 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
338 #pragma GCC diagnostic warning "-Weffc++"
343 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_CONE_H_