performOcr

fun performOcr(imageBytes: ByteArray, mode: String, options: Map<String, String> = emptyMap()): String

Performs OCR directly on the given image bytes, returning a JSON result.

Called by AiProxy for external OCR requests — Tesseract runs in-process (JNI) so there is no HTTP server to forward to, unlike LLAMA or Whisper.

Return

A JSON string with the OCR result.

Parameters

imageBytes

The raw image bytes (PNG, JPEG, etc.).

mode

The OCR mode: print, extract, verify, or extract fields.

options

Additional options: pattern, regex_flags, rotate, preprocess, field_patterns.