diff --git a/label_img.cpp b/label_img.cpp index 79517cf..06568d4 100644 --- a/label_img.cpp +++ b/label_img.cpp @@ -86,6 +86,9 @@ void label_img::setMousePosition(int x, int y) if(x > this->width()) x = this->width() - 1; if(y > this->height()) y = this->height() - 1; + m_aspectRatioWidth = static_cast(m_inputImg.width()) / this->width(); + m_aspectRatioHeight = static_cast(m_inputImg.height()) / this->height(); + m_mouse_pos_in_image_coordinate = QPoint(static_cast(x * m_aspectRatioWidth + 0.5), static_cast(y * m_aspectRatioHeight + 0.5)); } @@ -96,9 +99,6 @@ void label_img::openImage(const QString &qstrImg) m_inputImg = m_inputImg.convertToFormat(QImage::Format_RGB888); m_inputImgCopy = m_inputImg; - m_aspectRatioWidth = static_cast(m_inputImg.width()) / this->width(); - m_aspectRatioHeight = static_cast(m_inputImg.height()) / this->height(); - m_objBoundingBoxes.clear(); m_leftButtonClickedPoint = QPoint(); @@ -155,10 +155,10 @@ void label_img::loadLabelData(const QString& labelFilePath) ObjectLabelingBox objBox; objBox.label = static_cast(inputFileValues.at(i)); - double midX = inputFileValues.at(i + 1) * m_inputImg.width(); - double midY = inputFileValues.at(i + 2) * m_inputImg.height(); - double width = inputFileValues.at(i + 3) * m_inputImg.width(); - double height = inputFileValues.at(i + 4) * m_inputImg.height(); + double midX = inputFileValues.at(i + 1) * m_inputImg.width(); + double midY = inputFileValues.at(i + 2) * m_inputImg.height(); + double width = inputFileValues.at(i + 3) * m_inputImg.width(); + double height = inputFileValues.at(i + 4) * m_inputImg.height(); std::cout << "midX: " << midX << std::endl; diff --git a/label_img.h b/label_img.h index 0e5fb68..8249250 100644 --- a/label_img.h +++ b/label_img.h @@ -24,7 +24,6 @@ public: void mousePressEvent(QMouseEvent *ev); void mouseReleaseEvent(QMouseEvent *ev); - QImage m_inputImg; QImage m_inputImgCopy;//for drawing diff --git a/mainwindow.h b/mainwindow.h index cd425ba..1f730ae 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -21,8 +21,6 @@ public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); -Q_SIGNALS: - private slots: void on_pushButton_open_files_clicked(); void on_pushButton_save_clicked();