38 #ifndef PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_PLANE_H_
39 #define PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_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::SampleConsensusModelNormalPlane::selectWithinDistance] No input dataset containing normals was given!\n");
56 if (!isModelValid (model_coefficients))
63 Eigen::Vector4f coeff = model_coefficients;
67 inliers.resize (indices_->size ());
69 for (
size_t i = 0; i < indices_->size (); ++i)
73 Eigen::Vector4f p (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
74 Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
75 double d_euclid = fabs (coeff.dot (p) + model_coefficients[3]);
78 double d_normal = fabs (
getAngle3D (n, coeff));
79 d_normal = (std::min) (d_normal, M_PI - d_normal);
81 if (fabs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid) < threshold)
84 inliers[nr_p] = (*indices_)[i];
88 inliers.resize (nr_p);
92 template <
typename Po
intT,
typename Po
intNT>
int
94 const Eigen::VectorXf &model_coefficients,
const double threshold)
98 PCL_ERROR (
"[pcl::SampleConsensusModelNormalPlane::countWithinDistance] No input dataset containing normals was given!\n");
103 if (!isModelValid (model_coefficients))
107 Eigen::Vector4f coeff = model_coefficients;
113 for (
size_t i = 0; i < indices_->size (); ++i)
117 Eigen::Vector4f p (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
118 Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
119 double d_euclid = fabs (coeff.dot (p) + model_coefficients[3]);
122 double d_normal = fabs (
getAngle3D (n, coeff));
123 d_normal = (std::min) (d_normal, M_PI - d_normal);
125 if (fabs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid) < threshold)
132 template <
typename Po
intT,
typename Po
intNT>
void
134 const Eigen::VectorXf &model_coefficients, std::vector<double> &distances)
138 PCL_ERROR (
"[pcl::SampleConsensusModelNormalPlane::getDistancesToModel] No input dataset containing normals was given!\n");
143 if (!isModelValid (model_coefficients))
150 Eigen::Vector4f coeff = model_coefficients;
153 distances.resize (indices_->size ());
156 for (
size_t i = 0; i < indices_->size (); ++i)
160 Eigen::Vector4f p (input_->points[(*indices_)[i]].x, input_->points[(*indices_)[i]].y, input_->points[(*indices_)[i]].z, 0);
161 Eigen::Vector4f n (normals_->points[(*indices_)[i]].normal[0], normals_->points[(*indices_)[i]].normal[1], normals_->points[(*indices_)[i]].normal[2], 0);
162 double d_euclid = fabs (coeff.dot (p) + model_coefficients[3]);
165 double d_normal = fabs (
getAngle3D (n, coeff));
166 d_normal = (std::min) (d_normal, M_PI - d_normal);
168 distances[i] = fabs (normal_distance_weight_ * d_normal + (1 - normal_distance_weight_) * d_euclid);
173 template <
typename Po
intT,
typename Po
intNT>
bool
177 if (model_coefficients.size () != 4)
179 PCL_ERROR (
"[pcl::SampleConsensusModelNormalPlane::selectWithinDistance] Invalid number of model coefficients given (%zu)!\n", model_coefficients.size ());
186 #define PCL_INSTANTIATE_SampleConsensusModelNormalPlane(PointT, PointNT) template class PCL_EXPORTS pcl::SampleConsensusModelNormalPlane<PointT, PointNT>;
188 #endif // PCL_SAMPLE_CONSENSUS_IMPL_SAC_MODEL_NORMAL_PLANE_H_