diff --git a/CMakeLists.txt b/CMakeLists.txt index a8faae5..f72b7e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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("$<$:/utf-8>") add_compile_options("$<$:/utf-8>") diff --git a/README.md b/README.md index d61d860..79cd90f 100644 --- a/README.md +++ b/README.md @@ -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输入输出接口,请按需调整。 diff --git a/src/ocr_rec.cpp b/src/ocr_rec.cpp index f448108..f0358ba 100644 --- a/src/ocr_rec.cpp +++ b/src/ocr_rec.cpp @@ -3,13 +3,13 @@ namespace PaddleOCR { void CRNNRecognizer::Run(cv::Mat& img, std::vector* 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_); @@ -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); }