diff --git a/label_img.h b/label_img.h index 8249250..0e5fb68 100644 --- a/label_img.h +++ b/label_img.h @@ -24,6 +24,7 @@ public: void mousePressEvent(QMouseEvent *ev); void mouseReleaseEvent(QMouseEvent *ev); + QImage m_inputImg; QImage m_inputImgCopy;//for drawing diff --git a/mainwindow.cpp b/mainwindow.cpp index 76c4aa5..8430718 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -68,10 +68,10 @@ void MainWindow::on_pushButton_open_files_clicked() QString fileLabelList = QFileDialog::getOpenFileName( - this, - tr("Open LabelList file"), - "./", - tr("LabelList Files (*.txt *.names)")); + this, + tr("Open LabelList file"), + "./", + tr("LabelList Files (*.txt *.names)")); if(fileLabelList.size() == 0) { @@ -168,6 +168,16 @@ void MainWindow::save_label_data()const ObjectLabelingBox objBox = ui->label_image->m_objBoundingBoxes[i]; + if(ui->checkBox_cropping->isChecked()) + { + QImage cropped = ui->label_image->m_inputImgCopy.copy(objBox.box); + + string strImgFile = m_fileList.at(m_fileIndex).toStdString(); + strImgFile = strImgFile.substr( strImgFile.find_last_of('/') + 1, + strImgFile.find_last_of('.') - strImgFile.find_last_of('/') - 1); + + cropped.save(QString().fromStdString(strImgFile) + "_cropped_" + QString::number(i) + ".png"); + } double midX = static_cast(objBox.box.center().x()) / ui->label_image->m_inputImg.width(); double midY = static_cast(objBox.box.center().y()) / ui->label_image->m_inputImg.height(); double width = static_cast(objBox.box.width()) / ui->label_image->m_inputImg.width(); diff --git a/mainwindow.ui b/mainwindow.ui index c6a4e99..2ff7bbc 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -112,7 +112,7 @@ - ArrowCursor + CrossCursor true @@ -342,7 +342,7 @@ border-color: rgb(0, 255, 255); - 291 + 271 91 @@ -386,7 +386,7 @@ border-color: rgb(0, 255, 255); - 291 + 271 91 @@ -429,6 +429,34 @@ border-color: rgb(0, 255, 255); + + + + + 90 + 21 + + + + + 75 + true + + + + ArrowCursor + + + background-color : rgb(0, 0, 17);color : rgb(0, 255, 255); +border-style: outset; +border-width: 2px; +border-color: rgb(0, 255, 255); + + + with crop + + + @@ -632,7 +660,7 @@ QTableView { 2 - true + false false @@ -684,6 +712,7 @@ QTableView { false +