draw_rects.h
Go to the documentation of this file.
1 // -*- mode: C++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2017, 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  * draw_rects.h
37  * Author: furushchev <furushchev@jsk.imi.i.u-tokyo.ac.jp>
38  */
39 
40 
41 #ifndef DRAW_RECTS_H__
42 #define DRAW_RECTS_H__
43 
44 #include <sstream>
45 
46 #include <boost/shared_ptr.hpp>
47 #include <boost/thread.hpp>
48 
49 #include <opencv2/opencv.hpp>
50 
51 #include <cv_bridge/cv_bridge.h>
52 #include <dynamic_reconfigure/server.h>
53 #include <jsk_topic_tools/connection_based_nodelet.h>
60 
61 #include <jsk_perception/DrawRectsConfig.h>
62 #include <jsk_recognition_msgs/ClassificationResult.h>
63 #include <jsk_recognition_msgs/RectArray.h>
64 #include <sensor_msgs/Image.h>
65 
66 
67 namespace jsk_perception
68 {
69  class DrawRects : public jsk_topic_tools::ConnectionBasedNodelet
70  {
71  public:
72  typedef DrawRectsConfig Config;
74  sensor_msgs::Image,
75  jsk_recognition_msgs::RectArray,
76  jsk_recognition_msgs::ClassificationResult> SyncPolicy;
78  sensor_msgs::Image,
79  jsk_recognition_msgs::RectArray,
80  jsk_recognition_msgs::ClassificationResult> AsyncPolicy;
81 
82  DrawRects(){}
83  virtual ~DrawRects();
84  protected:
85  virtual void onInit();
86  virtual void subscribe();
87  virtual void unsubscribe();
88  virtual void configCallback(Config& config, uint32_t level);
89  virtual void onMessage(
90  const sensor_msgs::Image::ConstPtr& image,
91  const jsk_recognition_msgs::RectArray::ConstPtr& rects,
92  const jsk_recognition_msgs::ClassificationResult::ConstPtr& classes);
93  virtual void fillEmptyClasses(
94  const jsk_recognition_msgs::RectArray::ConstPtr& rects);
95  virtual void drawRect(
96  cv::Mat& img, const jsk_recognition_msgs::Rect& rect, const cv::Scalar& color);
97  virtual void drawLabel(
98  cv::Mat& img, const jsk_recognition_msgs::Rect& rect,
99  const cv::Scalar& color, const std::string& label);
100  virtual void randomColor(const int& label_num, const int& index, cv::Scalar& color);
101  virtual bool isDarkColor(const cv::Scalar& color) {
102  return color[2] * 0.299 + color[1] * 0.587 + color[0] * 0.114 <= 186.0;
103  }
104 
105  boost::mutex mutex_;
114 
115  bool use_async_;
117  bool show_proba_;
118  int queue_size_;
119  int rect_boldness_;
120  double label_size_;
121  int label_boldness_;
122  int label_font_;
123  double label_margin_factor_;
124  double resolution_factor_;
126  };
127 }
128 
129 
130 #endif // DRAW_RECTS_H__
jsk_perception::DrawRects::null_class_
message_filters::PassThrough< jsk_recognition_msgs::ClassificationResult > null_class_
Definition: draw_rects.h:174
ros::Publisher
jsk_perception::DrawRects::srv_
boost::shared_ptr< dynamic_reconfigure::Server< Config > > srv_
Definition: draw_rects.h:170
image_encodings.h
pass_through.h
boost::shared_ptr
jsk_perception::DrawRects::sub_image_
message_filters::Subscriber< sensor_msgs::Image > sub_image_
Definition: draw_rects.h:175
jsk_perception::DrawRects::unsubscribe
virtual void unsubscribe()
Definition: draw_rects.cpp:136
jsk_perception::DrawRects::onMessage
virtual void onMessage(const sensor_msgs::Image::ConstPtr &image, const jsk_recognition_msgs::RectArray::ConstPtr &rects, const jsk_recognition_msgs::ClassificationResult::ConstPtr &classes)
Definition: draw_rects.cpp:187
jsk_perception::DrawRects::Config
DrawRectsConfig Config
Definition: draw_rects.h:136
jsk_perception::DrawRects::use_async_
bool use_async_
Definition: draw_rects.h:179
jsk_perception::DrawRects::rect_boldness_
int rect_boldness_
Definition: draw_rects.h:183
jsk_perception::DrawRects::label_font_
int label_font_
Definition: draw_rects.h:186
jsk_perception::DrawRects::AsyncPolicy
message_filters::sync_policies::ApproximateTime< sensor_msgs::Image, jsk_recognition_msgs::RectArray, jsk_recognition_msgs::ClassificationResult > AsyncPolicy
Definition: draw_rects.h:144
message_filters::Subscriber< sensor_msgs::Image >
jsk_perception::DrawRects::label_boldness_
int label_boldness_
Definition: draw_rects.h:185
jsk_perception
Definition: add_mask_image.h:48
message_filters::sync_policies::ApproximateTime
jsk_perception::DrawRects::interpolation_method_
int interpolation_method_
Definition: draw_rects.h:189
jsk_perception::DrawRects::async_
boost::shared_ptr< message_filters::Synchronizer< AsyncPolicy > > async_
Definition: draw_rects.h:172
jsk_perception::DrawRects::SyncPolicy
message_filters::sync_policies::ExactTime< sensor_msgs::Image, jsk_recognition_msgs::RectArray, jsk_recognition_msgs::ClassificationResult > SyncPolicy
Definition: draw_rects.h:140
jsk_perception::DrawRects::use_classification_result_
bool use_classification_result_
Definition: draw_rects.h:180
subscriber.h
jsk_perception::DrawRects::drawLabel
virtual void drawLabel(cv::Mat &img, const jsk_recognition_msgs::Rect &rect, const cv::Scalar &color, const std::string &label)
Definition: draw_rects.cpp:241
jsk_perception::DrawRects::pub_image_
ros::Publisher pub_image_
Definition: draw_rects.h:173
jsk_perception::DrawRects::isDarkColor
virtual bool isDarkColor(const cv::Scalar &color)
Definition: draw_rects.h:165
jsk_perception::DrawRects::resolution_factor_
double resolution_factor_
Definition: draw_rects.h:188
jsk_perception::DrawRects::show_proba_
bool show_proba_
Definition: draw_rects.h:181
jsk_perception::DrawRects::~DrawRects
virtual ~DrawRects()
Definition: draw_rects.cpp:96
jsk_perception::DrawRects::mutex_
boost::mutex mutex_
Definition: draw_rects.h:169
jsk_perception::DrawRects::queue_size_
int queue_size_
Definition: draw_rects.h:182
jsk_perception::DrawRects::drawRect
virtual void drawRect(cv::Mat &img, const jsk_recognition_msgs::Rect &rect, const cv::Scalar &color)
Definition: draw_rects.cpp:231
exact_time.h
jsk_perception::DrawRects::fillEmptyClasses
virtual void fillEmptyClasses(const jsk_recognition_msgs::RectArray::ConstPtr &rects)
Definition: draw_rects.cpp:178
jsk_perception::DrawRects::label_margin_factor_
double label_margin_factor_
Definition: draw_rects.h:187
jsk_perception::DrawRects::onInit
virtual void onInit()
Definition: draw_rects.cpp:82
message_filters::PassThrough< jsk_recognition_msgs::ClassificationResult >
jsk_perception::DrawRects::subscribe
virtual void subscribe()
Definition: draw_rects.cpp:108
cv_bridge.h
jsk_perception::DrawRects::configCallback
virtual void configCallback(Config &config, uint32_t level)
Definition: draw_rects.cpp:144
synchronizer.h
approximate_time.h
jsk_perception::DrawRects::label_size_
double label_size_
Definition: draw_rects.h:184
jsk_perception::DrawRects::DrawRects
DrawRects()
Definition: draw_rects.h:146
message_filters::sync_policies::ExactTime
jsk_perception::DrawRects::randomColor
virtual void randomColor(const int &label_num, const int &index, cv::Scalar &color)
Definition: draw_rects.cpp:270
jsk_perception::DrawRects::sync_
boost::shared_ptr< message_filters::Synchronizer< SyncPolicy > > sync_
Definition: draw_rects.h:171
jsk_perception::DrawRects::sub_class_
message_filters::Subscriber< jsk_recognition_msgs::ClassificationResult > sub_class_
Definition: draw_rects.h:177
jsk_perception::DrawRects::sub_rects_
message_filters::Subscriber< jsk_recognition_msgs::RectArray > sub_rects_
Definition: draw_rects.h:176


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