color_filter.h
Go to the documentation of this file.
1 // -*- mode: C++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/o2r other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 
37 #ifndef JSK_PCL_ROS_COLOR_FILTER_H_
38 #define JSK_PCL_ROS_COLOR_FILTER_H_
39 
40 #include <nodelet/nodelet.h>
41 #include <pcl_ros/pcl_nodelet.h>
42 #include <pcl/filters/conditional_removal.h>
43 #include "jsk_pcl_ros/RGBColorFilterConfig.h"
44 #include "jsk_pcl_ros/HSIColorFilterConfig.h"
47 #include <dynamic_reconfigure/server.h>
48 
51 
52 namespace jsk_pcl_ros
53 {
54  class RGBColorFilter;
55  class HSIColorFilter;
56 
57  template <class PackedComparison, typename Config>
59  {
60  friend class RGBColorFilter;
61  friend class HSIColorFilter;
62  public:
63  typedef message_filters::sync_policies::ExactTime<sensor_msgs::PointCloud2,
65  typedef typename pcl::ConditionBase<pcl::PointXYZRGB>::Ptr ConditionPtr;
66  typedef typename pcl::ComparisonBase<pcl::PointXYZRGB>::Ptr ComparisonPtr;
67  typedef PackedComparison Comparison;
68 
69  protected:
71  pcl::ConditionalRemoval<pcl::PointXYZRGB> filter_instance_;
75  sensor_msgs::PointCloud2 color_space_msg_;
78  virtual void configCallback(Config &config, uint32_t level) = 0;
79  virtual void updateCondition() = 0;
80  virtual void convertToColorSpace(float &x, float &y, float &z,
81  unsigned char r, unsigned char g, unsigned char b) = 0;
82  virtual void filter(const sensor_msgs::PointCloud2ConstPtr &input);
83  virtual void filter(const sensor_msgs::PointCloud2ConstPtr &input,
84  const PCLIndicesMsg::ConstPtr& indices);
85  virtual void subscribe();
86  virtual void unsubscribe();
88 
90  private:
91  virtual void onInit();
92  };
93 
94  class RGBColorFilter: public ColorFilter<pcl::PackedRGBComparison<pcl::PointXYZRGB>, jsk_pcl_ros::RGBColorFilterConfig>
95  {
96  public:
97  protected:
98  int r_min_, r_max_, b_min_, b_max_, g_min_, g_max_;
99  virtual void configCallback(jsk_pcl_ros::RGBColorFilterConfig &config, uint32_t level);
100  virtual void updateCondition();
101  virtual void convertToColorSpace(float &x, float &y, float &z,
102  unsigned char r, unsigned char g, unsigned char b);
103  private:
104  virtual void onInit();
105  };
106 
107  class HSIColorFilter: public ColorFilter<pcl::PackedHSIComparison<pcl::PointXYZRGB>, jsk_pcl_ros::HSIColorFilterConfig>
108  {
109  public:
110  protected:
111  int h_min_, h_max_, s_min_, s_max_, i_min_, i_max_;
112  virtual void configCallback(jsk_pcl_ros::HSIColorFilterConfig &config, uint32_t level);
113  virtual void updateCondition();
114  virtual void convertToColorSpace(float &x, float &y, float &z,
115  unsigned char r, unsigned char g, unsigned char b);
116  private:
117  virtual void onInit();
118  };
119 }
120 
121 
122 #endif
message_filters::sync_policies::ExactTime< sensor_msgs::PointCloud2, PCLIndicesMsg > SyncPolicy
Definition: color_filter.h:64
message_filters::Subscriber< PCLIndicesMsg > sub_indices_
Definition: color_filter.h:73
PackedComparison Comparison
Definition: color_filter.h:67
virtual void configCallback(Config &config, uint32_t level)=0
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
Definition: color_filter.h:87
virtual void updateCondition()=0
pcl::ComparisonBase< pcl::PointXYZRGB >::Ptr ComparisonPtr
Definition: color_filter.h:66
sensor_msgs::PointCloud2 color_space_msg_
Definition: color_filter.h:75
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
Definition: color_filter.h:77
ros::Publisher color_space_pub_
Definition: color_filter.h:76
virtual void convertToColorSpace(float &x, float &y, float &z, unsigned char r, unsigned char g, unsigned char b)=0
pcl::ConditionBase< pcl::PointXYZRGB >::Ptr ConditionPtr
Definition: color_filter.h:65
message_filters::Subscriber< sensor_msgs::PointCloud2 > sub_input_
Definition: color_filter.h:72
boost::mutex mutex
global mutex.
pcl::PointIndices PCLIndicesMsg
pcl::ConditionalRemoval< pcl::PointXYZRGB > filter_instance_
Definition: color_filter.h:71
virtual void filter(const sensor_msgs::PointCloud2ConstPtr &input)


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Mon May 3 2021 03:03:46