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_
void PrintInfo(const std::string &message)
void disparityCallback(const stereo_msgs::DisparityImageConstPtr &image)
void Draw(double x, double y, double scale)
void PrintError(const std::string &message)
void PrintWarning(const std::string &message)
std::string UnitsToString(Units units)
cv::Mat_< cv::Vec3b > disparity_color_
bool Initialize(QGLWidget *canvas)
std::string AnchorToString(Anchor anchor)
void ScaleImage(double width, double height)
static const unsigned char COLOR_MAP[]
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
stereo_msgs::DisparityImage disparity_
void LoadConfig(const YAML::Node &node, const std::string &path)
QWidget * GetConfigWidget(QWidget *parent)


mapviz_plugins
Author(s): Marc Alban
autogenerated on Fri Dec 16 2022 03:59:33