Point Cloud Library (PCL)  1.3.1
color.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2011, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage, Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  *  Author: Suat Gedikli (gedikli@willowgarage.com)
00035  *
00036  */
00037 
00038 #ifndef PCL_FILTERS_COLOR_H_
00039 #define PCL_FILTERS_COLOR_H_
00040 
00041 #include "pcl/filters/filter.h"
00042 
00043 namespace pcl
00044 {
00045   template<typename PointT>
00046   class ColorFilter : public Filter<PointT>
00047   {
00048     using Filter<PointT>::input_;
00049     using Filter<PointT>::filter_name_;
00050     using Filter<PointT>::getClassName;
00051 
00052     using Filter<PointT>::removed_indices_;
00053     using Filter<PointT>::extract_removed_indices_;
00054 
00055     typedef typename Filter<PointT>::PointCloud PointCloud;
00056     typedef typename PointCloud::Ptr PointCloudPtr;
00057     typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00058 
00059     public:
00061       ColorFilter (bool extract_removed_indices = false) :
00062         Filter<PointT>::Filter (extract_removed_indices), keep_organized_ (false),
00063         user_filter_value_ (std::numeric_limits<float>::quiet_NaN ())
00064       {
00065         filter_name_ = "ColorFilter";
00066       }
00067 
00076       inline void
00077       setKeepOrganized (bool val)
00078       {
00079         keep_organized_ = val;
00080       }
00081 
00082       inline bool
00083       getKeepOrganized ()
00084       {
00085         return (keep_organized_);
00086       }
00087 
00093       inline void
00094       setUserFilterValue (float val)
00095       {
00096         user_filter_value_ = val;
00097       }
00098 
00099       inline void
00100       setLookUpTable (const std::vector<bool>& lookup)
00101       {
00102         lookup_ = lookup;
00103       }
00104     protected:
00108       void
00109       applyFilter (PointCloud &output);
00110 
00111       //typedef typename pcl::traits::fieldList<PointT>::type FieldList;
00112 
00113     private:
00117       bool keep_organized_;
00118 
00122       float user_filter_value_;
00123 
00124       std::vector<bool> lookup_;
00125   };
00126 
00127   template<>
00128   class PCL_EXPORTS ColorFilter<sensor_msgs::PointCloud2> : public Filter<sensor_msgs::PointCloud2>
00129   {
00130     typedef sensor_msgs::PointCloud2 PointCloud2;
00131     typedef PointCloud2::Ptr PointCloud2Ptr;
00132     typedef PointCloud2::ConstPtr PointCloud2ConstPtr;
00133 
00134     using Filter<sensor_msgs::PointCloud2>::removed_indices_;
00135     using Filter<sensor_msgs::PointCloud2>::extract_removed_indices_;
00136 
00137     public:
00139       ColorFilter (bool extract_removed_indices = false)
00140         : Filter<sensor_msgs::PointCloud2>::Filter (extract_removed_indices)
00141         , keep_organized_ (false)
00142       {
00143         filter_name_ = "ColorFilter";
00144       }
00145 
00154       inline void
00155       setKeepOrganized (bool val)
00156       {
00157         keep_organized_ = val;
00158       }
00159 
00160       inline bool
00161       getKeepOrganized ()
00162       {
00163         return (keep_organized_);
00164       }
00165 
00166       inline void
00167       setLookUpTable (const std::vector<bool>& lookup)
00168       {
00169         lookup_ = lookup;
00170       }
00171 
00172     protected:
00173       void
00174       applyFilter (PointCloud2 &output);
00175 
00176     private:
00180       bool keep_organized_;
00181 
00182       std::vector<bool> lookup_;
00183   };
00184 }
00185 
00186 #endif  //#ifndef PCL_FILTERS_COLOR_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines