跳過到頁腳內容
OCR 工具

Azure OCR vs Google OCR(OCR 功能比較)

在今天的數位環境中,光學文字識別(OCR)技術已成為企業從影像、PDF和其他文件中高效提取文字的必備技術。 在眾多OCR解決方案功能中,Microsoft Azure OCR、Google OCR和IronOCR脫穎而出,各自提供獨特的功能和能力。 在本文中,我們將討論這些OCR服務、它們的特點以及如何選擇。

1. OCR服務簡介

OCR服務是一個基於雲的平臺,利用先進的機器學習算法從影像和文件中提取文字。 Azure OCR、Google OCR和IronOCR都是廣泛使用的OCR服務,各自具有其優勢和應用。

2. Azure OCR

作為Microsoft Azure認知服務套件的一部分,Azure OCR工具提供了一個可靠且可擴展的文字識別解決方案。 它支援多種語言和文件格式,適用於多樣的使用案例。 Microsoft Azure OCR利用深度學習模型來實現高精度文字提取,使企業能夠有效地精簡文件處理流程。 Azure更像是一個計算機視覺服務。

2.1 Azure OCR的關鍵功能

  • 語言支持:Microsoft Azure OCR支持超過70種語言,包括阿拉伯語和中文等複雜文字。
  • 文件格式:它可以處理多種文件格式,包括圖像、PDF和掃描文件。
  • 可擴展性:Azure OCR可無縫擴展以處理大量的文字提取請求,適用於企業級應用。

2.2 程式碼範例 (C#)

using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;
using System;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Create an instance of the ComputerVisionClient
        ComputerVisionClient client = new ComputerVisionClient(new ApiKeyServiceClientCredentials("YOUR_API_KEY"))
        {
            Endpoint = "https://YOUR_REGION.api.cognitive.microsoft.com/"
        };

        // Specify the image URL
        string imageUrl = "https://example.com/image.jpg";

        // Perform OCR on the image
        OcrResult result = await client.RecognizePrintedTextAsync(true, imageUrl);

        // Display the extracted text
        foreach (var region in result.Regions)
        {
            foreach (var line in region.Lines)
            {
                foreach (var word in line.Words)
                {
                    Console.Write(word.Text + " ");
                }
                Console.WriteLine();
            }
        }
    }
}
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;
using System;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        // Create an instance of the ComputerVisionClient
        ComputerVisionClient client = new ComputerVisionClient(new ApiKeyServiceClientCredentials("YOUR_API_KEY"))
        {
            Endpoint = "https://YOUR_REGION.api.cognitive.microsoft.com/"
        };

        // Specify the image URL
        string imageUrl = "https://example.com/image.jpg";

        // Perform OCR on the image
        OcrResult result = await client.RecognizePrintedTextAsync(true, imageUrl);

        // Display the extracted text
        foreach (var region in result.Regions)
        {
            foreach (var line in region.Lines)
            {
                foreach (var word in line.Words)
                {
                    Console.Write(word.Text + " ");
                }
                Console.WriteLine();
            }
        }
    }
}
Imports Microsoft.Azure.CognitiveServices.Vision.ComputerVision
Imports Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models
Imports System
Imports System.Threading.Tasks

Friend Class Program
	Shared Async Function Main(ByVal args() As String) As Task
		' Create an instance of the ComputerVisionClient
		Dim client As New ComputerVisionClient(New ApiKeyServiceClientCredentials("YOUR_API_KEY")) With {.Endpoint = "https://YOUR_REGION.api.cognitive.microsoft.com/"}

		' Specify the image URL
		Dim imageUrl As String = "https://example.com/image.jpg"

		' Perform OCR on the image
		Dim result As OcrResult = Await client.RecognizePrintedTextAsync(True, imageUrl)

		' Display the extracted text
		For Each region In result.Regions
			For Each line In region.Lines
				For Each word In line.Words
					Console.Write(word.Text & " ")
				Next word
				Console.WriteLine()
			Next line
		Next region
	End Function
End Class
$vbLabelText   $csharpLabel

2.2.1 輸出

Azure OCR vs Google OCR (OCR功能比較):圖1 - Azure OCR程式碼的控制台輸出

3. Google OCR

Google OCR作為Google雲服務提供商的一部分,提供了一個強大的文字識別和文件分析平臺。 利用Google的先進機器學習算法,它提供準確的文字提取功能,並通過雲計算提供如圖像標籤和物件檢測等其他功能。 Google雲平臺OCR廣泛應用於各個行業,用於處理發票、表格識別和內容數字化等任務。

3.1 Google OCR的關鍵功能

  • 多語言支持:Google OCR支持超過200種語言,可以識別多種文字,包括拉丁文、西里爾文和漢字。
  • 圖像分析:它提供先進的圖像分析功能,如標籤檢測、人臉檢測和地標識別。
  • 與Google雲服務的整合:Google OCR可以無縫整合其他Google雲視覺API服務,使開發者能夠構建文件管理和分析的綜合解決方案。

3.2 程式碼範例 (C#)

using System;
using Google.Cloud.Vision.V1;

class Program
{
    static void Main(string[] args)
    {
        // Configure the ImageAnnotator client with credentials
        var clientBuilder = new ImageAnnotatorClientBuilder { CredentialsPath = "path-to-credentials.json" };
        var client = clientBuilder.Build();

        // Load the image from file
        var image = Image.FromFile("path-to-your-image.jpg");

        // Perform text detection on the image
        var response = client.DetectText(image);

        // Display the detected text
        foreach (var annotation in response)
        {
            Console.WriteLine(annotation.Description);
        }
    }
}
using System;
using Google.Cloud.Vision.V1;

class Program
{
    static void Main(string[] args)
    {
        // Configure the ImageAnnotator client with credentials
        var clientBuilder = new ImageAnnotatorClientBuilder { CredentialsPath = "path-to-credentials.json" };
        var client = clientBuilder.Build();

        // Load the image from file
        var image = Image.FromFile("path-to-your-image.jpg");

        // Perform text detection on the image
        var response = client.DetectText(image);

        // Display the detected text
        foreach (var annotation in response)
        {
            Console.WriteLine(annotation.Description);
        }
    }
}
Imports System
Imports Google.Cloud.Vision.V1

Friend Class Program
	Shared Sub Main(ByVal args() As String)
		' Configure the ImageAnnotator client with credentials
		Dim clientBuilder = New ImageAnnotatorClientBuilder With {.CredentialsPath = "path-to-credentials.json"}
		Dim client = clientBuilder.Build()

		' Load the image from file
		Dim image As System.Drawing.Image = System.Drawing.Image.FromFile("path-to-your-image.jpg")

		' Perform text detection on the image
		Dim response = client.DetectText(image)

		' Display the detected text
		For Each annotation In response
			Console.WriteLine(annotation.Description)
		Next annotation
	End Sub
End Class
$vbLabelText   $csharpLabel

3.2.1 輸出

Azure OCR vs Google OCR (OCR功能比較):圖2 - Google OCR程式碼的控制台輸出

4. IronOCR

IronOCR由Iron Software開發,是一個用於.NET應用程式的多功能OCR庫,提供業界領先的OCR準確性和性能。 與基於雲的OCR服務不同,IronOCR提供了本地端的文字提取能力,適用於需要數據隱私和安全的應用。 IronOCR在準確性上表現出色,尤其是在涉及複雜佈局和噪音圖像的情況下,是追求可靠OCR功能的企業的首選。

4.1 IronOCR的關鍵功能

  • 高準確性:IronOCR在文字識別方面提供卓越的準確性,保證在多樣文件類型和語言中的可靠結果。
  • 本地端OCR:它提供本地端的文字提取能力,讓企業能在不依賴外部服務的情況下處理敏感文件。
  • 多功能語言支持:IronOCR支持超過125種語言,並提供完整的語言包以實現無縫的多語言文字識別。

4.2 安裝IronOCR

可以使用NuGet Package Manager Console安裝IronOCR。 只需運行以下命令。

  1. 打開Visual Studio並創建一個新專案或打開一個現有的專案。
  2. 在工具欄中,轉到工具並選擇NuGet Package Manager。

Azure OCR vs Google OCR (OCR功能比較):圖3 - 在Visual Studio中找到NuGet包管理器的位置

  1. 現在選擇新出現列表中的包管理器控制台。
  2. 現在控制台會出現,運行以下命令並按下Enter。
Install-Package IronOcr

安裝IronOCR需要一段時間,但完成後我們可以進入程式碼範例部分。

4.3 程式碼範例 (C#)

using IronOcr;
using System;

class Program
{
    static void Main(string[] args)
    {
        // Specify the path to the image file
        string imagePath = "path-to-your-image.jpg";

        // Instantiate the IronTesseract OCR engine
        var ocr = new IronTesseract
        {
            // Set the language for text recognition
            Language = OcrLanguage.English
        };

        // Perform text recognition on the image
        var result = ocr.Read(imagePath);

        // Display the extracted text
        Console.WriteLine("Extracted Text:");
        Console.WriteLine(result.Text);
    }
}
using IronOcr;
using System;

class Program
{
    static void Main(string[] args)
    {
        // Specify the path to the image file
        string imagePath = "path-to-your-image.jpg";

        // Instantiate the IronTesseract OCR engine
        var ocr = new IronTesseract
        {
            // Set the language for text recognition
            Language = OcrLanguage.English
        };

        // Perform text recognition on the image
        var result = ocr.Read(imagePath);

        // Display the extracted text
        Console.WriteLine("Extracted Text:");
        Console.WriteLine(result.Text);
    }
}
Imports IronOcr
Imports System

Friend Class Program
	Shared Sub Main(ByVal args() As String)
		' Specify the path to the image file
		Dim imagePath As String = "path-to-your-image.jpg"

		' Instantiate the IronTesseract OCR engine
		Dim ocr = New IronTesseract With {.Language = OcrLanguage.English}

		' Perform text recognition on the image
		Dim result = ocr.Read(imagePath)

		' Display the extracted text
		Console.WriteLine("Extracted Text:")
		Console.WriteLine(result.Text)
	End Sub
End Class
$vbLabelText   $csharpLabel

4.3.1 輸出

Azure OCR vs Google OCR (OCR功能比較):圖4 - IronOCR程式碼的控制台輸出

5. 比較評估

5.1 準確性和性能

  • Microsoft Azure OCR和Google OCR在文字提取方面提供高準確性,適用於廣泛的應用。
  • IronOCR在準確性上表現出色,特別是在涉及複雜佈局和噪音圖像的情況中。

5.2 易於整合

  • Microsoft Azure OCR和Google Cloud解決方案提供雲基OCR服務,易於與雲應用和服務整合。
  • IronOCR提供本地端OCR功能,與.NET應用實現無縫整合,提供直觀的APIs和豐富的文檔。

5.3 可擴展性

  • Microsoft Azure OCR和Google OCR無縫擴展以處理大量文字提取請求,適用於企業級應用。
  • IronOCR的可擴展性取決於應用的基礎設施,因為其在本地端運行。

6. 結論

在所有OCR工具中,Azure OCR、Google Vision API和IronOCR被認為是提供高準確性和性能的強大OCR解決方案。 雖然Azure OCR和Google OCR提供基於雲的OCR服務,具有可擴展的基礎設施和豐富的語言支持,但IronOCR以最準確的解決方案脫穎而出。

IronOCR特別適合需要本地端文字提取和卓越準確性的應用。 通過利用IronOCR,企業可以精簡文件處理流程,提高數據提取準確性,並從掃瞄文件和影像中獲得有價值的見解,使其成為首選。

要了解更多有關IronOCR和其服務,請訪問IronOCR文檔頁面來開啟影像處理的新篇章。

Kannaopat Udonpant
軟體工程師
在成為软件工程師之前,Kannapat 從日本北海道大學完成了環境資源博士學位。在追逐學位期间,Kannapat 還成為了生產工程系一部份——汽車机器人实验室的成員。2022 年,他利用他的 C# 技能加入 Iron Software 的工程團隊, 專注於 IronPDF。Kannapat 珍惜他的工作,因为他直接向编写大部分 IronPDF 使用的代码的开发者学习。除了同行学习,Kannapat 还喜欢在 Iron Software 工作的社交十环。当他不编写代码或文档时,Kannapat 通常在他的 PS5 上打游戏或重看《The Last of Us》。