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_FILTERS_IMPL_NORMAL_REFINEMENT_H_
00042 #define PCL_FILTERS_IMPL_NORMAL_REFINEMENT_H_
00043
00044 #include <pcl/filters/normal_refinement.h>
00045
00047 template <typename NormalT> void
00048 pcl::NormalRefinement<NormalT>::applyFilter (PointCloud &output)
00049 {
00050
00051 if (input_->empty ())
00052 {
00053 PCL_ERROR ("[pcl::%s::applyFilter] No source was input!\n",
00054 getClassName ().c_str ());
00055 }
00056
00057
00058 output = *input_;
00059
00060
00061 if (k_indices_.empty () || k_sqr_distances_.empty ())
00062 {
00063 PCL_ERROR ("[pcl::%s::applyFilter] No point correspondences given! Returning original input.\n",
00064 getClassName ().c_str ());
00065 return;
00066 }
00067
00068
00069 const unsigned int size = k_indices_.size ();
00070 if (k_sqr_distances_.size () != size || input_->size () != size)
00071 {
00072 PCL_ERROR ("[pcl::%s::applyFilter] Inconsistency between size of correspondence indices/distances or input! Returning original input.\n",
00073 getClassName ().c_str ());
00074 return;
00075 }
00076
00077
00078 for (unsigned int i = 0; i < max_iterations_; ++i)
00079 {
00080
00081 PointCloud tmp = output;
00082
00083
00084 float ddot = 0.0f;
00085
00086
00087 int num_valids = 0;
00088 for(unsigned int j = 0; j < size; ++j)
00089 {
00090
00091 NormalT& tmpj = tmp[j];
00092
00093
00094 if (refineNormal (output, j, k_indices_[j], k_sqr_distances_[j], tmpj))
00095 {
00096
00097 const NormalT& outputj = output[j];
00098 ddot += tmpj.normal_x * outputj.normal_x + tmpj.normal_y * outputj.normal_y + tmpj.normal_z * outputj.normal_z;
00099 ++num_valids;
00100 }
00101 }
00102
00103
00104 ddot /= static_cast<float> (num_valids);
00105
00106
00107 ddot = 1.0f - ddot;
00108
00109
00110 output = tmp;
00111
00112
00113 if (ddot < convergence_threshold_)
00114 {
00115 PCL_DEBUG("[pcl::%s::applyFilter] Converged after %i iterations with mean error of %f.\n",
00116 getClassName ().c_str (), i+1, ddot);
00117 break;
00118 }
00119 }
00120 }
00121
00122 #endif