From cc3a1882755f389e9bf7c0a09dcda88ccb6e5072 Mon Sep 17 00:00:00 2001 From: Yonghye Kwon Date: Tue, 10 Jan 2023 21:32:09 +0900 Subject: [PATCH] turn on or off visualization function with a check box --- label_img.cpp | 6 ++++-- label_img.h | 1 + mainwindow.cpp | 13 +++++++------ mainwindow.h | 8 ++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/label_img.cpp b/label_img.cpp index 1c1f41e..76c400a 100644 --- a/label_img.cpp +++ b/label_img.cpp @@ -80,6 +80,7 @@ void label_img::init() { m_objBoundingBoxes.clear(); m_bLabelingStarted = false; + m_bVisualizeClassName = false; m_focusedObjectLabel = 0; QPoint mousePosInUi = this->mapFromGlobal(QCursor::pos()); @@ -159,7 +160,7 @@ void label_img::showImage() QPainter painter(&img); QFont font = painter.font(); - int fontSize = 14, xMargin = 5, yMargin = 2; + int fontSize = 16, xMargin = 5, yMargin = 2; font.setPixelSize(fontSize); font.setBold(true); painter.setFont(font); @@ -171,7 +172,8 @@ void label_img::showImage() drawCrossLine(painter, crossLineColor, penThick); drawFocusedObjectBox(painter, Qt::magenta, penThick); drawObjectBoxes(painter, penThick); - drawObjectLabels(painter, penThick, fontSize, xMargin, yMargin); + if(m_bVisualizeClassName) + drawObjectLabels(painter, penThick, fontSize, xMargin, yMargin); this->setPixmap(QPixmap::fromImage(img)); } diff --git a/label_img.h b/label_img.h index 0a628a9..157f8bc 100644 --- a/label_img.h +++ b/label_img.h @@ -34,6 +34,7 @@ public: int m_imgY; bool m_bLabelingStarted; + bool m_bVisualizeClassName; static QColor BOX_COLORS[10]; diff --git a/mainwindow.cpp b/mainwindow.cpp index 4b5dc37..34cccc4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -198,7 +198,7 @@ void MainWindow::remove_img() } else if( m_imgIndex == m_imgList.size()) { - m_imgIndex --; + m_imgIndex--; } goto_img(m_imgIndex); @@ -361,11 +361,6 @@ void MainWindow::open_obj_file(bool& ret) } } -void MainWindow::reupdate_img_list() -{ - -} - void MainWindow::wheelEvent(QWheelEvent *ev) { if(ev->angleDelta().y() > 0) // up Wheel @@ -480,3 +475,9 @@ void MainWindow::on_horizontalSlider_contrast_sliderMoved(int value) ui->label_image->setContrastGamma(percentageToGamma); ui->label_contrast->setText(QString("Contrast(%) ") + QString::number(int(valueToPercentage * 100.))); } + +void MainWindow::on_checkBox_visualize_class_name_clicked(bool checked) +{ + ui->label_image->m_bVisualizeClassName = checked; + ui->label_image->showImage(); +} diff --git a/mainwindow.h b/mainwindow.h index 9312377..f958522 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -23,10 +23,6 @@ public: private slots: void on_pushButton_open_files_clicked(); -// void on_pushButton_change_dir_clicked(); -// void on_pushButton_save_clicked(); -// void on_pushButton_remove_clicked(); - void on_pushButton_prev_clicked(); void on_pushButton_next_clicked(); @@ -48,6 +44,8 @@ private slots: void on_horizontalSlider_contrast_sliderMoved(int value); + void on_checkBox_visualize_class_name_clicked(bool checked); + private: void init(); void init_table_widget(); @@ -71,8 +69,6 @@ private: void open_img_dir(bool&); void open_obj_file(bool&); - void reupdate_img_list(); - Ui::MainWindow *ui; QString m_imgDir;