Files
ssw c303c315e5 rocr: rusto-rs 源码入库(上游 v0.2.5 基线 57609fc + 本地补丁)
- 源码 316 文件收编为 rusto-rs/ 文件夹,随本仓库管理
- 移除内部 .git(补丁已存档 docs/rusto-rs-metal-patch-20260912.patch,上游可随时 re-clone)
- target/ 与 docs/.yarn 缓存不入库;本地改动:ROCR_* 环境变量调优 + Metal 链接修复 + 预处理测试脚本
2026-09-12 17:30:04 +08:00

4.8 KiB

title, description, navigation, seo
title description navigation seo
Installation How to install RustO! across Rust, .NET, React Native, iOS, Android, and Native C FFI.
icon
i-ph-download
title description
Installation - RustO! How to install RustO! across Rust, .NET, React Native, iOS, Android, and Native C FFI.

RustO! is packaged modularly across multiple language package managers. Choose your target environment below.

1. Rust (Cargo.toml)

Add rusto-rs via cargo:

cargo add rusto-rs

Or add it directly to your Cargo.toml:

[dependencies]
rusto-rs = "0.2.4"

Optional Cargo Features

Feature Description
ffi Enables C FFI and JNI bindings for embedding RustO! into foreign runtimes.
use-opencv Enables optional OpenCV backend for comparison testing and visual parity validation.
build-from-source Compiles the underlying MNN C++ inference engine from source rather than prebuilt binaries.
metal Enables Apple Metal GPU acceleration on macOS and iOS.
coreml Enables Apple CoreML neural engine backend on Apple Silicon.
vulkan Enables Vulkan compute shader acceleration for modern GPUs on Linux/Windows/Android.
opencl Enables OpenCL acceleration on supported GPUs.
cuda Enables NVIDIA CUDA acceleration on Linux/Windows.
nnapi Enables Android Neural Networks API acceleration on compatible mobile chipsets.

2. .NET / C# (NuGet)

Install the core package from NuGet:

dotnet add package RustODotnet

Pre-Packaged Model Bundles

To include lightweight pre-packaged models without manually managing .mnn assets on disk, add one of the official model packages:

# Recommended default PP-OCRv6 Tiny models (~6 MB total)
dotnet add package RustODotnet.Models.PPOCRv6.Tiny

# Or specialized language/tier model packages:
dotnet add package RustODotnet.Models.PPOCRv6.Small
dotnet add package RustODotnet.Models.PPOCRv5.Latin
dotnet add package RustODotnet.Models.PPOCRv4.Japanese

3. React Native (npm / yarn / pnpm)

Install the React Native npm package:

# Using npm
npm install react-native-rusto

# Using Yarn
yarn add react-native-rusto

# Using pnpm
pnpm add react-native-rusto

iOS Setup (ios/Podfile)

Add your preferred OCR model pod inside your app target in ios/Podfile:

target 'YourApp' do
  # Add the model pod:
  pod 'RustO-Models-PPOCRv6-Tiny' # ~6 MB (Recommended)
  # or pod 'RustO-Models-PPOCRv6-Small'
  # or pod 'RustO-Models-PPOCRv5-Mobile'
end

Then install the CocoaPods dependencies:

cd ios && pod install

Android Setup (android/build.gradle & android/app/build.gradle)

In your root android/build.gradle or settings.gradle, verify that JitPack is included:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

In android/app/build.gradle, add the corresponding model package:

dependencies {
    implementation 'com.github.byrizki.rusto-rs:rusto-models-ppocrv6-tiny:v0.2.4'
}

4. iOS (Swift / CocoaPods)

In your project's Podfile:

target 'YourApp' do
  use_frameworks!

  # Core runtime
  pod 'RustO'

  # Model bundle
  pod 'RustO-Models-PPOCRv6-Tiny'
end

Run pod install.


5. Android (Kotlin / Gradle)

Ensure JitPack repository is registered in your root settings.gradle:

repositories {
    maven { url 'https://jitpack.io' }
}

Add the core library and model package in your app's build.gradle:

dependencies {
    // Core OCR runtime with native JNI shared libraries
    implementation 'com.github.byrizki.rusto-rs:rusto-android:v0.2.4'

    // Bundled PP-OCRv6 Tiny models
    implementation 'com.github.byrizki.rusto-rs:rusto-models-ppocrv6-tiny:v0.2.4'
}

6. C / Native Shared Libraries & Headers

Pre-compiled dynamic shared libraries and headers are published with every GitHub Release:

  • Linux: librusto.so (x86_64, aarch64)
  • macOS: librusto.dylib (Universal arm64 + x86_64)
  • Windows: rusto.dll, rusto.lib (x64, arm64)
  • C Header: librusto.h

To compile from source with FFI enabled:

cargo build --release --features ffi

The output dynamic and static libraries will be located in target/release/.