{"id":18273596,"url":"https://github.com/rapidai/rapidocronnx","last_synced_at":"2025-05-16T17:08:32.611Z","repository":{"id":64886240,"uuid":"551797412","full_name":"RapidAI/RapidOcrOnnx","owner":"RapidAI","description":"rapidocr onnx cpp","archived":false,"fork":false,"pushed_at":"2025-03-25T06:03:39.000Z","size":2766,"stargazers_count":227,"open_issues_count":20,"forks_count":53,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-12T16:58:34.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RapidAI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-15T05:32:26.000Z","updated_at":"2025-04-03T07:56:29.000Z","dependencies_parsed_at":"2024-01-07T13:39:34.372Z","dependency_job_id":"6423d657-7dd8-407d-904b-ea3dc38feb20","html_url":"https://github.com/RapidAI/RapidOcrOnnx","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidOcrOnnx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidOcrOnnx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidOcrOnnx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidOcrOnnx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RapidAI","download_url":"https://codeload.github.com/RapidAI/RapidOcrOnnx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254573589,"owners_count":22093731,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T12:07:00.527Z","updated_at":"2025-05-16T17:08:32.572Z","avatar_url":"https://github.com/RapidAI.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RapidOcrOnnx\n\n### 联系方式\n\n[QQ群](https://rapidai.github.io/RapidOCRDocs/main/communicate/#qq)\n\n\n### Project下载\n\n* 整合好源码和依赖库的完整工程项目，可以在Release中下载(github)\n* 可到Q群共享内下载，以Project开头的压缩包文件为源码工程，例：Project_RapidOcrOnnx-版本号.7z\n* 如果想自己折腾，则请继续阅读本说明\n\n### Demo下载(win、mac、linux)\n\n* 编译好的demo，可以在release中下载，或者Q群共享内下载\n* 各平台可执行文件：linux-bin.7z、macos-bin.7z、windows-bin.7z\n* 用于java的jni库：linux-jni.7z、macos-jni.7z、windows-jni.7z\n* 用于C的动态库：linux-clib.7z、macos-clib.7z、windows-clib.7z\n* C动态库调用范例:[RapidOcrOnnxLibTest](https://github.com/RapidAI/RapidOcrOnnxLibTest)\n* 注意：linux编译平台为ubuntu18.04，如果你的linux版本无法运行demo，请自行从源码编译依赖库和完整项目。\n\n### 介绍\n\n请查看项目主仓库：https://github.com/RapidAI/RapidOCR\n\n这个项目使用onnxruntime框架进行推理\n\n采用onnxruntime框架[https://github.com/microsoft/onnxruntime](https://github.com/microsoft/onnxruntime)\n\n### 更新说明\n\n#### 代码贡献者\n* configuration parameters for the number of IntraOp threads by https://github.com/Gmgge\n* 支持传入bitmap和image的二进制数据 by https://github.com/MyMonsterCat\n* Enhance ONNX Runtime GPU inference performance by https://github.com/Tryanks\n* Added DirectML GPU support by https://github.com/airchaoz\n\n#### 2022-10-15 update v1.1.1\n\n* opencv 4.6.0\n* onnxruntime 1.12.1\n* windows支持mt版引用库\n* rec模型输入图片高度改为48\n\n#### 2022-10-16 update v1.1.2\n\n* 修复：字典添加空格\n\n#### 2022-10-17 update v1.1.3\n\n* 修复：scoreToTextLine方法索引越界问题\n* Windows控制台编码修改为UTF8\n\n#### 2022-10-20 update v1.2.0\n\n* 再次修复空格问题\n* 增加GPU(cuda)支持，需要自行下载整合依赖库\n* windows下的free()方法更焕为_aligned_free()\n* 修改默认输入参数\n* 修改benchmark输出样式\n\n#### 2022-10-28 update v1.2.1\n\n* 适配onnxruntime 1.13.1\n* 修了些warning\n\n#### 2023-02-13 update v1.2.2\n\n* 适配onnxruntime 1.14.0\n\n#### 2024-01-07 update v1.2.3\n\n* onnxruntime 1.15.1\n* opencv 4.8.1\n\n### 模型下载\n\n整合好的范例工程自带了模型，在models文件夹中\n\n```\nRapidOcrOnnx/models\n    ├── ch_PP-OCRv3_det_infer.onnx\n    ├── ch_PP-OCRv3_rec_infer.onnx\n    ├── ch_ppocr_mobile_v2.0_cls_infer.onnx\n    └── ppocr_keys_v1.txt\n```\n\n### [编译说明](./BUILD.md)\n\n### [GPU版附加说明](./onnxruntime-gpu/README.md)\n\n### 测试说明\n\n1. 根据系统下载对应的程序包linux-bin.7z、macos-bin.7z、windows-bin.7z，并解压.\n2. 把上面的模型下载，解压到第一步解压的文件夹里.\n3. 终端运行run-test.sh或命令行运行run-test.bat，查看识别结果.\n4. 终端运行run-benchmark.sh或命令行运行run-benchmark.bat，查看识别过程平均耗时.\n\n### FAQ\n\n#### windows10下bat执行错误\n\n- 在win、linux、mac系统下，文本文件使用不同的换行符格式，win是CRLF，linux是LF，mac是CR\n- github的\"Download ZIP\"按钮下载的整个仓库代码，默认格式是UNIX换行符，此时bat脚本在windows平台执行会出错\n- 解决方法1：从Release中下载完整工程压缩包\n- 解决方法2：使用git clone命令同步仓库代码，git可以自动转换文件格式\n- 解决方法3：使用UltraEdit等文本编辑器，把bat文件的换行符转成win格式\n\n#### windows静态链接msvc\n\n- 作用:静态链接CRT(mt)可以让编译出来的包，部署时不需要安装c++运行时，但会增大包体积；\n- 需要mt版的引用库，参考编译说明，下载mt版的库；\n\n#### windows提示缺少\"VCRUNTIME140_1.dll\"\n\n下载安装适用于 Visual Studio 2015、2017 和 2019 的 Microsoft Visual C++ 可再发行软件包\n[下载地址](https://support.microsoft.com/zh-cn/help/2977003/the-latest-supported-visual-c-downloads)\n\n#### Windows7执行错误|中文乱码\n\n1. cmd窗口左上角-属性\n2. 字体选项卡-选择除了“点阵字体”以外的TrueType字体,例如:Lucida Console、宋体\n3. 重新执行bat\n\n### Windows调试运行\n\n* 下载范例项目工程自带的引用库是Release版，不能用于调试运行\n* debug版的引用库未压缩时容量超过1GB，极限压缩后也超过了100MB，请自行编译或到群共享里寻找\n* debug版的引用库必须是md版\n* 把debug版的引用库替换到范例工程的对应文件夹\n* 双击generate-vs-project.bat，选择2)Debug，生成对应的build-win-vsxxx-xx文件夹\n* 进入生成的文件夹，打开RapidOcrOnnx.sln\n* 右边解决方案管理器，选中RapidOcrOnnx，右键-\u003e设为启动项目，并生成(查看输出log，确保生成成功)\n* 如果引用库是dll，需要把对应的dll文件，例onnxruntime.dll复制到build-win-vsxxx-xx文件夹\\Debug，跟上一步生成的RapidOcrOnnx.exe放在一起\n* 右边解决方案管理器，选中RapidOcrOnnx，右键-\u003e属性-\u003e调试-\u003e\n  命令参数-\u003e```--models ../models --det ch_PP-OCRv3_det_infer.onnx --cls ch_ppocr_mobile_v2.0_cls_infer.onnx --rec ch_PP-OCRv3_rec_infer.onnx --keys ppocr_keys_v1.txt --image ../images/1.jpg```\n* 工具栏，点击绿色三角号启动\"本地Windows调试器\"\n* 第一次运行的话，查看左下角，等待加载各dll符号，网络不好的话，要等挺久的\n\n### 输入参数说明\n\n* 请参考main.h中的命令行参数说明。\n* 每个参数有一个短参数名和一个长参数名，用短的或长的均可。\n\n1. ```-d或--models```：模型所在文件夹路径，可以相对路径也可以绝对路径。\n2. ```-1或--det```:det模型文件名(含扩展名)\n3. ```-2或--cls```:cls模型文件名(含扩展名)\n4. ```-3或--rec```:rec模型文件名(含扩展名)\n5. ```-4或--keys```:keys.txt文件名(含扩展名)\n6. ```-i或--image```：目标图片路径，可以相对路径也可以绝对路径。\n7. ```-t或--numThread```：线程数量。\n8. ```-p或--padding```：图像预处理，在图片外周添加白边，用于提升识别率，文字框没有正确框住所有文字时，增加此值。\n9. ```-s或--maxSideLen```\n   ：按图片最长边的长度，此值为0代表不缩放，例：1024，如果图片长边大于1024则把图像整体缩小到1024再进行图像分割计算，如果图片长边小于1024则不缩放，如果图片长边小于32，则缩放到32。\n10. ```-b或--boxScoreThresh```：文字框置信度门限，文字框没有正确框住所有文字时，减小此值。\n11. ```-o或--boxThresh```：请自行试验。\n12. ```-u或--unClipRatio```：单个文字框大小倍率，越大时单个文字框越大。此项与图片的大小相关，越大的图片此值应该越大。\n13. ```-a或--doAngle```：启用(1)/禁用(0) 文字方向检测，只有图片倒置的情况下(旋转90~270度的图片)，才需要启用文字方向检测。\n14. ```-A或--mostAngle```：启用(1)/禁用(0) 角度投票(整张图片以最大可能文字方向来识别)，当禁用文字方向检测时，此项也不起作用。\n15. ```-h或--help```：打印命令行帮助。\n\n### 关于内存泄漏与valgrind\n\n* 项目根目录的valgrind-memcheck.sh用来检查内存泄漏(需要debug编译)。\n* 常见的并行库有tbb，hpx，openmp，gcd，concurrency，pthread\n* 并行库的种类可以看：https://docs.opencv.org/4.x/db/d05/tutorial_config_reference.html\n* 测试了openmp和pthread，目前已知这类并行库会导致检查报告中出现\"possibly lost\"\n* opencv只做简单的图像预处理，可以完全不使用任何并行库，但需要定制编译\n* onnxruntime1.6.0或之前，默认引用openmp，从1.7.0开始默认关闭openmp并使用自带的ThreadPool代码\n* 阅读报告可以看出\"possibly lost\"发生位置均在引用的第三方库(如果使用了并行库的话)，如opencv或onnxruntime\n* \"possibly lost\"不一定是内存泄露\n* 如果opencv想定制编译不使用任何并行库，可以使用以下参数进行编译\n\n```\n-DWITH_TBB=OFF\n-DWITH_HPX=OFF\n-DWITH_OPENMP=OFF\n-DWITH_GCD=OFF\n-DWITH_CONCURRENCY=OFF\n-DWITH_PTHREADS_PF=OFF\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidai%2Frapidocronnx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapidai%2Frapidocronnx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidai%2Frapidocronnx/lists"}