38 #ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_PARALLEL_PLANE_H_
39 #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_PARALLEL_PLANE_H_
44 template <
typename Po
intT,
typename Po
intNT>
void
46 const Eigen::VectorXf &model_coefficients,
const double threshold, std::vector<int> &inliers)
50 PCL_ERROR (
"[pcl::SampleConsensusModelNormalParallelPlane::selectWithinDistance] No input dataset containing normals was given!\n");
55 if (!isModelValid (model_coefficients))
62 Eigen::Vector4f coeff = model_coefficients;
65 inliers.resize (indices_->size ());
67 for (
size_t i = 0; i < indices_->size (); ++i)
71 Eigen::Vector4f p (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 1);
72 Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
73 double d_euclid = fabs (coeff.dot (p));
77 d_normal = (std::min) (d_normal, fabs(M_PI - d_normal));
79 if (fabs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid) < threshold)
82 inliers[nr_p] = (*indices_)[i];
86 inliers.resize (nr_p);
90 template <
typename Po
intT,
typename Po
intNT>
int
92 const Eigen::VectorXf &model_coefficients,
const double threshold)
96 PCL_ERROR (
"[pcl::SampleConsensusModelNormalParallelPlane::countWithinDistance] No input dataset containing normals was given!\n");
101 if (!isModelValid (model_coefficients))
105 Eigen::Vector4f coeff = model_coefficients;
110 for (
size_t i = 0; i < indices_->size (); ++i)
114 Eigen::Vector4f p (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 1);
115 Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
116 double d_euclid = fabs (coeff.dot (p));
119 double d_normal = fabs (
getAngle3D (n, coeff));
120 d_normal = (std::min) (d_normal, fabs(M_PI - d_normal));
122 if (fabs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid) < threshold)
130 template <
typename Po
intT,
typename Po
intNT>
void
132 const Eigen::VectorXf &model_coefficients, std::vector<double> &distances)
136 PCL_ERROR (
"[pcl::SampleConsensusModelNormalParallelPlane::getDistancesToModel] No input dataset containing normals was given!\n");
141 if (!isModelValid (model_coefficients))
148 Eigen::Vector4f coeff = model_coefficients;
150 distances.resize (indices_->size ());
153 for (
size_t i = 0; i < indices_->size (); ++i)
157 Eigen::Vector4f p (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 1);
158 Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
159 double d_euclid = fabs (coeff.dot (p));
163 d_normal = (std::min) (d_normal, fabs (M_PI - d_normal));
165 distances[i] = fabs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid);
170 template <
typename Po
intT,
typename Po
intNT>
bool
174 if (model_coefficients.size () != 4)
176 PCL_ERROR (
"[pcl::SampleConsensusModelNormalParallelPlane::isModelValid] Invalid number of model coefficients given (%zu)!\n", model_coefficients.size ());
181 if (eps_angle_ > 0.0)
184 Eigen::Vector4f coeff = model_coefficients;
188 if (fabs (axis_.dot (coeff)) < cos_angle_)
194 if (fabs (-model_coefficients[3] - distance_from_origin_) > eps_dist_)
201 #define PCL_INSTANTIATE_SampleConsensusModelNormalParallelPlane(PointT, PointNT) template class PCL_EXPORTS pcl::SampleConsensusModelNormalParallelPlane<PointT, PointNT>;
203 #endif // PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_PARALLEL_PLANE_H_