approx_nearest_pair_point_cloud_coherence.hpp
Go to the documentation of this file.
00001 #ifndef PCL_TRACKING_IMPL_APPROX_NEAREST_PAIR_POINT_CLOUD_COHERENCE_H_
00002 #define PCL_TRACKING_IMPL_APPROX_NEAREST_PAIR_POINT_CLOUD_COHERENCE_H_
00003 
00004 #include <pcl/search/octree.h>
00005 
00006 namespace pcl
00007 {
00008   namespace tracking
00009   {
00010     template <typename PointInT> void
00011     ApproxNearestPairPointCloudCoherence<PointInT>::computeCoherence (
00012         const PointCloudInConstPtr &cloud, const IndicesConstPtr &, float &w)
00013     {
00014       double val = 0.0;
00015       //for (size_t i = 0; i < indices->size (); i++)
00016       for (size_t i = 0; i < cloud->points.size (); i++)
00017       {
00018         int k_index = 0;
00019         float k_distance = 0.0;
00020         //PointInT input_point = cloud->points[(*indices)[i]];
00021         PointInT input_point = cloud->points[i];
00022         search_->approxNearestSearch(input_point, k_index, k_distance);
00023         if (k_distance < maximum_distance_ * maximum_distance_)
00024         {
00025           PointInT target_point = target_input_->points[k_index];
00026           double coherence_val = 1.0;
00027           for (size_t i = 0; i < point_coherences_.size (); i++)
00028           {
00029             PointCoherencePtr coherence = point_coherences_[i];  
00030             double w = coherence->compute (input_point, target_point);
00031             coherence_val *= w;
00032           }
00033           val += coherence_val;
00034         }
00035       }
00036       w = - static_cast<float> (val);
00037     }
00038 
00039     template <typename PointInT> bool
00040     ApproxNearestPairPointCloudCoherence<PointInT>::initCompute ()
00041     {
00042       if (!PointCloudCoherence<PointInT>::initCompute ())
00043       {
00044         PCL_ERROR ("[pcl::%s::initCompute] PointCloudCoherence::Init failed.\n", getClassName ().c_str ());
00045         //deinitCompute ();
00046         return (false);
00047       }
00048       
00049       // initialize tree
00050       if (!search_)
00051         search_.reset (new pcl::search::Octree<PointInT> (0.01));
00052       
00053       if (new_target_ && target_input_)
00054       {
00055         search_->setInputCloud (target_input_);
00056         new_target_ = false;
00057       }
00058       
00059       return true;
00060     }
00061     
00062   }
00063 }
00064 
00065 #define PCL_INSTANTIATE_ApproxNearestPairPointCloudCoherence(T) template class PCL_EXPORTS pcl::tracking::ApproxNearestPairPointCloudCoherence<T>;
00066 
00067 #endif


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:14:38