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 OBJWIDGET_H_
00029 #define OBJWIDGET_H_
00030
00031 #include "find_object/FindObjectExp.h"
00032
00033 #include <opencv2/features2d/features2d.hpp>
00034 #include <QtGui/QWidget>
00035 #include <QtCore/QMultiMap>
00036
00037 class QAction;
00038 class QMenu;
00039 class QGraphicsView;
00040 class QGraphicsScene;
00041 class QGraphicsRectItem;
00042 class QGraphicsItem;
00043 class QLabel;
00044
00045 namespace find_object {
00046
00047 class KeypointItem;
00048 class ImageKptsView;
00049
00050 class FINDOBJECT_EXP ObjWidget : public QWidget
00051 {
00052 Q_OBJECT
00053
00054 public:
00055 ObjWidget(QWidget * parent = 0);
00056 ObjWidget(int id, const std::vector<cv::KeyPoint> & keypoints, const QImage & image, QWidget * parent = 0);
00057 virtual ~ObjWidget();
00058
00059 void setId(int id);
00060 void setData(const std::vector<cv::KeyPoint> & keypoints, const QImage & image);
00061 void setTextLabel(const QString & text);
00062 void resetKptsColor();
00063 void setKptColor(int index, const QColor & color);
00064 void setGraphicsViewMode(bool on);
00065 void setAutoScale(bool autoScale);
00066 void setSizedFeatures(bool on);
00067 void setMirrorView(bool on);
00068 void setAlpha(int alpha);
00069 void setDeletable(bool deletable);
00070 void setImageShown(bool shown);
00071 void setFeaturesShown(bool shown);
00072 void addRect(QGraphicsRectItem * rect);
00073 void clearRoiSelection() {mousePressedPos_ = mouseCurrentPos_ = QPoint();update();}
00074
00075 int id() const {return id_;}
00076 const QColor & color() const {return color_;}
00077 const std::vector<cv::KeyPoint> keypoints() const {return keypoints_;}
00078 const QPixmap & pixmap() const {return pixmap_;}
00079 QColor defaultColor() const;
00080 bool isImageShown() const;
00081 bool isFeaturesShown() const;
00082 bool isSizedFeatures() const;
00083 bool isMirrorView() const;
00084
00085 std::vector<cv::KeyPoint> selectedKeypoints() const;
00086 QList<QGraphicsItem*> selectedItems() const;
00087
00088 QPixmap getSceneAsPixmap();
00089
00090 protected:
00091 virtual void paintEvent(QPaintEvent *event);
00092 virtual void contextMenuEvent(QContextMenuEvent * event);
00093 virtual void resizeEvent(QResizeEvent* event);
00094 virtual void mousePressEvent(QMouseEvent * event);
00095 virtual void mouseMoveEvent(QMouseEvent * event);
00096 virtual void mouseReleaseEvent(QMouseEvent * event);
00097
00098 Q_SIGNALS:
00099 void removalTriggered(find_object::ObjWidget *);
00100 void selectionChanged();
00101 void roiChanged(const cv::Rect &);
00102
00103 private:
00104 void setupGraphicsView();
00105 void drawKeypoints(QPainter * painter = 0);
00106 void setupUi();
00107 void updateItemsShown();
00108 void computeScaleOffsets(float & scale, float & offsetX, float & offsetY);
00109
00110 private:
00111 int id_;
00112 std::vector<cv::KeyPoint> keypoints_;
00113 QPixmap pixmap_;
00114 QList<KeypointItem*> keypointItems_;
00115 QGraphicsView * graphicsView_;
00116 QVector<QColor> kptColors_;
00117 QList<QGraphicsRectItem*> rectItems_;
00118 bool graphicsViewInitialized_;
00119 int alpha_;
00120 QLabel * label_;
00121 QColor color_;
00122
00123
00124 QString savedFileName_;
00125 QMenu * menu_;
00126 QAction * showImage_;
00127 QAction * showFeatures_;
00128 QAction * saveImage_;
00129 QAction * mirrorView_;
00130 QAction * delete_;
00131 QAction * graphicsViewMode_;
00132 QAction * autoScale_;
00133 QAction * sizedFeatures_;
00134 QAction * setAlpha_;
00135 QAction * setColor_;
00136
00137
00138 QPoint mousePressedPos_;
00139 QPoint mouseCurrentPos_;
00140 };
00141
00142 }
00143
00144 #endif