- 源码 316 文件收编为 rusto-rs/ 文件夹,随本仓库管理 - 移除内部 .git(补丁已存档 docs/rusto-rs-metal-patch-20260912.patch,上游可随时 re-clone) - target/ 与 docs/.yarn 缓存不入库;本地改动:ROCR_* 环境变量调优 + Metal 链接修复 + 预处理测试脚本
29 lines
954 B
C#
29 lines
954 B
C#
using RustODotnet;
|
|
|
|
var source = new UriImageSource("/absolute/path/invoice.png");
|
|
var options = new OcrRunOptions
|
|
{
|
|
Output = OutputGranularity.Words,
|
|
LineYThreshold = 0.5f,
|
|
WordXThreshold = 0.4f,
|
|
};
|
|
|
|
Console.WriteLine("RustODotnet consumer compiled.");
|
|
Console.WriteLine($"Source: {source.Value}; output: {options.OutputWireValue}");
|
|
Console.WriteLine("To run OCR, package native runtime assets and matching models, then call RustO.Initialize(...).DetectText(...).");
|
|
|
|
if (args.Length > 0)
|
|
{
|
|
using var ocr = RustO.Initialize(new InitializeConfig { Template = "ppv6" });
|
|
var result = ocr.DetectText(new UriImageSource(args[0]), options);
|
|
switch (result)
|
|
{
|
|
case StructuredDetectTextResult structured:
|
|
foreach (var item in structured.Items) Console.WriteLine(item.Text);
|
|
break;
|
|
case SpatialDetectTextResult spatial:
|
|
Console.WriteLine(spatial.Text);
|
|
break;
|
|
}
|
|
}
|