USING IRONBARCODE 如何在.NET中构建条形码阅读器SDK? Jordi Bardia 已更新:2026年1月20日 下载 IronBarcode NuGet 下载 DLL 下载 免费试用 LLM副本 LLM副本 将页面复制为 Markdown 格式,用于 LLMs 在 ChatGPT 中打开 向 ChatGPT 咨询此页面 在双子座打开 向 Gemini 询问此页面 在 Grok 中打开 向 Grok 询问此页面 打开困惑 向 Perplexity 询问有关此页面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 复制链接 电子邮件文章 IronBarcode使.NET开发人员能够通过最少的代码为其应用程序增加条形码读取功能。 它支持多种格式,包括1D和2D条码、各种图像来源,并通过基于机器学习的检测为生产环境提供高精度。 条形码扫描对于许多应用程序至关重要,从库存管理到零售和物流。 通过将条形码读取集成到您的.NET应用程序中,您可以简化数据采集、自动化工作流程并提高效率。 在评估条形码读取解决方案时,考虑支持的格式、处理速度和集成复杂性等因素。 IronBarcode库提供了完整的跨平台兼容性和卓越的容错功能。 IronBarcode 是一个有效的.NET库,可以简化条形码的使用。 使用此工具,您可以从图像、流和PDF文件中读取条形码,并使用C# QR码生成器生成QR码。 本文向您展示如何将条形码扫描集成到您的.NET应用程序中,重点介绍创建API或Web应用集成以公开条形码扫描功能。 该库支持各种条形码格式,包括1D和2D条形码,具有高级的生成功能和样式选项。 IronBarcode 集成的最佳用例是什么? IronBarcode 在以下场景中表现出色: 库存管理系统 – 使用多条码读取和多页TIFF/GIF支持自动产品跟踪 物流应用 – 使用高速读取和可定制的输出格式处理运输条码 零售POS系统 – 使用Code 39和1D条码创建验证交易 文档处理 – 使用自定义读取器设置从PDF发票中提取数据 医疗应用 – 使用错误更正通过2D格式读取患者ID 制造质量控制 – 运行批量处理,可配置条码边距 如何在.NET中创建一个条形码读取SDK? 要创建可以在您的应用程序中公开为服务的条形码读取器,将IronBarcode集成到REST API或Web应用中。架构选择取决于您的处理需求:偶尔扫描的单一图像处理、文档工作流的批量处理或连续扫描应用的流处理。 以下是使用ASP.NET Core和适当线程安全注意事项的示例。 该库的读取功能包括优化精度的高级图像创建过滤器。 使用NuGet包安装用于在C#中读取条形码的.NET库 使用适当的错误处理创建可重用的条形码扫描类 开发从不同来源读取条形码的方法 使用改进设置将条形码图像读取集成到您的应用程序中 使用读取速度选项测试并提升性能 在开始之前我需要准备什么? 如果您还没有,请下载IronBarcode用于您的项目。 确保您拥有适用于预期用途的正确许可证密钥。 注意,通过公共API公开IronBarcode的功能或将其作为独立服务转售需要额外许可(SDK、OEM或SaaS)。 确保在继续之前了解许可选项。 对于开发环境,您可以从免费试用开始,当准备好投入生产时使用您的许可证密钥。 查看更新日志以获取最新更新和里程碑。 为了获得最佳性能,请考虑您的部署环境。 IronBarcode支持跨平台兼容性,包括Windows、Linux、macOS、Docker,以及Azure和AWS Lambda等云平台。 移动开发人员可以通过Blazor集成,使用对Android和iOS的支持。 对于.NET MAUI应用程序,请遵循条码扫描器读取器教程。 如何创建一个条形码扫描器类? 一旦您在项目中设置好IronBarcode并安装了它,您就可以创建一个可重用的条形码扫描器类,集成IronBarcode的功能并将其公开为API端点。 实现包括性能优化和在方向矫正有挑战性的场景下的图像矫正。 考虑实现裁剪区域以便在条码位置可预测时加快处理速度: using IronBarCode; using System.IO; using System.Collections.Concurrent; using System.Threading.Tasks; namespace BarcodeIntegration { public class BarcodeScanner { private static readonly ConcurrentDictionary<string, BarcodeReaderOptions> _optionsCache = new(); static BarcodeScanner() { // Set the license key IronBarCode.License.LicenseKey = "Your-License-Key"; } // Method to read a barcode from an image file with performance optimization public string ReadBarcodeFromImage(string imagePath, BarcodeReadingSpeed speed = BarcodeReadingSpeed.Balanced) { try { var options = GetCachedOptions(speed); // Try to read the barcode from the given image path var barcode = BarcodeReader.Read(imagePath, options); return barcode?.ToString() ?? "No Barcode Found"; // Return the barcode string or indicate no barcode was found } catch (Exception ex) { // Return an error message if an exception occurs return $"Error reading barcode: {ex.Message}"; } } // Method to read a barcode from a stream (e.g., file upload or memory stream) public async Task<string> ReadBarcodeFromStreamAsync(Stream inputStream) { try { var options = GetCachedOptions(BarcodeReadingSpeed.Detailed); // Enable image correction for better accuracy options.ImageFilters = new[] { new SharpenFilter(), new ContrastFilter() }; // Try to read the barcode from the given stream var barcode = await Task.Run(() => BarcodeReader.Read(inputStream, options)); return barcode?.ToString() ?? "No barcode found"; } catch (Exception ex) { return $"Error reading barcode: {ex.Message}"; } } // Method to read a barcode from a PDF file with batch processing support public async Task<List<string>> ReadBarcodesFromPdfAsync(string filePath) { try { var options = new BarcodeReaderOptions { ExpectMultipleBarcodes = true, Speed = BarcodeReadingSpeed.Detailed }; // Try to read barcodes from the given PDF file path var barcodes = await Task.Run(() => BarcodeReader.ReadPdf(filePath, options)); return barcodes.Select(b => b.ToString()).ToList(); } catch (Exception ex) { return new List<string> { $"Error reading barcode: {ex.Message}" }; } } // Cache reader options for performance private BarcodeReaderOptions GetCachedOptions(BarcodeReadingSpeed speed) { return _optionsCache.GetOrAdd(speed.ToString(), _ => new BarcodeReaderOptions { Speed = speed, AutoRotate = true, RemoveFalsePositive = true }); } } } using IronBarCode; using System.IO; using System.Collections.Concurrent; using System.Threading.Tasks; namespace BarcodeIntegration { public class BarcodeScanner { private static readonly ConcurrentDictionary<string, BarcodeReaderOptions> _optionsCache = new(); static BarcodeScanner() { // Set the license key IronBarCode.License.LicenseKey = "Your-License-Key"; } // Method to read a barcode from an image file with performance optimization public string ReadBarcodeFromImage(string imagePath, BarcodeReadingSpeed speed = BarcodeReadingSpeed.Balanced) { try { var options = GetCachedOptions(speed); // Try to read the barcode from the given image path var barcode = BarcodeReader.Read(imagePath, options); return barcode?.ToString() ?? "No Barcode Found"; // Return the barcode string or indicate no barcode was found } catch (Exception ex) { // Return an error message if an exception occurs return $"Error reading barcode: {ex.Message}"; } } // Method to read a barcode from a stream (e.g., file upload or memory stream) public async Task<string> ReadBarcodeFromStreamAsync(Stream inputStream) { try { var options = GetCachedOptions(BarcodeReadingSpeed.Detailed); // Enable image correction for better accuracy options.ImageFilters = new[] { new SharpenFilter(), new ContrastFilter() }; // Try to read the barcode from the given stream var barcode = await Task.Run(() => BarcodeReader.Read(inputStream, options)); return barcode?.ToString() ?? "No barcode found"; } catch (Exception ex) { return $"Error reading barcode: {ex.Message}"; } } // Method to read a barcode from a PDF file with batch processing support public async Task<List<string>> ReadBarcodesFromPdfAsync(string filePath) { try { var options = new BarcodeReaderOptions { ExpectMultipleBarcodes = true, Speed = BarcodeReadingSpeed.Detailed }; // Try to read barcodes from the given PDF file path var barcodes = await Task.Run(() => BarcodeReader.ReadPdf(filePath, options)); return barcodes.Select(b => b.ToString()).ToList(); } catch (Exception ex) { return new List<string> { $"Error reading barcode: {ex.Message}" }; } } // Cache reader options for performance private BarcodeReaderOptions GetCachedOptions(BarcodeReadingSpeed speed) { return _optionsCache.GetOrAdd(speed.ToString(), _ => new BarcodeReaderOptions { Speed = speed, AutoRotate = true, RemoveFalsePositive = true }); } } } Imports IronBarCode Imports System.IO Imports System.Collections.Concurrent Imports System.Threading.Tasks Namespace BarcodeIntegration Public Class BarcodeScanner Private Shared ReadOnly _optionsCache As New ConcurrentDictionary(Of String, BarcodeReaderOptions)() Shared Sub New() ' Set the license key IronBarCode.License.LicenseKey = "Your-License-Key" End Sub ' Method to read a barcode from an image file with performance optimization Public Function ReadBarcodeFromImage(imagePath As String, Optional speed As BarcodeReadingSpeed = BarcodeReadingSpeed.Balanced) As String Try Dim options = GetCachedOptions(speed) ' Try to read the barcode from the given image path Dim barcode = BarcodeReader.Read(imagePath, options) Return If(barcode?.ToString(), "No Barcode Found") ' Return the barcode string or indicate no barcode was found Catch ex As Exception ' Return an error message if an exception occurs Return $"Error reading barcode: {ex.Message}" End Try End Function ' Method to read a barcode from a stream (e.g., file upload or memory stream) Public Async Function ReadBarcodeFromStreamAsync(inputStream As Stream) As Task(Of String) Try Dim options = GetCachedOptions(BarcodeReadingSpeed.Detailed) ' Enable image correction for better accuracy options.ImageFilters = {New SharpenFilter(), New ContrastFilter()} ' Try to read the barcode from the given stream Dim barcode = Await Task.Run(Function() BarcodeReader.Read(inputStream, options)) Return If(barcode?.ToString(), "No barcode found") Catch ex As Exception Return $"Error reading barcode: {ex.Message}" End Try End Function ' Method to read a barcode from a PDF file with batch processing support Public Async Function ReadBarcodesFromPdfAsync(filePath As String) As Task(Of List(Of String)) Try Dim options = New BarcodeReaderOptions With { .ExpectMultipleBarcodes = True, .Speed = BarcodeReadingSpeed.Detailed } ' Try to read barcodes from the given PDF file path Dim barcodes = Await Task.Run(Function() BarcodeReader.ReadPdf(filePath, options)) Return barcodes.Select(Function(b) b.ToString()).ToList() Catch ex As Exception Return New List(Of String) From {$"Error reading barcode: {ex.Message}"} End Try End Function ' Cache reader options for performance Private Function GetCachedOptions(speed As BarcodeReadingSpeed) As BarcodeReaderOptions Return _optionsCache.GetOrAdd(speed.ToString(), Function(_) New BarcodeReaderOptions With { .Speed = speed, .AutoRotate = True, .RemoveFalsePositive = True }) End Function End Class End Namespace $vbLabelText $csharpLabel 这个改进的BarcodeScanner类通过选项缓存实现了性能优化,更好地支持可扩展性,以及改进精度的图像过滤器。 该实现遵循SOLID原则,并提供生产准备的错误处理。 若要获得更多功能,请考虑使用System.Drawing 集成或导出为流。 您还可以使用自定义条码样式和QR码样式创建条形码图像。 我应该使用哪种方法读取不同的条码来源? 每种方法都针对特定的使用案例和处理要求进行优化: ReadBarcodeFromImage(string imagePath): 从图像文件读取条码。 ReadBarcodeFromStream(Stream inputStream): 从输入流(例如,文件上传或内存流)读取条码。 ReadBarcodeFromPdf(string filePath): 从PDF文件读取条码。 对于高容量场景,考虑使用裁剪区域以提高处理速度最多可达5倍,当条码位置可预测时。 您还可以创建条形码图像或通过保存条码为不同格式。 该库支持从System.Drawing对象读取,并可以导出条码为HTML或PDF文档。 我如何通过REST API公开条码读取功能? 为了让外部应用程序使用您的条码扫描功能,可以使用ASP.NET Core将其公开为REST API。 实现包括适当的错误处理、验证和对多种输入格式的支持。 您还可以使用C#条码图像生成器生成条码或探索条码快速入门示例。 在处理PDF时,请考虑为文档跟踪在现有PDF上加盖条码: using Microsoft.AspNetCore.Mvc; using System.IO; using Microsoft.AspNetCore.Http; using BarcodeIntegration; [ApiController] [Route("api/barcode")] public class BarcodeController : ControllerBase { private readonly BarcodeScanner _barcodeScanner; private readonly ILogger<BarcodeController> _logger; public BarcodeController(ILogger<BarcodeController> logger) { _barcodeScanner = new BarcodeScanner(); _logger = logger; } // POST endpoint to read barcode from an uploaded image [HttpPost("read-from-image")] public async Task<IActionResult> ReadFromImage(IFormFile file) { if (file == null || file.Length == 0) return BadRequest(new { Error = "No file uploaded" }); // Validate file type var allowedTypes = new[] { "image/jpeg", "image/png", "image/gif", "image/bmp", "image/tiff" }; if (!allowedTypes.Contains(file.ContentType.ToLower())) return BadRequest(new { Error = "Unsupported file type" }); try { using var stream = file.OpenReadStream(); var result = await _barcodeScanner.ReadBarcodeFromStreamAsync(stream); _logger.LogInformation($"Barcode read successfully from {file.FileName}"); return Ok(new { Barcode = result, FileName = file.FileName }); } catch (Exception ex) { _logger.LogError(ex, "Error processing barcode"); return StatusCode(500, new { Error = "Internal server error" }); } } // POST endpoint for batch processing [HttpPost("read-batch")] public async Task<IActionResult> ReadBatch(List<IFormFile> files) { var results = new List<object>(); foreach (var file in files) { using var stream = file.OpenReadStream(); var result = await _barcodeScanner.ReadBarcodeFromStreamAsync(stream); results.Add(new { FileName = file.FileName, Barcode = result }); } return Ok(new { Results = results, Count = results.Count }); } // POST endpoint to generate barcode from data [HttpPost("generate")] public IActionResult GenerateBarcode([FromBody] BarcodeGenerationRequest request) { try { // Create barcode with specified data and format var barcode = BarcodeWriter.CreateBarcode(request.Data, request.Format ?? BarcodeWriterEncoding.Code128); // Apply custom styling if requested if (request.Width.HasValue && request.Height.HasValue) barcode.ResizeTo(request.Width.Value, request.Height.Value); if (!string.IsNullOrEmpty(request.ForegroundColor)) barcode.ChangeBarCodeColor(System.Drawing.ColorTranslator.FromHtml(request.ForegroundColor)); // Return as base64 encoded image using var ms = barcode.ToStream(); var bytes = ms.ToArray(); return Ok(new { Image = Convert.ToBase64String(bytes), Format = request.Format?.ToString() ?? "Code128", Data = request.Data }); } catch (Exception ex) { _logger.LogError(ex, "Error generating barcode"); return BadRequest(new { Error = "Failed to generate barcode" }); } } } public class BarcodeGenerationRequest { public string Data { get; set; } public BarcodeWriterEncoding? Format { get; set; } public int? Width { get; set; } public int? Height { get; set; } public string ForegroundColor { get; set; } } using Microsoft.AspNetCore.Mvc; using System.IO; using Microsoft.AspNetCore.Http; using BarcodeIntegration; [ApiController] [Route("api/barcode")] public class BarcodeController : ControllerBase { private readonly BarcodeScanner _barcodeScanner; private readonly ILogger<BarcodeController> _logger; public BarcodeController(ILogger<BarcodeController> logger) { _barcodeScanner = new BarcodeScanner(); _logger = logger; } // POST endpoint to read barcode from an uploaded image [HttpPost("read-from-image")] public async Task<IActionResult> ReadFromImage(IFormFile file) { if (file == null || file.Length == 0) return BadRequest(new { Error = "No file uploaded" }); // Validate file type var allowedTypes = new[] { "image/jpeg", "image/png", "image/gif", "image/bmp", "image/tiff" }; if (!allowedTypes.Contains(file.ContentType.ToLower())) return BadRequest(new { Error = "Unsupported file type" }); try { using var stream = file.OpenReadStream(); var result = await _barcodeScanner.ReadBarcodeFromStreamAsync(stream); _logger.LogInformation($"Barcode read successfully from {file.FileName}"); return Ok(new { Barcode = result, FileName = file.FileName }); } catch (Exception ex) { _logger.LogError(ex, "Error processing barcode"); return StatusCode(500, new { Error = "Internal server error" }); } } // POST endpoint for batch processing [HttpPost("read-batch")] public async Task<IActionResult> ReadBatch(List<IFormFile> files) { var results = new List<object>(); foreach (var file in files) { using var stream = file.OpenReadStream(); var result = await _barcodeScanner.ReadBarcodeFromStreamAsync(stream); results.Add(new { FileName = file.FileName, Barcode = result }); } return Ok(new { Results = results, Count = results.Count }); } // POST endpoint to generate barcode from data [HttpPost("generate")] public IActionResult GenerateBarcode([FromBody] BarcodeGenerationRequest request) { try { // Create barcode with specified data and format var barcode = BarcodeWriter.CreateBarcode(request.Data, request.Format ?? BarcodeWriterEncoding.Code128); // Apply custom styling if requested if (request.Width.HasValue && request.Height.HasValue) barcode.ResizeTo(request.Width.Value, request.Height.Value); if (!string.IsNullOrEmpty(request.ForegroundColor)) barcode.ChangeBarCodeColor(System.Drawing.ColorTranslator.FromHtml(request.ForegroundColor)); // Return as base64 encoded image using var ms = barcode.ToStream(); var bytes = ms.ToArray(); return Ok(new { Image = Convert.ToBase64String(bytes), Format = request.Format?.ToString() ?? "Code128", Data = request.Data }); } catch (Exception ex) { _logger.LogError(ex, "Error generating barcode"); return BadRequest(new { Error = "Failed to generate barcode" }); } } } public class BarcodeGenerationRequest { public string Data { get; set; } public BarcodeWriterEncoding? Format { get; set; } public int? Width { get; set; } public int? Height { get; set; } public string ForegroundColor { get; set; } } Imports Microsoft.AspNetCore.Mvc Imports System.IO Imports Microsoft.AspNetCore.Http Imports BarcodeIntegration <ApiController> <Route("api/barcode")> Public Class BarcodeController Inherits ControllerBase Private ReadOnly _barcodeScanner As BarcodeScanner Private ReadOnly _logger As ILogger(Of BarcodeController) Public Sub New(logger As ILogger(Of BarcodeController)) _barcodeScanner = New BarcodeScanner() _logger = logger End Sub ' POST endpoint to read barcode from an uploaded image <HttpPost("read-from-image")> Public Async Function ReadFromImage(file As IFormFile) As Task(Of IActionResult) If file Is Nothing OrElse file.Length = 0 Then Return BadRequest(New With {.Error = "No file uploaded"}) End If ' Validate file type Dim allowedTypes = New String() {"image/jpeg", "image/png", "image/gif", "image/bmp", "image/tiff"} If Not allowedTypes.Contains(file.ContentType.ToLower()) Then Return BadRequest(New With {.Error = "Unsupported file type"}) End If Try Using stream = file.OpenReadStream() Dim result = Await _barcodeScanner.ReadBarcodeFromStreamAsync(stream) _logger.LogInformation($"Barcode read successfully from {file.FileName}") Return Ok(New With {.Barcode = result, .FileName = file.FileName}) End Using Catch ex As Exception _logger.LogError(ex, "Error processing barcode") Return StatusCode(500, New With {.Error = "Internal server error"}) End Try End Function ' POST endpoint for batch processing <HttpPost("read-batch")> Public Async Function ReadBatch(files As List(Of IFormFile)) As Task(Of IActionResult) Dim results = New List(Of Object)() For Each file In files Using stream = file.OpenReadStream() Dim result = Await _barcodeScanner.ReadBarcodeFromStreamAsync(stream) results.Add(New With {.FileName = file.FileName, .Barcode = result}) End Using Next Return Ok(New With {.Results = results, .Count = results.Count}) End Function ' POST endpoint to generate barcode from data <HttpPost("generate")> Public Function GenerateBarcode(<FromBody> request As BarcodeGenerationRequest) As IActionResult Try ' Create barcode with specified data and format Dim barcode = BarcodeWriter.CreateBarcode(request.Data, If(request.Format, BarcodeWriterEncoding.Code128)) ' Apply custom styling if requested If request.Width.HasValue AndAlso request.Height.HasValue Then barcode.ResizeTo(request.Width.Value, request.Height.Value) End If If Not String.IsNullOrEmpty(request.ForegroundColor) Then barcode.ChangeBarCodeColor(System.Drawing.ColorTranslator.FromHtml(request.ForegroundColor)) End If ' Return as base64 encoded image Using ms = barcode.ToStream() Dim bytes = ms.ToArray() Return Ok(New With { .Image = Convert.ToBase64String(bytes), .Format = If(request.Format?.ToString(), "Code128"), .Data = request.Data }) End Using Catch ex As Exception _logger.LogError(ex, "Error generating barcode") Return BadRequest(New With {.Error = "Failed to generate barcode"}) End Try End Function End Class Public Class BarcodeGenerationRequest Public Property Data As String Public Property Format As BarcodeWriterEncoding? Public Property Width As Integer? Public Property Height As Integer? Public Property ForegroundColor As String End Class $vbLabelText $csharpLabel API在Swagger UI中的外观如何? API的响应是什么样的? 此API公开POST端点,您可以上传条码图像,API将返回条码数据。 实现包括适当的验证、错误处理和生产使用的日志记录。 对于移动应用程序,请考虑添加针对较小图像尺寸和更快响应时间优化的端点。 您还可以从数据创建条形码并将其导出为HTML或PDF。 对于高对比度需求,请生成1-BPP条码图像。## 我可以添加哪些高级功能? 为了进一步改进您的SDK,可以考虑使用IronBarcode的完整API参考实现这些生产就绪的功能。 探索功能概述并查看演示以了解实际实现: 如何支持多种条形码类型? IronBarcode支持同时读取多个条形码。 您可以配置您的SDK以同时接受多个条形码,并进行特定格式过滤。 该库支持书写Unicode条形码,包括中文和阿拉伯字符。 对于专用应用,探索Code 39读取和创建自定义样式的QR码: public async Task<List<BarcodeResult>> ReadMultipleBarcodesAsync(string imagePath, BarcodeEncoding[] expectedTypes = null) { try { var options = new BarcodeReaderOptions() { ExpectMultipleBarcodes = true, ExpectBarcodeTypes = expectedTypes ?? BarcodeEncoding.All, Speed = BarcodeReadingSpeed.Detailed, MaxParallelThreads = Environment.ProcessorCount, Multithreaded = true }; // Apply confidence threshold for machine learning accuracy options.Confidence = Confidence.High; var results = await Task.Run(() => BarcodeReader.Read(imagePath, options)); return results.Select(barcode => new BarcodeResult { Value = barcode.ToString(), Format = barcode.BarcodeType.ToString(), Confidence = barcode.Confidence, Position = barcode.Rect }).ToList(); } catch (Exception ex) { _logger.LogError(ex, "Error reading multiple barcodes"); throw; } } public async Task<List<BarcodeResult>> ReadMultipleBarcodesAsync(string imagePath, BarcodeEncoding[] expectedTypes = null) { try { var options = new BarcodeReaderOptions() { ExpectMultipleBarcodes = true, ExpectBarcodeTypes = expectedTypes ?? BarcodeEncoding.All, Speed = BarcodeReadingSpeed.Detailed, MaxParallelThreads = Environment.ProcessorCount, Multithreaded = true }; // Apply confidence threshold for machine learning accuracy options.Confidence = Confidence.High; var results = await Task.Run(() => BarcodeReader.Read(imagePath, options)); return results.Select(barcode => new BarcodeResult { Value = barcode.ToString(), Format = barcode.BarcodeType.ToString(), Confidence = barcode.Confidence, Position = barcode.Rect }).ToList(); } catch (Exception ex) { _logger.LogError(ex, "Error reading multiple barcodes"); throw; } } Imports System Imports System.Collections.Generic Imports System.Threading.Tasks Public Async Function ReadMultipleBarcodesAsync(imagePath As String, Optional expectedTypes As BarcodeEncoding() = Nothing) As Task(Of List(Of BarcodeResult)) Try Dim options As New BarcodeReaderOptions() With { .ExpectMultipleBarcodes = True, .ExpectBarcodeTypes = If(expectedTypes, BarcodeEncoding.All), .Speed = BarcodeReadingSpeed.Detailed, .MaxParallelThreads = Environment.ProcessorCount, .Multithreaded = True } ' Apply confidence threshold for machine learning accuracy options.Confidence = Confidence.High Dim results = Await Task.Run(Function() BarcodeReader.Read(imagePath, options)) Return results.Select(Function(barcode) New BarcodeResult With { .Value = barcode.ToString(), .Format = barcode.BarcodeType.ToString(), .Confidence = barcode.Confidence, .Position = barcode.Rect }).ToList() Catch ex As Exception _logger.LogError(ex, "Error reading multiple barcodes") Throw End Try End Function $vbLabelText $csharpLabel 我应该考虑哪些其他改进? 错误处理: 实现完整的错误处理包括MSI条码识别 批量处理: 创建用于异步批处理的方法,并使用1-BPP条形码图像 性能监控: 使用读取速度配置添加度量 缓存: 为经常扫描的条形码实施结果缓存 图像预处理: 使用方向矫正和对比度过滤器 格式特定优化: 为GS1-128和新格式配置设置 WebSocket 支持: 添加用于连续监控的实时条形码扫描 自定义样式: 应用条形码样式和QR码自定义 对于生产部署,考虑实现信心阈值以减少误报并确保数据准确性。 基于机器学习的检测可以针对您的特定用例进行微调。 在创建部署包时,请遵循MSI安装指南并解决任何丢失的DLL问题。 对于AWS部署,请注意可能的运行时问题。 考虑使用各种输出数据格式创建条形码,并探索条码读取教程。 我应该注意哪些许可因素? 如前所述,IronBarcode SDK是为了集成到您的内部应用程序中,通过API公开需要额外的许可。 在将IronBarcode作为服务的一部分公开(例如公共API)之前,必须获得必要的许可(SDK、OEM或SaaS)。 对于企业部署,请考虑可用于其他席位或改进支持的许可扩展。 查看升级选项以扩展您的部署。 不要将IronBarcode转售为独立SDK或通过公开API公开它,而无需确保您的许可涵盖此用法。 对于Web应用程序,您可能需要在web.config中配置许可证密钥以进行正确的激活。 保持知晓安全CVE更新,并遵循运行时副本例外的最佳做法。 对于技术问题,请考虑提交工程请求。 查看关于书写Unicode条形码的资源,并探索读取条形码教程。 为什么我今天应该尝试IronBarcode? 体验IronBarcode的新功能。 试用我们的免费试用并为您的.NET应用程序发现流畅的条形码生成、读取和编辑功能。 凭借高级功能、卓越的性能和用户友好的界面,IronBarcode是满足您所有条码需求的终极解决方案。 探索我们的完整文档,查看代码示例,以及观看现场演示以了解全部功能。 查看关于读取条形码的教程,并探索MicroQR和rMQR支持。 了解不同部署场景的NuGet包选项。 您还可以探索IronBarcode文档以获取关于我们完整条形码解决方案的更多信息。 今天开始您的免费试用并改进您的项目。 常见问题解答 如何将条码阅读器集成到 .NET 应用程序中? 您可以通过使用 IronBarcode 库将条码阅读器集成到 .NET 应用程序中。首先安装 IronBarcode,然后创建一个用于条码扫描的类,并实现从图像、流和 PDF 中读取条码的方法。最后测试和优化您的设置。 如何将条码读取功能公开为 REST API? 要公开条码读取功能为 REST API,使用 ASP.NET Core 创建一个 Web 应用程序。结合 IronBarcode 库,开发一个 BarcodeScanner 类,并定义使用诸如ReadBarcodeFromImage和ReadBarcodeFromStream等方法读取条码的 API 端点。 使用 .NET 条码库可以读取哪些类型的条码? 像 IronBarcode 这样的 .NET 条码库可以读取各种条码类型,包括 QR 码、Code 128、UPC 和 EAN。您可以通过设置检测参数来配置库同时检测多种条码类型。 如何在 .NET 中处理读取条码时的错误? 可以通过在使用 IronBarcode 的条码扫描方法中实现稳健的错误处理来处理条码读取中的错误。确保捕捉异常并提供有意义的反馈或重试机制,以提高条码读取过程的可靠性。 在公共 API 中使用 .NET 条码库的许可要求是什么? 在公共 API 中使用 IronBarcode 时,您必须确保正确的许可。这包括获取 SDK、OEM 或 SaaS 许可,因为将该库的功能作为独立服务或公共 API 公开需要额外的权限。 我能否使用 .NET 库批量处理多个条码扫描? 是的,您可以使用 IronBarcode 批量处理多个条码扫描。该库允许您在单次操作中读取多个条码,这对于高效地处理大量图像或文档集特别有用。 是否有可用 .NET 条码库的试用版? 是的,IronBarcode 提供免费的试用版,允许您在 .NET 应用程序中探索其条码生成、读取和编辑的功能。此试用版可帮助您在进行购买决策之前评估该库。 Jordi Bardia 立即与工程团队聊天 软件工程师 Jordi 最擅长 Python、C# 和 C++,当他不在 Iron Software 利用这些技能时,他就在游戏编程。分享产品测试、产品开发和研究的责任,Jordi 在持续的产品改进中增加了巨大的价值。多样的经验使他面临挑战并保持投入,他表示这是在 Iron Software 工作的最喜欢的方面之一。Jordi 在佛罗里达州迈阿密长大,并在佛罗里达大学学习计算机科学和统计学。 相关文章 已发布2026年3月8日 为.NET应用程序创建条码专业SDK 一个全面的.NET条码SDK,用于QR码、GS1、数据矩阵等。支持.NET 6-10、Core和Framework。 阅读更多 已发布2026年3月8日 构建条码SDK C#: 使用一个库生成、读取和扫描条码 使用IronBarcode在C#中构建条码SDK功能。生成条码图像,从文件中扫描多个条码,并使用一个.NET库读取QR码。包括示例代码。 阅读更多 已更新2026年3月1日 .NET条形码字体:如何在不依赖字体的情况下生成和打印条形码 使用IronBarcode ,以现代化的方式在.NET中处理条形码字体。生成 Code 39 和 Code 128 条形码图像——无需依赖任何字体。提供免费试用版。 阅读更多 How to Create a MAUI Barcode Scanner Using IronBarcodeHow to Read Multiple Barcodes with ...
已发布2026年3月8日 构建条码SDK C#: 使用一个库生成、读取和扫描条码 使用IronBarcode在C#中构建条码SDK功能。生成条码图像,从文件中扫描多个条码,并使用一个.NET库读取QR码。包括示例代码。 阅读更多
已更新2026年3月1日 .NET条形码字体:如何在不依赖字体的情况下生成和打印条形码 使用IronBarcode ,以现代化的方式在.NET中处理条形码字体。生成 Code 39 和 Code 128 条形码图像——无需依赖任何字体。提供免费试用版。 阅读更多