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/RtabmapGuiExp.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"
40 
41 class QAction;
42 class QMenu;
43 
44 namespace rtabmap {
45 
46 class KeypointItem;
47 
48 class RTABMAPGUI_EXP ImageView : public QWidget {
49 
50  Q_OBJECT
51 
52 public:
53  ImageView(QWidget * parent = 0);
54  virtual ~ImageView();
55 
56  void saveSettings(QSettings & settings, const QString & group = "") const;
57  void loadSettings(QSettings & settings, const QString & group = "");
58 
59  QRectF sceneRect() const;
60  bool isImageShown() const;
61  bool isImageDepthShown() const;
62  bool isFeaturesShown() const;
63  bool isLinesShown() const;
64  int getAlpha() const {return _alpha;}
65  int getFeaturesSize() const {return _featuresSize;}
66  int getLinesWidth() const {return _linesWidth;}
67  bool isGraphicsViewMode() const;
68  bool isGraphicsViewScaled() const;
69  bool isGraphicsViewScaledToHeight() const;
70  const QColor & getDefaultBackgroundColor() const;
71  const QColor & getDefaultFeatureColor() const;
72  const QColor & getDefaultMatchingFeatureColor() const;
73  const QColor & getDefaultMatchingLineColor() const;
74  const QColor & getBackgroundColor() const;
75  float getDepthColorMapRange() const;
76  uCvQtDepthColorMap getDepthColorMap() const;
77 
78  float viewScale() const;
79 
80  void setFeaturesShown(bool shown);
81  void setImageShown(bool shown);
82  void setImageDepthShown(bool shown);
83  void setLinesShown(bool shown);
84  void setGraphicsViewMode(bool on);
85  void setGraphicsViewScaled(bool scaled);
86  void setGraphicsViewScaledToHeight(bool scaled);
87  void setDefaultBackgroundColor(const QColor & color);
88  void setDefaultFeatureColor(const QColor & color);
89  void setDefaultMatchingFeatureColor(const QColor & color);
90  void setDefaultMatchingLineColor(const QColor & color);
91  void setBackgroundColor(const QColor & color);
92  void setDepthColorMapRange(float value);
93 
94  void setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
95  void setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
96  void addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color);
97  void addLine(float x1, float y1, float x2, float y2, QColor color, const QString & text = QString());
98  void setImage(const QImage & image);
99  void setImageDepth(const cv::Mat & imageDepth);
100  void setImageDepth(const QImage & image);
101  void setFeatureColor(int id, QColor color);
102  void setFeaturesColor(QColor color);
103  void setAlpha(int alpha);
104  void setFeaturesSize(int size);
105  void setLinesWidth(int width);
106  void setSceneRect(const QRectF & rect);
107 
108  const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
109 
110  void clearLines();
111  void clearFeatures();
112  void clear();
113 
114  virtual QSize sizeHint() const;
115 
116 Q_SIGNALS:
117  void configChanged();
118 
119 protected:
120  virtual void paintEvent(QPaintEvent *event);
121  virtual void resizeEvent(QResizeEvent* event);
122  virtual void contextMenuEvent(QContextMenuEvent * e);
123 
124 private Q_SLOTS:
125  void sceneRectChanged(const QRectF &rect);
126 
127 private:
128  void updateOpacity();
129  void computeScaleOffsets(const QRect & targetRect, float & scale, float & offsetX, float & offsetY) const;
130  QIcon createIcon(const QColor & color);
131 
132 private:
133  QString _savedFileName;
134  int _alpha;
142 
143  QMenu * _menu;
144  QAction * _showImage;
145  QAction * _showImageDepth;
146  QAction * _showFeatures;
147  QAction * _showLines;
148  QAction * _setFeatureColor;
151  QAction * _saveImage;
152  QAction * _setAlpha;
153  QAction * _setFeaturesSize;
154  QAction * _setLinesWidth;
155  QAction * _graphicsViewMode;
163  QAction * _colorMapRange;
164  QMenu * _featureMenu;
165  QMenu * _scaleMenu;
166 
167  QGraphicsView * _graphicsView;
168  QMultiMap<int, rtabmap::KeypointItem *> _features;
169  QList<QGraphicsLineItem*> _lines;
170  QGraphicsPixmapItem * _imageItem;
171  QGraphicsPixmapItem * _imageDepthItem;
172  QPixmap _image;
173  QPixmap _imageDepth;
174  cv::Mat _imageDepthCv;
175 };
176 
177 }
178 
179 #endif /* IMAGEVIEW_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
QMultiMap< int, rtabmap::KeypointItem * > _features
Definition: ImageView.h:168
QAction * _showImageDepth
Definition: ImageView.h:145
int getLinesWidth() const
Definition: ImageView.h:66
QAction * _showLines
Definition: ImageView.h:147
QAction * _setFeaturesSize
Definition: ImageView.h:153
QList< QGraphicsLineItem * > _lines
Definition: ImageView.h:169
GLM_FUNC_DECL genType e()
GLM_FUNC_DECL detail::tmat4x4< T, P > scale(detail::tmat4x4< T, P > const &m, detail::tvec3< T, P > const &v)
QColor _defaultBgColor
Definition: ImageView.h:137
QAction * _setLinesWidth
Definition: ImageView.h:154
QAction * _showImage
Definition: ImageView.h:144
QAction * _graphicsViewScaledToHeight
Definition: ImageView.h:157
QAction * _colorMapRedToBlue
Definition: ImageView.h:161
QAction * _setMatchingFeatureColor
Definition: ImageView.h:149
QGraphicsView * _graphicsView
Definition: ImageView.h:167
QAction * _graphicsViewMode
Definition: ImageView.h:155
QGraphicsPixmapItem * _imageItem
Definition: ImageView.h:170
QAction * _saveImage
Definition: ImageView.h:151
QAction * _colorMapWhiteToBlack
Definition: ImageView.h:159
QColor _defaultMatchingFeatureColor
Definition: ImageView.h:139
QColor _defaultFeatureColor
Definition: ImageView.h:138
QMenu * _scaleMenu
Definition: ImageView.h:165
QPixmap _imageDepth
Definition: ImageView.h:173
QAction * _setMatchingLineColor
Definition: ImageView.h:150
int getFeaturesSize() const
Definition: ImageView.h:65
QAction * _setAlpha
Definition: ImageView.h:152
QAction * _colorMapBlueToRed
Definition: ImageView.h:162
QAction * _colorMapRange
Definition: ImageView.h:163
QAction * _showFeatures
Definition: ImageView.h:146
QIcon createIcon(const QColor &color)
QMenu * _featureMenu
Definition: ImageView.h:164
QAction * _setFeatureColor
Definition: ImageView.h:148
QColor _defaultMatchingLineColor
Definition: ImageView.h:140
QAction * _colorMapBlackToWhite
Definition: ImageView.h:160
uCvQtDepthColorMap
Definition: UCv2Qt.h:30
QString _savedFileName
Definition: ImageView.h:133
float _depthColorMapRange
Definition: ImageView.h:141
QAction * _graphicsViewNoScaling
Definition: ImageView.h:158
cv::Mat _imageDepthCv
Definition: ImageView.h:174
const QMultiMap< int, rtabmap::KeypointItem * > & getFeatures() const
Definition: ImageView.h:108
int getAlpha() const
Definition: ImageView.h:64
QAction * _graphicsViewScaled
Definition: ImageView.h:156
QGraphicsPixmapItem * _imageDepthItem
Definition: ImageView.h:171


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:28