add cropped image save option
This commit is contained in:
parent
32c05d2ca5
commit
43ce2bd7c0
@ -24,6 +24,7 @@ public:
|
||||
void mousePressEvent(QMouseEvent *ev);
|
||||
void mouseReleaseEvent(QMouseEvent *ev);
|
||||
|
||||
|
||||
QImage m_inputImg;
|
||||
QImage m_inputImgCopy;//for drawing
|
||||
|
||||
|
@ -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<double>(objBox.box.center().x()) / ui->label_image->m_inputImg.width();
|
||||
double midY = static_cast<double>(objBox.box.center().y()) / ui->label_image->m_inputImg.height();
|
||||
double width = static_cast<double>(objBox.box.width()) / ui->label_image->m_inputImg.width();
|
||||
|
@ -112,7 +112,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>ArrowCursor</cursorShape>
|
||||
<cursorShape>CrossCursor</cursorShape>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
<bool>true</bool>
|
||||
@ -342,7 +342,7 @@ border-color: rgb(0, 255, 255);</string>
|
||||
<widget class="QPushButton" name="pushButton_open_files">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>291</width>
|
||||
<width>271</width>
|
||||
<height>91</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -386,7 +386,7 @@ border-color: rgb(0, 255, 255);</string>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>291</width>
|
||||
<width>271</width>
|
||||
<height>91</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -429,6 +429,34 @@ border-color: rgb(0, 255, 255);</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_cropping">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>ArrowCursor</cursorShape>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color : rgb(0, 0, 17);color : rgb(0, 255, 255);
|
||||
border-style: outset;
|
||||
border-width: 2px;
|
||||
border-color: rgb(0, 255, 255);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>with crop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
@ -632,7 +660,7 @@ QTableView {
|
||||
<number>2</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
@ -684,6 +712,7 @@ QTableView {
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user