BaoBao.PaddleOCR
0.1.3
dotnet add package BaoBao.PaddleOCR --version 0.1.3
NuGet\Install-Package BaoBao.PaddleOCR -Version 0.1.3
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" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BaoBao.PaddleOCR" Version="0.1.3" />
<PackageReference Include="BaoBao.PaddleOCR" />
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 --version 0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BaoBao.PaddleOCR, 0.1.3"
#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@0.1.3
#: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&version=0.1.3
#tool nuget:?package=BaoBao.PaddleOCR&version=0.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BaoBaoPaddleOCR.NET
BaoBaoPaddleOCR.NET 是一个面向 Windows 的 PaddleOCR .NET 封装。
这份说明只讲两件事:
- 编译步骤
- 使用步骤
编译步骤
1. 编译 BaoBaoPaddleOCR.dll
这是最简单的一步。
直接用 Visual Studio 2022 打开 BaoBaoPaddleOCR.slnx,然后生成即可。
也可以使用命令行:
dotnet build .\BaoBaoPaddleOCR.slnx -c Release
生成结果:
BaoBaoPaddleOCR\bin\Release\net10.0\BaoBaoPaddleOCR.dll
2. 编译 BaoBaoPaddleOCR.Native.dll
如果你要真正运行 OCR,还需要原生层 DLL。
这一步需要先准备:
- Visual Studio 2022 的 C++ 桌面开发工具
- CMake
- OpenCV
paddle_inference- PaddleOCR C++ 源码
先准备依赖:
.\eng\setup-deps.ps1 -PaddleInferenceDir "D:\deps\paddle_inference" -Force
再编译原生层:
.\eng\build-native.ps1 `
-Configuration Release `
-WithPaddleOcr `
-PaddleInferenceDir .\deps\paddle_inference
生成结果会复制到:
BaoBaoPaddleOCR\runtimes\win-x64\native\BaoBaoPaddleOCR.Native.dll
3. 下载模型
模型不会自动下载。
需要你主动执行:
.\eng\setup-models.ps1 -Force
默认模型目录:
models\PP-OCRv5_server_det_infer
models\PP-OCRv5_server_rec_infer
models\PP-LCNet_x1_0_textline_ori_infer
使用步骤
1. 运行时需要的内容
如果你是通过 NuGet 引用 BaoBao.PaddleOCR:
runtimes\win-x64\native\会跟随包一起进入输出目录models\会在消费者项目首次构建时自动下载到输出目录
如果你不是通过 NuGet,而是手动拷贝文件运行 OCR,那么至少需要这些内容:
BaoBaoPaddleOCR.dllruntimes\win-x64\native\目录models\目录
2. 在 C# 代码中调用
using BaoBaoPaddleOCR;
using var client = new BaoBaoPaddleOcrClient();
var result = client.Detect("demo.png");
Console.WriteLine(result.Text);
3. 指定 native 和模型目录
如果你的目录不是默认结构,可以通过环境变量指定:
$env:BAOBAO_PADDLEOCR_NATIVE_DIR = "D:\runtime\native"
$env:BAOBAO_PADDLEOCR_MODEL_ROOT = "D:\runtime\models"
4. 使用 CLI 验证
dotnet run --project .\BaoBaoPaddleOCR.Cli\BaoBaoPaddleOCR.Cli.csproj -- .\demo.png --full
如果只是验证调用链路,不跑真实 OCR,可以用 mock:
$env:BAOBAO_PADDLEOCR_MOCK_TEXT = "mock result"
dotnet run --project .\BaoBaoPaddleOCR.Cli\BaoBaoPaddleOCR.Cli.csproj -- .\demo.png --full
NuGet 行为
如果使用者引用的是 BaoBao.PaddleOCR 这个包:
- native runtimes 会随包自动进入输出目录
- 模型会在首次构建时自动下载
如果你不希望自动下载模型,可以在消费者项目里关闭:
<PropertyGroup>
<BaoBaoPaddleOCRAutoDownloadModels>false</BaoBaoPaddleOCRAutoDownloadModels>
</PropertyGroup>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in 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.