Skip to content

Commit db7917f

Browse files
committed
[Fix] Fix bugs of preprocess.
1 parent 269ae9c commit db7917f

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/basemodel.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ void Model::PreProcess(std::vector<cv::Mat>& img_batch) {
132132
for (size_t i = 0; i < img_batch.size(); i++) {
133133
int height = img_batch[i].rows;
134134
int width = img_batch[i].cols;
135-
float scale = std::min(imageHeight / height, imageWidth / width);
135+
auto h_scale = static_cast<float>(imageHeight) / static_cast<float>(height);
136+
float w_scale = static_cast<float>(imageWidth) / static_cast<float>(width);
137+
float scale = std::min(h_scale, w_scale);
136138
cv::Mat s2d = (cv::Mat_<float>(2, 3) << scale, 0.f, (-scale * width + imageWidth + scale - 1) * 0.5,
137139
0.f, scale, (-scale * height + imageHeight + scale - 1) * 0.5);
138140
cv::Mat d2s = cv::Mat::zeros(2, 3, CV_32FC1);

0 commit comments

Comments
 (0)