# CoreOCROnnx
**Repository Path**: corallite/CoreOCROnnx
## Basic Information
- **Project Name**: CoreOCROnnx
- **Description**: 免费离线基于Onnxruntime/OpenVino/TensorRT极速版OCR组件,支持PaddleOCR的Onnx/IR/TRT模型,支持C#/C++/java/Python/Go语言开发,支持多线程并发。
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-11-30
- **Last Updated**: 2026-12-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
[](README.md) [
](README_EN.md)
## NuGet Backends and Deployment
Building this repository requires Visual Studio 2022 or later and the .NET 10 SDK. The native library is `PaddleOCROnnx.dll` on Windows and `PaddleOCROnnx.so` on Linux. Match the application process's operating system and architecture to the runtime package.
### Runtime Packages
A C# application uses `CoreOCROnnx.SDK` and one runtime package for its target environment. The Web API already references the SDK project, so select the runtime package directly. Backends share native library filenames, so publish them to separate directories. [NuGet runtime packages](https://www.nuget.org/packages?q=CoreOCRRuntime)
| NuGet package | Platform/architecture | Inference device | Main model formats | License requirement |
| --- | --- | --- | --- | --- |
| [`CoreOCRRuntime.Onnx.CPU.win-x86`](https://www.nuget.org/packages/CoreOCRRuntime.Onnx.CPU.win-x86) | Windows x86 | CPU | `.onnx` | Not required |
| [`CoreOCRRuntime.Onnx.CPU.win-x64`](https://www.nuget.org/packages/CoreOCRRuntime.Onnx.CPU.win-x64) | Windows x64 | CPU | `.onnx` | Not required |
| [`CoreOCRRuntime.Onnx.CPU.linux-x64`](https://www.nuget.org/packages/CoreOCRRuntime.Onnx.CPU.linux-x64) | Linux x64 | CPU | `.onnx` | Required |
| [`CoreOCRRuntime.DirectML.win-x86`](https://www.nuget.org/packages/CoreOCRRuntime.DirectML.win-x86) | Windows x86 | DirectML GPU; CPU is also available | `.onnx` | Not required for CPU; required for GPU |
| [`CoreOCRRuntime.DirectML.win-x64`](https://www.nuget.org/packages/CoreOCRRuntime.DirectML.win-x64) | Windows x64 | DirectML GPU; CPU is also available | `.onnx` | Not required for CPU; required for GPU |
| [`CoreOCRRuntime.OpenVino.win-x64`](https://www.nuget.org/packages/CoreOCRRuntime.OpenVino.win-x64) | Windows x64 | CPU and Intel GPU | `.onnx`, `.xml` + `.bin` | CPU mode is free, GPU mode requires a GPU license |
| [`CoreOCRRuntime.OpenVino.linux-x64`](https://www.nuget.org/packages/CoreOCRRuntime.OpenVino.linux-x64) | Linux x64 | CPU and Intel GPU | `.onnx`, `.xml` + `.bin` | Both modes require activation, GPU mode requires a GPU license |
| [`CoreOCRRuntime.TensorRT.GPU.win-x64`](https://www.nuget.org/packages/CoreOCRRuntime.TensorRT.GPU.win-x64) | Windows x64 | NVIDIA GPU | `.onnx`, `.engine`, `.plan` | GPU license required |
| [`CoreOCRRuntime.TensorRT.GPU.linux-x64`](https://www.nuget.org/packages/CoreOCRRuntime.TensorRT.GPU.linux-x64) | Linux x64 | NVIDIA GPU | `.onnx`, `.engine`, `.plan` | GPU license required |
Selection guide:
- For general CPU deployments or minimal external dependencies, choose the ONNX Runtime CPU package for the target platform.
- For AMD, Intel, or NVIDIA GPUs on Windows, choose DirectML.
- For OpenVINO inference on a CPU or Intel GPU, choose the package for Windows or Linux.
- For maximum performance on NVIDIA GPUs on Windows or Linux, choose TensorRT.
Runtime packages include PP-OCRv6 ONNX sample models, recognition dictionaries, and related resources. These files are placed in the application output after installation or publishing. Windows packages also provide a license request-code utility; on Linux, obtain the request code through the SDK's `GetLicenseRequestCode()` method. You may replace the sample models with your own compatible models; keep every model and dictionary used by the deployed application.
### Licensing and Native Dependencies
- Windows CPU mode is free and does not require license activation.
- Windows GPU modes (DirectML, OpenVINO GPU, and TensorRT) require a license that permits GPU use.
- Linux requires license activation for both CPU and GPU use. NuGet packages do not include an activated commercial license.
- When a license is required, generate the request code on the final deployment machine and apply for a license matching that machine, platform, and product version at [CoreOCROnnx Online Licensing](http://ocr.axinw.com).
- The DirectML and OpenVINO runtime packages copy their dependencies into the output directory. For manual deployment, copy the complete runtime.
- TensorRT deployments require TensorRT 11.1, CUDA 12.9, and a compatible NVIDIA driver. [TensorRT installation](#tensorrt-installation)
For manual native-library deployment, download the matching version from [GitHub Releases](https://github.com/PaddleOCRCore/CoreOCROnnx/releases). Copy the complete dependency set from the archive, and never mix files from different backends or architectures.
## Parameters
| Parameter | Default | Description |
| --------- | ------- | ----------- |
| det_model_dir | - | Path to the text detection inference model. |
| cls_model_dir | - | Path to the text direction classifier inference model. |
| rec_infer | - | Path to the text recognition inference model. |
| keys | - | Path to the dictionary paired with the recognition model. PP-OCRv6 tiny uses `ppocrv6tiny_dict.txt`. |
| General parameters | -- | -- |
| cpu_mem | 4000 | CPU memory limit in MB. Use `-1` for no limit. |
| cpu_math_library_num_threads | 10 | Number of CPU inference threads. More threads generally improve inference speed when sufficient CPU cores are available. |
| cpu_threads | 8 | Number of CPU inference threads. The default value is 8. |
| use_gpu | false | Whether to use a GPU. The TensorRT backend always uses a GPU; this parameter is retained only for ABI compatibility. |
| gpu_id | 0 | GPU ID. For TensorRT, this selects the CUDA device. |
| gpu_mem | 4000 | GPU memory parameter. Its actual meaning and availability depend on the selected backend. |
| padding | 20 | Adds a white border during image preprocessing to improve recognition. Increase this value when text boxes do not fully enclose the text. |
| maxSideLen | 1024 | Maximum length of the image's longest side. Use `0` to disable resizing. For example, a value of `1024` resizes images whose longest side exceeds 1024 pixels. |
| boxScoreThresh | 0.5 | Text-box confidence threshold. Lower this value when text boxes do not fully enclose the text. |
| boxThresh | 0.3 | Detection box threshold. Tune this value for your use case. |
| unClipRatio | 1.6 | Scale factor for individual text boxes. Larger values produce larger boxes. The ideal value depends on image dimensions and may need to be increased for larger images. |
| doAngle | true | Enable text direction detection only when images may be rotated by 90-270 degrees. |
| mostAngle | true | Enable (`1`) or disable (`0`) angle voting, which recognizes the whole image using the most probable text direction. This option has no effect when direction detection is disabled. |
| visualize | false | Visualize results. When `true`, annotated images are saved under the `output` directory using the input image names. |
| enable_log | false | Write logs to files under the `log` directory. |
| isOutputConsole | true | Write logs to the console. |
### YoloInitJson Parameters
`YoloInitJson` initializes a YOLO model from a JSON parameter string. Complete `parameterjson` example:
```json
{
"model_type": 1,
"input_width": 640,
"input_height": 640,
"confidence_threshold": 0.25,
"point_score_threshold": 0.25,
"iou_threshold": 0.45,
"enable_nms": false,
"key_points_num": 17,
"num_threads": 4,
"use_gpu": false,
"gpu_id": 0,
"warmup": true,
"visualize": false,
"enable_log": false,
"class_names_preset": "auto",
"class_names": ["person", "car"],
"class_names_file": "coco.names"
}
```
| Parameter | Example | Description |
| --- | --- | --- |
| `model_type` | `1` | Model type: `1`=detect, `2`=pose, `3`=classification, `4`=detect FP16, `5`=pose FP16, `6`=classification FP16, `7`=seg, `8`=obb, `9`=seg FP16, and `10`=obb FP16. |
| `input_width` / `input_height` | `640` | Model input dimensions. Fixed dimensions can be read automatically from an ONNX model; dynamic dimensions default to 640 when omitted. |
| `confidence_threshold` | `0.25` | Object or class confidence threshold. Candidates below this value are filtered out. |
| `point_score_threshold` | `0.25` | Pose keypoint drawing threshold. Keypoints and skeleton lines below this value are not drawn. |
| `iou_threshold` | `0.45` | Overlapping-box threshold for NMS. It applies only when `enable_nms=true`. |
| `enable_nms` | `false` | Enable NMS. The default is `false`. When disabled, detection results are not filtered by overlap; raw Tensor API output is unaffected. |
| `key_points_num` | `17` | Number of keypoints in a pose model. COCO human-pose models normally use 17. |
| `num_threads` | `4` | Number of CPU inference threads. The default is 1. |
| `use_gpu` | `false` | Use a GPU or accelerated backend. The license must permit it, and the corresponding backend build is required. TensorRT always uses a GPU. |
| `gpu_id` | `0` | GPU device ID. The default is 0. |
| `warmup` | `true` | Run one warm-up inference after initialization. The default is `true`. |
| `visualize` | `false` | Save visualized images under `output`. JSON APIs return `vis_path`; Tensor APIs perform visualization only as a side effect. |
| `enable_log` | `false` | Write YOLO runtime logs to the console. |
| `class_names_preset` | `"auto"` | Class-name preset: `auto` selects names based on the model task, while `none` disables preset class names. |
| `class_names` | `["person", "car"]` | Class names supplied as a JSON array or a comma/newline-delimited string. This takes precedence over `class_names_preset`. |
| `class_names_file` | `"coco.names"` | Path to a class-name file containing one name per line. When set, it overrides `class_names`. |
API declaration:
```cpp
Paddle_API bool CALL_CONV YoloInitJson(const char* modelPath, const char* parameterjson);
```
- `modelPath`: path to a YOLO ONNX model. Formats supported by the selected OpenVINO or TensorRT backend may also be used.
- `parameterjson`: YOLO initialization parameters as a JSON string.
- Return value: `true` on success or `false` on failure. Call `GetError` for error details.
## TensorRT Installation
The TensorRT backend requires **TensorRT 11.1 and CUDA 12.9**, a Windows or Linux x64 process, an NVIDIA GPU, a driver compatible with CUDA 12.9, and a license that permits GPU inference.
| Dependency | NVIDIA downloads |
| --- | --- |
| TensorRT 11.1.0.106 | [Windows x64 (ZIP)](https://developer.download.nvidia.com/compute/machine-learning/tensorrt/11.1.0/zip/TensorRT-Enterprise-11.1.0.106-Windows-amd64-cuda-12.9-Release-external.zip) · [Linux x86_64 (TAR.ZST)](https://developer.download.nvidia.com/compute/machine-learning/tensorrt/11.1.0/tars/TensorRT-Enterprise-11.1.0.106-Linux-x86_64-cuda-12.9-Release-external.tar.zst) |
| CUDA 12.9 | [CUDA 12.9.2 download page](https://developer.nvidia.com/cuda-12-9-2-download-archive) |
1. Install CUDA 12.9, extract the TensorRT archive for your platform, and select the matching CoreOCR runtime package, `CoreOCRRuntime.TensorRT.GPU.win-x64` or `CoreOCRRuntime.TensorRT.GPU.linux-x64`.
2. On Windows, add the TensorRT DLL directory to the application's `PATH` or place the DLLs alongside `PaddleOCROnnx.dll`. Ensure the process can load `nvinfer_11.dll`, `nvonnxparser_11.dll`, the matching builder resource DLLs, and the CUDA runtime.
3. On Linux, add TensorRT's `lib` directory to the system library search path or `LD_LIBRARY_PATH`. Ensure the process can load `libnvinfer.so.11`, `libnvonnxparser.so.11`, the matching builder resource libraries, and the CUDA runtime.
## OCR Performance
### Test Method
- The model was PP-OCRv6 tiny.
- Every backend used the same image of a shampoo bottle.
- Each backend ran two initialization warm-up passes, then 60 iterations. The statistics use the final 50 iterations.
- The inference thread setting was 8.
- Angle classification was enabled with `mostAngle=true`.
- Other time is the end-to-end time minus detection, angle classification, and recognition. It includes cropping, rotation, result assembly, and sorting.
- CPU backends used `use_gpu=false`. GPU backends used device 0.
- The benchmark measures OCR on a single image. FPS is `1000 / mean end-to-end latency in ms`. Relative latency is measured against the lowest mean latency on the same platform and rounded to two decimal places.
### Test Environment
- Windows 11 and Ubuntu 24.04 LTS both used an Intel Core Ultra 7 265K.
- Both reports listed an NVIDIA GeForce RTX 5070 Ti. The Windows report also listed Intel Graphics. TensorRT used the NVIDIA GPU and OpenVINO GPU used the Intel GPU.
### Windows 11 Results
| Backend | Device | Status | Mean end-to-end ms | P50 ms | P95 ms | FPS | Detection ms | Angle classification ms | Recognition ms | Other ms | Relative to fastest |
|---|---|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| TensorRT GPU x64 | GPU | Passed | 19.68 | 20.1 | 21.82 | 50.82 | 2.77 | 3.81 | 12.32 | 0.78 | 1.00x |
| ONNX CPU x64 | CPU | Passed | 27.63 | 27.48 | 28.73 | 36.2 | 8.6 | 5.8 | 12.49 | 0.73 | 1.41x |
| ONNX CPU x86 | CPU | Passed | 71.22 | 70.23 | 78.92 | 14.04 | 22.04 | 11.42 | 36.91 | 0.86 | 3.63x |
| OpenVINO CPU x64 | CPU | Passed | 26.2 | 25.96 | 28.14 | 38.17 | 5.55 | 4.86 | 15.09 | 0.7 | 1.34x |
| OpenVINO GPU x64 | GPU | Passed | 66.14 | 66.03 | 68.11 | 15.12 | 17.61 | 7.23 | 40.52 | 0.77 | 3.37x |
| ONNX DirectML x64 | GPU | Passed | 19.6 | 19.61 | 20.16 | 51.01 | 4.33 | 2.95 | 11.61 | 0.71 | 1.00x |
| ONNX DirectML x86 | GPU | Passed | 47.1 | 46.69 | 49.09 | 21.23 | 5.17 | 3.15 | 37.91 | 0.88 | 2.40x |
### Ubuntu 24.04 LTS Results
| Backend | Device | Status | Mean end-to-end ms | P50 ms | P95 ms | FPS | Detection ms | Angle classification ms | Recognition ms | Other ms | Relative to fastest |
|---|---|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| TensorRT GPU x64 | GPU | Passed | 18.29 | 18.15 | 22.06 | 54.67 | 2.77 | 3.48 | 11.47 | 0.56 | 1.00x |
| ONNX CPU x64 | CPU | Passed | 35.03 | 34.88 | 36.53 | 28.54 | 10 | 7.04 | 17.41 | 0.59 | 1.92x |
| OpenVINO CPU x64 | CPU | Passed | 29.22 | 29.2 | 31.24 | 34.22 | 5.59 | 3.92 | 19.1 | 0.62 | 1.60x |
| OpenVINO GPU x64 | GPU | Passed | 101.21 | 100.29 | 108.61 | 9.88 | 21.48 | 10.16 | 68.85 | 0.72 | 5.53x |
## Developer Community
Join QQ group 475159576 or add QQ contact 2380243976 to discuss the project. If you find the project useful, please give it a free Star.
## Donate
If this project has helped you, scan the QR code below to buy the author a coffee.
## Changelog
### v4.3.0 `2026.11.30`
- Optimized `PaddleOCROnnx.dll`, the native inference library, to substantially improve OCR recognition speed. [OCR performance results](#ocr-performance)
- Unified the Windows OpenVINO CPU and Intel GPU runtime packages and added a Linux x64 package with both inference modes.
### v4.2.1 `2026.9.22`
- Updated the OCR runtime for faster recognition, set the default to eight CPU inference threads, and made the number of OCR engine instances configurable for concurrent inference.
- Added support for Chinese characters in model and image paths and made character-level bounding boxes available on request.
- Updated the C++, C#, Go, Python, and WinForms demos and improved asynchronous processing and logging for batch recognition in WinForms. [GitHub release notes](https://github.com/PaddleOCRCore/CoreOCROnnx/releases/tag/v4.2.1)
### v4.1.0 `2026.7.15`
- Added TensorRT backend support.
### v4.0.0 `2026.6.7`
- Added YOLO and OpenVINO support.
### v1.0.0 `2026.1.18`
- Initial release: CoreOCROnnx.WebApi.
## Star
[](https://star-history.com/#PaddleOCRCore/CoreOCROnnx&Date)
## License
This project is released under the [Apache License Version 2.0](./LICENSE). Contributions are welcome.
## Use Restrictions and Disclaimer for CoreOCROnnx and the Companion E Language Module
This disclaimer applies to the CoreOCROnnx recognition engine, the CoreOCR module for calling the engine from E Language, and all accompanying sample programs, API documentation, and utilities (collectively, the "Software"). Please read this disclaimer in full before using the Software. By downloading, installing, copying, or using the Software, you are deemed to have fully understood and agreed to all of its terms.
### 1. Conditions for Lawful Use
You may use the Software's features, including screen capture, text recognition, and object detection, only if you comply with all applicable laws and regulations and have obtained all legally required authorizations for the intended use. Any use beyond the scope of your lawful authorization is expressly prohibited.
### 2. Prohibited Uses
#### Game Assistance and Cheating
You must not use the Software to develop, test, run, sell, or distribute to others any game assistance tools, cheats, or automated cheating scripts. Prohibited uses include using the Software's window capture, text recognition, or object detection features to implement automatic aiming, automated combat, unattended farming of in-game resources, automatic task completion, circumvention of or interference with anti-cheat mechanisms, or other functions that undermine fair play.
You must not indirectly help third parties engage in any of these prohibited gaming activities, including by wrapping or repackaging the Software, providing a remote recognition API, or processing recognition requests on another party's behalf.
#### Unlawful Activities and Infringement
You must not use the Software to commit fraud, steal other people's account credentials, unlawfully monitor their activities, misappropriate trade secrets, or engage in any other activity that violates applicable laws or regulations.
Without the express written authorization of the screen owner and the parties concerned with the content, you must not capture another person's screen, recognize the contents of private communications, or extract sensitive personal information. You must not unlawfully collect, store, use, sell to others, or distribute personally identifiable information, account credentials, private data, or any other legally protected information.
### 3. Responsibility and Limitation of Liability
If you violate any prohibition in Section 2, you are solely responsible for all resulting consequences, including game account bans, device restrictions, financial losses to you or third parties, enforcement action by platform operators, administrative penalties, and any resulting criminal liability.
To the fullest extent permitted by the laws of the People's Republic of China, the developers and publishers of the Software bear no direct or indirect liability for your prohibited use or any resulting consequences. They are under no obligation to provide any assistance, defense, or compensation in connection with your prohibited use.
Nothing in this disclaimer excludes or limits any statutory liability that cannot lawfully be excluded or limited.