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

請求書OCR機械学習(ステップバイステップチュートリアル)

今日の急速に変化するビジネス環境では、タスクや非構造化データの自動化が効率を高め、手作業によるエラーを減らすための重要な戦略となっています。 そのようなタスクの1つが、請求書や購入注文書からの情報抽出です。これは伝統的には多大な手作業を必要とするプロセスでした。 しかし、機械学習、深層学習モデル、光学文字認識(OCR)ソフトウェア技術の進歩のおかげで、企業はIronOCRなどのツールを使用してこの請求書情報抽出プロセスを簡素化できます。 この記事では、機械学習とIronOCRを活用して請求書処理の方法を変革する方法を探ります。

請求書OCRツールの理解

OCR技術は以前から存在していますが、請求書処理とデータ抽出への応用は、機械学習の登場で大きな進展を遂げました。 OCRは、光学文字認識の略で、請求書情報を含むスキャン済みの紙文書、PDFファイル、財務文書、またはデジタルカメラで撮影した画像を編集可能かつ検索可能なデータに変換する技術です。 これは基本的に画像からのテキストを画像プリプロセッシングを使用して機械可読テキストに変換します。

IronOCRは、機械学習アルゴリズムの上に構築された強力なOCRライブラリで、さまざまなアプリケーションやプログラミング言語に統合できるため、請求書処理の柔軟なツールとなります。 IronOCRを使用することで、企業は請求書番号、日付、ベンダーの詳細、ラインアイテムなどの請求書データの抽出を自動化し、卓越した精度を実現できます。

請求書OCRでのIronOCRの使用の利点

請求書処理におけるIronOCRの使用は、組織の財務運営、特に買掛金において効率と精度を大幅に向上させる多くの利点をもたらします。 これらの利点を詳しく見てみましょう。

1. 精度とエラー削減

IronOCRは高度な機械学習アルゴリズムを使用して、請求書から正確にテキストを認識し抽出します。 これにより、データ入力中の人的エラーの可能性が最小限に抑えられ、重要な財務情報が正しく記録されます。

2. 時間とコストの節約

IronOCRを使用した請求書処理の自動化により、手動データ入力に必要な時間とリソースが大幅に削減されます。 これにより、スタッフの時間を最適化し、手作業の必要性を減らすことで、かなりのコスト削減が可能です。

3. 改善された効率性

IronOCRは、大量の請求書を迅速かつ効率的に処理できます。 各請求書から手動でデータを入力する必要がなくなり、従業員はより戦略的なタスクに集中できます。

4. スケーラビリティ

IronOCRはスケーラブルで、ビジネスが拡大するにつれて増える請求書の量を処理できます。 請求書文書処理システムのワークロードの増加や境界ボックスによる圧倒を心配する必要はありません。

5. グローバルリーチ

IronOCRは125以上の言語をサポートしているため、世界中のベンダーやクライアントからの請求書を処理できます。 請求書がどの言語で書かれていても、IronOCRはデータを正確に抽出できます。

6. マルチフォーマットサポート

IronOCRは、スキャン画像、画像ベースのPDF、テキストベースのPDFを含むさまざまな形式の請求書を処理できます。 この柔軟性により、異なるソースやフォーマットの請求書を簡単に処理できます。

7. カスタマイズとデータ抽出

IronOCRをカスタマイズして、請求書番号、日付、ベンダー情報、項目情報など、請求書から特定のデータフィールドを抽出できます。 このレベルのカスタマイズにより、特定のビジネスニーズに合わせてソリューションを調整できます。

8. コンプライアンスと監査証跡

IronOCRを使用した請求書処理の自動化は、正確な記録の維持と監査証跡の提供を支援します。 これは、財務規制のコンプライアンスと監査プロセスの簡素化にとって重要です。

9. 請求書処理サイクルの短縮

IronOCRの効率化と自動化により、請求書処理にかかる時間が短縮され、それにより請求書処理サイクルが短縮されます。 これにより、ベンダーへの支払いが速くなり、関係が改善される可能性があります。

10. データ分析の向上

構造化されたデジタル形式の請求書データを持つことで、より詳細なデータ分析を行うことができます。 これにより、トレンドの特定、支出の最適化、情報に基づいた財務決定を行うことができます。

請求書処理のためのIronOCRの実装

請求書処理のためにIronOCRを実装するには、以下の一般的な手順に従います。

ステップ 1: 新しいC#を作成する

まず、新しいC#プロジェクトを作成するか、お好みの開発環境(例: Visual Studio または Visual Studio Code)で既存のプロジェクトを開きます。 このデモンストレーションでは、Visual Studio 2022 IDEとコンソールアプリケーションを使用しています。 ASP.NET Web APIs, ASP.NET MVC, ASP.NET Web Forms, または .NET Framework のプロジェクトタイプで同じ実装を使用できます。

請求書OCR機械学習(ステップバイステップチュートリアル):図1 - C#プロジェクト

ステップ 2: NuGetパッケージマネージャーを使用してIronOCRをインストールする

プロジェクトでIronOCRを使用するには、IronOCR NuGetパッケージをインストールする必要があります。 次のように操作を行います。

  1. NuGetパッケージマネージャーコンソールを開きます。 Visual Studioでは、"ツール" > "NuGetパッケージマネージャー" > "パッケージマネージャーコンソール" で見つけることができます。

請求書OCR機械学習(ステップバイステップチュートリアル):図2 - パッケージマネージャーコンソール

  1. 以下のコマンドを実行してIronOCRパッケージをインストールします。

    Install-Package IronOcr

    請求書OCR機械学習(ステップバイステップチュートリアル):図3 - IronOCRのインストール

  2. パッケージのインストールを待ちます。 完了したら、プロジェクトでIronOCRを使用し始めることができます。

ステップ 3: C#でOCRを実装する

それでは、C#コードを書いてIronOCRを使用して請求書に対してOCRを実行しましょう。 この例のために以下のサンプル請求書を使用します。

請求書OCR機械学習(ステップバイステップチュートリアル):図4 - サンプル請求書テンプレート

以下のサンプルコードは、請求書画像を入力として受け取り、請求書番号、購入注文などのデータを請求書から抽出します。

// Define the path to the invoice image
string invoicePath = @"D:\Invoices\SampleInvoice.png";

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Add the invoice image to the OCR input
    input.AddImage(invoicePath);

    // Perform OCR on the input image and store result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from the image to the console
    Console.WriteLine(result.Text);
}
// Define the path to the invoice image
string invoicePath = @"D:\Invoices\SampleInvoice.png";

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Add the invoice image to the OCR input
    input.AddImage(invoicePath);

    // Perform OCR on the input image and store result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from the image to the console
    Console.WriteLine(result.Text);
}
' Define the path to the invoice image
Dim invoicePath As String = "D:\Invoices\SampleInvoice.png"

' Create an instance of IronTesseract for OCR processing
Dim ocr As New IronTesseract()

' Use 'using' to ensure proper disposal of OcrInput resources
Using input As New OcrInput()
	' Add the invoice image to the OCR input
	input.AddImage(invoicePath)

	' Perform OCR on the input image and store result
	Dim result As OcrResult = ocr.Read(input)

	' Output the extracted text from the image to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

上記のコードは、単一の請求書画像 (SampleInvoice.png) に対してIronOCRを使用してOCRを実行し、抽出された請求書データをコンソールに出力する簡潔なC#の例です。 invoicePath変数を特定の請求書画像ファイルのパスに置き換えることを忘れないでください。

請求書OCR機械学習(ステップバイステップチュートリアル):図5 - 請求書OCR出力

複数の請求書を一度に入力してデータを抽出しましょう。 以下は、入力として使用している請求書ディレクトリです。

請求書OCR機械学習(ステップバイステップチュートリアル):図6 - 請求書ディレクトリ

以下のサンプルコードは、一度に複数の請求書からテキストを抽出します。

// Get all PNG files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.png");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddImage(file);
    }

    // Perform OCR on all the added images and store the result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from all images to the console
    Console.WriteLine(result.Text);
}
// Get all PNG files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.png");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddImage(file);
    }

    // Perform OCR on all the added images and store the result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from all images to the console
    Console.WriteLine(result.Text);
}
' Get all PNG files from the specified directory
Dim fileArray() As String = Directory.GetFiles("D:\Invoices\", "*.png")

' Create an instance of IronTesseract for OCR processing
Dim ocr As New IronTesseract()

' Use 'using' to ensure proper disposal of OcrInput resources
Using input As New OcrInput()
	' Loop through each file and add it to the OCR input
	For Each file As String In fileArray
		input.AddImage(file)
	Next file

	' Perform OCR on all the added images and store the result
	Dim result As OcrResult = ocr.Read(input)

	' Output the extracted text from all images to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

上記のコードは、フォルダー内のすべてのPNG画像を取得し、データを抽出し、フォルダー内のすべての請求書の抽出されたデータをコンソールに出力します。

請求書OCR機械学習(ステップバイステップチュートリアル):図7 - 抽出データ

抽出したデータを検索可能なPDF請求書として保存する

以下のコードは、フォルダーからすべての画像を読み込み、データを抽出して、1つの検索可能なPDF請求書として保存します。

// Get all PNG files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.png");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddImage(file);
    }

    // Perform OCR on all the added images and store the result
    OcrResult result = ocr.Read(input);

    // Save the result as a searchable PDF
    result.SaveAsSearchablePdf(@"D:\Invoices\Searchable.pdf");
}
// Get all PNG files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.png");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddImage(file);
    }

    // Perform OCR on all the added images and store the result
    OcrResult result = ocr.Read(input);

    // Save the result as a searchable PDF
    result.SaveAsSearchablePdf(@"D:\Invoices\Searchable.pdf");
}
' Get all PNG files from the specified directory
Dim fileArray() As String = Directory.GetFiles("D:\Invoices\", "*.png")

' Create an instance of IronTesseract for OCR processing
Dim ocr As New IronTesseract()

' Use 'using' to ensure proper disposal of OcrInput resources
Using input As New OcrInput()
	' Loop through each file and add it to the OCR input
	For Each file As String In fileArray
		input.AddImage(file)
	Next file

	' Perform OCR on all the added images and store the result
	Dim result As OcrResult = ocr.Read(input)

	' Save the result as a searchable PDF
	result.SaveAsSearchablePdf("D:\Invoices\Searchable.pdf")
End Using
$vbLabelText   $csharpLabel

ほぼすべての例でコードは類似しています。 異なるユースケースを示すためにわずかに変更を加えています。 出力PDFは以下の通りです。

請求書OCR機械学習(ステップバイステップチュートリアル):図8 - PDF出力

このように、IronPDFは請求書処理や文書処理を自動化する最も簡単な方法を提供します。

PDF請求書から請求書データを抽出する

IronOCRを使用してPDF請求書からデータを抽出するには、前のコード例と同様のアプローチをとることができます。 IronOCRは、画像ベースとテキストベースの両方のPDFに対応しています。 PDF請求書からデータを抽出する簡単な例を以下に示します。

// Get all PDF files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.pdf");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddPdf(file);
    }

    // Perform OCR on all the added PDFs and store the result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from all PDFs to the console
    Console.WriteLine(result.Text);
}
// Get all PDF files from the specified directory
string[] fileArray = Directory.GetFiles(@"D:\Invoices\", "*.pdf");

// Create an instance of IronTesseract for OCR processing
IronTesseract ocr = new IronTesseract();

// Use 'using' to ensure proper disposal of OcrInput resources
using (OcrInput input = new OcrInput())
{
    // Loop through each file and add it to the OCR input
    foreach (string file in fileArray)
    {
        input.AddPdf(file);
    }

    // Perform OCR on all the added PDFs and store the result
    OcrResult result = ocr.Read(input);

    // Output the extracted text from all PDFs to the console
    Console.WriteLine(result.Text);
}
' Get all PDF files from the specified directory
Dim fileArray() As String = Directory.GetFiles("D:\Invoices\", "*.pdf")

' Create an instance of IronTesseract for OCR processing
Dim ocr As New IronTesseract()

' Use 'using' to ensure proper disposal of OcrInput resources
Using input As New OcrInput()
	' Loop through each file and add it to the OCR input
	For Each file As String In fileArray
		input.AddPdf(file)
	Next file

	' Perform OCR on all the added PDFs and store the result
	Dim result As OcrResult = ocr.Read(input)

	' Output the extracted text from all PDFs to the console
	Console.WriteLine(result.Text)
End Using
$vbLabelText   $csharpLabel

上記のコードは、ディレクトリ(@"D:\Invoices\")内の複数のPDF請求書をIronOCRを使用して効率的に一括処理します。 ファイルパスを取得し、各PDFをOCR処理のために追加し、抽出されたテキストを結合し、結果をコンソールに出力します。 このアプローチは、多数の請求書を処理する組織において、効率を高め、手作業を削減するための請求書データ抽出を容易にします。

請求書OCR機械学習(ステップバイステップチュートリアル):図9 - 抽出出力

結論

要約すると、機械学習と高度なOCR技術であるIronOCRの融合が、請求書の取り扱い方法を変革しています。 この記事では、IronOCRを使用するプロセスを紹介し、その驚くべき利点を示しました。 IronOCRを採用することで、企業は精度を高め、時間とコストを節約し、さまざまな形式や言語の請求書を簡単に処理できます。 手作業によるデータ入力の排除は、効率を向上させるだけでなく、財務取引での高額なエラーの可能性も減少させます。 IronOCRは、請求書処理ワークフローを単純化し改善するため、競争の激しい今日の環境で財務運営を向上させたいと考える企業にとって賢明な選択肢です。 さらに、IronOCRは125以上の言語をサポートし、カスタマイズ可能なデータ抽出、画像ベースおよびテキストベースのPDFとの互換性などの強力な機能を提供します。

While IronOCR's feature set is impressive, it's also noteworthy that IronOCR's pricing model is designed to accommodate a wide range of business needs, offering flexible options with a free trial for both small enterprises and larger corporations. 少数の請求書を処理する場合でも、多数の財務文書を管理する場合でも、IronOCRは信頼性が高く費用対効果の高いソリューションとして評価されます。

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