跳至页脚内容
OCR 工具

Azure OCR 与 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 与 Google OCR(OCR 功能对比):图 1 - Azure OCR 代码的控制台输出

3. Google OCR

作为 Google Cloud 服务提供商的一部分, Google OCR提供了一个强大的文本识别和文档分析平台。 它利用谷歌先进的机器学习算法,提供精确的文本提取功能,并通过云计算提供图像标注和目标检测等附加功能。 Google 云平台 OCR 被广泛应用于各个行业,用于发票处理、表单识别和内容数字化等任务。

3.1 Google OCR 的主要功能

-多语言支持: Google OCR 支持 200 多种语言,可以识别多种文字,包括拉丁文、西里尔文和汉字。 -图像分析:它提供高级图像分析功能,例如标签检测、人脸检测和地标识别。 -与 Google Cloud 服务集成: Google OCR 与其他 Google Cloud 视觉 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 与 Google OCR(OCR 功能对比):图 2 - Google OCR 代码的控制台输出

4. 铁氧体

IronOCR由 Iron Software 开发,是一款功能全面的 .NET 应用程序 OCR 库,提供业界领先的 OCR 准确性和性能。 与基于云的 OCR 服务不同,IronOCR 提供本地文本提取功能,使其适用于需要数据隐私和安全的应用。 IronOCR 在准确性方面表现出色,尤其是在复杂布局和噪声图像的情况下,因此成为寻求可靠 OCR 功能的企业的首选。

4.1 IronOCR 的主要特点

-高精度: IronOCR 在文本识别方面具有卓越的精度,可确保在各种文档类型和语言中获得可靠的结果。 -本地 OCR:它提供本地文本提取功能,使企业能够在本地处理敏感文档,而无需依赖外部服务。 -多功能语言支持: IronOCR 支持超过 125 种语言,并提供全面的语言包,实现无缝的多语言文本识别。

4.2 安装 IronOCR

可以使用 NuGet 包管理器控制台安装 IronOCR。 只需运行以下命令。

  1. 打开 Visual Studio 并创建一个新项目或打开一个现有项目。
  2. 在工具栏中,转到"工具"并选择"NuGet 包管理器"。

Azure OCR 与 Google OCR(OCR 功能对比):图 3 - Visual Studio NuGet 包管理器位置

  1. 现在从新出现的列表中选择"程序包管理器控制台"。
  2. 现在将出现控制台,运行以下命令,然后按回车键。
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 与 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 应用程序无缝集成,具有直观的 API 和丰富的文档。

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 上玩游戏或重温《最后生还者》。