Skip to content

Commit 2c1747b

Browse files
committed
fix cls diff with python
1 parent ca27d79 commit 2c1747b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

deploy/cpp_infer/src/ocr_cls.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ void Classifier::Run(std::vector<cv::Mat> img_list,
4545

4646
this->normalize_op_.Run(&resize_img, this->mean_, this->scale_,
4747
this->is_scale_);
48+
if (resize_img.cols < cls_image_shape[2]) {
49+
cv::copyMakeBorder(resize_img, resize_img, 0, 0, 0,
50+
cls_image_shape[2] - resize_img.cols,
51+
cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0));
52+
}
4853
norm_img_batch.push_back(resize_img);
4954
}
5055
std::vector<float> input(batch_num * cls_image_shape[0] *

deploy/cpp_infer/src/preprocess_op.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ void ClsResizeImg::Run(const cv::Mat &img, cv::Mat &resize_img,
132132

133133
cv::resize(img, resize_img, cv::Size(resize_w, imgH), 0.f, 0.f,
134134
cv::INTER_LINEAR);
135-
if (resize_w < imgW) {
136-
cv::copyMakeBorder(resize_img, resize_img, 0, 0, 0, imgW - resize_w,
137-
cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0));
138-
}
139135
}
140136

141137
void TableResizeImg::Run(const cv::Mat &img, cv::Mat &resize_img,

0 commit comments

Comments
 (0)