2011-10-25 15:48:19 +00:00
|
|
|
/*
|
2014-08-06 13:43:29 +00:00
|
|
|
Copyright (c) 2011-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
* Neither the name of the Universite de Sherbrooke nor the
|
|
|
|
|
names of its contributors may be used to endorse or promote products
|
|
|
|
|
derived from this software without specific prior written permission.
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
2014-08-11 15:49:53 +00:00
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
2014-08-06 13:43:29 +00:00
|
|
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
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
|
|
|
|
2014-07-31 20:11:46 +00:00
|
|
|
#include "find_object/FindObjectExp.h" // DLL export/import defines
|
|
|
|
|
|
2011-10-25 15:48:19 +00:00
|
|
|
#include <opencv2/features2d/features2d.hpp>
|
|
|
|
|
#include <QtGui/QWidget>
|
2014-05-11 23:57:08 +00:00
|
|
|
#include <QtCore/QMultiMap>
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-08-06 13:43:29 +00:00
|
|
|
namespace find_object {
|
|
|
|
|
|
|
|
|
|
class KeypointItem;
|
|
|
|
|
class ImageKptsView;
|
|
|
|
|
|
2014-07-31 20:11:46 +00:00
|
|
|
class FINDOBJECT_EXP 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);
|
2015-06-24 18:07:52 -04:00
|
|
|
ObjWidget(int id, const std::vector<cv::KeyPoint> & keypoints, const QMultiMap<int,int> & words, const QImage & image, 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);
|
2015-06-24 18:07:52 -04:00
|
|
|
void updateImage(const QImage & image);
|
|
|
|
|
void updateData(const std::vector<cv::KeyPoint> & keypoints, const QMultiMap<int, int> & words=QMultiMap<int, int>());
|
|
|
|
|
void updateWords(const QMultiMap<int,int> & words);
|
2012-02-04 22:15:32 +00:00
|
|
|
void setTextLabel(const QString & text);
|
2011-10-25 15:48:19 +00:00
|
|
|
void resetKptsColor();
|
2015-06-24 18:07:52 -04:00
|
|
|
void resetKptsWordID();
|
2011-11-23 18:08:33 +00:00
|
|
|
void setKptColor(int index, const QColor & color);
|
2015-06-24 18:07:52 -04:00
|
|
|
void setKptWordID(int index, int wordId);
|
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);
|
2012-08-28 13:44:57 +00:00
|
|
|
void setImageShown(bool shown);
|
|
|
|
|
void setFeaturesShown(bool shown);
|
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
|
|
|
|
|
|
|
|
int id() const {return id_;}
|
2014-08-03 22:23:02 +00:00
|
|
|
const QColor & color() const {return color_;}
|
2014-07-31 19:02:31 +00:00
|
|
|
const std::vector<cv::KeyPoint> keypoints() const {return keypoints_;}
|
2015-06-24 18:07:52 -04:00
|
|
|
const QMap<int,int> & words() const {return words_;}
|
2014-07-31 19:02:31 +00:00
|
|
|
const QPixmap & pixmap() const {return pixmap_;}
|
2011-10-25 15:48:19 +00:00
|
|
|
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;
|
2011-11-09 15:07:19 +00:00
|
|
|
QList<QGraphicsItem*> selectedItems() const;
|
2011-10-25 15:48:19 +00:00
|
|
|
|
|
|
|
|
QPixmap getSceneAsPixmap();
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-07-08 19:55:03 +00:00
|
|
|
Q_SIGNALS:
|
2014-08-06 14:09:55 +00:00
|
|
|
void removalTriggered(find_object::ObjWidget *);
|
2011-11-09 15:07:19 +00:00
|
|
|
void selectionChanged();
|
2014-07-31 19:02:31 +00:00
|
|
|
void roiChanged(const cv::Rect &);
|
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:
|
2014-07-31 19:02:31 +00:00
|
|
|
int id_;
|
2011-10-25 15:48:19 +00:00
|
|
|
std::vector<cv::KeyPoint> keypoints_;
|
2015-06-24 18:07:52 -04:00
|
|
|
QMap<int,int> words_; //<keypoint, word>
|
2012-05-07 22:36:59 +00:00
|
|
|
QPixmap pixmap_;
|
2015-06-09 21:41:34 -04:00
|
|
|
QRect rect_;
|
2011-10-25 15:48:19 +00:00
|
|
|
QList<KeypointItem*> keypointItems_;
|
|
|
|
|
QGraphicsView * graphicsView_;
|
|
|
|
|
QVector<QColor> kptColors_;
|
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_;
|
2014-08-03 22:23:02 +00:00
|
|
|
QColor color_;
|
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_;
|
2014-08-03 22:23:02 +00:00
|
|
|
QAction * setColor_;
|
2012-01-28 01:00:23 +00:00
|
|
|
|
|
|
|
|
// selection stuff
|
|
|
|
|
QPoint mousePressedPos_;
|
|
|
|
|
QPoint mouseCurrentPos_;
|
2011-10-25 15:48:19 +00:00
|
|
|
};
|
|
|
|
|
|
2014-08-06 13:43:29 +00:00
|
|
|
} // namespace find_object
|
2011-10-25 15:48:19 +00:00
|
|
|
|
2011-11-15 16:37:40 +00:00
|
|
|
#endif /* OBJWIDGET_H_ */
|