如何使用IronBarcode在C#中調整讀取速度
IronBarcode提供四種讀取速度選項(Faster, Balanced, Detailed, ExtremeDetail),讓您在C#中讀取條碼時控制處理速度與準確性的權衡,Balanced是大多數應用程式的建議起始點。
介紹
讀取大量條碼時,準確度至關重要,但資源分配與處理效率也同樣重要。輸入影像品質決定了條碼讀取器的處理方式:清晰影像可跳過前置處理,品質劣化的條碼則需使用較耗資源的選項來提高準確度。
IronBarcode 提供了選擇處理速度和精確度等級的靈活性,讓您可以控制條碼讀取過程的每個方面。 您可以根據輸入的影像和可用資源來做決定。 對於更高級的條碼讀取情況,探索我們的全面條碼讀取教學 ,其中涵蓋了不同的格式和技術。
本文提供針對不同情境選擇最佳讀取速度的指引。 我們會使用 QR Code樣本來示範改變讀取速度會如何影響結果。 如果您專門處理QR Code,請查看我們的C# QR Code 生成器教學以建立測試樣本。
快速入門:以平衡的速度讀取BarCode使用IronBarcode的BarcodeReaderOptions可以立即設定掃描的Speed水平。 此範例顯示如何使用Balanced設定快速且可靠地讀取條碼。
-
1使用 IronBarcode 安裝 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提供四種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選項完全跳過前置處理,因此在四個設定中速度最快,負擔最低,但會漏掉比其他選項更多劣質或低品質的條碼。 只適合於極佳的影像條件。 處理單張影像中的多個條碼時,請參考我們的讀取多個條碼指南優化設定。
為何 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選項。 它應用中度前置處理來釐清 BarCode 區域並減少數位雜訊,以達到更好的檢測效果。 對於嚴重劣化的影像,請參閱我們的影像校正指南,其中涵蓋了各種前置處理技術。
讓我們應用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 密集型選項最適用於掃描同一輸入檔案中多個不清楚或模糊的 BarCode。當其他選項無法達到預期效果時,可將其作為最後的選擇。 對於高量處理場景,請探討從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提供四種讀取速度選項:更快、平衡、詳細和極致詳細。每種選項都滿足不同的速度和準確性需求,讓使用者能根據其特定需求來優化效能。
為什麼推薦平衡選項用於條碼閱讀?
平衡選項推薦的原因是它通過輕度圖片處理來平衡速度和準確性。這使它適合大多數現代、清晰的圖像,在不顯著增加資源消耗的情況下提供可靠的結果。
什麼時候應該使用更快的速度選項?
當您處理清晰、高品質的條碼圖片時,請使用更快的速度選項。此設置跳過圖像的前處理,提供最快的處理時間和最低的資源使用,但可能會犧牲非完美圖像的準確性。
詳細選項如何改善條碼偵測?
詳細選項應用中等水準的前處理來增強條碼區域並減少數位噪音,適用於中等退化或模糊的圖像,此時平衡選項可能不夠。
極致詳細速度設置適合哪些場景?
極致詳細設置最適用於其他選項無法產生滿意結果的嚴重退化、不清晰或模糊的條碼。它應用重度前處理,會大大增加資源使用量,應僅作為最後手段使用。
如何選擇合適的條碼閱讀速度選項?
從更快的設置開始,然後逐步過渡到平衡、詳細和極致詳細,同時評估輸出差異。大多數應用將受益於平衡設置。針對較失真的圖像,使用詳細和極致詳細。
我可以在使用IronBarcode之前手動預處理圖像嗎?
可以,在使用IronBarcode之前應用手動圖像預處理有時更為有效,尤其是在處理低品質條碼時。這可讓您更好地控制圖像質量改善。
讀取速度設置如何影響記憶體使用?
IronBarcode中的每個讀取速度設置都權衡速度、準確性和記憶體使用。更快的使用最少的記憶體,而極致詳細則因其應用的重度處理而需要最多的記憶體。
在極致詳細設置中應用重度處理的影響是什麼?
極致詳細設置由於密集的圖像前處理而顯著降低讀取效能並增加CPU使用。它可以比其他設置更有效地恢復某些條碼,特別是在高度退化的圖像中。
我應該使用哪個條碼閱讀速度設置進行大量處理?
對於高容量處理且圖像清晰、高品質,請選擇更快的設置,因為它具有高速和低資源消耗。然而,重要的是要根據您的特定數據集進行測試,以確保符合您的需求。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。