Skip to content

Commit b00bea3

Browse files
committed
fix bug
修复部分图像分辨率下,预标注模型报错的问题
1 parent b64a04a commit b00bea3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

model.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ bool SmartModel::run(const QString &image_file, QVector<box_t> &boxes) {
7474
try {
7575
auto img = cv::imread(image_file.toStdString());
7676
float scale = 640.f / std::max(img.cols, img.rows);
77-
int dw = img.cols * scale;
78-
int dh = img.rows * scale;
77+
cv::resize(img, img, {-1, -1}, scale, scale);
78+
int dw = img.cols;
79+
int dh = img.rows;
7980
int dx = (640 - dw) / 2;
8081
int dy = (640 - dh) / 2;
81-
cv::resize(img, img, {-1, -1}, scale, scale);
8282
cv::Mat input(640, 640, CV_8UC3);
8383
img.copyTo(input({dx, dy, dw, dh}));
8484
auto x = cv::dnn::blobFromImage(input);

0 commit comments

Comments
 (0)