フッターコンテンツにスキップ
OCRツール

Windows OCRエンジン対Tesseract:詳細な比較

今日のデジタル時代では、光学式文字認識 (OCR) 技術はさまざまな業界に不可欠なものとなり、画像やスキャンした文書を編集可能かつ検索可能なテキストに変換できるようになりました。

利用可能な数多くの OCR ソフトウェアの中で、Google Cloud Vision (Cloud Vision API)、Adobe Acrobat Pro DC、ABBYY Finereader、Windows OCR Engine、Tesseract、 IronOCRなどが有力候補として挙げられます。それぞれがドキュメント分析を支援する独自の機能を備えています。

この記事の目的は、これら 3 つの OCR エンジンの精度、パフォーマンス、統合の容易さを評価しながら、包括的な比較分析を提供することです。

1. OCRエンジンの紹介

OCR エンジンは、画像、PDF、その他のスキャンされたドキュメントからプレーンテキストを認識して抽出するように設計されたソフトウェア ツールです。 高度なアルゴリズムと機械学習技術を用いて文字を正確に識別し、機械が読み取り可能なテキストファイルに変換します。Windows OCR Engine、Tesseract、IronOCRは、それぞれに長所と用途があり、広く使用されている3つのOCRソリューションです。

2. Windows OCRエンジン

Windows オペレーティング システムに統合されたWindows OCR エンジンは、入力画像やスキャンしたドキュメントからテキストを抽出するための便利で使いやすいソリューションを提供します。 高度な画像処理技術を活用し、さまざまな言語やフォントスタイルのテキストを正確に認識できます。 Windows OCR エンジンは Windows ランタイム API を介してアクセス可能であり、コマンド ライン ツールの機能を使用して Windows アプリケーションにシームレスに統合できます。

2.1 Windows OCRエンジンの主な機能

-言語サポート: Windows OCR エンジンは多くの言語をサポートしているため、多言語ドキュメントに適しています。 -画像処理: 高度な画像処理アルゴリズムを採用し、低品質の画像でも印刷されたテキストの認識精度を向上させます。

  • Windows アプリケーションとの統合: Windows OCR エンジンは Windows アプリケーションとシームレスに統合されるため、開発者は OCR 機能をソフトウェアに完全に組み込むことができます。

2.2 コード例

using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Windows.Graphics.Imaging;
using Windows.Media.Ocr;

class Program
{
    static async Task Main(string[] args)
    {
        // Provide the path to the image file
        string imagePath = "sample.png";
        try
        {
            // Call the ExtractText method to extract text from the image
            string extractedText = await ExtractText(imagePath);
            // Display the extracted text
            Console.WriteLine("Extracted Text:");
            Console.WriteLine(extractedText);
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    }

    public static async Task<string> ExtractText(string image)
    {
        // Initialize StringBuilder to store extracted text
        StringBuilder text = new StringBuilder();
        try
        {
            // Open the image file stream
            using (var fileStream = File.OpenRead(image))
            {
                // Create a BitmapDecoder from the image file stream
                var bmpDecoder = await BitmapDecoder.CreateAsync(fileStream.AsRandomAccessStream());
                // Get the software bitmap from the decoder
                var softwareBmp = await bmpDecoder.GetSoftwareBitmapAsync();
                // Create an OCR engine from user profile languages
                var ocrEngine = OcrEngine.TryCreateFromUserProfileLanguages();
                // Recognize text from the software bitmap
                var ocrResult = await ocrEngine.RecognizeAsync(softwareBmp);
                // Append each line of recognized text to the StringBuilder
                foreach (var line in ocrResult.Lines)
                {
                    text.AppendLine(line.Text);
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error during OCR process: " + ex.Message);
        }
        // Return the extracted text
        return text.ToString();
    }
}
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Windows.Graphics.Imaging;
using Windows.Media.Ocr;

class Program
{
    static async Task Main(string[] args)
    {
        // Provide the path to the image file
        string imagePath = "sample.png";
        try
        {
            // Call the ExtractText method to extract text from the image
            string extractedText = await ExtractText(imagePath);
            // Display the extracted text
            Console.WriteLine("Extracted Text:");
            Console.WriteLine(extractedText);
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    }

    public static async Task<string> ExtractText(string image)
    {
        // Initialize StringBuilder to store extracted text
        StringBuilder text = new StringBuilder();
        try
        {
            // Open the image file stream
            using (var fileStream = File.OpenRead(image))
            {
                // Create a BitmapDecoder from the image file stream
                var bmpDecoder = await BitmapDecoder.CreateAsync(fileStream.AsRandomAccessStream());
                // Get the software bitmap from the decoder
                var softwareBmp = await bmpDecoder.GetSoftwareBitmapAsync();
                // Create an OCR engine from user profile languages
                var ocrEngine = OcrEngine.TryCreateFromUserProfileLanguages();
                // Recognize text from the software bitmap
                var ocrResult = await ocrEngine.RecognizeAsync(softwareBmp);
                // Append each line of recognized text to the StringBuilder
                foreach (var line in ocrResult.Lines)
                {
                    text.AppendLine(line.Text);
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error during OCR process: " + ex.Message);
        }
        // Return the extracted text
        return text.ToString();
    }
}
Imports System
Imports System.IO
Imports System.Text
Imports System.Threading.Tasks
Imports Windows.Graphics.Imaging
Imports Windows.Media.Ocr

Friend Class Program
	Shared Async Function Main(ByVal args() As String) As Task
		' Provide the path to the image file
		Dim imagePath As String = "sample.png"
		Try
			' Call the ExtractText method to extract text from the image
			Dim extractedText As String = Await ExtractText(imagePath)
			' Display the extracted text
			Console.WriteLine("Extracted Text:")
			Console.WriteLine(extractedText)
		Catch ex As Exception
			Console.WriteLine("An error occurred: " & ex.Message)
		End Try
	End Function

	Public Shared Async Function ExtractText(ByVal image As String) As Task(Of String)
		' Initialize StringBuilder to store extracted text
		Dim text As New StringBuilder()
		Try
			' Open the image file stream
			Using fileStream = File.OpenRead(image)
				' Create a BitmapDecoder from the image file stream
				Dim bmpDecoder = Await BitmapDecoder.CreateAsync(fileStream.AsRandomAccessStream())
				' Get the software bitmap from the decoder
				Dim softwareBmp = Await bmpDecoder.GetSoftwareBitmapAsync()
				' Create an OCR engine from user profile languages
				Dim ocrEngine = OcrEngine.TryCreateFromUserProfileLanguages()
				' Recognize text from the software bitmap
				Dim ocrResult = Await ocrEngine.RecognizeAsync(softwareBmp)
				' Append each line of recognized text to the StringBuilder
				For Each line In ocrResult.Lines
					text.AppendLine(line.Text)
				Next line
			End Using
		Catch ex As Exception
			Console.WriteLine("Error during OCR process: " & ex.Message)
		End Try
		' Return the extracted text
		Return text.ToString()
	End Function
End Class
$vbLabelText   $csharpLabel

2.2.1 出力

! Windows OCRエンジンとTesseract(OCR機能の比較): 図1 - Windows OCRエンジンコードのコンソール出力

3. Tesseract

Google が開発したオープンソースの OCR エンジンであるTesseract は、その精度と汎用性により幅広い人気を得ています。 100 以上の言語をサポートし、TIFF、JPEG、PNG などさまざまな画像形式を処理できます。 Tesseract OCR エンジンは、ディープラーニング アルゴリズムとニューラル ネットワークを採用して高いテキスト認識精度を実現し、幅広いアプリケーションに適しています。

3.1 Tesseractの主な特徴

-言語サポート: Tesseract エンジンは、アラビア語や中国語などの複雑な文字を含む 100 を超える言語をサポートしています。

  • 画像前処理:デスキュー、二値化、ノイズ削減を含む広範な画像前処理機能を提供し、テキスト認識精度を向上させます。 -カスタマイズ オプション: Tesseract を使用すると、ユーザーは OCR パラメータを微調整し、特定のユース ケースに合わせてカスタム モデルをトレーニングして、精度とパフォーマンスを向上させることができます。

3.2 コード例

using Patagames.Ocr;

class TesseractExample
{
    static void Main(string[] args)
    {
        // Create an OCR API instance
        using (var api = OcrApi.Create())
        {
            // Initialize the OCR engine for the English language
            api.Init(Patagames.Ocr.Enums.Languages.English);
            // Extract text from the image
            string plainText = api.GetTextFromImage(@"C:\Users\buttw\source\repos\ironqr\ironqr\bin\Debug\net5.0\Iron.png");
            // Display the extracted text
            Console.WriteLine(plainText);
        }
    }
}
using Patagames.Ocr;

class TesseractExample
{
    static void Main(string[] args)
    {
        // Create an OCR API instance
        using (var api = OcrApi.Create())
        {
            // Initialize the OCR engine for the English language
            api.Init(Patagames.Ocr.Enums.Languages.English);
            // Extract text from the image
            string plainText = api.GetTextFromImage(@"C:\Users\buttw\source\repos\ironqr\ironqr\bin\Debug\net5.0\Iron.png");
            // Display the extracted text
            Console.WriteLine(plainText);
        }
    }
}
Imports Patagames.Ocr

Friend Class TesseractExample
	Shared Sub Main(ByVal args() As String)
		' Create an OCR API instance
		Using api = OcrApi.Create()
			' Initialize the OCR engine for the English language
			api.Init(Patagames.Ocr.Enums.Languages.English)
			' Extract text from the image
			Dim plainText As String = api.GetTextFromImage("C:\Users\buttw\source\repos\ironqr\ironqr\bin\Debug\net5.0\Iron.png")
			' Display the extracted text
			Console.WriteLine(plainText)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

3.2.1 出力

! Windows OCRエンジンとTesseract(OCR機能の比較): 図2 - Tesseractコードのコンソール出力

4. IronOCR

Iron Software が開発した強力な OCR エンジンである IronOCR は、優れた精度、使いやすさ、多様な言語サポートが特徴です。 オンプレミスの OCR 機能を提供し、125 以上の言語をサポートしているため、グローバル アプリケーションに適しています。 IronOCR は、高度な機械学習アルゴリズムとクラウド ビジョン テクノロジーを活用して、困難なシナリオでも正確なテキスト認識結果を提供します。

4.1 IronOCRの主な機能

-高精度: IronOCR は、業界をリードするテキスト認識精度を実現し、さまざまなドキュメント タイプや言語で信頼性の高い結果を保証します。 -多様な言語サポート: 125 を超える言語をサポートし、シームレスな多言語テキスト認識のための包括的な言語パックを提供します。 -シンプルな統合: IronOCR は、直感的な API と広範なドキュメントを備え、.NET アプリケーションとの簡単な統合を実現し、元の画像の前処理と後処理を行ってテキストを抽出する開発プロセスを効率化します。

4.2 IronOCRをインストールする

コーディング例に進む前に、NuGet パッケージ マネージャーを使用して IronOCR をインストールする方法を見てみましょう。

  1. Visual Studio で [ツール] メニューに移動し、[NuGet パッケージ マネージャー] を選択します。
  2. 新しいリストが表示されるので、ここでソリューションの NuGet パッケージ マネージャーを選択します。

! Windows OCRエンジンとTesseract(OCR機能の比較): 図3 - Visual Studio NuGetパッケージマネージャーの場所

  1. 新しいウィンドウが表示されるので、'Browse'タブに移動し、検索バーに'IronOCR'とタイプします。
  2. パッケージのリストが表示されます。 最新の IronOCR パッケージを選択し、インストールをクリックします。

! Windows OCRエンジンとTesseract(OCR機能の比較): 図4 - IronOCRパッケージのインストール

4.3 コード例(C#)

using IronOcr;

class IronOCRExample
{
    static void Main(string[] args)
    {
        // Create an IronTesseract instance
        var ocr = new IronTesseract();
        // Set the language for OCR recognition
        ocr.Language = OcrLanguage.English;
        // Perform OCR on the specified image
        var result = ocr.Read(@"C:\Users\buttw\source\repos\ironqr\ironqr\bin\Debug\net5.0\Iron.png");
        // Display the extracted text
        Console.WriteLine(result.Text);
    }
}
using IronOcr;

class IronOCRExample
{
    static void Main(string[] args)
    {
        // Create an IronTesseract instance
        var ocr = new IronTesseract();
        // Set the language for OCR recognition
        ocr.Language = OcrLanguage.English;
        // Perform OCR on the specified image
        var result = ocr.Read(@"C:\Users\buttw\source\repos\ironqr\ironqr\bin\Debug\net5.0\Iron.png");
        // Display the extracted text
        Console.WriteLine(result.Text);
    }
}
Imports IronOcr

Friend Class IronOCRExample
	Shared Sub Main(ByVal args() As String)
		' Create an IronTesseract instance
		Dim ocr = New IronTesseract()
		' Set the language for OCR recognition
		ocr.Language = OcrLanguage.English
		' Perform OCR on the specified image
		Dim result = ocr.Read("C:\Users\buttw\source\repos\ironqr\ironqr\bin\Debug\net5.0\Iron.png")
		' Display the extracted text
		Console.WriteLine(result.Text)
	End Sub
End Class
$vbLabelText   $csharpLabel

4.3.1 出力

! Windows OCRエンジンとTesseract(OCR機能の比較): 図5 - IronOCRコードのコンソール出力

5. 比較評価

5.1 精度とパフォーマンス

  • Windows OCR エンジンTesseract は十分な精度を提供しますが、複雑なレイアウトでは苦労する可能性があります。
  • IronOCR : 精度に優れ、ノイズの多い画像を含むさまざまなドキュメントタイプや言語で信頼性の高い結果を提供します。

5.2 統合のしやすさ

  • Windows OCR エンジン: Windows アプリケーションとシームレスに統合されますが、カスタマイズ オプションがありません。
  • Tesseract : 統合には追加の構成と依存関係が必要ですが、広範なカスタマイズ オプションが用意されています。
  • IronOCR : 直感的な API と包括的なドキュメントを備え、.NET アプリケーションとの簡単な統合を提供します。

5.3 言語サポート

  • Windows OCR エンジンは、 Tesseract や IronOCR と比較して、サポートする言語の数が限られています。
  • Tesseract : 100 以上の言語をサポートします。
  • IronOCR : 125 以上の言語をサポートしており、グローバルなアプリケーションに適しています。

6. 結論

結論として、Windows OCRエンジンとTesseractはテキスト認識の一般的な選択肢ですが、 IronOCRは最も正確で汎用性の高いOCRエンジンとして浮上しました。業界をリードする精度、幅広い言語サポート、そしてシンプルな統合により、信頼性の高いOCR機能を求める企業や開発者にとって、IronOCRは傑出したソリューションとなっています。 IronOCR を活用することで、組織はドキュメント処理ワークフローを合理化し、データ抽出の精度を高め、スキャンされたドキュメントや画像から貴重な洞察を引き出すことができます。

IronOCR は無料トライアルを提供しています。 IronOCR とその機能の詳細については、こちらをご覧ください。

Kannaopat Udonpant
ソフトウェアエンジニア
ソフトウェアエンジニアになる前に、Kannapatは北海道大学で環境資源の博士号を修了しました。博士号を追求する間に、彼はバイオプロダクションエンジニアリング学科の一部である車両ロボティクスラボラトリーのメンバーになりました。2022年には、C#のスキルを活用してIron Softwareのエンジニアリングチームに参加し、IronPDFに注力しています。Kannapatは、IronPDFの多くのコードを執筆している開発者から直接学んでいるため、この仕事を大切にしています。同僚から学びながら、Iron Softwareでの働く社会的側面も楽しんでいます。コードやドキュメントを書いていない時は、KannapatはPS5でゲームをしたり、『The Last of Us』を再視聴したりしていることが多いです。