-
Notifications
You must be signed in to change notification settings - Fork 0
/
BoundingBoxSelector.h
85 lines (68 loc) · 2.3 KB
/
BoundingBoxSelector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include <QLabel>
#include <QImage>
#include <QMouseEvent>
#include <QMap>
class BoundingBoxSelector
: public QLabel
{
Q_OBJECT
public:
struct Label
{
using Vector = std::vector<Label>;
QString label;
QRectF box;
bool focused;
};
public:
BoundingBoxSelector(QWidget *parent = nullptr);
void init();
bool openImage(QString const&);
void showImage(bool menuHandling = false);
void loadClassBoxes(QVariantMap::iterator);
void syncClassBoxes();
void setFocusObjectLabel(QString const&);
void setClasses(QVariantMap* classes);
void clearAllClassBoxex();
auto importClassBoxesFromAnnotationFile(QString const&, QVariantMap&) -> QVariantMap;
void exportClassBoxesToAnnotationFile(QVariantMap::iterator, QVariantMap const&) const;
auto getCrops(QVariantMap::iterator) const -> QMap<QString, QList<QImage>>;
void addClassBoxesFromDarknet(Label::Vector const& boxes);
void boxesFromDarknetVisible(bool enable);
void setSelectionBoundingBoxFromDarknet(bool enable);
signals:
void Mouse_Moved();
void Mouse_Pressed();
void Mouse_Release();
void datasetIteratorUpdated();
private:
void mouseMoveEvent(QMouseEvent *ev) override;
void mousePressEvent(QMouseEvent *ev) override;
void mouseReleaseEvent(QMouseEvent *ev) override;
void resizeEvent(QResizeEvent *event) override;
private slots:
void onCustomContextMenuRequested(const QPoint &pos);
private:
void setMousePosition(QPoint&& pos = {});
void updateMousePosition();
void drawCrossLine(QPainter& , QColor , int thickWidth = 3);
bool updateSelectedObjects();
private:
QString _focusedClassName;
QImage m_inputImg;
QImage m_inputImgScaled;
// TODO: Should be used instead of m_MousePos, m_MousePosPrev and m_bLabelingStarted
//QRect _selectedRect;
QPointF m_MousePos;
QPointF m_MousePosPrev;
bool m_bLabelingStarted{};
QVariantMap* _classes{};
QVariantMap::iterator _datasetIt{};
Label::Vector m_objBoundingBoxes;
Label::Vector m_objBoundingBoxesFromDarknet;
Label::Vector::iterator m_selectedItem;
bool _isBoxesFromDarknetVisible{};
bool _isSelectionBoundingBoxFromDarknet{};
};
auto toTxtExtention(QString const& filePath) -> QString;