Service: Rapid OCR API - EyevinnOSC/community GitHub Wiki

Rapid OCR API

Rapid OCR API (serviceId rapidai-rapidocrapi) is a fast, lightweight REST service that converts images to text with optical character recognition. It wraps RapidOCR in a FastAPI application. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance. License: Apache-2.0. Source: RapidAI/RapidOCRAPI.

What it can do

  • Extract text from an image sent as a file upload or as a base64-encoded string.
  • Return, for each recognised text region, the text, its bounding box and a confidence score.
  • Expose interactive API documentation (Swagger UI) at /docs.

Creating an instance

There are no dependencies and no options beyond the name. Call create-service-instance with serviceId: "rapidai-rapidocrapi":

{ "name": "myocr" }

Wait with wait-for-service-ready (or get-instance-status) and read the instance URL with describe-service-instance. With the OSC CLI:

osc create rapidai-rapidocrapi myocr

Options

Option Required Type Meaning
name Yes string Name of the instance. Alphanumeric/word characters only (^\w+$), at most 20 characters.

The service has no other options.

Using the instance

Upload an image file to the /ocr endpoint (multipart form field image_file):

curl -s -X POST https://<instance-url>/ocr -F [email protected]

Or send a base64-encoded image in the form field image_data:

import base64, requests

with open("screenshot.png", "rb") as f:
    b64 = base64.b64encode(f.read()).decode()

response = requests.post("https://<instance-url>/ocr", data={"image_data": b64})
print(response.json())

The JSON response maps an index to an object with rec_txt (recognised text), dt_boxes (bounding box) and score (confidence). The optional form fields use_det, use_cls and use_rec (booleans) switch the detection, classification and recognition stages on or off. The root path / returns a welcome message and /docs serves the Swagger UI. This API description comes from the upstream source code (rapidocr_api/main.py).

Limitations

  • Upstream does not handle concurrent requests across multiple processes; it is aimed at fast, simple access to RapidOCR.
  • Upload size limits in the upstream server: 20 MB per file and 10 MB per form field.

Resources