C#でIronBarcodeを使用して読み取り速度を調整する方法
IronBarcodeは、バーコードをC#で読み取る際の処理速度と精度のバランスを制御するための4つの読み取り速度オプション(Faster、Balanced、Detailed、ExtremeDetail)を提供しており、ほとんどのアプリケーションではBalancedを起点とすることをお勧めします。
はじめに
大量のバーコードを読み取る際には正確さが不可欠ですが、リソースの割り当てと処理効率も同様に重要な考慮事項です。 入力画像の品質がバーコードリーダーがどのようにそれらを処理するべきかを決定します。明瞭な画像の場合は前処理をスキップするか、劣化したバーコードに対して精度を改善するためによりリソース集約的なオプションを使うかです。
IronBarcodeは処理速度と精度レベルを柔軟に選択できるため、バーコード読み取りプロセスのあらゆる側面を制御することができます。 入力イメージと利用可能なリソースに基づいて決定することができます。 より高度なバーコード読取シナリオについては、包括的なバーコード読取チュートリアルをご覧ください。さまざまな形式と手法をカバーしています。
この記事では、さまざまなシナリオに最適な読み取り速度を選択するためのガイドラインを提供します。 QRコードのサンプルを使用し、読み取り速度の変更が結果にどのように影響するかを実演します。 特にQRコードを扱っている場合は、テストサンプルを作成するためのC# QRコード生成チュートリアルをご確認ください。
クイックスタート:バランスの取れた速度でバーコードを読み取るIronBarcode の BarcodeReaderOptions を使用して、スキャンの Speed レベルを即座に設定します。 この例は、Balanced設定を使用して素早くバーコードを読み取る方法を示しています。迅速で信頼性のある結果を得ることができます。
-
1IronBarcode を NuGet Package Manager でインストールします
-
2このコード スニペットをコピーして実行します。
var results = IronBarCode.BarcodeReader.Read("path/to/image.png", new IronBarCode.BarcodeReaderOptions { Speed = IronBarCode.ReadingSpeed.Balanced });Dim results = IronBarCode.BarcodeReader.Read("path/to/image.png", New IronBarCode.BarcodeReaderOptions With {.Speed = IronBarCode.ReadingSpeed.Balanced})Dim results = IronBarCode.BarcodeReader.Read("path/to/image.png", New IronBarCode.BarcodeReaderOptions With {.Speed = IronBarCode.ReadingSpeed.Balanced}) -
3実際の環境でテストするためにデプロイする
今日からご自身のプロジェクトでIronBarcodeを使い始めるには、無料トライアルをお試しください。
最小限のワークフロー(5ステップ)
- 読取速度を調整するためのC#ライブラリをダウンロード
- BarcodeReaderOptionsクラスを利用して読み取り速度を設定します
Readメソッドを使用して、さまざまな画像形式からバーコード値を抽出します。- バーコードの値を出力する
- 異なる読み取り速度間のパフォーマンスのトレードオフを評価する
異なる読み取り速度のオプションとは何ですか?
IronBarcodeは、4つのReadingSpeedオプションを提供しています:Faster、Balanced、Detailed、ExtremeDetail。 それぞれのオプションの意図された使用事例を検討し、独自の画像に対する速度と精度を測定する方法を確認します。 サポートされている形式の完全なリストについては、サポートされているバーコード形式ページをご覧ください。
処理時間、精度、メモリ使用量はデータセット、ハードウェア、画像品質に大きく依存するため、このガイドでは固定のベンチマーク値を示していません。以下では各オプションのトレードオフと適した用途を説明します。.NETのベンチマークライブラリと、正常に読み取れたバーコードを数える簡単な方法を使い、実際に使用する画像の代表的なサンプルで各オプションを測定してください。読み取りオプションの設定については、バーコードリーダーの設定例をご覧ください。
Fasterオプションを使用すべき場合
Fasterオプションは、資源を最小限に抑えながら最速でバーコードを読み取りますが、精度が低下します。 このプロセスは画像の前処理を省略するため、入力画像がすでにシャープで鮮明な場合に最適です。
SpeedプロパティをReadingSpeed.Fasterに設定し、バーコードのディレクトリをインポートし、見つかったバーコードをその値、タイプ、画像ごとの数と共に出力します。 さまざまな画像形式からバーコードを読み取る方法を理解するためには、画像からのバーコードの読み取りガイドをご確認ください。
using IronBarCode;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
var optionsFaster = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Faster
};
// Directory containing PDF files
string folderPath = @"YOUR_FILE_PATH";
// Get all PDF files in the directory
var pdfFiles = Directory.GetFiles(folderPath, "*.jpg");
int countFaster = 0;
var stopwatch = Stopwatch.StartNew();
foreach (var file in pdfFiles)
{
// Read the barcode
var results = BarcodeReader.Read(file, optionsFaster);
if (results.Any())
{
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}");
foreach (var result in results)
{
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}");
countFaster++;
}
}
else
{
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}");
}
}
stopwatch.Stop();
// Print number of images the barcode reader could decode
Console.WriteLine($"Faster could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms");using IronBarCode;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
var optionsFaster = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Faster
};
// Directory containing PDF files
string folderPath = @"YOUR_FILE_PATH";
// Get all PDF files in the directory
var pdfFiles = Directory.GetFiles(folderPath, "*.jpg");
int countFaster = 0;
var stopwatch = Stopwatch.StartNew();
foreach (var file in pdfFiles)
{
// Read the barcode
var results = BarcodeReader.Read(file, optionsFaster);
if (results.Any())
{
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}");
foreach (var result in results)
{
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}");
countFaster++;
}
}
else
{
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}");
}
}
stopwatch.Stop();
// Print number of images the barcode reader could decode
Console.WriteLine($"Faster could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms");Imports IronBarCode
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Linq
Dim optionsFaster As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Faster
}
' Directory containing PDF files
Dim folderPath As String = "YOUR_FILE_PATH"
' Get all PDF files in the directory
Dim pdfFiles = Directory.GetFiles(folderPath, "*.jpg")
Dim countFaster As Integer = 0
Dim stopwatch As Stopwatch = Stopwatch.StartNew()
For Each file In pdfFiles
' Read the barcode
Dim results = BarcodeReader.Read(file, optionsFaster)
If results.Any() Then
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}")
For Each result In results
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}")
countFaster += 1
Next
Else
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}")
End If
Next
stopwatch.Stop()
' Print number of images the barcode reader could decode
Console.WriteLine($"Faster could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms")Imports IronBarCode
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Linq
Dim optionsFaster As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Faster
}
' Directory containing PDF files
Dim folderPath As String = "YOUR_FILE_PATH"
' Get all PDF files in the directory
Dim pdfFiles = Directory.GetFiles(folderPath, "*.jpg")
Dim countFaster As Integer = 0
Dim stopwatch As Stopwatch = Stopwatch.StartNew()
For Each file In pdfFiles
' Read the barcode
Dim results = BarcodeReader.Read(file, optionsFaster)
If results.Any() Then
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}")
For Each result In results
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}")
countFaster += 1
Next
Else
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}")
End If
Next
stopwatch.Stop()
' Print number of images the barcode reader could decode
Console.WriteLine($"Faster could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms")Fasterオプションは事前処理を完全にスキップするため、4つの設定の中で最も高速で低オーバーヘッドですが、他のオプションに比べて劣化した低品質のバーコードをより高い割合で見逃します。画像が非常に鮮明な場合にのみ適しています。 単一の画像に複数のバーコードがある場合は、複数のバーコード読み取りガイドをご覧いただき、最適な構成方法を確認してください。
Balancedが推奨される理由
Balancedオプションは精度と読み取り性能のバランスを取ります。 IronBarcodeは、バーコード領域を明確にするために軽い画像処理を適用し、検出と読み取りを容易にします。 最近の画像では、軽い処理で正確な結果が得られることが多いため、この設定を推奨します。
同じ画像を使用して、Balancedが出力結果にどのように影響するかを示しましょう。 非同期操作については、IronBarcode非同期とマルチスレッド処理ガイドをご覧ください。
using IronBarCode;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
var optionsFaster = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced
};
// Directory containing PDF files
string folderPath = @"YOUR_FILE_PATH";
// Get all PDF files in the directory
var pdfFiles = Directory.GetFiles(folderPath, "*.jpg");
int countFaster = 0;
var stopwatch = Stopwatch.StartNew();
foreach (var file in pdfFiles)
{
// Read the barcode
var results = BarcodeReader.Read(file, optionsFaster);
if (results.Any())
{
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}");
foreach (var result in results)
{
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}");
countFaster++;
}
}
else
{
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}");
}
}
stopwatch.Stop();
// Print number of images the barcode reader could decode
Console.WriteLine($"Balanced could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms");using IronBarCode;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
var optionsFaster = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced
};
// Directory containing PDF files
string folderPath = @"YOUR_FILE_PATH";
// Get all PDF files in the directory
var pdfFiles = Directory.GetFiles(folderPath, "*.jpg");
int countFaster = 0;
var stopwatch = Stopwatch.StartNew();
foreach (var file in pdfFiles)
{
// Read the barcode
var results = BarcodeReader.Read(file, optionsFaster);
if (results.Any())
{
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}");
foreach (var result in results)
{
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}");
countFaster++;
}
}
else
{
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}");
}
}
stopwatch.Stop();
// Print number of images the barcode reader could decode
Console.WriteLine($"Balanced could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms");Imports IronBarCode
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Linq
Dim optionsFaster As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced
}
' Directory containing PDF files
Dim folderPath As String = "YOUR_FILE_PATH"
' Get all PDF files in the directory
Dim pdfFiles = Directory.GetFiles(folderPath, "*.jpg")
Dim countFaster As Integer = 0
Dim stopwatch As Stopwatch = Stopwatch.StartNew()
For Each file In pdfFiles
' Read the barcode
Dim results = BarcodeReader.Read(file, optionsFaster)
If results.Any() Then
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}")
For Each result In results
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}")
countFaster += 1
Next
Else
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}")
End If
Next
stopwatch.Stop()
' Print number of images the barcode reader could decode
Console.WriteLine($"Balanced could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms")Imports IronBarCode
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Linq
Dim optionsFaster As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced
}
' Directory containing PDF files
Dim folderPath As String = "YOUR_FILE_PATH"
' Get all PDF files in the directory
Dim pdfFiles = Directory.GetFiles(folderPath, "*.jpg")
Dim countFaster As Integer = 0
Dim stopwatch As Stopwatch = Stopwatch.StartNew()
For Each file In pdfFiles
' Read the barcode
Dim results = BarcodeReader.Read(file, optionsFaster)
If results.Any() Then
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}")
For Each result In results
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}")
countFaster += 1
Next
Else
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}")
End If
Next
stopwatch.Stop()
' Print number of images the barcode reader could decode
Console.WriteLine($"Balanced could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms")Balancedオプションは軽い事前処理を適用し、処理時間の増加は控えめである一方で、Fasterよりも劣化した画像で検出率を大幅に向上させます。このオプションはメモリと速度の効率的なバランスを維持しており、多くの状況に理想的であり、推奨される開始点です。 このバランスの取れたアプローチは、適切な画像前処理技術によって特に効果的に機能します。
Detailedオプションが必要な場合
画像が非常にぼやけているか歪んでいて、Balanced が明確な結果を出せないときは、Detailed オプションを使用します。 バーコード領域を明確にし、デジタルノイズを減らして検出を向上させるために、中程度の前処理を適用します。 ひどく劣化した画像については、様々な前処理技術をカバーした画像補正ガイドをご覧ください。
Detailed設定を適用し、出力に及ぼす効果を観察してみましょう。
using IronBarCode;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
var optionsFaster = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Detailed
};
// Directory containing PDF files
string folderPath = @"YOUR_FILE_PATH";
// Get all PDF files in the directory
var pdfFiles = Directory.GetFiles(folderPath, "*.jpg");
int countFaster = 0;
var stopwatch = Stopwatch.StartNew();
foreach (var file in pdfFiles)
{
// Read the barcode
var results = BarcodeReader.Read(file, optionsFaster);
if (results.Any())
{
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}");
foreach (var result in results)
{
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}");
countFaster++;
}
}
else
{
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}");
}
}
stopwatch.Stop();
// Print number of images the barcode reader could decode
Console.WriteLine($"Detailed could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms");using IronBarCode;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
var optionsFaster = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Detailed
};
// Directory containing PDF files
string folderPath = @"YOUR_FILE_PATH";
// Get all PDF files in the directory
var pdfFiles = Directory.GetFiles(folderPath, "*.jpg");
int countFaster = 0;
var stopwatch = Stopwatch.StartNew();
foreach (var file in pdfFiles)
{
// Read the barcode
var results = BarcodeReader.Read(file, optionsFaster);
if (results.Any())
{
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}");
foreach (var result in results)
{
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}");
countFaster++;
}
}
else
{
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}");
}
}
stopwatch.Stop();
// Print number of images the barcode reader could decode
Console.WriteLine($"Detailed could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms");Imports IronBarCode
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Linq
Dim optionsFaster As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Detailed
}
' Directory containing PDF files
Dim folderPath As String = "YOUR_FILE_PATH"
' Get all PDF files in the directory
Dim pdfFiles = Directory.GetFiles(folderPath, "*.jpg")
Dim countFaster As Integer = 0
Dim stopwatch As Stopwatch = Stopwatch.StartNew()
For Each file In pdfFiles
' Read the barcode
Dim results = BarcodeReader.Read(file, optionsFaster)
If results.Any() Then
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}")
For Each result In results
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}")
countFaster += 1
Next
Else
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}")
End If
Next
stopwatch.Stop()
' Print number of images the barcode reader could decode
Console.WriteLine($"Detailed could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms")Imports IronBarCode
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Linq
Dim optionsFaster As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Detailed
}
' Directory containing PDF files
Dim folderPath As String = "YOUR_FILE_PATH"
' Get all PDF files in the directory
Dim pdfFiles = Directory.GetFiles(folderPath, "*.jpg")
Dim countFaster As Integer = 0
Dim stopwatch As Stopwatch = Stopwatch.StartNew()
For Each file In pdfFiles
' Read the barcode
Dim results = BarcodeReader.Read(file, optionsFaster)
If results.Any() Then
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}")
For Each result In results
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}")
countFaster += 1
Next
Else
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}")
End If
Next
stopwatch.Stop()
' Print number of images the barcode reader could decode
Console.WriteLine($"Detailed could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms")Detailed オプションの中度の前処理は Balanced に比べてかなりの処理時間を要し、必ずしもすべてのデータセットで検出をさらに改善するわけではありません - 利用する前に Balanced に対してご自身の画像でテストしてください。 追加のコストのため、このオプションは特に劣化したバーコード画像にのみ使用するべきです。 不完全なバーコードを扱う場合は、追加の戦略のために不完全なバーコード処理例をご確認ください。
ExtremeDetailが必要な場合
ExtremeDetail設定はバーコード画像に対して重い処理を適用し、読取パフォーマンスを著しく低下させます。 このCPU負荷の高いオプションは、1つの入力ファイル内で複数の不鮮明なバーコードやぼやけたバーコードをスキャンする場合に最適です。他のオプションで望ましい結果が得られない場合の最後の手段として使用してください。 大容量処理シナリオについては、1ページに複数のバーコードが含まれることが多いPDFファイルからのバーコード読み取りをご覧ください。
ExtremeDetail設定を適用し、その影響を観察してみましょう。
using IronBarCode;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
var optionsFaster = new BarcodeReaderOptions
{
Speed = ReadingSpeed.ExtremeDetail
};
// Directory containing PDF files
string folderPath = @"YOUR_FILE_PATH";
// Get all PDF files in the directory
var pdfFiles = Directory.GetFiles(folderPath, "*.jpg");
int countFaster = 0;
var stopwatch = Stopwatch.StartNew();
foreach (var file in pdfFiles)
{
// Read the barcode
var results = BarcodeReader.Read(file, optionsFaster);
if (results.Any())
{
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}");
foreach (var result in results)
{
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}");
countFaster++;
}
}
else
{
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}");
}
}
stopwatch.Stop();
// Print number of images the barcode reader could decode
Console.WriteLine($"ExtremeDetail could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms");using IronBarCode;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
var optionsFaster = new BarcodeReaderOptions
{
Speed = ReadingSpeed.ExtremeDetail
};
// Directory containing PDF files
string folderPath = @"YOUR_FILE_PATH";
// Get all PDF files in the directory
var pdfFiles = Directory.GetFiles(folderPath, "*.jpg");
int countFaster = 0;
var stopwatch = Stopwatch.StartNew();
foreach (var file in pdfFiles)
{
// Read the barcode
var results = BarcodeReader.Read(file, optionsFaster);
if (results.Any())
{
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}");
foreach (var result in results)
{
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}");
countFaster++;
}
}
else
{
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}");
}
}
stopwatch.Stop();
// Print number of images the barcode reader could decode
Console.WriteLine($"ExtremeDetail could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms");Imports IronBarCode
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Linq
Dim optionsFaster As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.ExtremeDetail
}
' Directory containing PDF files
Dim folderPath As String = "YOUR_FILE_PATH"
' Get all PDF files in the directory
Dim pdfFiles = Directory.GetFiles(folderPath, "*.jpg")
Dim countFaster As Integer = 0
Dim stopwatch As Stopwatch = Stopwatch.StartNew()
For Each file In pdfFiles
' Read the barcode
Dim results = BarcodeReader.Read(file, optionsFaster)
If results.Any() Then
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}")
For Each result In results
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}")
countFaster += 1
Next
Else
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}")
End If
Next
stopwatch.Stop()
' Print number of images the barcode reader could decode
Console.WriteLine($"ExtremeDetail could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms")Imports IronBarCode
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Linq
Dim optionsFaster As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.ExtremeDetail
}
' Directory containing PDF files
Dim folderPath As String = "YOUR_FILE_PATH"
' Get all PDF files in the directory
Dim pdfFiles = Directory.GetFiles(folderPath, "*.jpg")
Dim countFaster As Integer = 0
Dim stopwatch As Stopwatch = Stopwatch.StartNew()
For Each file In pdfFiles
' Read the barcode
Dim results = BarcodeReader.Read(file, optionsFaster)
If results.Any() Then
Console.WriteLine($"Barcode(s) found in: {Path.GetFileName(file)}")
For Each result In results
Console.WriteLine($" Value: {result.Value}, Type: {result.BarcodeType}")
countFaster += 1
Next
Else
Console.WriteLine($"No barcode found in: {Path.GetFileName(file)}")
End If
Next
stopwatch.Stop()
' Print number of images the barcode reader could decode
Console.WriteLine($"ExtremeDetail could read = {countFaster} out of {pdfFiles.Length} in {stopwatch.ElapsedMilliseconds}ms")ExtremeDetailオプションは四つの設定中で最も重い前処理を適用し、他のオプションが見逃すことがある非常に劣化した画像のバーコードを回復できますが、処理時間とメモリのオーバーヘッドが著しく高いため、最後の手段としてのみ適しています。 このオプションを使用する前に、画像の前処理を検討してください。
異なる速度を比較する方法は?
以下の表は相対的で定性的な比較であり、実際のカウント、タイミング、メモリ使用量はすべて完全にデータセット、ハードウェア、画像の品質に依存するため、ここでは固定の数値は公開されていません。 本番に使用するオプションを選択する前に、それぞれのオプションを自身の画像の代表的なサンプルに対してベンチマークしてください。
| モード | 相対速度 | 相対メモリ使用量 | 最適な用途 |
|---|---|---|---|
| Faster | 最速 | 最低 | 鮮明で高品質な画像 |
| Balanced | 速い | 低い | ほとんどのアプリケーション(推奨デフォルト) |
| Detailed | 遅い | 高い | 中程度に劣化した画像 |
| ExtremeDetail | 最遅 | 最高 | 非常に劣化した画像、最後の手段として |
自分のアプリケーションに適した速度を選択するにはどうすればよいですか?
上記の比較に基づいて、Faster設定から始め、Balanced、Detailed、ExtremeDetailを進めて、重要な出力の違いを特定します。 ほとんどのシナリオでBalancedはすべてを適切に処理します。 ひどく歪んだ画像の場合のみ、DetailedとExtremeDetailを使用してください。 薄いまたは低品質のバーコードには、検出感度を高めるためにMinScanLines = 1と速度設定を組み合わせてください。
Detailed と ExtremeDetail は中度および重度の処理を適用しますが、時には処理を分割する方が効率的です - バーコード読み取りの前にフィルターを手動で適用する方が、一つの処理を使用するよりも効率的です。 画像の前処理についての詳細は、このガイドを参照してください。
どの速度設定が私のユースケースに適していますか?

よくある質問
IronBarcodeでは、さまざまな読み取り速度のオプションがありますか?
IronBarcodeは4つの読み取り速度オプションを提供しています:Faster、Balanced、Detailed、ExtremeDetail。各オプションは速度と精度に応じてさまざまなニーズに対応し、ユーザーが特定の要件に基づいてパフォーマンスを最適化できるようにします。
なぜバーコード読み取りにおいてBalancedオプションが推奨されるのですか?
Balancedオプションは、画像処理を軽減しつつ速度と精度のバランスを取るため、ほとんどの現代的で明確な画像に適しており、リソース消費を大幅に増加させることなく信頼性のある結果を提供するため推奨されています。
Faster速度オプションはいつ使用すればよいですか?
明確で高品質なバーコード画像を扱う場合に、Faster速度オプションを使用してください。この設定は画像の前処理をスキップし、最も速い処理時間と最も低いリソース使用を提供しますが、完璧でない画像の精度を犠牲にする可能性があります。
Detailedオプションはどのようにバーコード検出を改善するのですか?
Detailedオプションは中程度の前処理を適用し、バーコード領域を強化し、デジタルノイズを減少させるため、Balancedオプションでは不十分なほど劣化したりぼけたりした画像に最適です。
ExtremeDetail速度設定に適したシナリオは何ですか?
ExtremeDetail設定は、他のオプションが満足のいく結果を出せないほど劣化し不明瞭でぼやけたバーコードに最適です。大規模な前処理を適用し、リソース使用量がかなり増加するため、最後の手段としてのみ使用すべきです。
バーコード読み取りのニーズに合った速度オプションをどのように選べばよいですか?
Faster設定から始め、Balanced、Detailed、ExtremeDetailを通じて進行しつつ出力の違いを評価してください。ほとんどのアプリケーションはBalanced設定でメリットがあります。より歪んだ画像にはDetailedとExtremeDetailを使用してください。
IronBarcodeを使用する前に手動で画像を前処理することは可能ですか?
はい、特に低品質のバーコードを扱う場合、IronBarcodeを使用する前に手動で画像を前処理することが時により効率的です。これにより、画像品質改善をより適切に制御できます。
読み取り速度設定がメモリ使用にどのように影響を与えるか?
IronBarcodeの各読み取り速度設定は、速度、精度、メモリ使用量の間でトレードオフがあります。Fasterは最も少ないメモリを使用し、ExtremeDetailは大規模な処理を適用するため最も多くのメモリを必要とします。
ExtremeDetail設定で大規模な処理を適用する影響は何ですか?
ExtremeDetail設定は、集中的な画像前処理により読み取りパフォーマンスを大きく低下させ、CPU使用率を増加させます。特に非常に劣化した画像で他の設定よりも効果的に特定のバーコードを回復できます。
大量処理においてどのバーコード読み取り速度設定を使用するべきですか?
明確で高品質な画像を用いた大量処理には、Faster設定が速度が速くリソース使用が低いため最適です。しかし、それがニーズを満たすかどうかを確認するために、特定のデータセットに対してテストを行うことが重要です。
Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。