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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BaoBao.PaddleOCR.Models" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BaoBao.PaddleOCR.Models" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="BaoBao.PaddleOCR.Models" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BaoBao.PaddleOCR.Models --version 0.1.0
                    
#r "nuget: BaoBao.PaddleOCR.Models, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BaoBao.PaddleOCR.Models@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BaoBao.PaddleOCR.Models&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=BaoBao.PaddleOCR.Models&version=0.1.0
                    
Install as a Cake Tool

BaoBaoPaddleOCR.NET

BaoBaoPaddleOCR.NET is a local OCR wrapper built as C++ inference + .NET P/Invoke.

  • BaoBaoPaddleOCR.Native: native C ABI layer
  • BaoBaoPaddleOCR: C# wrapper
  • BaoBaoPaddleOCR.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_infer
    • PP-OCRv5_server_rec_infer
    • PP-LCNet_x1_0_textline_ori_infer

Local prerequisites

This repo already bundles:

  • PaddleOCR-3.4.0
  • paddle_inference

The machine still needs:

  • Visual Studio C++ toolchain
  • CMake or Visual Studio CMake tools
  • OpenCV at C:\opencv\build or 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 under runtimes/win-x64/native
  • BaoBao.PaddleOCR.Models: OCR models under contentFiles/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_DIRNAME
  • BAOBAO_PADDLEOCR_REC_DIRNAME
  • BAOBAO_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 DLL
  • BAOBAO_PADDLEOCR_MODEL_ROOT: model root directory
  • BAOBAO_PADDLEOCR_MOCK_TEXT: mock output text when using the stub build
  • BAOBAO_PADDLEOCR_CPU_THREADS: CPU thread count for PaddleOCR
  • BAOBAO_PADDLEOCR_ENABLE_MKLDNN: true or false

Notes

  • The native wrapper now calls PaddleOCR deploy/cpp_infer directly when built with -WithPaddleOcr.
  • build-native.ps1 now auto-detects cmake.exe, Visual Studio developer tools, and falls back to Ninja when Visual Studio 17 2022 is unavailable.
  • The build script copies BaoBaoPaddleOCR.Native.dll and common Paddle/OpenCV runtime DLLs into both:
    • BaoBaoPaddleOCR.Cli/bin/<Configuration>/net10.0/native
    • BaoBaoPaddleOCR/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
There are no supported framework assets in this package.

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