Point Cloud Library (PCL)  1.7.0
/tmp/buildd/pcl-1.7-1.7.0/features/include/pcl/features/shot_omp.h
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2009, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  *
00038  */
00039 
00040 #ifndef PCL_SHOT_OMP_H_
00041 #define PCL_SHOT_OMP_H_
00042 
00043 #include <pcl/point_types.h>
00044 #include <pcl/features/feature.h>
00045 #include <pcl/features/shot.h>
00046 
00047 namespace pcl
00048 {
00049   /** \brief SHOTEstimationOMP estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given point cloud dataset
00050     * containing points and normals, in parallel, using the OpenMP standard.
00051     *
00052     * The suggested PointOutT is pcl::SHOT352.
00053     *
00054     * \note If you use this code in any academic work, please cite:
00055     *
00056     *   - F. Tombari, S. Salti, L. Di Stefano
00057     *     Unique Signatures of Histograms for Local Surface Description.
00058     *     In Proceedings of the 11th European Conference on Computer Vision (ECCV),
00059     *     Heraklion, Greece, September 5-11 2010.
00060     *   - F. Tombari, S. Salti, L. Di Stefano
00061     *     A Combined Texture-Shape Descriptor For Enhanced 3D Feature Matching.
00062     *     In Proceedings of the 18th International Conference on Image Processing (ICIP),
00063     *     Brussels, Belgium, September 11-14 2011.
00064     *
00065     * \author Samuele Salti
00066     * \ingroup features
00067     */
00068 
00069   template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT352, typename PointRFT = pcl::ReferenceFrame>
00070   class SHOTEstimationOMP : public SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>
00071   {
00072     public:
00073       typedef boost::shared_ptr<SHOTEstimationOMP<PointInT, PointNT, PointOutT, PointRFT> > Ptr;
00074       typedef boost::shared_ptr<const SHOTEstimationOMP<PointInT, PointNT, PointOutT, PointRFT> > ConstPtr;
00075       using Feature<PointInT, PointOutT>::feature_name_;
00076       using Feature<PointInT, PointOutT>::getClassName;
00077       using Feature<PointInT, PointOutT>::input_;
00078       using Feature<PointInT, PointOutT>::indices_;
00079       using Feature<PointInT, PointOutT>::k_;
00080       using Feature<PointInT, PointOutT>::search_parameter_;
00081       using Feature<PointInT, PointOutT>::search_radius_;
00082       using Feature<PointInT, PointOutT>::surface_;
00083       using Feature<PointInT, PointOutT>::fake_surface_;
00084       using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
00085       using FeatureWithLocalReferenceFrames<PointInT, PointRFT>::frames_;
00086       using SHOTEstimationBase<PointInT, PointNT, PointOutT, PointRFT>::lrf_radius_;
00087       using SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>::descLength_;
00088       using SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>::nr_grid_sector_;
00089       using SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>::nr_shape_bins_;
00090       using SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>::sqradius_;
00091       using SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius3_4_;
00092       using SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius1_4_;
00093       using SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius1_2_;
00094 
00095       typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00096       typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn;
00097 
00098       /** \brief Empty constructor. */
00099       SHOTEstimationOMP (unsigned int nr_threads = 0) : SHOTEstimation<PointInT, PointNT, PointOutT, PointRFT> (), threads_ (nr_threads)
00100       { };
00101       /** \brief Initialize the scheduler and set the number of threads to use.
00102         * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
00103         */
00104       inline void
00105       setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
00106 
00107     protected:
00108 
00109       /** \brief Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by
00110         * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
00111         * setSearchMethod ()
00112         * \param output the resultant point cloud model dataset that contains the SHOT feature estimates
00113         */
00114       void
00115       computeFeature (PointCloudOut &output);
00116 
00117       /** \brief This method should get called before starting the actual computation. */
00118       bool
00119       initCompute ();
00120 
00121       /** \brief The number of threads the scheduler should use. */
00122       unsigned int threads_;
00123   };
00124 
00125   /** \brief SHOTColorEstimationOMP estimates the Signature of Histograms of OrienTations (SHOT) descriptor for a given point cloud dataset
00126     * containing points, normals and colors, in parallel, using the OpenMP standard.
00127     *
00128     * The suggested PointOutT is pcl::SHOT1344.
00129     *
00130     * \note If you use this code in any academic work, please cite:
00131     *
00132     *   - F. Tombari, S. Salti, L. Di Stefano
00133     *     Unique Signatures of Histograms for Local Surface Description.
00134     *     In Proceedings of the 11th European Conference on Computer Vision (ECCV),
00135     *     Heraklion, Greece, September 5-11 2010.
00136     *   - F. Tombari, S. Salti, L. Di Stefano
00137     *     A Combined Texture-Shape Descriptor For Enhanced 3D Feature Matching.
00138     *     In Proceedings of the 18th International Conference on Image Processing (ICIP),
00139     *     Brussels, Belgium, September 11-14 2011.
00140     *
00141     * \author Samuele Salti
00142     * \ingroup features
00143     */
00144 
00145   template <typename PointInT, typename PointNT, typename PointOutT = pcl::SHOT1344, typename PointRFT = pcl::ReferenceFrame>
00146   class SHOTColorEstimationOMP : public SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>
00147   {
00148     public:
00149       typedef boost::shared_ptr<SHOTColorEstimationOMP<PointInT, PointNT, PointOutT, PointRFT> > Ptr;
00150       typedef boost::shared_ptr<const SHOTColorEstimationOMP<PointInT, PointNT, PointOutT, PointRFT> > ConstPtr;
00151       using Feature<PointInT, PointOutT>::feature_name_;
00152       using Feature<PointInT, PointOutT>::getClassName;
00153       using Feature<PointInT, PointOutT>::input_;
00154       using Feature<PointInT, PointOutT>::indices_;
00155       using Feature<PointInT, PointOutT>::k_;
00156       using Feature<PointInT, PointOutT>::search_parameter_;
00157       using Feature<PointInT, PointOutT>::search_radius_;
00158       using Feature<PointInT, PointOutT>::surface_;
00159       using Feature<PointInT, PointOutT>::fake_surface_;
00160       using FeatureFromNormals<PointInT, PointNT, PointOutT>::normals_;
00161       using FeatureWithLocalReferenceFrames<PointInT, PointRFT>::frames_;
00162       using SHOTEstimationBase<PointInT, PointNT, PointOutT, PointRFT>::lrf_radius_;
00163       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::descLength_;
00164       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::nr_grid_sector_;
00165       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::nr_shape_bins_;
00166       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::sqradius_;
00167       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius3_4_;
00168       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius1_4_;
00169       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::radius1_2_;
00170       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::b_describe_shape_;
00171       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::b_describe_color_;
00172       using SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT>::nr_color_bins_;
00173 
00174       typedef typename Feature<PointInT, PointOutT>::PointCloudOut PointCloudOut;
00175       typedef typename Feature<PointInT, PointOutT>::PointCloudIn PointCloudIn;
00176 
00177       /** \brief Empty constructor. */
00178       SHOTColorEstimationOMP (bool describe_shape = true,
00179                               bool describe_color = true,
00180                               unsigned int nr_threads = 0)
00181         : SHOTColorEstimation<PointInT, PointNT, PointOutT, PointRFT> (describe_shape, describe_color), threads_ (nr_threads)
00182       {
00183       }
00184 
00185       /** \brief Initialize the scheduler and set the number of threads to use.
00186         * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
00187         */
00188       inline void
00189       setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
00190 
00191     protected:
00192 
00193       /** \brief Estimate the Signatures of Histograms of OrienTations (SHOT) descriptors at a set of points given by
00194         * <setInputCloud (), setIndices ()> using the surface in setSearchSurface () and the spatial locator in
00195         * setSearchMethod ()
00196         * \param output the resultant point cloud model dataset that contains the SHOT feature estimates
00197         */
00198       void
00199       computeFeature (PointCloudOut &output);
00200 
00201       /** \brief This method should get called before starting the actual computation. */
00202       bool
00203       initCompute ();
00204 
00205       /** \brief The number of threads the scheduler should use. */
00206       unsigned int threads_;
00207   };
00208 
00209 }
00210 
00211 #ifdef PCL_NO_PRECOMPILE
00212 #include <pcl/features/impl/shot_omp.hpp>
00213 #endif
00214 
00215 #endif  //#ifndef PCL_SHOT_OMP_H_