Point Cloud Library (PCL)  1.7.0
/tmp/buildd/pcl-1.7-1.7.0/tracking/include/pcl/tracking/particle_filter_omp.h
00001 #ifndef PCL_TRACKING_PARTICLE_FILTER_OMP_H_
00002 #define PCL_TRACKING_PARTICLE_FILTER_OMP_H_
00003 
00004 #include <pcl/tracking/tracking.h>
00005 #include <pcl/tracking/particle_filter.h>
00006 #include <pcl/tracking/coherence.h>
00007 
00008 namespace pcl
00009 {
00010   namespace tracking
00011   {
00012   /** \brief @b ParticleFilterOMPTracker tracks the PointCloud which is given by
00013       setReferenceCloud within the measured PointCloud using particle filter method 
00014       in parallel, using the OpenMP standard.
00015     * \author Ryohei Ueda
00016     * \ingroup tracking
00017     */
00018     template <typename PointInT, typename StateT>
00019     class ParticleFilterOMPTracker: public ParticleFilterTracker<PointInT, StateT>
00020     {
00021     public:
00022       using Tracker<PointInT, StateT>::tracker_name_;
00023       using Tracker<PointInT, StateT>::search_;
00024       using Tracker<PointInT, StateT>::input_;
00025       using Tracker<PointInT, StateT>::indices_;
00026       using Tracker<PointInT, StateT>::getClassName;
00027       using ParticleFilterTracker<PointInT, StateT>::particles_;
00028       using ParticleFilterTracker<PointInT, StateT>::change_detector_;
00029       using ParticleFilterTracker<PointInT, StateT>::change_counter_;
00030       using ParticleFilterTracker<PointInT, StateT>::change_detector_interval_;
00031       using ParticleFilterTracker<PointInT, StateT>::use_change_detector_;
00032       using ParticleFilterTracker<PointInT, StateT>::alpha_;
00033       using ParticleFilterTracker<PointInT, StateT>::changed_;
00034       using ParticleFilterTracker<PointInT, StateT>::coherence_;
00035       using ParticleFilterTracker<PointInT, StateT>::use_normal_;
00036       using ParticleFilterTracker<PointInT, StateT>::particle_num_;
00037       using ParticleFilterTracker<PointInT, StateT>::change_detector_filter_;
00038       using ParticleFilterTracker<PointInT, StateT>::transed_reference_vector_;
00039       //using ParticleFilterTracker<PointInT, StateT>::calcLikelihood;
00040       using ParticleFilterTracker<PointInT, StateT>::normalizeWeight;
00041       using ParticleFilterTracker<PointInT, StateT>::normalizeParticleWeight;
00042       using ParticleFilterTracker<PointInT, StateT>::calcBoundingBox;
00043 
00044       typedef Tracker<PointInT, StateT> BaseClass;
00045       
00046       typedef typename Tracker<PointInT, StateT>::PointCloudIn PointCloudIn;
00047       typedef typename PointCloudIn::Ptr PointCloudInPtr;
00048       typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr;
00049 
00050       typedef typename Tracker<PointInT, StateT>::PointCloudState PointCloudState;
00051       typedef typename PointCloudState::Ptr PointCloudStatePtr;
00052       typedef typename PointCloudState::ConstPtr PointCloudStateConstPtr;
00053 
00054       typedef PointCoherence<PointInT> Coherence;
00055       typedef boost::shared_ptr< Coherence > CoherencePtr;
00056       typedef boost::shared_ptr< const Coherence > CoherenceConstPtr;
00057 
00058       typedef PointCloudCoherence<PointInT> CloudCoherence;
00059       typedef boost::shared_ptr< CloudCoherence > CloudCoherencePtr;
00060       typedef boost::shared_ptr< const CloudCoherence > CloudCoherenceConstPtr;
00061 
00062       /** \brief Initialize the scheduler and set the number of threads to use.
00063         * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
00064         */      
00065       ParticleFilterOMPTracker (unsigned int nr_threads = 0)
00066       : ParticleFilterTracker<PointInT, StateT> ()
00067       , threads_ (nr_threads)
00068       {
00069         tracker_name_ = "ParticleFilterOMPTracker";
00070       }
00071 
00072       /** \brief Initialize the scheduler and set the number of threads to use.
00073         * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
00074         */
00075       inline void
00076       setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
00077       
00078     protected:
00079       /** \brief The number of threads the scheduler should use. */
00080       unsigned int threads_;
00081 
00082       /** \brief weighting phase of particle filter method.
00083           calculate the likelihood of all of the particles and set the weights.
00084         */
00085       virtual void weight ();
00086 
00087     };
00088   }
00089 }
00090 
00091 //#include <pcl/tracking/impl/particle_filter_omp.hpp>
00092 #ifdef PCL_NO_PRECOMPILE
00093 #include <pcl/tracking/impl/particle_filter_omp.hpp>
00094 #endif
00095 
00096 #endif