color_histogram.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/or 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 #include <ros/ros.h>
37 #include <nodelet/nodelet.h>
38 #include <geometry_msgs/PolygonStamped.h>
39 #include <jsk_recognition_msgs/ColorHistogram.h>
41 #include <cv_bridge/cv_bridge.h>
48 #include <dynamic_reconfigure/server.h>
49 #include <jsk_perception/ColorHistogramConfig.h>
50 #include "opencv2/highgui/highgui.hpp"
51 #include "opencv2/imgproc/imgproc.hpp"
52 #include <jsk_topic_tools/diagnostic_nodelet.h>
53 
54 namespace jsk_perception
55 {
56  class ColorHistogram: public jsk_topic_tools::DiagnosticNodelet
57  {
58  public:
60  sensor_msgs::Image,
61  geometry_msgs::PolygonStamped > SyncPolicy;
62 
64  sensor_msgs::Image,
65  sensor_msgs::Image> MaskSyncPolicy;
66  typedef jsk_perception::ColorHistogramConfig Config;
67  ColorHistogram(): DiagnosticNodelet("ColorHistogram") {}
68  virtual ~ColorHistogram();
69  protected:
83  bool use_mask_;
84  boost::mutex mutex_;
85 
86  void configCallback(Config &new_config, uint32_t level);
87  virtual void onInit();
88  virtual void subscribe();
89  virtual void unsubscribe();
90  virtual void convertHistogramToMsg(
91  const cv::Mat& hist,
92  int size,
93  jsk_recognition_msgs::ColorHistogram& msg);
94  virtual void processBGR(const cv::Mat& bgr_image,
95  const std_msgs::Header& header);
96  virtual void processHSI(const cv::Mat& bgr_image,
97  const std_msgs::Header& header);
98  virtual void processBGR(const cv::Mat& bgr_image,
99  const cv::Mat& mask,
100  const std_msgs::Header& header);
101  virtual void processHSI(const cv::Mat& bgr_image,
102  const cv::Mat& mask,
103  const std_msgs::Header& header);
104  virtual void extract(
105  const sensor_msgs::Image::ConstPtr& image,
106  const geometry_msgs::PolygonStamped::ConstPtr& rectangle);
107  virtual void extractMask(
108  const sensor_msgs::Image::ConstPtr& image,
109  const sensor_msgs::Image::ConstPtr& mask_image);
110  private:
111 
112  };
113 }
jsk_perception::ColorHistogram::s_hist_pub_
ros::Publisher s_hist_pub_
Definition: color_histogram.h:143
image_transport::SubscriberFilter
jsk_perception::ColorHistogram::r_hist_size_
int r_hist_size_
Definition: color_histogram.h:145
jsk_perception::ColorHistogram::it_
boost::shared_ptr< image_transport::ImageTransport > it_
Definition: color_histogram.h:141
jsk_perception::ColorHistogram::g_hist_pub_
ros::Publisher g_hist_pub_
Definition: color_histogram.h:142
jsk_perception::ColorHistogram::~ColorHistogram
virtual ~ColorHistogram()
Definition: color_histogram.cpp:85
jsk_perception::ColorHistogram::configCallback
void configCallback(Config &new_config, uint32_t level)
Definition: color_histogram.cpp:73
ros::Publisher
image_encodings.h
jsk_perception::ColorHistogram::unsubscribe
virtual void unsubscribe()
Definition: color_histogram.cpp:155
boost::shared_ptr
jsk_perception::ColorHistogram::h_hist_pub_
ros::Publisher h_hist_pub_
Definition: color_histogram.h:143
jsk_perception::ColorHistogram::subscribe
virtual void subscribe()
Definition: color_histogram.cpp:125
ros.h
jsk_perception::ColorHistogram::Config
jsk_perception::ColorHistogramConfig Config
Definition: color_histogram.h:130
jsk_perception::ColorHistogram::i_hist_size_
int i_hist_size_
Definition: color_histogram.h:146
jsk_perception::ColorHistogram::i_hist_pub_
ros::Publisher i_hist_pub_
Definition: color_histogram.h:143
jsk_perception::ColorHistogram::image_mask_sub_
image_transport::SubscriberFilter image_mask_sub_
Definition: color_histogram.h:138
jsk_perception::ColorHistogram::processHSI
virtual void processHSI(const cv::Mat &bgr_image, const std_msgs::Header &header)
Definition: color_histogram.cpp:218
jsk_perception::ColorHistogram::convertHistogramToMsg
virtual void convertHistogramToMsg(const cv::Mat &hist, int size, jsk_recognition_msgs::ColorHistogram &msg)
Definition: color_histogram.cpp:167
jsk_perception::ColorHistogram::MaskSyncPolicy
message_filters::sync_policies::ApproximateTime< sensor_msgs::Image, sensor_msgs::Image > MaskSyncPolicy
Definition: color_histogram.h:129
jsk_perception::ColorHistogram::image_pub_
ros::Publisher image_pub_
Definition: color_histogram.h:144
message_filters::Subscriber< geometry_msgs::PolygonStamped >
jsk_perception::ColorHistogram::extractMask
virtual void extractMask(const sensor_msgs::Image::ConstPtr &image, const sensor_msgs::Image::ConstPtr &mask_image)
Definition: color_histogram.cpp:303
jsk_perception::ColorHistogram::h_hist_size_
int h_hist_size_
Definition: color_histogram.h:146
jsk_perception
Definition: add_mask_image.h:48
message_filters::sync_policies::ApproximateTime
subscriber_filter.h
jsk_perception::ColorHistogram::rectangle_sub_
message_filters::Subscriber< geometry_msgs::PolygonStamped > rectangle_sub_
Definition: color_histogram.h:139
subscriber.h
jsk_perception::ColorHistogram::b_hist_size_
int b_hist_size_
Definition: color_histogram.h:145
jsk_perception::ColorHistogram::mask_sync_
boost::shared_ptr< message_filters::Synchronizer< MaskSyncPolicy > > mask_sync_
Definition: color_histogram.h:135
jsk_perception::ColorHistogram::processBGR
virtual void processBGR(const cv::Mat &bgr_image, const std_msgs::Header &header)
Definition: color_histogram.cpp:212
jsk_perception::ColorHistogram::mutex_
boost::mutex mutex_
Definition: color_histogram.h:148
jsk_perception::ColorHistogram::r_hist_pub_
ros::Publisher r_hist_pub_
Definition: color_histogram.h:142
jsk_perception::ColorHistogram::ColorHistogram
ColorHistogram()
Definition: color_histogram.h:131
image_transport.h
exact_time.h
jsk_perception::ColorHistogram::extract
virtual void extract(const sensor_msgs::Image::ConstPtr &image, const geometry_msgs::PolygonStamped::ConstPtr &rectangle)
Definition: color_histogram.cpp:264
jsk_perception::ColorHistogram::nh_
ros::NodeHandle nh_
Definition: color_histogram.h:140
nodelet.h
cv_bridge.h
jsk_perception::ColorHistogram::sync_
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
Definition: color_histogram.h:134
jsk_perception::ColorHistogram::use_mask_
bool use_mask_
Definition: color_histogram.h:147
jsk_perception::ColorHistogram::s_hist_size_
int s_hist_size_
Definition: color_histogram.h:146
synchronizer.h
approximate_time.h
jsk_perception::ColorHistogram::onInit
virtual void onInit()
Definition: color_histogram.cpp:97
jsk_perception::ColorHistogram::b_hist_pub_
ros::Publisher b_hist_pub_
Definition: color_histogram.h:142
jsk_perception::ColorHistogram::image_sub_
image_transport::SubscriberFilter image_sub_
Definition: color_histogram.h:137
jsk_perception::ColorHistogram::srv_
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
Definition: color_histogram.h:136
jsk_perception::ColorHistogram::g_hist_size_
int g_hist_size_
Definition: color_histogram.h:145
jsk_perception::ColorHistogram::SyncPolicy
message_filters::sync_policies::ApproximateTime< sensor_msgs::Image, geometry_msgs::PolygonStamped > SyncPolicy
Definition: color_histogram.h:125
ros::NodeHandle


jsk_perception
Author(s): Manabu Saito, Ryohei Ueda
autogenerated on Fri May 16 2025 03:11:16