IronOCR 教程 Tesseract比较 如何在 C# 中使用 Tesseract OCR? IronOCR 的替代方案 Jacob Mellor 更新:8月 31, 2025 下載 IronOCR NuGet 下載 DLL 下載 Windows 安裝程式 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在雙子座打開 請向 Gemini 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 想在 C# 應用程式中實現光學字元辨識嗎? 雖然 Google Tesseract 提供免費的 OCR 解決方案,但許多開發者都難以應對其複雜的設定、在真實文件上的有限準確性以及具有挑戰性的 C++ 互通性要求。 本綜合指南向您展示如何使用 IronOCR 增強的 Tesseract 實作(原生 C# 函式庫,可消除安裝難題,同時提供卓越的結果)達到 99.8-100% 的 OCR 準確率。 無論您是從掃描文件中提取文字、處理發票還是建立文件自動化系統,您都將學會如何在幾分鐘內而不是幾週內實現可用於生產的 OCR。 快速入門:使用 IronTesseract 進行單行 OCR 使用 IronOCR 最簡單的 API,幾秒鐘即可抓取文字。 這個範例展示如何透過一行程式碼呼叫 IronTesseract,向其提供圖像,並獲取識別出的文字——簡單直接,結果立竿見影。 立即開始使用 NuGet 建立 PDF 檔案: 使用 NuGet 套件管理器安裝 IronOCR PM > Install-Package IronOcr 複製並運行這段程式碼。 string text = new IronTesseract().Read(new OcrInput("image.png")).Text; 部署到您的生產環境進行測試 立即開始在您的專案中使用 IronOCR,免費試用! 免費試用30天 最小工作流程(5 個步驟) 透過 NuGet 套件管理器安裝增強型 Tesseract OCR 庫 配置影像預處理以獲得最佳文字辨識效果 處理多種文件格式,包括PDF和多幀TIFF 擷取具有字元級準確度指標的結構化數據 無需原生依賴即可跨平台部署 本文全面概述了 IronOCR 的 Tesseract C# 實現,重點介紹了其平台相容性、支援的格式以及高級處理能力。 如何使用最少的程式碼在 C# 中從圖像中提取文字? 以下範例示範如何僅使用幾行程式碼在 .NET 應用程式中實作 OCR 功能。 與普通的 Tesseract 不同,這種方法可以自動處理影像預處理,即使掃描結果不完美也能提供準確的結果。 使用 NuGet 套件管理器將 IronOCR NuGet 套件安裝到 Visual Studio 解決方案中。 using IronOcr; using System; // Initialize IronTesseract for performing OCR (Optical Character Recognition) var ocr = new IronTesseract { // Set the language for the OCR process to English Language = OcrLanguage.English }; // Create a new OCR input that can hold the images to be processed using var input = new OcrInput(); // Specify the page indices to be processed from the TIFF image var pageIndices = new int[] { 1, 2 }; // Load specific pages of the TIFF image into the OCR input object // Perfect for processing large multi-page documents efficiently input.LoadImageFrames(@"img\example.tiff", pageIndices); // Optional pre-processing steps (uncomment as needed) // input.DeNoise(); // Remove digital noise from scanned documents // input.Deskew(); // Automatically straighten tilted scans // Perform OCR on the provided input OcrResult result = ocr.Read(input); // Output the recognized text to the console Console.WriteLine(result.Text); // Note: The OcrResult object contains detailed information including: // - Individual words with confidence scores // - Character positions and bounding boxes // - Paragraph and line structure using IronOcr; using System; // Initialize IronTesseract for performing OCR (Optical Character Recognition) var ocr = new IronTesseract { // Set the language for the OCR process to English Language = OcrLanguage.English }; // Create a new OCR input that can hold the images to be processed using var input = new OcrInput(); // Specify the page indices to be processed from the TIFF image var pageIndices = new int[] { 1, 2 }; // Load specific pages of the TIFF image into the OCR input object // Perfect for processing large multi-page documents efficiently input.LoadImageFrames(@"img\example.tiff", pageIndices); // Optional pre-processing steps (uncomment as needed) // input.DeNoise(); // Remove digital noise from scanned documents // input.Deskew(); // Automatically straighten tilted scans // Perform OCR on the provided input OcrResult result = ocr.Read(input); // Output the recognized text to the console Console.WriteLine(result.Text); // Note: The OcrResult object contains detailed information including: // - Individual words with confidence scores // - Character positions and bounding boxes // - Paragraph and line structure Imports IronOcr Imports System ' Initialize IronTesseract for performing OCR (Optical Character Recognition) Private ocr = New IronTesseract With {.Language = OcrLanguage.English} ' Create a new OCR input that can hold the images to be processed Private input = New OcrInput() ' Specify the page indices to be processed from the TIFF image Private pageIndices = New Integer() { 1, 2 } ' Load specific pages of the TIFF image into the OCR input object ' Perfect for processing large multi-page documents efficiently input.LoadImageFrames("img\example.tiff", pageIndices) ' Optional pre-processing steps (uncomment as needed) ' input.DeNoise(); // Remove digital noise from scanned documents ' input.Deskew(); // Automatically straighten tilted scans ' Perform OCR on the provided input Dim result As OcrResult = ocr.Read(input) ' Output the recognized text to the console Console.WriteLine(result.Text) ' Note: The OcrResult object contains detailed information including: ' - Individual words with confidence scores ' - Character positions and bounding boxes ' - Paragraph and line structure $vbLabelText $csharpLabel 這段程式碼展示了 IronOCR 簡化 API 的強大功能。 IronTesseract類別為 Tesseract 5 提供了一個託管封裝,無需複雜的 C++ 互通。 OcrInput OcrInput支援載入多種影像格式和頁面,而可選的預處理方法( DeNoise()和Deskew() )可以顯著提高實際文件的辨識準確率。 除了基本的文字擷取之外, OcrResult物件還提供豐富的結構化數據,包括單字級置信度分數、字元位置和文件結構,從而實現可搜尋 PDF 建立和精確文字位置追蹤等高級功能。 Tesseract 和 IronOCR 在安裝上有哪些主要差異? 使用 Tesseract 引擎和 .NET 進行 OCR 傳統 C# 中的 Tesseract 整合需要管理 C++ 函式庫,這帶來了一些挑戰。 開發人員必須處理特定於平台的二進位文件,確保 Visual C++ 運行時安裝,並管理 32/64 位元相容性問題。 安裝過程通常需要手動編譯 Tesseract 和 Leptonica 函式庫,特別是對於最新的 Tesseract 5 版本,這些版本並非為 Windows 編譯而設計。 在 Azure、Docker 或 Linux 等環境中,權限和相依性差異很大,因此跨平台部署會變得特別棘手。 IronOCR Tesseract for C IronOCR 透過 NuGet 分發的單一託管 .NET 程式庫,簡化了安裝流程: Install-Package IronOcr 沒有原生 DLL,沒有 C++ 執行時,沒有平台特定的配置。 所有功能均以純託管程式碼形式運行,並自動解決依賴關係。 該庫與以下庫完全相容: .NET Framework 4.6.2 及更高版本 .NET Standard 2.0 及更高版本(包括 .NET 5、6、7、8、9 和 10) .NET Core 2.0 及更高版本 這種方法確保在 Windows、macOS、Linux、Azure、AWS Lambda、Docker 容器,甚至 Xamarin 行動應用程式中保持一致的行為。 最新OCR引擎版本在.NET開發的比較情況如何? 使用 C# 連接 Google Tesseract Tesseract 5 雖然功能強大,但對 Windows 開發人員來說卻帶來了巨大的挑戰。 最新版本需要使用 MinGW 進行交叉編譯,而 MinGW 很少能產生可用的 Windows 二進位。 GitHub 上的免費 C# 封裝庫通常比最新的 Tesseract 版本落後數年,缺少關鍵的改進和錯誤修復。 由於這些編譯障礙,開發人員經常使用過時的 Tesseract 3.x 或 4.x 版本。 IronOCR Tesseract for .NET IronOCR 配備了專為 .NET 優化的客製化 Tesseract 5 引擎。 此實作方案包含效能增強功能,例如原生多執行緒支援、自動影像預處理以及高效處理大型文件。 定期更新可確保與最新的 .NET 版本相容,同時保持向後相容性。 該庫還透過專用的 NuGet 套件提供廣泛的語言支持,無需管理外部詞典文件即可輕鬆添加對 127 多種語言的 OCR 功能。 Google Cloud OCR 比較 雖然Google Cloud Vision OCR提供了很高的準確率,但它需要互聯網連接,每次請求都會產生費用,並且對於敏感文件而言,會引發資料隱私問題。 IronOCR 可提供與本地處理相當的精度,使其成為需要資料安全或離線功能的應用的理想選擇。 使用不同的方法可以達到怎樣的OCR準確率? 在 .NET 專案中使用 Google Tesseract Raw Tesseract 擅長讀取高解析度、完美對齊的文本,但難以處理實際文件。 掃描的頁面、照片或低解析度影像如果不經過大量預處理,通常會產生亂碼輸出。 要達到可接受的精確度,通常需要使用 ImageMagick 或類似工具的自訂影像處理流程,這會增加每種文件類型的數週開發時間。 常見的準確性問題包括: 讀錯傾斜文件上的字符 低DPI掃描完全失敗 混合使用不同字體或版面時效能不佳 無法處理背景噪音或浮水印 .NET 專案中的 IronOCR Tesseract IronOCR 的增強版無需人工預處理,即可在典型商業文件上實現99.8-100% 的準確率: using IronOcr; using System; // Create an instance of the IronTesseract class for OCR processing var ocr = new IronTesseract(); // Create an OcrInput object to load and preprocess images using var input = new OcrInput(); // Specify which pages to extract from multi-page documents var pageIndices = new int[] { 1, 2 }; // Load specific frames from a TIFF file // IronOCR automatically detects and handles various image formats input.LoadImageFrames(@"img\example.tiff", pageIndices); // Apply automatic image enhancement filters // These filters dramatically improve accuracy on imperfect scans input.DeNoise(); // Removes digital artifacts and speckles input.Deskew(); // Corrects rotation up to 15 degrees // Perform OCR with enhanced accuracy algorithms OcrResult result = ocr.Read(input); // Access the extracted text with confidence metrics Console.WriteLine(result.Text); // Additional accuracy features available: // - result.Confidence: Overall accuracy percentage // - result.Pages[0].Words: Word-level confidence scores // - result.Blocks: Structured document layout analysis using IronOcr; using System; // Create an instance of the IronTesseract class for OCR processing var ocr = new IronTesseract(); // Create an OcrInput object to load and preprocess images using var input = new OcrInput(); // Specify which pages to extract from multi-page documents var pageIndices = new int[] { 1, 2 }; // Load specific frames from a TIFF file // IronOCR automatically detects and handles various image formats input.LoadImageFrames(@"img\example.tiff", pageIndices); // Apply automatic image enhancement filters // These filters dramatically improve accuracy on imperfect scans input.DeNoise(); // Removes digital artifacts and speckles input.Deskew(); // Corrects rotation up to 15 degrees // Perform OCR with enhanced accuracy algorithms OcrResult result = ocr.Read(input); // Access the extracted text with confidence metrics Console.WriteLine(result.Text); // Additional accuracy features available: // - result.Confidence: Overall accuracy percentage // - result.Pages[0].Words: Word-level confidence scores // - result.Blocks: Structured document layout analysis Imports IronOcr Imports System ' Create an instance of the IronTesseract class for OCR processing Private ocr = New IronTesseract() ' Create an OcrInput object to load and preprocess images Private input = New OcrInput() ' Specify which pages to extract from multi-page documents Private pageIndices = New Integer() { 1, 2 } ' Load specific frames from a TIFF file ' IronOCR automatically detects and handles various image formats input.LoadImageFrames("img\example.tiff", pageIndices) ' Apply automatic image enhancement filters ' These filters dramatically improve accuracy on imperfect scans input.DeNoise() ' Removes digital artifacts and speckles input.Deskew() ' Corrects rotation up to 15 degrees ' Perform OCR with enhanced accuracy algorithms Dim result As OcrResult = ocr.Read(input) ' Access the extracted text with confidence metrics Console.WriteLine(result.Text) ' Additional accuracy features available: ' - result.Confidence: Overall accuracy percentage ' - result.Pages[0].Words: Word-level confidence scores ' - result.Blocks: Structured document layout analysis $vbLabelText $csharpLabel 自動預處理過濾器可以處理常見的文件品質問題,否則這些問題需要人工幹預。 DeNoise()方法可去除掃描中的數位偽影,而Deskew()可校正文件旋轉-這兩個項對於保持高精度都至關重要。 高級用戶可以透過自訂配置進一步優化準確性,包括字元白名單、特定區域處理以及針對行業特定術語的專用語言模型。 OCR處理支援哪些影像格式和來源? .NET 中的 Google Tesseract 原生 Tesseract 只接受 Leptonica PIX 格式——一種非託管的 C++ 指針,在 C# 中處理起來很困難。 將 .NET 映像轉換為 PIX 格式需要謹慎的記憶體管理,以防止記憶體洩漏。 支援 PDF 和多頁 TIFF 需要額外的程式庫,而這些程式庫本身也存在相容性問題。 許多實作方案在基本格式轉換方面存在困難,限制了其實際可用性。 IronOCR影像相容性 IronOCR 提供全面的格式支援和自動轉換功能: PDF 文件(包括受密碼保護的文件) 多幀 TIFF 文件 標準格式:JPEG、PNG、GIF、BMP 高級格式:JPEG2000、WBMP .NET 類型: System.Drawing.Image 、 System.Drawing.Bitmap 資料來源:流、位元組數組、檔案路徑 -直接掃描器集成 全面格式支援範例 using IronOcr; using System; // Initialize IronTesseract for OCR operations var ocr = new IronTesseract(); // Create an OcrInput container for multiple sources using var input = new OcrInput(); // Load password-protected PDFs seamlessly // IronOCR handles PDF rendering internally input.LoadPdf("example.pdf", "password"); // Process specific pages from multi-page TIFFs // Perfect for batch document processing var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames("multi-frame.tiff", pageIndices); // Add individual images in any common format // Automatic format detection and conversion input.LoadImage("image1.png"); input.LoadImage("image2.jpeg"); // Process all loaded content in a single operation // Results maintain document structure and ordering var result = ocr.Read(input); // Extract text while preserving document layout Console.WriteLine(result.Text); // Advanced features for complex documents: // - Extract images from specific PDF pages // - Process only certain regions of images // - Maintain reading order across mixed formats using IronOcr; using System; // Initialize IronTesseract for OCR operations var ocr = new IronTesseract(); // Create an OcrInput container for multiple sources using var input = new OcrInput(); // Load password-protected PDFs seamlessly // IronOCR handles PDF rendering internally input.LoadPdf("example.pdf", "password"); // Process specific pages from multi-page TIFFs // Perfect for batch document processing var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames("multi-frame.tiff", pageIndices); // Add individual images in any common format // Automatic format detection and conversion input.LoadImage("image1.png"); input.LoadImage("image2.jpeg"); // Process all loaded content in a single operation // Results maintain document structure and ordering var result = ocr.Read(input); // Extract text while preserving document layout Console.WriteLine(result.Text); // Advanced features for complex documents: // - Extract images from specific PDF pages // - Process only certain regions of images // - Maintain reading order across mixed formats Imports IronOcr Imports System ' Initialize IronTesseract for OCR operations Private ocr = New IronTesseract() ' Create an OcrInput container for multiple sources Private input = New OcrInput() ' Load password-protected PDFs seamlessly ' IronOCR handles PDF rendering internally input.LoadPdf("example.pdf", "password") ' Process specific pages from multi-page TIFFs ' Perfect for batch document processing Dim pageIndices = New Integer() { 1, 2 } input.LoadImageFrames("multi-frame.tiff", pageIndices) ' Add individual images in any common format ' Automatic format detection and conversion input.LoadImage("image1.png") input.LoadImage("image2.jpeg") ' Process all loaded content in a single operation ' Results maintain document structure and ordering Dim result = ocr.Read(input) ' Extract text while preserving document layout Console.WriteLine(result.Text) ' Advanced features for complex documents: ' - Extract images from specific PDF pages ' - Process only certain regions of images ' - Maintain reading order across mixed formats $vbLabelText $csharpLabel 這種統一的文檔載入方法消除了特定於格式的程式碼。 無論是處理掃描的 TIFF 檔案、數位 PDF 檔案或智慧型手機照片,同一個 API 都能處理所有場景。 OcrInput類別能夠智慧地管理內存,並且無論來源格式如何,都能提供一致的結果。 對於特殊場景,IronOCR 還支援從同一文件中讀取條碼和二維碼,從而能夠一次提取全面的文檔資料。 OCR在實際應用上的表現表現如何? 免費 Google Tesseract 效能 Vanilla Tesseract 可以對與訓練資料相符的預處理高解析度影像提供可接受的速度。 然而,實際表現往往令人失望。 當 Tesseract 處理影像品質不佳時,處理掃描文件的單頁可能需要 10-30 秒。 單執行緒架構會成為批次的瓶頸,並且隨著影像尺寸增加,記憶體使用量可能會呈螺旋式上升。 IronOCR Tesseract 庫效能 IronOCR 為生產工作負載實施智慧效能最佳化: using IronOcr; using System; // Configure IronTesseract for optimal performance var ocr = new IronTesseract(); // Performance optimization: disable unnecessary character recognition // Speeds up processing by 20-30% when special characters aren't needed ocr.Configuration.BlackListCharacters = "~`$#^*_}{][|\\@¢©«»°±·×‑–—''""•…′″€™←↑→↓↔⇄⇒∅∼≅≈≠≤≥≪≫⌁⌘○◔◑◕●"; // Use automatic page segmentation for faster processing // Adapts to document layout without manual configuration ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto; // Disable barcode scanning when not needed // Eliminates unnecessary processing overhead ocr.Configuration.ReadBarCodes = false; // Switch to fast language pack for speed-critical applications // Trades minimal accuracy for 40% performance improvement ocr.Language = OcrLanguage.EnglishFast; // Load and process documents efficiently using var input = new OcrInput(); var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames(@"img\Potter.tiff", pageIndices); // Multi-threaded processing utilizes all CPU cores // Automatically scales based on system capabilities var result = ocr.Read(input); Console.WriteLine(result.Text); // Performance monitoring capabilities: // - result.TimeToRead: Processing duration // - result.InputDetails: Image analysis metrics // - Memory-efficient streaming for large documents using IronOcr; using System; // Configure IronTesseract for optimal performance var ocr = new IronTesseract(); // Performance optimization: disable unnecessary character recognition // Speeds up processing by 20-30% when special characters aren't needed ocr.Configuration.BlackListCharacters = "~`$#^*_}{][|\\@¢©«»°±·×‑–—''""•…′″€™←↑→↓↔⇄⇒∅∼≅≈≠≤≥≪≫⌁⌘○◔◑◕●"; // Use automatic page segmentation for faster processing // Adapts to document layout without manual configuration ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto; // Disable barcode scanning when not needed // Eliminates unnecessary processing overhead ocr.Configuration.ReadBarCodes = false; // Switch to fast language pack for speed-critical applications // Trades minimal accuracy for 40% performance improvement ocr.Language = OcrLanguage.EnglishFast; // Load and process documents efficiently using var input = new OcrInput(); var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames(@"img\Potter.tiff", pageIndices); // Multi-threaded processing utilizes all CPU cores // Automatically scales based on system capabilities var result = ocr.Read(input); Console.WriteLine(result.Text); // Performance monitoring capabilities: // - result.TimeToRead: Processing duration // - result.InputDetails: Image analysis metrics // - Memory-efficient streaming for large documents Imports IronOcr Imports System ' Configure IronTesseract for optimal performance Private ocr = New IronTesseract() ' Performance optimization: disable unnecessary character recognition ' Speeds up processing by 20-30% when special characters aren't needed ocr.Configuration.BlackListCharacters = "~`$#^*_}{][|\@¢©«»°±·×‑–—''""•…′″€™←↑→↓↔⇄⇒∅∼≅≈≠≤≥≪≫⌁⌘○◔◑◕●" ' Use automatic page segmentation for faster processing ' Adapts to document layout without manual configuration ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto ' Disable barcode scanning when not needed ' Eliminates unnecessary processing overhead ocr.Configuration.ReadBarCodes = False ' Switch to fast language pack for speed-critical applications ' Trades minimal accuracy for 40% performance improvement ocr.Language = OcrLanguage.EnglishFast ' Load and process documents efficiently Dim input = New OcrInput() Dim pageIndices = New Integer() { 1, 2 } input.LoadImageFrames("img\Potter.tiff", pageIndices) ' Multi-threaded processing utilizes all CPU cores ' Automatically scales based on system capabilities Dim result = ocr.Read(input) Console.WriteLine(result.Text) ' Performance monitoring capabilities: ' - result.TimeToRead: Processing duration ' - result.InputDetails: Image analysis metrics ' - Memory-efficient streaming for large documents $vbLabelText $csharpLabel 這些優化措施證明了 IronOCR 已具備量產能力。 僅BlackListCharacters配置一項,在不需要特殊字元的情況下,即可將速度提高 20-30%。 快速語言包為大批量處理提供了極佳的平衡,在這種處理中,完美的準確性並非至關重要。 對於企業應用而言,IronOCR 的多線程支援能夠同時處理多個文檔,與單線程 Tesseract 相比,在現代多核心系統上可實現 4-8 倍的吞吐量提升。 Tesseract 和 IronOCR 的 API 設計有何不同? 在 .NET 中使用 Google Tesseract OCR 將原始 Tesseract 整合到 C# 應用程式中面臨兩種具有挑戰性的選擇: -互通封裝器:通常過時、文件不完善且容易出現記憶體洩漏 -命令列執行:部署困難,受安全性原則限制,錯誤處理能力差。 這兩種方法在雲端環境、Web應用程式或跨平台部署中都無法可靠地運作。 缺乏合適的 .NET 整合意味著要花費更多時間與工具作鬥爭,而不是解決業務問題。 IronOCR Tesseract OCR 函式庫,適用於 .NET IronOCR 提供了一個完全託管、直覺的 API,專為 .NET 開發人員設計: 最簡實現 using IronOcr; // Initialize the OCR engine with full IntelliSense support var ocr = new IronTesseract(); // Process an image with automatic format detection // Handles JPEG, PNG, TIFF, PDF, and more var result = ocr.Read("img.png"); // Extract text with confidence metrics string extractedText = result.Text; Console.WriteLine(extractedText); // Rich API provides detailed results: // - result.Confidence: Overall accuracy percentage // - result.Pages: Page-by-page breakdown // - result.Paragraphs: Document structure // - result.Words: Individual word details // - result.Barcodes: Detected barcode values using IronOcr; // Initialize the OCR engine with full IntelliSense support var ocr = new IronTesseract(); // Process an image with automatic format detection // Handles JPEG, PNG, TIFF, PDF, and more var result = ocr.Read("img.png"); // Extract text with confidence metrics string extractedText = result.Text; Console.WriteLine(extractedText); // Rich API provides detailed results: // - result.Confidence: Overall accuracy percentage // - result.Pages: Page-by-page breakdown // - result.Paragraphs: Document structure // - result.Words: Individual word details // - result.Barcodes: Detected barcode values Imports IronOcr ' Initialize the OCR engine with full IntelliSense support Private ocr = New IronTesseract() ' Process an image with automatic format detection ' Handles JPEG, PNG, TIFF, PDF, and more Private result = ocr.Read("img.png") ' Extract text with confidence metrics Private extractedText As String = result.Text Console.WriteLine(extractedText) ' Rich API provides detailed results: ' - result.Confidence: Overall accuracy percentage ' - result.Pages: Page-by-page breakdown ' - result.Paragraphs: Document structure ' - result.Words: Individual word details ' - result.Barcodes: Detected barcode values $vbLabelText $csharpLabel 這種簡化的 API 消除了傳統 Tesseract 整合的複雜性。 每個方法都包含全面的 XML 文檔,方便您在 IDE 中直接探索各項功能。豐富的 API 文件為每個功能提供了詳細的範例。 經驗豐富的工程師提供的專業支援確保您不會在實施細節上遇到困難。 該程式庫會定期更新,在保持與最新 .NET 版本相容的同時,根據開發者的回饋添加新功能。 支援哪些平台和部署場景? Google Tesseract + Interop for .NET 跨平台 Tesseract 部署需要針對特定平台進行建置和配置。 每個目標環境都需要不同的二進位檔案、執行時間依賴項和權限。 Docker容器需要仔細選擇基礎映像。 由於缺少 Visual C++ 運行時,Azure 部署經常失敗。 Linux相容性取決於具體的發行版和軟體包可用性。 IronOCR Tesseract .NET OCR庫 IronOCR 提供真正的"一次寫入,隨處部署"功能: 應用類型: 桌面應用程式(WPF、WinForms、控制台) Web 應用程式(ASP.NET Core、Blazor) 雲端服務(Azure Functions、AWS Lambda) 行動應用程式(透過 Xamarin) 微服務(Docker、Kubernetes) 平台支援: Windows(7、8、10、11、伺服器版本) macOS (Intel 和 Apple Silicon) Linux(Ubuntu、Debian、CentOS、Alpine) Docker 容器(官方基礎映像) 雲端平台(Azure、AWS、Google Cloud) .NET 相容性: .NET Framework 4.6.2 及更高版本 .NET Core 2.0+(所有版本) .NET 5、6、7、8、9 和 10 .NET Standard 2.0+ Mono框架 Xamarin.Mac 該庫在內部處理平台差異,從而在所有環境下提供一致的結果。 部署指南涵蓋了具體場景,包括容器化、無伺服器函數和高可用性配置。 多國語言OCR功能比較如何? Google Tesseract 語言支援 在 Tesseract 中管理語言需要下載和維護 tessdata 檔案 - 所有語言大約需要 4GB。 資料夾結構必須精確,環境變數必須配置正確,且路徑在運行時必須可存取。語言切換需要存取檔案系統,這使得在受限環境中部署變得複雜。 Tesseract 二進位檔案和語言檔案之間的版本不匹配會導致難以理解的錯誤。 IronOCR語言管理 IronOCR 透過 NuGet 套件管理革新了語言支援: 阿拉伯語 OCR 範例 using IronOcr; // Configure IronTesseract for Arabic text recognition var ocr = new IronTesseract { // Set primary language to Arabic // Automatically handles right-to-left text Language = OcrLanguage.Arabic }; // Load Arabic documents for processing using var input = new OcrInput(); var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames("img/arabic.gif", pageIndices); // IronOCR includes specialized preprocessing for Arabic scripts // Handles cursive text and diacritical marks automatically // Perform OCR with language-specific optimizations var result = ocr.Read(input); // Save results with proper Unicode encoding // Preserves Arabic text formatting and direction result.SaveAsTextFile("arabic.txt"); // Advanced Arabic features: // - Mixed Arabic/English document support // - Automatic number conversion (Eastern/Western Arabic) // - Font-specific optimization for common Arabic typefaces using IronOcr; // Configure IronTesseract for Arabic text recognition var ocr = new IronTesseract { // Set primary language to Arabic // Automatically handles right-to-left text Language = OcrLanguage.Arabic }; // Load Arabic documents for processing using var input = new OcrInput(); var pageIndices = new int[] { 1, 2 }; input.LoadImageFrames("img/arabic.gif", pageIndices); // IronOCR includes specialized preprocessing for Arabic scripts // Handles cursive text and diacritical marks automatically // Perform OCR with language-specific optimizations var result = ocr.Read(input); // Save results with proper Unicode encoding // Preserves Arabic text formatting and direction result.SaveAsTextFile("arabic.txt"); // Advanced Arabic features: // - Mixed Arabic/English document support // - Automatic number conversion (Eastern/Western Arabic) // - Font-specific optimization for common Arabic typefaces Imports IronOcr ' Configure IronTesseract for Arabic text recognition Private ocr = New IronTesseract With {.Language = OcrLanguage.Arabic} ' Load Arabic documents for processing Private input = New OcrInput() Private pageIndices = New Integer() { 1, 2 } input.LoadImageFrames("img/arabic.gif", pageIndices) ' IronOCR includes specialized preprocessing for Arabic scripts ' Handles cursive text and diacritical marks automatically ' Perform OCR with language-specific optimizations Dim result = ocr.Read(input) ' Save results with proper Unicode encoding ' Preserves Arabic text formatting and direction result.SaveAsTextFile("arabic.txt") ' Advanced Arabic features: ' - Mixed Arabic/English document support ' - Automatic number conversion (Eastern/Western Arabic) ' - Font-specific optimization for common Arabic typefaces $vbLabelText $csharpLabel 多語言文件處理 using IronOcr; // Install language packs via NuGet: // PM> Install-Package IronOcr.Languages.ChineseSimplified // Configure multi-language OCR var ocr = new IronTesseract(); // Set primary language for majority content ocr.Language = OcrLanguage.ChineseSimplified; // Add secondary language for mixed content // Perfect for documents with Chinese text and English metadata ocr.AddSecondaryLanguage(OcrLanguage.English); // Process multi-language PDFs efficiently using var input = new OcrInput(); input.LoadPdf("multi-language.pdf"); // IronOCR automatically detects and switches between languages // Maintains high accuracy across language boundaries var result = ocr.Read(input); // Export preserves all languages correctly result.SaveAsTextFile("results.txt"); // Supported scenarios: // - Technical documents with English terms in foreign text // - Multilingual forms and applications // - International business documents // - Mixed-script content (Latin, CJK, Arabic, etc.) using IronOcr; // Install language packs via NuGet: // PM> Install-Package IronOcr.Languages.ChineseSimplified // Configure multi-language OCR var ocr = new IronTesseract(); // Set primary language for majority content ocr.Language = OcrLanguage.ChineseSimplified; // Add secondary language for mixed content // Perfect for documents with Chinese text and English metadata ocr.AddSecondaryLanguage(OcrLanguage.English); // Process multi-language PDFs efficiently using var input = new OcrInput(); input.LoadPdf("multi-language.pdf"); // IronOCR automatically detects and switches between languages // Maintains high accuracy across language boundaries var result = ocr.Read(input); // Export preserves all languages correctly result.SaveAsTextFile("results.txt"); // Supported scenarios: // - Technical documents with English terms in foreign text // - Multilingual forms and applications // - International business documents // - Mixed-script content (Latin, CJK, Arabic, etc.) Imports IronOcr ' Install language packs via NuGet: ' PM> Install-Package IronOcr.Languages.ChineseSimplified ' Configure multi-language OCR Private ocr = New IronTesseract() ' Set primary language for majority content ocr.Language = OcrLanguage.ChineseSimplified ' Add secondary language for mixed content ' Perfect for documents with Chinese text and English metadata ocr.AddSecondaryLanguage(OcrLanguage.English) ' Process multi-language PDFs efficiently Dim input = New OcrInput() input.LoadPdf("multi-language.pdf") ' IronOCR automatically detects and switches between languages ' Maintains high accuracy across language boundaries Dim result = ocr.Read(input) ' Export preserves all languages correctly result.SaveAsTextFile("results.txt") ' Supported scenarios: ' - Technical documents with English terms in foreign text ' - Multilingual forms and applications ' - International business documents ' - Mixed-script content (Latin, CJK, Arabic, etc.) $vbLabelText $csharpLabel 語言包系統支援超過 127 種語言,每種語言都針對特定的腳本和書寫系統進行了最佳化。 透過 NuGet 安裝可確保版本相容性,並簡化跨不同環境的部署。 除了基本的OCR功能外,IronOCR還提供哪些其他功能? IronOCR 的功能遠不止基本的文字擷取,它還具備企業級功能: -自動影像分析:根據影像特徵智慧配置處理方案 -建立可搜尋的PDF :將掃描文件轉換為完全可搜尋的PDF文件 -進階PDF OCR :在保留文件結構的同時提取文本 條碼和二維碼讀取:一次掃描即可偵測和解碼條碼。 HTML匯出:根據OCR結果產生結構化HTML TIFF 轉 PDF 轉換:將多頁 TIFF 檔案轉換為可搜尋的 PDF 文件 -支援多執行緒:同時處理多個文檔 -詳細結果分析:存取具有置信度評分的角色級數據 OcrResult類別提供對已識別內容的精細訪問,從而實現複雜的後處理和驗證工作流程。 C# 開發應該選擇哪一種 OCR 解決方案? Google Tesseract for C# OCR 選擇香草色 Tesseract 的情況: 參與學術或研究項目 處理完美掃描的文檔,開發時間不受限制 建立概念驗證應用程式 成本是唯一考慮因素。 要做好應對重大整合挑戰和持續維護需求的準備。 IronOCR Tesseract OCR 函式庫,適用於 .NET Framework 和 Core IronOCR是以下情況的最佳選擇: 需要可靠性的生產應用 具有真實世界文檔品質的項目 跨平台部署 時間緊迫的開發計劃 需要專業支援的應用 該庫透過縮短開發時間和提高複雜文件的準確性來收回成本。 如何在 C# 專案中開始使用專業 OCR? 開始在 Visual Studio 專案中實現高精度 OCR: Install-Package IronOcr 或直接下載 IronOCR .NET DLL進行手動安裝。 首先請參閱我們全面的入門指南,瀏覽程式碼範例,並在需要時獲得專業支援。 體驗專業 OCR 帶來的不同——立即開始免費試用,加入超過 10,000 家公司行列,在文件處理工作流程中實現 99.8% 以上的準確率。 Iron Software 的 OCR 技術深受全球財富 500 強企業和政府機構的信賴,用於關鍵任務文件處理。 有關與其他 OCR 服務的詳細比較,請參閱我們的分析: AWS Textract 與 Google Vision OCR - 企業功能比較。 常見問題解答 我如何在C#应用程序中实现Tesseract OCR? 要在 C# 应用程序中实现 Tesseract OCR,您可以使用 IronOCR 中的 IronTesseract 类。通过命令 Install-Package IronOcr 使用 NuGet 安装,然后添加命名空间 using IronOcr;。使用 var ocr = new IronTesseract(); 实例化OCR引擎,并使用 var result = ocr.Read("image.png"); 从图像中提取文本。 使用 IronOCR 比传统 Tesseract 有哪些好处? IronOCR 提供了多项优于传统 Tesseract 的优势,包括无需本机依赖项的简化部署、用于提高准确性的自动图像预处理和托管的 .NET 集成。它提供 PDF 和多语言支持等功能,可以通过 NuGet 易于安装,避免了原版 Tesseract 所需的复杂 C++ 互操作。 如何改善C#项目中的OCR准确性? 要改善C#项目中的OCR准确性,请使用IronOCR的自动图像增强功能。方法如 input.DeNoise() 和 input.Deskew() 帮助预处理图像,减少噪声和校正倾斜。此外,选择合适的语言设置并使用通过 OcrResult.Confidence 进行准确性验证的置信度指标。 我可以使用C#对PDF文档执行OCR吗? 是的,使用 IronOCR 的 OcrInput 类,您可以对 PDF 文档执行 OCR。使用 input.LoadPdf("file.pdf", "password") 加载 PDF,并使用 var result = ocr.Read(input); 处理它。这允许在您的 C# 应用程序中直接提取文本和创建可搜索的 PDF。 我如何处理单个OCR文档中的多种语言? IronOCR 允许在单个文档中处理多种语言。使用 ocr.Language = OcrLanguage.English; 设置主要语言,并通过 ocr.AddSecondaryLanguage(OcrLanguage.Spanish); 添加辅助语言。这种灵活性对于包含混合语言或技术术语的文档非常有利。 哪些平台支持 IronOCR? IronOCR 支持多种平台,包括 .NET Framework 4.6.2+,.NET Core 2.0+,.NET 5-10 和 .NET Standard 2.0+。它在 Windows、macOS 和 Linux 上运行,也可以在 Docker 容器、Azure Functions、AWS Lambda 和 Xamarin 移动应用中运行,提供在不同环境中的一致性能。 我如何优化C#中OCR处理的性能? 要优化C#中OCR处理的性能,利用IronOCR的功能,如通过 ocr.Configuration.ReadBarCodes = false; 禁用不必要的条形码扫描,并选择更快的语言模型,如 ocr.Language = OcrLanguage.EnglishFast;。此外,利用多线程功能进行更快的批处理。 IronOCR支持哪些图像格式? IronOCR 支持多种图像格式,包括 PDF、TIFF、JPEG 和 PNG。使用 OcrInput 类通过 input.LoadImage("photo.jpg") 或 input.LoadPdf("file.pdf") 等方法加载图像。这种广泛的兼容性允许与不同的图像来源和格式轻松集成。 Jacob Mellor 立即與工程團隊聊天 首席技术官 Jacob Mellor 是 Iron Software 的首席技術官,作為 C# PDF 技術的先鋒工程師。作為 Iron Software 核心代碼的原作者,他自開始以來塑造了公司產品架構,與 CEO Cameron Rimington 一起將其轉變為一家擁有超過 50 名員工的公司,為 NASA、特斯拉 和 全世界政府機構服務。Jacob 持有曼徹斯特大學土木工程一級榮譽学士工程學位(BEng) (1998-2001)。他於 1999 年在倫敦開設了他的第一家軟件公司,並於 2005 年製作了他的首個 .NET 組件,專注於解決 Microsoft 生態系統內的複雜問題。他的旗艦產品 IronPDF & Iron Suite .NET 庫在全球 NuGet 被安裝超過 3000 萬次,其基礎代碼繼續為世界各地的開發工具提供動力。擁有 25 年的商業經驗和 41 年的編碼專業知識,Jacob 仍專注於推動企業級 C#、Java 及 Python PDF 技術的創新,同時指導新一代技術領袖。 審核人 Jeffrey T. Fritz 首席程序经理 - .NET 社区团队 Jeff 也是 .NET 和 Visual Studio 团队的首席程序经理。他是 .NET Conf 虚拟会议系列的执行制作人,并主持“Fritz 和朋友”这一每周两次的开发者的直播节目,在节目上讨论技术并与观众一起编写代码。Jeff 撰写研讨会、主持演讲,并计划大型 Microsoft 开发者活动(包括 Microsoft Build、Microsoft Ignite、.NET Conf 和 Microsoft MVP Summit)的内容。 準備好開始了嗎? Nuget 下載 5,167,857 | Version: 2025.11 剛發表 免費下載 NuGet 下載總數:5,167,857 檢視授權