IronOCR ile CAPTCHAları İşleme
IronOCR captcha kodlarını okuyacak mı?
Bu mümkün, ancak garanti değil.
Çoğu CAPTCHA üreticisini, özellikle Tesseract gibi OCR yazılımını yanıltmak için tasarlanmış olup, "OCR Yazılımı Tarafından Okunamama Hatası" gibi birim testi olarak kullanılır.
Captcha kodları, tanımı gereği OCR motorlarının okuması çok zordur. Çözünürlük çok düşüktür ve her bir karakter diğerlerinden farklı açılar ve boşluklarla özel olarak düzenlenmiştir ve değişken arka plan gürültüsü eklenmiştir.
Arka plan gürültüsü çıkarılan gri tonlamalı görüntüler, renkli görüntülerden daha başarılıdır, ancak yine de bir zorluk teşkil edebilir:
- OcrInput.DeNoise() veya OcrInput.DeepCleanBackgroundNoise() Filtresi
- OcrInput.ToGrayScale() Filtresi
Aşağıda, gürültüyü kaldırmaya ve OCR sonuçlarını iyileştirmek için bir CAPTCHA görüntüsünü gri tonlamaya dönüştürmeye çalışan bir C# kodu örneği bulunmaktadır:
using IronOcr;
class CaptchaReader
{
static void Main(string[] args)
{
// Initialize the IronOCR engine
var Ocr = new IronTesseract();
// Create an OCR input object
var Input = new OcrInput("captcha-image.jpg");
// Apply noise reduction to improve OCR accuracy
// This removes background noise while preserving text
Input.DeNoise();
// Optionally apply a deep clean for more aggressive noise removal
Input.DeepCleanBackgroundNoise();
// Convert the image to grayscale
// OCR works better on grayscale images compared to colored ones
Input.ToGrayScale();
// Perform OCR to extract text from the image
var Result = Ocr.Read(Input);
// Output the recognized text to the console
Console.WriteLine(Result.Text);
}
}
using IronOcr;
class CaptchaReader
{
static void Main(string[] args)
{
// Initialize the IronOCR engine
var Ocr = new IronTesseract();
// Create an OCR input object
var Input = new OcrInput("captcha-image.jpg");
// Apply noise reduction to improve OCR accuracy
// This removes background noise while preserving text
Input.DeNoise();
// Optionally apply a deep clean for more aggressive noise removal
Input.DeepCleanBackgroundNoise();
// Convert the image to grayscale
// OCR works better on grayscale images compared to colored ones
Input.ToGrayScale();
// Perform OCR to extract text from the image
var Result = Ocr.Read(Input);
// Output the recognized text to the console
Console.WriteLine(Result.Text);
}
}
Imports IronOcr
Friend Class CaptchaReader
Shared Sub Main(ByVal args() As String)
' Initialize the IronOCR engine
Dim Ocr = New IronTesseract()
' Create an OCR input object
Dim Input = New OcrInput("captcha-image.jpg")
' Apply noise reduction to improve OCR accuracy
' This removes background noise while preserving text
Input.DeNoise()
' Optionally apply a deep clean for more aggressive noise removal
Input.DeepCleanBackgroundNoise()
' Convert the image to grayscale
' OCR works better on grayscale images compared to colored ones
Input.ToGrayScale()
' Perform OCR to extract text from the image
Dim Result = Ocr.Read(Input)
' Output the recognized text to the console
Console.WriteLine(Result.Text)
End Sub
End Class
Açıklama:
IronOcr: Bu kutuphane, görüntülerden metin okumak icin kullanilir.OcrInput: Bu sınıf, OCR işleme icin görüntü girdisini temsil eder.DeNoise: Bu yöntem, görüntüdeki arka plan gurultusunu azaltmak icin kullanilir.DeepCleanBackgroundNoise: Bu yöntem, temelDeNoiseyeterli degilse daha agresif gurultu azaltma icin kullanilir.ToGrayScale: Bu, tanima dogrulugunu arttirmak icin görüntüyu gri tonlamaya cevirir.Read: Bu yöntem, islenmis görüntüden metin cikarmak icin cagirilir.

