Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(CMAKE_C_FLAGS_RELEASE "/MT")
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
set(CMAKE_C_FLAGS_DEBUG "/MTd")

# 用的MSVC有该死的乱码情况,只能用该挫方法处理
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# OCRDLL
base on paddleocr dll

- base on paddleocr dll
- 在paddleocr的基础上进行了简单的封装,实现基本的逻辑功能,将输出转为C类型的结构体,并且提供了python语言ctypes的调用实现 paddleocr地址,paddle_inference 高性能预测库
CMakelist.txt 参考paddleocr部署cmakelist文件进行了大幅度的简化(其实复杂的不会),本预测仅采用CPU的mkldnn进行加速,如果是要使用cuda,trt等预测加速,请参考paddleocrgithub地址
- 这仅仅是demo能够生成供外部调用的dll,其中dll输入输出接口,请按需调整。
12 changes: 4 additions & 8 deletions src/ocr_rec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ namespace PaddleOCR {

void CRNNRecognizer::Run(cv::Mat& img, std::vector<double>* times,
std::string& rec_strs,double& rec_scores) {
cv::Mat srcimg;
img.copyTo(srcimg);
cv::Mat src_img;
img.copyTo(src_img);
cv::Mat resize_img;

float wh_ratio = float(srcimg.cols) / float(srcimg.rows);
float wh_ratio = float(src_img.cols) / float(src_img.rows);
auto preprocess_start = std::chrono::steady_clock::now();
this->resize_op_.Run(srcimg, resize_img, wh_ratio, this->use_tensorrt_);
this->resize_op_.Run(src_img, resize_img, wh_ratio, this->use_tensorrt_);

this->normalize_op_.Run(&resize_img, this->mean_, this->scale_,
this->is_scale_);
Expand Down Expand Up @@ -121,16 +121,12 @@ namespace PaddleOCR {
}
config.SetCpuMathLibraryNumThreads(this->cpu_math_library_num_threads_);
}

config.SwitchUseFeedFetchOps(false);
// true for multiple input
config.SwitchSpecifyInputNames(true);

config.SwitchIrOptim(true);

config.EnableMemoryOptim();
config.DisableGlogInfo();

this->predictor_ = CreatePredictor(config);
}

Expand Down