2018-10-29 07:26:06 +03:00
|
|
|
#ifndef LABEL_IMG_H
|
|
|
|
#define LABEL_IMG_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
struct ObjectLabelingBox
|
|
|
|
{
|
|
|
|
int label;
|
2018-11-06 14:27:12 +03:00
|
|
|
QRectF box;
|
2018-10-29 07:26:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|
2022-11-03 12:09:48 +03:00
|
|
|
QStringList m_objList;
|
2018-10-29 07:26:06 +03:00
|
|
|
|
|
|
|
int m_uiX;
|
|
|
|
int m_uiY;
|
|
|
|
|
|
|
|
int m_imgX;
|
|
|
|
int m_imgY;
|
|
|
|
|
2018-11-07 08:45:20 +03:00
|
|
|
bool m_bLabelingStarted;
|
2023-01-10 15:32:09 +03:00
|
|
|
bool m_bVisualizeClassName;
|
2018-10-29 07:26:06 +03:00
|
|
|
|
|
|
|
static QColor BOX_COLORS[10];
|
|
|
|
|
|
|
|
QVector <ObjectLabelingBox> m_objBoundingBoxes;
|
|
|
|
|
2018-11-07 08:45:20 +03:00
|
|
|
void init();
|
2018-12-14 07:44:18 +03:00
|
|
|
void openImage(const QString &, bool& ret);
|
2018-10-29 07:26:06 +03:00
|
|
|
void showImage();
|
|
|
|
|
|
|
|
void loadLabelData(const QString & );
|
|
|
|
|
|
|
|
void setFocusObjectLabel(int);
|
|
|
|
void setFocusObjectName(QString);
|
2021-11-29 18:04:33 +03:00
|
|
|
void setContrastGamma(float);
|
2018-12-14 07:44:18 +03:00
|
|
|
|
|
|
|
bool isOpened();
|
2018-11-06 14:27:12 +03:00
|
|
|
QImage crop(QRect);
|
|
|
|
|
|
|
|
QRectF getRelativeRectFromTwoPoints(QPointF , QPointF);
|
|
|
|
|
|
|
|
QRect cvtRelativeToAbsoluteRectInUi(QRectF);
|
|
|
|
QRect cvtRelativeToAbsoluteRectInImage(QRectF);
|
|
|
|
|
2018-11-06 14:31:30 +03:00
|
|
|
QPoint cvtRelativeToAbsolutePoint(QPointF);
|
2018-11-06 14:27:12 +03:00
|
|
|
QPointF cvtAbsoluteToRelativePoint(QPoint);
|
|
|
|
|
2021-11-29 18:04:33 +03:00
|
|
|
|
2018-10-29 07:26:06 +03:00
|
|
|
signals:
|
|
|
|
void Mouse_Moved();
|
|
|
|
void Mouse_Pressed();
|
|
|
|
void Mouse_Release();
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_focusedObjectLabel;
|
|
|
|
QString m_foucsedObjectName;
|
|
|
|
|
|
|
|
double m_aspectRatioWidth;
|
|
|
|
double m_aspectRatioHeight;
|
|
|
|
|
2018-11-06 14:27:12 +03:00
|
|
|
QImage m_inputImg;
|
2021-11-29 18:04:33 +03:00
|
|
|
QImage m_resized_inputImg;
|
2018-11-06 14:27:12 +03:00
|
|
|
|
|
|
|
QPointF m_relative_mouse_pos_in_ui;
|
|
|
|
QPointF m_relatvie_mouse_pos_LBtnClicked_in_ui;
|
2018-10-29 07:26:06 +03:00
|
|
|
|
2021-11-29 18:04:33 +03:00
|
|
|
unsigned char m_gammatransform_lut[256];
|
|
|
|
QVector<QRgb> colorTable;
|
|
|
|
|
2018-10-29 07:26:06 +03:00
|
|
|
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);
|
2022-11-07 11:12:24 +03:00
|
|
|
void drawObjectLabels(QPainter& , int thickWidth = 3, int fontPixelSize = 14, int xMargin = 5, int yMargin = 2);
|
2021-11-29 18:04:33 +03:00
|
|
|
void gammaTransform(QImage& image);
|
2018-11-06 14:27:12 +03:00
|
|
|
void removeFocusedObjectBox(QPointF);
|
2018-10-29 07:26:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LABEL_IMG_H
|