DefaultOCRService

Wisej.AI.Services.DefaultOCRService

Namespace: Wisej.AI.Services

Assembly: Wisej.AI (3.5.0.0)

Represents a default implementation of the IOCRService interface using Tesseract for Optical Character Recognition (OCR).

public class DefaultOCRService : IOCRService, IDisposable

Constructors

DefaultOCRService()

Initializes a new instance of the DefaultOCRService class.

Properties

Language

CultureInfo: Gets or sets the language used for OCR processing.

The language should be specified as a CultureInfo object. If the language is not set, the default language used is English ("eng").

Methods

Dispose()

Releases all resources used by the DefaultOCRService.

This method should be called when the service is no longer needed to free up resources.

ScanImageAsync(image)

Scans an image and performs OCR to extract text from it.

Parameter
Type
Description

image

The image to be scanned. It should be a valid Image object. Defaults to null.

Returns: Task<String>. A Task representing the asynchronous operation, with the recognized text as the result.

This method performs OCR on the provided image using the specified language set in the Language property. If the language is not set, English is used by default. Example usage:


DefaultOCRService ocrService = new DefaultOCRService
{
Language = new CultureInfo("eng")
};
Image image = Image.FromFile("sample.png");
string text = await ocrService.ScanImageAsync(image);
Console.WriteLine(text);

Throws:

ScanImageAsync(imageUrl)

Asynchronously scans an image from a URL and returns the recognized text.

Parameter
Type
Description

imageUrl

The URL of the image to be scanned for text recognition. This parameter is not optional.

Returns: Task<String>. A task representing the asynchronous operation, with the recognized text as the result.

This method retrieves an image from the provided URL and utilizes the Tesseract OCR engine to recognize text. The language used for OCR is specified by the Language property. Example usage:


var ocrService = new DefaultOCRService();
ocrService.Language = new CultureInfo("eng");
string recognizedText = await ocrService.ScanImageAsync("http://example.com/image.jpg");
Console.WriteLine(recognizedText);

Throws:

Implements

Name
Description

Represents an OCR (Optical Character Recognition) service that can scan images and extract text using a specified language.

Last updated