Point Cloud Library (PCL)  1.7.0
/tmp/buildd/pcl-1.7-1.7.0/tracking/include/pcl/tracking/tracker.h
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2012, Willow Garage, Inc.
00006  *
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of Willow Garage, Inc. nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  * $Id: point_cloud.h 4696 2012-02-23 06:12:55Z rusu $
00037  *
00038  */
00039 
00040 #ifndef PCL_TRACKING_TRACKER_H_
00041 #define PCL_TRACKING_TRACKER_H_
00042 
00043 #include <pcl/tracking/tracking.h>
00044 #include <pcl/pcl_base.h>
00045 #include <pcl/search/search.h>
00046 
00047 namespace pcl
00048 {
00049   namespace tracking
00050   {
00051     /** \brief @b Tracker represents the base tracker class.
00052       * \author Ryohei Ueda
00053       * \ingroup tracking
00054       */
00055     template <typename PointInT, typename StateT>
00056     class Tracker: public PCLBase<PointInT>
00057     {
00058     protected:
00059       using PCLBase<PointInT>::deinitCompute;
00060       
00061     public:
00062       using PCLBase<PointInT>::indices_;
00063       using PCLBase<PointInT>::input_;
00064       
00065       typedef PCLBase<PointInT> BaseClass;
00066       typedef boost::shared_ptr< Tracker<PointInT, StateT> > Ptr;
00067       typedef boost::shared_ptr< const Tracker<PointInT, StateT> > ConstPtr;
00068 
00069       typedef boost::shared_ptr<pcl::search::Search<PointInT> > SearchPtr;
00070       typedef boost::shared_ptr<const pcl::search::Search<PointInT> > SearchConstPtr;
00071             
00072       typedef pcl::PointCloud<PointInT> PointCloudIn;
00073       typedef typename PointCloudIn::Ptr PointCloudInPtr;
00074       typedef typename PointCloudIn::ConstPtr PointCloudInConstPtr;
00075       
00076       typedef pcl::PointCloud<StateT> PointCloudState;
00077       typedef typename PointCloudState::Ptr PointCloudStatePtr;
00078       typedef typename PointCloudState::ConstPtr PointCloudStateConstPtr;
00079       
00080     public:
00081       /** \brief Empty constructor. */
00082       Tracker (): tracker_name_ (), search_ () {}
00083       
00084       /** \brief Base method for tracking for all points given in 
00085         * <setInputCloud (), setIndices ()> using the indices in setIndices () 
00086         */
00087       void 
00088       compute ();
00089       
00090     protected:
00091       /** \brief The tracker name. */
00092       std::string tracker_name_;
00093 
00094       /** \brief A pointer to the spatial search object. */
00095       SearchPtr search_;
00096 
00097       /** \brief Get a string representation of the name of this class. */
00098       inline const std::string& 
00099       getClassName () const { return (tracker_name_); }
00100 
00101       /** \brief This method should get called before starting the actual computation. */
00102       virtual bool
00103         initCompute ();
00104 
00105       /** \brief Provide a pointer to a dataset to add additional information
00106        * to estimate the features for every point in the input dataset.  This
00107        * is optional, if this is not set, it will only use the data in the
00108        * input cloud to estimate the features.  This is useful when you only
00109        * need to compute the features for a downsampled cloud.  
00110        * \param cloud a pointer to a PointCloud message
00111        */
00112       inline void 
00113       setSearchMethod (const SearchPtr &search) { search_ = search; }
00114 
00115       /** \brief Get a pointer to the point cloud dataset. */
00116       inline SearchPtr 
00117       getSearchMethod () { return (search_); }
00118       
00119       /** \brief Get an instance of the result of tracking. */
00120       virtual StateT 
00121       getResult () const = 0;
00122       
00123     private:
00124       /** \brief Abstract tracking method. */
00125       virtual void
00126       computeTracking () = 0;
00127       
00128     public:
00129       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00130     };
00131   }
00132 }
00133 
00134 #include <pcl/tracking/impl/tracker.hpp>
00135 
00136 #endif