image_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_IMAGE_PLUGIN_H_
31 #define MAPVIZ_PLUGINS_IMAGE_PLUGIN_H_
32 
33 // C++ standard libraries
34 #include <string>
35 #include <list>
36 
37 #include <mapviz/mapviz_plugin.h>
38 
39 // QT libraries
40 #include <QGLWidget>
41 #include <QObject>
42 #include <QWidget>
43 #include <QColor>
44 
45 // ROS libraries
46 #include <ros/ros.h>
47 #include <tf/transform_datatypes.h>
48 #include <sensor_msgs/Image.h>
49 #include <opencv2/highgui.hpp>
50 #include <cv_bridge/cv_bridge.h>
52 
53 #include <mapviz/map_canvas.h>
54 
55 // QT autogenerated files
56 #include "ui_image_config.h"
57 
58 namespace mapviz_plugins
59 {
61  {
62  Q_OBJECT
63 
64  public:
65  enum Anchor {
75  };
76 
77  enum Units {PIXELS, PERCENT};
78 
79  ImagePlugin();
80  virtual ~ImagePlugin();
81 
82  bool Initialize(QGLWidget* canvas);
83  void Shutdown() {}
84 
85  void Draw(double x, double y, double scale);
86 
87  void CreateLocalNode();
88  virtual void SetNode(const ros::NodeHandle& node);
89 
90  void Transform() {}
91 
92  void LoadConfig(const YAML::Node& node, const std::string& path);
93  void SaveConfig(YAML::Emitter& emitter, const std::string& path);
94 
95  QWidget* GetConfigWidget(QWidget* parent);
96 
97  protected:
98  void PrintError(const std::string& message);
99  void PrintInfo(const std::string& message);
100  void PrintWarning(const std::string& message);
101 
102  public Q_SLOTS:
103  void Resubscribe();
104 
105  protected Q_SLOTS:
106  void SelectTopic();
107  void TopicEdited();
108  void SetAnchor(QString anchor);
109  void SetUnits(QString units);
110  void SetOffsetX(int offset);
111  void SetOffsetY(int offset);
112  void SetWidth(double width);
113  void SetHeight(double height);
114  void SetSubscription(bool visible);
115  void SetTransport(const QString& transport);
116  void SetRotation(QString rotation);
117  void KeepRatioChanged(bool checked);
118 
119  private:
120  Ui::image_config ui_;
121  QWidget* config_widget_;
122 
123  std::string topic_;
128  double width_;
129  double height_;
130  std::string transport_;
132 
135 
136  double last_width_;
137  double last_height_;
140 
144 
145  sensor_msgs::Image image_;
146 
148  cv::Mat scaled_image_;
149  cv::Mat rotated_image_;
150 
151  void imageCallback(const sensor_msgs::ImageConstPtr& image);
152 
153  void ScaleImage(double width, double height);
154  void DrawIplImage(cv::Mat *image);
155 
156  std::string AnchorToString(Anchor anchor);
157  std::string UnitsToString(Units units);
158  std::string RotationToString(int rotation);
159  };
160 }
161 
162 #endif // MAPVIZ_PLUGINS_IMAGE_PLUGIN_H_
mapviz_plugins::ImagePlugin::DrawIplImage
void DrawIplImage(cv::Mat *image)
Definition: image_plugin.cpp:410
mapviz_plugins::ImagePlugin::SetNode
virtual void SetNode(const ros::NodeHandle &node)
Definition: image_plugin.cpp:728
mapviz_plugins::ImagePlugin::BOTTOM_RIGHT
@ BOTTOM_RIGHT
Definition: image_plugin.h:74
mapviz_plugins::ImagePlugin::SetOffsetX
void SetOffsetX(int offset)
Definition: image_plugin.cpp:102
mapviz_plugins::ImagePlugin::SetOffsetY
void SetOffsetY(int offset)
Definition: image_plugin.cpp:107
mapviz_plugins::ImagePlugin::units_
Units units_
Definition: image_plugin.h:125
mapviz_plugins::ImagePlugin::Resubscribe
void Resubscribe()
Definition: image_plugin.cpp:251
mapviz_plugins::ImagePlugin::SetTransport
void SetTransport(const QString &transport)
Definition: image_plugin.cpp:215
mapviz_plugins::ImagePlugin
Definition: image_plugin.h:60
mapviz_plugins::ImagePlugin::rotation_
int rotation_
Definition: image_plugin.h:131
boost::shared_ptr< CvImage >
mapviz_plugins::ImagePlugin::CreateLocalNode
void CreateLocalNode()
Definition: image_plugin.cpp:717
mapviz_plugins::ImagePlugin::BOTTOM_CENTER
@ BOTTOM_CENTER
Definition: image_plugin.h:73
mapviz_plugins::ImagePlugin::has_message_
bool has_message_
Definition: image_plugin.h:143
ros.h
mapviz_plugins::ImagePlugin::last_height_
double last_height_
Definition: image_plugin.h:137
mapviz_plugins::ImagePlugin::config_widget_
QWidget * config_widget_
Definition: image_plugin.h:121
mapviz_plugins::ImagePlugin::Shutdown
void Shutdown()
Definition: image_plugin.h:83
mapviz_plugins::ImagePlugin::TOP_RIGHT
@ TOP_RIGHT
Definition: image_plugin.h:68
mapviz_plugins::ImagePlugin::topic_
std::string topic_
Definition: image_plugin.h:123
mapviz_plugins::ImagePlugin::ImagePlugin
ImagePlugin()
Definition: image_plugin.cpp:53
mapviz_plugins::ImagePlugin::scaled_image_
cv::Mat scaled_image_
Definition: image_plugin.h:148
mapviz_plugins::ImagePlugin::Anchor
Anchor
Definition: image_plugin.h:65
mapviz_plugins::ImagePlugin::CENTER
@ CENTER
Definition: image_plugin.h:70
mapviz_plugins::ImagePlugin::last_rotation_
int last_rotation_
Definition: image_plugin.h:138
mapviz_plugins::ImagePlugin::image_sub_
image_transport::Subscriber image_sub_
Definition: image_plugin.h:142
mapviz_plugins::ImagePlugin::BOTTOM_LEFT
@ BOTTOM_LEFT
Definition: image_plugin.h:72
mapviz_plugins::ImagePlugin::PrintError
void PrintError(const std::string &message)
Definition: image_plugin.cpp:371
mapviz_plugins::ImagePlugin::last_width_
double last_width_
Definition: image_plugin.h:136
mapviz_plugins::ImagePlugin::Draw
void Draw(double x, double y, double scale)
Definition: image_plugin.cpp:444
mapviz_plugins::ImagePlugin::TOP_LEFT
@ TOP_LEFT
Definition: image_plugin.h:66
mapviz_plugins::ImagePlugin::UnitsToString
std::string UnitsToString(Units units)
Definition: image_plugin.cpp:690
mapviz_plugins::ImagePlugin::original_aspect_ratio_
double original_aspect_ratio_
Definition: image_plugin.h:139
image_transport::Subscriber
mapviz_plugins::ImagePlugin::height_
double height_
Definition: image_plugin.h:129
mapviz_plugins::ImagePlugin::TOP_CENTER
@ TOP_CENTER
Definition: image_plugin.h:67
mapviz_plugins::ImagePlugin::LoadConfig
void LoadConfig(const YAML::Node &node, const std::string &path)
Definition: image_plugin.cpp:548
mapviz_plugins::ImagePlugin::SelectTopic
void SelectTopic()
Definition: image_plugin.cpp:260
mapviz_plugins::ImagePlugin::local_node_
ros::NodeHandle local_node_
Definition: image_plugin.h:141
mapviz_plugins::ImagePlugin::imageCallback
void imageCallback(const sensor_msgs::ImageConstPtr &image)
Definition: image_plugin.cpp:334
mapviz_plugins::ImagePlugin::SetUnits
void SetUnits(QString units)
Definition: image_plugin.cpp:162
mapviz_plugins::ImagePlugin::rotated_image_
cv::Mat rotated_image_
Definition: image_plugin.h:149
mapviz_plugins::ImagePlugin::Transform
void Transform()
Definition: image_plugin.h:90
mapviz_plugins::ImagePlugin::has_image_
bool has_image_
Definition: image_plugin.h:134
mapviz_plugins::ImagePlugin::RotationToString
std::string RotationToString(int rotation)
Definition: image_plugin.cpp:706
image_transport.h
mapviz_plugins::ImagePlugin::SetRotation
void SetRotation(QString rotation)
Definition: image_plugin.cpp:222
mapviz_plugins::ImagePlugin::TopicEdited
void TopicEdited()
Definition: image_plugin.cpp:278
mapviz_plugins::ImagePlugin::AnchorToString
std::string AnchorToString(Anchor anchor)
Definition: image_plugin.cpp:646
mapviz_plugins::ImagePlugin::KeepRatioChanged
void KeepRatioChanged(bool checked)
Definition: image_plugin.cpp:242
mapviz_plugins::ImagePlugin::SetHeight
void SetHeight(double height)
Definition: image_plugin.cpp:117
transform_datatypes.h
mapviz_plugins::ImagePlugin::CENTER_RIGHT
@ CENTER_RIGHT
Definition: image_plugin.h:71
mapviz_plugins::ImagePlugin::PERCENT
@ PERCENT
Definition: image_plugin.h:77
mapviz_plugins::ImagePlugin::offset_x_
int offset_x_
Definition: image_plugin.h:126
mapviz_plugins::ImagePlugin::~ImagePlugin
virtual ~ImagePlugin()
Definition: image_plugin.cpp:98
mapviz_plugins::ImagePlugin::SetAnchor
void SetAnchor(QString anchor)
Definition: image_plugin.cpp:122
cv_bridge.h
mapviz_plugins::ImagePlugin::ScaleImage
void ScaleImage(double width, double height)
Definition: image_plugin.cpp:400
mapviz::MapvizPlugin
mapviz_plugins::ImagePlugin::width_
double width_
Definition: image_plugin.h:128
mapviz_plugins::ImagePlugin::anchor_
Anchor anchor_
Definition: image_plugin.h:124
mapviz_plugins::ImagePlugin::SaveConfig
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
Definition: image_plugin.cpp:632
mapviz_plugins::ImagePlugin::transport_
std::string transport_
Definition: image_plugin.h:130
mapviz_plugins::ImagePlugin::Units
Units
Definition: image_plugin.h:77
mapviz_plugins::ImagePlugin::cv_image_
cv_bridge::CvImagePtr cv_image_
Definition: image_plugin.h:147
mapviz_plugins
Definition: attitude_indicator_plugin.h:61
mapviz_plugins::ImagePlugin::SetSubscription
void SetSubscription(bool visible)
Definition: image_plugin.cpp:198
mapviz_plugins::ImagePlugin::SetWidth
void SetWidth(double width)
Definition: image_plugin.cpp:112
mapviz_plugins::ImagePlugin::offset_y_
int offset_y_
Definition: image_plugin.h:127
mapviz_plugins::ImagePlugin::PrintInfo
void PrintInfo(const std::string &message)
Definition: image_plugin.cpp:376
mapviz_plugins::ImagePlugin::GetConfigWidget
QWidget * GetConfigWidget(QWidget *parent)
Definition: image_plugin.cpp:386
mapviz_plugins::ImagePlugin::force_resubscribe_
bool force_resubscribe_
Definition: image_plugin.h:133
mapviz_plugins::ImagePlugin::CENTER_LEFT
@ CENTER_LEFT
Definition: image_plugin.h:69
map_canvas.h
mapviz_plugins::ImagePlugin::ui_
Ui::image_config ui_
Definition: image_plugin.h:120
mapviz_plugins::ImagePlugin::PIXELS
@ PIXELS
Definition: image_plugin.h:77
ros::NodeHandle
mapviz_plugins::ImagePlugin::PrintWarning
void PrintWarning(const std::string &message)
Definition: image_plugin.cpp:381
mapviz_plugins::ImagePlugin::image_
sensor_msgs::Image image_
Definition: image_plugin.h:145
mapviz_plugins::ImagePlugin::Initialize
bool Initialize(QGLWidget *canvas)
Definition: image_plugin.cpp:393
mapviz_plugin.h


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