2011-10-25 15:48:19 +00:00
|
|
|
/*
|
2011-12-02 18:34:08 +00:00
|
|
|
* Copyright (C) 2011, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
2011-10-25 15:48:19 +00:00
|
|
|
*/
|
|
|
|
|
|
2011-11-15 16:37:40 +00:00
|
|
|
#ifndef OBJWIDGET_H_
|
|
|
|
|
#define OBJWIDGET_H_
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
#include <opencv2/features2d/features2d.hpp>
|
|
|
|
|
#include <QtGui/QWidget>
|
|
|
|
|
|
|
|
|
|
class KeypointItem;
|
|
|
|
|
class ImageKptsView;
|
|
|
|
|
class QAction;
|
|
|
|
|
class QMenu;
|
|
|
|
|
class QGraphicsView;
|
|
|
|
|
class QGraphicsScene;
|
2011-11-09 15:07:19 +00:00
|
|
|
class QGraphicsRectItem;
|
|
|
|
|
class QGraphicsItem;
|
2012-02-04 22:15:32 +00:00
|
|
|
class QLabel;
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2011-11-15 16:37:40 +00:00
|
|
|
class ObjWidget : public QWidget
|
2011-10-25 15:48:19 +00:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2011-11-15 16:37:40 +00:00
|
|
|
ObjWidget(QWidget * parent = 0);
|
|
|
|
|
ObjWidget(int id,
|
2011-10-25 15:48:19 +00:00
|
|
|
const std::vector<cv::KeyPoint> & keypoints,
|
|
|
|
|
const cv::Mat & descriptors,
|
|
|
|
|
const IplImage * image,
|
|
|
|
|
const QString & detectorType = "NA",
|
|
|
|
|
const QString & descriptorType = "NA",
|
|
|
|
|
QWidget * parent = 0);
|
2011-11-15 16:37:40 +00:00
|
|
|
virtual ~ObjWidget();
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
void setId(int id);
|
|
|
|
|
void setData(const std::vector<cv::KeyPoint> & keypoints,
|
|
|
|
|
const cv::Mat & descriptors,
|
2012-01-28 01:00:23 +00:00
|
|
|
const IplImage * image,
|
|
|
|
|
const QString & detectorType,
|
|
|
|
|
const QString & descriptorType);
|
2012-02-04 22:15:32 +00:00
|
|
|
void setTextLabel(const QString & text);
|
2011-10-25 15:48:19 +00:00
|
|
|
void resetKptsColor();
|
2011-11-23 18:08:33 +00:00
|
|
|
void setKptColor(int index, const QColor & color);
|
2011-10-25 15:48:19 +00:00
|
|
|
void setGraphicsViewMode(bool on);
|
2011-11-17 20:31:08 +00:00
|
|
|
void setAutoScale(bool autoScale);
|
2011-11-18 16:09:23 +00:00
|
|
|
void setSizedFeatures(bool on);
|
2012-01-28 01:00:23 +00:00
|
|
|
void setMirrorView(bool on);
|
2011-11-18 16:09:23 +00:00
|
|
|
void setAlpha(int alpha);
|
2011-10-25 15:48:19 +00:00
|
|
|
void setDeletable(bool deletable);
|
2011-11-09 15:07:19 +00:00
|
|
|
void addRect(QGraphicsRectItem * rect);
|
2012-01-28 01:00:23 +00:00
|
|
|
void clearRoiSelection() {mousePressedPos_ = mouseCurrentPos_ = QPoint();update();}
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
const std::vector<cv::KeyPoint> & keypoints() const {return keypoints_;}
|
|
|
|
|
const cv::Mat & descriptors() const {return descriptors_;}
|
|
|
|
|
const QPixmap & image() const {return image_;}
|
|
|
|
|
const IplImage * iplImage() const {return iplImage_;}
|
|
|
|
|
int id() const {return id_;}
|
|
|
|
|
QColor defaultColor() const;
|
|
|
|
|
bool isImageShown() const;
|
|
|
|
|
bool isFeaturesShown() const;
|
2012-01-28 01:00:23 +00:00
|
|
|
bool isSizedFeatures() const;
|
2011-10-25 15:48:19 +00:00
|
|
|
bool isMirrorView() const;
|
2011-11-09 15:07:19 +00:00
|
|
|
//QGraphicsScene * scene() const;
|
2011-10-25 15:48:19 +00:00
|
|
|
std::vector<cv::KeyPoint> selectedKeypoints() const;
|
|
|
|
|
const QString & detectorType() const {return detectorType_;}
|
|
|
|
|
const QString & descriptorType() const {return descriptorType_;}
|
2011-11-09 15:07:19 +00:00
|
|
|
QList<QGraphicsItem*> selectedItems() const;
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
QPixmap getSceneAsPixmap();
|
|
|
|
|
|
|
|
|
|
void save(QDataStream & streamPtr) const;
|
|
|
|
|
void load(QDataStream & streamPtr);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void paintEvent(QPaintEvent *event);
|
|
|
|
|
virtual void contextMenuEvent(QContextMenuEvent * event);
|
|
|
|
|
virtual void resizeEvent(QResizeEvent* event);
|
2012-01-28 01:00:23 +00:00
|
|
|
virtual void mousePressEvent(QMouseEvent * event);
|
|
|
|
|
virtual void mouseMoveEvent(QMouseEvent * event);
|
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent * event);
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
signals:
|
2011-11-15 16:37:40 +00:00
|
|
|
void removalTriggered(ObjWidget *);
|
2011-11-09 15:07:19 +00:00
|
|
|
void selectionChanged();
|
2012-01-28 01:00:23 +00:00
|
|
|
void roiChanged(const QRect &);
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void setupGraphicsView();
|
|
|
|
|
void drawKeypoints(QPainter * painter = 0);
|
|
|
|
|
void setupUi();
|
|
|
|
|
void updateItemsShown();
|
2012-01-28 01:00:23 +00:00
|
|
|
void computeScaleOffsets(float & scale, float & offsetX, float & offsetY);
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::vector<cv::KeyPoint> keypoints_;
|
|
|
|
|
cv::Mat descriptors_;
|
|
|
|
|
QPixmap image_;
|
|
|
|
|
IplImage * iplImage_;
|
|
|
|
|
QList<KeypointItem*> keypointItems_;
|
|
|
|
|
QGraphicsView * graphicsView_;
|
|
|
|
|
int id_;
|
|
|
|
|
QVector<QColor> kptColors_;
|
|
|
|
|
QString detectorType_;
|
|
|
|
|
QString descriptorType_;
|
2011-11-09 15:07:19 +00:00
|
|
|
QList<QGraphicsRectItem*> rectItems_;
|
2011-11-17 20:31:08 +00:00
|
|
|
bool graphicsViewInitialized_;
|
2011-11-18 16:09:23 +00:00
|
|
|
int alpha_;
|
2012-02-04 22:15:32 +00:00
|
|
|
QLabel * label_;
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
// menu stuff
|
2012-04-04 18:15:51 +00:00
|
|
|
QString savedFileName_;
|
|
|
|
|
QMenu * menu_;
|
|
|
|
|
QAction * showImage_;
|
|
|
|
|
QAction * showFeatures_;
|
|
|
|
|
QAction * saveImage_;
|
|
|
|
|
QAction * mirrorView_;
|
|
|
|
|
QAction * delete_;
|
|
|
|
|
QAction * graphicsViewMode_;
|
|
|
|
|
QAction * autoScale_;
|
|
|
|
|
QAction * sizedFeatures_;
|
|
|
|
|
QAction * setAlpha_;
|
2012-01-28 01:00:23 +00:00
|
|
|
|
|
|
|
|
// selection stuff
|
|
|
|
|
QPoint mousePressedPos_;
|
|
|
|
|
QPoint mouseCurrentPos_;
|
2011-10-25 15:48:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-11-15 16:37:40 +00:00
|
|
|
#endif /* OBJWIDGET_H_ */
|