Visual Studio 2022 cmake编译 PP-OCRv4

1 环境准备

  1. 下载PaddleOCR
    PaddleOCR
    C++ 部署代码位于 PaddleOCR\deploy\cpp_infer目录下
  2. paddle_inference
    paddle_inference
  3. opencv
    这里使用已经安装好的opencv4.5.5
  4. 下载dirent-master.zip
    下载dirent-master.zip, 解压并复制dirent.h文件到PaddleOCR\deploy\cpp_infer目录下
  5. 下载权重文件
    检测模型 ch_PP-OCRv4_det_infer
    方向分类器 ch_ppocr_mobile_v2.0_cls_infer
    识别模型 ch_PP-OCRv4_rec_infer

2 使用Visual Studio 2022 编译

  1. 打开Visual Studio 2022,点击 文件->打开->CMake,选择项目代码所在路径,并打开CMakeList.txt
  2. 点击 项目->CMake设置
  3. 参数配置 OpenCV_DIR、PADDLE_LIB的路径

    OpenCV_DIR: E:/opencv455/build/x64/vc15/lib
    PADDLE_LIB: E:/paddle_inference
  4. 保存并生成CMake缓存以加载变量
  5. 编译生成

    编译完成

3 测试

CMD窗口 切换到 E:\cpp_code\paddle_compile\PaddleOCR\deploy\cpp_infer\out\build\x64-Release 目录

将 opencv_world455.dll,paddle_inference.dll,paddle2onnx.dll 和 onnxruntime.dll

输入CHCP 65001 回车,否则程序会输出乱码

bash 复制代码
ppocr.exe system --det_model_dir=E:\cpp_code\weights\PP-OCRv4\ch_PP-OCRv4_det_infer --rec_model_dir=E:\cpp_code\weights\PP-OCRv4\ch_PP-OCRv4_rec_infer --rec_char_dict_path=E:\cpp_code\paddle_compile\PaddleOCR\ppocr\utils\ppocr_keys_v1.txt --image_dir=E:\cpp_code\images\img_20230926_105643588.jpg  --use_angle_cls=true

输出结果

相关推荐
骥龙11 小时前
第六篇:AI平台篇 - 从Jupyter Notebook到生产级模型服务
ide·人工智能·jupyter
kun2003102912 小时前
如何用Obsidian+VSCode生成文案排版并发布到公众号
ide·vscode·编辑器
JQLvopkk19 小时前
C# 实践AI :Visual Studio + VSCode 组合方案
人工智能·c#·visual studio
踏过山河,踏过海21 小时前
【qt-查看对应的依赖的一种方法】
qt·visual studio
开源技术1 天前
Python GeoPandas基础知识:地图、投影和空间连接
开发语言·ide·python
承渊政道1 天前
C++学习之旅【C++中模板进阶内容介绍】
c语言·c++·笔记·学习·visual studio
寻梦csdn2 天前
pycharm+miniconda兼容问题
ide·python·pycharm·conda
电饭叔2 天前
Jupyter学习中的问题--FileNotFoundError
ide·学习·jupyter
noBt2 天前
Windows IDEA 卡顿严重
java·ide·intellij-idea
小疙瘩2 天前
去掉 IDEA 中 mybatis配置文件的局部背景颜色(图解)
java·ide·intellij-idea