如何在C#中使用IronBarcode调整读取速度
IronBarcode 提供四种读取速度选项(Faster、Balanced、Detailed、ExtremeDetail),允许您在C#中读取条形码时控制处理速度和准确性之间的权衡,其中Balanced是大多数应用程序的推荐起点。
介绍
在读取大量条形码时,准确性至关重要,但资源分配和处理效率也是同样重要的考虑因素。 输入图像的质量决定了条形码读取器应该如何处理它们——对于清晰的图像是跳过预处理,还是使用更耗资源的选项来提高退化条形码的准确性。
IronBarcode 可灵活选择处理速度和准确度级别,让您控制条码读取过程的方方面面。 您可以根据输入的图像和可用资源做出决定。 对于更高级的条形码读取场景,请查看我们的全面条形码读取教程,其中涵盖了各种格式和技术。
本文提供了针对不同情况选择最佳读取速度的指南。 我们将使用二维码样本来演示改变读取速度对结果的影响。 如果您专门处理二维码,请查看我们的C#二维码生成器教程以创建测试样本。
快速入门:以平衡的速度读取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选项提供了最快的条形码读取速度,使用资源最少,但降低了准确性。 该流程跳过了图像预处理,在输入图像已经清晰锐利的情况下效果最佳。
此示例将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选项。 它应用了中等强度的预处理,使条形码区域更清晰并减少数字噪声,从而更好地进行检测。 对于严重退化的图像,请查阅我们的图像校正指南,其中涵盖了各种预处理技术。
让我们应用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")与Balanced相比,Detailed选项的中等强度预处理会显著增加处理时间,但不一定在每个数据集上进一步改善检测效果 - 在采纳之前,先在自己的图像上与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,以识别显著的输出差异。 对于大多数场景,Balanced可以充分应对。 仅在图像严重失真时使用Detailed和ExtremeDetail。 对于条纹较细或质量较低的条形码,将速度设置与MinScanLines = 1结合使用,以提高检测灵敏度。
尽管Detailed和ExtremeDetail分别应用中等强度和高强度处理,有时分步处理效率更高,即 在条形码读取之前手动应用图像滤镜,而不是使用单一过程。 有关预处理图像的更多信息,请参阅此指南。
哪个速度设置符合我的用例?

常见问题
IronBarcode有哪些不同的读取速度选项?
IronBarcode提供四种读取速度选项:更快、平衡、详细和极致详细。每个选项都满足不同速度和准确度的需求,使用户能够根据具体的要求优化性能。
为什么推荐选择平衡选项进行条码读取?
推荐使用平衡选项是因为它在速度和准确度之间取得了均衡,通过轻度图像处理来实现。这使其适用于大多数现代、清晰的图像,并在不显著增加资源消耗的情况下提供可靠的结果。
我应该在什么时候使用更快的速度选项?
当您处理清晰、高质量的条码图像时,使用更快的速度选项。此设置跳过对图像的预处理,提供最快的处理时间和最低的资源使用,但对于不够完美的图像可能会牺牲准确性。
详细选项如何改善条码检测?
详细选项应用中等水平的预处理以增强条码区域并减少数字噪声,对于平衡选项可能不足的中等退化或模糊的图像非常理想。
哪个情境最适合使用极致详细的速度设置?
极致详细设置适合用于严重退化、不清晰或模糊的条码,其他选项无法产生满意结果时使用。它应用重度预处理,显著增加资源使用,仅应作为最后的选择。
如何选择适合我条码读取需求的速度选项?
从更快设置开始,根据输出差异逐渐过渡到平衡、详细和极致详细。大多数应用将从平衡设置中受益。使用详细和极致详细选项处理更扭曲的图像。
我可以在使用IronBarcode之前手动预处理图像吗?
是的,在使用IronBarcode之前应用手动图像预处理有时效率更高,特别是处理低质量条码时。这允许更好地控制图像质量的改进。
读取速度设置如何影响内存使用?
IronBarcode中的每个读取速度设置在速度、准确性和内存使用之间进行权衡。更快选项使用最少的内存,而极致详细由于其重度处理需要最多的内存。
在极致详细设置中应用重度处理有何影响?
极致详细设置由于密集的图像预处理,显著降低读取性能并增加CPU使用。它能比其他设置更有效地恢复某些条码,尤其是在高度退化的图像中。
对于大批量处理,我应该使用哪种条码读取速度设置?
对于大批量处理清晰、高质量的图像来说,由于其速度和低资源消耗,更快选项是最佳选择。然而,重要的是要针对您的特定数据集进行测试,以确保其满足您的需求。
Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。