Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OCRClient

High-level async API for performing document image layout analysis and OCR.

In the browser, this class can be constructed directly. In Node, use the createOCRClient helper from node-worker.js.

Hierarchy

  • OCRClient

Index

Constructors

  • Initialize an OCR engine.

    This will start a Worker in which the OCR operations will actually be performed.

    Parameters

    Returns OCRClient

Methods

  • clearImage(): Promise<void>
  • Clear the current image and text recognition results.

    This will clear the loaded image data internally, but keep the text recognition model loaded.

    At present there is no way to shrink WebAssembly memory, so this will not return the memory used by the image to the OS/browser. To release memory, the web worker needs to be shut down via destroy.

    Returns Promise<void>

  • destroy(): Promise<void>
  • Perform layout analysis on the current image, if not already done, and return bounding boxes for a given unit of text.

    This operation is relatively cheap compared to text recognition, so can provide much faster results if only the location of lines/words etc. on the page is required, not the text content.

    Parameters

    Returns Promise<BoxItem[]>

  • Perform layout analysis and text recognition on the current image, if not already done, and return the image's text as a string.

    Parameters

    Returns Promise<string>

  • Perform layout analysis and text recognition on the current image, if not already done, and return bounding boxes and text content for a given unit of text.

    Parameters

    Returns Promise<TextItem[]>

  • loadImage(image: ImageBitmap | ImageData): Promise<void>
  • Load an image into the OCR engine for processing.

    Parameters

    • image: ImageBitmap | ImageData

    Returns Promise<void>

  • loadModel(model: string | ArrayBuffer): Promise<void>
  • Load a trained model for a specific language. This can be specified either as a URL to fetch or a buffer containing an already-loaded model.

    Parameters

    • model: string | ArrayBuffer

    Returns Promise<void>

Generated using TypeDoc