IronBarcode와 함께 C#에서 읽기 속도를 조정하는 방법
IronBarcode는 처리 속도와 정확도 간의 균형을 조절할 수 있는 네 가지 판독 속도 옵션(Faster, Balanced, Detailed, ExtremeDetail)을 제공하여 C#에서 BARCODE를 읽을 때 처리 속도와 정확도 간의 균형을 조절할 수 있게 하며, Balanced은 대부분의 애플리케이션에 권장되는 시작점입니다.
소개
대량의 바코드를 읽을 때는 정확성이 필수적이지만, 자원 할당과 처리 효율성도 똑같이 중요한 고려 사항입니다. 입력 이미지의 품질에 따라 바코드 리더가 이를 처리할 방법을 결정합니다—즉, 명확한 이미지를 위해 전처리를 건너뛸지 아니면 손상된 바코드의 정확성을 높이기 위해 더 많은 자원을 사용해야 할지.
IronBarcode는 처리 속도와 정확도 수준을 선택할 수 있는 유연성을 제공하여 바코드 읽기 프로세스의 모든 측면을 제어할 수 있습니다. 입력 이미지와 사용 가능한 자원에 따라 결정을 내릴 수 있습니다. 보다 고급 바코드 읽기 시나리오를 위해, 다양한 형식과 기술을 다루는 종합 바코드 읽기 튜토리얼을 탐색하십시오.
이 문서는 다양한 시나리오에 대한 최적의 읽기 속도 선택 가이드라인을 제공합니다. 읽기 속도를 변경하는 것이 결과에 어떤 영향을 미치는지 QR 코드 샘플을 사용해 설명할 것입니다. 특히 QR 코드와 작업 중이라면, 테스트 샘플을 만드는 데 도움이 되는 C# QR 코드 생성기 튜토리얼을 확인하십시오.
빠른 시작: 균형 잡힌 속도로 바코드 읽기
IronBarcode의 BarcodeReaderOptions를 사용하여 스캔 시 Speed 수준을 즉시 설정할 수 있습니다. 이 예제는 빠르고 안정적인 결과를 얻기 위해 Balanced 설정을 사용하여 BARCODE를 신속하게 읽는 방법을 보여줍니다.
-
NuGet 패키지 관리자를 사용하여 https://www.nuget.org/packages/BarCode 설치하기
PM > Install-Package BarCode -
다음 코드 조각을 복사하여 실행하세요.
var results = IronBarCode.BarcodeReader.Read("path/to/image.png", new IronBarCode.BarcodeReaderOptions { Speed = IronBarCode.ReadingSpeed.Balanced }); -
실제 운영 환경에서 테스트할 수 있도록 배포하세요.
무료 체험판으로 오늘 프로젝트에서 IronBarcode 사용 시작하기
최소 워크플로우(5단계)
- C# 라이브러리를 다운로드하여 읽기 속도 조정
- BarcodeReaderOptions 클래스를 사용하여 읽기 속도를 설정하십시오
Read메서드를 사용하여 다양한 이미지 형식에서 바코드 값을 추출하세요- 바코드 값을 출력하세요
- 다양한 읽기 속도 간의 성능 상충관계를 평가하십시오
다양한 읽기 속도 옵션은 무엇인가요?
IronBarcode는 ReadingSpeed, Faster, Balanced, Detailed, ExtremeDetail 등 네 가지 옵션을 제공합니다. 라이브러리의 기능을 보여주기 위해 대부분 손상된 바코드 이미지와 일부 선명한 이미지를 포함한 샘플 세트를 사용하여 각 옵션을 검토할 것입니다. 지원되는 형식의 전체 목록은 지원되는 바코드 형식 페이지를 방문하십시오.
.NET 벤치마크 라이브러리를 사용하여 처리 시간과 메모리 사용량을 측정하고 각 옵션의 비교 및 각 읽기 속도에 대한 이상적인 시나리오를 식별할 것입니다. 벤치마킹 코드를 보여드리며 손상된 바코드를 성공적으로 읽은 개수를 세는 간단한 방법을 소개합니다. 리더 옵션 구성에 대한 자세한 내용을 보려면 바코드 리더 설정 예제를 참조하십시오.
빠른 속도 옵션을 언제 사용해야 하나요?
Faster 옵션은 최소한의 리소스로 가장 빠른 BarCode 판독 속도를 제공하지만 정확도는 떨어집니다. 이 프로세스는 이미지 전처리를 건너뛰며, 입력 이미지가 이미 선명하고 명확할 때 가장 잘 작동합니다.
이 예제는 Speed 속성을 ReadingSpeed.Faster로 설정하고, BARCODE 디렉터리를 불러온 다음, 발견된 BARCODE의 값, 유형 및 이미지당 개수를 함께 PRINT합니다. 다양한 이미지 형식에서 바코드를 읽는 방법을 더 이해하려면 이미지에서 바코드 읽기 가이드를 확인하십시오.
:path=/static-assets/barcode/content-code-examples/how-to/reading-speed-option-faster.cs
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")
Faster 옵션은 25초 만에 430개 중 146개의 BARCODE 결과를 감지하여 33.95%의 정확도를 달성했습니다. 빠르지만 이 방법은 순수한 이미지 조건에만 적합합니다. 하나의 이미지에 여러 바코드를 처리할 때는 여러 바코드 읽기 가이드를 참조하여 최적의 구성을 고려하십시오.
균형 잡힌 속도가 권장되는 이유는 무엇인가요?
Balanced 옵션은 정확성과 가독성 사이의 균형을 맞춥니다. IronBarcode는 바코드 영역을 명확히 하기 위해 가벼운 이미지 처리를 적용하여 감지 및 판독이 더 쉽게 이루어집니다. 가벼운 처리는 일반적으로 정확한 결과를 제공하기 때문에 대부분의 현대 이미지에 권장됩니다.
Balanced이 출력 결과에 어떤 영향을 미치는지 보여주기 위해 동일한 이미지를 사용해 보겠습니다. 비동기 작업에 대한 내용은 IronBarcode의 비동기 및 멀티스레딩 가이드를 탐색하십시오.
:path=/static-assets/barcode/content-code-examples/how-to/reading-speed-option-balanced.cs
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")
Balanced 옵션은 43초 만에 430개 중 237개의 BARCODE 결과를 감지했습니다. 이 기능은 55.11%의 정확도를 제공하며, 이는 Faster에 비해 상당한 개선된 수치이며 처리 시간은 약간만 증가했습니다. 이 옵션은 메모리와 속도 사이의 효율적인 균형을 유지하며 대부분의 상황에 이상적이고 권장되는 시작 지점입니다. 이 균형 잡힌 접근법은 적절한 이미지 전처리 기술과 특히 잘 작동합니다.
자세한 속도가 필요한 때는 언제인가요?
이미지가 심하게 흐리거나 왜곡되어 Balanced로 명확한 결과를 얻을 수 없는 경우, Detailed 옵션을 사용하십시오. 바코드 영역을 명확히 하고 디지털 노이즈를 줄여 더 나은 감지를 위해 중간 전처리를 적용합니다. 심하게 손상된 이미지의 경우, 다양한 전처리 기법을 다루는 이미지 보정 가이드를 참고하십시오.
Detailed 설정을 적용하고 출력에 미치는 영향을 확인해 봅시다.
:path=/static-assets/barcode/content-code-examples/how-to/reading-speed-option-detailed.cs
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")
Detailed 옵션은 5분 30초 만에 430개 중 237개의 BARCODE 결과를 감지했습니다. 심하게 손상된 바코드에 55.11%의 성공률을 보이며, 이 옵션의 정확성을 보여줍니다. 그러나 처리 시간이 크게 증가하기 때문에 이 옵션은 손상된 바코드 이미지에만 독점적으로 사용해야 합니다. 불완전한 바코드를 다룰 때는 추가 전략을 위해 불완전한 바코드 처리 예제를 참조하십시오.
어떤 상황에서 ExtremeDetail 속도가 필요한가요?
ExtremeDetail 설정은 BarCode 이미지에 대한 처리 부하가 커져 판독 성능이 현저히 저하됩니다. 이 CPU 집약적인 옵션은 하나의 입력 파일에 불명확하거나 흐릿한 여러 바코드를 스캔하는 데 가장 적합합니다. 다른 옵션들이 원하는 결과를 내지 못할 때 최후의 수단으로 사용하십시오. 대량 처리 시나리오에서는 PDF 파일에서의 바코드 읽기를 탐색하십시오. 이 파일에는 페이지당 여러 바코드가 포함되어 있을 수 있습니다.
ExtremeDetail 설정을 적용하여 그 효과를 확인해 봅시다.
:path=/static-assets/barcode/content-code-examples/how-to/reading-speed-option-extreme-detailed.cs
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")
ExtremeDetail 옵션은 약 10분 만에 430개의 BarCode 이미지 중 313개를 식별했습니다. 심하게 손상된 바코드에 대해 인상적인 72.79%의 정확도를 달성하지만, 높은 자원 소비로 인해 최후의 수단으로만 적합합니다. 이 옵션을 사용하기 전에 이미지를 전처리하는 것을 고려하십시오.
다양한 속도의 비교는 어떻게 이루어지나요?
| 방법 | 발견된 바코드 | 평균 시간 | 파일당 시간 | GC 압력 | 정확도 증가 |
|---|---|---|---|---|---|
| 더 빠름 | 147/430 (33.95%) | 25 초 | 0.058 초 | 높음 (Gen2: 177K) | 기준선 |
| 균형 | 237/430 (55.11%) | 43 초 | 0.1 초 | 높음 (Gen2: 151K) | +62.32% vs 더 빠른 |
| 세부사항 | 237/430 (55.11%) | 5.50 분 | 0.767 초 | 매우 높음 (Gen2: 297K) | +0% vs 균형 |
| 극세밀 | 313/430 (72.79%) | 10.14 분 | 1.414 초 | 극단 (Gen2: 4.74M) | +32.08% vs 세부사항 |
내 응용 프로그램에 맞는 적절한 속도 선택 방법
위의 비교 내용을 바탕으로, Faster 설정부터 시작하여 Balanced, Detailed, ExtremeDetail 순으로 진행하며 출력 결과의 주요 차이점을 확인하십시오. 대부분의 경우, Balanced가 모든 것을 적절히 처리합니다. Detailed 및 ExtremeDetail는 심하게 왜곡된 이미지에만 사용하십시오. 선명도가 낮거나 품질이 낮은 BARCODE의 경우, 속도 설정과 MinScanLines = 1를 함께 사용하여 감지 감도를 높이십시오.
Detailed 및 ExtremeDetail는 중간 및 고부하 처리를 수행하지만, 단일 프로세스를 사용하는 것보다 BarCode 판독 전에 수동으로 이미지 필터를 적용하는 등 프로세스를 분할하는 것이 더 효율적인 경우도 있습니다. 이미지 전처리에 대한 자세한 내용은 이 가이드를 참조하세요.
내 사용 사례에 맞는 속도 설정은 무엇인가요?
자주 묻는 질문
사용 가능한 바코드 판독 속도 옵션은 네 가지이며, 각각 무엇입니까?
IronBarcode는 Faster, Balanced, Detailed, ExtremeDetail의 네 가지 판독 속도 옵션을 제공합니다. 각 옵션은 처리 속도와 정확도 사이의 균형이 다르며, 대부분의 애플리케이션에는 Balanced 옵션이 권장되는 시작점입니다.
바코드를 스캔할 때 읽기 속도를 어떻게 설정하나요?
IronBarcode의 BarcodeReaderOptions 클래스를 사용하여 읽기 속도를 설정할 수 있습니다. 새 BarcodeReaderOptions 객체를 생성하고 Speed 속성을 원하는 읽기 속도 값(Faster, Balanced, Detailed 또는 ExtremeDetail)으로 설정한 다음, 해당 객체를 Read 메서드에 전달하면 됩니다.
내 애플리케이션에는 어떤 읽기 속도 옵션을 사용해야 할까요?
IronBarcode는 대부분의 용도에 대해 균형 속도 설정으로 시작할 것을 권장합니다. 고품질의 선명한 바코드 이미지를 사용하는 경우 빠른 모드를 사용할 수 있습니다. 이미지 품질이 저하되었거나 불량한 경우에는 정확도를 높이기 위해 상세 또는 극세사 모드를 사용하는 것을 고려해 보세요.
읽기 속도 옵션 간의 장단점은 무엇인가요?
IronBarcode의 바코드 판독 속도는 처리 속도와 정확도 사이의 절충점을 가지고 있습니다. 빠른 모드는 이미지를 신속하게 처리하지만 화질이 낮은 이미지에서는 바코드를 놓칠 수 있습니다. 극도로 세밀한 모드는 최고의 정확도를 제공하지만 더 많은 처리 시간과 메모리 리소스를 필요로 합니다.
서로 다른 속도 설정으로 여러 바코드 형식을 읽을 수 있습니까?
네, IronBarcode는 모든 속도 설정에서 QR 코드를 포함한 다양한 바코드 형식을 지원합니다. 속도 설정은 처리 방식에 영향을 미치지만, 읽을 수 있는 바코드 종류를 제한하지는 않습니다. 지원되는 바코드 형식 전체 목록은 지원되는 바코드 형식 페이지를 참조하세요.
이미지 품질은 읽기 속도 선택에 어떤 영향을 미치나요?
이미지 품질은 IronBarcode에서 처리 속도 선택에 직접적인 영향을 미칩니다. 선명하고 고품질의 바코드 이미지는 Faster 모드에서 효율적으로 처리할 수 있습니다. 화질이 저하되었거나 흐릿하거나 명암 대비가 낮은 이미지는 정확한 바코드 감지 및 판독을 위해 Detailed 또는 ExtremeDetail 모드가 필요합니다.
속도 옵션을 포함한 바코드 판독을 위한 최소 워크플로는 무엇입니까?
IronBarcode를 사용한 최소 워크플로는 다음과 같은 5단계로 구성됩니다. 1) C# 라이브러리 다운로드, 2) BarcodeReaderOptions를 사용하여 읽기 속도 설정, 3) 이미지 경로를 사용하여 Read 메서드 호출, 4) 바코드 값 추출 및 인쇄, 5) 다양한 속도 간의 성능 비교.
읽기 속도 차이가 학습 성과에 미치는 영향을 어떻게 측정할 수 있을까요?
IronBarcode의 성능은 .NET 벤치마크 라이브러리를 사용하여 다양한 읽기 속도에서 측정할 수 있으며, 이를 통해 처리 시간과 메모리 사용량을 추적할 수 있습니다. 이를 통해 특정 사용 사례 및 리소스 제약 조건에 맞는 최적의 속도 설정을 파악할 수 있습니다.

