-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathlabel_img.h
96 lines (69 loc) · 2.18 KB
/
label_img.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
86
87
88
89
90
91
92
93
94
95
96
#ifndef LABEL_IMG_H
#define LABEL_IMG_H
#include <QObject>
#include <QLabel>
#include <QImage>
#include <QMouseEvent>
#include <iostream>
#include <fstream>
struct ObjectLabelingBox
{
int label;
QRectF box;
};
class label_img : public QLabel
{
Q_OBJECT
public:
label_img(QWidget *parent = nullptr);
void mouseMoveEvent(QMouseEvent *ev);
void mousePressEvent(QMouseEvent *ev);
void mouseReleaseEvent(QMouseEvent *ev);
QVector<QColor> m_drawObjectBoxColor;
QStringList m_objList;
int m_uiX;
int m_uiY;
int m_imgX;
int m_imgY;
bool m_bLabelingStarted;
bool m_bVisualizeClassName;
static QColor BOX_COLORS[10];
QVector <ObjectLabelingBox> m_objBoundingBoxes;
void init();
void openImage(const QString &, bool& ret);
void showImage();
void loadLabelData(const QString & );
void setFocusObjectLabel(int);
void setFocusObjectName(QString);
void setContrastGamma(float);
bool isOpened();
QImage crop(QRect);
QRectF getRelativeRectFromTwoPoints(QPointF , QPointF);
QRect cvtRelativeToAbsoluteRectInUi(QRectF);
QRect cvtRelativeToAbsoluteRectInImage(QRectF);
QPoint cvtRelativeToAbsolutePoint(QPointF);
QPointF cvtAbsoluteToRelativePoint(QPoint);
signals:
void Mouse_Moved();
void Mouse_Pressed();
void Mouse_Release();
private:
int m_focusedObjectLabel;
QString m_foucsedObjectName;
double m_aspectRatioWidth;
double m_aspectRatioHeight;
QImage m_inputImg;
QImage m_resized_inputImg;
QPointF m_relative_mouse_pos_in_ui;
QPointF m_relatvie_mouse_pos_LBtnClicked_in_ui;
unsigned char m_gammatransform_lut[256];
QVector<QRgb> colorTable;
void setMousePosition(int , int);
void drawCrossLine(QPainter& , QColor , int thickWidth = 3);
void drawFocusedObjectBox(QPainter& , Qt::GlobalColor , int thickWidth = 3);
void drawObjectBoxes(QPainter& , int thickWidth = 3);
void drawObjectLabels(QPainter& , int thickWidth = 3, int fontPixelSize = 14, int xMargin = 5, int yMargin = 2);
void gammaTransform(QImage& image);
void removeFocusedObjectBox(QPointF);
};
#endif // LABEL_IMG_H