2011-10-25 15:48:19 +00:00
|
|
|
/*
|
2011-11-15 16:37:40 +00:00
|
|
|
* ObjWidget.h
|
2011-10-25 15:48:19 +00:00
|
|
|
*
|
|
|
|
|
* Created on: 2011-10-21
|
|
|
|
|
* Author: matlab
|
|
|
|
|
*/
|
|
|
|
|
|
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;
|
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,
|
|
|
|
|
const IplImage * image);
|
|
|
|
|
void resetKptsColor();
|
|
|
|
|
void setKptColor(unsigned int index, const QColor & color);
|
|
|
|
|
void setGraphicsViewMode(bool on);
|
2011-11-17 20:31:08 +00:00
|
|
|
void setAutoScale(bool autoScale);
|
2011-10-25 15:48:19 +00:00
|
|
|
void setDeletable(bool deletable);
|
2011-11-09 15:07:19 +00:00
|
|
|
void addRect(QGraphicsRectItem * rect);
|
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;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
signals:
|
2011-11-15 16:37:40 +00:00
|
|
|
void removalTriggered(ObjWidget *);
|
2011-11-09 15:07:19 +00:00
|
|
|
void selectionChanged();
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void setupGraphicsView();
|
|
|
|
|
void drawKeypoints(QPainter * painter = 0);
|
|
|
|
|
void setupUi();
|
|
|
|
|
void updateItemsShown();
|
|
|
|
|
|
|
|
|
|
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-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
// menu stuff
|
|
|
|
|
QString _savedFileName;
|
|
|
|
|
QMenu * _menu;
|
|
|
|
|
QAction * _showImage;
|
|
|
|
|
QAction * _showFeatures;
|
|
|
|
|
QAction * _saveImage;
|
|
|
|
|
QAction * _mirrorView;
|
|
|
|
|
QAction * _delete;
|
2011-11-17 20:31:08 +00:00
|
|
|
QAction * _graphicsViewMode;
|
|
|
|
|
QAction * _autoScale;
|
2011-10-25 15:48:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-11-15 16:37:40 +00:00
|
|
|
#endif /* OBJWIDGET_H_ */
|