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  bool isGraphicsViewMode() const;
67  bool isGraphicsViewScaled() const;
68  bool isGraphicsViewScaledToHeight() const;
69  const QColor & getDefaultBackgroundColor() const;
70  const QColor & getDefaultFeatureColor() const;
71  const QColor & getDefaultMatchingFeatureColor() const;
72  const QColor & getDefaultMatchingLineColor() const;
73  const QColor & getBackgroundColor() const;
74  uCvQtDepthColorMap getDepthColorMap() const;
75 
76  float viewScale() const;
77 
78  void setFeaturesShown(bool shown);
79  void setImageShown(bool shown);
80  void setImageDepthShown(bool shown);
81  void setLinesShown(bool shown);
82  void setGraphicsViewMode(bool on);
83  void setGraphicsViewScaled(bool scaled);
84  void setGraphicsViewScaledToHeight(bool scaled);
85  void setDefaultBackgroundColor(const QColor & color);
86  void setDefaultFeatureColor(const QColor & color);
87  void setDefaultMatchingFeatureColor(const QColor & color);
88  void setDefaultMatchingLineColor(const QColor & color);
89  void setBackgroundColor(const QColor & color);
90 
91  void setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
92  void setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
93  void addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color);
94  void addLine(float x1, float y1, float x2, float y2, QColor color, const QString & text = QString());
95  void setImage(const QImage & image);
96  void setImageDepth(const cv::Mat & imageDepth);
97  void setImageDepth(const QImage & image);
98  void setFeatureColor(int id, QColor color);
99  void setFeaturesColor(QColor color);
100  void setAlpha(int alpha);
101  void setFeaturesSize(int size);
102  void setSceneRect(const QRectF & rect);
103 
104  const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
105 
106  void clearLines();
107  void clearFeatures();
108  void clear();
109 
110  virtual QSize sizeHint() const;
111 
112 Q_SIGNALS:
113  void configChanged();
114 
115 protected:
116  virtual void paintEvent(QPaintEvent *event);
117  virtual void resizeEvent(QResizeEvent* event);
118  virtual void contextMenuEvent(QContextMenuEvent * e);
119 
120 private Q_SLOTS:
121  void sceneRectChanged(const QRectF &rect);
122 
123 private:
124  void updateOpacity();
125  void computeScaleOffsets(const QRect & targetRect, float & scale, float & offsetX, float & offsetY) const;
126  QIcon createIcon(const QColor & color);
127 
128 private:
129  QString _savedFileName;
130  int _alpha;
136 
137  QMenu * _menu;
138  QAction * _showImage;
139  QAction * _showImageDepth;
140  QAction * _showFeatures;
141  QAction * _showLines;
142  QAction * _setFeatureColor;
145  QAction * _saveImage;
146  QAction * _setAlpha;
147  QAction * _setFeaturesSize;
148  QAction * _graphicsViewMode;
156  QMenu * _featureMenu;
157  QMenu * _scaleMenu;
158 
159  QGraphicsView * _graphicsView;
160  QMultiMap<int, rtabmap::KeypointItem *> _features;
161  QList<QGraphicsLineItem*> _lines;
162  QGraphicsPixmapItem * _imageItem;
163  QGraphicsPixmapItem * _imageDepthItem;
164  QPixmap _image;
165  QPixmap _imageDepth;
166  cv::Mat _imageDepthCv;
167 };
168 
169 }
170 
171 #endif /* IMAGEVIEW_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
QMultiMap< int, rtabmap::KeypointItem * > _features
Definition: ImageView.h:160
QAction * _showImageDepth
Definition: ImageView.h:139
QAction * _showLines
Definition: ImageView.h:141
QAction * _setFeaturesSize
Definition: ImageView.h:147
const QMultiMap< int, rtabmap::KeypointItem * > & getFeatures() const
Definition: ImageView.h:104
QList< QGraphicsLineItem * > _lines
Definition: ImageView.h:161
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:132
QAction * _showImage
Definition: ImageView.h:138
QAction * _graphicsViewScaledToHeight
Definition: ImageView.h:150
QAction * _colorMapRedToBlue
Definition: ImageView.h:154
QAction * _setMatchingFeatureColor
Definition: ImageView.h:143
QGraphicsView * _graphicsView
Definition: ImageView.h:159
QAction * _graphicsViewMode
Definition: ImageView.h:148
QGraphicsPixmapItem * _imageItem
Definition: ImageView.h:162
QAction * _saveImage
Definition: ImageView.h:145
QAction * _colorMapWhiteToBlack
Definition: ImageView.h:152
QColor _defaultMatchingFeatureColor
Definition: ImageView.h:134
QColor _defaultFeatureColor
Definition: ImageView.h:133
QMenu * _scaleMenu
Definition: ImageView.h:157
QPixmap _imageDepth
Definition: ImageView.h:165
QAction * _setMatchingLineColor
Definition: ImageView.h:144
QAction * _setAlpha
Definition: ImageView.h:146
QAction * _colorMapBlueToRed
Definition: ImageView.h:155
QAction * _showFeatures
Definition: ImageView.h:140
QIcon createIcon(const QColor &color)
QMenu * _featureMenu
Definition: ImageView.h:156
int getAlpha() const
Definition: ImageView.h:64
QAction * _setFeatureColor
Definition: ImageView.h:142
QColor _defaultMatchingLineColor
Definition: ImageView.h:135
QAction * _colorMapBlackToWhite
Definition: ImageView.h:153
uCvQtDepthColorMap
Definition: UCv2Qt.h:30
QString _savedFileName
Definition: ImageView.h:129
QAction * _graphicsViewNoScaling
Definition: ImageView.h:151
int getFeaturesSize() const
Definition: ImageView.h:65
cv::Mat _imageDepthCv
Definition: ImageView.h:166
QAction * _graphicsViewScaled
Definition: ImageView.h:149
QGraphicsPixmapItem * _imageDepthItem
Definition: ImageView.h:163


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:59