From 572db7cf7c257323456d2e53839c559a2f64c314 Mon Sep 17 00:00:00 2001 From: Yonghye Kwon Date: Thu, 1 Nov 2018 17:45:06 +0900 Subject: [PATCH] Fix Bug: floating point error --- mainwindow.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index de72ff6..1a82919 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -190,11 +190,8 @@ void MainWindow::save_label_data()const cropped.save(QString().fromStdString(strImgFile) + "_cropped_" + QString::number(i) + ".png"); } - int iMidX = static_cast(objBox.box.x() + objBox.box.width()/2. + 0.5); - int iMidY = static_cast(objBox.box.y() + objBox.box.height()/2. + 0.5); - - double midX = static_cast(iMidX) / ui->label_image->m_inputImg.width(); - double midY = static_cast(iMidY) / ui->label_image->m_inputImg.height(); + double midX = static_cast(objBox.box.x() + objBox.box.width() / 2.) / ui->label_image->m_inputImg.width(); + double midY = static_cast(objBox.box.y() + objBox.box.height() / 2.) / ui->label_image->m_inputImg.height(); double width = static_cast(objBox.box.width()) / ui->label_image->m_inputImg.width(); double height = static_cast(objBox.box.height()) / ui->label_image->m_inputImg.height();