進階閱讀的 OCR 配置
IronOCR 提供進階掃描閱讀方法,如 ReadPassport、ReadLicensePlate 和 ReadPhoto,超越了標準的 OCR。 這些方法由 IronOcr.Extensions.AdvancedScan 套件提供支持。 為了精細調整這些方法處理文本的方式,IronOCR 透過展現 TesseractConfiguration 類別,讓開發人員完全控制字元白名單、黑名單、條碼檢測、資料表格閱讀等更多功能。
本文涵蓋用於進階閱讀的 TesseractConfiguration 屬性及其在真實場景中配置 OCR 的實用範例。
在呼叫 Read 之前,請在 TesseractConfiguration 設定 WhiteListCharacters。 任何不在白名單中的字元都會被靜默地從結果中刪除,從而消除雜訊而無需任何後製處理。
-
1使用 IronOCR 安裝 NuGet Package Manager
-
2複製並運行這段程式碼。
var input = new OcrInput(); input.LoadImage("image.png"); var result = new IronTesseract() { Configuration = new TesseractConfiguration { WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789- " } }.Read(input); Console.WriteLine(result.Text);Dim input As New OcrInput() input.LoadImage("image.png") Dim result As New IronTesseract() With { .Configuration = New TesseractConfiguration With { .WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789- " } }.Read(input) Console.WriteLine(result.Text)Dim input As New OcrInput() input.LoadImage("image.png") Dim result As New IronTesseract() With { .Configuration = New TesseractConfiguration With { .WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789- " } }.Read(input) Console.WriteLine(result.Text) -
3部署到您的生產環境進行測試
立即在您的項目中開始使用 IronOCR,並使用 免費試用
如何配置 OCR 以實現進階閱讀
- 從 NuGet 安裝 IronOCR
- 安裝 IronOcr.Extensions.AdvancedScan 套件
- 配置
TesseractConfiguration屬性,例如WhiteListCharacters和ReadBarCodes - 使用
OcrInput載入輸入影像 - 使用
ReadPhoto、ReadLicensePlate或ReadPassport等高階方法讀取影像。
Tesseract配置屬性
TesseractConfiguration 類別提供以下屬性以自訂 OCR 行為。 這些是通過 IronTesseract.Configuration 設置的。
| 屬性 | 類型 | 描述 |
|---|---|---|
WhiteListCharacters | 細繩 | OCR 輸出僅識別此字串中存在的字符,所有其他字符都將被排除。 |
BlackListCharacters | 細繩 | 該字串中的字元將被主動忽略並從 OCR 輸出中刪除。 |
ReadBarCodes | 布林值 | 在 OCR 處理過程中啟用或停用文件中的條碼偵測。 |
ReadDataTables | 布林值 | 使用 Tesseract 啟用或停用文件中的表格結構偵測。 |
PageSegmentationMode | TesseractPageSegmentationMode | 決定 Tesseract 如何分割輸入影像。選項包括AutoOsd 、 Auto 、 SingleBlock 、 SingleLine 、 SingleWord等。 |
RenderSearchablePdf | 布林值 | 啟用後,OCR 輸出可以儲存為具有不可見文字圖層的可搜尋 PDF。 |
RenderHocr | 布林值 | 啟用後,OCR 輸出將包含 hOCR 數據,以便進一步處理或匯出。 |
TesseractVariables | Dictionary<細繩, object> | 提供直接訪問低級 Tesseract 配置變量的途徑,以便進行細緻控制。 |
TesseractVariables 字典更進一步,揭示數百個基本的 Tesseract 引擎參數,以應對高層屬性不夠充分的情況。
以下範例示範了每個屬性組,首先是字元白名單。
設定車牌字元白名單
使用 WhiteListCharacters 的常見情況是將 OCR 輸出限制為只能顯示在車牌上的字元:大寫字母、數字、連字符和空格。 這樣可以消除噪聲,提高準確性,方法是告訴引擎忽略預期字元集以外的所有內容。
輸入
以下的車輛登記記錄包含大寫文本、小寫文本、特殊符號 (@, $, #, |, ~, ^, *) 和標點符號的混合。

BlackListCharacters 通過積極排除熟知的噪音符號如 ``,~, @, #, $, %, &和*` 補充了白名單。
using IronOcr;
// Initialize the Tesseract OCR engine
IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
// Whitelist only characters that appear on license plates
WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789- ",
// Blacklist common noise characters
BlackListCharacters = "`~@#$%&*",
};
var ocrInput = new OcrInput();
// Load the input image
ocrInput.LoadImage("advanced-input.png");
// Perform OCR on the input image with ReadPhoto method
var results = ocr.ReadPhoto(ocrInput);
// Print the filtered text result to the console
Console.WriteLine(results.Text);using IronOcr;
// Initialize the Tesseract OCR engine
IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
// Whitelist only characters that appear on license plates
WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789- ",
// Blacklist common noise characters
BlackListCharacters = "`~@#$%&*",
};
var ocrInput = new OcrInput();
// Load the input image
ocrInput.LoadImage("advanced-input.png");
// Perform OCR on the input image with ReadPhoto method
var results = ocr.ReadPhoto(ocrInput);
// Print the filtered text result to the console
Console.WriteLine(results.Text);Imports IronOcr
' Initialize the Tesseract OCR engine
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
' Whitelist only characters that appear on license plates
.WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789- ",
' Blacklist common noise characters
.BlackListCharacters = "`~@#$%&*"
}
Dim ocrInput As New OcrInput()
' Load the input image
ocrInput.LoadImage("advanced-input.png")
' Perform OCR on the input image with ReadPhoto method
Dim results = ocr.ReadPhoto(ocrInput)
' Print the filtered text result to the console
Console.WriteLine(results.Text)Imports IronOcr
' Initialize the Tesseract OCR engine
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
' Whitelist only characters that appear on license plates
.WhiteListCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789- ",
' Blacklist common noise characters
.BlackListCharacters = "`~@#$%&*"
}
Dim ocrInput As New OcrInput()
' Load the input image
ocrInput.LoadImage("advanced-input.png")
' Perform OCR on the input image with ReadPhoto method
Dim results = ocr.ReadPhoto(ocrInput)
' Print the filtered text result to the console
Console.WriteLine(results.Text)輸出

白名單濾波的效果在結果中清晰可見:
- “車牌:ABC-1234”變成“P ABC-1234” 。 小寫字母「late:」省略,而車牌號碼則完全保留。
- “VIN: 1HGBH41JXMN109186”變為“VIN 1HGBH41JXMN109186” 。 冒號被省略,但大寫的車輛識別碼和完整號碼被保留。
- “Owner: john.doe@email.com”變成“O” 。 所有小寫電子郵件地址和標點符號均被刪除。
- "地區:CA-90210 | “5區”變為“R CA-90210 Z 5” 。 管道符 (
|) 和井號 (#) 被移除,而大寫字母和數字則保留下來。 - “費用:$125.00 + 稅*”變為“F 12500” 。 美元符號、小數點、Plus號和小寫字母「tax」都被移除。
- "Ref: ~record_v2^final"變成"R 2" 。 波浪號 (
~)、下劃線、插入符號 (^) 和所有小寫字元都被剝離。
相同的 WhiteListCharacters 和 BlackListCharacters 方法適用於任何文件類型,而不僅僅是車牌。 下一節將展示如何擴展讀取操作,以便在同一次讀取過程中偵測條碼和表格結構。
條碼和資料表讀取配置
IronOCR可以偵測文件中的條碼、結構化表格以及文字。 這些功能通過 TesseractConfiguration 控制:
IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
// Enable barcode detection within documents
ReadBarCodes = true,
// Enable table structure detection
ReadDataTables = true,
};IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
// Enable barcode detection within documents
ReadBarCodes = true,
// Enable table structure detection
ReadDataTables = true,
};Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.ReadBarCodes = True,
.ReadDataTables = True
}Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.ReadBarCodes = True,
.ReadDataTables = True
}- ReadBarCodes: 設置為
true時,IronOCR 除了文本外還會掃描文件中的條碼。 設置為false以跳過條碼檢測並在不預期條碼時加速處理。 - ReadDataTables: 設置為
true時,Tesseract 試圖檢測並保留文件中的表格結構。 這對於發票、報告和其他表格文件非常有用。
這些選項可以與 WhiteListCharacters 和 BlackListCharacters 結合起來,以精確控制從複雜文件中提取的內容。
過濾和檢測控制著提取的內容,而佈局解釋則是另一個需要考慮的問題。 下一節介紹如何選擇適合文件類型的 PageSegmentationMode。
控制頁面分段模式
PageSegmentationMode 告訴 Tesseract 在識別之前如何對輸入圖像進行分割。 為給定佈局選擇錯誤的模式會導致引擎誤讀或完全跳過文字。
| 模式 | 使用案例 |
|---|---|
AutoOsd | 自動版面分析,具備方向與腳本偵測功能 |
Auto | 自動佈局分析(不含 OSD)(預設) |
SingleColumn | 假設圖像為單列文字。 |
SingleBlock | 假設影像是由單一均勻的文字區塊組成。 |
SingleLine | 假設圖像是一行文字。 |
SparseText | 盡可能多地查找文本,順序不限。 |
對於包含單行文字的標籤或橫幅,SingleLine 消除了多塊分析,提高了速度和準確性。
輸入
single-line-label.png 是一個窄型運輸標籤,包含精確的一行粗體字體:SHIPPING LABEL: TRK-2024-XR9-001。

IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
PageSegmentationMode = TesseractPageSegmentationMode.SingleLine,
};
using OcrInput input = new OcrInput();
input.LoadImage("single-line-label.png");
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
PageSegmentationMode = TesseractPageSegmentationMode.SingleLine,
};
using OcrInput input = new OcrInput();
input.LoadImage("single-line-label.png");
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);Imports IronOcr
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.PageSegmentationMode = TesseractPageSegmentationMode.SingleLine
}
Using input As New OcrInput()
input.LoadImage("single-line-label.png")
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)
End UsingImports IronOcr
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.PageSegmentationMode = TesseractPageSegmentationMode.SingleLine
}
Using input As New OcrInput()
input.LoadImage("single-line-label.png")
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)
End Using對於一個具有不規則文本放置的掃描頁面,SparseText 比 Auto 擷取更多內容。
輸入
receipt-scan.png 是一張 Corner Market 的熱感收據,包含四行項目(咖啡、鬆餅、果汁、燕麥棒)、虛線分隔符、小計、稅金和總計。 在這種佈局中,固定區塊分割會遺漏不同水平位置的條目。

IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
PageSegmentationMode = TesseractPageSegmentationMode.SparseText,
};
using OcrInput input = new OcrInput();
input.LoadImage("receipt-scan.png");
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
PageSegmentationMode = TesseractPageSegmentationMode.SparseText,
};
using OcrInput input = new OcrInput();
input.LoadImage("receipt-scan.png");
OcrResult result = ocr.Read(input);
Console.WriteLine(result.Text);Imports IronTesseract
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.PageSegmentationMode = TesseractPageSegmentationMode.SparseText
}
Using input As New OcrInput()
input.LoadImage("receipt-scan.png")
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)
End UsingImports IronTesseract
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.PageSegmentationMode = TesseractPageSegmentationMode.SparseText
}
Using input As New OcrInput()
input.LoadImage("receipt-scan.png")
Dim result As OcrResult = ocr.Read(input)
Console.WriteLine(result.Text)
End Using佈局分割已根據文件類型進行了調整,下一步是控制下游處理的輸出格式。
產生可搜尋的 PDF 和 hOCR 輸出
RenderSearchablePdf 和 RenderHocr 控制 IronOCR 生成的輸出格式以及純文本結果。
RenderSearchablePdf 在原始圖像上嵌入了隱藏的文本層,生成一個 PDF,使用者可以在其中搜尋和複製文本,而掃描的影像仍然可見。 這是文件歸檔工作流程的標準輸出格式。
輸入
scanned-document.pdf 是一封來自 IronOCR Solutions Ltd. 的單頁商業信函(日期 2024年3月15日,參考號DOC-2024-OCR-0315)。 結果以 searchable-output.pdf 儲存。
IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
RenderSearchablePdf = true,
};
using OcrInput input = new OcrInput();
input.LoadPdf("scanned-document.pdf");
OcrResult result = ocr.Read(input);
result.SaveAsSearchablePdf("searchable-output.pdf");IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
RenderSearchablePdf = true,
};
using OcrInput input = new OcrInput();
input.LoadPdf("scanned-document.pdf");
OcrResult result = ocr.Read(input);
result.SaveAsSearchablePdf("searchable-output.pdf");Imports IronTesseract
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.RenderSearchablePdf = True
}
Using input As New OcrInput()
input.LoadPdf("scanned-document.pdf")
Dim result As OcrResult = ocr.Read(input)
result.SaveAsSearchablePdf("searchable-output.pdf")
End UsingImports IronTesseract
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.RenderSearchablePdf = True
}
Using input As New OcrInput()
input.LoadPdf("scanned-document.pdf")
Dim result As OcrResult = ocr.Read(input)
result.SaveAsSearchablePdf("searchable-output.pdf")
End Using輸出
輸出結果是一個 PDF 文件,它看起來與輸入文件完全相同,但其中包含一個隱藏的文字層。 打開 searchable-output.pdf 並使用 Ctrl+F 來驗證嵌入的文本是否可以查詢和複製。
RenderHocr 生成一個 hOCR 文件,一個將文本內容與每個詞的邊界方框坐標一起編碼的 HTML 檔案。 當下游工具需要精確的字詞定位時,例如編輯引擎或文件佈局分析,這非常有用。
輸入
document-page.png 是一頁文件,題目為"季度摘要 Q1 2024",包覆兩段財務數據,涉及收入、營運成本和成長動力。 結果以 output.html 儲存。

IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
RenderHocr = true,
};
using OcrInput input = new OcrInput();
input.LoadImage("document-page.png");
OcrResult result = ocr.Read(input);
result.SaveAsHocrFile("output.html");IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
RenderHocr = true,
};
using OcrInput input = new OcrInput();
input.LoadImage("document-page.png");
OcrResult result = ocr.Read(input);
result.SaveAsHocrFile("output.html");Imports IronOcr
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.RenderHocr = True
}
Using input As New OcrInput()
input.LoadImage("document-page.png")
Dim result As OcrResult = ocr.Read(input)
result.SaveAsHocrFile("output.html")
End UsingImports IronOcr
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.RenderHocr = True
}
Using input As New OcrInput()
input.LoadImage("document-page.png")
Dim result As OcrResult = ocr.Read(input)
result.SaveAsHocrFile("output.html")
End Using輸出
output.html 將每個識別的詞語與其邊界框坐標編碼。 在瀏覽器中開啟檔案以檢查 hOCR 結構,或將其傳遞給下游工具進行佈局分析或編輯。
如果您需要從單一讀取呼叫中獲得所有三種輸出格式(純文字、可搜尋 PDF 和 hOCR),則可以同時啟用這兩個標誌。
這些輸出標誌與讀取的語言無關,包括非拉丁字母。下一節將介紹如何對日文文字套用字元過濾。
國際文檔的Unicode字元過濾
對於中文、日文或韓文的國際文件,WhiteListCharacters 和 BlackListCharacters 屬性可以處理 Unicode 字元。 這樣可以將輸出限制為特定腳本,例如日文僅輸出平假名和片假名。
輸入
這份文件包含標題 (テsuto)、混合平假名和片假名以及濁音變體 (プ、で) 的日文句子、包含列入黑名單的噪音符號 (★、■) 和漢字 (価格) 的價格線、包含另一個列入黑名單的符號 (§) 的備註行、価格) 的價格線、包含另一個列入黑名單的符號 (§) 的備註行、更多漢斯(プ和基本片假名(メモ,ール)。 白名單僅允許平假名、片假名、數字和常用日文標點符號通過; 這三個噪音符號已被明確列入黑名單。

平假名和片假名的 Unicode 字元範圍作為字符串字面量傳遞到 WhiteListCharacters,噪音符號列在 BlackListCharacters。
using IronOcr;
using System.IO;
IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
// Whitelist only Hiragana, Katakana, numbers, and common Japanese punctuation
WhiteListCharacters = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん" +
"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン" +
"0123456789、。?!()¥ー",
// Blacklist common noise/symbols you want to ignore
BlackListCharacters = "★■§",
};
var ocrInput = new OcrInput();
// Load Japanese input image
ocrInput.LoadImage("jp.png");
// Perform OCR on the input image with ReadPhoto method
var results = ocr.ReadPhoto(ocrInput);
// Write the text result directly to a file named "output.txt"
File.WriteAllText("output.txt", results.Text);
// You can add this line to confirm the file was saved:
Console.WriteLine("OCR results saved to output.txt");using IronOcr;
using System.IO;
IronTesseract ocr = new IronTesseract();
ocr.Configuration = new TesseractConfiguration
{
// Whitelist only Hiragana, Katakana, numbers, and common Japanese punctuation
WhiteListCharacters = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん" +
"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン" +
"0123456789、。?!()¥ー",
// Blacklist common noise/symbols you want to ignore
BlackListCharacters = "★■§",
};
var ocrInput = new OcrInput();
// Load Japanese input image
ocrInput.LoadImage("jp.png");
// Perform OCR on the input image with ReadPhoto method
var results = ocr.ReadPhoto(ocrInput);
// Write the text result directly to a file named "output.txt"
File.WriteAllText("output.txt", results.Text);
// You can add this line to confirm the file was saved:
Console.WriteLine("OCR results saved to output.txt");Imports IronOcr
Imports System.IO
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.WhiteListCharacters = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん" &
"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン" &
"0123456789、。?!()¥ー",
.BlackListCharacters = "★■§"
}
Dim ocrInput As New OcrInput()
' Load Japanese input image
ocrInput.LoadImage("jp.png")
' Perform OCR on the input image with ReadPhoto method
Dim results = ocr.ReadPhoto(ocrInput)
' Write the text result directly to a file named "output.txt"
File.WriteAllText("output.txt", results.Text)
' You can add this line to confirm the file was saved:
Console.WriteLine("OCR results saved to output.txt")Imports IronOcr
Imports System.IO
Dim ocr As New IronTesseract()
ocr.Configuration = New TesseractConfiguration With {
.WhiteListCharacters = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん" &
"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲン" &
"0123456789、。?!()¥ー",
.BlackListCharacters = "★■§"
}
Dim ocrInput As New OcrInput()
' Load Japanese input image
ocrInput.LoadImage("jp.png")
' Perform OCR on the input image with ReadPhoto method
Dim results = ocr.ReadPhoto(ocrInput)
' Write the text result directly to a file named "output.txt"
File.WriteAllText("output.txt", results.Text)
' You can add this line to confirm the file was saved:
Console.WriteLine("OCR results saved to output.txt")輸出

完整的過濾結果作為文本文件提供:jp-output.txt。
因為白名單只包含基本的平假名和片假名字符,所以像プ(pu)和デ(de)這樣的派生聲標變體被刪除了。 像価格(價格)和購入(購買)這樣的漢字也被排除在外,因為它們不在白名單字符集中。 像 ★, ■, 和 § 這樣的黑名單符號被積極去除,無論白名單如何。
接下來我該去哪裡?
現在您已經了解如何設定IronOCR以適應進階閱讀場景,請探索以下內容:
- 閱讀特定文件類型,如 護照 和 車牌
- 作為獨立的 OCR 使用案例進行條碼和 QR 碼閱讀
- 從處理結果導出 hOCR 和可搜尋的 PDF
對於生產使用,請記得獲取授權以移除水印並獲得完整功能。
常見問題
如何使用 IronOCR 限制 OCR 結果到特定字元?
在 IronOCR 中,您可以使用 TesseractConfiguration 的 WhiteListCharacters 屬性來限制 OCR 結果到特定字元。這使得您可以將辨識限制僅限於白名單中的字元,減少雜訊並提升準確性。
IronOCR 中 `BlackListCharacters` 功能的目的是什麼?
IronOCR 中的 BlackListCharacters 屬性讓您可以主動忽略並從 OCR 輸出中移除特定字元。這對於排除已知的雜訊符號非常有用。
如何啟用 IronOCR 的條碼和資料表閱讀功能?
要在 IronOCR 中啟用條碼和資料表閱讀功能,請在 TesseractConfiguration 中將 ReadBarCodes 和 ReadDataTables 屬性設為 true。這將允許 OCR 引擎在文件中檢測條碼和表格結構。
`PageSegmentationMode` 是什麼,它如何影響 OCR 處理?
IronOCR 中的 PageSegmentationMode 決定 Tesseract 在文字辨識前如何分割輸入影像。不同模式如 SingleLine 或 SparseText 可優化各類版面的 OCR,像是單行標籤或文本不規則分佈的複雜頁面。
IronOCR 能生成可搜尋的 PDF 嗎?
是的,IronOCR 可以生成可搜尋的 PDF,方法是將 TesseractConfiguration 中的 RenderSearchablePdf 設為 true。這將創建一個原始影像上具有隱藏文字層的 PDF,啟用文字搜尋和拷貝功能。
什麼是 IronOCR 中的 hOCR 輸出?
IronOCR 中的 hOCR 輸出是 HTML 格式,為每個字元內容附加邊界框座標。這可透過設定 RenderHocr 為 true 來啟用,使 HTML 能精確定位每個字的位置信息,便於後續處理。
如何在 IronOCR 中對國際文件進行 OCR?
IronOCR 對國際文件進行處理的方法是允許 Unicode 字元篩選。您可以設定 WhiteListCharacters 和 BlackListCharacters 包含 Unicode 字元,以控制哪些文字符號被辨識,確保準確處理中文、日文和韓文等語言。
配置 IronOCR 中的 `TesseractConfiguration` 有什麼好處?
配置 IronOCR 中的 TesseractConfiguration 允許開發者微調 OCR 處理,提供如字元白名單/黑名單、條碼檢測、表結構閱讀和頁面分割模式等選項,助其針對不同文件類型實現進階閱讀方案。
IronOCR 可以識別混合語言的影像文字嗎?
通過配置 WhiteListCharacters 包含所需文字符號,IronOCR 可以識別混合語言的影像文字。安裝適當的語言包,例如 IronOcr.Languages.Japanese 也能確保最佳識別結果。
IronOCR 如何處理不在白名單中的字元?
在 IronOCR 中,未包含在 WhiteListCharacters 屬性中的字元會被默默地從 OCR 輸出中移除。此功能有助於消除不必要的雜訊,將辨識聚焦於相關的字元集。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。