请参阅本文,了解如何将手写内容转换为 C# 中的文本。其中分享了设置环境的详细信息、步骤列表以及将笔记从手写内容转换为 C# 中的文本的示例代码。支持多种基于扩展拉丁字母的 European languages。
使用 C# 将手写内容转换为文本的步骤
- 在您的项目中添加 Aspose.OCR for .NET NuGet 包
- 创建 AsposeOcr 类的实例以利用 OCR 功能
- 使用单个图像处理标志声明 OcrInput
- 在OcrInput对象中设置OCR处理的文件名
- 使用 RecognizeHandwrittenText() 方法识别图像中的文本
- 迭代识别文本结果数组
- 使用 CorrectSpelling 方法纠正已识别文本的拼写
这些步骤总结了在 C# 中将手写内容转换为文本的过程。创建 AsposeOcr 类的实例以使用 OCR 功能,并设置 InputType.SingleImage 标志以处理单个图像、设置图像名称以及使用 RecognizeHandwrittenText() 方法识别文本。最后,遍历所有识别的文本结果并根据需要更正拼写。
使用 C# 将手写内容转换为文本的代码
using System; | |
using Aspose.OCR; | |
class HandwritingToTextConverter | |
{ | |
static void Main() | |
{ | |
new License().SetLicense("license.lic");// Initialize the OCR library | |
AsposeOcr ocrEngine = new AsposeOcr();// Set up the OCR engine | |
// Load the image for OCR processing | |
OcrInput inputImage = new OcrInput(InputType.SingleImage); | |
inputImage.Add("sample2.png"); | |
var recognitionResults = ocrEngine.RecognizeHandwrittenText(inputImage); | |
// Iterate through the recognized results and print corrected text | |
foreach (var result in recognitionResults) | |
{ | |
string correctedText = ocrEngine.CorrectSpelling(result.RecognitionText); | |
Console.WriteLine(correctedText); | |
} | |
} | |
} |
此代码指导我们开发了一个简单的C# 手写转文本应用程序。此功能有助于历史记录的数字存档、阅读简历和员工记录、数字化学生课堂笔记以及其他法律和医疗保健记录。您可以忽略使用 CorrectSpelling() 方法来显示精确的文本,例如技术术语等。
本文教我们如何使用 C# 开发一款将手写内容转换为文本的应用程序。要从扫描的 PDF 中提取文本,请参阅 如何使用 C# 从扫描的 PDF 中提取文本 上的文章。