如何使用IronOCR讀取手寫圖片
IronOCR提供了一種專門的ReadHandwriting方法,可以可靠地數位化圖片中的手寫文字,儘管在行距和筆劃變化的不規則性中具有挑戰性,但仍可達到約90%的英文字母手寫準確性。
快速開始:使用IronOCR讀取手寫圖片
- 安裝IronOCR和
IronOcr.Extensions.AdvancedScan套件 - 建立一個
IronTesseract實例 - 使用
LoadImage()載入您的手寫圖片 - 調用
ReadHandwriting()方法 - 從
OcrResult中存取提取出的文字
-
使用NuGet套件管理器安裝https://www.nuget.org/packages/IronOcr
-
複製並運行這段程式碼片段。
using IronOcr; var ocrTesseract = new IronTesseract(); using var ocrInput = new OcrInput(); ocrInput.LoadImage("handwriting.png"); var ocrResult = ocrTesseract.ReadHandwriting(ocrInput); Console.WriteLine(ocrResult.Text); -
部署以在您的實時環境中測試
今天就開始在您的專案中使用IronOCR,透過免費試用
自動從圖像中讀取手寫文字極其困難,因為人們的書寫方式各不相同。 這種大規模的不一致性使得OCR具有挑戰性。 關鍵文件如舊紀錄、患者登記表和客戶調查仍需人工處理,導致容易出錯的工作流程,破壞資料的整合性。
IronOCR透過引入一種專門的方法來可靠地理解和數位化手寫圖像來解決這個問題。 基於強大的Tesseract 5引擎,IronOCR結合了先進的影像處理和機器學習,提供行業領先的手寫識別能力。
本指南逐步介紹如何在您的.NET應用中實現手寫OCR。無論您正在數位化歷史文件、處理醫學表單,還是轉換手寫便條,您都將學會如何使用IronOCR實現可靠的結果。
開始使用IronOCR
如何使用IronOCR讀取手寫圖片
- 下載用於讀取手寫圖片的C#程式庫
- 實例化OCR引擎
- 使用
LoadImage載入手寫圖像 - 使用
ReadHandwriting方法從樣本手寫圖像中提取資料 - 存取OcrResult屬性以查看和操作提取的資料
要使用此功能,您必須先安裝IronOcr.Extensions.AdvancedScan套件。 請注意,ReadHandwriting方法目前僅支持英語。 欲使用多語言OCR,請使用標準的Read()方法,並搭配適當的語言包。
如何使用IronOCR讀取手寫圖片?
使用IronOCR讀取手寫圖片非常簡單。 首先實例化OCR引擎,然後使用ReadHandwriting方法。 列印提取的文字以驗證準確性和內容。
在處理之前,考慮應用影像質量校正濾鏡以提高可讀性。 這些濾鏡可以顯著提高識別准確性,特別是對於對比度或解析度較差的掃描文件。
我應該使用什麼輸入格式?
:path=/static-assets/ocr/content-code-examples/how-to/read-handwritten-image.cs
using IronOcr;
using System;
// Instantiate OCR engine
var ocr = new IronTesseract();
// Load handwriting image
var inputHandWriting = new OcrInput();
inputHandWriting.LoadImage("handwritten.png");
// Perform OCR on the handwriting image
OcrHandwritingResult result = ocr.ReadHandwriting(inputHandWriting);
// Output the recognized handwritten text
Console.WriteLine(result.Text);
// Output the confidence score of the OCR result
Console.WriteLine(result.Confidence);
Imports IronOcr
Imports System
' Instantiate OCR engine
Dim ocr As New IronTesseract()
' Load handwriting image
Dim inputHandWriting As New OcrInput()
inputHandWriting.LoadImage("handwritten.png")
' Perform OCR on the handwriting image
Dim result As OcrHandwritingResult = ocr.ReadHandwriting(inputHandWriting)
' Output the recognized handwritten text
Console.WriteLine(result.Text)
' Output the confidence score of the OCR result
Console.WriteLine(result.Confidence)
我可以預期什麼結果?
ReadHandwriting方法達到了90.6%的信心分數,正確識別了大部分文字,包括開頭的語句"我的名字是Erin Fish"。
這一強結果展示了IronOCR在面對具挑戰性的手寫腳本時的能力。 雖然引擎對間距和連接字母有困難,但成功提取了核心資訊。 這顯示了IronOCR能有效處理複雜的非標準文字。
對於OCR新手,請從我們的簡單OCR教程開始,了解基礎知識,再著手進行手寫識別。
如何使用非同步版本?
IronOCR支持一個非同步版本:ReadHandwritingAsync。 這對於需要在處理之前提取輸入圖像的非同步程式碼特別有用。 非同步支援文件提供了實施非同步OCR操作的完整指導。
使用同一輸入,以下是如何使用非同步方法:
:path=/static-assets/ocr/content-code-examples/how-to/read-handwritten-image-async.cs
using IronOcr;
using System;
using System.Threading.Tasks;
public class read_handwritten_image_async
{
public async Task codeAsync()
{
// Instantiate OCR engine
var ocr = new IronTesseract();
// Load handwriting image
var inputHandWriting = new OcrInput();
inputHandWriting.LoadImage("handwritten.png");
// Perform OCR using the async method with 'await'.
OcrHandwritingResult result = await ocr.ReadHandwritingAsync(inputHandWriting);
// Output the recognized handwriting text
Console.WriteLine(result.Text);
// Output the confidence score of the OCR result
Console.WriteLine(result.Confidence);
}
}
Imports IronOcr
Imports System
Imports System.Threading.Tasks
Public Class ReadHandwrittenImageAsync
Public Async Function CodeAsync() As Task
' Instantiate OCR engine
Dim ocr As New IronTesseract()
' Load handwriting image
Dim inputHandWriting As New OcrInput()
inputHandWriting.LoadImage("handwritten.png")
' Perform OCR using the async method with 'await'.
Dim result As OcrHandwritingResult = Await ocr.ReadHandwritingAsync(inputHandWriting)
' Output the recognized handwriting text
Console.WriteLine(result.Text)
' Output the confidence score of the OCR result
Console.WriteLine(result.Confidence)
End Function
End Class
您可以提供一個可選的timeoutMs參數,以指定自動取消前的毫秒數。 預設值為-1,意味著無時間限制——操作將持續到完成。
進階處理技巧
對於複雜的手寫識別場景,考慮以下進階技巧:
特定區域OCR:在處理表單或結構化文件時,使用基於區域的OCR,聚焦於包含手寫文字的特定區域。 這種方法透過限制處理區域來提高準確性:
:path=/static-assets/ocr/content-code-examples/how-to/read-handwritten-image-4.cs
using IronOcr;
using IronSoftware.Drawing;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
// Define a specific region for signature area
var signatureRegion = new CropRectangle(x: 100, y: 500, width: 300, height: 100);
ocrInput.LoadImage("form-with-signature.png", signatureRegion);
var signatureResult = ocrTesseract.ReadHandwriting(ocrInput);
Console.WriteLine($"Signature text: {signatureResult.Text}");
Imports IronOcr
Imports IronSoftware.Drawing
Dim ocrTesseract As New IronTesseract()
Using ocrInput As New OcrInput()
' Define a specific region for signature area
Dim signatureRegion As New CropRectangle(x:=100, y:=500, width:=300, height:=100)
ocrInput.LoadImage("form-with-signature.png", signatureRegion)
Dim signatureResult = ocrTesseract.ReadHandwriting(ocrInput)
Console.WriteLine($"Signature text: {signatureResult.Text}")
End Using
進度追蹤:對多份手寫文件進行批量處理時,實施進度追蹤以監控OCR操作:
ocrTesseract.OcrProgress += (sender, e) =>
{
Console.WriteLine($"Processing: {e.ProgressPercent}% complete");
};
ocrTesseract.OcrProgress += (sender, e) =>
{
Console.WriteLine($"Processing: {e.ProgressPercent}% complete");
};
ocrTesseract.OcrProgress += Sub(sender, e)
Console.WriteLine($"Processing: {e.ProgressPercent}% complete")
End Sub
我應注意哪些挑戰?
雖然IronOCR在保留整體結構和文字方面獲得了高可信度,但OCR仍在手寫方面存在困難,導致局部錯誤。 常見的挑戰需要驗證提取的輸出:
不規則的間距:列印文字字母之間的間距均勻。 手寫時筆劃之間的間距和連接字母的距離差異很大。 這導致字元錯誤分段,如ununiformed被拆分為單個字元(u n u n i f o c m e d)而不是單字。
筆劃變化:每個人的手寫都不一樣,同一個人每次寫同一個字母的方式也不同。字母連接和樣式差異顯著。 這阻止了"一刀切"模型,因為引擎必須處理筆劃斜度、壓力和格式的高變異性,這使得圖案匹配不如標準化字體可靠。
多義字元形狀:手寫經常使用簡化或潦草的筆劃,創造了多義形狀。一個快速寫成的i可能被錯誤識別。
質量和解析度問題:掃描質量差、解析度低或墨水褪色會顯著影響識別準確性。 遇到這些問題時,請參考我們的一般故障排除指南以獲得解決方案。
使用此方法時,請驗證輸出是否與預期輸入匹配,特別注意間距緊密或寫得不好的詞。 考慮實施後處理邏輯來處理特定於您使用案例的常見錯誤識別。
ReadHandwriting方法在涉及草書時只能獲得低精確的OCR提取。 常見問題
從影像中提取手寫文字時,預計可以達到什麼準確率?
IronOCR的ReadHandwriting方法在英文字的手寫識別中達到大約90%的準確率,儘管不規則間距和筆畫變化帶來了手寫OCR的挑戰。
目前支援哪些語言的手寫識別?
IronOCR中的ReadHandwriting方法目前僅支援英文。對於多語言OCR,您需要使用標準Read()方法並搭配適當的語言包,而不是專門的手寫方法。
要使用手寫OCR,還需要安裝哪個額外的套件?
要在IronOCR中使用手寫識別功能,除了主要的IronOCR程式庫外,您還必須安裝IronOcr.Extensions.AdvancedScan套件。
如何在C#中實施基本手寫識別?
建立IronTesseract實例,使用LoadImage()載入手寫影像,調用ReadHandwriting()方法,從OcrResult中存取提取出的文字。IronOCR自動處理複雜的影像處理和機器學習。
可以處理哪些型別的手寫文件?
IronOCR可以處理各種手寫文件,包括歷史檔案、病患入院表單、顧客調查和手寫筆記。此程式庫旨在處理人類手寫時的不一致性,這使得手動處理容易出錯。
手寫識別功能由什麼技術驅動?
IronOCR的手寫識別功能以功能強大的Tesseract 5引擎為基礎,結合了先進的影像處理和機器學習算法,提供行業領先的手寫識別功能。
IronOCR能整合到現有的應用程式中嗎?
IronOCR被設計成可以輕鬆地整合到現有應用程式中,使用C#允許開發人員以最小的努力為其軟體新增OCR功能。
使用IronOCR進行文件管理的好處是什麼?
使用IronOCR進行文件管理通過將掃描的文件轉換為可搜索和可編輯的文字來簡化工作流程,減少手動資料輸入的需求並提高文件的可存取性。
IronOCR如何提高資料精確性?
IronOCR通過其先進的識別算法和影像校正功能提高資料精確性,確保文字提取過程既可靠又精確。
IronOCR有免費試用版嗎?
有的,Iron Software提供IronOCR的免費試用版,允許使用者在做出購買決定前測試其功能和能力。

