ImageView.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef RTABMAP_IMAGEVIEW_H_
29 #define RTABMAP_IMAGEVIEW_H_
30 
31 #include "rtabmap/gui/rtabmap_gui_export.h" // DLL export/import defines
32 
33 #include <QGraphicsView>
34 #include <QtCore/QRectF>
35 #include <QtCore/QMultiMap>
36 #include <QtCore/QSettings>
37 #include <opencv2/features2d/features2d.hpp>
38 #include <map>
39 #include "rtabmap/utilite/UCv2Qt.h"
41 
42 class QAction;
43 class QMenu;
44 
45 namespace rtabmap {
46 
47 class KeypointItem;
48 
49 class RTABMAP_GUI_EXPORT ImageView : public QWidget {
50 
51  Q_OBJECT
52 
53 public:
54  ImageView(QWidget * parent = 0);
55  virtual ~ImageView();
56 
57  void saveSettings(QSettings & settings, const QString & group = "") const;
58  void loadSettings(QSettings & settings, const QString & group = "");
59 
60  QRectF sceneRect() const;
61  bool isImageShown() const;
62  bool isImageDepthShown() const;
63  bool isFeaturesShown() const;
64  bool isLinesShown() const;
65  int getAlpha() const {return _alpha;}
66  int getFeaturesSize() const {return _featuresSize;}
67  int getLinesWidth() const {return _linesWidth;}
68  bool isGraphicsViewMode() const;
69  bool isGraphicsViewScaled() const;
70  bool isGraphicsViewScaledToHeight() const;
71  const QColor & getDefaultBackgroundColor() const;
72  const QColor & getDefaultFeatureColor() const;
73  const QColor & getDefaultMatchingFeatureColor() const;
74  const QColor & getDefaultMatchingLineColor() const;
75  const QColor & getBackgroundColor() const;
76  float getDepthColorMapMinRange() const;
77  float getDepthColorMapMaxRange() const;
78  uCvQtDepthColorMap getDepthColorMap() const;
79 
80  float viewScale() const;
81 
82  void setFeaturesShown(bool shown);
83  void setImageShown(bool shown);
84  void setImageDepthShown(bool shown);
85  void setLinesShown(bool shown);
86  void setGraphicsViewMode(bool on);
87  void setGraphicsViewScaled(bool scaled);
88  void setGraphicsViewScaledToHeight(bool scaled);
89  void setDefaultBackgroundColor(const QColor & color);
90  void setDefaultFeatureColor(const QColor & color);
91  void setDefaultMatchingFeatureColor(const QColor & color);
92  void setDefaultMatchingLineColor(const QColor & color);
93  void setBackgroundColor(const QColor & color);
94  void setDepthColorMapRange(float min, float max);
95 
96  void setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
97  void setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
98  void addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color);
99  void addLine(float x1, float y1, float x2, float y2, QColor color, const QString & text = QString());
100  void setImage(const QImage & image, const std::vector<CameraModel> & models = std::vector<CameraModel>(), const Transform & pose = Transform());
101  void setImageDepth(const cv::Mat & imageDepth);
102  void setImageDepth(const QImage & image);
103  void setFeatureColor(int id, QColor color);
104  void setFeaturesColor(QColor color);
105  void setAlpha(int alpha);
106  void setFeaturesSize(int size);
107  void setLinesWidth(int width);
108  void setSceneRect(const QRectF & rect);
109 
110  const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
111 
112  void clearLines();
113  void clearFeatures();
114  void clear();
115 
116  virtual QSize sizeHint() const;
117 
118 Q_SIGNALS:
119  void configChanged();
120 
121 protected:
122  virtual void paintEvent(QPaintEvent *event);
123  virtual void resizeEvent(QResizeEvent* event);
124  virtual void contextMenuEvent(QContextMenuEvent * e);
125  virtual void mouseMoveEvent(QMouseEvent * event);
126 
127 private Q_SLOTS:
128  void sceneRectChanged(const QRectF &rect);
129 
130 private:
131  void updateOpacity();
132  void computeScaleOffsets(const QRect & targetRect, float & scale, float & offsetX, float & offsetY) const;
133  QIcon createIcon(const QColor & color);
134 
135 private:
136  QString _savedFileName;
137  int _alpha;
146 
147  QMenu * _menu;
148  QAction * _showImage;
149  QAction * _showImageDepth;
150  QAction * _showFeatures;
151  QAction * _showLines;
152  QAction * _setFeatureColor;
155  QAction * _saveImage;
156  QAction * _setAlpha;
157  QAction * _setFeaturesSize;
158  QAction * _setLinesWidth;
159  QAction * _graphicsViewMode;
167  QAction * _colorMapMinRange;
168  QAction * _colorMapMaxRange;
169  QAction * _mouseTracking;
170  QMenu * _featureMenu;
171  QMenu * _scaleMenu;
172 
173  QGraphicsView * _graphicsView;
174  QMultiMap<int, rtabmap::KeypointItem *> _features;
175  QList<QGraphicsLineItem*> _lines;
176  QGraphicsPixmapItem * _imageItem;
177  QGraphicsPixmapItem * _imageDepthItem;
178  QPixmap _image;
179  QPixmap _imageDepth;
180  cv::Mat _imageDepthCv;
181  std::vector<CameraModel> _models;
183 };
184 
185 }
186 
187 #endif /* IMAGEVIEW_H_ */
glm::min
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
rtabmap::ImageView::_setLinesWidth
QAction * _setLinesWidth
Definition: ImageView.h:158
rtabmap::ImageView::_image
QPixmap _image
Definition: ImageView.h:178
rtabmap::ImageView::_showFeatures
QAction * _showFeatures
Definition: ImageView.h:150
rtabmap::ImageView::_setFeatureColor
QAction * _setFeatureColor
Definition: ImageView.h:152
rtabmap::ImageView::_showImage
QAction * _showImage
Definition: ImageView.h:148
rtabmap::ImageView::_graphicsView
QGraphicsView * _graphicsView
Definition: ImageView.h:173
rtabmap::ImageView::_colorMapWhiteToBlack
QAction * _colorMapWhiteToBlack
Definition: ImageView.h:163
rtabmap::ImageView::_linesWidth
int _linesWidth
Definition: ImageView.h:139
rtabmap::ImageView::_showImageDepth
QAction * _showImageDepth
Definition: ImageView.h:149
rtabmap::ImageView::_defaultFeatureColor
QColor _defaultFeatureColor
Definition: ImageView.h:141
rtabmap::ImageView::_imageDepthItem
QGraphicsPixmapItem * _imageDepthItem
Definition: ImageView.h:177
uCvQtDepthColorMap
uCvQtDepthColorMap
Definition: UCv2Qt.h:30
rtabmap::ImageView::_scaleMenu
QMenu * _scaleMenu
Definition: ImageView.h:171
rtabmap::ImageView::_showLines
QAction * _showLines
Definition: ImageView.h:151
rtabmap::ImageView::_colorMapMaxRange
QAction * _colorMapMaxRange
Definition: ImageView.h:168
rtabmap::ImageView::_setMatchingFeatureColor
QAction * _setMatchingFeatureColor
Definition: ImageView.h:153
rtabmap::ImageView::_colorMapMinRange
QAction * _colorMapMinRange
Definition: ImageView.h:167
rtabmap::ImageView::_graphicsViewMode
QAction * _graphicsViewMode
Definition: ImageView.h:159
rtabmap::ImageView::getFeaturesSize
int getFeaturesSize() const
Definition: ImageView.h:66
rtabmap::ImageView::_setFeaturesSize
QAction * _setFeaturesSize
Definition: ImageView.h:157
rtabmap::ImageView::_setAlpha
QAction * _setAlpha
Definition: ImageView.h:156
rtabmap::ImageView::_menu
QMenu * _menu
Definition: ImageView.h:147
rtabmap::ImageView::_imageDepth
QPixmap _imageDepth
Definition: ImageView.h:179
rtabmap::ImageView::_defaultBgColor
QColor _defaultBgColor
Definition: ImageView.h:140
rtabmap::ImageView::_depthColorMapMaxRange
float _depthColorMapMaxRange
Definition: ImageView.h:145
rtabmap::ImageView::_colorMapRedToBlue
QAction * _colorMapRedToBlue
Definition: ImageView.h:165
rtabmap::ImageView::_lines
QList< QGraphicsLineItem * > _lines
Definition: ImageView.h:175
rtabmap::ImageView::_graphicsViewScaledToHeight
QAction * _graphicsViewScaledToHeight
Definition: ImageView.h:161
rtabmap::ImageView::_models
std::vector< CameraModel > _models
Definition: ImageView.h:181
glm::max
GLM_FUNC_DECL genType max(genType const &x, genType const &y)
UCv2Qt.h
rtabmap::ImageView::_colorMapBlueToRed
QAction * _colorMapBlueToRed
Definition: ImageView.h:166
rtabmap::ImageView::_defaultMatchingLineColor
QColor _defaultMatchingLineColor
Definition: ImageView.h:143
rtabmap::ImageView::_saveImage
QAction * _saveImage
Definition: ImageView.h:155
rtabmap::ImageView::_savedFileName
QString _savedFileName
Definition: ImageView.h:136
rtabmap::ImageView::getFeatures
const QMultiMap< int, rtabmap::KeypointItem * > & getFeatures() const
Definition: ImageView.h:110
rtabmap::ImageView::_colorMapBlackToWhite
QAction * _colorMapBlackToWhite
Definition: ImageView.h:164
rtabmap::ImageView::_featureMenu
QMenu * _featureMenu
Definition: ImageView.h:170
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
rtabmap::ImageView::_alpha
int _alpha
Definition: ImageView.h:137
rtabmap::Transform
Definition: Transform.h:41
rtabmap::createIcon
QIcon createIcon(const QColor &color)
Definition: GraphViewer.cpp:1838
rtabmap::ImageView::_defaultMatchingFeatureColor
QColor _defaultMatchingFeatureColor
Definition: ImageView.h:142
rtabmap::ImageView::_featuresSize
int _featuresSize
Definition: ImageView.h:138
rtabmap::ImageView::_graphicsViewNoScaling
QAction * _graphicsViewNoScaling
Definition: ImageView.h:162
rtabmap::ImageView::_imageDepthCv
cv::Mat _imageDepthCv
Definition: ImageView.h:180
rtabmap::ImageView::_imageItem
QGraphicsPixmapItem * _imageItem
Definition: ImageView.h:176
rtabmap::ImageView::_depthColorMapMinRange
float _depthColorMapMinRange
Definition: ImageView.h:144
rtabmap::ImageView::_mouseTracking
QAction * _mouseTracking
Definition: ImageView.h:169
rtabmap::ImageView::getAlpha
int getAlpha() const
Definition: ImageView.h:65
rtabmap::ImageView::_pose
Transform _pose
Definition: ImageView.h:182
rtabmap::ImageView
Definition: ImageView.h:49
rtabmap::ImageView::getLinesWidth
int getLinesWidth() const
Definition: ImageView.h:67
rtabmap::ImageView::_features
QMultiMap< int, rtabmap::KeypointItem * > _features
Definition: ImageView.h:174
rtabmap::ImageView::_setMatchingLineColor
QAction * _setMatchingLineColor
Definition: ImageView.h:154
CameraModel.h
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::ImageView::_graphicsViewScaled
QAction * _graphicsViewScaled
Definition: ImageView.h:160


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:11