{"id":18273614,"url":"https://github.com/rapidai/rapidocrncnnjvm","last_synced_at":"2025-04-12T03:10:59.787Z","repository":{"id":61740069,"uuid":"554680565","full_name":"RapidAI/RapidOcrNcnnJvm","owner":"RapidAI","description":"RapidOcr ncnn java kotlin jni","archived":false,"fork":false,"pushed_at":"2025-03-25T06:05:37.000Z","size":1509,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T07:22:05.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","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-20T07:56:05.000Z","updated_at":"2025-03-25T06:05:40.000Z","dependencies_parsed_at":"2024-12-22T17:42:19.747Z","dependency_job_id":"21ab12bf-6bb6-46c6-9cf9-379618e178da","html_url":"https://github.com/RapidAI/RapidOcrNcnnJvm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidOcrNcnnJvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidOcrNcnnJvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidOcrNcnnJvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RapidAI%2FRapidOcrNcnnJvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RapidAI","download_url":"https://codeload.github.com/RapidAI/RapidOcrNcnnJvm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248510000,"owners_count":21116131,"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:04.833Z","updated_at":"2025-04-12T03:10:59.781Z","avatar_url":"https://github.com/RapidAI.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RapidOcrNcnnJvm\n\n### Project下载\n\n* 整合好源码和依赖库的完整工程项目，可在Release中下载(github)\n* 可到Q群共享内下载，找Project_RapidOcrNcnnJvm压缩包文件\n* [QQ群](https://rapidai.github.io/RapidOCRDocs/main/communicate/#qq)\n* 如果想自己折腾，则请继续阅读本说明\n\n### Demo下载(win、mac、linux)\n\n编译好的demo，可以到Q群共享内下载 或者Release下载\n\n* jni部分代码请参考[C++项目](https://github.com/RapidAI/RapidOcrNcnn)\n* 各PC平台jni库[下载](https://github.com/RapidAi/RapidOcrNcnn/releases)\n* 因为jvm代码不常更新，可以把新版的jni库(例1.1.0)替换到旧版的demo里(比如1.0.0)\n\n### 介绍\n\n* 本项目为java或kotlin通过jni调用RapidOcrNcnn动态运行库的范例。\n\n### 编译环境\n\n1. jdk 1.8(参考动态运行库编译说明安装)\n2. gradle(可由IDE自动安装)\n3. IDE: IDEA 2021.2\n\n### 调试\u0026编译说明\n\n1. 开始JVM部分编译之前，请先完成编译RapidOcrNcnn动态运行库，参考[此页面](https://github.com/RapidAI/RapidOcrOnnx)的编译说明。\n2. 把预先编译好的动态运行库复制到run-test文件夹，根据您选择的编译类型，macOS、linux可能还需要额外配置动态库的搜索路径\n3. 从第1步的说明中找到模型下载地址，放到run-test/models文件夹，测试的目标图片放到run-test/images文件夹\n4. 用IDEA打开本项目\n5. Main.java为java版调用范例，main.kt为kotlin版调用范例，之后以kotlin为范例来说明\n6. IDEA中直接在在main方法左边点击绿色的运行图标，可以直接调试运行范例，但此时没有输入参数。\n\n* 编辑运行参数：顶部工具栏“运行”图标左边，点开下拉菜单“Edit Configurations”\n* VM options:添加```-Djava.library.path=run-test```，把run-test文件夹加到java的lib搜索路径\n* Program arguments:添加``run-test/models dbnet_op angle_op crnn_lite_op keys.txt run-test/test_imgs/1.jpg```，添加命令行输入参数\n* 命令行参数models文件夹里必须有相应的模型文件，接下来的四个文件名对应模型文件夹里的3种模型(不含扩展名)和1个keys文件，请确认文件名无误\n* run-test/images/1.jpg是待识别的目标图片\n* 点击运行，正常的话就可以输出识别结果。\n\n8. 编译为jar包(以Kotlin为例)：在菜单栏找到Project Structure\n\n* 转到“Artifacts”选项卡\n* 按“+”号新建配置，Add-\u003eJar-\u003eEmpty\n* 编辑Name:RapidOcrNcnnJvm，下面列表左边的名称也会对应改为“RapidOcrNcnnJvm.jar”，这是最终输出的文件名\n* 选中左边列表的“RapidOcrNcnnJvm.jar”，底部出现两个按钮，选择“Use Existing Manifest...”，选择src/main/resources/META-INF/MANIFEST.MF\n* 展开右边列表，找到RapidOcrNcnnJvm/main/“RapidOcrNcnnJvm.main compile output”，右键“Put into Output Root”\n* 选中右边列表的几个Gradle依赖包，“kotlin-stdlib-xxx:版本”/“annotations:版本”，右键“Extract Into Output\n  Root”\n* 按“OK”关闭项目设置窗口\n* 打开菜单栏Build-\u003eBuild Artifacts，找到刚才的配置，并选Build\n* 找到out/artifacts/RapidOcrNcnnJvm/RapidOcrNcnnJvm.jar，并复制到run-test文件夹\n* 测试jar包是否正确编译：顶部Demo下载解压，把编译出来的jar包复制替换进去，然后使用run-test脚本测试。\n\n  ![avatar](capture/Artifacts.png)\n\n### 其它问题\n\n1. windows部署时如果运行显示错误can’t find dependent libraries\n\n* 检查是否安装C++运行环境，https://support.microsoft.com/zh-cn/help/2977003/the-latest-supported-visual-c-downloads\n  下载安装：vc_redist.x64.exe\n\n2. 运行Java Main时出现\n\n```\nError: A JNI error has occurred, please check your installation and try again\nException in thread \"main\" java.lang.UnsupportedClassVersionError: com/benjaminwan/ocr/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0\n```\n\n* 配置Project-\u003e ProjectSDK: 选择合适的版本，最好跟以下的选项一致\n* 配置JAVA Runtime版本：调试运行按钮旁边-\u003e Edit Configurations-\u003e Build And Run-\u003e 选择合适的版本\n* 修改Preferences-\u003e Build,Execution,Deployment-\u003e Gradle-\u003e Gradle JVM:选择合适的版本(跟运行时JAVA版本相关)\n  ![avatar](capture/ProjectStructure.png)\n  ![avatar](capture/RunConfigrationJvm.png)\n  ![avatar](capture/GradleJvm.png)\n\n## 示例图\n\n* Java Main运行配置\n  ![avatar](capture/JavaRunConfiguration.png)\n\n* Kotlin Main运行配置\n  ![avatar](capture/KotlinRunConfigration.png)\n\n* 运行结果\n  ![avatar](capture/RunResult.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidai%2Frapidocrncnnjvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapidai%2Frapidocrncnnjvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapidai%2Frapidocrncnnjvm/lists"}