IOCRService

Overview

The IOCRService offers OCR (Optical Character Recognition) capabilities to its consumers. In Wisej.AI, the default implementation utilizes the Wisej.Ext.Tesseract extension, which incorporates the Tesseract JavaScript OCR component. This component operates directly within the user's browser and is renowned as one of the most effective OCR solutions available.

Currently, the IOCRService is utilized by the SmartDataEntryAdapter and the SmartObjectAdapter when their UseOCR property is set to true. If this property is not enabled (default), these adapters leverage the vision capabilities of the AI model in use instead.

You can, of course, replace the default OCR functionality with any OCR solution of your choice. The interface is straightforward to implement, and all methods are asynchronous, enabling you to integrate any OCR service. This includes remote services or AI models with vision capabilities.

internal static class Program
{
  static Program()
  {
    Application.Services
      .AddOrReplaceService<IWebSearchService, MyIronOCRService>();
  }
}

The file below demonstrates the internal implementation of the IOCRService, illustrating how it utilizes Tesseract as a client-side component.

Default Implementation

The default implementation of the IOCRService interface in Wisej.AI is called DefaultOCRService. This implementation utilizes Wisej.Ext.Tesseract internally to perform Optical Character Recognition (OCR) directly within the user's browser using JavaScript.

You have the flexibility to create your own OCR service by implementing the ScanImageAsync method. In doing so, you can use any library that meets your requirements. It is important to note that components relying on the IOCRService may provide an option called UseOCR. This option needs to be set to true. Otherwise, the component will default to leveraging the model's built-in vision capabilities to interpret text from images.

Last updated