Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef PCL_SAMPLE_CONSENSUS_MODEL_CIRCLE2D_H_
00042 #define PCL_SAMPLE_CONSENSUS_MODEL_CIRCLE2D_H_
00043
00044 #include <pcl/sample_consensus/sac_model.h>
00045 #include <pcl/sample_consensus/model_types.h>
00046
00047 namespace pcl
00048 {
00059 template <typename PointT>
00060 class SampleConsensusModelCircle2D : public SampleConsensusModel<PointT>
00061 {
00062 public:
00063 using SampleConsensusModel<PointT>::input_;
00064 using SampleConsensusModel<PointT>::indices_;
00065 using SampleConsensusModel<PointT>::radius_min_;
00066 using SampleConsensusModel<PointT>::radius_max_;
00067 using SampleConsensusModel<PointT>::error_sqr_dists_;
00068
00069 typedef typename SampleConsensusModel<PointT>::PointCloud PointCloud;
00070 typedef typename SampleConsensusModel<PointT>::PointCloudPtr PointCloudPtr;
00071 typedef typename SampleConsensusModel<PointT>::PointCloudConstPtr PointCloudConstPtr;
00072
00073 typedef boost::shared_ptr<SampleConsensusModelCircle2D> Ptr;
00074
00079 SampleConsensusModelCircle2D (const PointCloudConstPtr &cloud, bool random = false)
00080 : SampleConsensusModel<PointT> (cloud, random), tmp_inliers_ ()
00081 {};
00082
00088 SampleConsensusModelCircle2D (const PointCloudConstPtr &cloud,
00089 const std::vector<int> &indices,
00090 bool random = false)
00091 : SampleConsensusModel<PointT> (cloud, indices, random), tmp_inliers_ ()
00092 {};
00093
00097 SampleConsensusModelCircle2D (const SampleConsensusModelCircle2D &source) :
00098 SampleConsensusModel<PointT> (), tmp_inliers_ ()
00099 {
00100 *this = source;
00101 }
00102
00104 virtual ~SampleConsensusModelCircle2D () {}
00105
00109 inline SampleConsensusModelCircle2D&
00110 operator = (const SampleConsensusModelCircle2D &source)
00111 {
00112 SampleConsensusModel<PointT>::operator=(source);
00113 tmp_inliers_ = source.tmp_inliers_;
00114 return (*this);
00115 }
00116
00122 bool
00123 computeModelCoefficients (const std::vector<int> &samples,
00124 Eigen::VectorXf &model_coefficients);
00125
00130 void
00131 getDistancesToModel (const Eigen::VectorXf &model_coefficients,
00132 std::vector<double> &distances);
00133
00139 void
00140 selectWithinDistance (const Eigen::VectorXf &model_coefficients,
00141 const double threshold,
00142 std::vector<int> &inliers);
00143
00150 virtual int
00151 countWithinDistance (const Eigen::VectorXf &model_coefficients,
00152 const double threshold);
00153
00160 void
00161 optimizeModelCoefficients (const std::vector<int> &inliers,
00162 const Eigen::VectorXf &model_coefficients,
00163 Eigen::VectorXf &optimized_coefficients);
00164
00171 void
00172 projectPoints (const std::vector<int> &inliers,
00173 const Eigen::VectorXf &model_coefficients,
00174 PointCloud &projected_points,
00175 bool copy_data_fields = true);
00176
00182 bool
00183 doSamplesVerifyModel (const std::set<int> &indices,
00184 const Eigen::VectorXf &model_coefficients,
00185 const double threshold);
00186
00188 inline pcl::SacModel
00189 getModelType () const { return (SACMODEL_CIRCLE2D); }
00190
00191 protected:
00195 bool
00196 isModelValid (const Eigen::VectorXf &model_coefficients);
00197
00201 bool
00202 isSampleGood(const std::vector<int> &samples) const;
00203
00204 private:
00206 const std::vector<int> *tmp_inliers_;
00207
00208 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
00209 #pragma GCC diagnostic ignored "-Weffc++"
00210 #endif
00211
00212 struct OptimizationFunctor : pcl::Functor<float>
00213 {
00219 OptimizationFunctor (int m_data_points, pcl::SampleConsensusModelCircle2D<PointT> *model) :
00220 pcl::Functor<float>(m_data_points), model_ (model) {}
00221
00227 int
00228 operator() (const Eigen::VectorXf &x, Eigen::VectorXf &fvec) const
00229 {
00230 for (int i = 0; i < values (); ++i)
00231 {
00232
00233 float xt = model_->input_->points[(*model_->tmp_inliers_)[i]].x - x[0];
00234 float yt = model_->input_->points[(*model_->tmp_inliers_)[i]].y - x[1];
00235
00236
00237 fvec[i] = sqrtf (xt * xt + yt * yt) - x[2];
00238 }
00239 return (0);
00240 }
00241
00242 pcl::SampleConsensusModelCircle2D<PointT> *model_;
00243 };
00244 #if defined BUILD_Maintainer && defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ > 3
00245 #pragma GCC diagnostic warning "-Weffc++"
00246 #endif
00247 };
00248 }
00249
00250 #ifdef PCL_NO_PRECOMPILE
00251 #include <pcl/sample_consensus/impl/sac_model_circle.hpp>
00252 #endif
00253
00254 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_CIRCLE2D_H_