BaoBao.PaddleOCR.Models
0.1.0
dotnet add package BaoBao.PaddleOCR.Models --version 0.1.0
NuGet\Install-Package BaoBao.PaddleOCR.Models -Version 0.1.0
<PackageReference Include="BaoBao.PaddleOCR.Models" Version="0.1.0" />
<PackageVersion Include="BaoBao.PaddleOCR.Models" Version="0.1.0" />
<PackageReference Include="BaoBao.PaddleOCR.Models" />
paket add BaoBao.PaddleOCR.Models --version 0.1.0
#r "nuget: BaoBao.PaddleOCR.Models, 0.1.0"
#:package BaoBao.PaddleOCR.Models@0.1.0
#addin nuget:?package=BaoBao.PaddleOCR.Models&version=0.1.0
#tool nuget:?package=BaoBao.PaddleOCR.Models&version=0.1.0
BaoBaoPaddleOCR.NET
BaoBaoPaddleOCR.NET is a local OCR wrapper built as C++ inference + .NET P/Invoke.
BaoBaoPaddleOCR.Native: native C ABI layerBaoBaoPaddleOCR: C# wrapperBaoBaoPaddleOCR.Cli: CLI for smoke tests and local debugging
Current defaults
The repo is now wired for the assumptions we have so far:
- PaddleOCR source root: bundled in this repo at
src/BaoBaoPaddleOCR.NET/PaddleOCR-3.4.0 - OpenCV root:
C:\opencv\build - Inference target: CPU
- Publish target:
win-x64 - Model layout: defaults to official PaddleOCR inference directories under the model root:
PP-OCRv5_server_det_inferPP-OCRv5_server_rec_inferPP-LCNet_x1_0_textline_ori_infer
Local prerequisites
This repo already bundles:
PaddleOCR-3.4.0paddle_inference
The machine still needs:
- Visual Studio C++ toolchain
- CMake or Visual Studio CMake tools
- OpenCV at
C:\opencv\buildor passed with-OpenCvDir
Build .NET
dotnet build .\src\BaoBaoPaddleOCR.NET\BaoBaoPaddleOCR.slnx
Pack NuGet
.\src\BaoBaoPaddleOCR.NET\pack-nuget.ps1 `
-Version 0.1.0 `
-Configuration Release `
-BuildNative `
-WithPaddleOcr `
-WithModels `
-PaddleInferenceDir .\src\BaoBaoPaddleOCR.NET\paddle_inference
Default output:
src/BaoBaoPaddleOCR.NET/artifacts/nuget/
Produced packages:
BaoBao.PaddleOCR: managed wrapper DLL and native runtime assets underruntimes/win-x64/nativeBaoBao.PaddleOCR.Models: OCR models undercontentFiles/any/any/models
By default, the models package copies bundled models to $(TargetDir)\models.
Set BaoBaoPaddleOCRCopyModels=false in the consuming project if you want to manage models yourself.
Publish To Local Feed
.\src\BaoBaoPaddleOCR.NET\publish-local-feed.ps1
Default local feed:
src/BaoBaoPaddleOCR.NET/artifacts/local-feed/
Publish To NuGet.org
.\src\BaoBaoPaddleOCR.NET\publish-nugetorg.ps1 `
-ApiKey "<your-nuget-api-key>" `
-SkipDuplicate
Consumer Sample
Sample project:
src/BaoBaoPaddleOCR.NET/samples/NuGetConsumer
After packing and publishing to the local feed:
dotnet build .\src\BaoBaoPaddleOCR.NET\samples\NuGetConsumer\NuGetConsumer.csproj -c Release
dotnet run --project .\src\BaoBaoPaddleOCR.NET\samples\NuGetConsumer\NuGetConsumer.csproj -c Release -- .\src\BaoBaoPaddleOCR.NET\PaddleOCR-3.4.0\test_tipc\web\test.jpg
Build native mock DLL
.\src\BaoBaoPaddleOCR.NET\build-native.ps1 -Configuration Release
Build native PaddleOCR DLL
.\src\BaoBaoPaddleOCR.NET\build-native.ps1 `
-Configuration Release `
-WithPaddleOcr `
-PaddleInferenceDir .\src\BaoBaoPaddleOCR.NET\paddle_inference
If you need GPU later:
.\src\BaoBaoPaddleOCR.NET\build-native.ps1 `
-Configuration Release `
-WithPaddleOcr `
-WithGpu `
-PaddleInferenceDir "D:\deps\paddle_inference" `
-CudaLibDir "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\lib\x64" `
-CudnnLibDir "C:\tools\cudnn\lib\x64"
Run CLI
Mock mode:
$env:BAOBAO_PADDLEOCR_MOCK_TEXT = "mock result"
dotnet run --project .\src\BaoBaoPaddleOCR.NET\BaoBaoPaddleOCR.Cli\BaoBaoPaddleOCR.Cli.csproj -- .\demo.png --full
Real mode:
dotnet run --project .\src\BaoBaoPaddleOCR.NET\BaoBaoPaddleOCR.Cli\BaoBaoPaddleOCR.Cli.csproj -- .\demo.png --model-root .\models --full
Model layout
Default model root:
- CLI argument:
--model-root <dir> - or env:
BAOBAO_PADDLEOCR_MODEL_ROOT - or fallback:
AppContext.BaseDirectory\models
Default expected layout:
models/
PP-OCRv5_server_det_infer/
PP-OCRv5_server_rec_infer/
PP-LCNet_x1_0_textline_ori_infer/
If your actual subdirectory names are different, you can override them with environment variables:
BAOBAO_PADDLEOCR_DET_DIRNAMEBAOBAO_PADDLEOCR_REC_DIRNAMEBAOBAO_PADDLEOCR_CLS_DIRNAME
These can be either:
- a child directory name under the model root, or
- an absolute path
Runtime environment variables
BAOBAO_PADDLEOCR_NATIVE_DIR: extra directory to search for the native DLLBAOBAO_PADDLEOCR_MODEL_ROOT: model root directoryBAOBAO_PADDLEOCR_MOCK_TEXT: mock output text when using the stub buildBAOBAO_PADDLEOCR_CPU_THREADS: CPU thread count for PaddleOCRBAOBAO_PADDLEOCR_ENABLE_MKLDNN:trueorfalse
Notes
- The native wrapper now calls PaddleOCR
deploy/cpp_inferdirectly when built with-WithPaddleOcr. build-native.ps1now auto-detectscmake.exe, Visual Studio developer tools, and falls back toNinjawhenVisual Studio 17 2022is unavailable.- The build script copies
BaoBaoPaddleOCR.Native.dlland common Paddle/OpenCV runtime DLLs into both:BaoBaoPaddleOCR.Cli/bin/<Configuration>/net10.0/nativeBaoBaoPaddleOCR/runtimes/win-x64/native
- The machine must still have a working MSVC/CMake toolchain installed.
Chinese quick start
# 1. 编译 .NET
dotnet build .\src\BaoBaoPaddleOCR.NET\BaoBaoPaddleOCR.slnx
# 2. 编译 stub native(不接 PaddleOCR,验证 P/Invoke 链路)
.\src\BaoBaoPaddleOCR.NET\build-native.ps1 -Configuration Release
# 3. 编译真实 PaddleOCR native
.\src\BaoBaoPaddleOCR.NET\build-native.ps1 `
-Configuration Release `
-WithPaddleOcr `
-PaddleInferenceDir .\src\BaoBaoPaddleOCR.NET\paddle_inference
# 4. 跑 mock 自检
.\src\BaoBaoPaddleOCR.NET\smoke-test.ps1 -ImagePath .\src\BaoBaoPaddleOCR.NET\PaddleOCR-3.4.0\test_tipc\web\test.jpg
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 356 | 4/1/2026 |