diff --git a/label_img.cpp b/label_img.cpp
index 8428c5a..c769cd5 100644
--- a/label_img.cpp
+++ b/label_img.cpp
@@ -26,7 +26,7 @@ label_img::label_img(QWidget *parent)
void label_img::mouseMoveEvent(QMouseEvent *ev)
{
- setMousePosition(ev->x(), ev->y());
+ setMousePosition(ev->position().x(), ev->position().y());
showImage();
emit Mouse_Moved();
@@ -34,7 +34,7 @@ void label_img::mouseMoveEvent(QMouseEvent *ev)
void label_img::mousePressEvent(QMouseEvent *ev)
{
- setMousePosition(ev->x(), ev->y());
+ setMousePosition(ev->position().x(), ev->position().y());
if(ev->button() == Qt::RightButton)
{
@@ -174,6 +174,9 @@ void label_img::showImage()
if(m_bVisualizeClassName)
drawObjectLabels(painter, penThick, fontSize, xMargin, yMargin);
+ if(m_bVisualizeClassCenter)
+ drawCenter(painter, penThick*1.5);
+
this->setPixmap(QPixmap::fromImage(img));
}
@@ -271,6 +274,15 @@ void label_img::drawFocusedObjectBox(QPainter& painter, Qt::GlobalColor color, i
QPoint absolutePoint2 = cvtRelativeToAbsolutePoint(m_relative_mouse_pos_in_ui);
painter.drawRect(QRect(absolutePoint1, absolutePoint2));
+
+ if(m_bVisualizeClassCenter)
+ {
+ const auto center = 0.5*(absolutePoint1 + absolutePoint2);
+ painter.drawPoint(center);
+ }
+
+
+
}
}
@@ -288,6 +300,28 @@ void label_img::drawObjectBoxes(QPainter& painter, int thickWidth)
}
}
+void label_img::drawCenter(QPainter& painter, int minThickWidth)
+{
+ QPen pen;
+ for(ObjectLabelingBox boundingbox: m_objBoundingBoxes)
+ {
+ pen.setWidth(minThickWidth);
+ pen.setColor(m_drawObjectBoxColor.at(boundingbox.label));
+ painter.setPen(pen);
+ const auto center = cvtRelativeToAbsolutePoint(boundingbox.box.center());
+ painter.drawPoint(center);
+
+ const auto relative_box=cvtRelativeToAbsoluteRectInUi(boundingbox.box);
+ const int thickWidth = std::max((int)std::sqrt(std::min(relative_box.width(), relative_box.height())), minThickWidth);
+
+ if(minThickWidth * 2 < thickWidth)
+ {// the rectangle is big, draw a circle too
+ painter.drawEllipse(center, thickWidth, thickWidth);
+ }
+
+ };
+}
+
void label_img::drawObjectLabels(QPainter& painter, int thickWidth, int fontPixelSize, int xMargin, int yMargin)
{
QFontMetrics fontMetrics = painter.fontMetrics();
diff --git a/label_img.h b/label_img.h
index 157f8bc..75c0a6b 100644
--- a/label_img.h
+++ b/label_img.h
@@ -35,6 +35,7 @@ public:
bool m_bLabelingStarted;
bool m_bVisualizeClassName;
+ bool m_bVisualizeClassCenter = false;
static QColor BOX_COLORS[10];
@@ -88,6 +89,7 @@ private:
void drawCrossLine(QPainter& , QColor , int thickWidth = 3);
void drawFocusedObjectBox(QPainter& , Qt::GlobalColor , int thickWidth = 3);
void drawObjectBoxes(QPainter& , int thickWidth = 3);
+ void drawCenter(QPainter& , int thickWidth);
void drawObjectLabels(QPainter& , int thickWidth = 3, int fontPixelSize = 14, int xMargin = 5, int yMargin = 2);
void gammaTransform(QImage& image);
void removeFocusedObjectBox(QPointF);
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 34cccc4..0774ff5 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -481,3 +481,10 @@ void MainWindow::on_checkBox_visualize_class_name_clicked(bool checked)
ui->label_image->m_bVisualizeClassName = checked;
ui->label_image->showImage();
}
+
+void MainWindow::on_checkBox_visualize_center_stateChanged(int checked)
+{
+ ui->label_image->m_bVisualizeClassCenter = checked;
+ ui->label_image->showImage();
+}
+
diff --git a/mainwindow.h b/mainwindow.h
index f958522..d7990e1 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -46,6 +46,8 @@ private slots:
void on_checkBox_visualize_class_name_clicked(bool checked);
+ void on_checkBox_visualize_center_stateChanged(int arg1);
+
private:
void init();
void init_table_widget();
diff --git a/mainwindow.ui b/mainwindow.ui
index 18c7baa..b96cf7f 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -79,7 +79,6 @@
Arial
18
- 75
true
@@ -211,7 +210,6 @@ QSlider::handle:horizontal {
Arial
12
- 75
true
@@ -322,7 +320,6 @@ QSlider::handle:horizontal {
Arial
12
- 75
true
@@ -380,7 +377,6 @@ border-color: rgb(0, 255, 255);
Arial
12
- 75
true
true
@@ -432,7 +428,6 @@ border-color: rgb(0, 255, 255);
Arial
12
- 75
true
@@ -453,10 +448,13 @@ border-color: rgb(0, 255, 255);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:600; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Gulim'; font-size:9pt;">Last Labeled Image:<br />Current Image:</span></p></body></html>
+hr { height: 1px; border-width: 0; }
+li.unchecked::marker { content: "\2610"; }
+li.checked::marker { content: "\2612"; }
+</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:700; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Gulim'; font-size:9pt; font-weight:600;">Last Labeled Image:<br />Current Image:</span></p></body></html>
@@ -487,7 +485,6 @@ p, li { white-space: pre-wrap; }
10
- 75
true
@@ -581,6 +578,28 @@ QTableView {
-
+
-
+
+
+
+ Arial
+ 12
+ false
+ false
+
+
+
+ background-color : rgb(0, 0, 17);color : rgb(0, 255, 255);
+
+
+
+ Visualize Center
+
+
+ V
+
+
+
-
@@ -613,7 +632,7 @@ QTableView {
0
0
1180
- 21
+ 22