diff --git a/deploy/cpp_infer/src/ocr_cls.cpp b/deploy/cpp_infer/src/ocr_cls.cpp index abcfed125f45253fc13c72f94621dda25ba12780..13a03d6ad4564e710631ce62f99c622b47d6905f 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 19cd6c3f799e66c50a004881272e0c4a1e357c1d..b0261a9ed2b177ed58e07c042004e28c70b9762a 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,