Draw center (#1)
- add a function for drawing the center --------- Signed-off-by: Vincenzo La Spesa <vincenzolaspesa@gmail.com>
This commit is contained in:
parent
cb4ab0970a
commit
74edf6fa94
@ -26,7 +26,7 @@ label_img::label_img(QWidget *parent)
|
|||||||
|
|
||||||
void label_img::mouseMoveEvent(QMouseEvent *ev)
|
void label_img::mouseMoveEvent(QMouseEvent *ev)
|
||||||
{
|
{
|
||||||
setMousePosition(ev->x(), ev->y());
|
setMousePosition(ev->position().x(), ev->position().y());
|
||||||
|
|
||||||
showImage();
|
showImage();
|
||||||
emit Mouse_Moved();
|
emit Mouse_Moved();
|
||||||
@ -34,7 +34,7 @@ void label_img::mouseMoveEvent(QMouseEvent *ev)
|
|||||||
|
|
||||||
void label_img::mousePressEvent(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)
|
if(ev->button() == Qt::RightButton)
|
||||||
{
|
{
|
||||||
@ -174,6 +174,9 @@ void label_img::showImage()
|
|||||||
if(m_bVisualizeClassName)
|
if(m_bVisualizeClassName)
|
||||||
drawObjectLabels(painter, penThick, fontSize, xMargin, yMargin);
|
drawObjectLabels(painter, penThick, fontSize, xMargin, yMargin);
|
||||||
|
|
||||||
|
if(m_bVisualizeClassCenter)
|
||||||
|
drawCenter(painter, penThick*1.5);
|
||||||
|
|
||||||
this->setPixmap(QPixmap::fromImage(img));
|
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);
|
QPoint absolutePoint2 = cvtRelativeToAbsolutePoint(m_relative_mouse_pos_in_ui);
|
||||||
|
|
||||||
painter.drawRect(QRect(absolutePoint1, absolutePoint2));
|
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)
|
void label_img::drawObjectLabels(QPainter& painter, int thickWidth, int fontPixelSize, int xMargin, int yMargin)
|
||||||
{
|
{
|
||||||
QFontMetrics fontMetrics = painter.fontMetrics();
|
QFontMetrics fontMetrics = painter.fontMetrics();
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
|
|
||||||
bool m_bLabelingStarted;
|
bool m_bLabelingStarted;
|
||||||
bool m_bVisualizeClassName;
|
bool m_bVisualizeClassName;
|
||||||
|
bool m_bVisualizeClassCenter = false;
|
||||||
|
|
||||||
static QColor BOX_COLORS[10];
|
static QColor BOX_COLORS[10];
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ private:
|
|||||||
void drawCrossLine(QPainter& , QColor , int thickWidth = 3);
|
void drawCrossLine(QPainter& , QColor , int thickWidth = 3);
|
||||||
void drawFocusedObjectBox(QPainter& , Qt::GlobalColor , int thickWidth = 3);
|
void drawFocusedObjectBox(QPainter& , Qt::GlobalColor , int thickWidth = 3);
|
||||||
void drawObjectBoxes(QPainter& , 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 drawObjectLabels(QPainter& , int thickWidth = 3, int fontPixelSize = 14, int xMargin = 5, int yMargin = 2);
|
||||||
void gammaTransform(QImage& image);
|
void gammaTransform(QImage& image);
|
||||||
void removeFocusedObjectBox(QPointF);
|
void removeFocusedObjectBox(QPointF);
|
||||||
|
@ -481,3 +481,10 @@ void MainWindow::on_checkBox_visualize_class_name_clicked(bool checked)
|
|||||||
ui->label_image->m_bVisualizeClassName = checked;
|
ui->label_image->m_bVisualizeClassName = checked;
|
||||||
ui->label_image->showImage();
|
ui->label_image->showImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_checkBox_visualize_center_stateChanged(int checked)
|
||||||
|
{
|
||||||
|
ui->label_image->m_bVisualizeClassCenter = checked;
|
||||||
|
ui->label_image->showImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,8 @@ private slots:
|
|||||||
|
|
||||||
void on_checkBox_visualize_class_name_clicked(bool checked);
|
void on_checkBox_visualize_class_name_clicked(bool checked);
|
||||||
|
|
||||||
|
void on_checkBox_visualize_center_stateChanged(int arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void init_table_widget();
|
void init_table_widget();
|
||||||
|
@ -79,7 +79,6 @@
|
|||||||
<font>
|
<font>
|
||||||
<family>Arial</family>
|
<family>Arial</family>
|
||||||
<pointsize>18</pointsize>
|
<pointsize>18</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
@ -211,7 +210,6 @@ QSlider::handle:horizontal {
|
|||||||
<font>
|
<font>
|
||||||
<family>Arial</family>
|
<family>Arial</family>
|
||||||
<pointsize>12</pointsize>
|
<pointsize>12</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
@ -322,7 +320,6 @@ QSlider::handle:horizontal {
|
|||||||
<font>
|
<font>
|
||||||
<family>Arial</family>
|
<family>Arial</family>
|
||||||
<pointsize>12</pointsize>
|
<pointsize>12</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
@ -380,7 +377,6 @@ border-color: rgb(0, 255, 255);</string>
|
|||||||
<font>
|
<font>
|
||||||
<family>Arial</family>
|
<family>Arial</family>
|
||||||
<pointsize>12</pointsize>
|
<pointsize>12</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
<kerning>true</kerning>
|
<kerning>true</kerning>
|
||||||
</font>
|
</font>
|
||||||
@ -432,7 +428,6 @@ border-color: rgb(0, 255, 255);</string>
|
|||||||
<font>
|
<font>
|
||||||
<family>Arial</family>
|
<family>Arial</family>
|
||||||
<pointsize>12</pointsize>
|
<pointsize>12</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
@ -453,10 +448,13 @@ border-color: rgb(0, 255, 255);</string>
|
|||||||
</property>
|
</property>
|
||||||
<property name="html">
|
<property name="html">
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!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; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:600; font-style:normal;">
|
hr { height: 1px; border-width: 0; }
|
||||||
<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></string>
|
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></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -487,7 +485,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>10</pointsize>
|
<pointsize>10</pointsize>
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
@ -581,6 +578,28 @@ QTableView {
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBox_visualize_center">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Arial</family>
|
||||||
|
<pointsize>12</pointsize>
|
||||||
|
<underline>false</underline>
|
||||||
|
<strikeout>false</strikeout>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color : rgb(0, 0, 17);color : rgb(0, 255, 255);
|
||||||
|
</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Visualize Center</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>V</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox_visualize_class_name">
|
<widget class="QCheckBox" name="checkBox_visualize_class_name">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
@ -613,7 +632,7 @@ QTableView {
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1180</width>
|
<width>1180</width>
|
||||||
<height>21</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user