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 #ifndef PCL_SAMPLE_CONSENSUS_MODEL_LINE_H_
00039 #define PCL_SAMPLE_CONSENSUS_MODEL_LINE_H_
00040
00041 #include <pcl/sample_consensus/sac_model.h>
00042 #include <pcl/sample_consensus/model_types.h>
00043 #include <pcl/common/eigen.h>
00044 #include <pcl/features/feature.h>
00045
00046 namespace pcl
00047 {
00049
00052 template <typename PointT>
00053 class SampleConsensusModelLine : public SampleConsensusModel<PointT>
00054 {
00055 using SampleConsensusModel<PointT>::input_;
00056 using SampleConsensusModel<PointT>::indices_;
00057
00058 public:
00059 typedef typename SampleConsensusModel<PointT>::PointCloud PointCloud;
00060 typedef typename SampleConsensusModel<PointT>::PointCloudPtr PointCloudPtr;
00061 typedef typename SampleConsensusModel<PointT>::PointCloudConstPtr PointCloudConstPtr;
00062
00063 typedef boost::shared_ptr<SampleConsensusModelLine> Ptr;
00064
00068 SampleConsensusModelLine (const PointCloudConstPtr &cloud) : SampleConsensusModel<PointT> (cloud) {};
00069
00074 SampleConsensusModelLine (const PointCloudConstPtr &cloud, const std::vector<int> &indices) : SampleConsensusModel<PointT> (cloud, indices) {};
00075
00081 void getSamples (int &iterations, std::vector<int> &samples);
00082
00089 bool computeModelCoefficients (const std::vector<int> &samples, Eigen::VectorXf &model_coefficients);
00090
00095 void getDistancesToModel (const Eigen::VectorXf &model_coefficients, std::vector<double> &distances);
00096
00102 void selectWithinDistance (const Eigen::VectorXf &model_coefficients, double threshold, std::vector<int> &inliers);
00103
00110 void optimizeModelCoefficients (const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, Eigen::VectorXf &optimized_coefficients);
00111
00118 void projectPoints (const std::vector<int> &inliers, const Eigen::VectorXf &model_coefficients, PointCloud &projected_points, bool copy_data_fields = true);
00119
00125 bool doSamplesVerifyModel (const std::set<int> &indices, const Eigen::VectorXf &model_coefficients, double threshold);
00126
00128 inline pcl::SacModel getModelType () const { return (SACMODEL_LINE); }
00129
00130 protected:
00134 inline bool
00135 isModelValid (const Eigen::VectorXf &model_coefficients)
00136 {
00137 return (true);
00138 }
00139
00140 private:
00142 const static int MAX_ITERATIONS_UNIQUE = 1000;
00143 };
00144 }
00145
00146 #endif //#ifndef PCL_SAMPLE_CONSENSUS_MODEL_LINE_H_