Skip to main content
Version: 0.10.0

Function: useOpticalCharacterRecognizer()

useOpticalCharacterRecognizer(config, options?): object

Defined in: hooks/useOpticalCharacterRecognizer.ts:21

React hook for the PP-OCRv6 pipeline.

It downloads and loads the model, tracks progress and errors, instantiates the task runner, and cleans up native memory on unmount or config change. Heavy work runs on a worklet thread; recognizeCharacters resolves with the recognized regions in reading order.

For imperative usage, see createPaddleOcr.

Parameters​

config​

PaddleOcrModel

OCR model configuration. Use a preset from models.ocr.*.

options?​

ResourceOptions

Load and caching options. See ResourceOptions.

Returns​

object

The same object as PaddleOcr (without dispose), combined with loading state, download progress, and resource info.

downloadProgress​

downloadProgress: number

error​

error: Error | undefined

isReady​

isReady: boolean = !!model

recognizeCharacters​

recognizeCharacters: (input, options?) => Promise<OcrDetection[]> | undefined = model.recognizeCharacters

recognizeCharactersWorklet​

recognizeCharactersWorklet: (input, options?) => OcrDetection[] | undefined = model.recognizeCharactersWorklet

resource​

resource: PaddleOcrModel | undefined

See​

PaddleOcr