Makbuz Tarama API'si: C# ve IronOCR Kullanarak Makbuzlardan Veri Çıkarma
Makbuz tarama API'leri, OCR teknolojisi kullanarak makbuzlardan veri çıkarmayı otomatikleştirir, manuel giriş hatalarını önemli ölçüde azaltır ve işlemleri hızlandırır. Bu kılavuz, IronOCR'nin birden çok formatı destekleyen ve dahili görüntü önişleme ile birlikte makbuz görüntülerinden satıcı isimlerini, tarihleri, öğeleri, fiyatları ve toplamları doğru bir şekilde nasıl çıkaracağını C# içinde kullanmayı gösterir.
Makbuz Tarama için Neden IronOCR'yi Seçmelisiniz?
IronOCR, taramalı belgelerden, görüntülerden ve PDF'lerden güvenilir metin çıkarımı sunan esnek bir OCR kütüphanesidir. Gelişmiş algoritmalar, bilgisayarla görme ve makine öğrenimi modelleri ile IronOCR, zorlu senaryolarda bile yüksek doğruluk sağlar. Kütüphane, birden fazla dili ve yazı tipi stilini destekleyerek küresel uygulamalara uygun hale getirir. IronOCR'yi uygulamalarınıza entegre ederek otomatik veri girişi ve metin analizi yapabilir, verimliliği artırabilirsiniz.
IronOCR Makbuz Görüntülerinden Metni Nasıl Çıkarır?
IronOCR, belgelerden, fotoğraflardan, ekran görüntülerinden ve canlı kamera beslemelerinden metinleri JSON yanıtlar olarak alır. Gelişmiş algoritmalar ve makine öğrenimi kullanarak IronOCR görüntü verilerini analiz eder, karakterleri tanır ve onları makine tarafından okunabilir metne dönüştürür. Kütüphane, üstün doğruluk sağlamak için özel iyileştirmelerle geliştirilmiş Tesseract 5 teknolojisini kullanır.
IronOCR Makbuz İşleme İçin Neden Mükemmel?
IronOCR, düşük kalitedeki taramaları, değişken makbuz formatlarını ve farklı yönlendirmeleri işleme konusunda uzmandır. Dahili görüntü önişleme filtreleri, kırışık veya solmuş makbuzlardan bile en iyi sonuçları elde etmeyi sağlamak için işlemden önce görüntü kalitesini otomatik olarak iyileştirir.
IronOCR Kullanmak İçin Ne Gereklidir?
IronOCR ile çalışmadan önce, şu ön gereksinimlerin mevcut olduğundan emin olun:
Hangi Geliştirme Ortamları Desteklenir?
Hangi Programlama Becerileri Gereklidir?
- C# Bilgisi: Temel C# bilgisi, kod örneklerini değiştirmenize yardımcı olur. IronOCR, basit örnekler ve API belgeleri sağlar.
Hangi Yazılım Bağımlılıkları Gereklidir?
- IronOCR Kurulumu: NuGet Package Manager aracılığıyla kurun. Platforma özgü bağımlılıklar gerekebilir.
Bir Lisans Anahtarı Gerekli mi?
- Lisans Anahtarı (Opsiyonel): Ücretsiz deneme mevcuttur; produksiyon kullanımı için bir lisans gerektirir.
Makbuz Taraması İçin Yeni Bir Visual Studio Projesi Nasıl Oluşturulur?
Visual Studio'da Yeni Bir Projeye Nasıl Başlanır?
Visual Studio'yu açın ve Dosyalar'a gidin, ardından Yeni üzerinde gezinin ve Proje'ye tıklayın.
Yeni Proje Görseli
Hangi Proje Şablonunu Seçmeliyim?
Konsol Uygulaması'nı seçin ve İleri'ye tıklayın. Bu şablon, web uygulamalarında uygulamadan önce IronOCR'yi öğrenmek için idealdir.
Konsol Uygulaması
Makbuz Tarayıcı Projemi Nasıl Adlandırmalıyım?
Proje adınızı ve konumunuzu yazın, ardından İleri'ye tıklayın. 'ReceiptScannerAPI' gibi açıklayıcı bir isim seçin.
Proje Yapılandırması
Hangi .NET Framework Sürümünü Seçmeliyim?
Uyumluluğu en uygun hale getirmek için .NET 5.0 veya daha yenisini seçin, ardından Oluştur'a tıklayın.
Hedef Çerçeve
Projemde IronOCR Nasıl Kurulur?
İki basit kurulum yöntemi mevcuttur:
NuGet Package Manager Yöntemi Nasıl Kullanılır?
Tools > NuGet Paket Yöneticisi > Manage NuGet Packages for Solution gidin
NuGet Paket Yöneticisi
IronOCR'yi arayın ve paketi yükleyin. İngilizce olmayan makbuzlar için, dile özgü paketleri yükleyin.
IronOCR
Komut Satırı Kurulumu Nasıl Yapılır?
- Tools > NuGet Paket Yöneticisi > Package Manager Console gidin
-
Bu komutu girin:
Install-Package IronOcr
Package Manager Console
IronOCR ile Makbuz Verisini Nasıl Hızlıca Çıkartırım?
Sadece birkaç satır kodla makbuz verilerini çıkarın:
-
NuGet Paket Yöneticisi ile https://www.nuget.org/packages/IronOcr yükleyin
PM > Install-Package IronOcr -
Bu kod parçasını kopyalayıp çalıştırın.
using IronOcr; using System; var ocr = new IronTesseract(); // Configure for receipt scanning ocr.Configuration.ReadBarCodes = true; ocr.Configuration.WhiteListCharacters = "0123456789.$,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz% "; using (var input = new OcrInput(@"receipt.jpg")) { // Apply automatic image enhancement input.DeNoise(); input.Deskew(); input.EnhanceResolution(225); // Extract text from receipt var result = ocr.Read(input); // Display extracted text and confidence Console.WriteLine($"Extracted Text:\n{result.Text}"); Console.WriteLine($"\nConfidence: {result.Confidence}%"); } -
Canlı ortamınızda test etmek için dağıtın
Bugün projenizde IronOCR kullanmaya başlayın ücretsiz deneme ile
Makbuz Görüntülerinden Yapılandırılmış Veriyi Nasıl Çıkarır?
IronOCR, çeşitli belge türlerinden satır öğeleri, fiyatlandırma, vergiler ve toplamları çıkarır. Kütüphane PDF, çok sayfalı TIFF ve çeşitli görüntü formatlarını destekler.
using IronOcr;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class ReceiptScanner
{
static void Main()
{
var ocr = new IronTesseract();
// Configure OCR for optimal receipt reading
ocr.Configuration.WhiteListCharacters = "0123456789.$,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz% ";
ocr.Configuration.BlackListCharacters = "~`@#*_}{][|\\";
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
// Load the image of the receipt
using (var input = new OcrInput(@"r2.png"))
{
// Apply image enhancement filters
input.Deskew(); // Fix image rotation
input.EnhanceResolution(225); // Optimal DPI for receipts
input.DeNoise(); // Remove background noise
input.Sharpen(); // Improve text clarity
// Perform OCR on the input image
var result = ocr.Read(input);
// Regular expression patterns to extract relevant details from the OCR result
var descriptionPattern = @"\w+\s+(.*?)\s+(\d+\.\d+)\s+Units\s+(\d+\.\d+)\s+Tax15%\s+\$(\d+\.\d+)";
var pricePattern = @"\$\d+(\.\d{2})?";
var datePattern = @"\d{1,2}[/-]\d{1,2}[/-]\d{2,4}";
// Variables to store extracted data
var descriptions = new List<string>();
var unitPrices = new List<decimal>();
var taxes = new List<decimal>();
var amounts = new List<decimal>();
var lines = result.Text.Split('\n');
foreach (var line in lines)
{
// Match each line against the description pattern
var descriptionMatch = Regex.Match(line, descriptionPattern);
if (descriptionMatch.Success)
{
descriptions.Add(descriptionMatch.Groups[1].Value.Trim());
unitPrices.Add(decimal.Parse(descriptionMatch.Groups[2].Value));
// Calculate tax and total amount for each item
var tax = unitPrices[unitPrices.Count - 1] * 0.15m;
taxes.Add(tax);
amounts.Add(unitPrices[unitPrices.Count - 1] + tax);
}
// Extract date if found
var dateMatch = Regex.Match(line, datePattern);
if (dateMatch.Success)
{
Console.WriteLine($"Receipt Date: {dateMatch.Value}");
}
}
// Output the extracted data
for (int i = 0; i < descriptions.Count; i++)
{
Console.WriteLine($"Description: {descriptions[i]}");
Console.WriteLine($"Quantity: 1.00 Units");
Console.WriteLine($"Unit Price: ${unitPrices[i]:0.00}");
Console.WriteLine($"Taxes: ${taxes[i]:0.00}");
Console.WriteLine($"Amount: ${amounts[i]:0.00}");
Console.WriteLine("-----------------------");
}
// Calculate and display totals
var subtotal = unitPrices.Sum();
var totalTax = taxes.Sum();
var grandTotal = amounts.Sum();
Console.WriteLine($"\nSubtotal: ${subtotal:0.00}");
Console.WriteLine($"Total Tax: ${totalTax:0.00}");
Console.WriteLine($"Grand Total: ${grandTotal:0.00}");
}
}
}
using IronOcr;
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class ReceiptScanner
{
static void Main()
{
var ocr = new IronTesseract();
// Configure OCR for optimal receipt reading
ocr.Configuration.WhiteListCharacters = "0123456789.$,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz% ";
ocr.Configuration.BlackListCharacters = "~`@#*_}{][|\\";
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
// Load the image of the receipt
using (var input = new OcrInput(@"r2.png"))
{
// Apply image enhancement filters
input.Deskew(); // Fix image rotation
input.EnhanceResolution(225); // Optimal DPI for receipts
input.DeNoise(); // Remove background noise
input.Sharpen(); // Improve text clarity
// Perform OCR on the input image
var result = ocr.Read(input);
// Regular expression patterns to extract relevant details from the OCR result
var descriptionPattern = @"\w+\s+(.*?)\s+(\d+\.\d+)\s+Units\s+(\d+\.\d+)\s+Tax15%\s+\$(\d+\.\d+)";
var pricePattern = @"\$\d+(\.\d{2})?";
var datePattern = @"\d{1,2}[/-]\d{1,2}[/-]\d{2,4}";
// Variables to store extracted data
var descriptions = new List<string>();
var unitPrices = new List<decimal>();
var taxes = new List<decimal>();
var amounts = new List<decimal>();
var lines = result.Text.Split('\n');
foreach (var line in lines)
{
// Match each line against the description pattern
var descriptionMatch = Regex.Match(line, descriptionPattern);
if (descriptionMatch.Success)
{
descriptions.Add(descriptionMatch.Groups[1].Value.Trim());
unitPrices.Add(decimal.Parse(descriptionMatch.Groups[2].Value));
// Calculate tax and total amount for each item
var tax = unitPrices[unitPrices.Count - 1] * 0.15m;
taxes.Add(tax);
amounts.Add(unitPrices[unitPrices.Count - 1] + tax);
}
// Extract date if found
var dateMatch = Regex.Match(line, datePattern);
if (dateMatch.Success)
{
Console.WriteLine($"Receipt Date: {dateMatch.Value}");
}
}
// Output the extracted data
for (int i = 0; i < descriptions.Count; i++)
{
Console.WriteLine($"Description: {descriptions[i]}");
Console.WriteLine($"Quantity: 1.00 Units");
Console.WriteLine($"Unit Price: ${unitPrices[i]:0.00}");
Console.WriteLine($"Taxes: ${taxes[i]:0.00}");
Console.WriteLine($"Amount: ${amounts[i]:0.00}");
Console.WriteLine("-----------------------");
}
// Calculate and display totals
var subtotal = unitPrices.Sum();
var totalTax = taxes.Sum();
var grandTotal = amounts.Sum();
Console.WriteLine($"\nSubtotal: ${subtotal:0.00}");
Console.WriteLine($"Total Tax: ${totalTax:0.00}");
Console.WriteLine($"Grand Total: ${grandTotal:0.00}");
}
}
}
Imports IronOcr
Imports System
Imports System.Collections.Generic
Imports System.Text.RegularExpressions
Imports System.Linq
Class ReceiptScanner
Shared Sub Main()
Dim ocr = New IronTesseract()
' Configure OCR for optimal receipt reading
ocr.Configuration.WhiteListCharacters = "0123456789.$,ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz% "
ocr.Configuration.BlackListCharacters = "~`@#*_}{][|\"
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
' Load the image of the receipt
Using input = New OcrInput("r2.png")
' Apply image enhancement filters
input.Deskew() ' Fix image rotation
input.EnhanceResolution(225) ' Optimal DPI for receipts
input.DeNoise() ' Remove background noise
input.Sharpen() ' Improve text clarity
' Perform OCR on the input image
Dim result = ocr.Read(input)
' Regular expression patterns to extract relevant details from the OCR result
Dim descriptionPattern = "\w+\s+(.*?)\s+(\d+\.\d+)\s+Units\s+(\d+\.\d+)\s+Tax15%\s+\$(\d+\.\d+)"
Dim pricePattern = "\$\d+(\.\d{2})?"
Dim datePattern = "\d{1,2}[/-]\d{1,2}[/-]\d{2,4}"
' Variables to store extracted data
Dim descriptions = New List(Of String)()
Dim unitPrices = New List(Of Decimal)()
Dim taxes = New List(Of Decimal)()
Dim amounts = New List(Of Decimal)()
Dim lines = result.Text.Split(ControlChars.Lf)
For Each line In lines
' Match each line against the description pattern
Dim descriptionMatch = Regex.Match(line, descriptionPattern)
If descriptionMatch.Success Then
descriptions.Add(descriptionMatch.Groups(1).Value.Trim())
unitPrices.Add(Decimal.Parse(descriptionMatch.Groups(2).Value))
' Calculate tax and total amount for each item
Dim tax = unitPrices(unitPrices.Count - 1) * 0.15D
taxes.Add(tax)
amounts.Add(unitPrices(unitPrices.Count - 1) + tax)
End If
' Extract date if found
Dim dateMatch = Regex.Match(line, datePattern)
If dateMatch.Success Then
Console.WriteLine($"Receipt Date: {dateMatch.Value}")
End If
Next
' Output the extracted data
For i As Integer = 0 To descriptions.Count - 1
Console.WriteLine($"Description: {descriptions(i)}")
Console.WriteLine("Quantity: 1.00 Units")
Console.WriteLine($"Unit Price: ${unitPrices(i):0.00}")
Console.WriteLine($"Taxes: ${taxes(i):0.00}")
Console.WriteLine($"Amount: ${amounts(i):0.00}")
Console.WriteLine("-----------------------")
Next
' Calculate and display totals
Dim subtotal = unitPrices.Sum()
Dim totalTax = taxes.Sum()
Dim grandTotal = amounts.Sum()
Console.WriteLine(vbCrLf & $"Subtotal: ${subtotal:0.00}")
Console.WriteLine($"Total Tax: ${totalTax:0.00}")
Console.WriteLine($"Grand Total: ${grandTotal:0.00}")
End Using
End Sub
End Class
Makbuz Tarama Doğruluğunu Hangi Teknikler İyileştirir?
Doğru makbuz taraması için anahtar teknikler:
- Karakter beyaz listeleme: Tanımayı beklenen karakterlerle sınırlama
- Görüntü ön işleme: deskewing, çözünürlük iyileştirme ve gürültü giderme kullanır
- Desen eşleştirme: Düzenli ifadeler kullanarak yapılandırılmış veri çıkarır
- Güven puanlama: tanıma güvenine dayanarak sonuçları doğrulama
Çıktı
Tüm Makbuz İçeriğini Nasıl Çıkarırım?
Korunan biçimlendirme ile tam makbuz içeriğini çıkarın:
using IronOcr;
using System;
using System.Linq;
class WholeReceiptExtractor
{
static void Main()
{
var ocr = new IronTesseract();
// Configure for receipt scanning
ocr.Configuration.ReadBarCodes = true; // Enable barcode detection
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5; // Use latest engine
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm; // Best accuracy
using (var input = new OcrInput(@"r3.png"))
{
// Apply automatic image correction
input.WithTitle("Receipt Scan");
// Use computer vision to find text regions
var textRegions = input.FindTextRegions();
Console.WriteLine($"Found {textRegions.Count()} text regions");
// Apply optimal filters for receipt processing
input.ApplyOcrInputFilters();
// Perform OCR on the entire receipt
var result = ocr.Read(input);
// Display extracted text
Console.WriteLine("=== EXTRACTED RECEIPT TEXT ===");
Console.WriteLine(result.Text);
// Get detailed results
Console.WriteLine($"\n=== OCR STATISTICS ===");
Console.WriteLine($"OCR Confidence: {result.Confidence:F2}%");
Console.WriteLine($"Pages Processed: {result.Pages.Length}");
Console.WriteLine($"Paragraphs Found: {result.Paragraphs.Length}");
Console.WriteLine($"Lines Detected: {result.Lines.Length}");
Console.WriteLine($"Words Recognized: {result.Words.Length}");
// Extract any barcodes found
if (result.Barcodes.Any())
{
Console.WriteLine("\n=== BARCODES DETECTED ===");
foreach(var barcode in result.Barcodes)
{
Console.WriteLine($"Type: {barcode.Type}");
Console.WriteLine($"Value: {barcode.Value}");
Console.WriteLine($"Location: X={barcode.X}, Y={barcode.Y}");
}
}
// Save as searchable PDF
result.SaveAsSearchablePdf("receipt_searchable.pdf");
Console.WriteLine("\nSearchable PDF saved as: receipt_searchable.pdf");
// Export as hOCR for preservation
result.SaveAsHocrFile("receipt_hocr.html");
Console.WriteLine("hOCR file saved as: receipt_hocr.html");
}
}
}
using IronOcr;
using System;
using System.Linq;
class WholeReceiptExtractor
{
static void Main()
{
var ocr = new IronTesseract();
// Configure for receipt scanning
ocr.Configuration.ReadBarCodes = true; // Enable barcode detection
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5; // Use latest engine
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm; // Best accuracy
using (var input = new OcrInput(@"r3.png"))
{
// Apply automatic image correction
input.WithTitle("Receipt Scan");
// Use computer vision to find text regions
var textRegions = input.FindTextRegions();
Console.WriteLine($"Found {textRegions.Count()} text regions");
// Apply optimal filters for receipt processing
input.ApplyOcrInputFilters();
// Perform OCR on the entire receipt
var result = ocr.Read(input);
// Display extracted text
Console.WriteLine("=== EXTRACTED RECEIPT TEXT ===");
Console.WriteLine(result.Text);
// Get detailed results
Console.WriteLine($"\n=== OCR STATISTICS ===");
Console.WriteLine($"OCR Confidence: {result.Confidence:F2}%");
Console.WriteLine($"Pages Processed: {result.Pages.Length}");
Console.WriteLine($"Paragraphs Found: {result.Paragraphs.Length}");
Console.WriteLine($"Lines Detected: {result.Lines.Length}");
Console.WriteLine($"Words Recognized: {result.Words.Length}");
// Extract any barcodes found
if (result.Barcodes.Any())
{
Console.WriteLine("\n=== BARCODES DETECTED ===");
foreach(var barcode in result.Barcodes)
{
Console.WriteLine($"Type: {barcode.Type}");
Console.WriteLine($"Value: {barcode.Value}");
Console.WriteLine($"Location: X={barcode.X}, Y={barcode.Y}");
}
}
// Save as searchable PDF
result.SaveAsSearchablePdf("receipt_searchable.pdf");
Console.WriteLine("\nSearchable PDF saved as: receipt_searchable.pdf");
// Export as hOCR for preservation
result.SaveAsHocrFile("receipt_hocr.html");
Console.WriteLine("hOCR file saved as: receipt_hocr.html");
}
}
}
Imports IronOcr
Imports System
Imports System.Linq
Class WholeReceiptExtractor
Shared Sub Main()
Dim ocr = New IronTesseract()
' Configure for receipt scanning
ocr.Configuration.ReadBarCodes = True ' Enable barcode detection
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5 ' Use latest engine
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm ' Best accuracy
Using input = New OcrInput("r3.png")
' Apply automatic image correction
input.WithTitle("Receipt Scan")
' Use computer vision to find text regions
Dim textRegions = input.FindTextRegions()
Console.WriteLine($"Found {textRegions.Count()} text regions")
' Apply optimal filters for receipt processing
input.ApplyOcrInputFilters()
' Perform OCR on the entire receipt
Dim result = ocr.Read(input)
' Display extracted text
Console.WriteLine("=== EXTRACTED RECEIPT TEXT ===")
Console.WriteLine(result.Text)
' Get detailed results
Console.WriteLine(vbCrLf & "=== OCR STATISTICS ===")
Console.WriteLine($"OCR Confidence: {result.Confidence:F2}%")
Console.WriteLine($"Pages Processed: {result.Pages.Length}")
Console.WriteLine($"Paragraphs Found: {result.Paragraphs.Length}")
Console.WriteLine($"Lines Detected: {result.Lines.Length}")
Console.WriteLine($"Words Recognized: {result.Words.Length}")
' Extract any barcodes found
If result.Barcodes.Any() Then
Console.WriteLine(vbCrLf & "=== BARCODES DETECTED ===")
For Each barcode In result.Barcodes
Console.WriteLine($"Type: {barcode.Type}")
Console.WriteLine($"Value: {barcode.Value}")
Console.WriteLine($"Location: X={barcode.X}, Y={barcode.Y}")
Next
End If
' Save as searchable PDF
result.SaveAsSearchablePdf("receipt_searchable.pdf")
Console.WriteLine(vbCrLf & "Searchable PDF saved as: receipt_searchable.pdf")
' Export as hOCR for preservation
result.SaveAsHocrFile("receipt_hocr.html")
Console.WriteLine("hOCR file saved as: receipt_hocr.html")
End Using
End Sub
End Class
Makbuz tarama API çıkışı
Makbuz Tarama Üzerinde İyileştiren Gelişmiş Özellikler Nelerdir?
IronOCR, makbuz tarama doğruluğunu önemli ölçüde iyileştiren birkaç gelişmiş özellik sunar:
IronOCR Hangi Dilleri Destekler?
- Çok Dilli Destek: 125+ dilde veya tek bir belgede birden fazla dilde makbuz işleyin.
IronOCR, Makbuzlardaki Barkodları Okuyabilir mi?
- Barkod Okuma: barkodları ve QR kodlarını otomatik olarak algılayıp okuyun.
Bilgisayarla Görme Makbuz İşlemeye Nasıl Yardımcı Olur?
- Bilgisayarla Görme: OCR öncesi metin bölgelerini belirlemek için ilerlemiş metin algılama kullanın.
Özel Makbuz Formatları için Özel Modeller Eğitimini Yapabilir miyim?
- Özel Eğitim: Özelleştirilmiş makbuz formatları için özel yazı tiplerini eğitin.
Toplu İşleme Performansını Nasıl İyileştirebilirim?
- Performans Optimizasyonu: Toplu işlemler için çoklama ve eşzamanlı işlem uygulayın.
// Example: Async receipt processing for high-volume scenarios
using IronOcr;
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.IO;
class BulkReceiptProcessor
{
static async Task Main()
{
var ocr = new IronTesseract();
// Configure for optimal performance
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
ocr.Configuration.UseMultiThreading = true;
ocr.Configuration.ProcessorCount = Environment.ProcessorCount;
// Process multiple receipts asynchronously
var receiptFiles = Directory.GetFiles(@"C:\Receipts\", "*.jpg");
var tasks = new List<Task<OcrResult>>();
foreach (var file in receiptFiles)
{
tasks.Add(ProcessReceiptAsync(ocr, file));
}
// Wait for all receipts to be processed
var results = await Task.WhenAll(tasks);
// Aggregate results
decimal totalAmount = 0;
foreach (var result in results)
{
// Extract total from each receipt
var match = System.Text.RegularExpressions.Regex.Match(
result.Text, @"Total:?\s*\$?(\d+\.\d{2})");
if (match.Success && decimal.TryParse(match.Groups[1].Value, out var amount))
{
totalAmount += amount;
}
}
Console.WriteLine($"Processed {results.Length} receipts");
Console.WriteLine($"Combined total: ${totalAmount:F2}");
}
static async Task<OcrResult> ProcessReceiptAsync(IronTesseract ocr, string filePath)
{
using (var input = new OcrInput(filePath))
{
// Apply preprocessing
input.DeNoise();
input.Deskew();
input.EnhanceResolution(200);
// Process asynchronously
return await ocr.ReadAsync(input);
}
}
}
// Example: Async receipt processing for high-volume scenarios
using IronOcr;
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.IO;
class BulkReceiptProcessor
{
static async Task Main()
{
var ocr = new IronTesseract();
// Configure for optimal performance
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
ocr.Configuration.UseMultiThreading = true;
ocr.Configuration.ProcessorCount = Environment.ProcessorCount;
// Process multiple receipts asynchronously
var receiptFiles = Directory.GetFiles(@"C:\Receipts\", "*.jpg");
var tasks = new List<Task<OcrResult>>();
foreach (var file in receiptFiles)
{
tasks.Add(ProcessReceiptAsync(ocr, file));
}
// Wait for all receipts to be processed
var results = await Task.WhenAll(tasks);
// Aggregate results
decimal totalAmount = 0;
foreach (var result in results)
{
// Extract total from each receipt
var match = System.Text.RegularExpressions.Regex.Match(
result.Text, @"Total:?\s*\$?(\d+\.\d{2})");
if (match.Success && decimal.TryParse(match.Groups[1].Value, out var amount))
{
totalAmount += amount;
}
}
Console.WriteLine($"Processed {results.Length} receipts");
Console.WriteLine($"Combined total: ${totalAmount:F2}");
}
static async Task<OcrResult> ProcessReceiptAsync(IronTesseract ocr, string filePath)
{
using (var input = new OcrInput(filePath))
{
// Apply preprocessing
input.DeNoise();
input.Deskew();
input.EnhanceResolution(200);
// Process asynchronously
return await ocr.ReadAsync(input);
}
}
}
Imports IronOcr
Imports System
Imports System.Threading.Tasks
Imports System.Collections.Generic
Imports System.IO
Imports System.Text.RegularExpressions
Module BulkReceiptProcessor
Sub Main()
MainAsync().GetAwaiter().GetResult()
End Sub
Private Async Function MainAsync() As Task
Dim ocr As New IronTesseract()
' Configure for optimal performance
ocr.Configuration.TesseractVersion = TesseractVersion.Tesseract5
ocr.Configuration.UseMultiThreading = True
ocr.Configuration.ProcessorCount = Environment.ProcessorCount
' Process multiple receipts asynchronously
Dim receiptFiles = Directory.GetFiles("C:\Receipts\", "*.jpg")
Dim tasks As New List(Of Task(Of OcrResult))()
For Each file In receiptFiles
tasks.Add(ProcessReceiptAsync(ocr, file))
Next
' Wait for all receipts to be processed
Dim results = Await Task.WhenAll(tasks)
' Aggregate results
Dim totalAmount As Decimal = 0
For Each result In results
' Extract total from each receipt
Dim match = Regex.Match(result.Text, "Total:?\s*\$?(\d+\.\d{2})")
If match.Success AndAlso Decimal.TryParse(match.Groups(1).Value, totalAmount) Then
totalAmount += totalAmount
End If
Next
Console.WriteLine($"Processed {results.Length} receipts")
Console.WriteLine($"Combined total: ${totalAmount:F2}")
End Function
Private Async Function ProcessReceiptAsync(ocr As IronTesseract, filePath As String) As Task(Of OcrResult)
Using input As New OcrInput(filePath)
' Apply preprocessing
input.DeNoise()
input.Deskew()
input.EnhanceResolution(200)
' Process asynchronously
Return Await ocr.ReadAsync(input)
End Using
End Function
End Module
Yaygın Makbuz Tarama Zorluklarını Nasıl Ele Alırım?
Makbuz taraması, IronOCR'un yardımcı olduğu benzersiz zorluklar sunar:
Düşük Kaliteli Makbuz Görüntüleriyle Nasıl Başa Çıkılır?
- Düşük Kaliteli Görüntüler: Otomatik olarak en uygun ön işlem ayarlarını bulmak için Filtre Sihirbazı kullanın.
Bozuk veya Döndürülmüş Makbuzlara Ne Yapmalı?
- Bozuk veya Döndürülmüş Makbuzlar: Otomatik sayfa döndürme algılama uygun yönlendirmeyi sağlar.
Soluk veya Düşük Kontrastlı Makbuzları Nasıl İşleyebilirim?
- Soluk veya Düşük Kontrastlı Metin: Renk düzeltme ve geliştirme filtreleri uygulayın.
IronOCR Kırışık veya Hasarlı Makbuzları İşleyebilir mi?
- Kırışık veya Hasarlı Makbuzlar: Zorlu görüntülerden metinleri geri kazanmak için gelişmiş ön işlem yapılır.
Farklı Makbuz Formatları ve Düzenlemeleri Nasıl Yönetebilirim?
Makbuz formatları perakendeciler arasında büyük farklılıklar gösterir. IronOCR esnek yaklaşımlar sunar:
using IronOcr;
using System;
using System.Collections.Generic;
using System.Linq;
class ReceiptLayoutHandler
{
static void Main()
{
var ocr = new IronTesseract();
// Configure for different receipt layouts
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd;
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
using (var input = new OcrInput(@"complex_receipt.jpg"))
{
// Apply region-specific processing
var cropRegion = new CropRectangle(x: 0, y: 100, width: 400, height: 800);
input.AddImage(@"complex_receipt.jpg", cropRegion);
// Process with confidence tracking
var result = ocr.Read(input);
// Parse using confidence scores
var highConfidenceLines = result.Lines
.Where(line => line.Confidence > 85)
.Select(line => line.Text)
.ToList();
// Extract data with fallback strategies
var total = ExtractTotal(highConfidenceLines)
?? ExtractTotalAlternative(result.Text);
Console.WriteLine($"Receipt Total: {total}");
}
}
static decimal? ExtractTotal(List<string> lines)
{
// Primary extraction method
foreach (var line in lines)
{
if (line.Contains("TOTAL") &&
System.Text.RegularExpressions.Regex.IsMatch(line, @"\d+\.\d{2}"))
{
var match = System.Text.RegularExpressions.Regex.Match(line, @"(\d+\.\d{2})");
if (decimal.TryParse(match.Value, out var total))
return total;
}
}
return null;
}
static decimal? ExtractTotalAlternative(string fullText)
{
// Fallback extraction method
var pattern = @"(?:Total|TOTAL|Grand Total|Amount Due).*?(\d+\.\d{2})";
var match = System.Text.RegularExpressions.Regex.Match(fullText, pattern);
if (match.Success && decimal.TryParse(match.Groups[1].Value, out var total))
return total;
return null;
}
}
using IronOcr;
using System;
using System.Collections.Generic;
using System.Linq;
class ReceiptLayoutHandler
{
static void Main()
{
var ocr = new IronTesseract();
// Configure for different receipt layouts
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd;
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm;
using (var input = new OcrInput(@"complex_receipt.jpg"))
{
// Apply region-specific processing
var cropRegion = new CropRectangle(x: 0, y: 100, width: 400, height: 800);
input.AddImage(@"complex_receipt.jpg", cropRegion);
// Process with confidence tracking
var result = ocr.Read(input);
// Parse using confidence scores
var highConfidenceLines = result.Lines
.Where(line => line.Confidence > 85)
.Select(line => line.Text)
.ToList();
// Extract data with fallback strategies
var total = ExtractTotal(highConfidenceLines)
?? ExtractTotalAlternative(result.Text);
Console.WriteLine($"Receipt Total: {total}");
}
}
static decimal? ExtractTotal(List<string> lines)
{
// Primary extraction method
foreach (var line in lines)
{
if (line.Contains("TOTAL") &&
System.Text.RegularExpressions.Regex.IsMatch(line, @"\d+\.\d{2}"))
{
var match = System.Text.RegularExpressions.Regex.Match(line, @"(\d+\.\d{2})");
if (decimal.TryParse(match.Value, out var total))
return total;
}
}
return null;
}
static decimal? ExtractTotalAlternative(string fullText)
{
// Fallback extraction method
var pattern = @"(?:Total|TOTAL|Grand Total|Amount Due).*?(\d+\.\d{2})";
var match = System.Text.RegularExpressions.Regex.Match(fullText, pattern);
if (match.Success && decimal.TryParse(match.Groups[1].Value, out var total))
return total;
return null;
}
}
Imports IronOcr
Imports System
Imports System.Collections.Generic
Imports System.Linq
Class ReceiptLayoutHandler
Shared Sub Main()
Dim ocr = New IronTesseract()
' Configure for different receipt layouts
ocr.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd
ocr.Configuration.EngineMode = TesseractEngineMode.TesseractAndLstm
Using input = New OcrInput("complex_receipt.jpg")
' Apply region-specific processing
Dim cropRegion = New CropRectangle(x:=0, y:=100, width:=400, height:=800)
input.AddImage("complex_receipt.jpg", cropRegion)
' Process with confidence tracking
Dim result = ocr.Read(input)
' Parse using confidence scores
Dim highConfidenceLines = result.Lines _
.Where(Function(line) line.Confidence > 85) _
.Select(Function(line) line.Text) _
.ToList()
' Extract data with fallback strategies
Dim total = ExtractTotal(highConfidenceLines) _
OrElse ExtractTotalAlternative(result.Text)
Console.WriteLine($"Receipt Total: {total}")
End Using
End Sub
Shared Function ExtractTotal(lines As List(Of String)) As Decimal?
' Primary extraction method
For Each line In lines
If line.Contains("TOTAL") AndAlso _
System.Text.RegularExpressions.Regex.IsMatch(line, "\d+\.\d{2}") Then
Dim match = System.Text.RegularExpressions.Regex.Match(line, "(\d+\.\d{2})")
Dim total As Decimal
If Decimal.TryParse(match.Value, total) Then
Return total
End If
End If
Next
Return Nothing
End Function
Shared Function ExtractTotalAlternative(fullText As String) As Decimal?
' Fallback extraction method
Dim pattern = "(?:Total|TOTAL|Grand Total|Amount Due).*?(\d+\.\d{2})"
Dim match = System.Text.RegularExpressions.Regex.Match(fullText, pattern)
Dim total As Decimal
If match.Success AndAlso Decimal.TryParse(match.Groups(1).Value, total) Then
Return total
End If
Return Nothing
End Function
End Class
Makbuz Tarama API'leri Hakkında Hatırlamam Gereken Anahtar Çıkartmalar Nelerdir?
IronOCR gibi makbuz tarama API'leri, makbuzlardan veri çıkarımını otomatik hale getirmek için güvenilir çözümler sunar. Gelişmiş OCR teknolojisini kullanarak, işletmeler satıcı isimlerini, satın alma tarihlerini, madde listelerini, fiyatları, vergileri ve toplamları otomatik olarak çıkarabilir. Çoklu dil, para birimleri ve barkod desteği ile işletmeler, makbuz yönetimini basitleştirebilir, zaman tasarrufu sağlayabilir ve veri odaklı kararlar alabilir.
IronOCR, geliştiricilerin doğru ve verimli metin çıkarımı için ihtiyaç duyduğu araçları sunar, görev otomasyonunu ve verimliliği arttırır. Kütüphanenin tam özellik seti, çeşitli belge türleri için destek ve yakın zamanda yapılan %98 bellek azaltma gibi iyileştirmeleri içerir.
Ön koşulları karşılayıp IronOCR'u entegre ederek otomatik makbuz işleme faydalarını ortaya çıkarabilirsiniz. Kütüphanenin belgelendirmesi, örnekler ve sorun giderme kılavuzları sorunsuz bir uygulama sağlar.
Daha fazla bilgi için lisanslama sayfasını ziyaret edin veya C# Tesseract OCR eğitimini keşfedin.
Sıkça Sorulan Sorular
OCR kullanarak makbuz veri çıkarımını C#’da nasıl otomatikleştirebilirim?
C#’da IronOCR kullanarak makbuz veri çıkarımını otomatikleştirebilirsiniz, bu da makbuz görüntülerinden satır öğeleri, fiyatlandırmalar, vergiler ve toplam tutarlar gibi anahtar detayları yüksek doğrulukla çıkarmanıza olanak tanır.
C#’ta bir fatura tarama projesi kurmanın ön şartları nelerdir?
C#’ta bir fatura tarama projesi kurmak için, Visual Studio, temel C# programlama bilgisi ve projenizde kurulu IronOCR kütüphanesine ihtiyaçınız var.
NuGet Paket Yöneticisi'ni kullanarak Visual Studio'da OCR kütüphanesi nasıl kurulur?
Visual Studio'yu açın ve Araçlar > NuGet Paket Yöneticisi > Çözüm İçin NuGet Paketlerini Yönet yolunu izleyin, IronOCR'yi arayın ve projenizde kurun.
Visual Studio Komut Satırını kullanarak OCR kütüphanesini kurabilir miyim?
Evet, IronOCR'yi Visual Studio'daki Paket Yöneticisi Konsolunu açarak ve Install-Package IronOcr komutunu çalıştırarak kurabilirsiniz.
Tüm bir makbuzda OCR kullanarak metni nasıl çıkarırım?
Tüm makbuzdan metin çıkarmak için, IronOCR’yi kullanarak tam makbuz görüntüsünde OCR gerçekleştirin ve ardından çıkarılan metni C# kodu ile çıktı olarak verin.
Bir makbuz tarama API’si hangi yararları sağlar?
IronOCR gibi bir makbuz tarama API, veri çıkarımını otomatikleştirir, manuel hataları en aza indirir, üretkenliği artırır ve daha iyi iş kararları için harcama kalıplarına ilişkin içgörüler sağlar.
OCR kütüphanesi birden fazla dili ve para birimini destekliyor mu?
Evet, IronOCR birden fazla dili, para birimini ve makbuz formatını destekler, bu da onu küresel uygulamalar için ideal kılar.
OCR kütüphanesi görüntülerden metin çıkarmada ne kadar doğru?
IronOCR, gelişmiş OCR algoritmaları, bilgisayarlı görü ve makine öğrenimi modelleri kullanarak yüksek doğruluğu sağlar, zorlu senaryolarda bile.
OCR kullanarak makbuzlardan hangi tür veriler çıkarılabilir?
IronOCR, satır öğeleri, fiyatlandırma, vergi tutarları, toplam tutarlar ve diğer makbuz detayları gibi verileri çıkarabilir.
Makbuz ayrıştırmasının otomasyonu iş süreçlerini nasıl iyileştirir?
IronOCR ile makbuz ayrıştırmasını otomatikleştirmek, iş süreçlerini manuel girdiyi azaltarak, doğru veri toplamaya izin vererek ve veri temelli karar almaya olanak tanıyarak iyileştirir.



