OCR and image reports

Image moderation assesses visual content and readable text. Enable the optional OCR processing feature with processingOptions.features.ocr.enabled: true per upload to extract and moderate text separately. The text moderation result contributes to the image’s combined report. Use it for screenshots, signs and memes; poor legibility or layout can still cause recognition errors.

{
  "processingOptions": {
    "features": {
      "ocr": { "enabled": true }
    }
  }
}

When OCR is disabled

With OCR off (the default, when the request doesn't turn it on), the image is evaluated directly, including text the visual model can read. Image qualifiers carry the same Some and All scores as text, so allowances and restrictions apply to images as they do to text. For clearly readable written content, the category boundaries match text moderation, but the scores need not match numerically: image recognition, layout, visual evidence and model uncertainty can change the result. Enable OCR to assess extracted text separately as well.

When OCR is enabled

With processingOptions.features.ocr.enabled set to true, non-empty extracted text receives an additional normal text moderation pass. Its result is merged into the image report before the project's policy is applied. No separate text asset is created.

The extracted text is kept only when the upload sets retainContent; otherwise content.extractedText is null once processing finishes. When it is kept, retrieve the image to read content.extractedText, or open its extracted-text section in the portal. Small text is inline as { "type": "string", "content": "…" }; larger text is a document reference with type: "document" and an id. The API doesn't return the text while the image is under a safety or copyright hold. Removing or purging the image's content also removes its extracted text. The combined classification.moderation remains available after content removal. Reclassification replaces the image's extracted text.

OCR extraction and moderation are separately metered: the OCR request increments OCR usage on the image, and non-empty extracted text incurs normal text-moderation tokens on the image. Combining the two reports does not run or bill text moderation again.

Merged reports combine the two results field by field:

FieldMerged result
Parent category scoreThe higher evaluated score.
Qualifier Some scoreThe highest supported score across the image and the extracted text.
Qualifier All scoreThe lowest supported score, capped by Some. Missing All evidence stays unavailable and can't establish coverage.
Parent evaluation statusevaluated if either report evaluated it directly, partial if only a narrower signal was evaluated.

Category evidence below 0.1 doesn't contribute to qualifier merging. Because qualifiers are merged this way, an allowance that covers the visual content can't exempt a separate current threat in the extracted text, and the reverse also holds.

If OCR returns no non-whitespace text, content.extractedText is null and only the direct image classification result is used. If OCR extraction or moderation of the extracted text fails, image processing fails: CalmLens doesn't replace failed text moderation with an allowed text result or a completed visual-only decision.

Text regions

OCR also records where text sits in the image, in classification.ocr. When OCR ran, its status is evaluated and textRegions holds approximate boxes around detected text lines. Lines containing a detected email address, phone number, payment card number, IBAN or US social security number are marked personalInformation: true. Boxes are fractions of the image width and height, and textRegions is empty for an image without text. When OCR couldn't run on the image, status is not-evaluated with a reason: not-supported or unavailable, or for a document or website in-children, whose images hold their own results (see OCR in documents and websites). An image reported as unavailable can still have content.extractedText: its text was read, but where it sits wasn't recorded. classification.ocr is null when OCR wasn't requested, and for a signed test image, which skips OCR (see Testing).

OCR in documents and websites

OCR reads the images of a document or website as it reads an uploaded image: each image the document holds, and each page or slide rendered to be moderated as it appears, such as a scanned page, is a child asset that inherits the upload's processingOptions. Each child's classification.ocr holds its text regions, personal information included, with boxes as fractions of that child image, and its content.extractedText holds the text when the upload keeps its content. The document's own text is read from the file into its text child, which has no OCR result.

The document or website reports classification.ocr as not-evaluated with reason in-children, which says that its results are on its children. List them with GET /assets/:assetId/children; a child's parentPages names the pages it shows, numbered from 1, such as [2, 3] for a letterhead drawn on pages 2 and 3, and is empty when the page isn't known, as for an image read from a Word file without laying out its pages.

{
  "id": "asset_…",
  "parentId": "asset_…",
  "parentPages": [1],
  "type": "image",
  "classification": {
    "ocr": {
      "status": "evaluated",
      "textRegions": [
        { "box": { "left": 0.1, "top": 0.1, "width": 0.8, "height": 0.2 }, "personalInformation": false },
        { "box": { "left": 0.1, "top": 0.5, "width": 0.4, "height": 0.05 }, "personalInformation": true }
      ]
    }
  }
}

Link detection finds links in every image by default. Set processingOptions.features.linkDetection.enabled to false to skip it for an upload. It decodes up to five QR codes and lists them in classification.linkDetection.qrCodes, each with its contents and position. CalmLens moderates the decoded contents as text and merges the findings into the image report.

classification.linkDetection.links lists the web links found. The source is qr-code for QR links and text for links in the OCR text when OCR is enabled. Link detection extracts the URL as written, adding https:// when the image leaves out the scheme, with no redirects or destination verdicts. Your app can use the extracted URLs for its own domain rules. Link detection is free. Moderating QR code contents bills text-moderation tokens like OCR text.

If your app requires an approved destination, parse the hostname and hold a submission for review when the detected address is incomplete or ambiguous. The project's Accepted domains applies when CalmLens downloads a file or website submitted by URL. Apply your publication rules to the links found inside content in your own integration.

Last updated

Cookies on CalmLens

We use essential cookies for sign-in and security. With your permission, functional cookies remember your preferences and Google Analytics measures website use and signups. Optional ad measurement cookies link Google ad clicks to signups. Personalised advertising stays off. Manage cookies