disparity_plugin.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #ifndef MAPVIZ_PLUGINS_DISPARITY_PLUGIN_H_
31 #define MAPVIZ_PLUGINS_DISPARITY_PLUGIN_H_
32 
33 // Include mapviz_plugin.h first to ensure GL deps are included in the right order
34 #include <mapviz/mapviz_plugin.h>
35 
36 // C++ standard libraries
37 #include <list>
38 #include <string>
39 
40 // QT libraries
41 #include <QColor>
42 #include <QGLWidget>
43 #include <QObject>
44 #include <QWidget>
45 
46 // ROS libraries
47 #include <cv_bridge/cv_bridge.h>
48 #include <opencv2/highgui.hpp>
49 #include <ros/ros.h>
50 #include <stereo_msgs/DisparityImage.h>
51 #include <tf/transform_datatypes.h>
52 
53 #include <mapviz/map_canvas.h>
54 
55 // QT autogenerated files
56 #include "ui_disparity_config.h"
57 
58 namespace mapviz_plugins
59 {
61  {
62  Q_OBJECT
63 
64  public:
65  enum Anchor {
75 
76  enum Units {PIXELS, PERCENT};
77 
79  virtual ~DisparityPlugin();
80 
81  bool Initialize(QGLWidget* canvas);
82  void Shutdown() {}
83 
84  void Draw(double x, double y, double scale);
85 
86  void Transform() {}
87 
88  void LoadConfig(const YAML::Node& node, const std::string& path);
89  void SaveConfig(YAML::Emitter& emitter, const std::string& path);
90 
91  QWidget* GetConfigWidget(QWidget* parent);
92 
93  protected:
94  void PrintError(const std::string& message);
95  void PrintInfo(const std::string& message);
96  void PrintWarning(const std::string& message);
97 
98  protected Q_SLOTS:
99  void SelectTopic();
100  void TopicEdited();
101  void SetAnchor(QString anchor);
102  void SetUnits(QString units);
103  void SetOffsetX(int offset);
104  void SetOffsetY(int offset);
105  void SetWidth(int width);
106  void SetHeight(int height);
107  void SetSubscription(bool visible);
108 
109  private:
110  Ui::disparity_config ui_;
111  QWidget* config_widget_;
112 
113  std::string topic_;
116  double offset_x_;
117  double offset_y_;
118  double width_;
119  double height_;
120 
122 
123  double last_width_;
124  double last_height_;
125 
128 
129  stereo_msgs::DisparityImage disparity_;
130 
131  cv::Mat_<cv::Vec3b> disparity_color_;
132  cv::Mat scaled_image_;
133 
134  void disparityCallback(const stereo_msgs::DisparityImageConstPtr& image);
135 
136  void ScaleImage(double width, double height);
137  void DrawIplImage(cv::Mat *image);
138 
139  std::string AnchorToString(Anchor anchor);
140  std::string UnitsToString(Units units);
141 
142  const static unsigned char COLOR_MAP[];
143  };
144 }
145 
146 #endif // MAPVIZ_PLUGINS_DISPARITY_PLUGIN_H_
mapviz_plugins::DisparityPlugin::disparityCallback
void disparityCallback(const stereo_msgs::DisparityImageConstPtr &image)
Definition: disparity_plugin.cpp:234
mapviz_plugins::DisparityPlugin::topic_
std::string topic_
Definition: disparity_plugin.h:113
mapviz_plugins::DisparityPlugin::PrintInfo
void PrintInfo(const std::string &message)
Definition: disparity_plugin.cpp:293
mapviz_plugins::DisparityPlugin::DisparityPlugin
DisparityPlugin()
Definition: disparity_plugin.cpp:56
mapviz_plugins::DisparityPlugin::SetSubscription
void SetSubscription(bool visible)
Definition: disparity_plugin.cpp:166
mapviz_plugins::DisparityPlugin::SaveConfig
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
Definition: disparity_plugin.cpp:498
mapviz_plugins::DisparityPlugin::SetAnchor
void SetAnchor(QString anchor)
Definition: disparity_plugin.cpp:115
mapviz_plugins::DisparityPlugin::BOTTOM_LEFT
@ BOTTOM_LEFT
Definition: disparity_plugin.h:72
mapviz_plugins::DisparityPlugin::SetWidth
void SetWidth(int width)
Definition: disparity_plugin.cpp:105
mapviz_plugins::DisparityPlugin::Units
Units
Definition: disparity_plugin.h:76
mapviz_plugins::DisparityPlugin::CENTER
@ CENTER
Definition: disparity_plugin.h:70
mapviz_plugins::DisparityPlugin::anchor_
Anchor anchor_
Definition: disparity_plugin.h:114
mapviz_plugins::DisparityPlugin::TopicEdited
void TopicEdited()
Definition: disparity_plugin.cpp:200
mapviz_plugins::DisparityPlugin::offset_y_
double offset_y_
Definition: disparity_plugin.h:117
ros.h
mapviz_plugins::DisparityPlugin::BOTTOM_RIGHT
@ BOTTOM_RIGHT
Definition: disparity_plugin.h:74
mapviz_plugins::DisparityPlugin::last_width_
double last_width_
Definition: disparity_plugin.h:123
mapviz_plugins::DisparityPlugin::Anchor
Anchor
Definition: disparity_plugin.h:65
mapviz_plugins::DisparityPlugin::offset_x_
double offset_x_
Definition: disparity_plugin.h:116
mapviz_plugins::DisparityPlugin::TOP_RIGHT
@ TOP_RIGHT
Definition: disparity_plugin.h:68
mapviz_plugins::DisparityPlugin::SelectTopic
void SelectTopic()
Definition: disparity_plugin.cpp:184
mapviz_plugins::DisparityPlugin::units_
Units units_
Definition: disparity_plugin.h:115
mapviz_plugins::DisparityPlugin::LoadConfig
void LoadConfig(const YAML::Node &node, const std::string &path)
Definition: disparity_plugin.cpp:447
mapviz_plugins::DisparityPlugin::UnitsToString
std::string UnitsToString(Units units)
Definition: disparity_plugin.cpp:553
mapviz_plugins::DisparityPlugin::TOP_LEFT
@ TOP_LEFT
Definition: disparity_plugin.h:66
mapviz_plugins::DisparityPlugin::scaled_image_
cv::Mat scaled_image_
Definition: disparity_plugin.h:132
mapviz_plugins::DisparityPlugin::COLOR_MAP
const static unsigned char COLOR_MAP[]
Definition: disparity_plugin.h:142
mapviz_plugins::DisparityPlugin::last_height_
double last_height_
Definition: disparity_plugin.h:124
mapviz_plugins::DisparityPlugin::Transform
void Transform()
Definition: disparity_plugin.h:86
mapviz_plugins::DisparityPlugin::config_widget_
QWidget * config_widget_
Definition: disparity_plugin.h:111
mapviz_plugins::DisparityPlugin
Definition: disparity_plugin.h:60
mapviz_plugins::DisparityPlugin::disparity_sub_
ros::Subscriber disparity_sub_
Definition: disparity_plugin.h:126
mapviz_plugins::DisparityPlugin::SetUnits
void SetUnits(QString units)
Definition: disparity_plugin.cpp:155
mapviz_plugins::DisparityPlugin::disparity_color_
cv::Mat_< cv::Vec3b > disparity_color_
Definition: disparity_plugin.h:131
mapviz_plugins::DisparityPlugin::Shutdown
void Shutdown()
Definition: disparity_plugin.h:82
mapviz_plugins::DisparityPlugin::SetOffsetY
void SetOffsetY(int offset)
Definition: disparity_plugin.cpp:100
mapviz_plugins::DisparityPlugin::GetConfigWidget
QWidget * GetConfigWidget(QWidget *parent)
Definition: disparity_plugin.cpp:303
mapviz_plugins::DisparityPlugin::ScaleImage
void ScaleImage(double width, double height)
Definition: disparity_plugin.cpp:317
mapviz_plugins::DisparityPlugin::BOTTOM_CENTER
@ BOTTOM_CENTER
Definition: disparity_plugin.h:73
mapviz_plugins::DisparityPlugin::ui_
Ui::disparity_config ui_
Definition: disparity_plugin.h:110
mapviz_plugins::DisparityPlugin::width_
double width_
Definition: disparity_plugin.h:118
mapviz_plugins::DisparityPlugin::has_image_
bool has_image_
Definition: disparity_plugin.h:121
mapviz_plugins::DisparityPlugin::TOP_CENTER
@ TOP_CENTER
Definition: disparity_plugin.h:67
mapviz_plugins::DisparityPlugin::disparity_
stereo_msgs::DisparityImage disparity_
Definition: disparity_plugin.h:129
mapviz_plugins::DisparityPlugin::PIXELS
@ PIXELS
Definition: disparity_plugin.h:76
transform_datatypes.h
mapviz_plugins::DisparityPlugin::~DisparityPlugin
virtual ~DisparityPlugin()
Definition: disparity_plugin.cpp:91
mapviz_plugins::DisparityPlugin::PrintError
void PrintError(const std::string &message)
Definition: disparity_plugin.cpp:288
cv_bridge.h
mapviz_plugins::DisparityPlugin::Draw
void Draw(double x, double y, double scale)
Definition: disparity_plugin.cpp:362
mapviz_plugins::DisparityPlugin::height_
double height_
Definition: disparity_plugin.h:119
mapviz::MapvizPlugin
mapviz_plugins::DisparityPlugin::AnchorToString
std::string AnchorToString(Anchor anchor)
Definition: disparity_plugin.cpp:509
mapviz_plugins::DisparityPlugin::SetHeight
void SetHeight(int height)
Definition: disparity_plugin.cpp:110
mapviz_plugins::DisparityPlugin::Initialize
bool Initialize(QGLWidget *canvas)
Definition: disparity_plugin.cpp:310
mapviz_plugins::DisparityPlugin::PrintWarning
void PrintWarning(const std::string &message)
Definition: disparity_plugin.cpp:298
mapviz_plugins::DisparityPlugin::PERCENT
@ PERCENT
Definition: disparity_plugin.h:76
mapviz_plugins::DisparityPlugin::SetOffsetX
void SetOffsetX(int offset)
Definition: disparity_plugin.cpp:95
mapviz_plugins
Definition: attitude_indicator_plugin.h:61
mapviz_plugins::DisparityPlugin::DrawIplImage
void DrawIplImage(cv::Mat *image)
Definition: disparity_plugin.cpp:327
map_canvas.h
ros::Subscriber
mapviz_plugins::DisparityPlugin::CENTER_RIGHT
@ CENTER_RIGHT
Definition: disparity_plugin.h:71
mapviz_plugins::DisparityPlugin::has_message_
bool has_message_
Definition: disparity_plugin.h:127
mapviz_plugins::DisparityPlugin::CENTER_LEFT
@ CENTER_LEFT
Definition: disparity_plugin.h:69
mapviz_plugin.h


mapviz_plugins
Author(s): Marc Alban
autogenerated on Sun Sep 8 2024 02:27:14