fix bug that rouding off error accumulation

This commit is contained in:
yonghye 2018-10-31 18:18:58 +09:00
parent 4c24991535
commit 32c05d2ca5

View File

@ -86,8 +86,8 @@ void label_img::setMousePosition(int x, int y)
if(x > this->width()) x = this->width() - 1; if(x > this->width()) x = this->width() - 1;
if(y > this->height()) y = this->height() - 1; if(y > this->height()) y = this->height() - 1;
m_mouse_pos_in_image_coordinate = QPoint(static_cast<int>(x * m_aspectRatioWidth), m_mouse_pos_in_image_coordinate = QPoint(static_cast<int>(x * m_aspectRatioWidth + 0.5),
static_cast<int>(y * m_aspectRatioHeight)); static_cast<int>(y * m_aspectRatioHeight + 0.5));
} }
void label_img::openImage(const QString &qstrImg) void label_img::openImage(const QString &qstrImg)
@ -160,10 +160,15 @@ void label_img::loadLabelData(const QString& labelFilePath)
double width = inputFileValues.at(i + 3) * m_inputImg.width(); double width = inputFileValues.at(i + 3) * m_inputImg.width();
double height = inputFileValues.at(i + 4) * m_inputImg.height(); double height = inputFileValues.at(i + 4) * m_inputImg.height();
objBox.box.setX(static_cast<int>(midX - width/2));
objBox.box.setY(static_cast<int>(midY - height/2)); std::cout << "midX: " << midX << std::endl;
objBox.box.setWidth(static_cast<int>(width)); std::cout << "midX: " << midY << std::endl;
objBox.box.setHeight(static_cast<int>(height));
objBox.box.setX(static_cast<int>(midX - width/2 + 0.5));
objBox.box.setY(static_cast<int>(midY - height/2 + 0.5));
objBox.box.setWidth(static_cast<int>(width + 0.5));
objBox.box.setHeight(static_cast<int>(height + 0.5));
m_objBoundingBoxes.push_back(objBox); m_objBoundingBoxes.push_back(objBox);
} }