From 2c1747b6385b9fefa15f805635601d640844ef9b Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Tue, 25 Oct 2022 08:38:42 +0000 Subject: [PATCH] fix cls diff with python --- deploy/cpp_infer/src/ocr_cls.cpp | 5 +++++ deploy/cpp_infer/src/preprocess_op.cpp | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/deploy/cpp_infer/src/ocr_cls.cpp b/deploy/cpp_infer/src/ocr_cls.cpp index abcfed12..13a03d6a 100644 --- a/deploy/cpp_infer/src/ocr_cls.cpp +++ b/deploy/cpp_infer/src/ocr_cls.cpp @@ -45,6 +45,11 @@ void Classifier::Run(std::vector img_list, this->normalize_op_.Run(&resize_img, this->mean_, this->scale_, this->is_scale_); + if (resize_img.cols < cls_image_shape[2]) { + cv::copyMakeBorder(resize_img, resize_img, 0, 0, 0, + cls_image_shape[2] - resize_img.cols, + cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0)); + } norm_img_batch.push_back(resize_img); } std::vector input(batch_num * cls_image_shape[0] * diff --git a/deploy/cpp_infer/src/preprocess_op.cpp b/deploy/cpp_infer/src/preprocess_op.cpp index 19cd6c3f..b0261a9e 100644 --- a/deploy/cpp_infer/src/preprocess_op.cpp +++ b/deploy/cpp_infer/src/preprocess_op.cpp @@ -132,10 +132,6 @@ void ClsResizeImg::Run(const cv::Mat &img, cv::Mat &resize_img, cv::resize(img, resize_img, cv::Size(resize_w, imgH), 0.f, 0.f, cv::INTER_LINEAR); - if (resize_w < imgW) { - cv::copyMakeBorder(resize_img, resize_img, 0, 0, 0, imgW - resize_w, - cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0)); - } } void TableResizeImg::Run(const cv::Mat &img, cv::Mat &resize_img, -- GitLab