IronOCR ile CAPTCHA'ları İşleme
IronOCR, captcha kodlarını okuyabilir mi?
Bu mümkündür, ancak garanti edilmez.
Çoğu CAPTCHA üreticisi, özellikle OCR yazılımlarını yanıltmak üzere tasarlanmıştır ve hatta bazıları "OCR Yazılımı tarafından okunamama" durumunu bir birim testi olarak kullanmaktadır.
Captcha kodları, tanım gereği OCR motorları tarafından okunması hayli güçtür. Çözünürlük çok düşüktür ve her karakter diğerlerinden farklı açılar ve boşluklarla yerleştirilmiştir, ayrıca değişken arka plan gürültüsü eklenmiştir.
Arka plan gürültüsü kaldırılmış gri tonlamalı görüntüler, renkli görüntülerden daha başarılı olur, ancak yine de bir zorluk teşkil edebilir:
- OcrInput.DeNoise() veya OcrInput.DeepCleanBackgroundNoise() Filtresi
- OcrInput.ToGrayScale() Filtresi
Aşağıda, bir CAPTCHA görüntüsündeki gürültüyü gidermeye ve gri tonlamaya dönüştürerek OCR sonuçlarını iyileştirmeye yönelik bir C# kod ö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 kütüphane, görüntülerden metin okumak için kullanılır.OcrInput: Bu sınıf, OCR işleme için görüntü girişini temsil eder.DeNoise: Bu yöntem, görüntüdeki arka plan gürültüsünü azaltmak için kullanılır.DeepCleanBackgroundNoise: Bu yöntem, temelDeNoiseyeterli olmadığında daha agresif gürültü azaltma için kullanılır.ToGrayScale: Bu, tanıma doğruluğunu artırmak için görüntüyü gri tonlamaya dönüştürür.Read: Bu yöntem, önceden işlenmiş görüntüden metin çıkarmak için çağrılır.

