Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef IMAGEVIEW_H_
00029 #define IMAGEVIEW_H_
00030
00031 #include "rtabmap/gui/RtabmapGuiExp.h"
00032
00033 #include <QGraphicsView>
00034 #include <QtCore/QRectF>
00035 #include <QtCore/QMultiMap>
00036 #include <QtCore/QSettings>
00037 #include <opencv2/features2d/features2d.hpp>
00038 #include <map>
00039
00040 class QAction;
00041 class QMenu;
00042
00043 namespace rtabmap {
00044
00045 class KeypointItem;
00046
00047 class RTABMAPGUI_EXP ImageView : public QWidget {
00048
00049 Q_OBJECT
00050
00051 public:
00052 ImageView(QWidget * parent = 0);
00053 virtual ~ImageView();
00054
00055 void saveSettings(QSettings & settings, const QString & group = "") const;
00056 void loadSettings(QSettings & settings, const QString & group = "");
00057
00058 bool isImageShown() const;
00059 bool isImageDepthShown() const;
00060 bool isFeaturesShown() const;
00061 bool isLinesShown() const;
00062 int getAlpha() const {return _alpha;}
00063 bool isGraphicsViewMode() const;
00064 bool isGraphicsViewScaled() const;
00065 const QColor & getBackgroundColor() const;
00066
00067 float viewScale() const;
00068
00069 void setFeaturesShown(bool shown);
00070 void setImageShown(bool shown);
00071 void setImageDepthShown(bool shown);
00072 void setLinesShown(bool shown);
00073 void setGraphicsViewMode(bool on);
00074 void setGraphicsViewScaled(bool scaled);
00075 void setBackgroundColor(const QColor & color);
00076
00077 void setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
00078 void setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth = cv::Mat(), const QColor & color = Qt::yellow);
00079 void addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color);
00080 void addLine(float x1, float y1, float x2, float y2, QColor color);
00081 void setImage(const QImage & image);
00082 void setImageDepth(const QImage & image);
00083 void setFeatureColor(int id, QColor color);
00084 void setFeaturesColor(QColor color);
00085 void setAlpha(int alpha);
00086 void setSceneRect(const QRectF & rect);
00087
00088 const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
00089
00090 void clearLines();
00091 void clear();
00092
00093 virtual QSize sizeHint() const;
00094
00095 signals:
00096 void configChanged();
00097
00098 protected:
00099 virtual void paintEvent(QPaintEvent *event);
00100 virtual void resizeEvent(QResizeEvent* event);
00101 virtual void contextMenuEvent(QContextMenuEvent * e);
00102
00103 private slots:
00104 void sceneRectChanged(const QRectF &rect);
00105
00106 private:
00107 void updateOpacity();
00108 void computeScaleOffsets(const QRect & targetRect, float & scale, float & offsetX, float & offsetY) const;
00109
00110 private:
00111 QString _savedFileName;
00112 int _alpha;
00113
00114 QMenu * _menu;
00115 QAction * _showImage;
00116 QAction * _showImageDepth;
00117 QAction * _showFeatures;
00118 QAction * _showLines;
00119 QAction * _saveImage;
00120 QAction * _setAlpha;
00121 QAction * _graphicsViewMode;
00122 QAction * _graphicsViewScaled;
00123
00124 QGraphicsView * _graphicsView;
00125 QMultiMap<int, rtabmap::KeypointItem *> _features;
00126 QList<QGraphicsLineItem*> _lines;
00127 QGraphicsPixmapItem * _imageItem;
00128 QGraphicsPixmapItem * _imageDepthItem;
00129 QPixmap _image;
00130 QPixmap _imageDepth;
00131 };
00132
00133 }
00134
00135 #endif