From 15e8dec4120b9e89aee2cac2a3ad06a12043fcef Mon Sep 17 00:00:00 2001 From: MissPenguin Date: Mon, 26 Apr 2021 02:13:49 +0000 Subject: [PATCH] Modify the resize operation to be consistent with the python version --- deploy/cpp_infer/src/preprocess_op.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) mode change 100644 => 100755 deploy/cpp_infer/src/preprocess_op.cpp diff --git a/deploy/cpp_infer/src/preprocess_op.cpp b/deploy/cpp_infer/src/preprocess_op.cpp old mode 100644 new mode 100755 index 87d8dbbd..37e33aee --- a/deploy/cpp_infer/src/preprocess_op.cpp +++ b/deploy/cpp_infer/src/preprocess_op.cpp @@ -77,19 +77,10 @@ void ResizeImgType0::Run(const cv::Mat &img, cv::Mat &resize_img, int resize_h = int(float(h) * ratio); int resize_w = int(float(w) * ratio); - if (resize_h % 32 == 0) - resize_h = resize_h; - else if (resize_h / 32 < 1 + 1e-5) - resize_h = 32; - else - resize_h = (resize_h / 32) * 32; - if (resize_w % 32 == 0) - resize_w = resize_w; - else if (resize_w / 32 < 1 + 1e-5) - resize_w = 32; - else - resize_w = (resize_w / 32) * 32; + resize_h = max(int(round(float(resize_h) / 32) * 32), 32); + resize_w = max(int(round(float(resize_w) / 32) * 32), 32); + if (!use_tensorrt) { cv::resize(img, resize_img, cv::Size(resize_w, resize_h)); ratio_h = float(resize_h) / float(h); -- GitLab